diff --git a/app/src/main/java/org/pixeldroid/app/MainActivity.kt b/app/src/main/java/org/pixeldroid/app/MainActivity.kt index 1df075f7..8a981c20 100644 --- a/app/src/main/java/org/pixeldroid/app/MainActivity.kt +++ b/app/src/main/java/org/pixeldroid/app/MainActivity.kt @@ -72,8 +72,8 @@ class MainActivity : BaseActivity() { //Check if we have logged in and gotten an access token if (user == null) { - launchActivity(LoginActivity(), firstTime = true) finish() + launchActivity(LoginActivity(), firstTime = true) } else { sendTraceDroidStackTracesIfExist("contact@pixeldroid.org", this) @@ -172,6 +172,7 @@ class MainActivity : BaseActivity() { } private fun logOut(){ + finish() db.runInTransaction { db.userDao().deleteActiveUsers() @@ -229,6 +230,8 @@ class MainActivity : BaseActivity() { apiHolder.setToCurrentUser() val intent = Intent(this, MainActivity::class.java) intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK + + finish() startActivity(intent) return false diff --git a/app/src/main/java/org/pixeldroid/app/posts/PostActivity.kt b/app/src/main/java/org/pixeldroid/app/posts/PostActivity.kt index 2c68c62b..77c89db0 100644 --- a/app/src/main/java/org/pixeldroid/app/posts/PostActivity.kt +++ b/app/src/main/java/org/pixeldroid/app/posts/PostActivity.kt @@ -38,8 +38,8 @@ class PostActivity : BaseActivity() { supportActionBar?.setDisplayHomeAsUpEnabled(true) status = intent.getSerializableExtra(POST_TAG) as Status - val viewComments: Boolean = (intent.getSerializableExtra(VIEW_COMMENTS_TAG) ?: false) as Boolean - val postComment: Boolean = (intent.getSerializableExtra(POST_COMMENT_TAG) ?: false) as Boolean + val viewComments: Boolean = intent.getBooleanExtra(VIEW_COMMENTS_TAG, false) + val postComment: Boolean = intent.getBooleanExtra(POST_COMMENT_TAG, false) val user = db.userDao().getActiveUser() diff --git a/app/src/main/java/org/pixeldroid/app/posts/feeds/cachedFeeds/notifications/NotificationsFragment.kt b/app/src/main/java/org/pixeldroid/app/posts/feeds/cachedFeeds/notifications/NotificationsFragment.kt index 9d75a9fa..9ac41fd7 100644 --- a/app/src/main/java/org/pixeldroid/app/posts/feeds/cachedFeeds/notifications/NotificationsFragment.kt +++ b/app/src/main/java/org/pixeldroid/app/posts/feeds/cachedFeeds/notifications/NotificationsFragment.kt @@ -249,7 +249,7 @@ class NotificationsFragment : CachedFeedFragment() { override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) { val uiModel = getItem(position) - uiModel.let { + uiModel?.let { (holder as NotificationViewHolder).bind( it, apiHolder, diff --git a/app/src/main/java/org/pixeldroid/app/utils/db/AppDatabase.kt b/app/src/main/java/org/pixeldroid/app/utils/db/AppDatabase.kt index c2a52989..88bfea96 100644 --- a/app/src/main/java/org/pixeldroid/app/utils/db/AppDatabase.kt +++ b/app/src/main/java/org/pixeldroid/app/utils/db/AppDatabase.kt @@ -3,6 +3,8 @@ package org.pixeldroid.app.utils.db import androidx.room.Database import androidx.room.RoomDatabase import androidx.room.TypeConverters +import androidx.room.migration.Migration +import androidx.sqlite.db.SupportSQLiteDatabase import org.pixeldroid.app.utils.db.dao.* import org.pixeldroid.app.utils.db.dao.feedContent.NotificationDao import org.pixeldroid.app.utils.db.dao.feedContent.posts.HomePostDao @@ -29,4 +31,12 @@ abstract class AppDatabase : RoomDatabase() { abstract fun homePostDao(): HomePostDao abstract fun publicPostDao(): PublicPostDao abstract fun notificationDao(): NotificationDao +} + +val MIGRATION_3_4 = object : Migration(3, 4) { + override fun migrate(database: SupportSQLiteDatabase) { + database.execSQL("DELETE FROM homePosts") + database.execSQL("DELETE FROM publicPosts") + database.execSQL("DELETE FROM notifications") + } } \ No newline at end of file diff --git a/app/src/main/java/org/pixeldroid/app/utils/di/DatabaseModule.kt b/app/src/main/java/org/pixeldroid/app/utils/di/DatabaseModule.kt index 6b2e4dbe..bc08dec5 100644 --- a/app/src/main/java/org/pixeldroid/app/utils/di/DatabaseModule.kt +++ b/app/src/main/java/org/pixeldroid/app/utils/di/DatabaseModule.kt @@ -5,6 +5,7 @@ import androidx.room.Room import org.pixeldroid.app.utils.db.AppDatabase import dagger.Module import dagger.Provides +import org.pixeldroid.app.utils.db.MIGRATION_3_4 import javax.inject.Singleton @Module @@ -16,6 +17,6 @@ class DatabaseModule(private val context: Context) { return Room.databaseBuilder( context, AppDatabase::class.java, "pixeldroid" - ).allowMainThreadQueries().build() + ).addMigrations(MIGRATION_3_4).allowMainThreadQueries().build() } } \ No newline at end of file