mirror of
https://github.com/rebelonion/Dantotsu.git
synced 2026-01-21 19:43:56 +00:00
chore: implement an app getString
This commit is contained in:
@@ -151,7 +151,7 @@ class App : MultiDexApplication() {
|
||||
}
|
||||
|
||||
companion object {
|
||||
private var instance: App? = null
|
||||
var instance: App? = null
|
||||
var context: Context? = null
|
||||
fun currentContext(): Context? {
|
||||
return instance?.mFTActivityLifecycleCallbacks?.currentActivity ?: context
|
||||
|
||||
@@ -999,6 +999,10 @@ class EmptyAdapter(private val count: Int) : RecyclerView.Adapter<RecyclerView.V
|
||||
inner class EmptyViewHolder(view: View) : RecyclerView.ViewHolder(view)
|
||||
}
|
||||
|
||||
fun getAppString(res: Int?): String? {
|
||||
return res?.let { App.instance?.getString(it) }
|
||||
}
|
||||
|
||||
fun toast(string: String?) {
|
||||
if (string != null) {
|
||||
Logger.log(string)
|
||||
@@ -1049,6 +1053,10 @@ fun snackString(s: String?, activity: Activity? = null, clipboard: String? = nul
|
||||
return null
|
||||
}
|
||||
|
||||
fun snackString(r: Int?, activity: Activity? = null, clipboard: String? = null): Snackbar? {
|
||||
snackString(getAppString(r), activity, clipboard)
|
||||
}
|
||||
|
||||
open class NoPaddingArrayAdapter<T>(context: Context, layoutId: Int, items: List<T>) :
|
||||
ArrayAdapter<T>(context, layoutId, items) {
|
||||
override fun getView(position: Int, convertView: View?, parent: ViewGroup): View {
|
||||
|
||||
@@ -85,7 +85,7 @@ class MediaAdaptor(
|
||||
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n", "ClickableViewAccessibility")
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
|
||||
when (type) {
|
||||
0 -> {
|
||||
|
||||
@@ -11,6 +11,7 @@ import ani.dantotsu.connections.comments.Comment
|
||||
import ani.dantotsu.connections.comments.CommentsAPI
|
||||
import ani.dantotsu.copyToClipboard
|
||||
import ani.dantotsu.databinding.ItemCommentsBinding
|
||||
import ani.dantotsu.getAppString
|
||||
import ani.dantotsu.loadImage
|
||||
import ani.dantotsu.others.ImageViewDialog
|
||||
import ani.dantotsu.profile.ProfileActivity
|
||||
@@ -76,8 +77,15 @@ class CommentItem(val comment: Comment,
|
||||
if ((comment.replyCount ?: 0) > 0) {
|
||||
viewBinding.commentTotalReplies.visibility = View.VISIBLE
|
||||
viewBinding.commentRepliesDivider.visibility = View.VISIBLE
|
||||
viewBinding.commentTotalReplies.text = if(repliesVisible) "Hide Replies" else
|
||||
"View ${comment.replyCount} repl${if (comment.replyCount == 1) "y" else "ies"}"
|
||||
viewBinding.commentTotalReplies.context.run {
|
||||
viewBinding.commentTotalReplies.text = if (repliesVisible)
|
||||
getString(R.string.hide_replies)
|
||||
else
|
||||
if (comment.replyCount == 1)
|
||||
getString(R.string.view_reply)
|
||||
else
|
||||
getString(R.string.view_replies, comment.replyCount)
|
||||
}
|
||||
} else {
|
||||
viewBinding.commentTotalReplies.visibility = View.GONE
|
||||
viewBinding.commentRepliesDivider.visibility = View.GONE
|
||||
@@ -128,12 +136,12 @@ class CommentItem(val comment: Comment,
|
||||
viewBinding.modBadge.visibility = if (comment.isMod == true) View.VISIBLE else View.GONE
|
||||
viewBinding.adminBadge.visibility = if (comment.isAdmin == true) View.VISIBLE else View.GONE
|
||||
viewBinding.commentDelete.setOnClickListener {
|
||||
dialogBuilder("Delete Comment", "Are you sure you want to delete this comment?") {
|
||||
dialogBuilder(getAppString(R.string.delete_comment), getAppString(R.string.delete_comment_confirm)) {
|
||||
val scope = CoroutineScope(Dispatchers.Main + SupervisorJob())
|
||||
scope.launch {
|
||||
val success = CommentsAPI.deleteComment(comment.commentId)
|
||||
if (success) {
|
||||
snackString("Comment Deleted")
|
||||
snackString(R.string.comment_deleted)
|
||||
parentSection.remove(this@CommentItem)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -713,4 +713,12 @@ Non quae tempore quo provident laudantium qui illo dolor vel quia dolor et exerc
|
||||
<string name="activities">Activities</string>
|
||||
|
||||
<string name="delete_fail_reason">Failed to delete because of… %1$s</string>
|
||||
|
||||
<string name="hide_replies">Hide Replies</string>
|
||||
<string name="view_reply">View reply</string>
|
||||
<string name="view_replies">View %1$d replies</string>
|
||||
|
||||
<string name="delete_comment">Delete Comment</string>
|
||||
<string name="delete_comment_confirm">Are you sure you want to delete this comment?</string>
|
||||
<string name="comment_deleted">Comment Deleted</string>
|
||||
</resources>
|
||||
|
||||
Reference in New Issue
Block a user