Kate Mobile v109.1版本的 MD5 值为:fcd76ded5f363ecbfac46035a4ed2a23

以下内容为反编译后的 CommentsSearchActivity.java 源代码,内容仅作参考


package com.perm.kate;

import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.widget.AbsListView;
import android.widget.AdapterView;
import android.widget.EditText;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.TextView;
import androidx.appcompat.app.AlertDialog;
import com.perm.kate.api.Comment;
import com.perm.kate.api.CommentList;
import com.perm.kate.api.Group;
import com.perm.kate.api.KException;
import com.perm.kate.api.User;
import com.perm.kate.data.PageCommentList;
import com.perm.kate.session.Callback;
import java.util.ArrayList;
import java.util.Iterator;
public class CommentsSearchActivity extends BaseActivity {
    private CommentListAdapter comment_list_adapter;
    private int comment_type;
    private long content_id;
    private long content_owner_id;
    private ListView lv_comment_list;
    String query;
    String reply_to_cid;
    String reply_to_user_name;
    EditText tb_search;
    private final long account_id = Long.parseLong(KApplication.session.getMid());
    private int state = -1;
    private final Callback callback_reload = new Callback(this) {
        @Override
        public void error(Throwable th) {
            super.error(th);
            CommentsSearchActivity.this.showProgressBar(false);
            CommentsSearchActivity.this.state = 2;
        }

        @Override
        public void ready(Object obj) {
            CommentList commentList = (CommentList) obj;
            CommentsSearchActivity.this.state = commentList.comments.size() < 100 ? 3 : 0;
            CommentsSearchActivity.this.comments.clear();
            CommentsSearchActivity.this.comments.addAll(commentList.comments);
            CommentsSearchActivity.this.requeryOnUiThread();
            CommentsSearchActivity.this.showProgressBar(false);
        }
    };
    ArrayList comments = new ArrayList();
    private final AdapterView.OnItemClickListener onItemClickListener = new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView adapterView, View view, int i, long j) {
            CommentsSearchActivity.this.displayContextMenu((CommentTag) view.getTag());
        }
    };
    final int page_size = 100;
    private final AbsListView.OnScrollListener scrollListener = new AbsListView.OnScrollListener() {
        @Override
        public void onScroll(AbsListView absListView, int i, int i2, int i3) {
            if ((i + i2 >= i3 - 1) && CommentsSearchActivity.this.state == 0) {
                Log.i("CommentsSearchActivity", "Loading more");
                CommentsSearchActivity.this.state = 1;
                CommentsSearchActivity.this.loadMore();
                CommentsSearchActivity.this.showProgressBar(true);
            }
        }

        @Override
        public void onScrollStateChanged(AbsListView absListView, int i) {
        }
    };
    private final Callback load_more_callback = new Callback(this) {
        @Override
        public void error(Throwable th) {
            super.error(th);
            CommentsSearchActivity.this.state = 2;
            CommentsSearchActivity.this.showProgressBar(false);
        }

        @Override
        public void ready(Object obj) {
            if (CommentsSearchActivity.this.isFinishing()) {
                return;
            }
            CommentList commentList = (CommentList) obj;
            CommentsSearchActivity.this.state = commentList.comments.size() < 100 ? 3 : 0;
            CommentsSearchActivity.this.comments.addAll(commentList.comments);
            CommentsSearchActivity.this.requeryOnUiThread();
            CommentsSearchActivity.this.showProgressBar(false);
        }
    };
    private final View.OnClickListener search_OnClickListener = new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            CommentsSearchActivity.this.searchClick();
        }
    };

    public void copyLink(long j) {
        Helper.copyText(getLink(j), this);
    }

    public void displayContextMenu(final CommentTag commentTag) {
        boolean z;
        final ArrayList extractUrl;
        final ArrayList arrayList;
        int i;
        int i2;
        long j;
        long j2;
        int i3;
        if (commentTag == null) {
            return;
        }
        try {
            Long valueOf = Long.valueOf(Long.parseLong(KApplication.session.getMid()));
            if (!valueOf.equals(Long.valueOf(commentTag.user_id))) {
                long longValue = valueOf.longValue();
                long j3 = this.content_owner_id;
                if (longValue != j3 && j3 >= 0 && this.comment_type != 4) {
                    long j4 = commentTag.user_id;
                    if (j4 >= 0 || !KApplication.db.isAdminOrEditorInGroup(valueOf, -j4)) {
                        z = false;
                        extractUrl = Helper.extractUrl(commentTag.message, true);
                        arrayList = new ArrayList();
                        if (!valueOf.equals(Long.valueOf(commentTag.user_id)) && ((i3 = this.comment_type) == 1 || i3 == 4 || i3 == 0 || i3 == 2 || i3 == 5)) {
                            arrayList.add(new MenuItemDetails((int) R.string.label_replay, 4));
                        }
                        i = this.comment_type;
                        if (i != 1 || i == 4 || i == 0 || i == 2 || i == 5) {
                            if (commentTag.like) {
                                arrayList.add(new MenuItemDetails((int) R.string.i_like, 5));
                            } else {
                                arrayList.add(new MenuItemDetails((int) R.string.i_dont_like, 6));
                            }
                        }
                        arrayList.add(new MenuItemDetails((int) R.string.who_likes, 7));
                        arrayList.add(new MenuItemDetails((int) R.string.label_menu_send_to_friend, 17));
                        if (commentTag.comment.reply_to_cid > 0) {
                            arrayList.add(new MenuItemDetails((int) R.string.reply_to_who, 15));
                        }
                        if (extractUrl.size() > 0) {
                            arrayList.add(new MenuItemDetails((int) R.string.links, 2));
                        }
                        arrayList.add(new MenuItemDetails((int) R.string.copy_text, 3));
                        arrayList.add(new MenuItemDetails((int) R.string.label_copy_video_link, 16));
                        if (!valueOf.equals(Long.valueOf(commentTag.user_id)) && (this.comment_type != 4 || !KApplication.db.isAdminOrEditorInGroup(valueOf, -getCorrectOwnerId()))) {
                            j = this.content_owner_id;
                            if (j < 0 || j != commentTag.user_id || !KApplication.db.isAdminOrEditorInGroup(valueOf, -getCorrectOwnerId())) {
                                j2 = commentTag.user_id;
                                if (j2 < 0) {
                                }
                                if ((this.comment_type != 4 || this.content_owner_id < 0) && !valueOf.equals(Long.valueOf(commentTag.user_id)) && KApplication.db.isModerInGroup(valueOf, -getCorrectOwnerId())) {
                                    arrayList.add(new MenuItemDetails((int) R.string.label_user_to_ban, 9));
                                }
                                if (z) {
                                    arrayList.add(new MenuItemDetails((int) R.string.delete, 1));
                                }
                                i2 = this.comment_type;
                                if ((i2 != 1 || i2 == 0 || i2 == 2 || i2 == 5) && this.account_id != commentTag.user_id) {
                                    arrayList.add(new MenuItemDetails((int) R.string.label_complain_report, 13));
                                }
                                if (arrayList.size() != 0) {
                                    return;
                                }
                                AlertDialog create = new AlertDialog.Builder(this).setItems(MenuItemDetails.toArray(arrayList), new DialogInterface.OnClickListener() {
                                    @Override
                                    public void onClick(DialogInterface dialogInterface, int i4) {
                                        switch (((MenuItemDetails) arrayList.get(i4)).code) {
                                            case 1:
                                                CommentsSearchActivity.this.confirmRemoveComment(Long.valueOf(commentTag.comment_id), commentTag.user_id);
                                                return;
                                            case 2:
                                                Helper.displayLinksMenu(extractUrl, CommentsSearchActivity.this);
                                                return;
                                            case 3:
                                                Helper.copyText(commentTag.message, CommentsSearchActivity.this);
                                                return;
                                            case 4:
                                                CommentsSearchActivity.this.reply(commentTag);
                                                return;
                                            case 5:
                                                CommentsSearchActivity.this.setLike(Long.valueOf(commentTag.comment_id), commentTag.comment, true);
                                                return;
                                            case 6:
                                                CommentsSearchActivity.this.setLike(Long.valueOf(commentTag.comment_id), commentTag.comment, false);
                                                return;
                                            case 7:
                                                CommentsSearchActivity.this.showLikes(commentTag.comment_id);
                                                return;
                                            case 8:
                                                CommentsSearchActivity commentsSearchActivity = CommentsSearchActivity.this;
                                                CommentTag commentTag2 = commentTag;
                                                commentsSearchActivity.editComment(commentTag2.comment_id, commentTag2.comment);
                                                return;
                                            case 9:
                                                Helper.showGroupBlockActivity(CommentsSearchActivity.this.content_owner_id, commentTag.user_id, CommentsSearchActivity.this);
                                                return;
                                            case 10:
                                            case 11:
                                            case 12:
                                            case 14:
                                            default:
                                                return;
                                            case 13:
                                                if (CommentsSearchActivity.this.comment_type == 0) {
                                                    new ReportHelper(CommentsSearchActivity.this).showReportPhotoCommentDialog(commentTag.comment_id, CommentsSearchActivity.this.content_owner_id);
                                                    return;
                                                } else if (CommentsSearchActivity.this.comment_type == 2) {
                                                    new ReportHelper(CommentsSearchActivity.this).showReportVideoCommentDialog(commentTag.comment_id, CommentsSearchActivity.this.content_owner_id);
                                                    return;
                                                } else if (CommentsSearchActivity.this.comment_type == 5) {
                                                    new ReportHelper(CommentsSearchActivity.this).showReportMarketCommentDialog(commentTag.comment_id, CommentsSearchActivity.this.content_owner_id);
                                                    return;
                                                } else {
                                                    new ReportHelper(CommentsSearchActivity.this).showReportPostCommentDialog(commentTag.comment_id, CommentsSearchActivity.this.content_owner_id);
                                                    return;
                                                }
                                            case 15:
                                                CommentsSearchActivity.this.replyToWho(commentTag.comment.reply_to_cid);
                                                return;
                                            case 16:
                                                CommentsSearchActivity.this.copyLink(commentTag.comment.cid);
                                                return;
                                            case 17:
                                                CommentsSearchActivity.this.sendToFriend(commentTag.comment.cid);
                                                return;
                                        }
                                    }
                                }).create();
                                create.setCanceledOnTouchOutside(true);
                                create.show();
                                return;
                            }
                        }
                        arrayList.add(new MenuItemDetails((int) R.string.label_edit, 8));
                        if (this.comment_type != 4) {
                        }
                        arrayList.add(new MenuItemDetails((int) R.string.label_user_to_ban, 9));
                        if (z) {
                        }
                        i2 = this.comment_type;
                        if (i2 != 1) {
                        }
                        arrayList.add(new MenuItemDetails((int) R.string.label_complain_report, 13));
                        if (arrayList.size() != 0) {
                        }
                    }
                }
            }
            z = true;
            extractUrl = Helper.extractUrl(commentTag.message, true);
            arrayList = new ArrayList();
            if (!valueOf.equals(Long.valueOf(commentTag.user_id))) {
                arrayList.add(new MenuItemDetails((int) R.string.label_replay, 4));
            }
            i = this.comment_type;
            if (i != 1) {
            }
            if (commentTag.like) {
            }
            arrayList.add(new MenuItemDetails((int) R.string.who_likes, 7));
            arrayList.add(new MenuItemDetails((int) R.string.label_menu_send_to_friend, 17));
            if (commentTag.comment.reply_to_cid > 0) {
            }
            if (extractUrl.size() > 0) {
            }
            arrayList.add(new MenuItemDetails((int) R.string.copy_text, 3));
            arrayList.add(new MenuItemDetails((int) R.string.label_copy_video_link, 16));
            if (!valueOf.equals(Long.valueOf(commentTag.user_id))) {
                j = this.content_owner_id;
                if (j < 0) {
                }
                j2 = commentTag.user_id;
                if (j2 < 0) {
                }
                if (this.comment_type != 4) {
                }
                arrayList.add(new MenuItemDetails((int) R.string.label_user_to_ban, 9));
                if (z) {
                }
                i2 = this.comment_type;
                if (i2 != 1) {
                }
                arrayList.add(new MenuItemDetails((int) R.string.label_complain_report, 13));
                if (arrayList.size() != 0) {
                }
            }
            arrayList.add(new MenuItemDetails((int) R.string.label_edit, 8));
            if (this.comment_type != 4) {
            }
            arrayList.add(new MenuItemDetails((int) R.string.label_user_to_ban, 9));
            if (z) {
            }
            i2 = this.comment_type;
            if (i2 != 1) {
            }
            arrayList.add(new MenuItemDetails((int) R.string.label_complain_report, 13));
            if (arrayList.size() != 0) {
            }
        } catch (Throwable th) {
            Helper.reportError(th);
            th.printStackTrace();
        }
    }

    private void displayData() {
        try {
            CommentListAdapter commentListAdapter = new CommentListAdapter(new ArrayList(), this);
            this.comment_list_adapter = commentListAdapter;
            this.lv_comment_list.setAdapter((ListAdapter) commentListAdapter);
        } catch (Exception e) {
            Helper.reportError(e);
            displayToast(e.getMessage());
            e.printStackTrace();
        }
    }

    public void downloadComments(int i, Callback callback) {
        int i2 = this.comment_type;
        if (i2 == 1) {
            KApplication.session.getWallComments(Long.valueOf(this.content_owner_id), Long.valueOf(this.content_id), i, 100, false, null, 0L, callback, this);
        } else if (i2 == 0) {
            KApplication.session.getPhotoComments(Long.valueOf(this.content_id), Long.valueOf(this.content_owner_id), i, 100, null, callback, this);
        } else if (i2 == 3) {
            KApplication.session.getNoteComments(Long.valueOf(this.content_id), Long.valueOf(this.content_owner_id), i, 100, callback, this);
        } else if (i2 == 2) {
            KApplication.session.getVideoComments(this.content_id, Long.valueOf(this.content_owner_id), i, 100, null, callback, this);
        } else if (i2 == 4) {
            KApplication.session.getGroupTopicComments(this.content_owner_id, this.content_id, 0, 0, 100, i, false, null, callback, this);
        } else if (i2 == 5) {
            KApplication.session.getMarketComments(Long.valueOf(this.content_owner_id), Long.valueOf(this.content_id), i, 100, null, callback, this);
        }
    }

    public void editComment(long j, Comment comment) {
        Intent intent = new Intent(this, NewCommentActivity.class);
        intent.putExtra("com.perm.kate.edit", true);
        intent.putExtra("com.perm.kate.cid", j);
        intent.putExtra("com.perm.kate.pid", String.valueOf(this.content_id));
        intent.putExtra("com.perm.kate.owner_id", String.valueOf(getCorrectOwnerId()));
        intent.putExtra("com.perm.kate.comment_type", this.comment_type);
        intent.putExtra("com.perm.kate.comment", comment);
        startActivityForResult(intent, 2);
    }

    private ArrayList filter(ArrayList arrayList) {
        ArrayList arrayList2 = new ArrayList();
        Iterator it = arrayList.iterator();
        while (it.hasNext()) {
            Comment comment = (Comment) it.next();
            if (comment.message.toLowerCase().contains(this.query)) {
                arrayList2.add(comment);
            }
            if (comment.thread_comments.size() > 0) {
                Iterator<Comment> it2 = comment.thread_comments.iterator();
                while (it2.hasNext()) {
                    Comment next = it2.next();
                    if (next.message.toLowerCase().contains(this.query)) {
                        arrayList2.add(next);
                    }
                }
            }
        }
        return arrayList2;
    }

    public long getCorrectOwnerId() {
        return this.comment_type == 4 ? -this.content_owner_id : this.content_owner_id;
    }

    private String getLink(long j) {
        int i = this.comment_type;
        String str = i == 4 ? "topic" : i == 0 ? "photo" : i == 2 ? "video" : i == 5 ? "product" : i == 1 ? "wall" : "";
        String str2 = i == 4 ? "post" : "reply";
        return "http://vk.com/" + str + getCorrectOwnerId() + "_" + this.content_id + "?" + str2 + "=" + j;
    }

    private void loadFromCache() {
        this.comments = KApplication.db.fetchCommentList(this.content_id, this.comment_type, this.content_owner_id, this.account_id);
    }

    public void loadMore() {
        new Thread() {
            @Override
            public void run() {
                if (KApplication.session == null) {
                    return;
                }
                CommentsSearchActivity commentsSearchActivity = CommentsSearchActivity.this;
                commentsSearchActivity.downloadComments(commentsSearchActivity.comments.size(), CommentsSearchActivity.this.load_more_callback);
            }
        }.start();
    }

    private void reloadInThread() {
        new Thread() {
            @Override
            public void run() {
                CommentsSearchActivity.this.showProgressBar(true);
                CommentsSearchActivity.this.state = 1;
                CommentsSearchActivity commentsSearchActivity = CommentsSearchActivity.this;
                commentsSearchActivity.downloadComments(0, commentsSearchActivity.callback_reload);
            }
        }.start();
    }

    public void reply(CommentTag commentTag) {
        try {
            this.reply_to_cid = String.valueOf(commentTag.comment_id);
            String str = commentTag.user_name;
            if (str == null || str.length() <= 0) {
                Comment comment = commentTag.comment;
                if (comment != null) {
                    long j = comment.from_id;
                    if (j > 0) {
                        User fetchUser = KApplication.db.fetchUser(j);
                        if (fetchUser != null) {
                            this.reply_to_user_name = fetchUser.first_name;
                        }
                    } else {
                        Group fetchGroup = KApplication.db.fetchGroup(j * (-1));
                        if (fetchGroup != null) {
                            this.reply_to_user_name = fetchGroup.name;
                        }
                    }
                }
            } else {
                this.reply_to_user_name = commentTag.user_name;
            }
            showNewCommentActivity(this.reply_to_cid, this.reply_to_user_name);
        } catch (Throwable th) {
            th.printStackTrace();
            Helper.reportError(th);
        }
    }

    public void replyToWho(long j) {
        Intent intent = new Intent();
        intent.setClass(this, CommentRepliesActivity.class);
        intent.putExtra("comment_id", j);
        intent.putExtra("content_id", this.content_id);
        intent.putExtra("content_owner_id", this.content_owner_id);
        intent.putExtra("content_type", this.comment_type);
        startActivity(intent);
    }

    public void requeryOnUiThread() {
        ArrayList filter = filter(this.comments);
        Helper.getMissingUsers(filter);
        final ArrayList arrayList = new ArrayList();
        Iterator it = filter.iterator();
        while (it.hasNext()) {
            Comment comment = (Comment) it.next();
            CommentListAdapter.parseProfileLinks(comment);
            arrayList.add(new PageCommentList.CommentData(comment));
        }
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                CommentsSearchActivity.this.comment_list_adapter.list = arrayList;
                CommentsSearchActivity.this.comment_list_adapter.notifyDataSetChanged();
            }
        });
    }

    public void searchClick() {
        String lowerCase = this.tb_search.getText().toString().toLowerCase();
        if (TextUtils.isEmpty(lowerCase)) {
            return;
        }
        this.query = lowerCase;
        reloadInThread();
        loadFromCache();
        requeryOnUiThread();
    }

    public void sendToFriend(long j) {
        String link = getLink(j);
        Intent intent = new Intent();
        intent.setClass(this, MembersActivity.class);
        intent.putExtra("com.perm.kate.only_members", false);
        intent.putExtra("com.perm.kate.new_message", true);
        intent.putExtra("shared_text", link);
        startActivity(intent);
    }

    public void showLikes(long j) {
        Intent intent = new Intent();
        intent.setClass(this, LikesActivity.class);
        intent.putExtra("com.perm.kate.item_id", j);
        intent.putExtra("com.perm.kate.owner_id", getCorrectOwnerId());
        int i = this.comment_type;
        intent.putExtra("com.perm.kate.item_type", i == 4 ? "topic_comment" : i == 0 ? "photo_comment" : i == 2 ? "video_comment" : i == 5 ? "market_comment" : "comment");
        startActivity(intent);
    }

    private void showNewCommentActivity(String str, String str2) {
        Intent intent = new Intent();
        intent.setClass(this, NewCommentActivity.class);
        intent.putExtra("com.perm.kate.pid", String.valueOf(this.content_id));
        intent.putExtra("com.perm.kate.owner_id", String.valueOf(getCorrectOwnerId()));
        intent.putExtra("com.perm.kate.comment_type", this.comment_type);
        intent.putExtra("com.perm.kate.reply_to_cid", str);
        intent.putExtra("com.perm.kate.reply_to_user_name", str2);
        startActivityForResult(intent, 0);
    }

    void confirmRemoveComment(final Long l, final long j) {
        AlertDialog create = new AlertDialog.Builder(this).setMessage(R.string.label_confirm_delete).setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialogInterface, int i) {
                CommentsSearchActivity.this.removeComment(l, j);
            }
        }).setNegativeButton(R.string.no, (DialogInterface.OnClickListener) null).create();
        create.setCanceledOnTouchOutside(true);
        create.show();
    }

    @Override
    public void onActivityResult(int i, int i2, Intent intent) {
        super.onActivityResult(i, i2, intent);
    }

    @Override
    public void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        setContentView(R.layout.comments_search);
        setHeaderTitle(R.string.label_menu_search);
        ListView listView = (ListView) findViewById(R.id.lv_comment_list);
        this.lv_comment_list = listView;
        listView.setOnItemClickListener(this.onItemClickListener);
        this.lv_comment_list.setOnScrollListener(this.scrollListener);
        EditText editText = (EditText) findViewById(R.id.tb_search);
        this.tb_search = editText;
        editText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
            @Override
            public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
                if (i == 3 || i == 0 || i == 2 || i == 5 || i == 6 || i == 4) {
                    CommentsSearchActivity.this.searchClick();
                    return true;
                }
                return false;
            }
        });
        this.content_owner_id = getIntent().getLongExtra("com.perm.kate.current_owner_id", 0L);
        this.content_id = getIntent().getLongExtra("com.perm.kate.current_photo_pid", 0L);
        this.comment_type = getIntent().getIntExtra("com.perm.kate.comment_type", 0);
        findViewById(R.id.btn_search).setOnClickListener(this.search_OnClickListener);
        displayData();
    }

    @Override
    public void onDestroy() {
        CommentListAdapter commentListAdapter = this.comment_list_adapter;
        if (commentListAdapter != null) {
            commentListAdapter.Destroy();
        }
        super.onDestroy();
    }

    protected void removeComment(final Long l, long j) {
        showProgressBar(true);
        final Callback callback = new Callback(this) {
            @Override
            public void error(Throwable th) {
                super.error(th);
                CommentsSearchActivity.this.showProgressBar(false);
            }

            @Override
            public void ready(Object obj) {
                CommentsSearchActivity.this.showProgressBar(false);
                if (((Boolean) obj).booleanValue()) {
                    KApplication.db.deleteComment(CommentsSearchActivity.this.content_id, CommentsSearchActivity.this.comment_type, CommentsSearchActivity.this.content_owner_id, l.longValue());
                    CommentsSearchActivity.this.requeryOnUiThread();
                }
            }
        };
        new Thread() {
            @Override
            public void run() {
                if (CommentsSearchActivity.this.comment_type == 1) {
                    KApplication.session.deleteWallComment(Long.valueOf(CommentsSearchActivity.this.content_owner_id), l.longValue(), callback, CommentsSearchActivity.this);
                } else if (CommentsSearchActivity.this.comment_type == 0) {
                    KApplication.session.deletePhotoComment(CommentsSearchActivity.this.content_id, Long.valueOf(CommentsSearchActivity.this.content_owner_id), l.longValue(), callback, CommentsSearchActivity.this);
                } else if (CommentsSearchActivity.this.comment_type == 3) {
                    KApplication.session.deleteNoteComment(Long.valueOf(CommentsSearchActivity.this.content_owner_id), l.longValue(), callback, CommentsSearchActivity.this);
                } else if (CommentsSearchActivity.this.comment_type == 2) {
                    KApplication.session.deleteVideoComment(Long.valueOf(CommentsSearchActivity.this.content_owner_id), l.longValue(), callback, CommentsSearchActivity.this);
                } else if (CommentsSearchActivity.this.comment_type == 4) {
                    KApplication.session.deleteGroupTopicComment(CommentsSearchActivity.this.content_owner_id, CommentsSearchActivity.this.content_id, l.longValue(), callback, CommentsSearchActivity.this);
                }
                if (CommentsSearchActivity.this.comment_type == 5) {
                    KApplication.session.deleteMarketComment(Long.valueOf(CommentsSearchActivity.this.content_owner_id), l.longValue(), callback, CommentsSearchActivity.this);
                }
            }
        }.start();
    }

    void setLike(final Long l, final Comment comment, final boolean z) {
        final Callback callback = new Callback(this) {
            @Override
            public void error(Throwable th) {
                super.error(th);
                if (th instanceof KException) {
                    int i = ((KException) th).error_code;
                    if (i == 230 || i == 231) {
                        KApplication.db.updateCommentLikes(l.longValue(), CommentsSearchActivity.this.content_id, CommentsSearchActivity.this.content_owner_id, CommentsSearchActivity.this.comment_type, null, z, CommentsSearchActivity.this.account_id);
                        CommentsSearchActivity.this.requeryOnUiThread();
                    }
                }
            }

            @Override
            public void ready(Object obj) {
                KApplication.db.updateCommentLikes(l.longValue(), CommentsSearchActivity.this.content_id, CommentsSearchActivity.this.content_owner_id, CommentsSearchActivity.this.comment_type, (Long) obj, z, CommentsSearchActivity.this.account_id);
                Comment comment2 = comment;
                boolean z2 = z;
                comment2.user_like = z2;
                if (z2) {
                    comment2.like_count++;
                } else {
                    comment2.like_count--;
                }
                CommentsSearchActivity.this.requeryOnUiThread();
            }
        };
        new Thread() {
            @Override
            public void run() {
                Long valueOf = Long.valueOf(CommentsSearchActivity.this.getCorrectOwnerId());
                int i = CommentsSearchActivity.this.comment_type;
                String str = i != 0 ? i != 2 ? i != 4 ? i != 5 ? "comment" : "market_comment" : "topic_comment" : "video_comment" : "photo_comment";
                if (z) {
                    KApplication.session.addLike(valueOf, l, str, null, callback, CommentsSearchActivity.this);
                } else {
                    KApplication.session.deleteLike(valueOf, str, l, callback, CommentsSearchActivity.this);
                }
            }
        }.start();
    }
}