....
This commit is contained in:
parent
b1fdea3317
commit
ff14d6d3a5
@ -36,6 +36,7 @@ import androidx.fragment.app.FragmentManager
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.work.OneTimeWorkRequest
|
||||
import androidx.work.OneTimeWorkRequestBuilder
|
||||
import androidx.work.PeriodicWorkRequestBuilder
|
||||
import androidx.work.WorkInfo
|
||||
import androidx.work.WorkManager
|
||||
import com.google.gson.Gson
|
||||
@ -62,6 +63,7 @@ import rasel.lunar.launcher.utils.MissedCallGetter
|
||||
import rasel.lunar.launcher.utils.SimpleFingerGestures
|
||||
import java.util.Calendar
|
||||
import java.util.Locale
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
|
||||
internal class LauncherHome : Fragment() {
|
||||
@ -82,7 +84,23 @@ internal class LauncherHome : Fragment() {
|
||||
binding.favAppsGroup.visibility = View.GONE
|
||||
|
||||
mWorkManager = WorkManager.getInstance(lActivity!!.application);
|
||||
mWorkManager?.enqueue(OneTimeWorkRequestBuilder<MissedCallGetter>().addTag("MissedCallGetter").build())
|
||||
mWorkManager?.enqueue(PeriodicWorkRequestBuilder<MissedCallGetter>(30, TimeUnit.MINUTES).addTag("MissedCallGetter").build())
|
||||
mSavedWorkInfo = mWorkManager?.getWorkInfosByTagLiveData("MissedCallGetter");
|
||||
getOutputWorkInfo().observeForever {
|
||||
it.last()?.outputData?.keyValueMap?.forEach { t, u ->
|
||||
try {
|
||||
if (u is String) {
|
||||
Gson().fromJson(u,MissedCall::class.java)?.let {
|
||||
callList.add(it)
|
||||
}
|
||||
}
|
||||
} catch (e : Exception) {
|
||||
|
||||
} finally {
|
||||
showTodoList()
|
||||
}
|
||||
}
|
||||
}
|
||||
BLog.LOGE("onCreateView()")
|
||||
return binding.root
|
||||
}
|
||||
@ -135,22 +153,7 @@ internal class LauncherHome : Fragment() {
|
||||
|
||||
/* show weather */
|
||||
WeatherExecutor(settingsPrefs).generateWeatherString(binding.weather)
|
||||
mSavedWorkInfo = mWorkManager?.getWorkInfosByTagLiveData("MissedCallGetter");
|
||||
getOutputWorkInfo().observeForever {
|
||||
it.last()?.outputData?.keyValueMap?.forEach { t, u ->
|
||||
try {
|
||||
if (u is String) {
|
||||
Gson().fromJson(u,MissedCall::class.java)?.let {
|
||||
callList.add(it)
|
||||
}
|
||||
}
|
||||
} catch (e : Exception) {
|
||||
|
||||
} finally {
|
||||
showTodoList()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user