Author: Adam Pioterek <adam.pioterek@protonmail.ch>
checking db on resume NoDbActivity
app/src/main/java/ml/adamsprogs/bimba/activities/NoDbActivity.kt | 8 app/src/main/java/ml/adamsprogs/bimba/activities/SplashActivity.kt | 13
diff --git a/app/src/main/java/ml/adamsprogs/bimba/activities/NoDbActivity.kt b/app/src/main/java/ml/adamsprogs/bimba/activities/NoDbActivity.kt index 28d24f6d832eb6a185ea90d8720fb432282ff607..5bd0095df723e6c3629556cd2b2a0f41debc5caa 100644 --- a/app/src/main/java/ml/adamsprogs/bimba/activities/NoDbActivity.kt +++ b/app/src/main/java/ml/adamsprogs/bimba/activities/NoDbActivity.kt @@ -7,8 +7,9 @@ import android.content.IntentFilter import ml.adamsprogs.bimba.* import kotlinx.android.synthetic.main.activity_nodb.* import ml.adamsprogs.bimba.datasources.TimetableDownloader +import ml.adamsprogs.bimba.models.Timetable -//todo onResume check again +//todo onResume check again // check class NoDbActivity : AppCompatActivity(), NetworkStateReceiver.OnConnectivityChangeListener, MessageReceiver.OnTimetableDownloadListener { private val networkStateReceiver = NetworkStateReceiver() private val timetableDownloadReceiver = MessageReceiver.getMessageReceiver() @@ -35,6 +36,11 @@ } override fun onResume() { super.onResume() + val timetable = Timetable.getTimetable(this) + if (!timetable.isEmpty()){ + startActivity(Intent(this, DashActivity::class.java)) + finish() + } var filter = IntentFilter(TimetableDownloader.ACTION_DOWNLOADED) filter.addCategory(Intent.CATEGORY_DEFAULT) registerReceiver(timetableDownloadReceiver, filter) diff --git a/app/src/main/java/ml/adamsprogs/bimba/activities/SplashActivity.kt b/app/src/main/java/ml/adamsprogs/bimba/activities/SplashActivity.kt index 9731a065e2b2754d6f0d52cdb01b74f74bbd9e90..1a64e08790453363e9d7db46c4ca24b58a7a6e20 100644 --- a/app/src/main/java/ml/adamsprogs/bimba/activities/SplashActivity.kt +++ b/app/src/main/java/ml/adamsprogs/bimba/activities/SplashActivity.kt @@ -12,16 +12,11 @@ class SplashActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - try { - val timetable = Timetable.getTimetable(this) - if (timetable.isEmpty()) - startActivity(Intent(this, NoDbActivity::class.java)) - else - startActivity(Intent(this, DashActivity::class.java)) - } catch(e: Exception) { - e.printStackTrace() + val timetable = Timetable.getTimetable(this) + if (timetable.isEmpty()) startActivity(Intent(this, NoDbActivity::class.java)) - } + else + startActivity(Intent(this, DashActivity::class.java)) finish() } }