Пример #1
0
 private void toggleLike(Button button) {
   if (post.isLiked()) {
     post.setLiked(false);
     button.setText("Like");
     button.setTextColor(getResources().getColor(R.color.normalColor));
   } else {
     post.setLiked(true);
     button.setText("Liked!");
     button.setTextColor(getResources().getColor(R.color.toogleColor));
   }
 }
Пример #2
0
 private void initLikeButton(Button button) {
   if (LoginInfo.hasLoggedIn()) {
     if (post.isLiked()) {
       button.setText("Liked!");
       button.setTextColor(getResources().getColor(R.color.toogleColor));
     } else {
       button.setText("Like");
       button.setTextColor(getResources().getColor(R.color.normalColor));
     }
   } else {
     button.setVisibility(View.INVISIBLE);
     button.setEnabled(false);
   }
 }
Пример #3
0
 private void changeLike(final Button button, final TextView textView) {
   String routing = "";
   if (post.isLiked()) {
     routing = "delete";
   } else {
     routing = "new";
   }
   new HttpRequestTask(routing) {
     @Override
     protected void atPostExecute(JSONObject jsonObject) {
       toggleLike(button);
       fetchLikeCount(textView);
     }
   }.execute(JSONFactory.createLike(post.getId()));
 }