Search in sources :

Example 1 with LENGTH_SHORT

use of android.widget.Toast.LENGTH_SHORT in project Hentoid by avluis.

the class UpdateCheckService method onCheckSuccess.

private void onCheckSuccess(UpdateInfo updateInfoJson) {
    boolean newVersion = false;
    if (BuildConfig.VERSION_CODE < updateInfoJson.getVersionCode(BuildConfig.DEBUG)) {
        stopForeground(true);
        String updateUrl = updateInfoJson.getUpdateUrl(BuildConfig.DEBUG);
        notificationManager.notify(new UpdateAvailableNotification(updateUrl));
        newVersion = true;
    } else if (shouldShowToast) {
        Toast.makeText(this, R.string.pref_check_updates_manual_no_new, LENGTH_SHORT).show();
    }
    // Get the alerts relevant to current version code
    List<UpdateInfo.SourceAlert> sourceAlerts = Stream.of(updateInfoJson.getSourceAlerts(BuildConfig.DEBUG)).filter(a -> a.getFixedByBuild() > BuildConfig.VERSION_CODE).toList();
    // Send update info through the bus to whom it may concern
    EventBus.getDefault().postSticky(new UpdateEvent(newVersion, sourceAlerts));
}
Also used : Context(android.content.Context) UpdateCheckNotification(me.devsaki.hentoid.notification.update.UpdateCheckNotification) Stream(com.annimon.stream.Stream) AndroidSchedulers.mainThread(io.reactivex.android.schedulers.AndroidSchedulers.mainThread) Service(android.app.Service) UpdateInfo(me.devsaki.hentoid.json.core.UpdateInfo) Intent(android.content.Intent) IBinder(android.os.IBinder) Timber(timber.log.Timber) R(me.devsaki.hentoid.R) List(java.util.List) Disposable(io.reactivex.disposables.Disposable) Nullable(androidx.annotation.Nullable) BuildConfig(me.devsaki.hentoid.BuildConfig) Toast(android.widget.Toast) EventBus(org.greenrobot.eventbus.EventBus) UpdateAvailableNotification(me.devsaki.hentoid.notification.update.UpdateAvailableNotification) UpdateServer(me.devsaki.hentoid.retrofit.UpdateServer) UpdateEvent(me.devsaki.hentoid.events.UpdateEvent) ServiceNotificationManager(me.devsaki.hentoid.util.notification.ServiceNotificationManager) LENGTH_SHORT(android.widget.Toast.LENGTH_SHORT) UpdateAvailableNotification(me.devsaki.hentoid.notification.update.UpdateAvailableNotification) UpdateEvent(me.devsaki.hentoid.events.UpdateEvent)

Aggregations

Service (android.app.Service)1 Context (android.content.Context)1 Intent (android.content.Intent)1 IBinder (android.os.IBinder)1 Toast (android.widget.Toast)1 LENGTH_SHORT (android.widget.Toast.LENGTH_SHORT)1 Nullable (androidx.annotation.Nullable)1 Stream (com.annimon.stream.Stream)1 AndroidSchedulers.mainThread (io.reactivex.android.schedulers.AndroidSchedulers.mainThread)1 Disposable (io.reactivex.disposables.Disposable)1 List (java.util.List)1 BuildConfig (me.devsaki.hentoid.BuildConfig)1 R (me.devsaki.hentoid.R)1 UpdateEvent (me.devsaki.hentoid.events.UpdateEvent)1 UpdateInfo (me.devsaki.hentoid.json.core.UpdateInfo)1 UpdateAvailableNotification (me.devsaki.hentoid.notification.update.UpdateAvailableNotification)1 UpdateCheckNotification (me.devsaki.hentoid.notification.update.UpdateCheckNotification)1 UpdateServer (me.devsaki.hentoid.retrofit.UpdateServer)1 ServiceNotificationManager (me.devsaki.hentoid.util.notification.ServiceNotificationManager)1 EventBus (org.greenrobot.eventbus.EventBus)1