mirror of
https://gitlab.shinice.net/pixeldroid/PixelDroid
synced 2025-01-19 10:20:52 +01:00
Make double tap to like work correctly
This commit is contained in:
parent
68cdb880a4
commit
0f122ce4e2
@ -51,7 +51,7 @@ class PostFragment : Fragment() {
|
||||
current_status?.showComments(holder, api, "Bearer $accessToken")
|
||||
|
||||
//Activate double tap liking
|
||||
current_status?.activateDoubleTapLiker(holder, api, "Bearer $accessToken", current_status.favourited)
|
||||
current_status?.activateDoubleTapLiker(holder, api, "Bearer $accessToken")
|
||||
|
||||
return root
|
||||
}
|
||||
|
@ -121,7 +121,7 @@ open class PostsFeedFragment : FeedFragment<Status, PostViewHolder>() {
|
||||
post.activateLiker(holder, api, credential, post.favourited)
|
||||
|
||||
//Activate double tap liking
|
||||
post.activateDoubleTapLiker(holder, api, credential, post.favourited)
|
||||
post.activateDoubleTapLiker(holder, api, credential)
|
||||
|
||||
//Show comments
|
||||
post.showComments(holder, api, credential)
|
||||
|
@ -5,7 +5,6 @@ import android.content.Context
|
||||
import android.graphics.ColorMatrixColorFilter
|
||||
import android.graphics.Typeface
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.os.Handler
|
||||
import android.text.Spanned
|
||||
import android.text.method.LinkMovementMethod
|
||||
import android.view.View
|
||||
@ -301,8 +300,7 @@ data class Status(
|
||||
fun activateDoubleTapLiker(
|
||||
holder : PostViewHolder,
|
||||
api: PixelfedAPI,
|
||||
credential: String,
|
||||
isLiked: Boolean
|
||||
credential: String
|
||||
) {
|
||||
holder.apply {
|
||||
var clicked = false
|
||||
@ -311,11 +309,14 @@ data class Status(
|
||||
if(sensitiveW.visibility == GONE) {
|
||||
//Check for double click
|
||||
if(clicked) {
|
||||
if (isLiked) {
|
||||
if (holder.liker.isChecked) {
|
||||
// Button is active, unlike
|
||||
holder.liker.isChecked = false
|
||||
unLikePostCall(holder, api, credential, this@Status)
|
||||
} else {
|
||||
// Button is inactive, like
|
||||
holder.liker.playAnimation()
|
||||
holder.liker.isChecked = true
|
||||
likePostCall(holder, api, credential, this@Status)
|
||||
}
|
||||
} else {
|
||||
|
@ -115,9 +115,6 @@ abstract class PostUtils {
|
||||
//Update shown like count and internal like toggle
|
||||
holder.nlikes.text = resp.getNLikes(holder.context)
|
||||
holder.liker.isChecked = resp.favourited
|
||||
|
||||
//Notify the user, that the action was successful
|
||||
Toast.makeText(holder.context, holder.context.getString(R.string.liked_post), Toast.LENGTH_SHORT).show()
|
||||
} else {
|
||||
Log.e("RESPONSE_CODE", response.code().toString())
|
||||
holder.liker.isChecked = false
|
||||
@ -147,9 +144,6 @@ abstract class PostUtils {
|
||||
//Update shown like count and internal like toggle
|
||||
holder.nlikes.text = resp.getNLikes(holder.context)
|
||||
holder.liker.isChecked = resp.favourited
|
||||
|
||||
//Notify the user, that the action was successful
|
||||
Toast.makeText(holder.context, holder.context.getString(R.string.unliked_post), Toast.LENGTH_SHORT).show()
|
||||
} else {
|
||||
Log.e("RESPONSE_CODE", response.code().toString())
|
||||
holder.liker.isChecked = true
|
||||
|
@ -62,9 +62,6 @@
|
||||
<string name="image_download_failed">Download has failed, please try again</string>
|
||||
<string name="image_download_downloading">Downloading…</string>
|
||||
<string name="image_download_success">Image downloaded successfully</string>
|
||||
<!-- Post action feedback -->
|
||||
<string name="liked_post">Post successfully liked!</string>
|
||||
<string name="unliked_post">Post successfully unliked</string>
|
||||
<!-- Post attributes -->
|
||||
<string name="no_description">No description</string>
|
||||
<string name="likes">"%1$s Likes"</string>
|
||||
|
Loading…
Reference in New Issue
Block a user