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>,
response: Response<LikeForumResultBean>
) {
val data = response.body() ?: return
mDataBean!!.forum?.isLike = "1"
Toast.makeText(
this@ForumActivity,
getString(
R.string.toast_like_success,
response.body()!!.info?.memberSum
data.info?.memberSum
),
Toast.LENGTH_SHORT
).show()

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -123,13 +123,13 @@ class UserPostFragment : BaseFragment() {
response: Response<UserPostBean>
) {
page += 1
val data = response.body()
val data = response.body() ?: return
userPostBean = data
refreshLayout.finishLoadMore()
if (data!!.postList.isNullOrEmpty()) {
if (data.postList.isNullOrEmpty()) {
refreshLayout.setNoMoreData(true)
} 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) {
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")) {
val isTiebaLink =
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_posts_num">回贴</string>
<string name="title_stat_concerns_num">关注</string>
<string name="toast_data_error">数据错误</string>
<string name="toast_feature_unavailable">该功能尚未实现</string>
</resources>