fix: 修复举报无法使用
This commit is contained in:
parent
150a0cce4e
commit
63642faaa5
|
|
@ -1,9 +1,11 @@
|
||||||
package com.huanchengfly.tieba.post
|
package com.huanchengfly.tieba.post
|
||||||
|
|
||||||
|
import android.animation.LayoutTransition
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
|
import android.view.ViewGroup
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.annotation.ColorRes
|
import androidx.annotation.ColorRes
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
|
|
@ -65,6 +67,11 @@ fun Context.toastShort(text: String) {
|
||||||
Toast.makeText(this, text, Toast.LENGTH_SHORT).show()
|
Toast.makeText(this, text, Toast.LENGTH_SHORT).show()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Context.toastShort(resId: Int) {
|
fun Context.toastShort(resId: Int, vararg args: Any) {
|
||||||
Toast.makeText(this, resId, Toast.LENGTH_SHORT).show()
|
Toast.makeText(this, getString(resId, *args), Toast.LENGTH_SHORT).show()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun ViewGroup.enableChangingLayoutTransition() {
|
||||||
|
this.layoutTransition = LayoutTransition()
|
||||||
|
this.layoutTransition.enableTransitionType(LayoutTransition.CHANGING)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -482,11 +482,9 @@ class ThreadActivity : BaseActivity(), View.OnClickListener {
|
||||||
|
|
||||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||||
when (item.itemId) {
|
when (item.itemId) {
|
||||||
R.id.menu_report -> navigationHelper!!.navigationByData(NavigationHelper.ACTION_URL,
|
R.id.menu_report -> {
|
||||||
getString(R.string.url_post_report,
|
if (dataBean != null) TiebaUtil.reportPost(this, dataBean?.thread?.postId!!)
|
||||||
dataBean!!.forum?.id,
|
}
|
||||||
dataBean!!.thread?.threadId,
|
|
||||||
dataBean!!.thread?.postId))
|
|
||||||
R.id.menu_share -> TiebaUtil.shareText(this, url, if (dataBean == null) null else dataBean!!.thread?.title)
|
R.id.menu_share -> TiebaUtil.shareText(this, url, if (dataBean == null) null else dataBean!!.thread?.title)
|
||||||
R.id.menu_jump_page -> {
|
R.id.menu_jump_page -> {
|
||||||
val dialog = EditTextDialog(this)
|
val dialog = EditTextDialog(this)
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,7 @@ import com.huanchengfly.tieba.post.utils.ImageUtil;
|
||||||
import com.huanchengfly.tieba.post.utils.NavigationHelper;
|
import com.huanchengfly.tieba.post.utils.NavigationHelper;
|
||||||
import com.huanchengfly.tieba.post.utils.StringUtil;
|
import com.huanchengfly.tieba.post.utils.StringUtil;
|
||||||
import com.huanchengfly.tieba.post.utils.ThemeUtil;
|
import com.huanchengfly.tieba.post.utils.ThemeUtil;
|
||||||
|
import com.huanchengfly.tieba.post.utils.TiebaUtil;
|
||||||
import com.huanchengfly.tieba.post.utils.TimeUtils;
|
import com.huanchengfly.tieba.post.utils.TimeUtils;
|
||||||
import com.huanchengfly.tieba.post.utils.Util;
|
import com.huanchengfly.tieba.post.utils.Util;
|
||||||
import com.huanchengfly.tieba.post.widgets.MyLinearLayout;
|
import com.huanchengfly.tieba.post.widgets.MyLinearLayout;
|
||||||
|
|
@ -131,7 +132,7 @@ public class RecyclerFloorAdapter extends CommonBaseAdapter<SubFloorListBean.Pos
|
||||||
.putExtra("data", replyData));
|
.putExtra("data", replyData));
|
||||||
return true;
|
return true;
|
||||||
case R.id.menu_report:
|
case R.id.menu_report:
|
||||||
navigationHelper.navigationByData(NavigationHelper.ACTION_URL, mContext.getString(R.string.url_post_report, dataBean.getForum().getId(), dataBean.getThread().getId(), postInfo.getId()));
|
TiebaUtil.reportPost(mContext, postInfo.getId());
|
||||||
return true;
|
return true;
|
||||||
case R.id.menu_copy:
|
case R.id.menu_copy:
|
||||||
StringBuilder stringBuilder = new StringBuilder();
|
StringBuilder stringBuilder = new StringBuilder();
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,7 @@ import com.huanchengfly.tieba.post.utils.ImageUtil;
|
||||||
import com.huanchengfly.tieba.post.utils.NavigationHelper;
|
import com.huanchengfly.tieba.post.utils.NavigationHelper;
|
||||||
import com.huanchengfly.tieba.post.utils.StringUtil;
|
import com.huanchengfly.tieba.post.utils.StringUtil;
|
||||||
import com.huanchengfly.tieba.post.utils.ThemeUtil;
|
import com.huanchengfly.tieba.post.utils.ThemeUtil;
|
||||||
|
import com.huanchengfly.tieba.post.utils.TiebaUtil;
|
||||||
import com.huanchengfly.tieba.post.utils.TimeUtils;
|
import com.huanchengfly.tieba.post.utils.TimeUtils;
|
||||||
import com.huanchengfly.tieba.post.utils.Util;
|
import com.huanchengfly.tieba.post.utils.Util;
|
||||||
import com.huanchengfly.tieba.post.widgets.MyImageView;
|
import com.huanchengfly.tieba.post.widgets.MyImageView;
|
||||||
|
|
@ -412,9 +413,6 @@ public class RecyclerThreadAdapter extends MultiBaseAdapter<ThreadContentBean.Po
|
||||||
mContext.startActivity(new Intent(mContext, ReplyActivity.class)
|
mContext.startActivity(new Intent(mContext, ReplyActivity.class)
|
||||||
.putExtra("data", replyData));
|
.putExtra("data", replyData));
|
||||||
return true;
|
return true;
|
||||||
case R.id.menu_report:
|
|
||||||
navigationHelper.navigationByData(NavigationHelper.ACTION_URL, mContext.getString(R.string.url_post_report, dataBean.getForum().getId(), dataBean.getThread().getId(), subPostListItemBean.getId()));
|
|
||||||
return true;
|
|
||||||
case R.id.menu_copy:
|
case R.id.menu_copy:
|
||||||
StringBuilder stringBuilder = new StringBuilder();
|
StringBuilder stringBuilder = new StringBuilder();
|
||||||
for (ThreadContentBean.ContentBean contentBean : subPostListItemBean.getContent()) {
|
for (ThreadContentBean.ContentBean contentBean : subPostListItemBean.getContent()) {
|
||||||
|
|
@ -463,6 +461,7 @@ public class RecyclerThreadAdapter extends MultiBaseAdapter<ThreadContentBean.Po
|
||||||
return false;
|
return false;
|
||||||
})
|
})
|
||||||
.setInitMenuCallback(menu -> {
|
.setInitMenuCallback(menu -> {
|
||||||
|
menu.findItem(R.id.menu_report).setVisible(false);
|
||||||
if (TextUtils.equals(AccountUtil.getUid(mContext), subPostListItemBean.getAuthorId())) {
|
if (TextUtils.equals(AccountUtil.getUid(mContext), subPostListItemBean.getAuthorId())) {
|
||||||
menu.findItem(R.id.menu_delete).setVisible(true);
|
menu.findItem(R.id.menu_delete).setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
@ -487,7 +486,7 @@ public class RecyclerThreadAdapter extends MultiBaseAdapter<ThreadContentBean.Po
|
||||||
dataBean.getUser().getNameShow()).setPn(dataBean.getPage().getOffset()).toString()));
|
dataBean.getUser().getNameShow()).setPn(dataBean.getPage().getOffset()).toString()));
|
||||||
return true;
|
return true;
|
||||||
case R.id.menu_report:
|
case R.id.menu_report:
|
||||||
navigationHelper.navigationByData(NavigationHelper.ACTION_URL, mContext.getString(R.string.url_post_report, dataBean.getForum().getId(), dataBean.getThread().getId(), postListItemBean.getId()));
|
TiebaUtil.reportPost(mContext, postListItemBean.getId());
|
||||||
return true;
|
return true;
|
||||||
case R.id.menu_copy:
|
case R.id.menu_copy:
|
||||||
StringBuilder stringBuilder = new StringBuilder();
|
StringBuilder stringBuilder = new StringBuilder();
|
||||||
|
|
|
||||||
|
|
@ -552,4 +552,13 @@ interface ITiebaApi {
|
||||||
sortType: ForumSortType = ForumSortType.REPLY_TIME,
|
sortType: ForumSortType = ForumSortType.REPLY_TIME,
|
||||||
pageSize: Int = 30
|
pageSize: Int = 30
|
||||||
): Call<ForumBean>
|
): Call<ForumBean>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取举报贴子/回贴页面 URL
|
||||||
|
*
|
||||||
|
* @param postId PID
|
||||||
|
*/
|
||||||
|
fun checkReportPost(
|
||||||
|
postId: String
|
||||||
|
): Call<CheckReportBean>
|
||||||
}
|
}
|
||||||
|
|
@ -231,4 +231,12 @@ object MixedTiebaApiImpl : ITiebaApi {
|
||||||
forumName: String, page: Int, goodClassifyId: String?, sortType: ForumSortType, pageSize: Int
|
forumName: String, page: Int, goodClassifyId: String?, sortType: ForumSortType, pageSize: Int
|
||||||
): Call<ForumBean> =
|
): Call<ForumBean> =
|
||||||
RetrofitTiebaApi.WEB_TIEBA_API.frs(forumName, (page - 1) * pageSize, sortType.value, goodClassifyId)
|
RetrofitTiebaApi.WEB_TIEBA_API.frs(forumName, (page - 1) * pageSize, sortType.value, goodClassifyId)
|
||||||
|
|
||||||
|
override fun checkReportPost(postId: String): Call<CheckReportBean> =
|
||||||
|
RetrofitTiebaApi.MINI_TIEBA_API.checkReport(
|
||||||
|
category = "1",
|
||||||
|
reportParam = mapOf(
|
||||||
|
"pid" to postId
|
||||||
|
)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
@ -0,0 +1,15 @@
|
||||||
|
package com.huanchengfly.tieba.post.api.models
|
||||||
|
|
||||||
|
import com.google.gson.annotations.SerializedName
|
||||||
|
|
||||||
|
data class CheckReportBean(
|
||||||
|
@SerializedName("errno")
|
||||||
|
var errorCode: Int?,
|
||||||
|
@SerializedName("errmsg")
|
||||||
|
var errorMsg: String?,
|
||||||
|
val data: CheckReportDataBean
|
||||||
|
) {
|
||||||
|
data class CheckReportDataBean(
|
||||||
|
val url: String?
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
@ -227,4 +227,13 @@ interface MiniTiebaApi {
|
||||||
@retrofit2.http.Header(Header.USER_AGENT) user_agent: String = "bdtb for Android $client_version",
|
@retrofit2.http.Header(Header.USER_AGENT) user_agent: String = "bdtb for Android $client_version",
|
||||||
@Query("cuid_gid") cuid_gid: String = ""
|
@Query("cuid_gid") cuid_gid: String = ""
|
||||||
): Call<SearchUserBean>
|
): Call<SearchUserBean>
|
||||||
|
|
||||||
|
@Headers("${Header.FORCE_LOGIN}: ${Header.FORCE_LOGIN_TRUE}")
|
||||||
|
@POST("/c/f/ueg/checkjubao")
|
||||||
|
@FormUrlEncoded
|
||||||
|
fun checkReport(
|
||||||
|
@Field("category") category: String,
|
||||||
|
@FieldMap reportParam: Map<String, String>,
|
||||||
|
@Field("stoken") stoken: String? = AccountUtil.getLoginInfo(BaseApplication.instance)?.getsToken()
|
||||||
|
): Call<CheckReportBean>
|
||||||
}
|
}
|
||||||
|
|
@ -6,6 +6,7 @@ import android.graphics.Typeface
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.text.TextUtils
|
import android.text.TextUtils
|
||||||
import android.view.View
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
import android.widget.CompoundButton
|
import android.widget.CompoundButton
|
||||||
import android.widget.ImageView
|
import android.widget.ImageView
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
|
|
@ -18,6 +19,7 @@ import com.gyf.immersionbar.ImmersionBar
|
||||||
import com.huanchengfly.tieba.post.R
|
import com.huanchengfly.tieba.post.R
|
||||||
import com.huanchengfly.tieba.post.activities.*
|
import com.huanchengfly.tieba.post.activities.*
|
||||||
import com.huanchengfly.tieba.post.api.interfaces.CommonCallback
|
import com.huanchengfly.tieba.post.api.interfaces.CommonCallback
|
||||||
|
import com.huanchengfly.tieba.post.enableChangingLayoutTransition
|
||||||
import com.huanchengfly.tieba.post.goToActivity
|
import com.huanchengfly.tieba.post.goToActivity
|
||||||
import com.huanchengfly.tieba.post.interfaces.Refreshable
|
import com.huanchengfly.tieba.post.interfaces.Refreshable
|
||||||
import com.huanchengfly.tieba.post.models.MyInfoBean
|
import com.huanchengfly.tieba.post.models.MyInfoBean
|
||||||
|
|
@ -143,6 +145,7 @@ class MyInfoFragment : BaseFragment(), View.OnClickListener, CompoundButton.OnCh
|
||||||
threadsTextView
|
threadsTextView
|
||||||
).forEach {
|
).forEach {
|
||||||
it.typeface = Typeface.createFromAsset(attachContext.assets, "bebas.ttf")
|
it.typeface = Typeface.createFromAsset(attachContext.assets, "bebas.ttf")
|
||||||
|
(it.parent as ViewGroup).enableChangingLayoutTransition()
|
||||||
}
|
}
|
||||||
listOf(
|
listOf(
|
||||||
R.id.my_info_collect,
|
R.id.my_info_collect,
|
||||||
|
|
@ -154,6 +157,7 @@ class MyInfoFragment : BaseFragment(), View.OnClickListener, CompoundButton.OnCh
|
||||||
).forEach {
|
).forEach {
|
||||||
view.findViewById<View>(it).setOnClickListener(this)
|
view.findViewById<View>(it).setOnClickListener(this)
|
||||||
}
|
}
|
||||||
|
view.findViewById<ViewGroup>(R.id.my_info_user).enableChangingLayoutTransition()
|
||||||
(followsTextView.parent as View).setOnClickListener {
|
(followsTextView.parent as View).setOnClickListener {
|
||||||
WebViewActivity.launch(attachContext, attachContext.resources.getString(R.string.url_user_home, dataBean!!.data.getName(), 2))
|
WebViewActivity.launch(attachContext, attachContext.resources.getString(R.string.url_user_home, dataBean!!.data.getName(), 2))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,7 @@ import com.huanchengfly.tieba.post.interfaces.OnReceivedTitleListener;
|
||||||
import com.huanchengfly.tieba.post.interfaces.WebViewListener;
|
import com.huanchengfly.tieba.post.interfaces.WebViewListener;
|
||||||
import com.huanchengfly.tieba.post.models.PermissionBean;
|
import com.huanchengfly.tieba.post.models.PermissionBean;
|
||||||
import com.huanchengfly.tieba.post.utils.AccountUtil;
|
import com.huanchengfly.tieba.post.utils.AccountUtil;
|
||||||
|
import com.huanchengfly.tieba.post.utils.AssetUtil;
|
||||||
import com.huanchengfly.tieba.post.utils.DialogUtil;
|
import com.huanchengfly.tieba.post.utils.DialogUtil;
|
||||||
import com.huanchengfly.tieba.post.utils.FileUtil;
|
import com.huanchengfly.tieba.post.utils.FileUtil;
|
||||||
import com.huanchengfly.tieba.post.utils.HistoryHelper;
|
import com.huanchengfly.tieba.post.utils.HistoryHelper;
|
||||||
|
|
@ -46,7 +47,6 @@ import com.huanchengfly.tieba.post.utils.NavigationHelper;
|
||||||
import com.huanchengfly.tieba.post.utils.ThemeUtil;
|
import com.huanchengfly.tieba.post.utils.ThemeUtil;
|
||||||
import com.huanchengfly.tieba.post.utils.TiebaLiteJavaScript;
|
import com.huanchengfly.tieba.post.utils.TiebaLiteJavaScript;
|
||||||
import com.huanchengfly.tieba.post.utils.Util;
|
import com.huanchengfly.tieba.post.utils.Util;
|
||||||
import com.huanchengfly.tieba.post.utils.AssetUtil;
|
|
||||||
import com.yanzhenjie.permission.AndPermission;
|
import com.yanzhenjie.permission.AndPermission;
|
||||||
import com.yanzhenjie.permission.runtime.Permission;
|
import com.yanzhenjie.permission.runtime.Permission;
|
||||||
|
|
||||||
|
|
@ -59,7 +59,7 @@ import static com.huanchengfly.tieba.post.utils.FileUtil.FILE_TYPE_DOWNLOAD;
|
||||||
//TODO: 代码太烂,需要重写
|
//TODO: 代码太烂,需要重写
|
||||||
public class WebViewFragment extends BaseFragment implements DownloadListener {
|
public class WebViewFragment extends BaseFragment implements DownloadListener {
|
||||||
public static final String TAG = WebViewFragment.class.getSimpleName();
|
public static final String TAG = WebViewFragment.class.getSimpleName();
|
||||||
private static final String DEFAULT_TITLE = "贴吧 Lite";
|
private static final String DEFAULT_TITLE = "";
|
||||||
private final static int FILE_CHOOSER_RESULT_CODE = 1;
|
private final static int FILE_CHOOSER_RESULT_CODE = 1;
|
||||||
private String mUrl;
|
private String mUrl;
|
||||||
private String mTitle;
|
private String mTitle;
|
||||||
|
|
|
||||||
|
|
@ -8,9 +8,16 @@ import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import com.huanchengfly.tieba.post.R
|
import com.huanchengfly.tieba.post.R
|
||||||
|
import com.huanchengfly.tieba.post.activities.WebViewActivity
|
||||||
|
import com.huanchengfly.tieba.post.api.TiebaApi
|
||||||
|
import com.huanchengfly.tieba.post.api.models.CheckReportBean
|
||||||
|
import com.huanchengfly.tieba.post.components.dialogs.LoadingDialog
|
||||||
import com.huanchengfly.tieba.post.receivers.AutoSignAlarm
|
import com.huanchengfly.tieba.post.receivers.AutoSignAlarm
|
||||||
import com.huanchengfly.tieba.post.services.OKSignService
|
import com.huanchengfly.tieba.post.services.OKSignService
|
||||||
import com.huanchengfly.tieba.post.toastShort
|
import com.huanchengfly.tieba.post.toastShort
|
||||||
|
import retrofit2.Call
|
||||||
|
import retrofit2.Callback
|
||||||
|
import retrofit2.Response
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
object TiebaUtil {
|
object TiebaUtil {
|
||||||
|
|
@ -66,4 +73,22 @@ object TiebaUtil {
|
||||||
putExtra(Intent.EXTRA_TEXT, "${if (title != null) "「$title」\n" else ""}$text\n(分享自贴吧 Lite)")
|
putExtra(Intent.EXTRA_TEXT, "${if (title != null) "「$title」\n" else ""}$text\n(分享自贴吧 Lite)")
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
fun reportPost(context: Context, postId: String) {
|
||||||
|
val dialog = LoadingDialog(context).apply { show() }
|
||||||
|
TiebaApi.getInstance()
|
||||||
|
.checkReportPost(postId)
|
||||||
|
.enqueue(object : Callback<CheckReportBean> {
|
||||||
|
override fun onResponse(call: Call<CheckReportBean>, response: Response<CheckReportBean>) {
|
||||||
|
dialog.dismiss()
|
||||||
|
WebViewActivity.launch(context, response.body()!!.data.url)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onFailure(call: Call<CheckReportBean>, t: Throwable) {
|
||||||
|
dialog.dismiss()
|
||||||
|
context.toastShort(R.string.toast_load_failed)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue