fix: 修复 Bugs

This commit is contained in:
HuanCheng65 2022-08-11 11:14:58 +08:00
parent 7adfcf0401
commit f30498e83a
No known key found for this signature in database
GPG Key ID: E9031EF91A805148
10 changed files with 97 additions and 51 deletions

View File

@ -591,12 +591,13 @@ class ForumActivity : BaseActivity(), View.OnClickListener, OnRefreshedListener,
call: Call<LikeForumResultBean>, call: Call<LikeForumResultBean>,
response: Response<LikeForumResultBean> response: Response<LikeForumResultBean>
) { ) {
val data = response.body() ?: return
mDataBean!!.forum?.isLike = "1" mDataBean!!.forum?.isLike = "1"
Toast.makeText( Toast.makeText(
this@ForumActivity, this@ForumActivity,
getString( getString(
R.string.toast_like_success, R.string.toast_like_success,
response.body()!!.info?.memberSum data.info?.memberSum
), ),
Toast.LENGTH_SHORT Toast.LENGTH_SHORT
).show() ).show()

View File

@ -88,13 +88,13 @@ class PhotoViewActivity : BaseActivity(), OnChangeBottomBarVisibilityListener,
false false
).enqueue(object : Callback<PicPageBean?> { ).enqueue(object : Callback<PicPageBean?> {
override fun onResponse(call: Call<PicPageBean?>, response: Response<PicPageBean?>) { override fun onResponse(call: Call<PicPageBean?>, response: Response<PicPageBean?>) {
val data = response.body()!!
mLoading = false mLoading = false
amount = data.picAmount ?: "${photoViewBeans.size}" val data = response.body()
amount = data?.picAmount ?: "${photoViewBeans.size}"
updateCounter(mViewPager.currentItem) updateCounter(mViewPager.currentItem)
val picBeans: MutableList<PicPageBean.PicBean> = ArrayList() val picBeans: MutableList<PicPageBean.PicBean> = ArrayList()
val imgInfoBeans: MutableList<ImgInfoBean> = ArrayList() val imgInfoBeans: MutableList<ImgInfoBean> = ArrayList()
if (data.picList?.isNotEmpty()!!) { if (data?.picList?.isNotEmpty() == true) {
val index = data.picList.last().overAllIndex?.toInt() val index = data.picList.last().overAllIndex?.toInt()
if (index != null) { if (index != null) {
loadFinished = index >= amount!!.toInt() loadFinished = index >= amount!!.toInt()

View File

@ -201,7 +201,7 @@ class ReplyActivity : BaseActivity(), View.OnClickListener,
val intent = intent val intent = intent
val jsonData = intent.getStringExtra("data") val jsonData = intent.getStringExtra("data")
replyInfoBean = GsonUtil.getGson().fromJson(jsonData, ReplyInfoBean::class.java) replyInfoBean = GsonUtil.getGson().fromJson(jsonData, ReplyInfoBean::class.java)
val draft = where("hash = ?", replyInfoBean?.hash()) val draft = where("hash = ?", replyInfoBean?.hash() ?: "")
.findFirst(Draft::class.java) .findFirst(Draft::class.java)
if (draft != null) { if (draft != null) {
content = draft.content content = draft.content
@ -502,6 +502,10 @@ class ReplyActivity : BaseActivity(), View.OnClickListener,
private fun realReply( /*String code, String md5*/) { private fun realReply( /*String code, String md5*/) {
if (replyInfoBean == null && replyInfoBean!!.forumId == null) {
toastShort(R.string.toast_data_error)
return
}
loadingDialog = LoadingDialog(this) loadingDialog = LoadingDialog(this)
loadingDialog!!.show() loadingDialog!!.show()
getImageInfo(object : ReplyContentCallback { getImageInfo(object : ReplyContentCallback {

View File

@ -181,36 +181,41 @@ class UserActivity : BaseActivity() {
} }
fun refreshHeader() { fun refreshHeader() {
titleView.text = profileBean!!.user!!.nameShow profileBean?.let {
sloganView.text = profileBean!!.user!!.intro if (it.user == null) {
followStatTv.text = "${profileBean!!.user!!.concernNum}" return
fansStatTv.text = "${profileBean!!.user!!.fansNum}" }
titleView.text = it.user.nameShow
sloganView.text = it.user.intro
followStatTv.text = "${it.user.concernNum}"
fansStatTv.text = "${it.user.fansNum}"
//getString(R.string.tip_stat, profileBean!!.user!!.concernNum, profileBean!!.user!!.fansNum) //getString(R.string.tip_stat, profileBean!!.user!!.concernNum, profileBean!!.user!!.fansNum)
if (avatarView.tag == null) { if (avatarView.tag == null) {
ImageUtil.load( ImageUtil.load(
avatarView, avatarView,
ImageUtil.LOAD_TYPE_AVATAR, ImageUtil.LOAD_TYPE_AVATAR,
StringUtil.getAvatarUrl(profileBean!!.user!!.portrait) StringUtil.getAvatarUrl(it.user.portrait)
) )
ImageUtil.initImageView( ImageUtil.initImageView(
avatarView, avatarView,
PhotoViewBean(StringUtil.getAvatarUrl(profileBean!!.user!!.portrait)) PhotoViewBean(StringUtil.getAvatarUrl(it.user.portrait))
) )
} }
if (TextUtils.equals(AccountUtil.getUid(this), profileBean!!.user!!.id)) { if (TextUtils.equals(AccountUtil.getUid(this), it.user.id)) {
actionBtn.setText(R.string.menu_edit_info) actionBtn.setText(R.string.menu_edit_info)
} else { } else {
if ("1" == profileBean!!.user!!.hasConcerned) { if ("1" == it.user.hasConcerned) {
actionBtn.setText(R.string.button_unfollow) actionBtn.setText(R.string.button_unfollow)
} else { } else {
actionBtn.setText(R.string.button_follow) actionBtn.setText(R.string.button_follow)
} }
} }
sexTv.text = sexTv.text =
if (profileBean!!.user!!.sex == "1") "" else if (profileBean!!.user!!.sex == "2") "" else "?" if (it.user.sex == "1") "" else if (it.user.sex == "2") "" else "?"
tbAgeTv.text = getString(R.string.tb_age, profileBean!!.user!!.tbAge) tbAgeTv.text = getString(R.string.tb_age, it.user.tbAge)
infoChips.visibility = View.VISIBLE infoChips.visibility = View.VISIBLE
} }
}
override fun onCreateOptionsMenu(menu: Menu): Boolean { override fun onCreateOptionsMenu(menu: Menu): Boolean {
menuInflater.inflate(R.menu.menu_user_space, menu) menuInflater.inflate(R.menu.menu_user_space, menu)

View File

@ -45,19 +45,24 @@ class WebViewActivity : BaseActivity(), OnReceivedTitleListener, OnOverrideUrlLo
if (title != null) { if (title != null) {
setTitle(title) setTitle(title)
} }
mUrl = intent.getStringExtra(EXTRA_URL) mUrl = intent.getStringExtra(EXTRA_URL).also { url ->
if (url != null) {
mWebViewFragment = WebViewFragment.newInstance( mWebViewFragment = WebViewFragment.newInstance(
mUrl, url,
TAG, TAG,
title, title,
false, false,
true, true,
mUrl!!.contains(DOMAIN_SAPI) url.contains(DOMAIN_SAPI)
).also { ).also {
supportFragmentManager.beginTransaction() supportFragmentManager.beginTransaction()
.replace(R.id.main, it, TAG) .replace(R.id.main, it, TAG)
.commit() .commit()
} }
} else {
finish()
}
}
} }
override fun setTitle(newTitle: String?) { override fun setTitle(newTitle: String?) {

View File

@ -23,13 +23,19 @@ import okhttp3.Interceptor
import okhttp3.OkHttpClient import okhttp3.OkHttpClient
import retrofit2.Retrofit import retrofit2.Retrofit
import retrofit2.converter.protobuf.ProtoConverterFactory import retrofit2.converter.protobuf.ProtoConverterFactory
import java.util.concurrent.TimeUnit
import kotlin.math.roundToInt
object RetrofitTiebaApi { object RetrofitTiebaApi {
private const val READ_TIMEOUT = 60L
private const val CONNECT_TIMEOUT = 60L
private const val WRITE_TIMEOUT = 60L
private val initTime = System.currentTimeMillis() private val initTime = System.currentTimeMillis()
private val clientId = "wappc_${initTime}_${Math.round(Math.random() * 1000).toInt()}" private val clientId = "wappc_${initTime}_${(Math.random() * 1000).roundToInt()}"
private val stParamInterceptor = StParamInterceptor() private val stParamInterceptor = StParamInterceptor()
private val connectionPool = ConnectionPool() private val connectionPool = ConnectionPool(32, 5, TimeUnit.MINUTES)
private val defaultCommonParamInterceptor = CommonParamInterceptor( private val defaultCommonParamInterceptor = CommonParamInterceptor(
Param.BDUSS to { AccountUtil.getBduss(BaseApplication.INSTANCE) }, Param.BDUSS to { AccountUtil.getBduss(BaseApplication.INSTANCE) },
@ -130,15 +136,19 @@ object RetrofitTiebaApi {
.addConverterFactory(gsonConverterFactory) .addConverterFactory(gsonConverterFactory)
.addConverterFactory(ProtoConverterFactory.create()) .addConverterFactory(ProtoConverterFactory.create())
.client(OkHttpClient.Builder().apply { .client(OkHttpClient.Builder().apply {
readTimeout(READ_TIMEOUT, TimeUnit.SECONDS)
connectTimeout(CONNECT_TIMEOUT, TimeUnit.SECONDS)
writeTimeout(WRITE_TIMEOUT, TimeUnit.SECONDS)
interceptors.forEach { interceptors.forEach {
addInterceptor(it) addInterceptor(it)
} }
addInterceptor(DropInterceptor) addInterceptor(DropInterceptor)
addInterceptor(sortAndSignInterceptor)
addInterceptor(FailureResponseInterceptor) addInterceptor(FailureResponseInterceptor)
addInterceptor(ForceLoginInterceptor) addInterceptor(ForceLoginInterceptor)
addInterceptor(sortAndSignInterceptor)
connectionPool(connectionPool) connectionPool(connectionPool)
}.build()) }.build())
.build() .build()
.create(T::class.java) .create(T::class.java)
} }

View File

@ -52,6 +52,7 @@ public class UserLikeForumFragment extends BaseFragment {
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
userLikeForumAdapter = new UserLikeForumAdapter(getAttachContext());
Bundle args = getArguments(); Bundle args = getArguments();
if (args != null) { if (args != null) {
uid = args.getString(PARAM_UID, null); uid = args.getString(PARAM_UID, null);
@ -72,7 +73,9 @@ public class UserLikeForumFragment extends BaseFragment {
refreshLayout.setOnLoadMoreListener(refreshLayout -> load()); refreshLayout.setOnLoadMoreListener(refreshLayout -> load());
recyclerView.setLayoutManager(new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL)); recyclerView.setLayoutManager(new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL));
recyclerView.addItemDecoration(new StaggeredDividerItemDecoration(getAttachContext(), 16)); recyclerView.addItemDecoration(new StaggeredDividerItemDecoration(getAttachContext(), 16));
if (userLikeForumAdapter == null) {
userLikeForumAdapter = new UserLikeForumAdapter(getAttachContext()); userLikeForumAdapter = new UserLikeForumAdapter(getAttachContext());
}
userLikeForumAdapter.setOnItemChildClickListener( userLikeForumAdapter.setOnItemChildClickListener(
R.id.forum_item_card, R.id.forum_item_card,
(OnItemChildClickListener<UserLikeForumBean.ForumBean>) (OnItemChildClickListener<UserLikeForumBean.ForumBean>)

View File

@ -123,13 +123,13 @@ class UserPostFragment : BaseFragment() {
response: Response<UserPostBean> response: Response<UserPostBean>
) { ) {
page += 1 page += 1
val data = response.body() val data = response.body() ?: return
userPostBean = data userPostBean = data
refreshLayout.finishLoadMore() refreshLayout.finishLoadMore()
if (data!!.postList.isNullOrEmpty()) { if (data.postList.isNullOrEmpty()) {
refreshLayout.setNoMoreData(true) refreshLayout.setNoMoreData(true)
} else { } else {
userPostAdapter.insert(data.postList!!) userPostAdapter.insert(data.postList)
} }
} }

View File

@ -139,6 +139,22 @@ fun launchUrl(context: Context, url: String) {
if (host == null || scheme == null || path == null) { if (host == null || scheme == null || path == null) {
return return
} }
if (scheme == "tiebaclient") {
val action = uri.getQueryParameter("action")
when (action) {
"preview_file" -> {
val realUrl = uri.getQueryParameter("url")
if (realUrl.isNullOrEmpty()) {
return
}
launchUrl(context, realUrl)
}
else -> {
context.toastShort(R.string.toast_feature_unavailable)
}
}
return
}
if (!path.contains("android_asset")) { if (!path.contains("android_asset")) {
val isTiebaLink = val isTiebaLink =
host.contains("tieba.baidu.com") || host.contains("wappass.baidu.com") || host.contains( host.contains("tieba.baidu.com") || host.contains("wappass.baidu.com") || host.contains(

View File

@ -550,4 +550,6 @@
<string name="title_stat_threads_num">贴子</string> <string name="title_stat_threads_num">贴子</string>
<string name="title_stat_posts_num">回贴</string> <string name="title_stat_posts_num">回贴</string>
<string name="title_stat_concerns_num">关注</string> <string name="title_stat_concerns_num">关注</string>
<string name="toast_data_error">数据错误</string>
<string name="toast_feature_unavailable">该功能尚未实现</string>
</resources> </resources>