fix: 修复 Bug
This commit is contained in:
parent
6f72e2b373
commit
7539406b38
|
|
@ -161,7 +161,11 @@ class PhotoViewActivity : BaseActivity(), OnChangeBottomBarVisibilityListener,
|
||||||
isFrs = intent.getBooleanExtra(EXTRA_IS_FRS, false)
|
isFrs = intent.getBooleanExtra(EXTRA_IS_FRS, false)
|
||||||
photoViewBeans = mutableListOf()
|
photoViewBeans = mutableListOf()
|
||||||
startPosition = intent.getIntExtra(EXTRA_POSITION, 0)
|
startPosition = intent.getIntExtra(EXTRA_POSITION, 0)
|
||||||
val parcelables = intent.getParcelableArrayExtra(EXTRA_BEANS)!!
|
val parcelables = intent.getParcelableArrayExtra(EXTRA_BEANS)
|
||||||
|
if (parcelables == null) {
|
||||||
|
finish()
|
||||||
|
return
|
||||||
|
}
|
||||||
photoViewBeans.addAll(parcelables.map { it as PhotoViewBean })
|
photoViewBeans.addAll(parcelables.map { it as PhotoViewBean })
|
||||||
amount = photoViewBeans.size.toString()
|
amount = photoViewBeans.size.toString()
|
||||||
mAdapter = PhotoViewAdapter(this, photoViewBeans)
|
mAdapter = PhotoViewAdapter(this, photoViewBeans)
|
||||||
|
|
|
||||||
|
|
@ -236,12 +236,16 @@ class ThreadMainPostAdapter(
|
||||||
}
|
}
|
||||||
val forumNameView = forumView.findViewById<TextView>(R.id.forum_bar_name)
|
val forumNameView = forumView.findViewById<TextView>(R.id.forum_bar_name)
|
||||||
val forumAvatarView: ImageView = forumView.findViewById(R.id.forum_bar_avatar)
|
val forumAvatarView: ImageView = forumView.findViewById(R.id.forum_bar_avatar)
|
||||||
if (!showForum || !context.appPreferences.showShortcutInThread || "0" == forumInfoBean.isExists || forumInfoBean.name?.isEmpty() == true) {
|
if (!showForum ||
|
||||||
|
!context.appPreferences.showShortcutInThread ||
|
||||||
|
"0" == forumInfoBean.isExists ||
|
||||||
|
forumInfoBean.name.isNullOrEmpty()
|
||||||
|
) {
|
||||||
forumView.visibility = View.GONE
|
forumView.visibility = View.GONE
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
forumView.visibility = View.VISIBLE
|
forumView.visibility = View.VISIBLE
|
||||||
forumView.setOnClickListener(View.OnClickListener { launch(context, forumInfoBean.name!!) })
|
forumView.setOnClickListener(View.OnClickListener { launch(context, forumInfoBean.name) })
|
||||||
forumNameView.text = forumInfoBean.name
|
forumNameView.text = forumInfoBean.name
|
||||||
ImageUtil.load(forumAvatarView, ImageUtil.LOAD_TYPE_AVATAR, forumInfoBean.avatar)
|
ImageUtil.load(forumAvatarView, ImageUtil.LOAD_TYPE_AVATAR, forumInfoBean.avatar)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,6 @@ import com.google.gson.annotations.SerializedName
|
||||||
|
|
||||||
@Keep
|
@Keep
|
||||||
data class GetForumListBean(
|
data class GetForumListBean(
|
||||||
@SerializedName("anti_info")
|
|
||||||
val antiInfo: List<Any>,
|
|
||||||
@SerializedName("button_content")
|
@SerializedName("button_content")
|
||||||
val buttonContent: String,
|
val buttonContent: String,
|
||||||
@SerializedName("can_use")
|
@SerializedName("can_use")
|
||||||
|
|
@ -20,7 +18,7 @@ data class GetForumListBean(
|
||||||
@SerializedName("forum_info")
|
@SerializedName("forum_info")
|
||||||
val forumInfo: List<ForumInfo>,
|
val forumInfo: List<ForumInfo>,
|
||||||
val level: String,
|
val level: String,
|
||||||
val logid: Int,
|
val logid: Long,
|
||||||
@SerializedName("msign_step_num")
|
@SerializedName("msign_step_num")
|
||||||
val msignStepNum: String,
|
val msignStepNum: String,
|
||||||
@SerializedName("num_notice")
|
@SerializedName("num_notice")
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ data class MSignBean(
|
||||||
val info: List<Info>,
|
val info: List<Info>,
|
||||||
@SerializedName("is_timeout")
|
@SerializedName("is_timeout")
|
||||||
val isTimeout: String,
|
val isTimeout: String,
|
||||||
val logid: Int,
|
val logid: Long,
|
||||||
@SerializedName("server_time")
|
@SerializedName("server_time")
|
||||||
val serverTime: String,
|
val serverTime: String,
|
||||||
@SerializedName("show_dialog")
|
@SerializedName("show_dialog")
|
||||||
|
|
|
||||||
|
|
@ -20,16 +20,14 @@ import com.huanchengfly.tieba.post.api.TiebaApi
|
||||||
import com.huanchengfly.tieba.post.api.models.ForumPageBean
|
import com.huanchengfly.tieba.post.api.models.ForumPageBean
|
||||||
import com.huanchengfly.tieba.post.api.retrofit.doIfFailure
|
import com.huanchengfly.tieba.post.api.retrofit.doIfFailure
|
||||||
import com.huanchengfly.tieba.post.api.retrofit.doIfSuccess
|
import com.huanchengfly.tieba.post.api.retrofit.doIfSuccess
|
||||||
import com.huanchengfly.tieba.post.api.retrofit.exception.TiebaException
|
import com.huanchengfly.tieba.post.api.retrofit.exception.getErrorCode
|
||||||
|
import com.huanchengfly.tieba.post.api.retrofit.exception.getErrorMessage
|
||||||
import com.huanchengfly.tieba.post.components.dividers.ForumDivider
|
import com.huanchengfly.tieba.post.components.dividers.ForumDivider
|
||||||
import com.huanchengfly.tieba.post.interfaces.OnSwitchListener
|
import com.huanchengfly.tieba.post.interfaces.OnSwitchListener
|
||||||
import com.huanchengfly.tieba.post.interfaces.Refreshable
|
import com.huanchengfly.tieba.post.interfaces.Refreshable
|
||||||
import com.huanchengfly.tieba.post.interfaces.ScrollTopable
|
import com.huanchengfly.tieba.post.interfaces.ScrollTopable
|
||||||
import com.huanchengfly.tieba.post.utils.Util
|
import com.huanchengfly.tieba.post.utils.Util
|
||||||
import com.scwang.smart.refresh.layout.SmartRefreshLayout
|
import com.scwang.smart.refresh.layout.SmartRefreshLayout
|
||||||
import retrofit2.Call
|
|
||||||
import retrofit2.Callback
|
|
||||||
import retrofit2.Response
|
|
||||||
|
|
||||||
class ForumFragment : BaseFragment(), Refreshable, OnSwitchListener, ScrollTopable {
|
class ForumFragment : BaseFragment(), Refreshable, OnSwitchListener, ScrollTopable {
|
||||||
private var page = 1
|
private var page = 1
|
||||||
|
|
@ -198,50 +196,49 @@ class ForumFragment : BaseFragment(), Refreshable, OnSwitchListener, ScrollTopab
|
||||||
delegateAdapter.clear()
|
delegateAdapter.clear()
|
||||||
delegateAdapter.notifyDataSetChanged()
|
delegateAdapter.notifyDataSetChanged()
|
||||||
page = 1
|
page = 1
|
||||||
TiebaApi.getInstance().forumPage(forumName!!, page, sortType, classifyId)
|
launchIO {
|
||||||
.enqueue(object : Callback<ForumPageBean> {
|
TiebaApi.getInstance()
|
||||||
override fun onFailure(call: Call<ForumPageBean>, t: Throwable) {
|
.forumPageAsync(forumName!!, page, sortType, classifyId)
|
||||||
var errorCode = -1
|
.doIfSuccess {
|
||||||
if (t is TiebaException) {
|
|
||||||
errorCode = t.code
|
|
||||||
}
|
|
||||||
if (!isGood) {
|
if (!isGood) {
|
||||||
if (attachContext is OnRefreshedListener) {
|
if (attachContext is OnRefreshedListener) {
|
||||||
(attachContext as OnRefreshedListener).onFailure(errorCode, t.message)
|
(attachContext as OnRefreshedListener).onSuccess(it)
|
||||||
}
|
|
||||||
}
|
|
||||||
refreshLayout?.finishRefresh(false)
|
|
||||||
if (errorCode == -1) {
|
|
||||||
Util.showNetworkErrorSnackbar(mRecyclerView) {
|
|
||||||
refreshLayout?.autoRefresh()
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
Toast.makeText(
|
|
||||||
attachContext,
|
|
||||||
attachContext.getString(R.string.toast_error, errorCode, t.message),
|
|
||||||
Toast.LENGTH_SHORT
|
|
||||||
).show()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onResponse(
|
|
||||||
call: Call<ForumPageBean>,
|
|
||||||
response: Response<ForumPageBean>
|
|
||||||
) {
|
|
||||||
val forumPageBean = response.body()!!
|
|
||||||
if (!isGood) {
|
|
||||||
if (attachContext is OnRefreshedListener) {
|
|
||||||
(attachContext as OnRefreshedListener).onSuccess(forumPageBean)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
refreshLayout?.finishRefresh()
|
refreshLayout?.finishRefresh()
|
||||||
mDataBean = forumPageBean
|
mDataBean = it
|
||||||
pageSize = forumPageBean.page?.pageSize?.toInt()!!
|
pageSize = it.page?.pageSize?.toInt()!!
|
||||||
forumAdapter.setData(forumPageBean)
|
forumAdapter.setData(it)
|
||||||
refreshLayout?.setNoMoreData(mDataBean!!.page?.hasMore == "0")
|
refreshLayout?.setNoMoreData(it.page?.hasMore == "0")
|
||||||
reloadAdapters()
|
reloadAdapters()
|
||||||
}
|
}
|
||||||
})
|
.doIfFailure {
|
||||||
|
if (!isGood) {
|
||||||
|
if (attachContext is OnRefreshedListener) {
|
||||||
|
(attachContext as OnRefreshedListener).onFailure(
|
||||||
|
it.getErrorCode(),
|
||||||
|
it.getErrorMessage()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
refreshLayout?.finishRefresh(false)
|
||||||
|
if (it.getErrorCode() == -1) {
|
||||||
|
Util.showNetworkErrorSnackbar(mRecyclerView) {
|
||||||
|
refreshLayout?.autoRefresh()
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Toast.makeText(
|
||||||
|
attachContext,
|
||||||
|
attachContext.getString(
|
||||||
|
R.string.toast_error,
|
||||||
|
it.getErrorCode(),
|
||||||
|
it.getErrorMessage()
|
||||||
|
),
|
||||||
|
Toast.LENGTH_SHORT
|
||||||
|
).show()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onRefresh() {
|
override fun onRefresh() {
|
||||||
|
|
|
||||||
|
|
@ -206,7 +206,7 @@ class MessageFragment : BaseFragment(), Refreshable, OnTabSelectedListener,
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun loadMore() {
|
private fun loadMore() {
|
||||||
if (dataBean!!.page!!.hasMore == "1") {
|
if (dataBean?.page?.hasMore == "1") {
|
||||||
page += 1
|
page += 1
|
||||||
load(false)
|
load(false)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -74,10 +74,17 @@ public class PhotoViewFragment extends BaseFragment {
|
||||||
@SuppressLint("ClickableViewAccessibility")
|
@SuppressLint("ClickableViewAccessibility")
|
||||||
private void loadByBigImageView() {
|
private void loadByBigImageView() {
|
||||||
if (!canLoad()) return;
|
if (!canLoad()) return;
|
||||||
|
String url = photoViewBean.getOriginUrl();
|
||||||
|
if (url == null) {
|
||||||
|
url = photoViewBean.getUrl();
|
||||||
|
}
|
||||||
|
if (url == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
bigImageView.setVisibility(View.VISIBLE);
|
bigImageView.setVisibility(View.VISIBLE);
|
||||||
bigImageView.setImageViewFactory(new GlideImageViewFactory());
|
bigImageView.setImageViewFactory(new GlideImageViewFactory());
|
||||||
bigImageView.setProgressIndicator(new CircleProgressIndicator());
|
bigImageView.setProgressIndicator(new CircleProgressIndicator());
|
||||||
bigImageView.showImage(Uri.parse(photoViewBean.getOriginUrl()));
|
bigImageView.showImage(Uri.parse(url));
|
||||||
bigImageView.setOnTouchListener((view, event) -> {
|
bigImageView.setOnTouchListener((view, event) -> {
|
||||||
showBottomBar(true);
|
showBottomBar(true);
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
|
|
@ -36,8 +36,8 @@ class OKSignService : IntentService(TAG), CoroutineScope, ProgressListener {
|
||||||
private var position = 0
|
private var position = 0
|
||||||
|
|
||||||
@Deprecated("Deprecated in Java")
|
@Deprecated("Deprecated in Java")
|
||||||
override fun onCreate() {
|
override fun onStart(intent: Intent?, startId: Int) {
|
||||||
super.onCreate()
|
super.onStart(intent, startId)
|
||||||
updateNotification(
|
updateNotification(
|
||||||
getString(R.string.title_fetching_forum_list),
|
getString(R.string.title_fetching_forum_list),
|
||||||
getString(R.string.text_please_wait)
|
getString(R.string.text_please_wait)
|
||||||
|
|
@ -67,6 +67,7 @@ class OKSignService : IntentService(TAG), CoroutineScope, ProgressListener {
|
||||||
.setSubText(getString(R.string.title_oksign))
|
.setSubText(getString(R.string.title_oksign))
|
||||||
.setSmallIcon(R.drawable.ic_oksign)
|
.setSmallIcon(R.drawable.ic_oksign)
|
||||||
.setAutoCancel(true)
|
.setAutoCancel(true)
|
||||||
|
.setStyle(NotificationCompat.BigTextStyle())
|
||||||
.setColor(ThemeUtils.getColorByAttr(this, R.attr.colorPrimary))
|
.setColor(ThemeUtils.getColorByAttr(this, R.attr.colorPrimary))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import android.content.Context;
|
||||||
|
|
||||||
import androidx.annotation.ColorInt;
|
import androidx.annotation.ColorInt;
|
||||||
import androidx.annotation.ColorRes;
|
import androidx.annotation.ColorRes;
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
|
|
@ -16,7 +17,7 @@ public class AppIntroFragment extends BaseIntroFragment {
|
||||||
private CharSequence title;
|
private CharSequence title;
|
||||||
private CharSequence subtitle;
|
private CharSequence subtitle;
|
||||||
|
|
||||||
private AppIntroFragment(Builder builder) {
|
private AppIntroFragment(@NonNull Builder builder) {
|
||||||
this.iconRes = builder.getIconRes();
|
this.iconRes = builder.getIconRes();
|
||||||
this.title = builder.getTitle();
|
this.title = builder.getTitle();
|
||||||
this.subtitle = builder.getSubtitle();
|
this.subtitle = builder.getSubtitle();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue