支持删除动态和评论了。
This commit is contained in:
parent
528efe3f83
commit
01ec14d156
|
@ -6,12 +6,21 @@ import android.view.ViewGroup
|
|||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.bumptech.glide.Glide
|
||||
import com.bumptech.glide.request.RequestOptions
|
||||
import com.coldmint.dialog.CoreDialog
|
||||
import com.coldmint.rust.core.dataBean.ApiResponse
|
||||
import com.coldmint.rust.core.dataBean.mod.WebModCommentData
|
||||
import com.coldmint.rust.core.interfaces.ApiCallBack
|
||||
import com.coldmint.rust.core.tool.AppOperator
|
||||
import com.coldmint.rust.core.web.Dynamic
|
||||
import com.coldmint.rust.core.web.ServerConfiguration
|
||||
import com.coldmint.rust.core.web.WebMod
|
||||
import com.coldmint.rust.pro.R
|
||||
import com.coldmint.rust.pro.base.BaseAdapter
|
||||
import com.coldmint.rust.pro.databinding.ItemCommentBinding
|
||||
import com.coldmint.rust.pro.tool.AppSettings
|
||||
import com.coldmint.rust.pro.tool.GlobalMethod
|
||||
import com.coldmint.rust.pro.tool.TextStyleMaker
|
||||
import com.google.android.material.snackbar.Snackbar
|
||||
|
||||
/**
|
||||
* 评论
|
||||
|
@ -47,6 +56,73 @@ class CommentAdapter(context: Context, dataList: MutableList<WebModCommentData.D
|
|||
} else {
|
||||
data.time + " " + data.location
|
||||
}
|
||||
viewBinding.shareImageView.setOnClickListener {
|
||||
AppOperator.shareText(context, context.getString(R.string.share_message), data.content);
|
||||
}
|
||||
viewBinding.moreImageView.setOnClickListener { view ->
|
||||
val menu = GlobalMethod.createPopMenu(view)
|
||||
menu.menu.add(R.string.copy)
|
||||
menu.menu.add(R.string.delete_title)
|
||||
menu.setOnMenuItemClickListener {
|
||||
val title = it.title
|
||||
when (title) {
|
||||
context.getString(R.string.copy) -> {
|
||||
GlobalMethod.copyText(context, data.content, view)
|
||||
}
|
||||
context.getString(R.string.delete_title) -> {
|
||||
CoreDialog(context).setTitle(R.string.delete_comment).setMessage(
|
||||
String.format(
|
||||
context.getString(R.string.delete_comment_tip),
|
||||
data.userName
|
||||
)
|
||||
).setPositiveButton(R.string.dialog_ok){
|
||||
val token = AppSettings.getValue(AppSettings.Setting.Token, "")
|
||||
if (token.isNullOrBlank()) {
|
||||
Snackbar.make(
|
||||
view,
|
||||
context.getString(R.string.please_login_first),
|
||||
Snackbar.LENGTH_SHORT
|
||||
).show()
|
||||
} else {
|
||||
WebMod.instance.modifyCommentVisibility(
|
||||
token,
|
||||
data.id,
|
||||
object : ApiCallBack<ApiResponse> {
|
||||
override fun onResponse(t: ApiResponse) {
|
||||
if (t.code == ServerConfiguration.Success_Code) {
|
||||
removeItem(viewHolder.adapterPosition)
|
||||
Snackbar.make(
|
||||
view,
|
||||
t.message,
|
||||
Snackbar.LENGTH_SHORT
|
||||
).show()
|
||||
} else {
|
||||
Snackbar.make(
|
||||
viewBinding.root,
|
||||
t.message,
|
||||
Snackbar.LENGTH_SHORT
|
||||
).show()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onFailure(e: Exception) {
|
||||
Snackbar.make(
|
||||
viewBinding.root,
|
||||
R.string.network_error,
|
||||
Snackbar.LENGTH_SHORT
|
||||
).show()
|
||||
}
|
||||
})
|
||||
}
|
||||
}.setNegativeButton(R.string.dialog_cancel){
|
||||
|
||||
}.show()
|
||||
}
|
||||
}
|
||||
true
|
||||
}
|
||||
menu.show()
|
||||
}
|
||||
TextStyleMaker.instance.load(viewBinding.contentView, data.content) { type, data ->
|
||||
TextStyleMaker.instance.clickEvent(context, type, data)
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ import android.widget.PopupWindow
|
|||
import android.widget.Toast
|
||||
import com.bumptech.glide.Glide
|
||||
import com.bumptech.glide.request.RequestOptions
|
||||
import com.coldmint.dialog.CoreDialog
|
||||
import com.coldmint.rust.core.dataBean.ApiResponse
|
||||
import com.coldmint.rust.core.dataBean.DynamicItemDataBean
|
||||
import com.coldmint.rust.core.interfaces.ApiCallBack
|
||||
|
@ -62,7 +63,10 @@ class DynamicAdapter(context: Context, dataList: MutableList<DynamicItemDataBean
|
|||
TextStyleMaker.instance.load(viewBinding.contentView, data.content) { type, data ->
|
||||
TextStyleMaker.instance.clickEvent(context, type, data)
|
||||
}
|
||||
viewBinding.contentView.setOnLongClickListener { view ->
|
||||
viewBinding.shareImageView.setOnClickListener {
|
||||
AppOperator.shareText(context, context.getString(R.string.share_message), data.content);
|
||||
}
|
||||
viewBinding.moreImageView.setOnClickListener { view ->
|
||||
val menu = GlobalMethod.createPopMenu(view)
|
||||
menu.menu.add(R.string.copy)
|
||||
menu.menu.add(R.string.delete_title)
|
||||
|
@ -73,42 +77,47 @@ class DynamicAdapter(context: Context, dataList: MutableList<DynamicItemDataBean
|
|||
GlobalMethod.copyText(context, data.content, view)
|
||||
}
|
||||
context.getString(R.string.delete_title) -> {
|
||||
val account = AppSettings.getValue(AppSettings.Setting.Account, "")
|
||||
val appId =
|
||||
AppSettings
|
||||
.getValue(AppSettings.Setting.AppID, "")
|
||||
Dynamic.instance.deleteDynamic(
|
||||
account,
|
||||
appId,
|
||||
data.id,
|
||||
object : ApiCallBack<ApiResponse> {
|
||||
override fun onResponse(t: ApiResponse) {
|
||||
//成功与否执行都一样
|
||||
if (t.code == ServerConfiguration.Success_Code) {
|
||||
removeItem(viewHolder.adapterPosition)
|
||||
}
|
||||
Snackbar.make(
|
||||
viewBinding.root,
|
||||
t.message,
|
||||
Snackbar.LENGTH_SHORT
|
||||
).show()
|
||||
}
|
||||
CoreDialog(context).setTitle(R.string.delete_dynamic)
|
||||
.setMessage(R.string.delete_dynamic_tip)
|
||||
.setPositiveButton(R.string.dialog_ok) {
|
||||
val account = AppSettings.getValue(AppSettings.Setting.Account, "")
|
||||
val appId =
|
||||
AppSettings
|
||||
.getValue(AppSettings.Setting.AppID, "")
|
||||
Dynamic.instance.deleteDynamic(
|
||||
account,
|
||||
appId,
|
||||
data.id,
|
||||
object : ApiCallBack<ApiResponse> {
|
||||
override fun onResponse(t: ApiResponse) {
|
||||
//成功与否执行都一样
|
||||
if (t.code == ServerConfiguration.Success_Code) {
|
||||
removeItem(viewHolder.adapterPosition)
|
||||
}
|
||||
Snackbar.make(
|
||||
viewBinding.root,
|
||||
t.message,
|
||||
Snackbar.LENGTH_SHORT
|
||||
).show()
|
||||
}
|
||||
|
||||
override fun onFailure(e: Exception) {
|
||||
Snackbar.make(
|
||||
viewBinding.root,
|
||||
R.string.network_error,
|
||||
Snackbar.LENGTH_SHORT
|
||||
).show()
|
||||
}
|
||||
override fun onFailure(e: Exception) {
|
||||
Snackbar.make(
|
||||
viewBinding.root,
|
||||
R.string.network_error,
|
||||
Snackbar.LENGTH_SHORT
|
||||
).show()
|
||||
}
|
||||
|
||||
})
|
||||
})
|
||||
}.setNegativeButton(R.string.dialog_cancel) {
|
||||
|
||||
}.show()
|
||||
}
|
||||
}
|
||||
true
|
||||
}
|
||||
menu.show()
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
|
|
10
app/src/main/res/drawable/github.xml
Normal file
10
app/src/main/res/drawable/github.xml
Normal file
|
@ -0,0 +1,10 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="200dp"
|
||||
android:height="200dp"
|
||||
android:viewportWidth="1024"
|
||||
android:viewportHeight="1024"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M512,21.3C241,21.3 21.3,241 21.3,512c0,216.8 140.5,400.7 335.6,465.7 24.5,4.4 32.3,-10.1 32.3,-23.1 0,-11.7 0.3,-44.2 0,-85.2 -136.4,29.6 -164.7,-64.6 -164.7,-64.6 -22.3,-56.7 -54.4,-71.8 -54.4,-71.8 -44.6,-30.5 3.3,-29.8 3.3,-29.8 49.2,3.4 75.2,50.5 75.2,50.5 43.8,75 114.8,53.3 142.8,40.8 4.5,-31.7 17.2,-53.4 31.2,-65.5 -109,-12.5 -223.5,-54.5 -223.5,-242.6 0,-53.5 19.1,-97.3 50.5,-131.7 -5,-12.3 -21.9,-62.3 4.8,-129.8 0,0 41.3,-13.2 134.9,50.3a469.8,469.8 0,0 1,122.9 -16.6c41.6,0.2 83.6,5.6 122.9,16.6 93.7,-63.5 134.8,-50.3 134.8,-50.3 26.8,67.5 9.9,117.5 4.9,129.8 31.4,34.3 50.5,78.1 50.5,131.7 0,188.6 -114.7,230 -224,242.1 17.6,15.2 33.6,44.7 33.6,90.5v135.9c0,13.1 7.9,27.6 32.9,22.9C862.3,912.6 1002.7,728.7 1002.7,512 1002.7,241 783,21.3 512,21.3z" />
|
||||
</vector>
|
|
@ -50,8 +50,8 @@
|
|||
<string name="dialog_search">正在扫描%1$s...</string>
|
||||
<string name="dialog_remove">正在移动%1$s...</string>
|
||||
<string name="dialog_packing">正在添加%1$s...</string>
|
||||
<string name="pack_success">已成功打包%1$s,要分享给朋友嘛?</string>
|
||||
<string name="pack_success2">已成功打包%1$s,要开始导出嘛?</string>
|
||||
<string name="pack_success">已成功打包%1$s,确认分享给朋友吗?</string>
|
||||
<string name="pack_success2">已成功打包%1$s,确认开始导出吗?</string>
|
||||
<string name="pack_file_success">打包完成。</string>
|
||||
<string name="pack_failed">打包失败</string>
|
||||
<string name="repair_complete">修复完成</string>
|
||||
|
@ -63,6 +63,10 @@
|
|||
<string name="menu_title3">数据集</string>
|
||||
<string name="data_array">数据数组(以\"|\"分割):</string>
|
||||
<string name="delete_title">删除</string>
|
||||
<string name="delete_comment">删除评论</string>
|
||||
<string name="delete_dynamic">删除动态</string>
|
||||
<string name="delete_dynamic_tip">确认删除此条动态吗?</string>
|
||||
<string name="delete_comment_tip">确认删除\"%1$s\"的评论吗?</string>
|
||||
<string name="del_moding">正在删除...</string>
|
||||
<string name="del_moding_tip">正在删除\"%1$s\"...</string>
|
||||
<string name="restoreing">正在还原...</string>
|
||||
|
@ -236,7 +240,7 @@
|
|||
<!--编译错误-->
|
||||
|
||||
<string name="not_save_exit">不保存退出</string>
|
||||
<string name="save_settings">检查到配置信息更新,要保存更改嘛?</string>
|
||||
<string name="save_settings">检查到配置信息更新,确认保存更改吗?</string>
|
||||
<string name="saveing">正在保存%1$s...</string>
|
||||
<string name="save_complete">%1$s保存完成。</string>
|
||||
<string name="save_complete2">保存完成。</string>
|
||||
|
@ -252,7 +256,7 @@
|
|||
<string name="import_error1">解压文件时出错。</string>
|
||||
<string name="import_effor7">不可识别的路径。</string>
|
||||
<string name="delete_unit">删除单位</string>
|
||||
<string name="delete_prompt">要删除 %1$s 嘛? </string>
|
||||
<string name="delete_prompt">确认删除 %1$s 吗? </string>
|
||||
<!--导入-->
|
||||
<string name="importing">导入中...</string>
|
||||
<string name="import_name">导入</string>
|
||||
|
@ -374,7 +378,7 @@
|
|||
<string name="not_find_template">没有找到模板</string>
|
||||
<string name="night_mode">深色主题</string>
|
||||
<string name="copy_complete">已复制%1$s。</string>e
|
||||
<string name="text_changed">您有文件尚未保存,要保存更改嘛?</string>
|
||||
<string name="text_changed">您有文件尚未保存,确认保存更改吗?</string>
|
||||
<string name="collapse_info">崩溃信息</string>
|
||||
<string name="load_system_application">显示系统应用</string>
|
||||
<string name="choose_color">选择颜色</string>
|
||||
|
@ -437,6 +441,7 @@
|
|||
<string name="open_tip">立即以%1$.2f元开通</string>
|
||||
<string name="packing">打包中...</string>
|
||||
<string name="share_mod">分享</string>
|
||||
<string name="share_message">分享</string>
|
||||
<string name="setting_pack_directory" translatable="false">PackDirectory</string>
|
||||
<string name="clear_code_cache">清理代码缓存</string>
|
||||
<string name="custom_symbol">自定义符号栏</string>
|
||||
|
@ -542,17 +547,17 @@
|
|||
<string name="build_database">构建项目...</string>
|
||||
<string name="build_database_complete">构建项目完成。</string>
|
||||
<string name="rebuild_project">重构项目</string>
|
||||
<string name="rebuild_project_tip">要清理缓存数据并重新构建索引嘛?</string>
|
||||
<string name="rebuild_project_tip">确认清理缓存数据并重新构建索引吗?</string>
|
||||
<string name="clean_up_cache_and_rebuild">立即重构项目</string>
|
||||
<string name="import_type_could_not_be_resolved">无法解析导入类型\"%1$s\"。</string>
|
||||
<string name="import_path_could_not_be_resolved">无法识别路径\"%1$s\"。</string>
|
||||
<string name="uri_null">uri错误。</string>
|
||||
<string name="location_info">位于%1$s第%2$d行:</string>
|
||||
<string name="covers_the_import">您正在尝试导入低版本的模板包(%1$s),当前版本(%2$s),这将覆盖更新的内容。要继续嘛?</string>
|
||||
<string name="covers_the_import_mod">%1$s已存在,这将覆盖旧的内容。要继续嘛?</string>
|
||||
<string name="covers_the_import">您正在尝试导入低版本的模板包(%1$s),当前版本(%2$s),这将覆盖更新的内容。确认继续吗?</string>
|
||||
<string name="covers_the_import_mod">%1$s已存在,这将覆盖旧的内容。确认继续吗?</string>
|
||||
<string name="empty_text">无法为空文件制作模板。</string>
|
||||
<string name="value_selector_array_describe">使用\",\"分割参数,也可以使用\"[\"和\"]\"注解参数。例如:[喜欢:like],喜欢将被显示给用户,选中后,写入like。</string>
|
||||
<string name="template_save_complete">模板添加完成,请现在退出模板制作器嘛?</string>
|
||||
<string name="template_save_complete">模板添加完成,现在退出模板制作器吗?</string>
|
||||
<string name="edit_template">编辑模板</string>
|
||||
<string name="file_type_tip">已智能推断文件类型为\"%1$s\"。</string>
|
||||
<string name="file_type_define">默认创建ini文件。</string>
|
||||
|
@ -578,7 +583,7 @@
|
|||
<string name="screenshot">截图:</string>
|
||||
<string name="required">必填</string>
|
||||
<string name="selectable">可选</string>
|
||||
<string name="exit_tip">要退出\"%1$s\"嘛?</string>
|
||||
<string name="exit_tip">退出\"%1$s\"吗?</string>
|
||||
<string name="path">路径</string>
|
||||
<string name="from_url">从url添加</string>
|
||||
<string name="sign_error">安全验证</string>
|
||||
|
@ -617,7 +622,7 @@
|
|||
<string name="each_other_follow">已互粉</string>
|
||||
<string name="followed">已关注</string>
|
||||
<string name="defollow">取消关注</string>
|
||||
<string name="defollow_tip">要取消关注\"%1$s\"嘛?</string>
|
||||
<string name="defollow_tip">取消关注\"%1$s\"吗?</string>
|
||||
<string name="head_icon">头像:</string>
|
||||
<string name="signature">个性签名</string>
|
||||
<string name="gender">性别</string>
|
||||
|
@ -670,7 +675,7 @@
|
|||
<string name="data_transfer">数据传输</string>
|
||||
<string name="using_mobile_networks">允许使用数据网络</string>
|
||||
<string name="using_mobile_networks_tip">使用移动网络上传下载模组,可能会产生额外的流量费用。</string>
|
||||
<string name="using_mobile_networks_msg">使用移动网络上传下载模组,可能会产生额外的流量费用。仍然继续嘛?</string>
|
||||
<string name="using_mobile_networks_msg">使用移动网络上传下载模组,可能会产生额外的流量费用。仍然继续吗?</string>
|
||||
<string name="setting_use_mobile_network" translatable="false">usingMobileNetwork</string>
|
||||
<string name="no_followers">请先关注你喜欢的作者</string>
|
||||
<string name="my_follow">我的关注</string>
|
||||
|
@ -684,7 +689,7 @@
|
|||
<string name="pay_attention_new">关注新作</string>
|
||||
<string name="version_name_tip">版本名显示在更新记录内。</string>
|
||||
<string name="sold_out_mod_tip">上架重新需要审核,要下架嘛?</string>
|
||||
<string name="review_audit_mod_tip">要重新审核%1$s嘛?</string>
|
||||
<string name="review_audit_mod_tip">确认重新审核%1$s吗?</string>
|
||||
<string name="review_audit">重新审核</string>
|
||||
<string name="warehouse">仓库</string>
|
||||
<string name="not_find_map">没有地图</string>
|
||||
|
@ -742,7 +747,7 @@
|
|||
<string name="wechat">微信</string>
|
||||
<string name="setting">设置</string>
|
||||
<string name="order_list">订单列表</string>
|
||||
<string name="copy_orderid">要复制订单编号(%1$s)嘛?</string>
|
||||
<string name="copy_orderid">确认复制订单编号(%1$s)吗?</string>
|
||||
<string name="remove_fans_tip">确认要移除粉丝 %1$s 嘛?</string>
|
||||
<string name="ban_fans">同时将此用户加入黑名单</string>
|
||||
<string name="reject_follow">拒绝关注</string>
|
||||
|
@ -827,7 +832,7 @@
|
|||
<string name="order_manager">订单管理</string>
|
||||
<string name="log_out">登出</string>
|
||||
<string name="user_info">最近登录:%1$s ip归属地:%2$s</string>
|
||||
<string name="use_coupon">将使用优惠券创建订单,仍继续嘛?(创建订单完成后,将优惠券消耗)</string>
|
||||
<string name="use_coupon">将使用优惠券创建订单,仍继续吗?(创建订单完成后,将优惠券消耗)</string>
|
||||
<string name="use">使用</string>
|
||||
<string name="account_or_email">账号/电子邮件</string>
|
||||
<string name="account_error4">找不到用户,请检查电子邮件地址是否正确。</string>
|
||||
|
@ -860,10 +865,10 @@
|
|||
<string name="update_and_iteration">版本更新与用户体验计划</string>
|
||||
<string name="setting_experience_the_plan" translatable="false">experiencePlan</string>
|
||||
<string name="order_timeout" translatable="false">订单超时,无法支付。</string>
|
||||
<string name="is_paid">请问您付款了嘛?(未支付的订单将过期,无法再为其付款)。</string>
|
||||
<string name="is_paid">请问您付款了吗?(未支付的订单将过期,无法再为其付款)。</string>
|
||||
<string name="paid_yes">是的,我付款了</string>
|
||||
<string name="paid_no">放弃订单</string>
|
||||
<string name="preferential_price">已为您优惠%1$.2f元,仍然放弃订单嘛,放弃订单后不返还优惠券。</string>
|
||||
<string name="preferential_price">已为您优惠%1$.2f元,仍然放弃订单吗,放弃订单后不返还优惠券。</string>
|
||||
<string name="paid_continue">继续支付</string>
|
||||
<string name="mail_helper">不知道自己的邮箱地址?点击这里查看帮助</string>
|
||||
<string name="qq_number">QQ号</string>
|
||||
|
@ -902,7 +907,7 @@
|
|||
<string name="customize_edit_text">定制编辑框</string>
|
||||
<string name="subscription">订阅</string>
|
||||
<string name="de_subscription">退订</string>
|
||||
<string name="de_subscription_msg">要退订%1$s嘛?</string>
|
||||
<string name="de_subscription_msg">确认退订%1$s吗?</string>
|
||||
<string name="keyword_color">关键字颜色</string>
|
||||
<string name="text_color">普通文本颜色</string>
|
||||
<string name="edit_text_color">字体颜色</string>
|
||||
|
|
|
@ -21,7 +21,8 @@ class WebMod private constructor() {
|
|||
|
||||
Latest_Time("latestTime"), Download_Number("downloadNumber"), Coin_Number("coinNumber"), Unit_Number(
|
||||
"unitNumber"
|
||||
),Update_Number("updateNumber");
|
||||
),
|
||||
Update_Number("updateNumber");
|
||||
|
||||
/**
|
||||
* 获取枚举代表的值
|
||||
|
@ -200,6 +201,61 @@ class WebMod private constructor() {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* 修改评论可见状态(默认隐藏评论)
|
||||
*/
|
||||
fun modifyCommentVisibility(
|
||||
adminToken: String,
|
||||
commentId: Int,
|
||||
apiCallBack: ApiCallBack<ApiResponse>,
|
||||
hide: Boolean = true
|
||||
) {
|
||||
val hideCode = if (hide) 1 else 0
|
||||
val okHttpClient = ServerConfiguration.initOkHttpClient()
|
||||
val requestBodyBuilder: FormBody.Builder =
|
||||
FormBody.Builder().add("adminToken", adminToken).add("commentId", commentId.toString())
|
||||
.add("hide", hideCode.toString())
|
||||
val requestBody = requestBodyBuilder.build()
|
||||
val request =
|
||||
Request.Builder()
|
||||
.url(ServerConfiguration.website + "php/mod.php?action=modifyCommentVisibility")
|
||||
.post(requestBody).build()
|
||||
val call = okHttpClient.newCall(request)
|
||||
val handler = Handler(Looper.getMainLooper())
|
||||
val gson = Gson()
|
||||
call.enqueue(object : Callback {
|
||||
override fun onFailure(call: Call, e: IOException) {
|
||||
e.printStackTrace()
|
||||
handler.post { apiCallBack.onFailure(e) }
|
||||
}
|
||||
|
||||
override fun onResponse(call: Call, response: Response) {
|
||||
try {
|
||||
val body = response.body
|
||||
if (body == null) {
|
||||
handler.post {
|
||||
apiCallBack.onFailure(NullPointerException())
|
||||
}
|
||||
} else {
|
||||
val data = body.string()
|
||||
val finalApiResponse =
|
||||
gson.fromJson(data, ApiResponse::class.java)
|
||||
handler.post {
|
||||
apiCallBack.onResponse(finalApiResponse)
|
||||
}
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
handler.post {
|
||||
apiCallBack.onFailure(e)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 加载随机推荐
|
||||
* @param number Int 推荐数量
|
||||
|
|
Loading…
Reference in New Issue
Block a user