From 32ff6c3269abb81289160aa6f9f55c14369c99a3 Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Thu, 12 Oct 2017 12:36:05 -0400 Subject: misc (#400) * Remove job scheduler null check * Add try catch for viewpager on touch event. Resolves #356 * Update kotlin and translation url * Use short url * Check job scheduler null check against travis lint * Add badges and update crashlytics --- .../com/pitchedapps/frost/services/FrostNotifications.kt | 12 ++---------- .../kotlin/com/pitchedapps/frost/views/FrostViewPager.kt | 11 ++++++++--- 2 files changed, 10 insertions(+), 13 deletions(-) (limited to 'app/src/main/kotlin') diff --git a/app/src/main/kotlin/com/pitchedapps/frost/services/FrostNotifications.kt b/app/src/main/kotlin/com/pitchedapps/frost/services/FrostNotifications.kt index b1f26d99..d296b5f3 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/services/FrostNotifications.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/services/FrostNotifications.kt @@ -172,11 +172,7 @@ const val NOTIFICATION_PERIODIC_JOB = 7 * returns false if an error occurs; true otherwise */ fun Context.scheduleNotifications(minutes: Long): Boolean { - val scheduler = getSystemService(Context.JOB_SCHEDULER_SERVICE) as JobScheduler? - if (scheduler == null) { - L.e("JobScheduler not found; cannot schedule notifications") - return false - } + val scheduler = getSystemService(Context.JOB_SCHEDULER_SERVICE) as JobScheduler scheduler.cancel(NOTIFICATION_PERIODIC_JOB) if (minutes < 0L) return true val serviceComponent = ComponentName(this, NotificationService::class.java) @@ -198,11 +194,7 @@ const val NOTIFICATION_JOB_NOW = 6 * Run notification job right now */ fun Context.fetchNotifications(): Boolean { - val scheduler = getSystemService(Context.JOB_SCHEDULER_SERVICE) as JobScheduler? - if (scheduler == null) { - L.e("JobScheduler not found") - return false - } + val scheduler = getSystemService(Context.JOB_SCHEDULER_SERVICE) as JobScheduler val serviceComponent = ComponentName(this, NotificationService::class.java) val builder = JobInfo.Builder(NOTIFICATION_JOB_NOW, serviceComponent) .setMinimumLatency(0L) diff --git a/app/src/main/kotlin/com/pitchedapps/frost/views/FrostViewPager.kt b/app/src/main/kotlin/com/pitchedapps/frost/views/FrostViewPager.kt index 91673b15..8122d362 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/views/FrostViewPager.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/views/FrostViewPager.kt @@ -18,10 +18,15 @@ class FrostViewPager @JvmOverloads constructor(context: Context, attrs: Attribut override fun onInterceptTouchEvent(ev: MotionEvent?) = try { Prefs.viewpagerSwipe && enableSwipe && super.onInterceptTouchEvent(ev) - } catch(e: IllegalArgumentException) { - true + } catch (e: IllegalArgumentException) { + false } @SuppressLint("ClickableViewAccessibility") - override fun onTouchEvent(ev: MotionEvent?): Boolean = Prefs.viewpagerSwipe && enableSwipe && super.onTouchEvent(ev) + override fun onTouchEvent(ev: MotionEvent?): Boolean = + try { + Prefs.viewpagerSwipe && enableSwipe && super.onTouchEvent(ev) + } catch (e: IllegalArgumentException) { + false + } } \ No newline at end of file -- cgit v1.2.3