From 1823007b1b838810ab149444afe16641fe9fb68f Mon Sep 17 00:00:00 2001 From: Matthieu <24-artectrex@users.noreply.shinice.net> Date: Sat, 12 Mar 2022 22:32:39 +0100 Subject: [PATCH] Fix profile recyclerview not recycling --- .../NotificationsRemoteMediator.kt | 3 + .../pixeldroid/app/profile/ProfileActivity.kt | 10 +- app/src/main/res/layout/activity_profile.xml | 311 +++++++++--------- app/src/main/res/layout/post_fragment.xml | 2 +- app/src/main/res/values-night/colors.xml | 1 + app/src/main/res/values/colors.xml | 1 + 6 files changed, 173 insertions(+), 155 deletions(-) diff --git a/app/src/main/java/org/pixeldroid/app/posts/feeds/cachedFeeds/notifications/NotificationsRemoteMediator.kt b/app/src/main/java/org/pixeldroid/app/posts/feeds/cachedFeeds/notifications/NotificationsRemoteMediator.kt index 609c5a1c..a4799e5c 100644 --- a/app/src/main/java/org/pixeldroid/app/posts/feeds/cachedFeeds/notifications/NotificationsRemoteMediator.kt +++ b/app/src/main/java/org/pixeldroid/app/posts/feeds/cachedFeeds/notifications/NotificationsRemoteMediator.kt @@ -23,6 +23,7 @@ import org.pixeldroid.app.utils.di.PixelfedAPIHolder import org.pixeldroid.app.utils.api.objects.Notification import retrofit2.HttpException import java.io.IOException +import java.lang.Exception import java.lang.NullPointerException import javax.inject.Inject @@ -77,6 +78,8 @@ class NotificationsRemoteMediator @Inject constructor( return MediatorResult.Error(exception) } catch (exception: HttpException) { return MediatorResult.Error(exception) + } catch (exception: Exception){ + return MediatorResult.Error(exception) } } } \ No newline at end of file diff --git a/app/src/main/java/org/pixeldroid/app/profile/ProfileActivity.kt b/app/src/main/java/org/pixeldroid/app/profile/ProfileActivity.kt index fb84c5ca..81d9d11b 100644 --- a/app/src/main/java/org/pixeldroid/app/profile/ProfileActivity.kt +++ b/app/src/main/java/org/pixeldroid/app/profile/ProfileActivity.kt @@ -71,12 +71,12 @@ class ProfileActivity : BaseActivity() { // get the view model @Suppress("UNCHECKED_CAST") viewModel = ViewModelProvider(this, ProfileViewModelFactory( - ProfileContentRepository( - apiHolder.setToCurrentUser(), - accountId - ) + ProfileContentRepository( + apiHolder.setToCurrentUser(), + accountId ) - ).get(FeedViewModel::class.java) as FeedViewModel + ) + )[FeedViewModel::class.java] as FeedViewModel profileAdapter = ProfilePostsAdapter() initAdapter(binding.profileProgressBar, binding.profileRefreshLayout, diff --git a/app/src/main/res/layout/activity_profile.xml b/app/src/main/res/layout/activity_profile.xml index 2ebc9cac..8d529b8c 100644 --- a/app/src/main/res/layout/activity_profile.xml +++ b/app/src/main/res/layout/activity_profile.xml @@ -1,167 +1,180 @@ - - - - - - - - - - - - - - - - - -