Skip to content

Commit

Permalink
Updated update policy and wrapped EmojiCompat with try/catch block
Browse files Browse the repository at this point in the history
  • Loading branch information
Javinator9889 committed Apr 21, 2020
1 parent 7b26092 commit 0e9e747
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,11 @@ class LauncherActivity : AppCompatActivity() {
}
}

override fun finish() {
Timber.d("Calling finish")
super.finish()
}

private fun installRequiredModules() {
val modules = ArrayList<String>(MODULE_COUNT)
val googleApi = GoogleApiAvailability.getInstance()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ data class NotificationStructure(

class NotificationsWorker(
private val context: Context,
private val params: WorkerParameters
params: WorkerParameters
) : CoroutineWorker(context, params) {

override suspend fun doWork(): Result = coroutineScope {
Expand All @@ -70,11 +70,19 @@ class NotificationsWorker(


val emojiCompat = emojiLoader.await()
val title =
emojiCompat.process(context.getString(notificationData.title))
val comments =
context.resources.getStringArray(notificationData.content)
val comment = emojiCompat.process(comments.asList().random())
var title: CharSequence
var comment: CharSequence
try {
title =
emojiCompat.process(context.getString(notificationData.title))
val comments =
context.resources.getStringArray(notificationData.content)
comment = emojiCompat.process(comments.asList().random())
} catch (_: IllegalStateException) {
title = context.getText(notificationData.title)
comment = context.resources
.getStringArray(notificationData.content).asList().random()
}

withContext(Dispatchers.Main) {
notificationsHandler.createNotification(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class WorkHandler(private val context: Context) {
with(workManager) {
enqueueUniqueWork(
who,
ExistingWorkPolicy.REPLACE,
ExistingWorkPolicy.APPEND,
jobRequest
)
}
Expand Down

0 comments on commit 0e9e747

Please sign in to comment.