mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-13 21:35:39 +00:00
Bug 786826 - Use SharedPrefs.commit in WebAppAllocator for Eclair compatibility r=mfinkle
This commit is contained in:
parent
501256d2ba
commit
99e3cf44fb
@ -15,6 +15,7 @@ import android.util.Log;
|
||||
import java.io.FileOutputStream;
|
||||
|
||||
import org.mozilla.gecko.gfx.BitmapUtils;
|
||||
import org.mozilla.gecko.util.GeckoBackgroundThread;
|
||||
|
||||
public class WebAppAllocator {
|
||||
private final String LOGTAG = "GeckoWebAppAllocator";
|
||||
@ -67,25 +68,30 @@ public class WebAppAllocator {
|
||||
return findAndAllocateIndex(app, name, bitmap);
|
||||
}
|
||||
|
||||
public synchronized int findAndAllocateIndex(String app, String name, Bitmap aIcon) {
|
||||
public synchronized int findAndAllocateIndex(final String app, final String name, final Bitmap aIcon) {
|
||||
int index = getIndexForApp(app);
|
||||
if (index != -1)
|
||||
return index;
|
||||
|
||||
int color = 0;
|
||||
try {
|
||||
color = BitmapUtils.getDominantColor(aIcon);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
for (int i = 0; i < MAX_WEB_APPS; ++i) {
|
||||
if (!mPrefs.contains(appKey(i))) {
|
||||
// found unused index i
|
||||
mPrefs.edit()
|
||||
.putString(appKey(i), app)
|
||||
.putInt(iconKey(i), color)
|
||||
.apply();
|
||||
final int foundIndex = i;
|
||||
GeckoBackgroundThread.getHandler().post(new Runnable() {
|
||||
public void run() {
|
||||
int color = 0;
|
||||
try {
|
||||
color = BitmapUtils.getDominantColor(aIcon);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
mPrefs.edit()
|
||||
.putString(appKey(foundIndex), app)
|
||||
.putInt(iconKey(foundIndex), color)
|
||||
.commit();
|
||||
}
|
||||
});
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user