Loading packages/EasterEgg/src/com/android/egg/neko/NekoService.java +8 −0 Original line number Diff line number Diff line Loading @@ -102,6 +102,14 @@ public class NekoService extends JobService { return false; } public static void registerJobIfNeeded(Context context, long intervalMinutes) { JobScheduler jss = context.getSystemService(JobScheduler.class); JobInfo info = jss.getPendingJob(JOB_ID); if (info == null) { registerJob(context, intervalMinutes); } } public static void registerJob(Context context, long intervalMinutes) { JobScheduler jss = context.getSystemService(JobScheduler.class); jss.cancel(JOB_ID); Loading packages/EasterEgg/src/com/android/egg/neko/NekoTile.java +3 −0 Original line number Diff line number Diff line Loading @@ -68,6 +68,9 @@ public class NekoTile extends TileService implements PrefsListener { Tile tile = getQsTile(); int foodState = mPrefs.getFoodState(); Food food = new Food(foodState); if (foodState != 0) { NekoService.registerJobIfNeeded(this, food.getInterval(this)); } tile.setIcon(food.getIcon(this)); tile.setLabel(food.getName(this)); tile.setState(foodState != 0 ? Tile.STATE_ACTIVE : Tile.STATE_INACTIVE); Loading packages/EasterEgg/src/com/android/egg/neko/PrefState.java +3 −5 Original line number Diff line number Diff line Loading @@ -43,13 +43,11 @@ public class PrefState implements OnSharedPreferenceChangeListener { public void addCat(Cat cat) { mPrefs.edit() .putString(CAT_KEY_PREFIX + String.valueOf(cat.getSeed()), cat.getName()) .commit(); .apply(); } public void removeCat(Cat cat) { mPrefs.edit() .remove(CAT_KEY_PREFIX + String.valueOf(cat.getSeed())) .commit(); mPrefs.edit().remove(CAT_KEY_PREFIX + String.valueOf(cat.getSeed())).apply(); } public List<Cat> getCats() { Loading @@ -71,7 +69,7 @@ public class PrefState implements OnSharedPreferenceChangeListener { } public void setFoodState(int foodState) { mPrefs.edit().putInt(FOOD_STATE, foodState).commit(); mPrefs.edit().putInt(FOOD_STATE, foodState).apply(); } public void setListener(PrefsListener listener) { Loading Loading
packages/EasterEgg/src/com/android/egg/neko/NekoService.java +8 −0 Original line number Diff line number Diff line Loading @@ -102,6 +102,14 @@ public class NekoService extends JobService { return false; } public static void registerJobIfNeeded(Context context, long intervalMinutes) { JobScheduler jss = context.getSystemService(JobScheduler.class); JobInfo info = jss.getPendingJob(JOB_ID); if (info == null) { registerJob(context, intervalMinutes); } } public static void registerJob(Context context, long intervalMinutes) { JobScheduler jss = context.getSystemService(JobScheduler.class); jss.cancel(JOB_ID); Loading
packages/EasterEgg/src/com/android/egg/neko/NekoTile.java +3 −0 Original line number Diff line number Diff line Loading @@ -68,6 +68,9 @@ public class NekoTile extends TileService implements PrefsListener { Tile tile = getQsTile(); int foodState = mPrefs.getFoodState(); Food food = new Food(foodState); if (foodState != 0) { NekoService.registerJobIfNeeded(this, food.getInterval(this)); } tile.setIcon(food.getIcon(this)); tile.setLabel(food.getName(this)); tile.setState(foodState != 0 ? Tile.STATE_ACTIVE : Tile.STATE_INACTIVE); Loading
packages/EasterEgg/src/com/android/egg/neko/PrefState.java +3 −5 Original line number Diff line number Diff line Loading @@ -43,13 +43,11 @@ public class PrefState implements OnSharedPreferenceChangeListener { public void addCat(Cat cat) { mPrefs.edit() .putString(CAT_KEY_PREFIX + String.valueOf(cat.getSeed()), cat.getName()) .commit(); .apply(); } public void removeCat(Cat cat) { mPrefs.edit() .remove(CAT_KEY_PREFIX + String.valueOf(cat.getSeed())) .commit(); mPrefs.edit().remove(CAT_KEY_PREFIX + String.valueOf(cat.getSeed())).apply(); } public List<Cat> getCats() { Loading @@ -71,7 +69,7 @@ public class PrefState implements OnSharedPreferenceChangeListener { } public void setFoodState(int foodState) { mPrefs.edit().putInt(FOOD_STATE, foodState).commit(); mPrefs.edit().putInt(FOOD_STATE, foodState).apply(); } public void setListener(PrefsListener listener) { Loading