我有一個Android應用程序發送喜歡到服務器。2秒後如何檢查按鈕是否被點擊?
我想要做的不是立即向服務器發送消息,而是在2秒後發送,如果用戶仍喜歡該消息。
我喜歡空白;
public void rotationAnimation(ImageView button, int source1, int source2){
if(isLikeClicked){
button.setImageResource(source1);
button.startAnimation(rotate_backward);
isLikeClicked = false;
}else{
button.setImageResource(source2);
button.startAnimation(rotate_forward);
isLikeClicked = true;
}
ChangeLikeCount();
if(isReadyToPost)
if(!isLikeClicked){
Like like = new Like();
like.execute(ServerCons.HOST + "unlike");
}else{
Like like = new Like();
like.execute(ServerCons.HOST + "like");
}
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
// I thought the solution could be there
}
}, 2000);
}