Commit c83388bb authored by Ricki Hirner's avatar Ricki Hirner

Simplify startup fragment interface

parent 6a35fe5f
......@@ -70,7 +70,7 @@ class CalendarListActivity:
if (savedInstanceState == null)
ServiceLoader
.load(StartupFragment::class.java)
.forEach { it.initiate(this, supportFragmentManager) }
.forEach { it.initialize(this) }
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.READ_CALENDAR) == PackageManager.PERMISSION_GRANTED &&
ActivityCompat.checkSelfPermission(this, Manifest.permission.WRITE_CALENDAR) == PackageManager.PERMISSION_GRANTED)
......
package at.bitfire.icsdroid.ui
import android.app.Activity
import androidx.fragment.app.FragmentManager
import androidx.appcompat.app.AppCompatActivity
interface StartupFragment {
fun initiate(activity: Activity, fragmentManager: FragmentManager)
fun initialize(activity: AppCompatActivity)
}
\ No newline at end of file
......@@ -8,12 +8,11 @@
package at.bitfire.icsdroid.ui;
import android.app.Activity
import android.content.Intent
import android.os.Bundle
import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.DialogFragment
import androidx.fragment.app.FragmentManager
import at.bitfire.icsdroid.Constants
import at.bitfire.icsdroid.R
......@@ -46,9 +45,9 @@ class DonateDialogFragment: DialogFragment() {
class Factory: StartupFragment {
override fun initiate(activity: Activity, fragmentManager: FragmentManager) {
override fun initialize(activity: AppCompatActivity) {
if (activity.getPreferences(0).getLong(PREF_NEXT_REMINDER, 0) < System.currentTimeMillis())
DonateDialogFragment().show(fragmentManager, "donate")
DonateDialogFragment().show(activity.supportFragmentManager, "donate")
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment