Fix empty state for account media, fix tablets (#1018)
This commit is contained in:
parent
6b7ca5d184
commit
87364edd98
2 changed files with 36 additions and 14 deletions
|
@ -15,7 +15,6 @@
|
|||
|
||||
package com.keylesspalace.tusky.fragment
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Color
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
|
@ -35,7 +34,8 @@ import com.keylesspalace.tusky.entity.Attachment
|
|||
import com.keylesspalace.tusky.entity.Status
|
||||
import com.keylesspalace.tusky.network.MastodonApi
|
||||
import com.keylesspalace.tusky.util.ThemeUtils
|
||||
import com.keylesspalace.tusky.util.visible
|
||||
import com.keylesspalace.tusky.util.hide
|
||||
import com.keylesspalace.tusky.util.show
|
||||
import com.keylesspalace.tusky.view.SquareImageView
|
||||
import com.keylesspalace.tusky.viewdata.AttachmentViewData
|
||||
import com.squareup.picasso.Picasso
|
||||
|
@ -43,6 +43,7 @@ import kotlinx.android.synthetic.main.fragment_timeline.*
|
|||
import retrofit2.Call
|
||||
import retrofit2.Callback
|
||||
import retrofit2.Response
|
||||
import java.io.IOException
|
||||
import java.util.*
|
||||
import javax.inject.Inject
|
||||
|
||||
|
@ -80,9 +81,19 @@ class AccountMediaFragment : BaseFragment(), Injectable {
|
|||
private val callback = object : Callback<List<Status>> {
|
||||
override fun onFailure(call: Call<List<Status>>?, t: Throwable?) {
|
||||
fetchingStatus = FetchingStatus.NOT_FETCHING
|
||||
if(isAdded) {
|
||||
if (isAdded) {
|
||||
swipe_refresh_layout.isRefreshing = false
|
||||
progress_bar.visibility = View.GONE
|
||||
statusView.show()
|
||||
if (t is IOException) {
|
||||
statusView.setup(R.drawable.elephant_offline, R.string.error_network) {
|
||||
doInitialLoadingIfNeeded()
|
||||
}
|
||||
} else {
|
||||
statusView.setup(R.drawable.elephant_error, R.string.error_generic) {
|
||||
doInitialLoadingIfNeeded()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Log.d(TAG, "Failed to fetch account media", t)
|
||||
|
@ -90,7 +101,7 @@ class AccountMediaFragment : BaseFragment(), Injectable {
|
|||
|
||||
override fun onResponse(call: Call<List<Status>>, response: Response<List<Status>>) {
|
||||
fetchingStatus = FetchingStatus.NOT_FETCHING
|
||||
if(isAdded) {
|
||||
if (isAdded) {
|
||||
swipe_refresh_layout.isRefreshing = false
|
||||
progress_bar.visibility = View.GONE
|
||||
|
||||
|
@ -103,7 +114,11 @@ class AccountMediaFragment : BaseFragment(), Injectable {
|
|||
result.addAll(AttachmentViewData.list(status))
|
||||
}
|
||||
adapter.addTop(result)
|
||||
nothing_message.visible(statuses.isEmpty())
|
||||
if (statuses.isEmpty()) {
|
||||
statusView.show()
|
||||
statusView.setup(R.drawable.elephant_friend_empty, R.string.message_empty,
|
||||
null)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -112,6 +127,7 @@ class AccountMediaFragment : BaseFragment(), Injectable {
|
|||
private val bottomCallback = object : Callback<List<Status>> {
|
||||
override fun onFailure(call: Call<List<Status>>?, t: Throwable?) {
|
||||
fetchingStatus = FetchingStatus.NOT_FETCHING
|
||||
|
||||
Log.d(TAG, "Failed to fetch account media", t)
|
||||
}
|
||||
|
||||
|
@ -156,6 +172,7 @@ class AccountMediaFragment : BaseFragment(), Injectable {
|
|||
val accountId = arguments?.getString(ACCOUNT_ID_ARG)
|
||||
|
||||
swipe_refresh_layout.setOnRefreshListener {
|
||||
statusView.hide()
|
||||
if (fetchingStatus != FetchingStatus.NOT_FETCHING) return@setOnRefreshListener
|
||||
currentCall = if (statuses.isEmpty()) {
|
||||
fetchingStatus = FetchingStatus.INITIAL_FETCHING
|
||||
|
@ -170,7 +187,7 @@ class AccountMediaFragment : BaseFragment(), Injectable {
|
|||
swipe_refresh_layout.setColorSchemeResources(R.color.tusky_blue)
|
||||
swipe_refresh_layout.setProgressBackgroundColorSchemeColor(ThemeUtils.getColor(context, android.R.attr.colorBackground))
|
||||
|
||||
nothing_message.visibility = View.GONE
|
||||
statusView.visibility = View.GONE
|
||||
|
||||
recycler_view.addOnScrollListener(object : RecyclerView.OnScrollListener() {
|
||||
|
||||
|
@ -202,6 +219,9 @@ class AccountMediaFragment : BaseFragment(), Injectable {
|
|||
}
|
||||
|
||||
private fun doInitialLoadingIfNeeded() {
|
||||
if (isAdded) {
|
||||
statusView.hide()
|
||||
}
|
||||
val accountId = arguments?.getString(ACCOUNT_ID_ARG)
|
||||
if (fetchingStatus == FetchingStatus.NOT_FETCHING && statuses.isEmpty()) {
|
||||
fetchingStatus = FetchingStatus.INITIAL_FETCHING
|
||||
|
@ -239,7 +259,7 @@ class AccountMediaFragment : BaseFragment(), Injectable {
|
|||
NOT_FETCHING, INITIAL_FETCHING, FETCHING_BOTTOM, REFRESHING
|
||||
}
|
||||
|
||||
inner class MediaGridAdapter:
|
||||
inner class MediaGridAdapter :
|
||||
RecyclerView.Adapter<MediaGridAdapter.MediaViewHolder>() {
|
||||
|
||||
var baseItemColor = Color.BLACK
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue