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

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


package com.perm.kate;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.database.Cursor;
import android.graphics.PorterDuff;
import android.os.Build;
import android.preference.PreferenceManager;
import android.text.SpannableStringBuilder;
import android.text.TextUtils;
import android.text.method.LinkMovementMethod;
import android.text.style.ClickableSpan;
import android.text.style.URLSpan;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.CursorAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.fragment.app.Fragment;
import com.perm.kate.NewsCursorAdapter;
import com.perm.kate.api.Attachment;
import com.perm.kate.api.Comment;
import com.perm.kate.api.Group;
import com.perm.kate.api.Photo;
import com.perm.kate.api.User;
import com.perm.kate.api.WallMessage;
import com.perm.kate.api.WallResponse;
import com.perm.kate.db.DataHelper;
import com.perm.kate.session.Callback;
import com.perm.kate.theme.ColorTheme;
import com.perm.utils.AdEvents;
import com.perm.utils.GroupCache;
import com.perm.utils.LeakDetector;
import com.perm.utils.Linkify;
import com.perm.utils.LocalLinkMovementMethod;
import com.perm.utils.RepostHelper;
import com.perm.utils.SmileHelper;
import com.perm.utils.SpamFinder;
import com.perm.utils.SpamHelper;
import com.perm.utils.UserCache;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.json.JSONArray;
import org.json.JSONObject;
public class NewsCursorAdapter extends CursorAdapter {
    final long account_id;
    BaseActivity activity;
    AttachmentsHelper attachmentsHelper;
    final HashMap attachments_cache;
    final boolean big_photos;
    boolean card_style_news;
    boolean collapse_news;
    private final View.OnClickListener commentsClickListener;
    final WeakReference fragment;
    final GroupCache groupCache;
    boolean is_clickable_count_views;
    private final View.OnClickListener likesClickListener;
    private final View.OnLongClickListener likesLongClickListener;
    boolean old_style_news;
    final HashSet open_news;
    private final RepostHelper.RepostCallback repostCallback;
    private final View.OnClickListener repostsClickListener;
    final UserCache userCache;
    private final View.OnClickListener user_photo_OnClickListener;
    static final View.OnClickListener readMoreClick = new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            long longValue = ((Long) view.getTag(R.id.action_audio)).longValue();
            NewsItemTag newsItemTag = (NewsItemTag) view.getTag(R.id.action_faves);
            ((HashSet) view.getTag(R.id.accounts)).add(Long.valueOf(longValue));
            ((BaseAdapter) view.getTag(R.id.action_all)).notifyDataSetChanged();
            if (newsItemTag.ad_data != null) {
                AdEvents.reportExpand(newsItemTag.wall_owner_id + "_" + newsItemTag.post_id, newsItemTag.ad_data, newsItemTag.track_code);
            }
        }
    };
    static final Pattern pattern = Pattern.compile("\\[([^\\]\\[]*?)(:bp-\\d*_\\d*)?\\|(.*?)\\]");

    public class AnonymousClass6 implements View.OnClickListener {
        AnonymousClass6() {
        }

        public void lambda$onClick$0(NewsItemTag newsItemTag, Callback callback) {
            KApplication.session.getWallMessages(Long.valueOf(Long.parseLong(newsItemTag.wall_owner_id)), 100, 0, null, callback, NewsCursorAdapter.this.activity);
        }

        @Override
        public void onClick(final View view) {
            final String str = (String) view.getTag(R.id.view1);
            final String str2 = (String) view.getTag(R.id.view2);
            final NewsItemTag newsItemTag = (NewsItemTag) view.getTag();
            if (!newsItemTag.type.equals("ads")) {
                Helper.ShowComments(1, Long.valueOf(Long.parseLong(str)), Long.parseLong(str2), NewsCursorAdapter.this.activity, newsItemTag.comment_can_post);
                return;
            }
            final Callback callback = new Callback(NewsCursorAdapter.this.activity) {
                @Override
                public void ready(Object obj) {
                    ArrayList arrayList = ((WallResponse) obj).items;
                    long longValue = ((Long) view.getTag(R.id.view3)).longValue();
                    Iterator it = arrayList.iterator();
                    while (it.hasNext()) {
                        WallMessage wallMessage = (WallMessage) it.next();
                        if (wallMessage.date == longValue) {
                            Helper.ShowComments(1, Long.valueOf(wallMessage.id), Long.parseLong(str2), NewsCursorAdapter.this.activity, wallMessage.comment_can_post);
                            return;
                        }
                    }
                    Helper.ShowComments(1, Long.valueOf(Long.parseLong(str)), Long.parseLong(str2), NewsCursorAdapter.this.activity, newsItemTag.comment_can_post);
                }
            };
            new Thread(new Runnable() {
                @Override
                public final void run() {
                    NewsCursorAdapter.AnonymousClass6.this.lambda$onClick$0(newsItemTag, callback);
                }
            }).start();
        }
    }

    public static class AttachmentsHelper extends com.perm.kate.AttachmentsHelper {
        public AttachmentsHelper(BaseActivity baseActivity, boolean z, int i, boolean z2, int i2, int i3, int i4) {
            super(baseActivity, z, i, z2, i2, i3, i4);
        }
    }

    public NewsCursorAdapter(BaseActivity baseActivity, Cursor cursor, Fragment fragment) {
        super((Context) baseActivity, cursor, false);
        boolean shouldDisplayBigPhotos = shouldDisplayBigPhotos();
        this.big_photos = shouldDisplayBigPhotos;
        this.attachments_cache = new HashMap();
        this.collapse_news = true;
        this.open_news = new HashSet();
        this.old_style_news = false;
        this.is_clickable_count_views = true;
        this.card_style_news = false;
        this.groupCache = new GroupCache();
        this.userCache = new UserCache();
        this.user_photo_OnClickListener = new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                NewsCursorAdapter.profileClick(view, NewsCursorAdapter.this.activity);
            }
        };
        this.likesClickListener = new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                String str = (String) view.getTag(R.id.view1);
                String str2 = (String) view.getTag(R.id.view2);
                boolean booleanValue = ((Boolean) view.getTag(R.id.view3)).booleanValue();
                boolean booleanValue2 = ((Boolean) view.getTag(R.id.action_audio)).booleanValue();
                NewsCursorAdapter newsCursorAdapter = NewsCursorAdapter.this;
                NewsFragment.setLike(str, str2, !booleanValue, newsCursorAdapter.activity, newsCursorAdapter.getCursor(), NewsCursorAdapter.this.account_id, booleanValue2);
            }
        };
        this.likesLongClickListener = new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View view) {
                boolean booleanValue = ((Boolean) view.getTag(R.id.action_audio)).booleanValue();
                NewsCursorAdapter newsCursorAdapter = NewsCursorAdapter.this;
                NewsCursorAdapter.showReactionsDialog((String) view.getTag(R.id.view1), (String) view.getTag(R.id.view2), booleanValue, newsCursorAdapter.activity, newsCursorAdapter.getCursor(), NewsCursorAdapter.this.account_id);
                return true;
            }
        };
        this.commentsClickListener = new AnonymousClass6();
        this.repostsClickListener = new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                boolean booleanValue = ((Boolean) view.getTag(R.id.view3)).booleanValue();
                NewsCursorAdapter newsCursorAdapter = NewsCursorAdapter.this;
                Helper.showShareDialog(newsCursorAdapter.activity, (String) view.getTag(R.id.view1), (String) view.getTag(R.id.view2), true, true, newsCursorAdapter.repostCallback, (Fragment) NewsCursorAdapter.this.fragment.get(), booleanValue);
            }
        };
        this.repostCallback = new RepostHelper.RepostCallback() {
            @Override
            public void success(WallMessage wallMessage) {
                NewsCursorAdapter.this.activity.runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        if (NewsCursorAdapter.this.getCursor() != null) {
                            NewsCursorAdapter.this.getCursor().requery();
                        }
                    }
                });
            }
        };
        LeakDetector.getInstance().monitorObject(this);
        this.activity = baseActivity;
        this.fragment = new WeakReference(fragment);
        this.account_id = Long.parseLong(KApplication.session.getMid());
        int i = KApplication.isTabletUi ? KApplication.LEFT_PANE_NEWS_MIN_WIDTH : 0;
        int i2 = getOldStyleFlag(this.activity) ? 0 : getCardStyleFlag(baseActivity) ? 20 : 0;
        int i3 = getOldStyleFlag(this.activity) ? 12 : 0;
        BaseActivity baseActivity2 = this.activity;
        this.attachmentsHelper = new AttachmentsHelper(baseActivity2, shouldDisplayBigPhotos, i, getOldStyleFlag(baseActivity2), i2, i3, 3);
        this.collapse_news = isCollapseNewsEnabled();
        this.old_style_news = getOldStyleFlag(this.activity);
        this.card_style_news = getCardStyleFlag(this.activity);
    }

    public static void ShowGroup(Long l, Activity activity) {
        Intent intent = new Intent();
        intent.setClass(activity, GroupActivity.class);
        intent.putExtra("com.perm.kate.group_id", l);
        activity.startActivity(intent);
    }

    public static void ShowProfile(String str, Activity activity) {
        Intent intent = new Intent();
        intent.setClass(activity, ProfileInfoActivity.class);
        intent.putExtra("com.perm.kate.user_id", str);
        activity.startActivity(intent);
    }

    private static ClickableSpan createLinkSpan(final Activity activity, final GroupLink groupLink, boolean z, final List list, final String str, final String str2, final String str3) {
        return !z ? new URLSpan("") : new ClickableSpan() {
            @Override
            public void onClick(View view) {
                Activity activity2 = activity;
                if (activity2 == null) {
                    return;
                }
                Helper.openVK_COMlink(groupLink.link, activity2);
                if (TextUtils.isEmpty(str2)) {
                    return;
                }
                AdEvents.reportPostLinkClick(list, str, str2, str3, groupLink.link);
            }
        };
    }

    public static View createView(Context context, ViewGroup viewGroup, boolean z, int i) {
        View inflate = LayoutInflater.from(context).inflate(i, viewGroup, false);
        ViewHolder viewHolder = new ViewHolder();
        viewHolder.tv_posts_news_user_name = (TextView) inflate.findViewById(R.id.tv_posts_news_user_name);
        viewHolder.tv_posts_news_ago = (TextView) inflate.findViewById(R.id.tv_posts_news_ago);
        viewHolder.tv_posts_news_text = (TextView) inflate.findViewById(R.id.tv_posts_news_text);
        viewHolder.img_posts_news_user_photo = (ImageView) inflate.findViewById(R.id.img_posts_news_user_photo);
        viewHolder.tv_posts_news_like_count = (TextView) inflate.findViewById(R.id.tv_posts_news_like_count);
        viewHolder.tv_posts_news_comments_count = (TextView) inflate.findViewById(R.id.tv_posts_news_comments_count);
        viewHolder.comments_view = inflate.findViewById(R.id.comments_view);
        viewHolder.views_container = inflate.findViewById(R.id.views_container);
        viewHolder.views_text = (TextView) inflate.findViewById(R.id.views_text);
        viewHolder.photo_container = (ViewGroup) inflate.findViewById(R.id.photo_attachments);
        viewHolder.links_container = (LinearLayout) inflate.findViewById(R.id.link_attachments);
        viewHolder.likes_view = inflate.findViewById(R.id.likes_view);
        viewHolder.likes_heart = (ImageView) inflate.findViewById(R.id.likes_heart);
        viewHolder.original_name = (TextView) inflate.findViewById(R.id.original_name);
        viewHolder.original_name_layout = inflate.findViewById(R.id.original_name_layout);
        viewHolder.copy_text = (TextView) inflate.findViewById(R.id.copy_text);
        viewHolder.reposts_view = inflate.findViewById(R.id.reposts_view);
        viewHolder.tv_reposts_count = (TextView) inflate.findViewById(R.id.tv_reposts_count);
        viewHolder.repost_icon = (ImageView) inflate.findViewById(R.id.repost_icon);
        viewHolder.tv_post_type = (TextView) inflate.findViewById(R.id.tv_post_type);
        NewsItemTag newsItemTag = new NewsItemTag();
        newsItemTag.view_holder = viewHolder;
        inflate.setTag(newsItemTag);
        return inflate;
    }

    public static void cropLongText(SpannableStringBuilder spannableStringBuilder, View view, HashSet hashSet, long j, BaseAdapter baseAdapter, NewsItemTag newsItemTag) {
        try {
            if (spannableStringBuilder.length() <= 280 || hashSet.contains(Long.valueOf(j))) {
                return;
            }
            spannableStringBuilder.delete(280, spannableStringBuilder.length());
            view.setVisibility(0);
            view.setTag(R.id.action_audio, Long.valueOf(j));
            view.setTag(R.id.accounts, hashSet);
            view.setTag(R.id.action_all, baseAdapter);
            view.setTag(R.id.action_faves, newsItemTag);
            view.setOnClickListener(readMoreClick);
        } catch (Throwable th) {
            th.printStackTrace();
            Helper.reportError(th);
        }
    }

    private void displayComments(View view, Context context, Cursor cursor) {
        Group group;
        ViewGroup viewGroup = (ViewGroup) view.findViewById(R.id.comments_container);
        viewGroup.removeAllViews();
        String string = cursor.getString(cursor.getColumnIndex("comments_json"));
        if (string == null || string.equals("")) {
            return;
        }
        JSONArray jSONArray = new JSONArray(string);
        int length = jSONArray.length();
        for (int i = 0; i < length; i++) {
            try {
                Comment parse = Comment.parse((JSONObject) jSONArray.get(i));
                User user = null;
                View inflate = LayoutInflater.from(context).inflate(R.layout.comment_item, (ViewGroup) null, false);
                inflate.setBackground(null);
                String removeProfileLinks = CommentListAdapter.removeProfileLinks(parse.message);
                ArrayList<Attachment> arrayList = parse.attachments;
                if (arrayList != null && arrayList.size() > 0) {
                    if (!TextUtils.isEmpty(removeProfileLinks)) {
                        removeProfileLinks = removeProfileLinks + " ";
                    }
                    removeProfileLinks = removeProfileLinks + "(" + DialogsAdapter.getAttachmnetsText(this.activity, parse.attachments) + ")";
                }
                ((TextView) inflate.findViewById(R.id.tv_comment_message)).setText(SmileHelper.getSmiledText(this.activity, removeProfileLinks));
                ((TextView) inflate.findViewById(R.id.tv_message_ago)).setText(Helper.getAgo(this.activity, parse.date));
                long j = parse.from_id;
                if (j > 0) {
                    user = this.userCache.get(j);
                    group = null;
                } else {
                    group = this.groupCache.get(j);
                }
                if (parse.deleted) {
                    ((TextView) inflate.findViewById(R.id.tv_comment_name)).setText(this.activity.getString(R.string.comment_has_been_deleted));
                    ((ImageView) inflate.findViewById(R.id.img_comment_photo)).setImageBitmap(Helper.getDeletedAva());
                } else if (user != null || group != null) {
                    ImageView imageView = (ImageView) inflate.findViewById(R.id.img_comment_photo);
                    imageView.setOnClickListener(this.user_photo_OnClickListener);
                    imageView.setTag(R.id.img_posts_news_user_photo, Long.valueOf(parse.from_id));
                    TextView textView = (TextView) inflate.findViewById(R.id.tv_comment_name);
                    if (user != null) {
                        KApplication.getImageLoader().DisplayImage(user.photo, imageView, true, 90, Helper.getAvaStubId(), true);
                        textView.setText(user.first_name + " " + user.last_name);
                    } else {
                        KApplication.getImageLoader().DisplayImage(group.photo_medium, imageView, true, 90, Helper.getAvaStubId(), true);
                        textView.setText(group.name);
                    }
                }
                viewGroup.addView(inflate);
            } catch (Throwable th) {
                th.printStackTrace();
                Helper.reportError(th);
            }
        }
    }

    public static void displayCommentsCount(ViewHolder viewHolder, long j, boolean z) {
        if (j > 0) {
            viewHolder.comments_view.setVisibility(0);
            viewHolder.tv_posts_news_comments_count.setText(String.valueOf(j));
            return;
        }
        viewHolder.comments_view.setVisibility(z ? 8 : 0);
        viewHolder.tv_posts_news_comments_count.setText("");
    }

    public static void displayLikeCount(long j, boolean z, View view, TextView textView, ImageView imageView, boolean z2) {
        if (j <= 0) {
            view.setVisibility(z2 ? 8 : 0);
            imageView.setColorFilter(-4473925);
            textView.setText("");
            return;
        }
        view.setVisibility(0);
        textView.setText(String.valueOf(j));
        if (z) {
            imageView.setColorFilter(ColorTheme.getColorTheme().getLikeColor());
        } else {
            imageView.setColorFilter(-4473925);
        }
    }

    public static void displayProfile(ViewHolder viewHolder, String str, long j, View.OnClickListener onClickListener, String str2) {
        viewHolder.tv_posts_news_user_name.setText(str);
        ImageView imageView = viewHolder.img_posts_news_user_photo;
        imageView.setContentDescription((KApplication.current.getString(R.string.label_menu_profile) + " ") + str);
        KApplication.getImageLoader().DisplayImage(str2, viewHolder.img_posts_news_user_photo, true, 90, Helper.getAvaStubId(), true);
        viewHolder.img_posts_news_user_photo.setOnClickListener(onClickListener);
        viewHolder.img_posts_news_user_photo.setTag(R.id.img_posts_news_user_photo, Long.valueOf(j));
    }

    public static void displayRepostsCount(ViewHolder viewHolder, long j, boolean z, boolean z2) {
        if (j > 0) {
            viewHolder.reposts_view.setVisibility(0);
            viewHolder.tv_reposts_count.setText(String.valueOf(j));
        } else {
            viewHolder.reposts_view.setVisibility(z ? 8 : 0);
            viewHolder.tv_reposts_count.setText("");
        }
        if (z2) {
            viewHolder.repost_icon.setColorFilter(ColorTheme.getColorTheme().getLikeColor(), PorterDuff.Mode.SRC_ATOP);
        } else {
            viewHolder.repost_icon.setColorFilter(-4473925, PorterDuff.Mode.SRC_ATOP);
        }
    }

    public static void displayRetweet(ViewHolder viewHolder, Long l, GroupCache groupCache, UserCache userCache, NewsItemTag newsItemTag, String str, boolean z, Activity activity) {
        String str2;
        newsItemTag.copy_owner_group = null;
        newsItemTag.copy_owner_user = null;
        if (l == null || l.longValue() == 0) {
            viewHolder.original_name_layout.setVisibility(8);
        } else {
            str2 = "";
            if (l.longValue() < 0) {
                Group group = groupCache.get(l.longValue());
                str2 = group != null ? group.name : "";
                newsItemTag.copy_owner_group = group;
            } else {
                User user = userCache.get(l.longValue());
                if (user != null) {
                    str2 = user.first_name + " " + user.last_name;
                }
                newsItemTag.copy_owner_user = user;
            }
            viewHolder.original_name.setText(str2);
            viewHolder.original_name_layout.setVisibility(0);
        }
        if (str == null || str.length() == 0) {
            viewHolder.copy_text.setVisibility(8);
            return;
        }
        viewHolder.copy_text.setVisibility(0);
        if (!z || activity == null) {
            SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(str);
            spannableLink(spannableStringBuilder, activity, false);
            viewHolder.copy_text.setText(SmileHelper.getSmiledText(KApplication.current, spannableStringBuilder));
            return;
        }
        SpannableStringBuilder spannableStringBuilder2 = new SpannableStringBuilder(str);
        Linkify.addWebLinks(spannableStringBuilder2);
        spannableLink(spannableStringBuilder2, activity, true);
        WallMessageActivity.createHashtagLinks(spannableStringBuilder2, activity, true, false, null, null, null, null);
        viewHolder.copy_text.setText(SmileHelper.getSmiledText(activity, spannableStringBuilder2));
        viewHolder.copy_text.setMovementMethod(LinkMovementMethod.getInstance());
    }

    public static void displaySigner(long j, TextView textView, UserCache userCache, String str, String str2, String str3) {
        User user = j > 0 ? userCache.get(j) : null;
        if (user == null) {
            textView.setVisibility(8);
            return;
        }
        textView.setVisibility(0);
        textView.setText("- " + user.first_name + " " + user.last_name);
    }

    public static void displaySource(String str, TextView textView, Context context) {
        if (textView == null) {
            return;
        }
        if (TextUtils.isEmpty(str)) {
            textView.setVisibility(8);
            return;
        }
        textView.setText(context.getString(R.string.source) + ": " + str);
        textView.setVisibility(0);
    }

    public static void displaySpam(View view, ViewHolder viewHolder, boolean z, boolean z2, View view2, View view3) {
        if (SpamHelper.isHideSpamEnabled()) {
            if (!z) {
                viewHolder.tv_posts_news_text.setMaxLines(Integer.MAX_VALUE);
                viewHolder.tv_posts_news_text.setAlpha(1.0f);
                if (z2) {
                    return;
                }
                view.findViewById(R.id.author).setVisibility(0);
                return;
            }
            viewHolder.tv_posts_news_text.setMaxLines(2);
            viewHolder.tv_posts_news_text.setAlpha(0.5f);
            hideCountViews(viewHolder);
            if (!z2) {
                view.findViewById(R.id.author).setVisibility(8);
            }
            viewHolder.original_name_layout.setVisibility(8);
            viewHolder.copy_text.setVisibility(8);
            view2.setVisibility(8);
            view.findViewById(R.id.show_more).setVisibility(8);
            if (view3 != null) {
                view3.setVisibility(8);
            }
        }
    }

    public static void displayViews(Cursor cursor, ViewHolder viewHolder) {
        int columnIndex = cursor.getColumnIndex("views");
        displayViews(!cursor.isNull(columnIndex) ? Integer.valueOf(cursor.getInt(columnIndex)) : null, viewHolder);
    }

    public static void displayViews(Integer num, ViewHolder viewHolder) {
        String num2;
        View view = viewHolder.views_container;
        if (view == null) {
            return;
        }
        if (num == null) {
            view.setVisibility(8);
            return;
        }
        view.setVisibility(0);
        if (num.intValue() > 1000000) {
            num2 = (num.intValue() / 1000000) + "M";
        } else if (num.intValue() > 1000) {
            num2 = (num.intValue() / 1000) + "K";
        } else {
            num2 = Integer.toString(num.intValue());
        }
        viewHolder.views_text.setText(num2);
    }

    public static int getCardBgByTheme() {
        switch (BaseActivity.Theme) {
            case R.style.KateDark:
                return R.drawable.ds_item_card_bg_black;
            case R.style.KateHolo:
                return R.drawable.ds_item_card_bg_holo_dark;
            case R.style.KateMaterialDark:
                return R.drawable.ds_item_card_bg_material_dark;
            case R.style.KateTransparent:
                return R.drawable.ds_item_card_bg_transparent;
            default:
                return R.drawable.ds_item_card_bg;
        }
    }

    public static boolean getCardStyleFlag(Activity activity) {
        boolean z;
        boolean z2 = PreferenceManager.getDefaultSharedPreferences(activity).getBoolean(activity.getString(R.string.key_card_style_news), true);
        switch (BaseActivity.Theme) {
            case R.style.KateDark:
            case R.style.KateHolo:
            case R.style.KateIndigo:
            case R.style.KateLight:
            case R.style.KateMaterialDark:
            case R.style.KateTransparent:
            case R.style.KateWhite:
                z = true;
                break;
            default:
                z = false;
                break;
        }
        return z2 && z;
    }

    public static boolean getOldStyleFlag(Activity activity) {
        return PreferenceManager.getDefaultSharedPreferences(activity).getBoolean(activity.getString(R.string.key_old_style_news), false);
    }

    public static void hideCountViews(ViewHolder viewHolder) {
        viewHolder.comments_view.setVisibility(8);
        viewHolder.likes_view.setVisibility(8);
        viewHolder.reposts_view.setVisibility(8);
        View view = viewHolder.views_container;
        if (view != null) {
            view.setVisibility(8);
        }
    }

    public static void hideFields(ViewHolder viewHolder) {
        TextView textView = viewHolder.tv_post_type;
        if (textView != null) {
            textView.setVisibility(8);
        }
    }

    public static boolean isCollapseNewsEnabled() {
        return PreferenceManager.getDefaultSharedPreferences(KApplication.current).getBoolean("key_collapse_news", true);
    }

    public static void lambda$showReactionsDialog$0(String str, String str2, Activity activity, Cursor cursor, long j, boolean z, int[] iArr, DialogInterface dialogInterface, int i) {
        NewsFragment.setLike(str, str2, true, activity, cursor, j, z, Integer.valueOf(iArr[i]));
    }

    public static void profileClick(View view, Activity activity) {
        Long l = (Long) view.getTag(R.id.img_posts_news_user_photo);
        if (l.longValue() == 0) {
            return;
        }
        if (l.longValue() > 0) {
            ShowProfile(Long.toString(l.longValue()), activity);
        } else {
            ShowGroup(Long.valueOf(-l.longValue()), activity);
        }
        NewsItemTag newsItemTag = (NewsItemTag) view.getTag();
        if (newsItemTag == null || TextUtils.isEmpty(newsItemTag.ad_data)) {
            return;
        }
        List list = newsItemTag.statistics;
        AdEvents.reportOwnerClick(list, newsItemTag.wall_owner_id + "_" + newsItemTag.post_id, newsItemTag.ad_data, newsItemTag.track_code);
    }

    public static boolean shouldDisplayBigPhotos() {
        String string = PreferenceManager.getDefaultSharedPreferences(KApplication.current.getApplicationContext()).getString(KApplication.current.getApplicationContext().getString(R.string.key_photo_size), "0");
        return string.equals("0") ? Helper.isWifi() : string.equals("2");
    }

    public static void showReactionsDialog(final String str, final String str2, final boolean z, final Activity activity, final Cursor cursor, final long j) {
        final int[] iArr = {0, 1, 2, 3, 5, 4};
        new AlertDialog.Builder(activity).setItems(new CharSequence[]{SmileHelper.getSmiledText(activity, "❤ Нравится"), SmileHelper.getSmiledText(activity, "😂 Смешно"), SmileHelper.getSmiledText(activity, "😲 Ого!"), SmileHelper.getSmiledText(activity, "😍 Восторг"), SmileHelper.getSmiledText(activity, "😢 Печаль"), SmileHelper.getSmiledText(activity, "🤬 Ругаюсь")}, new DialogInterface.OnClickListener() {
            @Override
            public final void onClick(DialogInterface dialogInterface, int i) {
                NewsCursorAdapter.lambda$showReactionsDialog$0(str, str2, activity, cursor, j, z, iArr, dialogInterface, i);
            }
        }).create().show();
    }

    public static void spannableLink(SpannableStringBuilder spannableStringBuilder, Activity activity, boolean z) {
        spannableLink(spannableStringBuilder, activity, z, null, null, null, null);
    }

    public static void spannableLink(SpannableStringBuilder spannableStringBuilder, Activity activity, boolean z, List list, String str, String str2, String str3) {
        try {
            ArrayList arrayList = new ArrayList();
            Matcher matcher = pattern.matcher(spannableStringBuilder.toString());
            while (matcher.find()) {
                GroupLink groupLink = new GroupLink();
                groupLink.index = spannableStringBuilder.toString().indexOf(matcher.group(0));
                groupLink.len = matcher.group(3).length();
                int i = groupLink.index;
                spannableStringBuilder.replace(i, matcher.group(0).length() + i, (CharSequence) matcher.group(3));
                String group = matcher.group(1);
                groupLink.link = group;
                if (!group.startsWith("http")) {
                    groupLink.link = "https://vk.com/" + groupLink.link;
                }
                arrayList.add(groupLink);
            }
            Iterator it = arrayList.iterator();
            while (it.hasNext()) {
                GroupLink groupLink2 = (GroupLink) it.next();
                ClickableSpan createLinkSpan = createLinkSpan(activity, groupLink2, z, list, str, str2, str3);
                int i2 = groupLink2.index;
                spannableStringBuilder.setSpan(createLinkSpan, i2, groupLink2.len + i2, 33);
            }
        } catch (Throwable th) {
            th.printStackTrace();
            Helper.reportError(th, spannableStringBuilder.toString());
        }
    }

    @Override
    public void bindView(View view, Context context, Cursor cursor) {
        ViewHolder viewHolder;
        boolean z;
        View view2;
        String str;
        ArrayList arrayList;
        String str2;
        Object obj;
        long j;
        long j2;
        SpannableStringBuilder spannableStringBuilder;
        Object obj2;
        long j3;
        int i;
        int i2;
        String str3;
        boolean z2;
        Attachment attachment;
        String str4;
        String string;
        String string2;
        Object obj3;
        String str5;
        String str6;
        long j4;
        Object obj4;
        ArrayList arrayList2;
        TextView textView;
        User user;
        boolean z3;
        try {
            NewsItemTag newsItemTag = (NewsItemTag) view.getTag();
            if (newsItemTag == null || (viewHolder = newsItemTag.view_holder) == null) {
                return;
            }
            String string3 = cursor.getString(cursor.getColumnIndex("type"));
            hideFields(viewHolder);
            View findViewById = view.findViewById(R.id.show_more);
            findViewById.setVisibility(8);
            long j5 = cursor.getLong(cursor.getColumnIndex("date"));
            String string4 = cursor.getString(cursor.getColumnIndex("text"));
            int i3 = cursor.getInt(cursor.getColumnIndex("is_comments"));
            boolean equals = string3.equals("ads");
            if (equals) {
                newsItemTag.ad_data = cursor.getString(cursor.getColumnIndex("ad_data"));
                newsItemTag.ad_data_impression = cursor.getString(cursor.getColumnIndex("ad_data_impression"));
                newsItemTag.statistics = DataHelper.deserializeStats(cursor.getBlob(cursor.getColumnIndex("statistics")));
                newsItemTag.track_code = cursor.getString(cursor.getColumnIndex("track_code"));
                newsItemTag.ads_id1 = Integer.valueOf(cursor.getInt(cursor.getColumnIndex("ads_id1")));
                newsItemTag.ads_id2 = Integer.valueOf(cursor.getInt(cursor.getColumnIndex("ads_id2")));
                newsItemTag.advertiser_info_url = cursor.getString(cursor.getColumnIndex("advertiser_info_url"));
            } else {
                newsItemTag.ad_data = null;
            }
            String string5 = cursor.getString(cursor.getColumnIndex("source_id"));
            String valueOf = String.valueOf(cursor.getLong(cursor.getColumnIndex("post_id")));
            String str7 = string5 + "_" + valueOf;
            Long valueOf2 = Long.valueOf(cursor.getLong(cursor.getColumnIndex("copy_owner_id")));
            String string6 = cursor.getString(cursor.getColumnIndex("copy_text"));
            if (!SpamHelper.isHideSpamEnabled() || equals) {
                z = false;
            } else {
                if (!SpamHelper.isSpam(string4) && !SpamHelper.isSpam(string6)) {
                    z3 = false;
                    z = z3;
                }
                z3 = true;
                z = z3;
            }
            long j6 = cursor.getLong(cursor.getColumnIndex("_id"));
            ArrayList arrayList3 = (ArrayList) this.attachments_cache.get(Long.valueOf(j6));
            if (arrayList3 != null || KApplication.session == null) {
                view2 = findViewById;
                str = valueOf;
            } else {
                view2 = findViewById;
                str = valueOf;
                ArrayList deserializeAttachments = DataHelper.deserializeAttachments(cursor.getBlob(cursor.getColumnIndex("attachments")), this.account_id);
                this.attachments_cache.put(Long.valueOf(j6), deserializeAttachments);
                arrayList3 = deserializeAttachments;
            }
            long parseLong = Long.parseLong(string5);
            if (string3.equals("photo")) {
                if (i3 == 0) {
                    viewHolder.tv_posts_news_text.setText(R.string.text_photo_added);
                } else {
                    viewHolder.tv_posts_news_text.setText(R.string.photo_comment_added);
                }
            } else if (string3.equals("wall_photo")) {
                viewHolder.tv_posts_news_text.setText(R.string.added_wall_photo);
            } else if (string3.equals("photo_tag")) {
                viewHolder.tv_posts_news_text.setText(R.string.text_photo_tagged);
            } else {
                String str8 = "";
                if (string3.equals("friend")) {
                    Iterator it = arrayList3.iterator();
                    arrayList = arrayList3;
                    String str9 = "";
                    while (it.hasNext()) {
                        Iterator it2 = it;
                        String str10 = string5;
                        if (((Attachment) it.next()).type.equals("friend")) {
                            if (!TextUtils.isEmpty(str8)) {
                                str8 = str8 + ", ";
                            }
                            str8 = str8 + attachment.user.first_name + " " + attachment.user.last_name;
                            str9 = str9 + attachment.user.uid + ",";
                        }
                        it = it2;
                        string5 = str10;
                    }
                    str2 = string5;
                    TextView textView2 = viewHolder.tv_posts_news_text;
                    StringBuilder sb = new StringBuilder();
                    obj = "wall_photo";
                    j = j6;
                    sb.append((Object) context.getText(R.string.text_added_friends));
                    sb.append(": ");
                    sb.append(str8);
                    textView2.setText(sb.toString());
                    newsItemTag.friends = str8;
                    newsItemTag.friend_ids = str9;
                } else {
                    arrayList = arrayList3;
                    str2 = string5;
                    obj = "wall_photo";
                    j = j6;
                    if (string3.equals("audio")) {
                        viewHolder.tv_posts_news_text.setText("");
                    } else if (string3.equals("video")) {
                        viewHolder.tv_posts_news_text.setText("");
                    } else {
                        if (!TextUtils.isEmpty(string4) && !z && !equals) {
                            SpamFinder.add(string4, parseLong);
                        }
                        if (Build.VERSION.SDK_INT == 23) {
                            string4 = string4.replace("\u00ad", "-");
                        }
                        String removeBrokenChar = Helper.removeBrokenChar(string4);
                        SpannableStringBuilder spannableStringBuilder2 = new SpannableStringBuilder(removeBrokenChar);
                        Linkify.addWebLinks(spannableStringBuilder2, equals, newsItemTag.statistics, str7, newsItemTag.ad_data, newsItemTag.track_code);
                        spannableLink(spannableStringBuilder2, this.activity, true, newsItemTag.statistics, str7, newsItemTag.ad_data, newsItemTag.track_code);
                        WallMessageActivity.createHashtagLinks(spannableStringBuilder2, this.activity, true, equals, newsItemTag.statistics, str7, newsItemTag.ad_data, newsItemTag.track_code);
                        if (this.collapse_news) {
                            j2 = parseLong;
                            obj2 = "photo_tag";
                            j3 = j5;
                            i = i3;
                            spannableStringBuilder = spannableStringBuilder2;
                            i2 = 8;
                            cropLongText(spannableStringBuilder2, view2, this.open_news, j, this, newsItemTag);
                        } else {
                            j2 = parseLong;
                            spannableStringBuilder = spannableStringBuilder2;
                            obj2 = "photo_tag";
                            j3 = j5;
                            i = i3;
                            i2 = 8;
                        }
                        viewHolder.tv_posts_news_text.setText(SmileHelper.getSmiledText(this.activity, spannableStringBuilder));
                        viewHolder.tv_posts_news_text.setMovementMethod(z ? null : LocalLinkMovementMethod.getInstance());
                        viewHolder.tv_posts_news_text.setLongClickable(false);
                        str3 = removeBrokenChar;
                        z2 = false;
                        if (viewHolder.tv_posts_news_text.getText().length() == 0) {
                            viewHolder.tv_posts_news_text.setVisibility(i2);
                        } else {
                            viewHolder.tv_posts_news_text.setVisibility(0);
                        }
                        if (j2 > 0) {
                            string = cursor.getString(cursor.getColumnIndex("first_name")) + " " + cursor.getString(cursor.getColumnIndex("last_name"));
                            str4 = "photo";
                            string2 = cursor.getString(cursor.getColumnIndex(str4));
                        } else {
                            str4 = "photo";
                            string = cursor.getString(cursor.getColumnIndex("name"));
                            string2 = cursor.getString(cursor.getColumnIndex("photo_medium"));
                        }
                        if (i == 1 || !string3.equals("post")) {
                            obj3 = str4;
                        } else {
                            obj3 = str4;
                            long j7 = cursor.getLong(cursor.getColumnIndex("from_id"));
                            if (j7 > 0) {
                                str5 = user.first_name + " " + user.last_name;
                                j4 = j7;
                                str6 = this.userCache.get(j7).photo;
                                obj4 = obj3;
                                displayProfile(viewHolder, str5, j4, this.user_photo_OnClickListener, str6);
                                displayRetweet(viewHolder, valueOf2, this.groupCache, this.userCache, newsItemTag, string6, false, null);
                                long j8 = j3;
                                viewHolder.tv_posts_news_ago.setText(Helper.getAgo(this.activity, j8));
                                if (z2) {
                                    displayCommentsCount(viewHolder, cursor.getLong(cursor.getColumnIndex("comment_count")), !this.is_clickable_count_views);
                                    newsItemTag.comment_can_post = cursor.getLong(cursor.getColumnIndex("comment_can_post")) == 1;
                                    newsItemTag.i_like = cursor.getLong(cursor.getColumnIndex("user_like")) == 1;
                                    displayLikeCount(cursor.getLong(cursor.getColumnIndex("like_count")), newsItemTag.i_like, viewHolder.likes_view, viewHolder.tv_posts_news_like_count, viewHolder.likes_heart, !this.is_clickable_count_views);
                                    displayRepostsCount(viewHolder, cursor.getLong(cursor.getColumnIndex("reposts_count")), !this.is_clickable_count_views, cursor.getLong(cursor.getColumnIndex("user_reposted")) == 1);
                                } else {
                                    hideCountViews(viewHolder);
                                }
                                String str11 = str2;
                                newsItemTag.user_id = str11;
                                newsItemTag.post_id = null;
                                newsItemTag.wall_owner_id = null;
                                newsItemTag.type = string3;
                                newsItemTag.text = str3;
                                newsItemTag._id = j;
                                ArrayList arrayList4 = new ArrayList();
                                if (!string3.equals(obj4) && !string3.equals(obj2) && !string3.equals(obj)) {
                                    newsItemTag.photo_owner_id = null;
                                    newsItemTag.photo_id = null;
                                    arrayList2 = arrayList;
                                    ViewGroup viewGroup = (ViewGroup) view.findViewById(R.id.audio_attachments);
                                    ViewGroup viewGroup2 = (ViewGroup) view.findViewById(R.id.gift_attachments);
                                    if (z) {
                                        arrayList2.clear();
                                    }
                                    viewHolder.img_posts_news_user_photo.setTag(newsItemTag);
                                    this.attachmentsHelper.displayAttachments(arrayList4, newsItemTag, viewHolder, str, str11, arrayList2, this.activity, viewHolder.photo_container, viewHolder.links_container, viewGroup, viewGroup2, null, null, str7, newsItemTag.ad_data, newsItemTag.track_code, null);
                                    newsItemTag.post_id = str;
                                    newsItemTag.wall_owner_id = str11;
                                    displayComments(view, context, cursor);
                                    long j9 = cursor.getLong(cursor.getColumnIndex("signer_id"));
                                    TextView textView3 = (TextView) view.findViewById(R.id.signer);
                                    displaySigner(j9, textView3, this.userCache, str7, newsItemTag.ad_data, newsItemTag.track_code);
                                    String string7 = cursor.getString(cursor.getColumnIndex("copyright_name"));
                                    TextView textView4 = (TextView) view.findViewById(R.id.source);
                                    displaySource(string7, textView4, context);
                                    if (!z2 && this.is_clickable_count_views) {
                                        viewHolder.likes_view.setTag(R.id.view1, newsItemTag.post_id);
                                        viewHolder.likes_view.setTag(R.id.view2, newsItemTag.wall_owner_id);
                                        viewHolder.likes_view.setTag(R.id.view3, Boolean.valueOf(newsItemTag.i_like));
                                        viewHolder.likes_view.setTag(R.id.action_audio, Boolean.valueOf(equals));
                                        viewHolder.likes_view.setOnClickListener(this.likesClickListener);
                                        viewHolder.likes_view.setOnLongClickListener(this.likesLongClickListener);
                                        viewHolder.comments_view.setTag(newsItemTag);
                                        viewHolder.comments_view.setTag(R.id.view1, newsItemTag.post_id);
                                        viewHolder.comments_view.setTag(R.id.view2, newsItemTag.wall_owner_id);
                                        viewHolder.comments_view.setTag(R.id.view3, Long.valueOf(j8));
                                        viewHolder.comments_view.setOnClickListener(this.commentsClickListener);
                                        viewHolder.reposts_view.setTag(R.id.view1, newsItemTag.post_id);
                                        viewHolder.reposts_view.setTag(R.id.view2, newsItemTag.wall_owner_id);
                                        viewHolder.reposts_view.setTag(R.id.view3, Boolean.valueOf(equals));
                                        viewHolder.reposts_view.setOnClickListener(this.repostsClickListener);
                                    }
                                    displayViews(cursor, viewHolder);
                                    displaySpam(view, viewHolder, z, this.old_style_news, textView3, textView4);
                                    textView = (TextView) view.findViewById(R.id.promo_title);
                                    if (textView != null) {
                                        if (!equals) {
                                            textView.setVisibility(8);
                                            return;
                                        }
                                        textView.setVisibility(0);
                                        String string8 = cursor.getString(cursor.getColumnIndex("ads_title"));
                                        String string9 = cursor.getString(cursor.getColumnIndex("age_restriction"));
                                        if (string9 != null) {
                                            string8 = string8 + " " + string9;
                                        }
                                        textView.setText(string8);
                                        return;
                                    }
                                    return;
                                }
                                if (arrayList.size() > 0) {
                                    arrayList2 = arrayList;
                                    if (((Attachment) arrayList2.get(0)).photo != null) {
                                        Photo photo = ((Attachment) arrayList2.get(0)).photo;
                                        newsItemTag.photo_owner_id = photo.owner_id;
                                        newsItemTag.photo_id = Long.valueOf(photo.pid);
                                    }
                                    ViewGroup viewGroup3 = (ViewGroup) view.findViewById(R.id.audio_attachments);
                                    ViewGroup viewGroup22 = (ViewGroup) view.findViewById(R.id.gift_attachments);
                                    if (z) {
                                    }
                                    viewHolder.img_posts_news_user_photo.setTag(newsItemTag);
                                    this.attachmentsHelper.displayAttachments(arrayList4, newsItemTag, viewHolder, str, str11, arrayList2, this.activity, viewHolder.photo_container, viewHolder.links_container, viewGroup3, viewGroup22, null, null, str7, newsItemTag.ad_data, newsItemTag.track_code, null);
                                    newsItemTag.post_id = str;
                                    newsItemTag.wall_owner_id = str11;
                                    displayComments(view, context, cursor);
                                    long j92 = cursor.getLong(cursor.getColumnIndex("signer_id"));
                                    TextView textView32 = (TextView) view.findViewById(R.id.signer);
                                    displaySigner(j92, textView32, this.userCache, str7, newsItemTag.ad_data, newsItemTag.track_code);
                                    String string72 = cursor.getString(cursor.getColumnIndex("copyright_name"));
                                    TextView textView42 = (TextView) view.findViewById(R.id.source);
                                    displaySource(string72, textView42, context);
                                    if (!z2) {
                                        viewHolder.likes_view.setTag(R.id.view1, newsItemTag.post_id);
                                        viewHolder.likes_view.setTag(R.id.view2, newsItemTag.wall_owner_id);
                                        viewHolder.likes_view.setTag(R.id.view3, Boolean.valueOf(newsItemTag.i_like));
                                        viewHolder.likes_view.setTag(R.id.action_audio, Boolean.valueOf(equals));
                                        viewHolder.likes_view.setOnClickListener(this.likesClickListener);
                                        viewHolder.likes_view.setOnLongClickListener(this.likesLongClickListener);
                                        viewHolder.comments_view.setTag(newsItemTag);
                                        viewHolder.comments_view.setTag(R.id.view1, newsItemTag.post_id);
                                        viewHolder.comments_view.setTag(R.id.view2, newsItemTag.wall_owner_id);
                                        viewHolder.comments_view.setTag(R.id.view3, Long.valueOf(j8));
                                        viewHolder.comments_view.setOnClickListener(this.commentsClickListener);
                                        viewHolder.reposts_view.setTag(R.id.view1, newsItemTag.post_id);
                                        viewHolder.reposts_view.setTag(R.id.view2, newsItemTag.wall_owner_id);
                                        viewHolder.reposts_view.setTag(R.id.view3, Boolean.valueOf(equals));
                                        viewHolder.reposts_view.setOnClickListener(this.repostsClickListener);
                                    }
                                    displayViews(cursor, viewHolder);
                                    displaySpam(view, viewHolder, z, this.old_style_news, textView32, textView42);
                                    textView = (TextView) view.findViewById(R.id.promo_title);
                                    if (textView != null) {
                                    }
                                }
                                arrayList2 = arrayList;
                                ViewGroup viewGroup32 = (ViewGroup) view.findViewById(R.id.audio_attachments);
                                ViewGroup viewGroup222 = (ViewGroup) view.findViewById(R.id.gift_attachments);
                                if (z) {
                                }
                                viewHolder.img_posts_news_user_photo.setTag(newsItemTag);
                                this.attachmentsHelper.displayAttachments(arrayList4, newsItemTag, viewHolder, str, str11, arrayList2, this.activity, viewHolder.photo_container, viewHolder.links_container, viewGroup32, viewGroup222, null, null, str7, newsItemTag.ad_data, newsItemTag.track_code, null);
                                newsItemTag.post_id = str;
                                newsItemTag.wall_owner_id = str11;
                                displayComments(view, context, cursor);
                                long j922 = cursor.getLong(cursor.getColumnIndex("signer_id"));
                                TextView textView322 = (TextView) view.findViewById(R.id.signer);
                                displaySigner(j922, textView322, this.userCache, str7, newsItemTag.ad_data, newsItemTag.track_code);
                                String string722 = cursor.getString(cursor.getColumnIndex("copyright_name"));
                                TextView textView422 = (TextView) view.findViewById(R.id.source);
                                displaySource(string722, textView422, context);
                                if (!z2) {
                                }
                                displayViews(cursor, viewHolder);
                                displaySpam(view, viewHolder, z, this.old_style_news, textView322, textView422);
                                textView = (TextView) view.findViewById(R.id.promo_title);
                                if (textView != null) {
                                }
                            }
                        }
                        str5 = string;
                        str6 = string2;
                        j4 = j2;
                        obj4 = obj3;
                        displayProfile(viewHolder, str5, j4, this.user_photo_OnClickListener, str6);
                        displayRetweet(viewHolder, valueOf2, this.groupCache, this.userCache, newsItemTag, string6, false, null);
                        long j82 = j3;
                        viewHolder.tv_posts_news_ago.setText(Helper.getAgo(this.activity, j82));
                        if (z2) {
                        }
                        String str112 = str2;
                        newsItemTag.user_id = str112;
                        newsItemTag.post_id = null;
                        newsItemTag.wall_owner_id = null;
                        newsItemTag.type = string3;
                        newsItemTag.text = str3;
                        newsItemTag._id = j;
                        ArrayList arrayList42 = new ArrayList();
                        if (!string3.equals(obj4)) {
                            newsItemTag.photo_owner_id = null;
                            newsItemTag.photo_id = null;
                            arrayList2 = arrayList;
                            ViewGroup viewGroup322 = (ViewGroup) view.findViewById(R.id.audio_attachments);
                            ViewGroup viewGroup2222 = (ViewGroup) view.findViewById(R.id.gift_attachments);
                            if (z) {
                            }
                            viewHolder.img_posts_news_user_photo.setTag(newsItemTag);
                            this.attachmentsHelper.displayAttachments(arrayList42, newsItemTag, viewHolder, str, str112, arrayList2, this.activity, viewHolder.photo_container, viewHolder.links_container, viewGroup322, viewGroup2222, null, null, str7, newsItemTag.ad_data, newsItemTag.track_code, null);
                            newsItemTag.post_id = str;
                            newsItemTag.wall_owner_id = str112;
                            displayComments(view, context, cursor);
                            long j9222 = cursor.getLong(cursor.getColumnIndex("signer_id"));
                            TextView textView3222 = (TextView) view.findViewById(R.id.signer);
                            displaySigner(j9222, textView3222, this.userCache, str7, newsItemTag.ad_data, newsItemTag.track_code);
                            String string7222 = cursor.getString(cursor.getColumnIndex("copyright_name"));
                            TextView textView4222 = (TextView) view.findViewById(R.id.source);
                            displaySource(string7222, textView4222, context);
                            if (!z2) {
                            }
                            displayViews(cursor, viewHolder);
                            displaySpam(view, viewHolder, z, this.old_style_news, textView3222, textView4222);
                            textView = (TextView) view.findViewById(R.id.promo_title);
                            if (textView != null) {
                            }
                        }
                        if (arrayList.size() > 0) {
                        }
                        arrayList2 = arrayList;
                        ViewGroup viewGroup3222 = (ViewGroup) view.findViewById(R.id.audio_attachments);
                        ViewGroup viewGroup22222 = (ViewGroup) view.findViewById(R.id.gift_attachments);
                        if (z) {
                        }
                        viewHolder.img_posts_news_user_photo.setTag(newsItemTag);
                        this.attachmentsHelper.displayAttachments(arrayList42, newsItemTag, viewHolder, str, str112, arrayList2, this.activity, viewHolder.photo_container, viewHolder.links_container, viewGroup3222, viewGroup22222, null, null, str7, newsItemTag.ad_data, newsItemTag.track_code, null);
                        newsItemTag.post_id = str;
                        newsItemTag.wall_owner_id = str112;
                        displayComments(view, context, cursor);
                        long j92222 = cursor.getLong(cursor.getColumnIndex("signer_id"));
                        TextView textView32222 = (TextView) view.findViewById(R.id.signer);
                        displaySigner(j92222, textView32222, this.userCache, str7, newsItemTag.ad_data, newsItemTag.track_code);
                        String string72222 = cursor.getString(cursor.getColumnIndex("copyright_name"));
                        TextView textView42222 = (TextView) view.findViewById(R.id.source);
                        displaySource(string72222, textView42222, context);
                        if (!z2) {
                        }
                        displayViews(cursor, viewHolder);
                        displaySpam(view, viewHolder, z, this.old_style_news, textView32222, textView42222);
                        textView = (TextView) view.findViewById(R.id.promo_title);
                        if (textView != null) {
                        }
                    }
                }
                str3 = string4;
                j2 = parseLong;
                obj2 = "photo_tag";
                j3 = j5;
                i = i3;
                z2 = true;
                i2 = 8;
                if (viewHolder.tv_posts_news_text.getText().length() == 0) {
                }
                if (j2 > 0) {
                }
                if (i == 1) {
                }
                obj3 = str4;
                str5 = string;
                str6 = string2;
                j4 = j2;
                obj4 = obj3;
                displayProfile(viewHolder, str5, j4, this.user_photo_OnClickListener, str6);
                displayRetweet(viewHolder, valueOf2, this.groupCache, this.userCache, newsItemTag, string6, false, null);
                long j822 = j3;
                viewHolder.tv_posts_news_ago.setText(Helper.getAgo(this.activity, j822));
                if (z2) {
                }
                String str1122 = str2;
                newsItemTag.user_id = str1122;
                newsItemTag.post_id = null;
                newsItemTag.wall_owner_id = null;
                newsItemTag.type = string3;
                newsItemTag.text = str3;
                newsItemTag._id = j;
                ArrayList arrayList422 = new ArrayList();
                if (!string3.equals(obj4)) {
                }
                if (arrayList.size() > 0) {
                }
                arrayList2 = arrayList;
                ViewGroup viewGroup32222 = (ViewGroup) view.findViewById(R.id.audio_attachments);
                ViewGroup viewGroup222222 = (ViewGroup) view.findViewById(R.id.gift_attachments);
                if (z) {
                }
                viewHolder.img_posts_news_user_photo.setTag(newsItemTag);
                this.attachmentsHelper.displayAttachments(arrayList422, newsItemTag, viewHolder, str, str1122, arrayList2, this.activity, viewHolder.photo_container, viewHolder.links_container, viewGroup32222, viewGroup222222, null, null, str7, newsItemTag.ad_data, newsItemTag.track_code, null);
                newsItemTag.post_id = str;
                newsItemTag.wall_owner_id = str1122;
                displayComments(view, context, cursor);
                long j922222 = cursor.getLong(cursor.getColumnIndex("signer_id"));
                TextView textView322222 = (TextView) view.findViewById(R.id.signer);
                displaySigner(j922222, textView322222, this.userCache, str7, newsItemTag.ad_data, newsItemTag.track_code);
                String string722222 = cursor.getString(cursor.getColumnIndex("copyright_name"));
                TextView textView422222 = (TextView) view.findViewById(R.id.source);
                displaySource(string722222, textView422222, context);
                if (!z2) {
                }
                displayViews(cursor, viewHolder);
                displaySpam(view, viewHolder, z, this.old_style_news, textView322222, textView422222);
                textView = (TextView) view.findViewById(R.id.promo_title);
                if (textView != null) {
                }
            }
            str3 = string4;
            arrayList = arrayList3;
            str2 = string5;
            obj2 = "photo_tag";
            obj = "wall_photo";
            j = j6;
            j3 = j5;
            z2 = true;
            i2 = 8;
            j2 = parseLong;
            i = i3;
            if (viewHolder.tv_posts_news_text.getText().length() == 0) {
            }
            if (j2 > 0) {
            }
            if (i == 1) {
            }
            obj3 = str4;
            str5 = string;
            str6 = string2;
            j4 = j2;
            obj4 = obj3;
            displayProfile(viewHolder, str5, j4, this.user_photo_OnClickListener, str6);
            displayRetweet(viewHolder, valueOf2, this.groupCache, this.userCache, newsItemTag, string6, false, null);
            long j8222 = j3;
            viewHolder.tv_posts_news_ago.setText(Helper.getAgo(this.activity, j8222));
            if (z2) {
            }
            String str11222 = str2;
            newsItemTag.user_id = str11222;
            newsItemTag.post_id = null;
            newsItemTag.wall_owner_id = null;
            newsItemTag.type = string3;
            newsItemTag.text = str3;
            newsItemTag._id = j;
            ArrayList arrayList4222 = new ArrayList();
            if (!string3.equals(obj4)) {
            }
            if (arrayList.size() > 0) {
            }
            arrayList2 = arrayList;
            ViewGroup viewGroup322222 = (ViewGroup) view.findViewById(R.id.audio_attachments);
            ViewGroup viewGroup2222222 = (ViewGroup) view.findViewById(R.id.gift_attachments);
            if (z) {
            }
            viewHolder.img_posts_news_user_photo.setTag(newsItemTag);
            this.attachmentsHelper.displayAttachments(arrayList4222, newsItemTag, viewHolder, str, str11222, arrayList2, this.activity, viewHolder.photo_container, viewHolder.links_container, viewGroup322222, viewGroup2222222, null, null, str7, newsItemTag.ad_data, newsItemTag.track_code, null);
            newsItemTag.post_id = str;
            newsItemTag.wall_owner_id = str11222;
            displayComments(view, context, cursor);
            long j9222222 = cursor.getLong(cursor.getColumnIndex("signer_id"));
            TextView textView3222222 = (TextView) view.findViewById(R.id.signer);
            displaySigner(j9222222, textView3222222, this.userCache, str7, newsItemTag.ad_data, newsItemTag.track_code);
            String string7222222 = cursor.getString(cursor.getColumnIndex("copyright_name"));
            TextView textView4222222 = (TextView) view.findViewById(R.id.source);
            displaySource(string7222222, textView4222222, context);
            if (!z2) {
            }
            displayViews(cursor, viewHolder);
            displaySpam(view, viewHolder, z, this.old_style_news, textView3222222, textView4222222);
            textView = (TextView) view.findViewById(R.id.promo_title);
            if (textView != null) {
            }
        } catch (Throwable th) {
            Helper.reportError(th);
            th.printStackTrace();
        }
    }

    public void destroy() {
        this.attachmentsHelper.destroy();
        this.attachmentsHelper = null;
        this.activity = null;
    }

    @Override
    public int getCount() {
        return super.getCount();
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        try {
            return super.getView(i, view, viewGroup);
        } catch (Throwable th) {
            Helper.reportError(th);
            throw new RuntimeException(th);
        }
    }

    @Override
    public View newView(Context context, Cursor cursor, ViewGroup viewGroup) {
        View findViewById;
        View createView = createView(context, viewGroup, this.big_photos, this.old_style_news ? R.layout.posts_news_item2 : R.layout.posts_news_item);
        if (!this.old_style_news && this.card_style_news && (findViewById = createView.findViewById(R.id.root_news_item)) != null) {
            findViewById.setBackgroundResource(getCardBgByTheme());
        }
        ((ViewGroup) createView).setDescendantFocusability(393216);
        ((ScaleTextView) ((NewsItemTag) createView.getTag()).view_holder.tv_posts_news_text).dontConsumeNonUrlClicks = true;
        return createView;
    }

    @Override
    public void notifyDataSetChanged() {
        this.attachments_cache.clear();
        super.notifyDataSetChanged();
    }
}