mirror of
https://github.com/mihonapp/mihon.git
synced 2025-11-19 23:41:13 +01:00
Refresh button in library is now looking for new chapters in sources and notifying the user
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
package eu.kanade.mangafeed.util;
|
||||
|
||||
import android.app.ActivityManager;
|
||||
import android.app.ActivityManager.RunningServiceInfo;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageManager;
|
||||
|
||||
import timber.log.Timber;
|
||||
|
||||
public class AndroidComponentUtil {
|
||||
|
||||
public static void toggleComponent(Context context, Class componentClass, boolean enable) {
|
||||
Timber.i((enable ? "Enabling " : "Disabling ") + componentClass.getSimpleName());
|
||||
ComponentName componentName = new ComponentName(context, componentClass);
|
||||
PackageManager pm = context.getPackageManager();
|
||||
pm.setComponentEnabledSetting(componentName,
|
||||
enable ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED :
|
||||
PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
|
||||
PackageManager.DONT_KILL_APP);
|
||||
}
|
||||
|
||||
public static boolean isServiceRunning(Context context, Class serviceClass) {
|
||||
ActivityManager manager =
|
||||
(ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
|
||||
for (RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
|
||||
if (serviceClass.getName().equals(service.service.getClassName())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package eu.kanade.mangafeed.util;
|
||||
|
||||
import android.app.NotificationManager;
|
||||
import android.content.Context;
|
||||
import android.support.v4.app.NotificationCompat;
|
||||
|
||||
import eu.kanade.mangafeed.R;
|
||||
|
||||
public class NotificationUtil {
|
||||
|
||||
public static void create(Context context, int nId, String title, String body, int iconRes) {
|
||||
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context)
|
||||
.setSmallIcon(iconRes == -1 ? R.drawable.ic_action_refresh : iconRes)
|
||||
.setContentTitle(title)
|
||||
.setContentText(body);
|
||||
|
||||
|
||||
NotificationManager mNotificationManager =
|
||||
(NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
|
||||
mNotificationManager.notify(nId, mBuilder.build());
|
||||
}
|
||||
|
||||
public static void createBigText(Context context, int nId, String title, String body, int iconRes) {
|
||||
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context)
|
||||
.setSmallIcon(iconRes == -1 ? R.drawable.ic_action_refresh : iconRes)
|
||||
.setContentTitle(title)
|
||||
.setStyle(new NotificationCompat.BigTextStyle().bigText(body));
|
||||
|
||||
NotificationManager mNotificationManager =
|
||||
(NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
|
||||
mNotificationManager.notify(nId, mBuilder.build());
|
||||
}
|
||||
|
||||
public static void create(Context context, int nId, String title, String body) {
|
||||
create(context, nId, title, body, -1);
|
||||
}
|
||||
|
||||
public static void createBigText(Context context, int nId, String title, String body) {
|
||||
createBigText(context, nId, title, body, -1);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -19,17 +19,14 @@ public class PostResult {
|
||||
this.numberOfRowsDeleted = numberOfRowsDeleted;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Integer getNumberOfRowsUpdated() {
|
||||
return numberOfRowsUpdated;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Integer getNumberOfRowsInserted() {
|
||||
return numberOfRowsInserted;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Integer getNumberOfRowsDeleted() {
|
||||
return numberOfRowsDeleted;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user