diff --git a/app/build.gradle b/app/build.gradle index 28124af3..92d7b50c 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -28,8 +28,8 @@ android { applicationId "org.pixeldroid.app" minSdkVersion 23 targetSdkVersion 31 - versionCode 9 - versionName "1.0.beta$versionCode" + versionCode 10 + versionName "1.0.beta" + versionCode testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" testInstrumentationRunnerArguments clearPackageData: 'true' diff --git a/app/src/main/java/org/pixeldroid/app/posts/feeds/CommonFeedFragmentUtils.kt b/app/src/main/java/org/pixeldroid/app/posts/feeds/CommonFeedFragmentUtils.kt index 76c008d4..daa19705 100644 --- a/app/src/main/java/org/pixeldroid/app/posts/feeds/CommonFeedFragmentUtils.kt +++ b/app/src/main/java/org/pixeldroid/app/posts/feeds/CommonFeedFragmentUtils.kt @@ -1,6 +1,7 @@ package org.pixeldroid.app.posts.feeds import android.view.LayoutInflater +import android.view.View import android.view.ViewGroup import android.widget.ProgressBar import androidx.constraintlayout.motion.widget.MotionLayout @@ -29,7 +30,8 @@ import retrofit2.HttpException private fun showError( errorText: String, show: Boolean = true, motionLayout: MotionLayout, - errorLayout: ErrorLayoutBinding){ + errorLayout: ErrorLayoutBinding, + progressBar: ProgressBar){ if(show) { motionLayout.transitionToEnd() @@ -37,6 +39,7 @@ private fun showError( } else if(motionLayout.progress == 1F) { motionLayout.transitionToStart() } + progressBar.visibility = View.GONE } /** @@ -79,7 +82,7 @@ internal fun initAdapter( val error: String = (it.error as? HttpException)?.response()?.errorBody()?.string()?.ifEmpty { null }?.let { s -> Gson().fromJson(s, org.pixeldroid.app.utils.api.objects.Error::class.java)?.error?.ifBlank { null } } ?: it.error.localizedMessage.orEmpty() - showError(motionLayout = motionLayout, errorLayout = errorLayout, errorText = error) + showError(motionLayout = motionLayout, errorLayout = errorLayout, errorText = error, progressBar = progressBar) } // If the state is not an error, hide the error layout, or show message that the feed is empty @@ -91,10 +94,11 @@ internal fun initAdapter( progressBar.isVisible = false showError( motionLayout = motionLayout, errorLayout = errorLayout, - errorText = errorLayout.root.context.getString(R.string.empty_feed) + errorText = errorLayout.root.context.getString(R.string.empty_feed), + progressBar = progressBar ) } else { - showError(motionLayout = motionLayout, errorLayout = errorLayout, show = false, errorText = "") + showError(motionLayout = motionLayout, errorLayout = errorLayout, show = false, errorText = "", progressBar = progressBar) } } } 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 1ceedf52..969cedeb 100644 --- a/app/src/main/java/org/pixeldroid/app/profile/ProfileActivity.kt +++ b/app/src/main/java/org/pixeldroid/app/profile/ProfileActivity.kt @@ -9,6 +9,7 @@ import android.view.ViewGroup import android.widget.* import androidx.appcompat.app.AlertDialog import androidx.appcompat.content.res.AppCompatResources +import androidx.constraintlayout.motion.widget.MotionLayout import androidx.core.content.ContextCompat import androidx.lifecycle.ViewModel import androidx.lifecycle.ViewModelProvider @@ -38,6 +39,7 @@ import org.pixeldroid.app.utils.db.entities.UserDatabaseEntity import org.pixeldroid.app.utils.openUrl import kotlinx.coroutines.Job import kotlinx.coroutines.launch +import org.pixeldroid.app.databinding.ErrorLayoutBinding import org.pixeldroid.app.utils.api.objects.Attachment import retrofit2.HttpException import java.io.IOException @@ -81,12 +83,13 @@ class ProfileActivity : BaseActivity() { profileAdapter = ProfilePostsAdapter() initAdapter(binding.profileProgressBar, binding.profileRefreshLayout, - binding.profilePostsRecyclerView, binding.motionLayout, binding.profileErrorLayout, + binding.profilePostsRecyclerView, binding.motionLayout, binding.errorLayout, profileAdapter) binding.profilePostsRecyclerView.layoutManager = GridLayoutManager(this, 3) binding.profileRefreshLayout.setOnRefreshListener { + setContent(account) profileAdapter.refresh() } @@ -101,6 +104,7 @@ class ProfileActivity : BaseActivity() { if(show){ binding.profileProgressBar.visibility = View.GONE binding.motionLayout.transitionToEnd() + binding.errorLayout.errorText.text = errorText } else if(binding.motionLayout.progress == 1F) { binding.motionLayout.transitionToStart() } diff --git a/app/src/main/res/layout/activity_profile.xml b/app/src/main/res/layout/activity_profile.xml index 8d529b8c..031b5306 100644 --- a/app/src/main/res/layout/activity_profile.xml +++ b/app/src/main/res/layout/activity_profile.xml @@ -129,8 +129,6 @@ app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toEndOf="@+id/profilePictureImageView" app:layout_constraintTop_toTopOf="@+id/profilePictureImageView" /> - - @@ -144,37 +142,36 @@ android:layout_gravity="center" android:layout_marginTop="16dp" /> - - - - - - - + android:layout_marginTop="8dp" + android:visibility="visible" + app:layoutDescription="@xml/error_layout_xml_error_scene"> + + + + + + + diff --git a/app/src/main/res/layout/fragment_feed.xml b/app/src/main/res/layout/fragment_feed.xml index 5b50fd9b..f32b760a 100644 --- a/app/src/main/res/layout/fragment_feed.xml +++ b/app/src/main/res/layout/fragment_feed.xml @@ -5,9 +5,6 @@ android:id="@+id/coordinatorLayout" android:layout_width="match_parent" android:layout_height="match_parent"> - - + app:layout_constraintTop_toBottomOf="@id/followButton">