mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-03-05 18:36:49 +00:00
Using persisted item storage for install queue.
Shared prefs are loaded during startup and should avoid large objects Change-Id: Ibb5c8307dbccb9414b42454825e6c3c2a972efa6
This commit is contained in:
@@ -68,8 +68,7 @@ public class PersistedItemArray<T extends ItemInfo> {
|
||||
*/
|
||||
@WorkerThread
|
||||
public void write(Context context, List<T> items) {
|
||||
AtomicFile file = new AtomicFile(context.getFileStreamPath(mFileName));
|
||||
|
||||
AtomicFile file = getFile(context);
|
||||
FileOutputStream fos;
|
||||
try {
|
||||
fos = file.startWrite();
|
||||
@@ -124,9 +123,7 @@ public class PersistedItemArray<T extends ItemInfo> {
|
||||
@WorkerThread
|
||||
public List<T> read(Context context, ItemFactory<T> factory, LongFunction<UserHandle> userFn) {
|
||||
List<T> result = new ArrayList<>();
|
||||
AtomicFile file = new AtomicFile(context.getFileStreamPath(mFileName));
|
||||
|
||||
try (FileInputStream fis = file.openRead()) {
|
||||
try (FileInputStream fis = getFile(context).openRead()) {
|
||||
XmlPullParser parser = Xml.newPullParser();
|
||||
parser.setInput(new InputStreamReader(fis, StandardCharsets.UTF_8));
|
||||
|
||||
@@ -166,6 +163,13 @@ public class PersistedItemArray<T extends ItemInfo> {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the underlying file used for persisting data
|
||||
*/
|
||||
public AtomicFile getFile(Context context) {
|
||||
return new AtomicFile(context.getFileStreamPath(mFileName));
|
||||
}
|
||||
|
||||
/**
|
||||
* Interface to create an ItemInfo during parsing
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user