盛康基办.apk(点击下载) / ArticleViewer.java


package im.guobwnxjuc.ui;

import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
import android.animation.IntEvaluator;
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.database.DataSetObserver;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.SurfaceTexture;
import android.graphics.Typeface;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.text.Layout;
import android.text.Selection;
import android.text.Spannable;
import android.text.SpannableStringBuilder;
import android.text.Spanned;
import android.text.StaticLayout;
import android.text.TextPaint;
import android.text.TextUtils;
import android.text.method.LinkMovementMethod;
import android.text.style.MetricAffectingSpan;
import android.text.style.URLSpan;
import android.util.LongSparseArray;
import android.util.Property;
import android.util.SparseArray;
import android.view.DisplayCutout;
import android.view.GestureDetector;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.TextureView;
import android.view.VelocityTracker;
import android.view.View;
import android.view.ViewConfiguration;
import android.view.ViewGroup;
import android.view.WindowInsets;
import android.view.WindowManager;
import android.view.accessibility.AccessibilityNodeInfo;
import android.view.animation.DecelerateInterpolator;
import android.webkit.CookieManager;
import android.webkit.JavascriptInterface;
import android.webkit.WebChromeClient;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.FrameLayout;
import android.widget.HorizontalScrollView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.TextView;
import androidx.core.content.FileProvider;
import androidx.core.internal.view.SupportMenu;
import androidx.recyclerview.widget.DefaultItemAnimator;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.GridLayoutManagerFixed;
import androidx.recyclerview.widget.ItemTouchHelper;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.viewpager.widget.PagerAdapter;
import androidx.viewpager.widget.ViewPager;
import com.bjz.comm.net.premission.PermissionUtils;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.ui.AspectRatioFrameLayout;
import im.guobwnxjuc.messenger.AndroidUtilities;
import im.guobwnxjuc.messenger.ApplicationLoader;
import im.guobwnxjuc.messenger.DownloadController;
import im.guobwnxjuc.messenger.Emoji;
import im.guobwnxjuc.messenger.FileLoader;
import im.guobwnxjuc.messenger.FileLog;
import im.guobwnxjuc.messenger.ImageLoader;
import im.guobwnxjuc.messenger.ImageLocation;
import im.guobwnxjuc.messenger.ImageReceiver;
import im.guobwnxjuc.messenger.LocaleController;
import im.guobwnxjuc.messenger.MediaController;
import im.guobwnxjuc.messenger.MessageObject;
import im.guobwnxjuc.messenger.MessagesController;
import im.guobwnxjuc.messenger.MessagesStorage;
import im.guobwnxjuc.messenger.NotificationCenter;
import im.guobwnxjuc.messenger.R;
import im.guobwnxjuc.messenger.UserConfig;
import im.guobwnxjuc.messenger.Utilities;
import im.guobwnxjuc.messenger.WebFile;
import im.guobwnxjuc.messenger.browser.Browser;
import im.guobwnxjuc.tgnet.ConnectionsManager;
import im.guobwnxjuc.tgnet.RequestDelegate;
import im.guobwnxjuc.tgnet.TLObject;
import im.guobwnxjuc.tgnet.TLRPC;
import im.guobwnxjuc.ui.ArticleViewer;
import im.guobwnxjuc.ui.actionbar.ActionBar;
import im.guobwnxjuc.ui.actionbar.ActionBarMenu;
import im.guobwnxjuc.ui.actionbar.ActionBarMenuItem;
import im.guobwnxjuc.ui.actionbar.ActionBarPopupWindow;
import im.guobwnxjuc.ui.actionbar.AlertDialog;
import im.guobwnxjuc.ui.actionbar.BackDrawable;
import im.guobwnxjuc.ui.actionbar.BaseFragment;
import im.guobwnxjuc.ui.actionbar.BottomSheet;
import im.guobwnxjuc.ui.actionbar.SimpleTextView;
import im.guobwnxjuc.ui.actionbar.Theme;
import im.guobwnxjuc.ui.components.AlertsCreator;
import im.guobwnxjuc.ui.components.AnchorSpan;
import im.guobwnxjuc.ui.components.AnimatedArrowDrawable;
import im.guobwnxjuc.ui.components.AnimatedFileDrawable;
import im.guobwnxjuc.ui.components.AnimationProperties;
import im.guobwnxjuc.ui.components.AvatarDrawable;
import im.guobwnxjuc.ui.components.ClippingImageView;
import im.guobwnxjuc.ui.components.CombinedDrawable;
import im.guobwnxjuc.ui.components.ContextProgressView;
import im.guobwnxjuc.ui.components.GroupedPhotosListView;
import im.guobwnxjuc.ui.components.LayoutHelper;
import im.guobwnxjuc.ui.components.LineProgressView;
import im.guobwnxjuc.ui.components.LinkPath;
import im.guobwnxjuc.ui.components.RadialProgress2;
import im.guobwnxjuc.ui.components.RecyclerListView;
import im.guobwnxjuc.ui.components.Scroller;
import im.guobwnxjuc.ui.components.SeekBar;
import im.guobwnxjuc.ui.components.ShareAlert;
import im.guobwnxjuc.ui.components.StaticLayoutEx;
import im.guobwnxjuc.ui.components.TableLayout;
import im.guobwnxjuc.ui.components.TextPaintImageReceiverSpan;
import im.guobwnxjuc.ui.components.TextPaintMarkSpan;
import im.guobwnxjuc.ui.components.TextPaintSpan;
import im.guobwnxjuc.ui.components.TextPaintUrlSpan;
import im.guobwnxjuc.ui.components.TextPaintWebpageUrlSpan;
import im.guobwnxjuc.ui.components.TypefaceSpan;
import im.guobwnxjuc.ui.components.VideoPlayer;
import im.guobwnxjuc.ui.components.WebPlayerView;
import im.guobwnxjuc.ui.components.toast.ToastUtils;
import java.io.File;
import java.lang.reflect.Array;
import java.net.URLDecoder;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import org.json.JSONObject;

public class ArticleViewer implements NotificationCenter.NotificationCenterDelegate, GestureDetector.OnGestureListener, GestureDetector.OnDoubleTapListener {
    public static final Property<WindowView, Float> ARTICLE_VIEWER_INNER_TRANSLATION_X = new AnimationProperties.FloatProperty<WindowView>("innerTranslationX") {
        /* class im.guobwnxjuc.ui.ArticleViewer.AnonymousClass1 */

        public void setValue(WindowView windowView, float f) {
            windowView.setInnerTranslationX(f);
        }

        public Float get(WindowView windowView) {
            return Float.valueOf(windowView.getInnerTranslationX());
        }
    };
    private static volatile ArticleViewer Instance = null;
    private static final int TEXT_FLAG_ITALIC = 2;
    private static final int TEXT_FLAG_MARKED = 64;
    private static final int TEXT_FLAG_MEDIUM = 1;
    private static final int TEXT_FLAG_MONO = 4;
    private static final int TEXT_FLAG_REGULAR = 0;
    private static final int TEXT_FLAG_STRIKE = 32;
    private static final int TEXT_FLAG_SUB = 128;
    private static final int TEXT_FLAG_SUP = 256;
    private static final int TEXT_FLAG_UNDERLINE = 16;
    private static final int TEXT_FLAG_URL = 8;
    private static final int TEXT_FLAG_WEBPAGE_URL = 512;
    private static TextPaint audioTimePaint = new TextPaint(1);
    private static SparseArray<TextPaint> authorTextPaints = new SparseArray<>();
    private static TextPaint channelNamePaint = null;
    private static Paint colorPaint = null;
    private static DecelerateInterpolator decelerateInterpolator = null;
    private static SparseArray<TextPaint> detailsTextPaints = new SparseArray<>();
    private static Paint dividerPaint = null;
    private static Paint dotsPaint = null;
    private static TextPaint embedPostAuthorPaint = null;
    private static SparseArray<TextPaint> embedPostCaptionTextPaints = new SparseArray<>();
    private static TextPaint embedPostDatePaint = null;
    private static SparseArray<TextPaint> embedPostTextPaints = new SparseArray<>();
    private static TextPaint errorTextPaint = null;
    private static SparseArray<TextPaint> footerTextPaints = new SparseArray<>();
    private static final int gallery_menu_openin = 3;
    private static final int gallery_menu_save = 1;
    private static final int gallery_menu_share = 2;
    private static SparseArray<TextPaint> headerTextPaints = new SparseArray<>();
    private static SparseArray<TextPaint> kickerTextPaints = new SparseArray<>();
    private static TextPaint listTextNumPaint;
    private static SparseArray<TextPaint> listTextPaints = new SparseArray<>();
    private static TextPaint listTextPointerPaint;
    private static SparseArray<TextPaint> mediaCaptionTextPaints = new SparseArray<>();
    private static SparseArray<TextPaint> mediaCreditTextPaints = new SparseArray<>();
    private static SparseArray<TextPaint> paragraphTextPaints = new SparseArray<>();
    private static Paint photoBackgroundPaint;
    private static SparseArray<TextPaint> photoCaptionTextPaints = new SparseArray<>();
    private static SparseArray<TextPaint> photoCreditTextPaints = new SparseArray<>();
    private static Paint preformattedBackgroundPaint;
    private static SparseArray<TextPaint> preformattedTextPaints = new SparseArray<>();
    private static Drawable[] progressDrawables;
    private static Paint progressPaint;
    private static Paint quoteLinePaint;
    private static SparseArray<TextPaint> quoteTextPaints = new SparseArray<>();
    private static TextPaint relatedArticleHeaderPaint;
    private static TextPaint relatedArticleTextPaint;
    private static SparseArray<TextPaint> relatedArticleTextPaints = new SparseArray<>();
    private static Paint selectorPaint;
    private static SparseArray<TextPaint> subheaderTextPaints = new SparseArray<>();
    private static SparseArray<TextPaint> subtitleTextPaints = new SparseArray<>();
    private static Paint tableHalfLinePaint;
    private static Paint tableHeaderPaint;
    private static Paint tableLinePaint;
    private static Paint tableStripPaint;
    private static SparseArray<TextPaint> tableTextPaints = new SparseArray<>();
    private static SparseArray<TextPaint> titleTextPaints = new SparseArray<>();
    private static Paint urlPaint;
    private static Paint webpageMarkPaint;
    private static Paint webpageUrlPaint;
    private ActionBar actionBar;
    private WebpageAdapter[] adapter;
    private int anchorsOffsetMeasuredWidth;
    private float animateToScale;
    private float animateToX;
    private float animateToY;
    private ClippingImageView animatingImageView;
    private Runnable animationEndRunnable;
    private int animationInProgress;
    private long animationStartTime;
    private float animationValue;
    private float[][] animationValues = ((float[][]) Array.newInstance(float.class, 2, 10));
    private AspectRatioFrameLayout aspectRatioFrameLayout;
    private boolean attachedToWindow;
    private ImageView backButton;
    private BackDrawable backDrawable;
    private Paint backgroundPaint;
    private Paint blackPaint = new Paint();
    private FrameLayout bottomLayout;
    private boolean canDragDown = true;
    private boolean canZoom = true;
    private TextView captionTextView;
    private TextView captionTextViewNext;
    private ImageReceiver centerImage = new ImageReceiver();
    private boolean changingPage;
    private TLRPC.TL_pageBlockChannel channelBlock;
    private boolean checkingForLongPress = false;
    private boolean collapsed;
    private ColorCell[] colorCells = new ColorCell[3];
    private FrameLayout containerView;
    private int[] coords = new int[2];
    private Drawable copyBackgroundDrawable;
    private ArrayList<BlockEmbedCell> createdWebViews = new ArrayList<>();
    private int currentAccount;
    private AnimatorSet currentActionBarAnimation;
    private AnimatedFileDrawable currentAnimation;
    private String[] currentFileNames = new String[3];
    private int currentHeaderHeight;
    private int currentIndex;
    private TLRPC.PageBlock currentMedia;
    private TLRPC.WebPage currentPage;
    private PlaceProviderObject currentPlaceObject;
    private WebPlayerView currentPlayingVideo;
    private int currentRotation;
    private ImageReceiver.BitmapHolder currentThumb;
    private View customView;
    private WebChromeClient.CustomViewCallback customViewCallback;
    private TextView deleteView;
    private boolean disableShowCheck;
    private boolean discardTap;
    private boolean dontResetZoomOnFirstLayout;
    private boolean doubleTap;
    private float dragY;
    private boolean draggingDown;
    private boolean drawBlockSelection;
    private FontCell[] fontCells = new FontCell[2];
    private final int fontSizeCount = 5;
    private AspectRatioFrameLayout fullscreenAspectRatioView;
    private TextureView fullscreenTextureView;
    private FrameLayout fullscreenVideoContainer;
    private WebPlayerView fullscreenedVideo;
    private GestureDetector gestureDetector;
    private GroupedPhotosListView groupedPhotosListView;
    boolean hasCutout;
    private Paint headerPaint = new Paint();
    private Paint headerProgressPaint = new Paint();
    private FrameLayout headerView;
    private PlaceProviderObject hideAfterAnimation;
    private AnimatorSet imageMoveAnimation;
    private ArrayList<TLRPC.PageBlock> imagesArr = new ArrayList<>();
    private DecelerateInterpolator interpolator = new DecelerateInterpolator(1.5f);
    private boolean invalidCoords;
    private boolean isActionBarVisible = true;
    private boolean isPhotoVisible;
    private boolean isPlaying;
    private boolean isRtl;
    private boolean isVisible;
    private int lastBlockNum = 1;
    private Object lastInsets;
    private int lastReqId;
    private Drawable layerShadowDrawable;
    private LinearLayoutManager[] layoutManager;
    private ImageReceiver leftImage = new ImageReceiver();
    private Runnable lineProgressTickRunnable;
    private LineProgressView lineProgressView;
    private BottomSheet linkSheet;
    private RecyclerListView[] listView;
    private TLRPC.Chat loadedChannel;
    private boolean loadingChannel;
    private float maxX;
    private float maxY;
    private ActionBarMenuItem menuItem;
    private float minX;
    private float minY;
    private float moveStartX;
    private float moveStartY;
    private boolean moving;
    private boolean nightModeEnabled;
    private FrameLayout nightModeHintView;
    private ImageView nightModeImageView;
    private int openUrlReqId;
    private AnimatorSet pageSwitchAnimation;
    private ArrayList<TLRPC.WebPage> pagesStack = new ArrayList<>();
    private Activity parentActivity;
    private BaseFragment parentFragment;
    private CheckForLongPress pendingCheckForLongPress = null;
    private CheckForTap pendingCheckForTap = null;
    private Runnable photoAnimationEndRunnable;
    private int photoAnimationInProgress;
    private PhotoBackgroundDrawable photoBackgroundDrawable = new PhotoBackgroundDrawable(-16777216);
    private View photoContainerBackground;
    private FrameLayoutDrawer photoContainerView;
    private long photoTransitionAnimationStartTime;
    private float pinchCenterX;
    private float pinchCenterY;
    private float pinchStartDistance;
    private float pinchStartScale = 1.0f;
    private float pinchStartX;
    private float pinchStartY;
    private ActionBarPopupWindow.ActionBarPopupWindowLayout popupLayout;
    private Rect popupRect;
    private ActionBarPopupWindow popupWindow;
    private int pressCount = 0;
    private int pressedLayoutY;
    private TextPaintUrlSpan pressedLink;
    private DrawingText pressedLinkOwnerLayout;
    private View pressedLinkOwnerView;
    private int previewsReqId;
    private ContextProgressView progressView;
    private AnimatorSet progressViewAnimation;
    private RadialProgressView[] radialProgressViews = new RadialProgressView[3];
    private ImageReceiver rightImage = new ImageReceiver();
    private float scale = 1.0f;
    private Paint scrimPaint;
    private Scroller scroller;
    private int selectedColor = 0;
    private int selectedFont = 0;
    private int selectedFontSize = 2;
    private ActionBarMenuItem settingsButton;
    private ImageView shareButton;
    private FrameLayout shareContainer;
    private PlaceProviderObject showAfterAnimation;
    private Drawable slideDotBigDrawable;
    private Drawable slideDotDrawable;
    private Paint statusBarPaint = new Paint();
    private int switchImageAfterAnimation;
    private boolean textureUploaded;
    private SimpleTextView titleTextView;
    private long transitionAnimationStartTime;
    private float translationX;
    private float translationY;
    private Runnable updateProgressRunnable = new Runnable() {
        /* class im.guobwnxjuc.ui.ArticleViewer.AnonymousClass18 */

        public void run() {
            if (!(ArticleViewer.this.videoPlayer == null || ArticleViewer.this.videoPlayerSeekbar == null || ArticleViewer.this.videoPlayerSeekbar.isDragging())) {
                ArticleViewer.this.videoPlayerSeekbar.setProgress(((float) ArticleViewer.this.videoPlayer.getCurrentPosition()) / ((float) ArticleViewer.this.videoPlayer.getDuration()));
                ArticleViewer.this.videoPlayerControlFrameLayout.invalidate();
                ArticleViewer.this.updateVideoPlayerTime();
            }
            if (ArticleViewer.this.isPlaying) {
                AndroidUtilities.runOnUIThread(ArticleViewer.this.updateProgressRunnable, 100);
            }
        }
    };
    private LinkPath urlPath = new LinkPath();
    private VelocityTracker velocityTracker;
    private float videoCrossfadeAlpha;
    private long videoCrossfadeAlphaLastTime;
    private boolean videoCrossfadeStarted;
    private ImageView videoPlayButton;
    private VideoPlayer videoPlayer;
    private FrameLayout videoPlayerControlFrameLayout;
    private SeekBar videoPlayerSeekbar;
    private TextView videoPlayerTime;
    private TextureView videoTextureView;
    private Dialog visibleDialog;
    private boolean wasLayout;
    private WindowManager.LayoutParams windowLayoutParams;
    private WindowView windowView;
    private boolean zoomAnimation;
    private boolean zooming;

    public static class PlaceProviderObject {
        public int clipBottomAddition;
        public int clipTopAddition;
        public ImageReceiver imageReceiver;
        public int index;
        public View parentView;
        public int radius;
        public float scale = 1.0f;
        public int size;
        public ImageReceiver.BitmapHolder thumb;
        public int viewX;
        public int viewY;
    }

    static /* synthetic */ boolean lambda$setParentActivity$12(View view, MotionEvent motionEvent) {
        return true;
    }

    public boolean onDoubleTapEvent(MotionEvent motionEvent) {
        return false;
    }

    public boolean onDown(MotionEvent motionEvent) {
        return false;
    }

    public void onLongPress(MotionEvent motionEvent) {
    }

    public boolean onScroll(MotionEvent motionEvent, MotionEvent motionEvent2, float f, float f2) {
        return false;
    }

    public void onShowPress(MotionEvent motionEvent) {
    }

    public boolean onSingleTapUp(MotionEvent motionEvent) {
        return false;
    }

    static /* synthetic */ int access$1104(ArticleViewer articleViewer) {
        int i = articleViewer.pressCount + 1;
        articleViewer.pressCount = i;
        return i;
    }

    static /* synthetic */ int access$13108(ArticleViewer articleViewer) {
        int i = articleViewer.lastBlockNum;
        articleViewer.lastBlockNum = i + 1;
        return i;
    }

    public static ArticleViewer getInstance() {
        ArticleViewer articleViewer = Instance;
        if (articleViewer == null) {
            synchronized (ArticleViewer.class) {
                articleViewer = Instance;
                if (articleViewer == null) {
                    articleViewer = new ArticleViewer();
                    Instance = articleViewer;
                }
            }
        }
        return articleViewer;
    }

    public static boolean hasInstance() {
        return Instance != null;
    }

    /* access modifiers changed from: private */
    public class TL_pageBlockRelatedArticlesChild extends TLRPC.PageBlock {
        private int num;
        private TLRPC.TL_pageBlockRelatedArticles parent;

        private TL_pageBlockRelatedArticlesChild() {
        }
    }

    /* access modifiers changed from: private */
    public class TL_pageBlockRelatedArticlesShadow extends TLRPC.PageBlock {
        private TLRPC.TL_pageBlockRelatedArticles parent;

        private TL_pageBlockRelatedArticlesShadow() {
        }
    }

    /* access modifiers changed from: private */
    public class TL_pageBlockDetailsChild extends TLRPC.PageBlock {
        private TLRPC.PageBlock block;
        private TLRPC.PageBlock parent;

        private TL_pageBlockDetailsChild() {
        }
    }

    /* access modifiers changed from: private */
    public class TL_pageBlockDetailsBottom extends TLRPC.PageBlock {
        private TLRPC.TL_pageBlockDetails parent;

        private TL_pageBlockDetailsBottom() {
        }
    }

    /* access modifiers changed from: private */
    public class TL_pageBlockListParent extends TLRPC.PageBlock {
        private ArrayList<TL_pageBlockListItem> items;
        private int lastFontSize;
        private int lastMaxNumCalcWidth;
        private int level;
        private int maxNumWidth;
        private TLRPC.TL_pageBlockList pageBlockList;

        private TL_pageBlockListParent() {
            this.items = new ArrayList<>();
        }
    }

    /* access modifiers changed from: private */
    public class TL_pageBlockListItem extends TLRPC.PageBlock {
        private TLRPC.PageBlock blockItem;
        private int index;
        private String num;
        private DrawingText numLayout;
        private TL_pageBlockListParent parent;
        private TLRPC.RichText textItem;

        private TL_pageBlockListItem() {
            this.index = Integer.MAX_VALUE;
        }
    }

    /* access modifiers changed from: private */
    public class TL_pageBlockOrderedListParent extends TLRPC.PageBlock {
        private ArrayList<TL_pageBlockOrderedListItem> items;
        private int lastFontSize;
        private int lastMaxNumCalcWidth;
        private int level;
        private int maxNumWidth;
        private TLRPC.TL_pageBlockOrderedList pageBlockOrderedList;

        private TL_pageBlockOrderedListParent() {
            this.items = new ArrayList<>();
        }
    }

    /* access modifiers changed from: private */
    public class TL_pageBlockOrderedListItem extends TLRPC.PageBlock {
        private TLRPC.PageBlock blockItem;
        private int index;
        private String num;
        private DrawingText numLayout;
        private TL_pageBlockOrderedListParent parent;
        private TLRPC.RichText textItem;

        private TL_pageBlockOrderedListItem() {
            this.index = Integer.MAX_VALUE;
        }
    }

    /* access modifiers changed from: private */
    public class TL_pageBlockEmbedPostCaption extends TLRPC.TL_pageBlockEmbedPost {
        private TLRPC.TL_pageBlockEmbedPost parent;

        private TL_pageBlockEmbedPostCaption() {
        }
    }

    public class DrawingText {
        public LinkPath markPath;
        public StaticLayout textLayout;
        public LinkPath textPath;

        public DrawingText() {
        }

        public void draw(Canvas canvas) {
            LinkPath linkPath = this.textPath;
            if (linkPath != null) {
                canvas.drawPath(linkPath, ArticleViewer.webpageUrlPaint);
            }
            LinkPath linkPath2 = this.markPath;
            if (linkPath2 != null) {
                canvas.drawPath(linkPath2, ArticleViewer.webpageMarkPaint);
            }
            ArticleViewer.this.drawLayoutLink(canvas, this);
            this.textLayout.draw(canvas);
        }

        public CharSequence getText() {
            return this.textLayout.getText();
        }

        public int getLineCount() {
            return this.textLayout.getLineCount();
        }

        public int getLineAscent(int i) {
            return this.textLayout.getLineAscent(i);
        }

        public float getLineLeft(int i) {
            return this.textLayout.getLineLeft(i);
        }

        public float getLineWidth(int i) {
            return this.textLayout.getLineWidth(i);
        }

        public int getHeight() {
            return this.textLayout.getHeight();
        }

        public int getWidth() {
            return this.textLayout.getWidth();
        }
    }

    /* access modifiers changed from: private */
    public class SizeChooseView extends View {
        private int circleSize;
        private int gapSize;
        private int lineSize;
        private boolean moving;
        private Paint paint = new Paint(1);
        private int sideSide;
        private boolean startMoving;
        private int startMovingQuality;
        private float startX;

        public SizeChooseView(Context context) {
            super(context);
        }

        public boolean onTouchEvent(MotionEvent motionEvent) {
            float x = motionEvent.getX();
            int i = 0;
            boolean z = false;
            if (motionEvent.getAction() == 0) {
                getParent().requestDisallowInterceptTouchEvent(true);
                int i2 = 0;
                while (true) {
                    if (i2 >= 5) {
                        break;
                    }
                    int i3 = this.sideSide;
                    int i4 = this.lineSize + (this.gapSize * 2);
                    int i5 = this.circleSize;
                    int i6 = i3 + ((i4 + i5) * i2) + (i5 / 2);
                    if (x <= ((float) (i6 - AndroidUtilities.dp(15.0f))) || x >= ((float) (i6 + AndroidUtilities.dp(15.0f)))) {
                        i2++;
                    } else {
                        if (i2 == ArticleViewer.this.selectedFontSize) {
                            z = true;
                        }
                        this.startMoving = z;
                        this.startX = x;
                        this.startMovingQuality = ArticleViewer.this.selectedFontSize;
                    }
                }
            } else if (motionEvent.getAction() == 2) {
                if (this.startMoving) {
                    if (Math.abs(this.startX - x) >= AndroidUtilities.getPixelsInCM(0.5f, true)) {
                        this.moving = true;
                        this.startMoving = false;
                    }
                } else if (this.moving) {
                    while (true) {
                        if (i >= 5) {
                            break;
                        }
                        int i7 = this.sideSide;
                        int i8 = this.lineSize;
                        int i9 = this.gapSize;
                        int i10 = this.circleSize;
                        int i11 = i7 + (((i9 * 2) + i8 + i10) * i) + (i10 / 2);
                        int i12 = (i8 / 2) + (i10 / 2) + i9;
                        if (x <= ((float) (i11 - i12)) || x >= ((float) (i11 + i12))) {
                            i++;
                        } else if (ArticleViewer.this.selectedFontSize != i) {
                            ArticleViewer.this.selectedFontSize = i;
                            ArticleViewer.this.updatePaintSize();
                            invalidate();
                        }
                    }
                }
            } else if (motionEvent.getAction() == 1 || motionEvent.getAction() == 3) {
                if (!this.moving) {
                    int i13 = 0;
                    while (true) {
                        if (i13 >= 5) {
                            break;
                        }
                        int i14 = this.sideSide;
                        int i15 = this.lineSize + (this.gapSize * 2);
                        int i16 = this.circleSize;
                        int i17 = i14 + ((i15 + i16) * i13) + (i16 / 2);
                        if (x <= ((float) (i17 - AndroidUtilities.dp(15.0f))) || x >= ((float) (i17 + AndroidUtilities.dp(15.0f)))) {
                            i13++;
                        } else if (ArticleViewer.this.selectedFontSize != i13) {
                            ArticleViewer.this.selectedFontSize = i13;
                            ArticleViewer.this.updatePaintSize();
                            invalidate();
                        }
                    }
                } else if (ArticleViewer.this.selectedFontSize != this.startMovingQuality) {
                    ArticleViewer.this.updatePaintSize();
                }
                this.startMoving = false;
                this.moving = false;
            }
            return true;
        }

        /* access modifiers changed from: protected */
        public void onMeasure(int i, int i2) {
            super.onMeasure(i, i2);
            View.MeasureSpec.getSize(i);
            this.circleSize = AndroidUtilities.dp(5.0f);
            this.gapSize = AndroidUtilities.dp(2.0f);
            this.sideSide = AndroidUtilities.dp(17.0f);
            this.lineSize = (((getMeasuredWidth() - (this.circleSize * 5)) - ((this.gapSize * 2) * 4)) - (this.sideSide * 2)) / 4;
        }

        /* access modifiers changed from: protected */
        public void onDraw(Canvas canvas) {
            int measuredHeight = getMeasuredHeight() / 2;
            int i = 0;
            while (i < 5) {
                int i2 = this.sideSide;
                int i3 = this.lineSize + (this.gapSize * 2);
                int i4 = this.circleSize;
                int i5 = i2 + ((i3 + i4) * i) + (i4 / 2);
                if (i <= ArticleViewer.this.selectedFontSize) {
                    this.paint.setColor(-15428119);
                } else {
                    this.paint.setColor(-3355444);
                }
                canvas.drawCircle((float) i5, (float) measuredHeight, (float) (i == ArticleViewer.this.selectedFontSize ? AndroidUtilities.dp(4.0f) : this.circleSize / 2), this.paint);
                if (i != 0) {
                    int i6 = ((i5 - (this.circleSize / 2)) - this.gapSize) - this.lineSize;
                    canvas.drawRect((float) i6, (float) (measuredHeight - AndroidUtilities.dp(1.0f)), (float) (i6 + this.lineSize), (float) (AndroidUtilities.dp(1.0f) + measuredHeight), this.paint);
                }
                i++;
            }
        }
    }

    public class ColorCell extends FrameLayout {
        private int currentColor;
        private boolean selected;
        private TextView textView;

        public ColorCell(Context context) {
            super(context);
            if (ArticleViewer.colorPaint == null) {
                Paint unused = ArticleViewer.colorPaint = new Paint(1);
                Paint unused2 = ArticleViewer.selectorPaint = new Paint(1);
                ArticleViewer.selectorPaint.setColor(-15428119);
                ArticleViewer.selectorPaint.setStyle(Paint.Style.STROKE);
                ArticleViewer.selectorPaint.setStrokeWidth((float) AndroidUtilities.dp(2.0f));
            }
            setBackgroundDrawable(Theme.createSelectorDrawable(251658240, 2));
            setWillNotDraw(false);
            TextView textView2 = new TextView(context);
            this.textView = textView2;
            textView2.setTextColor(-14606047);
            this.textView.setTextSize(1, 16.0f);
            this.textView.setLines(1);
            this.textView.setMaxLines(1);
            this.textView.setSingleLine(true);
            int i = 5;
            this.textView.setGravity((LocaleController.isRTL ? 5 : 3) | 16);
            this.textView.setPadding(0, 0, 0, AndroidUtilities.dp(1.0f));
            addView(this.textView, LayoutHelper.createFrame(-1.0f, -1.0f, (!LocaleController.isRTL ? 3 : i) | 48, (float) (LocaleController.isRTL ? 17 : 53), 0.0f, (float) (LocaleController.isRTL ? 53 : 17), 0.0f));
        }

        /* access modifiers changed from: protected */
        public void onMeasure(int i, int i2) {
            super.onMeasure(View.MeasureSpec.makeMeasureSpec(View.MeasureSpec.getSize(i), 1073741824), View.MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(48.0f), 1073741824));
        }

        public void setTextAndColor(String str, int i) {
            this.textView.setText(str);
            this.currentColor = i;
            invalidate();
        }

        public void select(boolean z) {
            if (this.selected != z) {
                this.selected = z;
                invalidate();
            }
        }

        /* access modifiers changed from: protected */
        public void onDraw(Canvas canvas) {
            ArticleViewer.colorPaint.setColor(this.currentColor);
            canvas.drawCircle((float) (!LocaleController.isRTL ? AndroidUtilities.dp(28.0f) : getMeasuredWidth() - AndroidUtilities.dp(28.0f)), (float) (getMeasuredHeight() / 2), (float) AndroidUtilities.dp(10.0f), ArticleViewer.colorPaint);
            if (this.selected) {
                ArticleViewer.selectorPaint.setStrokeWidth((float) AndroidUtilities.dp(2.0f));
                ArticleViewer.selectorPaint.setColor(-15428119);
                canvas.drawCircle((float) (!LocaleController.isRTL ? AndroidUtilities.dp(28.0f) : getMeasuredWidth() - AndroidUtilities.dp(28.0f)), (float) (getMeasuredHeight() / 2), (float) AndroidUtilities.dp(10.0f), ArticleViewer.selectorPaint);
            } else if (this.currentColor == -1) {
                ArticleViewer.selectorPaint.setStrokeWidth((float) AndroidUtilities.dp(1.0f));
                ArticleViewer.selectorPaint.setColor(-4539718);
                canvas.drawCircle((float) (!LocaleController.isRTL ? AndroidUtilities.dp(28.0f) : getMeasuredWidth() - AndroidUtilities.dp(28.0f)), (float) (getMeasuredHeight() / 2), (float) AndroidUtilities.dp(9.0f), ArticleViewer.selectorPaint);
            }
        }
    }

    public class FontCell extends FrameLayout {
        private TextView textView;
        private TextView textView2;

        public FontCell(Context context) {
            super(context);
            setBackgroundDrawable(Theme.createSelectorDrawable(251658240, 2));
            TextView textView3 = new TextView(context);
            this.textView = textView3;
            textView3.setTextColor(-14606047);
            this.textView.setTextSize(1, 16.0f);
            this.textView.setLines(1);
            this.textView.setMaxLines(1);
            this.textView.setSingleLine(true);
            int i = 5;
            this.textView.setGravity((LocaleController.isRTL ? 5 : 3) | 16);
            addView(this.textView, LayoutHelper.createFrame(-1.0f, -1.0f, (LocaleController.isRTL ? 5 : 3) | 48, (float) (LocaleController.isRTL ? 17 : 53), 0.0f, (float) (LocaleController.isRTL ? 53 : 17), 0.0f));
            TextView textView4 = new TextView(context);
            this.textView2 = textView4;
            textView4.setTextColor(-14606047);
            this.textView2.setTextSize(1, 16.0f);
            this.textView2.setLines(1);
            this.textView2.setMaxLines(1);
            this.textView2.setSingleLine(true);
            this.textView2.setText("Aa");
            this.textView2.setGravity((LocaleController.isRTL ? 5 : 3) | 16);
            addView(this.textView2, LayoutHelper.createFrame(-1.0f, -1.0f, (!LocaleController.isRTL ? 3 : i) | 48, 17.0f, 0.0f, 17.0f, 0.0f));
        }

        /* access modifiers changed from: protected */
        public void onMeasure(int i, int i2) {
            super.onMeasure(View.MeasureSpec.makeMeasureSpec(View.MeasureSpec.getSize(i), 1073741824), View.MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(48.0f), 1073741824));
        }

        public void select(boolean z) {
            this.textView2.setTextColor(z ? -15428119 : -14606047);
        }

        public void setTextAndTypeface(String str, Typeface typeface) {
            this.textView.setText(str);
            this.textView.setTypeface(typeface);
            this.textView2.setTypeface(typeface);
            invalidate();
        }
    }

    /* access modifiers changed from: private */
    public class FrameLayoutDrawer extends FrameLayout {
        public FrameLayoutDrawer(Context context) {
            super(context);
        }

        public boolean onTouchEvent(MotionEvent motionEvent) {
            ArticleViewer.this.processTouchEvent(motionEvent);
            return true;
        }

        /* access modifiers changed from: protected */
        public void onDraw(Canvas canvas) {
            ArticleViewer.this.drawContent(canvas);
        }

        /* access modifiers changed from: protected */
        public boolean drawChild(Canvas canvas, View view, long j) {
            return view != ArticleViewer.this.aspectRatioFrameLayout && super.drawChild(canvas, view, j);
        }
    }

    /* access modifiers changed from: private */
    public final class CheckForTap implements Runnable {
        private CheckForTap() {
        }

        public void run() {
            if (ArticleViewer.this.pendingCheckForLongPress == null) {
                ArticleViewer articleViewer = ArticleViewer.this;
                articleViewer.pendingCheckForLongPress = new CheckForLongPress();
            }
            ArticleViewer.this.pendingCheckForLongPress.currentPressCount = ArticleViewer.access$1104(ArticleViewer.this);
            if (ArticleViewer.this.windowView != null) {
                ArticleViewer.this.windowView.postDelayed(ArticleViewer.this.pendingCheckForLongPress, (long) (ViewConfiguration.getLongPressTimeout() - ViewConfiguration.getTapTimeout()));
            }
        }
    }

    /* access modifiers changed from: private */
    public class WindowView extends FrameLayout {
        private float alpha;
        private Runnable attachRunnable;
        private int bHeight;
        private int bWidth;
        private int bX;
        private int bY;
        private boolean closeAnimationInProgress;
        private float innerTranslationX;
        private boolean maybeStartTracking;
        private boolean movingPage;
        private boolean selfLayout;
        private int startMovingHeaderHeight;
        private boolean startedTracking;
        private int startedTrackingPointerId;
        private int startedTrackingX;
        private int startedTrackingY;
        private VelocityTracker tracker;

        public WindowView(Context context) {
            super(context);
        }

        /* access modifiers changed from: protected */
        public void onMeasure(int i, int i2) {
            int size = View.MeasureSpec.getSize(i);
            int size2 = View.MeasureSpec.getSize(i2);
            if (Build.VERSION.SDK_INT < 21 || ArticleViewer.this.lastInsets == null) {
                setMeasuredDimension(size, size2);
            } else {
                setMeasuredDimension(size, size2);
                WindowInsets windowInsets = (WindowInsets) ArticleViewer.this.lastInsets;
                if (AndroidUtilities.incorrectDisplaySizeFix) {
                    if (size2 > AndroidUtilities.displaySize.y) {
                        size2 = AndroidUtilities.displaySize.y;
                    }
                    size2 += AndroidUtilities.statusBarHeight;
                }
                int systemWindowInsetBottom = size2 - windowInsets.getSystemWindowInsetBottom();
                size -= windowInsets.getSystemWindowInsetRight() + windowInsets.getSystemWindowInsetLeft();
                if (windowInsets.getSystemWindowInsetRight() != 0) {
                    this.bWidth = windowInsets.getSystemWindowInsetRight();
                    this.bHeight = systemWindowInsetBottom;
                } else if (windowInsets.getSystemWindowInsetLeft() != 0) {
                    this.bWidth = windowInsets.getSystemWindowInsetLeft();
                    this.bHeight = systemWindowInsetBottom;
                } else {
                    this.bWidth = size;
                    this.bHeight = windowInsets.getSystemWindowInsetBottom();
                }
                size2 = systemWindowInsetBottom - windowInsets.getSystemWindowInsetTop();
            }
            ArticleViewer.this.containerView.measure(View.MeasureSpec.makeMeasureSpec(size, 1073741824), View.MeasureSpec.makeMeasureSpec(size2, 1073741824));
            ArticleViewer.this.photoContainerView.measure(View.MeasureSpec.makeMeasureSpec(size, 1073741824), View.MeasureSpec.makeMeasureSpec(size2, 1073741824));
            ArticleViewer.this.photoContainerBackground.measure(View.MeasureSpec.makeMeasureSpec(size, 1073741824), View.MeasureSpec.makeMeasureSpec(size2, 1073741824));
            ArticleViewer.this.fullscreenVideoContainer.measure(View.MeasureSpec.makeMeasureSpec(size, 1073741824), View.MeasureSpec.makeMeasureSpec(size2, 1073741824));
            ViewGroup.LayoutParams layoutParams = ArticleViewer.this.animatingImageView.getLayoutParams();
            ArticleViewer.this.animatingImageView.measure(View.MeasureSpec.makeMeasureSpec(layoutParams.width, Integer.MIN_VALUE), View.MeasureSpec.makeMeasureSpec(layoutParams.height, Integer.MIN_VALUE));
        }

        /* access modifiers changed from: protected */
        public void onLayout(boolean z, int i, int i2, int i3, int i4) {
            int i5;
            int i6;
            if (!this.selfLayout) {
                int i7 = i3 - i;
                if (ArticleViewer.this.anchorsOffsetMeasuredWidth != i7) {
                    for (int i8 = 0; i8 < ArticleViewer.this.listView.length; i8++) {
                        for (Map.Entry entry : ArticleViewer.this.adapter[i8].anchorsOffset.entrySet()) {
                            entry.setValue(-1);
                        }
                    }
                    ArticleViewer.this.anchorsOffsetMeasuredWidth = i7;
                }
                if (Build.VERSION.SDK_INT < 21 || ArticleViewer.this.lastInsets == null) {
                    i5 = 0;
                    i6 = 0;
                } else {
                    WindowInsets windowInsets = (WindowInsets) ArticleViewer.this.lastInsets;
                    i6 = windowInsets.getSystemWindowInsetLeft();
                    if (windowInsets.getSystemWindowInsetRight() != 0) {
                        this.bX = i7 - this.bWidth;
                        this.bY = 0;
                    } else if (windowInsets.getSystemWindowInsetLeft() != 0) {
                        this.bX = 0;
                        this.bY = 0;
                    } else {
                        this.bX = 0;
                        this.bY = (i4 - i2) - this.bHeight;
                    }
                    i5 = Build.VERSION.SDK_INT >= 28 ? windowInsets.getSystemWindowInsetTop() + 0 : 0;
                }
                ArticleViewer.this.containerView.layout(i6, i5, ArticleViewer.this.containerView.getMeasuredWidth() + i6, ArticleViewer.this.containerView.getMeasuredHeight() + i5);
                ArticleViewer.this.photoContainerView.layout(i6, i5, ArticleViewer.this.photoContainerView.getMeasuredWidth() + i6, ArticleViewer.this.photoContainerView.getMeasuredHeight() + i5);
                ArticleViewer.this.photoContainerBackground.layout(i6, i5, ArticleViewer.this.photoContainerBackground.getMeasuredWidth() + i6, ArticleViewer.this.photoContainerBackground.getMeasuredHeight() + i5);
                ArticleViewer.this.fullscreenVideoContainer.layout(i6, i5, ArticleViewer.this.fullscreenVideoContainer.getMeasuredWidth() + i6, ArticleViewer.this.fullscreenVideoContainer.getMeasuredHeight() + i5);
                ArticleViewer.this.animatingImageView.layout(0, 0, ArticleViewer.this.animatingImageView.getMeasuredWidth(), ArticleViewer.this.animatingImageView.getMeasuredHeight());
            }
        }

        /* access modifiers changed from: protected */
        public void onAttachedToWindow() {
            super.onAttachedToWindow();
            ArticleViewer.this.attachedToWindow = true;
        }

        /* access modifiers changed from: protected */
        public void onDetachedFromWindow() {
            super.onDetachedFromWindow();
            ArticleViewer.this.attachedToWindow = false;
        }

        public void requestDisallowInterceptTouchEvent(boolean z) {
            handleTouchEvent(null);
            super.requestDisallowInterceptTouchEvent(z);
        }

        public boolean onInterceptTouchEvent(MotionEvent motionEvent) {
            return !ArticleViewer.this.collapsed && (handleTouchEvent(motionEvent) || super.onInterceptTouchEvent(motionEvent));
        }

        public boolean onTouchEvent(MotionEvent motionEvent) {
            return !ArticleViewer.this.collapsed && (handleTouchEvent(motionEvent) || super.onTouchEvent(motionEvent));
        }

        public void setInnerTranslationX(float f) {
            this.innerTranslationX = f;
            if (ArticleViewer.this.parentActivity instanceof LaunchActivity) {
                ((LaunchActivity) ArticleViewer.this.parentActivity).drawerLayoutContainer.setAllowDrawContent((ArticleViewer.this.isVisible && this.alpha == 1.0f && this.innerTranslationX == 0.0f) ? false : true);
            }
            invalidate();
        }

        /* access modifiers changed from: protected */
        public boolean drawChild(Canvas canvas, View view, long j) {
            int measuredWidth = getMeasuredWidth();
            int i = (int) this.innerTranslationX;
            int save = canvas.save();
            canvas.clipRect(i, 0, measuredWidth, getHeight());
            boolean drawChild = super.drawChild(canvas, view, j);
            canvas.restoreToCount(save);
            if (i != 0 && view == ArticleViewer.this.containerView) {
                float f = (float) (measuredWidth - i);
                float min = Math.min(0.8f, f / ((float) measuredWidth));
                if (min < 0.0f) {
                    min = 0.0f;
                }
                ArticleViewer.this.scrimPaint.setColor(((int) (min * 153.0f)) << 24);
                canvas.drawRect(0.0f, 0.0f, (float) i, (float) getHeight(), ArticleViewer.this.scrimPaint);
                float max = Math.max(0.0f, Math.min(f / ((float) AndroidUtilities.dp(20.0f)), 1.0f));
                ArticleViewer.this.layerShadowDrawable.setBounds(i - ArticleViewer.this.layerShadowDrawable.getIntrinsicWidth(), view.getTop(), i, view.getBottom());
                ArticleViewer.this.layerShadowDrawable.setAlpha((int) (max * 255.0f));
                ArticleViewer.this.layerShadowDrawable.draw(canvas);
            }
            return drawChild;
        }

        public float getInnerTranslationX() {
            return this.innerTranslationX;
        }

        private void prepareForMoving(MotionEvent motionEvent) {
            this.maybeStartTracking = false;
            this.startedTracking = true;
            this.startedTrackingX = (int) motionEvent.getX();
            if (ArticleViewer.this.pagesStack.size() > 1) {
                this.movingPage = true;
                this.startMovingHeaderHeight = ArticleViewer.this.currentHeaderHeight;
                ArticleViewer.this.listView[1].setVisibility(0);
                ArticleViewer.this.listView[1].setAlpha(1.0f);
                ArticleViewer.this.listView[1].setTranslationX(0.0f);
                ArticleViewer.this.listView[0].setBackgroundColor(ArticleViewer.this.backgroundPaint.getColor());
            } else {
                this.movingPage = false;
            }
            ArticleViewer.this.cancelCheckLongPress();
        }

        public boolean handleTouchEvent(MotionEvent motionEvent) {
            if (ArticleViewer.this.isPhotoVisible || this.closeAnimationInProgress || ArticleViewer.this.fullscreenVideoContainer.getVisibility() == 0) {
                return false;
            }
            if (motionEvent != null && motionEvent.getAction() == 0 && !this.startedTracking && !this.maybeStartTracking) {
                this.startedTrackingPointerId = motionEvent.getPointerId(0);
                this.maybeStartTracking = true;
                this.startedTrackingX = (int) motionEvent.getX();
                this.startedTrackingY = (int) motionEvent.getY();
                VelocityTracker velocityTracker = this.tracker;
                if (velocityTracker != null) {
                    velocityTracker.clear();
                }
            } else if (motionEvent != null && motionEvent.getAction() == 2 && motionEvent.getPointerId(0) == this.startedTrackingPointerId) {
                if (this.tracker == null) {
                    this.tracker = VelocityTracker.obtain();
                }
                int max = Math.max(0, (int) (motionEvent.getX() - ((float) this.startedTrackingX)));
                int abs = Math.abs(((int) motionEvent.getY()) - this.startedTrackingY);
                this.tracker.addMovement(motionEvent);
                if (this.maybeStartTracking && !this.startedTracking && ((float) max) >= AndroidUtilities.getPixelsInCM(0.4f, true) && Math.abs(max) / 3 > abs) {
                    prepareForMoving(motionEvent);
                } else if (this.startedTracking) {
                    ArticleViewer.this.pressedLinkOwnerLayout = null;
                    ArticleViewer.this.pressedLinkOwnerView = null;
                    if (this.movingPage) {
                        ArticleViewer.this.listView[0].setTranslationX((float) max);
                    } else {
                        float f = (float) max;
                        ArticleViewer.this.containerView.setTranslationX(f);
                        setInnerTranslationX(f);
                    }
                }
            } else if (motionEvent != null && motionEvent.getPointerId(0) == this.startedTrackingPointerId && (motionEvent.getAction() == 3 || motionEvent.getAction() == 1 || motionEvent.getAction() == 6)) {
                if (this.tracker == null) {
                    this.tracker = VelocityTracker.obtain();
                }
                this.tracker.computeCurrentVelocity(1000);
                float xVelocity = this.tracker.getXVelocity();
                float yVelocity = this.tracker.getYVelocity();
                if (!this.startedTracking && xVelocity >= 3500.0f && xVelocity > Math.abs(yVelocity)) {
                    prepareForMoving(motionEvent);
                }
                if (this.startedTracking) {
                    View view = this.movingPage ? ArticleViewer.this.listView[0] : ArticleViewer.this.containerView;
                    float x = view.getX();
                    final boolean z = x < ((float) view.getMeasuredWidth()) / 3.0f && (xVelocity < 3500.0f || xVelocity < yVelocity);
                    AnimatorSet animatorSet = new AnimatorSet();
                    if (!z) {
                        x = ((float) view.getMeasuredWidth()) - x;
                        if (this.movingPage) {
                            animatorSet.playTogether(ObjectAnimator.ofFloat(ArticleViewer.this.listView[0], View.TRANSLATION_X, (float) view.getMeasuredWidth()));
                        } else {
                            animatorSet.playTogether(ObjectAnimator.ofFloat(ArticleViewer.this.containerView, View.TRANSLATION_X, (float) view.getMeasuredWidth()), ObjectAnimator.ofFloat(this, ArticleViewer.ARTICLE_VIEWER_INNER_TRANSLATION_X, (float) view.getMeasuredWidth()));
                        }
                    } else if (this.movingPage) {
                        animatorSet.playTogether(ObjectAnimator.ofFloat(ArticleViewer.this.listView[0], View.TRANSLATION_X, 0.0f));
                    } else {
                        animatorSet.playTogether(ObjectAnimator.ofFloat(ArticleViewer.this.containerView, View.TRANSLATION_X, 0.0f), ObjectAnimator.ofFloat(this, ArticleViewer.ARTICLE_VIEWER_INNER_TRANSLATION_X, 0.0f));
                    }
                    animatorSet.setDuration((long) Math.max((int) ((200.0f / ((float) view.getMeasuredWidth())) * x), 50));
                    animatorSet.addListener(new AnimatorListenerAdapter() {
                        /* class im.guobwnxjuc.ui.ArticleViewer.WindowView.AnonymousClass1 */

                        public void onAnimationEnd(Animator animator) {
                            if (WindowView.this.movingPage) {
                                ArticleViewer.this.listView[0].setBackgroundDrawable(null);
                                if (!z) {
                                    WebpageAdapter webpageAdapter = ArticleViewer.this.adapter[1];
                                    ArticleViewer.this.adapter[1] = ArticleViewer.this.adapter[0];
                                    ArticleViewer.this.adapter[0] = webpageAdapter;
                                    RecyclerListView recyclerListView = ArticleViewer.this.listView[1];
                                    ArticleViewer.this.listView[1] = ArticleViewer.this.listView[0];
                                    ArticleViewer.this.listView[0] = recyclerListView;
                                    LinearLayoutManager linearLayoutManager = ArticleViewer.this.layoutManager[1];
                                    ArticleViewer.this.layoutManager[1] = ArticleViewer.this.layoutManager[0];
                                    ArticleViewer.this.layoutManager[0] = linearLayoutManager;
                                    ArticleViewer.this.pagesStack.remove(ArticleViewer.this.pagesStack.size() - 1);
                                    ArticleViewer.this.currentPage = (TLRPC.WebPage) ArticleViewer.this.pagesStack.get(ArticleViewer.this.pagesStack.size() - 1);
                                }
                                ArticleViewer.this.listView[1].setVisibility(8);
                                ArticleViewer.this.headerView.invalidate();
                            } else if (!z) {
                                ArticleViewer.this.saveCurrentPagePosition();
                                ArticleViewer.this.onClosed();
                            }
                            WindowView.this.movingPage = false;
                            WindowView.this.startedTracking = false;
                            WindowView.this.closeAnimationInProgress = false;
                        }
                    });
                    animatorSet.start();
                    this.closeAnimationInProgress = true;
                } else {
                    this.maybeStartTracking = false;
                    this.startedTracking = false;
                    this.movingPage = false;
                }
                VelocityTracker velocityTracker2 = this.tracker;
                if (velocityTracker2 != null) {
                    velocityTracker2.recycle();
                    this.tracker = null;
                }
            } else if (motionEvent == null) {
                this.maybeStartTracking = false;
                this.startedTracking = false;
                this.movingPage = false;
                VelocityTracker velocityTracker3 = this.tracker;
                if (velocityTracker3 != null) {
                    velocityTracker3.recycle();
                    this.tracker = null;
                }
            }
            return this.startedTracking;
        }

        /* access modifiers changed from: protected */
        public void dispatchDraw(Canvas canvas) {
            int i;
            int i2;
            super.dispatchDraw(canvas);
            int i3 = this.bWidth;
            if (i3 != 0 && (i = this.bHeight) != 0) {
                int i4 = this.bX;
                if (i4 == 0 && (i2 = this.bY) == 0) {
                    canvas.drawRect((float) i4, (float) i2, (float) (i4 + i3), (float) (i2 + i), ArticleViewer.this.blackPaint);
                } else {
                    canvas.drawRect(((float) this.bX) - getTranslationX(), (float) this.bY, ((float) (this.bX + this.bWidth)) - getTranslationX(), (float) (this.bY + this.bHeight), ArticleViewer.this.blackPaint);
                }
            }
        }

        /* access modifiers changed from: protected */
        public void onDraw(Canvas canvas) {
            canvas.drawRect(this.innerTranslationX, 0.0f, (float) getMeasuredWidth(), (float) getMeasuredHeight(), ArticleViewer.this.backgroundPaint);
            if (Build.VERSION.SDK_INT >= 21 && ArticleViewer.this.hasCutout && ArticleViewer.this.lastInsets != null) {
                canvas.drawRect(this.innerTranslationX, 0.0f, (float) getMeasuredWidth(), (float) ((WindowInsets) ArticleViewer.this.lastInsets).getSystemWindowInsetBottom(), ArticleViewer.this.statusBarPaint);
            }
        }

        public void setAlpha(float f) {
            int i = (int) (255.0f * f);
            ArticleViewer.this.backgroundPaint.setAlpha(i);
            ArticleViewer.this.statusBarPaint.setAlpha(i);
            this.alpha = f;
            if (ArticleViewer.this.parentActivity instanceof LaunchActivity) {
                ((LaunchActivity) ArticleViewer.this.parentActivity).drawerLayoutContainer.setAllowDrawContent((ArticleViewer.this.isVisible && this.alpha == 1.0f && this.innerTranslationX == 0.0f) ? false : true);
            }
            invalidate();
        }

        public float getAlpha() {
            return this.alpha;
        }
    }

    /* access modifiers changed from: package-private */
    public class CheckForLongPress implements Runnable {
        public int currentPressCount;

        CheckForLongPress() {
        }

        public void run() {
            if (ArticleViewer.this.checkingForLongPress && ArticleViewer.this.windowView != null) {
                ArticleViewer.this.checkingForLongPress = false;
                if (ArticleViewer.this.pressedLink != null) {
                    ArticleViewer.this.windowView.performHapticFeedback(0);
                    ArticleViewer articleViewer = ArticleViewer.this;
                    articleViewer.showCopyPopup(articleViewer.pressedLink.getUrl());
                    ArticleViewer.this.pressedLink = null;
                    ArticleViewer.this.pressedLinkOwnerLayout = null;
                    if (ArticleViewer.this.pressedLinkOwnerView != null) {
                        ArticleViewer.this.pressedLinkOwnerView.invalidate();
                    }
                } else if (ArticleViewer.this.pressedLinkOwnerLayout != null && ArticleViewer.this.pressedLinkOwnerView != null) {
                    ArticleViewer.this.windowView.performHapticFeedback(0);
                    int[] iArr = new int[2];
                    ArticleViewer.this.pressedLinkOwnerView.getLocationInWindow(iArr);
                    int dp = (iArr[1] + ArticleViewer.this.pressedLayoutY) - AndroidUtilities.dp(54.0f);
                    if (dp < 0) {
                        dp = 0;
                    }
                    ArticleViewer.this.pressedLinkOwnerView.invalidate();
                    ArticleViewer.this.drawBlockSelection = true;
                    ArticleViewer articleViewer2 = ArticleViewer.this;
                    articleViewer2.showPopup(articleViewer2.pressedLinkOwnerView, 48, 0, dp);
                    ArticleViewer.this.listView[0].setLayoutFrozen(true);
                    ArticleViewer.this.listView[0].setLayoutFrozen(false);
                }
            }
        }
    }

    private void createPaint(boolean z) {
        if (quoteLinePaint == null) {
            quoteLinePaint = new Paint();
            preformattedBackgroundPaint = new Paint();
            Paint paint = new Paint(1);
            tableLinePaint = paint;
            paint.setStyle(Paint.Style.STROKE);
            tableLinePaint.setStrokeWidth((float) AndroidUtilities.dp(1.0f));
            Paint paint2 = new Paint();
            tableHalfLinePaint = paint2;
            paint2.setStyle(Paint.Style.STROKE);
            tableHalfLinePaint.setStrokeWidth(((float) AndroidUtilities.dp(1.0f)) / 2.0f);
            tableHeaderPaint = new Paint();
            tableStripPaint = new Paint();
            urlPaint = new Paint();
            webpageUrlPaint = new Paint(1);
            photoBackgroundPaint = new Paint();
            dividerPaint = new Paint();
            webpageMarkPaint = new Paint(1);
        } else if (!z) {
            return;
        }
        int selectedColor2 = getSelectedColor();
        if (selectedColor2 == 0) {
            preformattedBackgroundPaint.setColor(-657156);
            webpageUrlPaint.setColor(-1313798);
            urlPaint.setColor(-2299145);
            tableHalfLinePaint.setColor(-2039584);
            tableLinePaint.setColor(-2039584);
            tableHeaderPaint.setColor(-723724);
            tableStripPaint.setColor(-526345);
            photoBackgroundPaint.setColor(-723724);
            dividerPaint.setColor(-3288619);
            webpageMarkPaint.setColor(-68676);
        } else if (selectedColor2 == 1) {
            preformattedBackgroundPaint.setColor(-1712440);
            webpageUrlPaint.setColor(-2365721);
            urlPaint.setColor(-3481882);
            tableHalfLinePaint.setColor(-3620432);
            tableLinePaint.setColor(-3620432);
            tableHeaderPaint.setColor(-1120560);
            tableStripPaint.setColor(-1120560);
            photoBackgroundPaint.setColor(-1120560);
            dividerPaint.setColor(-4080987);
            webpageMarkPaint.setColor(-1712691);
        } else if (selectedColor2 == 2) {
            preformattedBackgroundPaint.setColor(-15000805);
            webpageUrlPaint.setColor(-14536904);
            urlPaint.setColor(-14469050);
            tableHalfLinePaint.setColor(-13750738);
            tableLinePaint.setColor(-13750738);
            tableHeaderPaint.setColor(-15066598);
            tableStripPaint.setColor(-15066598);
            photoBackgroundPaint.setColor(-14935012);
            dividerPaint.setColor(-12303292);
            webpageMarkPaint.setColor(-14408668);
        }
        quoteLinePaint.setColor(getTextColor());
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private void showCopyPopup(String str) {
        if (this.parentActivity != null) {
            BottomSheet bottomSheet = this.linkSheet;
            if (bottomSheet != null) {
                bottomSheet.dismiss();
                this.linkSheet = null;
            }
            BottomSheet.Builder builder = new BottomSheet.Builder(this.parentActivity);
            builder.setUseFullscreen(true);
            builder.setTitle(str);
            builder.setItems(new CharSequence[]{LocaleController.getString("Open", R.string.Open), LocaleController.getString("Copy", R.string.Copy)}, new DialogInterface.OnClickListener(str) {
                /* class im.guobwnxjuc.ui.$$Lambda$ArticleViewer$6LubhAJ5UWfYufssCrQYKelPE8 */
                private final /* synthetic */ String f$1;

                {
                    this.f$1 = r2;
                }

                public final void onClick(DialogInterface dialogInterface, int i) {
                    ArticleViewer.this.lambda$showCopyPopup$0$ArticleViewer(this.f$1, dialogInterface, i);
                }
            });
            BottomSheet create = builder.create();
            showDialog(create);
            for (int i = 0; i < 2; i++) {
                create.setItemColor(i, getTextColor(), getTextColor());
            }
            create.setTitleColor(getGrayTextColor());
            int i2 = this.selectedColor;
            if (i2 == 0) {
                create.setBackgroundColor(-1);
            } else if (i2 == 1) {
                create.setBackgroundColor(-659492);
            } else if (i2 == 2) {
                create.setBackgroundColor(-15461356);
            }
        }
    }

    public /* synthetic */ void lambda$showCopyPopup$0$ArticleViewer(String str, DialogInterface dialogInterface, int i) {
        String str2;
        String str3;
        if (this.parentActivity != null) {
            if (i == 0) {
                int lastIndexOf = str.lastIndexOf(35);
                if (lastIndexOf != -1) {
                    if (!TextUtils.isEmpty(this.currentPage.cached_page.url)) {
                        str2 = this.currentPage.cached_page.url.toLowerCase();
                    } else {
                        str2 = this.currentPage.url.toLowerCase();
                    }
                    try {
                        str3 = URLDecoder.decode(str.substring(lastIndexOf + 1), "UTF-8");
                    } catch (Exception unused) {
                        str3 = "";
                    }
                    if (str.toLowerCase().contains(str2)) {
                        if (TextUtils.isEmpty(str3)) {
                            this.layoutManager[0].scrollToPositionWithOffset(0, 0);
                            checkScrollAnimated();
                            return;
                        }
                        scrollToAnchor(str3);
                        return;
                    }
                }
                Browser.openUrl(this.parentActivity, str);
            } else if (i == 1) {
                if (str.startsWith("mailto:")) {
                    str = str.substring(7);
                } else if (str.startsWith("tel:")) {
                    str = str.substring(4);
                }
                AndroidUtilities.addToClipboard(str);
            }
        }
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private void showPopup(View view, int i, int i2, int i3) {
        ActionBarPopupWindow actionBarPopupWindow = this.popupWindow;
        if (actionBarPopupWindow == null || !actionBarPopupWindow.isShowing()) {
            if (this.popupLayout == null) {
                this.popupRect = new Rect();
                ActionBarPopupWindow.ActionBarPopupWindowLayout actionBarPopupWindowLayout = new ActionBarPopupWindow.ActionBarPopupWindowLayout(this.parentActivity);
                this.popupLayout = actionBarPopupWindowLayout;
                actionBarPopupWindowLayout.setPadding(AndroidUtilities.dp(1.0f), AndroidUtilities.dp(1.0f), AndroidUtilities.dp(1.0f), AndroidUtilities.dp(1.0f));
                ActionBarPopupWindow.ActionBarPopupWindowLayout actionBarPopupWindowLayout2 = this.popupLayout;
                Drawable drawable = this.parentActivity.getResources().getDrawable(R.drawable.menu_copy);
                this.copyBackgroundDrawable = drawable;
                actionBarPopupWindowLayout2.setBackgroundDrawable(drawable);
                this.popupLayout.setAnimationEnabled(false);
                this.popupLayout.setOnTouchListener(new View.OnTouchListener() {
                    /* class im.guobwnxjuc.ui.$$Lambda$ArticleViewer$v9Z_FtANXtgvF2eVPrpq1l7ufk */

                    public final boolean onTouch(View view, MotionEvent motionEvent) {
                        return ArticleViewer.this.lambda$showPopup$1$ArticleViewer(view, motionEvent);
                    }
                });
                this.popupLayout.setDispatchKeyEventListener(new ActionBarPopupWindow.OnDispatchKeyEventListener() {
                    /* class im.guobwnxjuc.ui.$$Lambda$ArticleViewer$qgLqdYBnJct68cLUrg811m3Cb2s */

                    @Override // im.guobwnxjuc.ui.actionbar.ActionBarPopupWindow.OnDispatchKeyEventListener
                    public final void onDispatchKeyEvent(KeyEvent keyEvent) {
                        ArticleViewer.this.lambda$showPopup$2$ArticleViewer(keyEvent);
                    }
                });
                this.popupLayout.setShowedFromBotton(false);
                TextView textView = new TextView(this.parentActivity);
                this.deleteView = textView;
                textView.setBackgroundDrawable(Theme.createSelectorDrawable(251658240, 2));
                this.deleteView.setGravity(16);
                this.deleteView.setPadding(AndroidUtilities.dp(20.0f), 0, AndroidUtilities.dp(20.0f), 0);
                this.deleteView.setTextSize(1, 15.0f);
                this.deleteView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
                this.deleteView.setText(LocaleController.getString("Copy", R.string.Copy).toUpperCase());
                this.deleteView.setOnClickListener(new View.OnClickListener() {
                    /* class im.guobwnxjuc.ui.$$Lambda$ArticleViewer$gvkd0qmTaH7iKJ1PIU6mR2brts */

                    public final void onClick(View view) {
                        ArticleViewer.this.lambda$showPopup$3$ArticleViewer(view);
                    }
                });
                this.popupLayout.addView(this.deleteView, LayoutHelper.createFrame(-2, 48.0f));
                ActionBarPopupWindow actionBarPopupWindow2 = new ActionBarPopupWindow(this.popupLayout, -2, -2);
                this.popupWindow = actionBarPopupWindow2;
                actionBarPopupWindow2.setAnimationEnabled(false);
                this.popupWindow.setAnimationStyle(R.style.PopupContextAnimation);
                this.popupWindow.setOutsideTouchable(true);
                this.popupWindow.setClippingEnabled(true);
                this.popupWindow.setInputMethodMode(2);
                this.popupWindow.setSoftInputMode(0);
                this.popupWindow.getContentView().setFocusableInTouchMode(true);
                this.popupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
                    /* class im.guobwnxjuc.ui.$$Lambda$ArticleViewer$CiNJD9Tui62tRAWXmwjqa8ql0Wc */

                    public final void onDismiss() {
                        ArticleViewer.this.lambda$showPopup$4$ArticleViewer();
                    }
                });
            }
            if (this.selectedColor == 2) {
                this.deleteView.setTextColor(-5723992);
                Drawable drawable2 = this.copyBackgroundDrawable;
                if (drawable2 != null) {
                    drawable2.setColorFilter(new PorterDuffColorFilter(-14408668, PorterDuff.Mode.MULTIPLY));
                }
            } else {
                this.deleteView.setTextColor(-14606047);
                Drawable drawable3 = this.copyBackgroundDrawable;
                if (drawable3 != null) {
                    drawable3.setColorFilter(new PorterDuffColorFilter(-1, PorterDuff.Mode.MULTIPLY));
                }
            }
            this.popupLayout.measure(View.MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(1000.0f), Integer.MIN_VALUE), View.MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(1000.0f), Integer.MIN_VALUE));
            this.popupWindow.setFocusable(true);
            this.popupWindow.showAtLocation(view, i, i2, i3);
            this.popupWindow.startAnimation();
            return;
        }
        this.popupWindow.dismiss();
    }

    public /* synthetic */ boolean lambda$showPopup$1$ArticleViewer(View view, MotionEvent motionEvent) {
        ActionBarPopupWindow actionBarPopupWindow;
        if (motionEvent.getActionMasked() != 0 || (actionBarPopupWindow = this.popupWindow) == null || !actionBarPopupWindow.isShowing()) {
            return false;
        }
        view.getHitRect(this.popupRect);
        if (this.popupRect.contains((int) motionEvent.getX(), (int) motionEvent.getY())) {
            return false;
        }
        this.popupWindow.dismiss();
        return false;
    }

    public /* synthetic */ void lambda$showPopup$2$ArticleViewer(KeyEvent keyEvent) {
        ActionBarPopupWindow actionBarPopupWindow;
        if (keyEvent.getKeyCode() == 4 && keyEvent.getRepeatCount() == 0 && (actionBarPopupWindow = this.popupWindow) != null && actionBarPopupWindow.isShowing()) {
            this.popupWindow.dismiss();
        }
    }

    public /* synthetic */ void lambda$showPopup$3$ArticleViewer(View view) {
        DrawingText drawingText = this.pressedLinkOwnerLayout;
        if (drawingText != null) {
            AndroidUtilities.addToClipboard(drawingText.getText());
            ToastUtils.show((int) R.string.TextCopied);
        }
        ActionBarPopupWindow actionBarPopupWindow = this.popupWindow;
        if (actionBarPopupWindow != null && actionBarPopupWindow.isShowing()) {
            this.popupWindow.dismiss(true);
        }
    }

    public /* synthetic */ void lambda$showPopup$4$ArticleViewer() {
        View view = this.pressedLinkOwnerView;
        if (view != null) {
            this.pressedLinkOwnerLayout = null;
            view.invalidate();
            this.pressedLinkOwnerView = null;
        }
    }

    private TLRPC.RichText getBlockCaption(TLRPC.PageBlock pageBlock, int i) {
        if (i == 2) {
            TLRPC.RichText blockCaption = getBlockCaption(pageBlock, 0);
            if (blockCaption instanceof TLRPC.TL_textEmpty) {
                blockCaption = null;
            }
            TLRPC.RichText blockCaption2 = getBlockCaption(pageBlock, 1);
            if (blockCaption2 instanceof TLRPC.TL_textEmpty) {
                blockCaption2 = null;
            }
            if (blockCaption != null && blockCaption2 == null) {
                return blockCaption;
            }
            if (blockCaption == null && blockCaption2 != null) {
                return blockCaption2;
            }
            if (blockCaption == null || blockCaption2 == null) {
                return null;
            }
            TLRPC.TL_textPlain tL_textPlain = new TLRPC.TL_textPlain();
            tL_textPlain.text = " ";
            TLRPC.TL_textConcat tL_textConcat = new TLRPC.TL_textConcat();
            tL_textConcat.texts.add(blockCaption);
            tL_textConcat.texts.add(tL_textPlain);
            tL_textConcat.texts.add(blockCaption2);
            return tL_textConcat;
        }
        if (pageBlock instanceof TLRPC.TL_pageBlockEmbedPost) {
            TLRPC.TL_pageBlockEmbedPost tL_pageBlockEmbedPost = (TLRPC.TL_pageBlockEmbedPost) pageBlock;
            if (i == 0) {
                return tL_pageBlockEmbedPost.caption.text;
            }
            if (i == 1) {
                return tL_pageBlockEmbedPost.caption.credit;
            }
        } else if (pageBlock instanceof TLRPC.TL_pageBlockSlideshow) {
            TLRPC.TL_pageBlockSlideshow tL_pageBlockSlideshow = (TLRPC.TL_pageBlockSlideshow) pageBlock;
            if (i == 0) {
                return tL_pageBlockSlideshow.caption.text;
            }
            if (i == 1) {
                return tL_pageBlockSlideshow.caption.credit;
            }
        } else if (pageBlock instanceof TLRPC.TL_pageBlockPhoto) {
            TLRPC.TL_pageBlockPhoto tL_pageBlockPhoto = (TLRPC.TL_pageBlockPhoto) pageBlock;
            if (i == 0) {
                return tL_pageBlockPhoto.caption.text;
            }
            if (i == 1) {
                return tL_pageBlockPhoto.caption.credit;
            }
        } else if (pageBlock instanceof TLRPC.TL_pageBlockCollage) {
            TLRPC.TL_pageBlockCollage tL_pageBlockCollage = (TLRPC.TL_pageBlockCollage) pageBlock;
            if (i == 0) {
                return tL_pageBlockCollage.caption.text;
            }
            if (i == 1) {
                return tL_pageBlockCollage.caption.credit;
            }
        } else if (pageBlock instanceof TLRPC.TL_pageBlockEmbed) {
            TLRPC.TL_pageBlockEmbed tL_pageBlockEmbed = (TLRPC.TL_pageBlockEmbed) pageBlock;
            if (i == 0) {
                return tL_pageBlockEmbed.caption.text;
            }
            if (i == 1) {
                return tL_pageBlockEmbed.caption.credit;
            }
        } else if (pageBlock instanceof TLRPC.TL_pageBlockBlockquote) {
            return ((TLRPC.TL_pageBlockBlockquote) pageBlock).caption;
        } else {
            if (pageBlock instanceof TLRPC.TL_pageBlockVideo) {
                TLRPC.TL_pageBlockVideo tL_pageBlockVideo = (TLRPC.TL_pageBlockVideo) pageBlock;
                if (i == 0) {
                    return tL_pageBlockVideo.caption.text;
                }
                if (i == 1) {
                    return tL_pageBlockVideo.caption.credit;
                }
            } else if (pageBlock instanceof TLRPC.TL_pageBlockPullquote) {
                return ((TLRPC.TL_pageBlockPullquote) pageBlock).caption;
            } else {
                if (pageBlock instanceof TLRPC.TL_pageBlockAudio) {
                    TLRPC.TL_pageBlockAudio tL_pageBlockAudio = (TLRPC.TL_pageBlockAudio) pageBlock;
                    if (i == 0) {
                        return tL_pageBlockAudio.caption.text;
                    }
                    if (i == 1) {
                        return tL_pageBlockAudio.caption.credit;
                    }
                } else if (pageBlock instanceof TLRPC.TL_pageBlockCover) {
                    return getBlockCaption(((TLRPC.TL_pageBlockCover) pageBlock).cover, i);
                } else {
                    if (pageBlock instanceof TLRPC.TL_pageBlockMap) {
                        TLRPC.TL_pageBlockMap tL_pageBlockMap = (TLRPC.TL_pageBlockMap) pageBlock;
                        if (i == 0) {
                            return tL_pageBlockMap.caption.text;
                        }
                        if (i == 1) {
                            return tL_pageBlockMap.caption.credit;
                        }
                    }
                }
            }
        }
        return null;
    }

    private View getLastNonListCell(View view) {
        if (view instanceof BlockListItemCell) {
            BlockListItemCell blockListItemCell = (BlockListItemCell) view;
            if (blockListItemCell.blockLayout != null) {
                return getLastNonListCell(blockListItemCell.blockLayout.itemView);
            }
            return view;
        } else if (!(view instanceof BlockOrderedListItemCell)) {
            return view;
        } else {
            BlockOrderedListItemCell blockOrderedListItemCell = (BlockOrderedListItemCell) view;
            return blockOrderedListItemCell.blockLayout != null ? getLastNonListCell(blockOrderedListItemCell.blockLayout.itemView) : view;
        }
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private boolean isListItemBlock(TLRPC.PageBlock pageBlock) {
        return (pageBlock instanceof TL_pageBlockListItem) || (pageBlock instanceof TL_pageBlockOrderedListItem);
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private TLRPC.PageBlock getLastNonListPageBlock(TLRPC.PageBlock pageBlock) {
        if (pageBlock instanceof TL_pageBlockListItem) {
            TL_pageBlockListItem tL_pageBlockListItem = (TL_pageBlockListItem) pageBlock;
            if (tL_pageBlockListItem.blockItem != null) {
                return getLastNonListPageBlock(tL_pageBlockListItem.blockItem);
            }
            return tL_pageBlockListItem.blockItem;
        } else if (!(pageBlock instanceof TL_pageBlockOrderedListItem)) {
            return pageBlock;
        } else {
            TL_pageBlockOrderedListItem tL_pageBlockOrderedListItem = (TL_pageBlockOrderedListItem) pageBlock;
            if (tL_pageBlockOrderedListItem.blockItem != null) {
                return getLastNonListPageBlock(tL_pageBlockOrderedListItem.blockItem);
            }
            return tL_pageBlockOrderedListItem.blockItem;
        }
    }

    private boolean openAllParentBlocks(TL_pageBlockDetailsChild tL_pageBlockDetailsChild) {
        boolean z;
        TLRPC.PageBlock lastNonListPageBlock = getLastNonListPageBlock(tL_pageBlockDetailsChild.parent);
        if (lastNonListPageBlock instanceof TLRPC.TL_pageBlockDetails) {
            TLRPC.TL_pageBlockDetails tL_pageBlockDetails = (TLRPC.TL_pageBlockDetails) lastNonListPageBlock;
            if (tL_pageBlockDetails.open) {
                return false;
            }
            tL_pageBlockDetails.open = true;
            return true;
        } else if (!(lastNonListPageBlock instanceof TL_pageBlockDetailsChild)) {
            return false;
        } else {
            TL_pageBlockDetailsChild tL_pageBlockDetailsChild2 = (TL_pageBlockDetailsChild) lastNonListPageBlock;
            TLRPC.PageBlock lastNonListPageBlock2 = getLastNonListPageBlock(tL_pageBlockDetailsChild2.block);
            if (lastNonListPageBlock2 instanceof TLRPC.TL_pageBlockDetails) {
                TLRPC.TL_pageBlockDetails tL_pageBlockDetails2 = (TLRPC.TL_pageBlockDetails) lastNonListPageBlock2;
                if (!tL_pageBlockDetails2.open) {
                    tL_pageBlockDetails2.open = true;
                    z = true;
                    if (!openAllParentBlocks(tL_pageBlockDetailsChild2) || z) {
                        return true;
                    }
                    return false;
                }
            }
            z = false;
            if (!openAllParentBlocks(tL_pageBlockDetailsChild2)) {
            }
            return true;
        }
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private TLRPC.PageBlock fixListBlock(TLRPC.PageBlock pageBlock, TLRPC.PageBlock pageBlock2) {
        if (pageBlock instanceof TL_pageBlockListItem) {
            ((TL_pageBlockListItem) pageBlock).blockItem = pageBlock2;
            return pageBlock;
        } else if (!(pageBlock instanceof TL_pageBlockOrderedListItem)) {
            return pageBlock2;
        } else {
            ((TL_pageBlockOrderedListItem) pageBlock).blockItem = pageBlock2;
            return pageBlock;
        }
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private TLRPC.PageBlock wrapInTableBlock(TLRPC.PageBlock pageBlock, TLRPC.PageBlock pageBlock2) {
        if (pageBlock instanceof TL_pageBlockListItem) {
            TL_pageBlockListItem tL_pageBlockListItem = (TL_pageBlockListItem) pageBlock;
            TL_pageBlockListItem tL_pageBlockListItem2 = new TL_pageBlockListItem();
            tL_pageBlockListItem2.parent = tL_pageBlockListItem.parent;
            tL_pageBlockListItem2.blockItem = wrapInTableBlock(tL_pageBlockListItem.blockItem, pageBlock2);
            return tL_pageBlockListItem2;
        } else if (!(pageBlock instanceof TL_pageBlockOrderedListItem)) {
            return pageBlock2;
        } else {
            TL_pageBlockOrderedListItem tL_pageBlockOrderedListItem = (TL_pageBlockOrderedListItem) pageBlock;
            TL_pageBlockOrderedListItem tL_pageBlockOrderedListItem2 = new TL_pageBlockOrderedListItem();
            tL_pageBlockOrderedListItem2.parent = tL_pageBlockOrderedListItem.parent;
            tL_pageBlockOrderedListItem2.blockItem = wrapInTableBlock(tL_pageBlockOrderedListItem.blockItem, pageBlock2);
            return tL_pageBlockOrderedListItem2;
        }
    }

    private void updateInterfaceForCurrentPage(int i) {
        int i2;
        TLRPC.WebPage webPage = this.currentPage;
        if (webPage != null && webPage.cached_page != null) {
            this.isRtl = this.currentPage.cached_page.rtl;
            this.channelBlock = null;
            this.titleTextView.setText(this.currentPage.site_name == null ? "" : this.currentPage.site_name);
            boolean z = true;
            if (i != 0) {
                WebpageAdapter[] webpageAdapterArr = this.adapter;
                WebpageAdapter webpageAdapter = webpageAdapterArr[1];
                webpageAdapterArr[1] = webpageAdapterArr[0];
                webpageAdapterArr[0] = webpageAdapter;
                RecyclerListView[] recyclerListViewArr = this.listView;
                RecyclerListView recyclerListView = recyclerListViewArr[1];
                recyclerListViewArr[1] = recyclerListViewArr[0];
                recyclerListViewArr[0] = recyclerListView;
                LinearLayoutManager[] linearLayoutManagerArr = this.layoutManager;
                LinearLayoutManager linearLayoutManager = linearLayoutManagerArr[1];
                linearLayoutManagerArr[1] = linearLayoutManagerArr[0];
                linearLayoutManagerArr[0] = linearLayoutManager;
                int indexOfChild = this.containerView.indexOfChild(recyclerListViewArr[0]);
                int indexOfChild2 = this.containerView.indexOfChild(this.listView[1]);
                if (i == 1) {
                    if (indexOfChild < indexOfChild2) {
                        this.containerView.removeView(this.listView[0]);
                        this.containerView.addView(this.listView[0], indexOfChild2);
                    }
                } else if (indexOfChild2 < indexOfChild) {
                    this.containerView.removeView(this.listView[0]);
                    this.containerView.addView(this.listView[0], indexOfChild);
                }
                this.pageSwitchAnimation = new AnimatorSet();
                this.listView[0].setVisibility(0);
                final int i3 = i == 1 ? 0 : 1;
                this.listView[i3].setBackgroundColor(this.backgroundPaint.getColor());
                if (Build.VERSION.SDK_INT >= 18) {
                    this.listView[i3].setLayerType(2, null);
                }
                if (i == 1) {
                    this.pageSwitchAnimation.playTogether(ObjectAnimator.ofFloat(this.listView[0], View.TRANSLATION_X, (float) AndroidUtilities.dp(56.0f), 0.0f), ObjectAnimator.ofFloat(this.listView[0], View.ALPHA, 0.0f, 1.0f));
                } else if (i == -1) {
                    this.listView[0].setAlpha(1.0f);
                    this.listView[0].setTranslationX(0.0f);
                    this.pageSwitchAnimation.playTogether(ObjectAnimator.ofFloat(this.listView[1], View.TRANSLATION_X, 0.0f, (float) AndroidUtilities.dp(56.0f)), ObjectAnimator.ofFloat(this.listView[1], View.ALPHA, 1.0f, 0.0f));
                }
                this.pageSwitchAnimation.setDuration(150L);
                this.pageSwitchAnimation.setInterpolator(this.interpolator);
                this.pageSwitchAnimation.addListener(new AnimatorListenerAdapter() {
                    /* class im.guobwnxjuc.ui.ArticleViewer.AnonymousClass2 */

                    public void onAnimationEnd(Animator animator) {
                        ArticleViewer.this.listView[1].setVisibility(8);
                        ArticleViewer.this.listView[i3].setBackgroundDrawable(null);
                        if (Build.VERSION.SDK_INT >= 18) {
                            ArticleViewer.this.listView[i3].setLayerType(0, null);
                        }
                        ArticleViewer.this.pageSwitchAnimation = null;
                    }
                });
                this.pageSwitchAnimation.start();
            }
            this.headerView.invalidate();
            this.adapter[0].cleanup();
            int size = this.currentPage.cached_page.blocks.size();
            int i4 = 0;
            while (i4 < size) {
                TLRPC.PageBlock pageBlock = this.currentPage.cached_page.blocks.get(i4);
                if (i4 == 0) {
                    pageBlock.first = true;
                    if (pageBlock instanceof TLRPC.TL_pageBlockCover) {
                        TLRPC.TL_pageBlockCover tL_pageBlockCover = (TLRPC.TL_pageBlockCover) pageBlock;
                        TLRPC.RichText blockCaption = getBlockCaption(tL_pageBlockCover, 0);
                        TLRPC.RichText blockCaption2 = getBlockCaption(tL_pageBlockCover, 1);
                        if (((blockCaption != null && !(blockCaption instanceof TLRPC.TL_textEmpty)) || (blockCaption2 != null && !(blockCaption2 instanceof TLRPC.TL_textEmpty))) && size > 1) {
                            TLRPC.PageBlock pageBlock2 = this.currentPage.cached_page.blocks.get(1);
                            if (pageBlock2 instanceof TLRPC.TL_pageBlockChannel) {
                                this.channelBlock = (TLRPC.TL_pageBlockChannel) pageBlock2;
                            }
                        }
                    }
                } else if (i4 == 1 && this.channelBlock != null) {
                    i4++;
                }
                this.adapter[0].addBlock(pageBlock, 0, 0, i4 == size + -1 ? i4 : 0);
                i4++;
            }
            this.adapter[0].notifyDataSetChanged();
            if (this.pagesStack.size() == 1 || i == -1) {
                SharedPreferences sharedPreferences = ApplicationLoader.applicationContext.getSharedPreferences("articles", 0);
                String str = "article" + this.currentPage.id;
                int i5 = sharedPreferences.getInt(str, -1);
                boolean z2 = sharedPreferences.getBoolean(str + "r", true);
                if (AndroidUtilities.displaySize.x <= AndroidUtilities.displaySize.y) {
                    z = false;
                }
                if (z2 == z) {
                    i2 = sharedPreferences.getInt(str + "o", 0) - this.listView[0].getPaddingTop();
                } else {
                    i2 = AndroidUtilities.dp(10.0f);
                }
                if (i5 != -1) {
                    this.layoutManager[0].scrollToPositionWithOffset(i5, i2);
                }
            } else {
                this.layoutManager[0].scrollToPositionWithOffset(0, 0);
            }
            checkScrollAnimated();
        }
    }

    private boolean addPageToStack(TLRPC.WebPage webPage, String str, int i) {
        saveCurrentPagePosition();
        this.currentPage = webPage;
        this.pagesStack.add(webPage);
        updateInterfaceForCurrentPage(i);
        return scrollToAnchor(str);
    }

    private boolean scrollToAnchor(String str) {
        Integer num = 0;
        if (TextUtils.isEmpty(str)) {
            return false;
        }
        String lowerCase = str.toLowerCase();
        Integer num2 = (Integer) this.adapter[0].anchors.get(lowerCase);
        if (num2 != null) {
            TLRPC.TL_textAnchor tL_textAnchor = (TLRPC.TL_textAnchor) this.adapter[0].anchorsParent.get(lowerCase);
            if (tL_textAnchor != null) {
                TLRPC.TL_pageBlockParagraph tL_pageBlockParagraph = new TLRPC.TL_pageBlockParagraph();
                tL_pageBlockParagraph.text = tL_textAnchor.text;
                int typeForBlock = this.adapter[0].getTypeForBlock(tL_pageBlockParagraph);
                RecyclerView.ViewHolder onCreateViewHolder = this.adapter[0].onCreateViewHolder(null, typeForBlock);
                this.adapter[0].bindBlockToHolder(typeForBlock, onCreateViewHolder, tL_pageBlockParagraph, 0, 0);
                BottomSheet.Builder builder = new BottomSheet.Builder(this.parentActivity);
                builder.setUseFullscreen(true);
                builder.setApplyTopPadding(false);
                LinearLayout linearLayout = new LinearLayout(this.parentActivity);
                linearLayout.setOrientation(1);
                AnonymousClass3 r3 = new TextView(this.parentActivity) {
                    /* class im.guobwnxjuc.ui.ArticleViewer.AnonymousClass3 */

                    /* access modifiers changed from: protected */
                    public void onDraw(Canvas canvas) {
                        canvas.drawLine(0.0f, (float) (getMeasuredHeight() - 1), (float) getMeasuredWidth(), (float) (getMeasuredHeight() - 1), ArticleViewer.dividerPaint);
                        super.onDraw(canvas);
                    }
                };
                r3.setTextSize(1, 16.0f);
                r3.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
                r3.setText(LocaleController.getString("InstantViewReference", R.string.InstantViewReference));
                r3.setGravity((this.isRtl ? 5 : 3) | 16);
                r3.setTextColor(getTextColor());
                r3.setPadding(AndroidUtilities.dp(18.0f), 0, AndroidUtilities.dp(18.0f), 0);
                linearLayout.addView(r3, new LinearLayout.LayoutParams(-1, AndroidUtilities.dp(48.0f) + 1));
                linearLayout.addView(onCreateViewHolder.itemView, LayoutHelper.createLinear(-1, -2, 0.0f, 7.0f, 0.0f, 0.0f));
                builder.setCustomView(linearLayout);
                BottomSheet create = builder.create();
                this.linkSheet = create;
                int i = this.selectedColor;
                if (i == 0) {
                    create.setBackgroundColor(-1);
                } else if (i == 1) {
                    create.setBackgroundColor(-659492);
                } else if (i == 2) {
                    create.setBackgroundColor(-15461356);
                }
                showDialog(this.linkSheet);
                return true;
            } else if (num2.intValue() >= 0 && num2.intValue() < this.adapter[0].blocks.size()) {
                TLRPC.PageBlock pageBlock = (TLRPC.PageBlock) this.adapter[0].blocks.get(num2.intValue());
                TLRPC.PageBlock lastNonListPageBlock = getLastNonListPageBlock(pageBlock);
                if ((lastNonListPageBlock instanceof TL_pageBlockDetailsChild) && openAllParentBlocks((TL_pageBlockDetailsChild) lastNonListPageBlock)) {
                    this.adapter[0].updateRows();
                    this.adapter[0].notifyDataSetChanged();
                }
                int indexOf = this.adapter[0].localBlocks.indexOf(pageBlock);
                if (indexOf != -1) {
                    num2 = Integer.valueOf(indexOf);
                }
                Integer num3 = (Integer) this.adapter[0].anchorsOffset.get(lowerCase);
                if (num3 != null) {
                    if (num3.intValue() == -1) {
                        int typeForBlock2 = this.adapter[0].getTypeForBlock(pageBlock);
                        RecyclerView.ViewHolder onCreateViewHolder2 = this.adapter[0].onCreateViewHolder(null, typeForBlock2);
                        this.adapter[0].bindBlockToHolder(typeForBlock2, onCreateViewHolder2, pageBlock, 0, 0);
                        onCreateViewHolder2.itemView.measure(View.MeasureSpec.makeMeasureSpec(this.listView[0].getMeasuredWidth(), 1073741824), View.MeasureSpec.makeMeasureSpec(0, 0));
                        Integer num4 = (Integer) this.adapter[0].anchorsOffset.get(lowerCase);
                        if (num4.intValue() != -1) {
                            num = num4;
                        }
                    } else {
                        num = num3;
                    }
                }
                this.layoutManager[0].scrollToPositionWithOffset(num2.intValue(), (this.currentHeaderHeight - AndroidUtilities.dp(56.0f)) - num.intValue());
                return true;
            }
        }
        return false;
    }

    private boolean removeLastPageFromStack() {
        if (this.pagesStack.size() < 2) {
            return false;
        }
        ArrayList<TLRPC.WebPage> arrayList = this.pagesStack;
        arrayList.remove(arrayList.size() - 1);
        ArrayList<TLRPC.WebPage> arrayList2 = this.pagesStack;
        this.currentPage = arrayList2.get(arrayList2.size() - 1);
        updateInterfaceForCurrentPage(-1);
        return true;
    }

    /* access modifiers changed from: protected */
    public void startCheckLongPress() {
        if (!this.checkingForLongPress) {
            this.checkingForLongPress = true;
            if (this.pendingCheckForTap == null) {
                this.pendingCheckForTap = new CheckForTap();
            }
            this.windowView.postDelayed(this.pendingCheckForTap, (long) ViewConfiguration.getTapTimeout());
        }
    }

    /* access modifiers changed from: protected */
    public void cancelCheckLongPress() {
        this.checkingForLongPress = false;
        CheckForLongPress checkForLongPress = this.pendingCheckForLongPress;
        if (checkForLongPress != null) {
            this.windowView.removeCallbacks(checkForLongPress);
            this.pendingCheckForLongPress = null;
        }
        CheckForTap checkForTap = this.pendingCheckForTap;
        if (checkForTap != null) {
            this.windowView.removeCallbacks(checkForTap);
            this.pendingCheckForTap = null;
        }
    }

    private int getTextFlags(TLRPC.RichText richText) {
        if (richText instanceof TLRPC.TL_textFixed) {
            return getTextFlags(richText.parentRichText) | 4;
        }
        if (richText instanceof TLRPC.TL_textItalic) {
            return getTextFlags(richText.parentRichText) | 2;
        }
        if (richText instanceof TLRPC.TL_textBold) {
            return getTextFlags(richText.parentRichText) | 1;
        }
        if (richText instanceof TLRPC.TL_textUnderline) {
            return getTextFlags(richText.parentRichText) | 16;
        }
        if (richText instanceof TLRPC.TL_textStrike) {
            return getTextFlags(richText.parentRichText) | 32;
        }
        if (richText instanceof TLRPC.TL_textEmail) {
            return getTextFlags(richText.parentRichText) | 8;
        }
        if (richText instanceof TLRPC.TL_textPhone) {
            return getTextFlags(richText.parentRichText) | 8;
        }
        if (richText instanceof TLRPC.TL_textUrl) {
            if (((TLRPC.TL_textUrl) richText).webpage_id != 0) {
                return getTextFlags(richText.parentRichText) | 512;
            }
            return getTextFlags(richText.parentRichText) | 8;
        } else if (richText instanceof TLRPC.TL_textSubscript) {
            return getTextFlags(richText.parentRichText) | 128;
        } else {
            if (richText instanceof TLRPC.TL_textSuperscript) {
                return getTextFlags(richText.parentRichText) | 256;
            }
            if (richText instanceof TLRPC.TL_textMarked) {
                return getTextFlags(richText.parentRichText) | 64;
            }
            if (richText != null) {
                return getTextFlags(richText.parentRichText);
            }
            return 0;
        }
    }

    private TLRPC.RichText getLastRichText(TLRPC.RichText richText) {
        if (richText == null) {
            return null;
        }
        if (richText instanceof TLRPC.TL_textFixed) {
            return getLastRichText(((TLRPC.TL_textFixed) richText).text);
        }
        if (richText instanceof TLRPC.TL_textItalic) {
            return getLastRichText(((TLRPC.TL_textItalic) richText).text);
        }
        if (richText instanceof TLRPC.TL_textBold) {
            return getLastRichText(((TLRPC.TL_textBold) richText).text);
        }
        if (richText instanceof TLRPC.TL_textUnderline) {
            return getLastRichText(((TLRPC.TL_textUnderline) richText).text);
        }
        if (richText instanceof TLRPC.TL_textStrike) {
            return getLastRichText(((TLRPC.TL_textStrike) richText).text);
        }
        if (richText instanceof TLRPC.TL_textEmail) {
            return getLastRichText(((TLRPC.TL_textEmail) richText).text);
        }
        if (richText instanceof TLRPC.TL_textUrl) {
            return getLastRichText(((TLRPC.TL_textUrl) richText).text);
        }
        if (richText instanceof TLRPC.TL_textAnchor) {
            getLastRichText(((TLRPC.TL_textAnchor) richText).text);
            return richText;
        } else if (richText instanceof TLRPC.TL_textSubscript) {
            return getLastRichText(((TLRPC.TL_textSubscript) richText).text);
        } else {
            if (richText instanceof TLRPC.TL_textSuperscript) {
                return getLastRichText(((TLRPC.TL_textSuperscript) richText).text);
            }
            if (richText instanceof TLRPC.TL_textMarked) {
                return getLastRichText(((TLRPC.TL_textMarked) richText).text);
            }
            return richText instanceof TLRPC.TL_textPhone ? getLastRichText(((TLRPC.TL_textPhone) richText).text) : richText;
        }
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private CharSequence getText(View view, TLRPC.RichText richText, TLRPC.RichText richText2, TLRPC.PageBlock pageBlock, int i) {
        int i2;
        int i3;
        Object obj;
        Object obj2;
        TextPaint textPaint = null;
        if (richText2 == null) {
            return null;
        }
        if (richText2 instanceof TLRPC.TL_textFixed) {
            return getText(view, richText, ((TLRPC.TL_textFixed) richText2).text, pageBlock, i);
        }
        if (richText2 instanceof TLRPC.TL_textItalic) {
            return getText(view, richText, ((TLRPC.TL_textItalic) richText2).text, pageBlock, i);
        }
        if (richText2 instanceof TLRPC.TL_textBold) {
            return getText(view, richText, ((TLRPC.TL_textBold) richText2).text, pageBlock, i);
        }
        if (richText2 instanceof TLRPC.TL_textUnderline) {
            return getText(view, richText, ((TLRPC.TL_textUnderline) richText2).text, pageBlock, i);
        }
        if (richText2 instanceof TLRPC.TL_textStrike) {
            return getText(view, richText, ((TLRPC.TL_textStrike) richText2).text, pageBlock, i);
        }
        if (richText2 instanceof TLRPC.TL_textEmail) {
            SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(getText(view, richText, ((TLRPC.TL_textEmail) richText2).text, pageBlock, i));
            MetricAffectingSpan[] metricAffectingSpanArr = (MetricAffectingSpan[]) spannableStringBuilder.getSpans(0, spannableStringBuilder.length(), MetricAffectingSpan.class);
            if (spannableStringBuilder.length() != 0) {
                if (metricAffectingSpanArr == null || metricAffectingSpanArr.length == 0) {
                    textPaint = getTextPaint(richText, richText2, pageBlock);
                }
                spannableStringBuilder.setSpan(new TextPaintUrlSpan(textPaint, "mailto:" + getUrl(richText2)), 0, spannableStringBuilder.length(), 33);
            }
            return spannableStringBuilder;
        }
        long j = 0;
        if (richText2 instanceof TLRPC.TL_textUrl) {
            TLRPC.TL_textUrl tL_textUrl = (TLRPC.TL_textUrl) richText2;
            SpannableStringBuilder spannableStringBuilder2 = new SpannableStringBuilder(getText(view, richText, tL_textUrl.text, pageBlock, i));
            MetricAffectingSpan[] metricAffectingSpanArr2 = (MetricAffectingSpan[]) spannableStringBuilder2.getSpans(0, spannableStringBuilder2.length(), MetricAffectingSpan.class);
            TextPaint textPaint2 = (metricAffectingSpanArr2 == null || metricAffectingSpanArr2.length == 0) ? getTextPaint(richText, richText2, pageBlock) : null;
            if (tL_textUrl.webpage_id != 0) {
                obj2 = new TextPaintWebpageUrlSpan(textPaint2, getUrl(richText2));
            } else {
                obj2 = new TextPaintUrlSpan(textPaint2, getUrl(richText2));
            }
            if (spannableStringBuilder2.length() != 0) {
                spannableStringBuilder2.setSpan(obj2, 0, spannableStringBuilder2.length(), 33);
            }
            return spannableStringBuilder2;
        } else if (richText2 instanceof TLRPC.TL_textPlain) {
            return ((TLRPC.TL_textPlain) richText2).text;
        } else {
            if (richText2 instanceof TLRPC.TL_textAnchor) {
                TLRPC.TL_textAnchor tL_textAnchor = (TLRPC.TL_textAnchor) richText2;
                SpannableStringBuilder spannableStringBuilder3 = new SpannableStringBuilder(getText(view, richText, tL_textAnchor.text, pageBlock, i));
                spannableStringBuilder3.setSpan(new AnchorSpan(tL_textAnchor.name), 0, spannableStringBuilder3.length(), 17);
                return spannableStringBuilder3;
            } else if (richText2 instanceof TLRPC.TL_textEmpty) {
                return "";
            } else {
                int i4 = 1;
                if (richText2 instanceof TLRPC.TL_textConcat) {
                    SpannableStringBuilder spannableStringBuilder4 = new SpannableStringBuilder();
                    int size = richText2.texts.size();
                    int i5 = 0;
                    while (i5 < size) {
                        TLRPC.RichText richText3 = richText2.texts.get(i5);
                        TLRPC.RichText lastRichText = getLastRichText(richText3);
                        boolean z = i >= 0 && (richText3 instanceof TLRPC.TL_textUrl) && ((TLRPC.TL_textUrl) richText3).webpage_id != j;
                        if (!(!z || spannableStringBuilder4.length() == 0 || spannableStringBuilder4.charAt(spannableStringBuilder4.length() - i4) == '\n')) {
                            spannableStringBuilder4.append((CharSequence) " ");
                        }
                        CharSequence text = getText(view, richText, richText3, pageBlock, i);
                        int textFlags = getTextFlags(lastRichText);
                        int length = spannableStringBuilder4.length();
                        spannableStringBuilder4.append(text);
                        if (textFlags != 0 && !(text instanceof SpannableStringBuilder)) {
                            if ((textFlags & 8) != 0 || (textFlags & 512) != 0) {
                                String url = getUrl(richText3);
                                if (url == null) {
                                    url = getUrl(richText);
                                }
                                if ((textFlags & 512) != 0) {
                                    obj = new TextPaintWebpageUrlSpan(getTextPaint(richText, lastRichText, pageBlock), url);
                                } else {
                                    obj = new TextPaintUrlSpan(getTextPaint(richText, lastRichText, pageBlock), url);
                                }
                                if (length != spannableStringBuilder4.length()) {
                                    spannableStringBuilder4.setSpan(obj, length, spannableStringBuilder4.length(), 33);
                                }
                            } else if (length != spannableStringBuilder4.length()) {
                                spannableStringBuilder4.setSpan(new TextPaintSpan(getTextPaint(richText, lastRichText, pageBlock)), length, spannableStringBuilder4.length(), 33);
                            }
                        }
                        if (z && i5 != size - 1) {
                            spannableStringBuilder4.append((CharSequence) " ");
                        }
                        i5++;
                        size = size;
                        i4 = 1;
                        j = 0;
                    }
                    return spannableStringBuilder4;
                } else if (richText2 instanceof TLRPC.TL_textSubscript) {
                    return getText(view, richText, ((TLRPC.TL_textSubscript) richText2).text, pageBlock, i);
                } else {
                    if (richText2 instanceof TLRPC.TL_textSuperscript) {
                        return getText(view, richText, ((TLRPC.TL_textSuperscript) richText2).text, pageBlock, i);
                    }
                    if (richText2 instanceof TLRPC.TL_textMarked) {
                        SpannableStringBuilder spannableStringBuilder5 = new SpannableStringBuilder(getText(view, richText, ((TLRPC.TL_textMarked) richText2).text, pageBlock, i));
                        MetricAffectingSpan[] metricAffectingSpanArr3 = (MetricAffectingSpan[]) spannableStringBuilder5.getSpans(0, spannableStringBuilder5.length(), MetricAffectingSpan.class);
                        if (spannableStringBuilder5.length() != 0) {
                            spannableStringBuilder5.setSpan(new TextPaintMarkSpan((metricAffectingSpanArr3 == null || metricAffectingSpanArr3.length == 0) ? getTextPaint(richText, richText2, pageBlock) : null), 0, spannableStringBuilder5.length(), 33);
                        }
                        return spannableStringBuilder5;
                    } else if (richText2 instanceof TLRPC.TL_textPhone) {
                        SpannableStringBuilder spannableStringBuilder6 = new SpannableStringBuilder(getText(view, richText, ((TLRPC.TL_textPhone) richText2).text, pageBlock, i));
                        MetricAffectingSpan[] metricAffectingSpanArr4 = (MetricAffectingSpan[]) spannableStringBuilder6.getSpans(0, spannableStringBuilder6.length(), MetricAffectingSpan.class);
                        if (spannableStringBuilder6.length() != 0) {
                            TextPaint textPaint3 = (metricAffectingSpanArr4 == null || metricAffectingSpanArr4.length == 0) ? getTextPaint(richText, richText2, pageBlock) : null;
                            spannableStringBuilder6.setSpan(new TextPaintUrlSpan(textPaint3, "tel:" + getUrl(richText2)), 0, spannableStringBuilder6.length(), 33);
                        }
                        return spannableStringBuilder6;
                    } else if (richText2 instanceof TLRPC.TL_textImage) {
                        TLRPC.TL_textImage tL_textImage = (TLRPC.TL_textImage) richText2;
                        TLRPC.Document documentWithId = getDocumentWithId(tL_textImage.document_id);
                        if (documentWithId == null) {
                            return "";
                        }
                        SpannableStringBuilder spannableStringBuilder7 = new SpannableStringBuilder("*");
                        int dp = AndroidUtilities.dp((float) tL_textImage.w);
                        int dp2 = AndroidUtilities.dp((float) tL_textImage.h);
                        int abs = Math.abs(i);
                        if (dp > abs) {
                            i2 = (int) (((float) dp2) * (((float) abs) / ((float) dp)));
                            i3 = abs;
                        } else {
                            i2 = dp2;
                            i3 = dp;
                        }
                        spannableStringBuilder7.setSpan(new TextPaintImageReceiverSpan(view, documentWithId, this.currentPage, i3, i2, false, this.selectedColor == 2), 0, spannableStringBuilder7.length(), 33);
                        return spannableStringBuilder7;
                    } else {
                        return "not supported " + richText2;
                    }
                }
            }
        }
    }

    public static CharSequence getPlainText(TLRPC.RichText richText) {
        if (richText == null) {
            return "";
        }
        if (richText instanceof TLRPC.TL_textFixed) {
            return getPlainText(((TLRPC.TL_textFixed) richText).text);
        }
        if (richText instanceof TLRPC.TL_textItalic) {
            return getPlainText(((TLRPC.TL_textItalic) richText).text);
        }
        if (richText instanceof TLRPC.TL_textBold) {
            return getPlainText(((TLRPC.TL_textBold) richText).text);
        }
        if (richText instanceof TLRPC.TL_textUnderline) {
            return getPlainText(((TLRPC.TL_textUnderline) richText).text);
        }
        if (richText instanceof TLRPC.TL_textStrike) {
            return getPlainText(((TLRPC.TL_textStrike) richText).text);
        }
        if (richText instanceof TLRPC.TL_textEmail) {
            return getPlainText(((TLRPC.TL_textEmail) richText).text);
        }
        if (richText instanceof TLRPC.TL_textUrl) {
            return getPlainText(((TLRPC.TL_textUrl) richText).text);
        }
        if (richText instanceof TLRPC.TL_textPlain) {
            return ((TLRPC.TL_textPlain) richText).text;
        }
        if (richText instanceof TLRPC.TL_textAnchor) {
            return getPlainText(((TLRPC.TL_textAnchor) richText).text);
        }
        if (richText instanceof TLRPC.TL_textEmpty) {
            return "";
        }
        if (richText instanceof TLRPC.TL_textConcat) {
            StringBuilder sb = new StringBuilder();
            int size = richText.texts.size();
            for (int i = 0; i < size; i++) {
                sb.append(getPlainText(richText.texts.get(i)));
            }
            return sb;
        } else if (richText instanceof TLRPC.TL_textSubscript) {
            return getPlainText(((TLRPC.TL_textSubscript) richText).text);
        } else {
            if (richText instanceof TLRPC.TL_textSuperscript) {
                return getPlainText(((TLRPC.TL_textSuperscript) richText).text);
            }
            if (richText instanceof TLRPC.TL_textMarked) {
                return getPlainText(((TLRPC.TL_textMarked) richText).text);
            }
            if (richText instanceof TLRPC.TL_textPhone) {
                return getPlainText(((TLRPC.TL_textPhone) richText).text);
            }
            if (richText instanceof TLRPC.TL_textImage) {
            }
            return "";
        }
    }

    public static String getUrl(TLRPC.RichText richText) {
        if (richText instanceof TLRPC.TL_textFixed) {
            return getUrl(((TLRPC.TL_textFixed) richText).text);
        }
        if (richText instanceof TLRPC.TL_textItalic) {
            return getUrl(((TLRPC.TL_textItalic) richText).text);
        }
        if (richText instanceof TLRPC.TL_textBold) {
            return getUrl(((TLRPC.TL_textBold) richText).text);
        }
        if (richText instanceof TLRPC.TL_textUnderline) {
            return getUrl(((TLRPC.TL_textUnderline) richText).text);
        }
        if (richText instanceof TLRPC.TL_textStrike) {
            return getUrl(((TLRPC.TL_textStrike) richText).text);
        }
        if (richText instanceof TLRPC.TL_textEmail) {
            return ((TLRPC.TL_textEmail) richText).email;
        }
        if (richText instanceof TLRPC.TL_textUrl) {
            return ((TLRPC.TL_textUrl) richText).url;
        }
        if (richText instanceof TLRPC.TL_textPhone) {
            return ((TLRPC.TL_textPhone) richText).phone;
        }
        return null;
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private int getTextColor() {
        int selectedColor2 = getSelectedColor();
        return (selectedColor2 == 0 || selectedColor2 == 1) ? -14606047 : -6710887;
    }

    private int getInstantLinkBackgroundColor() {
        int selectedColor2 = getSelectedColor();
        if (selectedColor2 != 0) {
            return selectedColor2 != 1 ? -14536904 : -2498337;
        }
        return -1707782;
    }

    private int getLinkTextColor() {
        int selectedColor2 = getSelectedColor();
        if (selectedColor2 != 0) {
            return selectedColor2 != 1 ? -10838585 : -13471296;
        }
        return -15435321;
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private int getGrayTextColor() {
        int selectedColor2 = getSelectedColor();
        if (selectedColor2 != 0) {
            return selectedColor2 != 1 ? -10066330 : -11711675;
        }
        return -8156010;
    }

    /* JADX WARNING: Removed duplicated region for block: B:144:0x02d0  */
    /* JADX WARNING: Removed duplicated region for block: B:149:0x02eb  */
    /* JADX WARNING: Removed duplicated region for block: B:14:0x0044  */
    /* JADX WARNING: Removed duplicated region for block: B:21:0x0069  */
    private TextPaint getTextPaint(TLRPC.RichText richText, TLRPC.RichText richText2, TLRPC.PageBlock pageBlock) {
        int i;
        SparseArray<TextPaint> sparseArray;
        int i2;
        SparseArray<TextPaint> sparseArray2;
        int dp;
        int textColor;
        int i3;
        SparseArray<TextPaint> sparseArray3;
        int i4;
        SparseArray<TextPaint> sparseArray4;
        int i5;
        SparseArray<TextPaint> sparseArray5;
        int i6;
        SparseArray<TextPaint> sparseArray6;
        int i7;
        SparseArray<TextPaint> sparseArray7;
        int dp2;
        int textFlags = getTextFlags(richText2);
        int dp3 = AndroidUtilities.dp(14.0f);
        int i8 = this.selectedFontSize;
        if (i8 == 0) {
            dp2 = AndroidUtilities.dp(4.0f);
        } else if (i8 == 1) {
            dp2 = AndroidUtilities.dp(2.0f);
        } else {
            if (i8 == 3) {
                i = AndroidUtilities.dp(2.0f);
            } else {
                i = i8 == 4 ? AndroidUtilities.dp(4.0f) : 0;
            }
            SparseArray<TextPaint> sparseArray8 = null;
            if (!(pageBlock instanceof TLRPC.TL_pageBlockPhoto)) {
                TLRPC.TL_pageBlockPhoto tL_pageBlockPhoto = (TLRPC.TL_pageBlockPhoto) pageBlock;
                if (tL_pageBlockPhoto.caption.text == richText2 || tL_pageBlockPhoto.caption.text == richText) {
                    sparseArray7 = photoCaptionTextPaints;
                    i7 = AndroidUtilities.dp(14.0f);
                } else {
                    sparseArray7 = photoCreditTextPaints;
                    i7 = AndroidUtilities.dp(12.0f);
                }
                sparseArray8 = sparseArray7;
                dp3 = i7;
                i2 = getGrayTextColor();
            } else if (pageBlock instanceof TLRPC.TL_pageBlockMap) {
                TLRPC.TL_pageBlockMap tL_pageBlockMap = (TLRPC.TL_pageBlockMap) pageBlock;
                if (tL_pageBlockMap.caption.text == richText2 || tL_pageBlockMap.caption.text == richText) {
                    sparseArray6 = photoCaptionTextPaints;
                    i6 = AndroidUtilities.dp(14.0f);
                } else {
                    sparseArray6 = photoCreditTextPaints;
                    i6 = AndroidUtilities.dp(12.0f);
                }
                sparseArray8 = sparseArray6;
                dp3 = i6;
                i2 = getGrayTextColor();
            } else if (pageBlock instanceof TLRPC.TL_pageBlockTitle) {
                sparseArray8 = titleTextPaints;
                dp3 = AndroidUtilities.dp(24.0f);
                i2 = getTextColor();
            } else if (pageBlock instanceof TLRPC.TL_pageBlockKicker) {
                sparseArray8 = kickerTextPaints;
                dp3 = AndroidUtilities.dp(14.0f);
                i2 = getTextColor();
            } else if (pageBlock instanceof TLRPC.TL_pageBlockAuthorDate) {
                sparseArray8 = authorTextPaints;
                dp3 = AndroidUtilities.dp(14.0f);
                i2 = getGrayTextColor();
            } else if (pageBlock instanceof TLRPC.TL_pageBlockFooter) {
                sparseArray8 = footerTextPaints;
                dp3 = AndroidUtilities.dp(14.0f);
                i2 = getGrayTextColor();
            } else if (pageBlock instanceof TLRPC.TL_pageBlockSubtitle) {
                sparseArray8 = subtitleTextPaints;
                dp3 = AndroidUtilities.dp(21.0f);
                i2 = getTextColor();
            } else if (pageBlock instanceof TLRPC.TL_pageBlockHeader) {
                sparseArray8 = headerTextPaints;
                dp3 = AndroidUtilities.dp(21.0f);
                i2 = getTextColor();
            } else if (pageBlock instanceof TLRPC.TL_pageBlockSubheader) {
                sparseArray8 = subheaderTextPaints;
                dp3 = AndroidUtilities.dp(18.0f);
                i2 = getTextColor();
            } else {
                if (pageBlock instanceof TLRPC.TL_pageBlockBlockquote) {
                    TLRPC.TL_pageBlockBlockquote tL_pageBlockBlockquote = (TLRPC.TL_pageBlockBlockquote) pageBlock;
                    if (tL_pageBlockBlockquote.text == richText) {
                        sparseArray8 = quoteTextPaints;
                        dp3 = AndroidUtilities.dp(15.0f);
                        i2 = getTextColor();
                    } else if (tL_pageBlockBlockquote.caption == richText) {
                        sparseArray8 = photoCaptionTextPaints;
                        dp3 = AndroidUtilities.dp(14.0f);
                        i2 = getGrayTextColor();
                    }
                } else if (pageBlock instanceof TLRPC.TL_pageBlockPullquote) {
                    TLRPC.TL_pageBlockPullquote tL_pageBlockPullquote = (TLRPC.TL_pageBlockPullquote) pageBlock;
                    if (tL_pageBlockPullquote.text == richText) {
                        sparseArray8 = quoteTextPaints;
                        dp3 = AndroidUtilities.dp(15.0f);
                        i2 = getTextColor();
                    } else if (tL_pageBlockPullquote.caption == richText) {
                        sparseArray8 = photoCaptionTextPaints;
                        dp3 = AndroidUtilities.dp(14.0f);
                        i2 = getGrayTextColor();
                    }
                } else if (pageBlock instanceof TLRPC.TL_pageBlockPreformatted) {
                    sparseArray8 = preformattedTextPaints;
                    dp3 = AndroidUtilities.dp(14.0f);
                    i2 = getTextColor();
                } else if (pageBlock instanceof TLRPC.TL_pageBlockParagraph) {
                    sparseArray8 = paragraphTextPaints;
                    dp3 = AndroidUtilities.dp(16.0f);
                    i2 = getTextColor();
                } else if (isListItemBlock(pageBlock)) {
                    sparseArray8 = listTextPaints;
                    dp3 = AndroidUtilities.dp(16.0f);
                    i2 = getTextColor();
                } else if (pageBlock instanceof TLRPC.TL_pageBlockEmbed) {
                    TLRPC.TL_pageBlockEmbed tL_pageBlockEmbed = (TLRPC.TL_pageBlockEmbed) pageBlock;
                    if (tL_pageBlockEmbed.caption.text == richText2 || tL_pageBlockEmbed.caption.text == richText) {
                        sparseArray5 = photoCaptionTextPaints;
                        i5 = AndroidUtilities.dp(14.0f);
                    } else {
                        sparseArray5 = photoCreditTextPaints;
                        i5 = AndroidUtilities.dp(12.0f);
                    }
                    sparseArray8 = sparseArray5;
                    dp3 = i5;
                    i2 = getGrayTextColor();
                } else if (pageBlock instanceof TLRPC.TL_pageBlockSlideshow) {
                    TLRPC.TL_pageBlockSlideshow tL_pageBlockSlideshow = (TLRPC.TL_pageBlockSlideshow) pageBlock;
                    if (tL_pageBlockSlideshow.caption.text == richText2 || tL_pageBlockSlideshow.caption.text == richText) {
                        sparseArray4 = photoCaptionTextPaints;
                        i4 = AndroidUtilities.dp(14.0f);
                    } else {
                        sparseArray4 = photoCreditTextPaints;
                        i4 = AndroidUtilities.dp(12.0f);
                    }
                    sparseArray8 = sparseArray4;
                    dp3 = i4;
                    i2 = getGrayTextColor();
                } else if (pageBlock instanceof TLRPC.TL_pageBlockCollage) {
                    TLRPC.TL_pageBlockCollage tL_pageBlockCollage = (TLRPC.TL_pageBlockCollage) pageBlock;
                    if (tL_pageBlockCollage.caption.text == richText2 || tL_pageBlockCollage.caption.text == richText) {
                        sparseArray3 = photoCaptionTextPaints;
                        i3 = AndroidUtilities.dp(14.0f);
                    } else {
                        sparseArray3 = photoCreditTextPaints;
                        i3 = AndroidUtilities.dp(12.0f);
                    }
                    sparseArray8 = sparseArray3;
                    dp3 = i3;
                    i2 = getGrayTextColor();
                } else if (pageBlock instanceof TLRPC.TL_pageBlockEmbedPost) {
                    TLRPC.TL_pageBlockEmbedPost tL_pageBlockEmbedPost = (TLRPC.TL_pageBlockEmbedPost) pageBlock;
                    if (richText2 == tL_pageBlockEmbedPost.caption.text) {
                        sparseArray8 = photoCaptionTextPaints;
                        dp3 = AndroidUtilities.dp(14.0f);
                        i2 = getGrayTextColor();
                    } else if (richText2 == tL_pageBlockEmbedPost.caption.credit) {
                        sparseArray8 = photoCreditTextPaints;
                        dp3 = AndroidUtilities.dp(12.0f);
                        i2 = getGrayTextColor();
                    } else if (richText2 != null) {
                        sparseArray8 = embedPostTextPaints;
                        dp3 = AndroidUtilities.dp(14.0f);
                        i2 = getTextColor();
                    }
                } else {
                    if (pageBlock instanceof TLRPC.TL_pageBlockVideo) {
                        if (richText2 == ((TLRPC.TL_pageBlockVideo) pageBlock).caption.text) {
                            sparseArray2 = mediaCaptionTextPaints;
                            dp = AndroidUtilities.dp(14.0f);
                            textColor = getTextColor();
                        } else {
                            sparseArray2 = mediaCreditTextPaints;
                            dp = AndroidUtilities.dp(12.0f);
                            textColor = getTextColor();
                        }
                    } else if (pageBlock instanceof TLRPC.TL_pageBlockAudio) {
                        if (richText2 == ((TLRPC.TL_pageBlockAudio) pageBlock).caption.text) {
                            sparseArray2 = mediaCaptionTextPaints;
                            dp = AndroidUtilities.dp(14.0f);
                            textColor = getTextColor();
                        } else {
                            sparseArray2 = mediaCreditTextPaints;
                            dp = AndroidUtilities.dp(12.0f);
                            textColor = getTextColor();
                        }
                    } else if (pageBlock instanceof TLRPC.TL_pageBlockRelatedArticles) {
                        sparseArray8 = relatedArticleTextPaints;
                        dp3 = AndroidUtilities.dp(15.0f);
                        i2 = getGrayTextColor();
                    } else if (pageBlock instanceof TLRPC.TL_pageBlockDetails) {
                        sparseArray8 = detailsTextPaints;
                        dp3 = AndroidUtilities.dp(15.0f);
                        i2 = getTextColor();
                    } else if (pageBlock instanceof TLRPC.TL_pageBlockTable) {
                        sparseArray8 = tableTextPaints;
                        dp3 = AndroidUtilities.dp(15.0f);
                        i2 = getTextColor();
                    } else {
                        sparseArray = null;
                        i2 = SupportMenu.CATEGORY_MASK;
                        int i9 = textFlags & 256;
                        if (!(i9 == 0 && (textFlags & 128) == 0)) {
                            dp3 -= AndroidUtilities.dp(4.0f);
                        }
                        if (sparseArray == null) {
                            if (errorTextPaint == null) {
                                TextPaint textPaint = new TextPaint(1);
                                errorTextPaint = textPaint;
                                textPaint.setColor(SupportMenu.CATEGORY_MASK);
                            }
                            errorTextPaint.setTextSize((float) AndroidUtilities.dp(14.0f));
                            return errorTextPaint;
                        }
                        TextPaint textPaint2 = sparseArray.get(textFlags);
                        if (textPaint2 == null) {
                            textPaint2 = new TextPaint(1);
                            if ((textFlags & 4) != 0) {
                                textPaint2.setTypeface(AndroidUtilities.getTypeface("fonts/rmono.ttf"));
                            } else if (pageBlock instanceof TLRPC.TL_pageBlockRelatedArticles) {
                                textPaint2.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
                            } else if (this.selectedFont == 1 || (pageBlock instanceof TLRPC.TL_pageBlockTitle) || (pageBlock instanceof TLRPC.TL_pageBlockKicker) || (pageBlock instanceof TLRPC.TL_pageBlockHeader) || (pageBlock instanceof TLRPC.TL_pageBlockSubtitle) || (pageBlock instanceof TLRPC.TL_pageBlockSubheader)) {
                                int i10 = textFlags & 1;
                                if (i10 != 0 && (textFlags & 2) != 0) {
                                    textPaint2.setTypeface(Typeface.create(C.SERIF_NAME, 3));
                                } else if (i10 != 0) {
                                    textPaint2.setTypeface(Typeface.create(C.SERIF_NAME, 1));
                                } else if ((textFlags & 2) != 0) {
                                    textPaint2.setTypeface(Typeface.create(C.SERIF_NAME, 2));
                                } else {
                                    textPaint2.setTypeface(Typeface.create(C.SERIF_NAME, 0));
                                }
                            } else {
                                int i11 = textFlags & 1;
                                if (i11 != 0 && (textFlags & 2) != 0) {
                                    textPaint2.setTypeface(AndroidUtilities.getTypeface("fonts/rmediumitalic.ttf"));
                                } else if (i11 != 0) {
                                    textPaint2.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
                                } else if ((textFlags & 2) != 0) {
                                    textPaint2.setTypeface(AndroidUtilities.getTypeface("fonts/ritalic.ttf"));
                                }
                            }
                            if ((textFlags & 32) != 0) {
                                textPaint2.setFlags(textPaint2.getFlags() | 16);
                            }
                            if ((textFlags & 16) != 0) {
                                textPaint2.setFlags(textPaint2.getFlags() | 8);
                            }
                            if (!((textFlags & 8) == 0 && (textFlags & 512) == 0)) {
                                textPaint2.setFlags(textPaint2.getFlags());
                                i2 = getLinkTextColor();
                            }
                            if (i9 != 0) {
                                textPaint2.baselineShift -= AndroidUtilities.dp(6.0f);
                            } else if ((textFlags & 128) != 0) {
                                textPaint2.baselineShift += AndroidUtilities.dp(2.0f);
                            }
                            textPaint2.setColor(i2);
                            sparseArray.put(textFlags, textPaint2);
                        }
                        textPaint2.setTextSize((float) (dp3 + i));
                        return textPaint2;
                    }
                    sparseArray8 = sparseArray2;
                    i2 = textColor;
                    dp3 = dp;
                }
                i2 = SupportMenu.CATEGORY_MASK;
            }
            sparseArray = sparseArray8;
            int i92 = textFlags & 256;
            dp3 -= AndroidUtilities.dp(4.0f);
            if (sparseArray == null) {
            }
        }
        i = -dp2;
        SparseArray<TextPaint> sparseArray82 = null;
        if (!(pageBlock instanceof TLRPC.TL_pageBlockPhoto)) {
        }
        sparseArray = sparseArray82;
        int i922 = textFlags & 256;
        dp3 -= AndroidUtilities.dp(4.0f);
        if (sparseArray == null) {
        }
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private DrawingText createLayoutForText(View view, CharSequence charSequence, TLRPC.RichText richText, int i, TLRPC.PageBlock pageBlock, WebpageAdapter webpageAdapter) {
        return createLayoutForText(view, charSequence, richText, i, 0, pageBlock, Layout.Alignment.ALIGN_NORMAL, 0, webpageAdapter);
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private DrawingText createLayoutForText(View view, CharSequence charSequence, TLRPC.RichText richText, int i, TLRPC.PageBlock pageBlock, Layout.Alignment alignment, WebpageAdapter webpageAdapter) {
        return createLayoutForText(view, charSequence, richText, i, 0, pageBlock, alignment, 0, webpageAdapter);
    }

    private DrawingText createLayoutForText(View view, CharSequence charSequence, TLRPC.RichText richText, int i, int i2, TLRPC.PageBlock pageBlock, WebpageAdapter webpageAdapter) {
        return createLayoutForText(view, charSequence, richText, i, i2, pageBlock, Layout.Alignment.ALIGN_NORMAL, 0, webpageAdapter);
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    /* JADX WARNING: Failed to process nested try/catch */
    /* JADX WARNING: Missing exception handler attribute for start block: B:142:0x02fe */
    /* JADX WARNING: Removed duplicated region for block: B:152:0x031b A[Catch:{ Exception -> 0x0358 }] */
    /* JADX WARNING: Removed duplicated region for block: B:48:0x00c8  */
    /* JADX WARNING: Removed duplicated region for block: B:56:0x00fc  */
    /* JADX WARNING: Removed duplicated region for block: B:86:0x01c9  */
    /* JADX WARNING: Removed duplicated region for block: B:90:0x01fc  */
    /* JADX WARNING: Removed duplicated region for block: B:98:0x023f A[RETURN] */
    /* JADX WARNING: Removed duplicated region for block: B:99:0x0240  */
    private DrawingText createLayoutForText(View view, CharSequence charSequence, TLRPC.RichText richText, int i, int i2, TLRPC.PageBlock pageBlock, Layout.Alignment alignment, int i3, WebpageAdapter webpageAdapter) {
        CharSequence charSequence2;
        int i4;
        TextPaint textPaint;
        StaticLayout staticLayout;
        LinkPath linkPath;
        LinkPath linkPath2;
        TextPaintMarkSpan[] textPaintMarkSpanArr;
        int i5;
        int dp;
        LinkPath linkPath3 = null;
        if (charSequence == null && (richText == null || (richText instanceof TLRPC.TL_textEmpty))) {
            return null;
        }
        int dp2 = i < 0 ? AndroidUtilities.dp(10.0f) : i;
        int selectedColor2 = getSelectedColor();
        if (charSequence != null) {
            charSequence2 = charSequence;
        } else {
            charSequence2 = getText(view, richText, richText, pageBlock, dp2);
        }
        if (TextUtils.isEmpty(charSequence2)) {
            return null;
        }
        int i6 = this.selectedFontSize;
        if (i6 == 0) {
            dp = AndroidUtilities.dp(4.0f);
        } else if (i6 == 1) {
            dp = AndroidUtilities.dp(2.0f);
        } else {
            if (i6 == 3) {
                i4 = AndroidUtilities.dp(2.0f);
            } else {
                i4 = i6 == 4 ? AndroidUtilities.dp(4.0f) : 0;
            }
            if ((pageBlock instanceof TLRPC.TL_pageBlockEmbedPost) || richText != null) {
                if (!(pageBlock instanceof TLRPC.TL_pageBlockChannel)) {
                    if (channelNamePaint == null) {
                        TextPaint textPaint2 = new TextPaint(1);
                        channelNamePaint = textPaint2;
                        textPaint2.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
                    }
                    if (this.channelBlock == null) {
                        channelNamePaint.setColor(getTextColor());
                    } else {
                        channelNamePaint.setColor(-1);
                    }
                    channelNamePaint.setTextSize((float) AndroidUtilities.dp(15.0f));
                    textPaint = channelNamePaint;
                } else if (pageBlock instanceof TL_pageBlockRelatedArticlesChild) {
                    TL_pageBlockRelatedArticlesChild tL_pageBlockRelatedArticlesChild = (TL_pageBlockRelatedArticlesChild) pageBlock;
                    if (charSequence == tL_pageBlockRelatedArticlesChild.parent.articles.get(tL_pageBlockRelatedArticlesChild.num).title) {
                        if (relatedArticleHeaderPaint == null) {
                            TextPaint textPaint3 = new TextPaint(1);
                            relatedArticleHeaderPaint = textPaint3;
                            textPaint3.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
                        }
                        relatedArticleHeaderPaint.setColor(getTextColor());
                        relatedArticleHeaderPaint.setTextSize((float) (AndroidUtilities.dp(15.0f) + i4));
                        textPaint = relatedArticleHeaderPaint;
                    } else {
                        if (relatedArticleTextPaint == null) {
                            relatedArticleTextPaint = new TextPaint(1);
                        }
                        relatedArticleTextPaint.setColor(getGrayTextColor());
                        relatedArticleTextPaint.setTextSize((float) (AndroidUtilities.dp(14.0f) + i4));
                        textPaint = relatedArticleTextPaint;
                    }
                } else if (!isListItemBlock(pageBlock) || charSequence == null) {
                    textPaint = getTextPaint(richText, richText, pageBlock);
                } else {
                    if (listTextPointerPaint == null) {
                        TextPaint textPaint4 = new TextPaint(1);
                        listTextPointerPaint = textPaint4;
                        textPaint4.setColor(getTextColor());
                    }
                    if (listTextNumPaint == null) {
                        TextPaint textPaint5 = new TextPaint(1);
                        listTextNumPaint = textPaint5;
                        textPaint5.setColor(getTextColor());
                    }
                    listTextPointerPaint.setTextSize((float) (AndroidUtilities.dp(19.0f) + i4));
                    listTextNumPaint.setTextSize((float) (AndroidUtilities.dp(16.0f) + i4));
                    if (!(pageBlock instanceof TL_pageBlockListItem) || ((TL_pageBlockListItem) pageBlock).parent.pageBlockList.ordered) {
                        textPaint = listTextNumPaint;
                    } else {
                        textPaint = listTextPointerPaint;
                    }
                }
            } else if (((TLRPC.TL_pageBlockEmbedPost) pageBlock).author == charSequence) {
                if (embedPostAuthorPaint == null) {
                    TextPaint textPaint6 = new TextPaint(1);
                    embedPostAuthorPaint = textPaint6;
                    textPaint6.setColor(getTextColor());
                }
                embedPostAuthorPaint.setTextSize((float) (AndroidUtilities.dp(15.0f) + i4));
                textPaint = embedPostAuthorPaint;
            } else {
                if (embedPostDatePaint == null) {
                    TextPaint textPaint7 = new TextPaint(1);
                    embedPostDatePaint = textPaint7;
                    if (selectedColor2 == 0) {
                        textPaint7.setColor(-7366752);
                    } else {
                        textPaint7.setColor(getGrayTextColor());
                    }
                }
                embedPostDatePaint.setTextSize((float) (AndroidUtilities.dp(14.0f) + i4));
                textPaint = embedPostDatePaint;
            }
            if (i3 != 0) {
                if (charSequence2.charAt(charSequence2.length() - 1) == '\n') {
                    charSequence2 = charSequence2.subSequence(0, charSequence2.length() - 1);
                }
                if (pageBlock instanceof TLRPC.TL_pageBlockPullquote) {
                    staticLayout = new StaticLayout(charSequence2, textPaint, dp2, Layout.Alignment.ALIGN_CENTER, 1.0f, 0.0f, false);
                } else {
                    staticLayout = new StaticLayout(charSequence2, textPaint, dp2, alignment, 1.0f, (float) AndroidUtilities.dp(4.0f), false);
                }
            } else if (pageBlock instanceof TLRPC.TL_pageBlockPullquote) {
                staticLayout = StaticLayoutEx.createStaticLayout(charSequence2, textPaint, dp2, Layout.Alignment.ALIGN_CENTER, 1.0f, 0.0f, false, TextUtils.TruncateAt.END, dp2, i3);
            } else {
                staticLayout = StaticLayoutEx.createStaticLayout(charSequence2, textPaint, dp2, alignment, 1.0f, (float) AndroidUtilities.dp(4.0f), false, TextUtils.TruncateAt.END, dp2, i3);
            }
            if (staticLayout != null) {
                return null;
            }
            CharSequence text = staticLayout.getText();
            if (staticLayout == null || !(text instanceof Spanned)) {
                linkPath = null;
            } else {
                Spanned spanned = (Spanned) text;
                try {
                    AnchorSpan[] anchorSpanArr = (AnchorSpan[]) spanned.getSpans(0, spanned.length(), AnchorSpan.class);
                    int lineCount = staticLayout.getLineCount();
                    if (anchorSpanArr != null && anchorSpanArr.length > 0) {
                        for (int i7 = 0; i7 < anchorSpanArr.length; i7++) {
                            if (lineCount <= 1) {
                                webpageAdapter.anchorsOffset.put(anchorSpanArr[i7].getName(), Integer.valueOf(i2));
                            } else {
                                webpageAdapter.anchorsOffset.put(anchorSpanArr[i7].getName(), Integer.valueOf(i2 + staticLayout.getLineTop(staticLayout.getLineForOffset(spanned.getSpanStart(anchorSpanArr[i7])))));
                            }
                        }
                    }
                } catch (Exception unused) {
                }
                try {
                    TextPaintWebpageUrlSpan[] textPaintWebpageUrlSpanArr = (TextPaintWebpageUrlSpan[]) spanned.getSpans(0, spanned.length(), TextPaintWebpageUrlSpan.class);
                    if (textPaintWebpageUrlSpanArr != null && textPaintWebpageUrlSpanArr.length > 0) {
                        linkPath2 = new LinkPath(true);
                        linkPath2.setAllowReset(false);
                        for (int i8 = 0; i8 < textPaintWebpageUrlSpanArr.length; i8++) {
                            int spanStart = spanned.getSpanStart(textPaintWebpageUrlSpanArr[i8]);
                            int spanEnd = spanned.getSpanEnd(textPaintWebpageUrlSpanArr[i8]);
                            linkPath2.setCurrentLayout(staticLayout, spanStart, 0.0f);
                            int i9 = textPaintWebpageUrlSpanArr[i8].getTextPaint() != null ? textPaintWebpageUrlSpanArr[i8].getTextPaint().baselineShift : 0;
                            linkPath2.setBaselineShift(i9 != 0 ? i9 + AndroidUtilities.dp(i9 > 0 ? 5.0f : -2.0f) : 0);
                            staticLayout.getSelectionPath(spanStart, spanEnd, linkPath2);
                        }
                        linkPath2.setAllowReset(true);
                        textPaintMarkSpanArr = (TextPaintMarkSpan[]) spanned.getSpans(0, spanned.length(), TextPaintMarkSpan.class);
                        if (textPaintMarkSpanArr != null && textPaintMarkSpanArr.length > 0) {
                            LinkPath linkPath4 = new LinkPath(true);
                            linkPath4.setAllowReset(false);
                            for (i5 = 0; i5 < textPaintMarkSpanArr.length; i5++) {
                                int spanStart2 = spanned.getSpanStart(textPaintMarkSpanArr[i5]);
                                int spanEnd2 = spanned.getSpanEnd(textPaintMarkSpanArr[i5]);
                                linkPath4.setCurrentLayout(staticLayout, spanStart2, 0.0f);
                                int i10 = textPaintMarkSpanArr[i5].getTextPaint() != null ? textPaintMarkSpanArr[i5].getTextPaint().baselineShift : 0;
                                linkPath4.setBaselineShift(i10 != 0 ? i10 + AndroidUtilities.dp(i10 > 0 ? 5.0f : -2.0f) : 0);
                                staticLayout.getSelectionPath(spanStart2, spanEnd2, linkPath4);
                            }
                            linkPath4.setAllowReset(true);
                            linkPath3 = linkPath4;
                        }
                        linkPath = linkPath3;
                        linkPath3 = linkPath2;
                    }
                } catch (Exception unused2) {
                }
                linkPath2 = null;
                try {
                    textPaintMarkSpanArr = (TextPaintMarkSpan[]) spanned.getSpans(0, spanned.length(), TextPaintMarkSpan.class);
                    LinkPath linkPath42 = new LinkPath(true);
                    try {
                        linkPath42.setAllowReset(false);
                        while (i5 < textPaintMarkSpanArr.length) {
                        }
                        linkPath42.setAllowReset(true);
                    } catch (Exception unused3) {
                    }
                    linkPath3 = linkPath42;
                } catch (Exception unused4) {
                }
                linkPath = linkPath3;
                linkPath3 = linkPath2;
            }
            DrawingText drawingText = new DrawingText();
            drawingText.textLayout = staticLayout;
            drawingText.textPath = linkPath3;
            drawingText.markPath = linkPath;
            return drawingText;
        }
        i4 = -dp;
        if (pageBlock instanceof TLRPC.TL_pageBlockEmbedPost) {
        }
        if (!(pageBlock instanceof TLRPC.TL_pageBlockChannel)) {
        }
        if (i3 != 0) {
        }
        if (staticLayout != null) {
        }
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private void drawLayoutLink(Canvas canvas, DrawingText drawingText) {
        float f;
        float f2;
        if (canvas != null && drawingText != null && this.pressedLinkOwnerLayout == drawingText) {
            if (this.pressedLink != null) {
                canvas.drawPath(this.urlPath, urlPaint);
            } else if (this.drawBlockSelection && drawingText != null) {
                if (drawingText.getLineCount() == 1) {
                    f = drawingText.getLineWidth(0);
                    f2 = drawingText.getLineLeft(0);
                } else {
                    f = (float) drawingText.getWidth();
                    f2 = 0.0f;
                }
                canvas.drawRect(((float) (-AndroidUtilities.dp(2.0f))) + f2, 0.0f, f2 + f + ((float) AndroidUtilities.dp(2.0f)), (float) drawingText.getHeight(), urlPaint);
            }
        }
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    /* JADX WARNING: Code restructure failed: missing block: B:91:0x0195, code lost:
        if (r0.isShowing() == false) goto L_0x0197;
     */
    /* JADX WARNING: Removed duplicated region for block: B:106:0x01bc  */
    /* JADX WARNING: Removed duplicated region for block: B:109:0x01c2  */
    /* JADX WARNING: Removed duplicated region for block: B:95:0x019c  */
    /* JADX WARNING: Removed duplicated region for block: B:98:0x01a5  */
    private boolean checkLayoutForLinks(MotionEvent motionEvent, View view, DrawingText drawingText, int i, int i2) {
        boolean z;
        boolean z2;
        String str;
        String str2;
        if (this.pageSwitchAnimation != null || view == null || drawingText == null) {
            return false;
        }
        StaticLayout staticLayout = drawingText.textLayout;
        int x = (int) motionEvent.getX();
        int y = (int) motionEvent.getY();
        if (motionEvent.getAction() == 0) {
            float f = 2.14748365E9f;
            int lineCount = staticLayout.getLineCount();
            float f2 = 0.0f;
            for (int i3 = 0; i3 < lineCount; i3++) {
                f2 = Math.max(staticLayout.getLineWidth(i3), f2);
                f = Math.min(staticLayout.getLineLeft(i3), f);
            }
            float f3 = (float) x;
            float f4 = ((float) i) + f;
            if (f3 >= f4 && f3 <= f4 + f2 && y >= i2 && y <= staticLayout.getHeight() + i2) {
                this.pressedLinkOwnerLayout = drawingText;
                this.pressedLinkOwnerView = view;
                this.pressedLayoutY = i2;
                if (staticLayout.getText() instanceof Spannable) {
                    int i4 = x - i;
                    try {
                        int lineForVertical = staticLayout.getLineForVertical(y - i2);
                        float f5 = (float) i4;
                        int offsetForHorizontal = staticLayout.getOffsetForHorizontal(lineForVertical, f5);
                        float lineLeft = staticLayout.getLineLeft(lineForVertical);
                        if (lineLeft <= f5 && lineLeft + staticLayout.getLineWidth(lineForVertical) >= f5) {
                            Spannable spannable = (Spannable) staticLayout.getText();
                            TextPaintUrlSpan[] textPaintUrlSpanArr = (TextPaintUrlSpan[]) spannable.getSpans(offsetForHorizontal, offsetForHorizontal, TextPaintUrlSpan.class);
                            if (textPaintUrlSpanArr != null && textPaintUrlSpanArr.length > 0) {
                                TextPaintUrlSpan textPaintUrlSpan = textPaintUrlSpanArr[0];
                                this.pressedLink = textPaintUrlSpan;
                                int spanStart = spannable.getSpanStart(textPaintUrlSpan);
                                int spanEnd = spannable.getSpanEnd(this.pressedLink);
                                for (int i5 = 1; i5 < textPaintUrlSpanArr.length; i5++) {
                                    TextPaintUrlSpan textPaintUrlSpan2 = textPaintUrlSpanArr[i5];
                                    int spanStart2 = spannable.getSpanStart(textPaintUrlSpan2);
                                    int spanEnd2 = spannable.getSpanEnd(textPaintUrlSpan2);
                                    if (spanStart > spanStart2 || spanEnd2 > spanEnd) {
                                        this.pressedLink = textPaintUrlSpan2;
                                        spanStart = spanStart2;
                                        spanEnd = spanEnd2;
                                    }
                                }
                                try {
                                    this.urlPath.setUseRoundRect(true);
                                    this.urlPath.setCurrentLayout(staticLayout, spanStart, 0.0f);
                                    int i6 = this.pressedLink.getTextPaint() != null ? this.pressedLink.getTextPaint().baselineShift : 0;
                                    this.urlPath.setBaselineShift(i6 != 0 ? i6 + AndroidUtilities.dp(i6 > 0 ? 5.0f : -2.0f) : 0);
                                    staticLayout.getSelectionPath(spanStart, spanEnd, this.urlPath);
                                    view.invalidate();
                                } catch (Exception e) {
                                    FileLog.e(e);
                                }
                            }
                        }
                    } catch (Exception e2) {
                        FileLog.e(e2);
                    }
                }
            }
        } else {
            if (motionEvent.getAction() == 1) {
                TextPaintUrlSpan textPaintUrlSpan3 = this.pressedLink;
                if (textPaintUrlSpan3 != null) {
                    String url = textPaintUrlSpan3.getUrl();
                    if (url != null) {
                        BottomSheet bottomSheet = this.linkSheet;
                        String str3 = null;
                        if (bottomSheet != null) {
                            bottomSheet.dismiss();
                            this.linkSheet = null;
                        }
                        int lastIndexOf = url.lastIndexOf(35);
                        if (lastIndexOf != -1) {
                            if (!TextUtils.isEmpty(this.currentPage.cached_page.url)) {
                                str = this.currentPage.cached_page.url.toLowerCase();
                            } else {
                                str = this.currentPage.url.toLowerCase();
                            }
                            try {
                                str2 = URLDecoder.decode(url.substring(lastIndexOf + 1), "UTF-8");
                            } catch (Exception unused) {
                                str2 = "";
                            }
                            if (url.toLowerCase().contains(str)) {
                                if (TextUtils.isEmpty(str2)) {
                                    this.layoutManager[0].scrollToPositionWithOffset(0, 0);
                                    checkScrollAnimated();
                                } else {
                                    scrollToAnchor(str2);
                                }
                                z2 = true;
                            } else {
                                z2 = false;
                            }
                            str3 = str2;
                        } else {
                            z2 = false;
                        }
                        if (!z2) {
                            openWebpageUrl(this.pressedLink.getUrl(), str3);
                        }
                    }
                }
            } else if (motionEvent.getAction() == 3) {
                ActionBarPopupWindow actionBarPopupWindow = this.popupWindow;
                if (actionBarPopupWindow != null) {
                }
            }
            z = true;
            if (z) {
                removePressedLink();
            }
            if (motionEvent.getAction() == 0) {
                startCheckLongPress();
            }
            if (!(motionEvent.getAction() == 0 || motionEvent.getAction() == 2)) {
                cancelCheckLongPress();
            }
            if (!(view instanceof BlockDetailsCell)) {
                if (this.pressedLink != null) {
                    return true;
                }
                return false;
            } else if (this.pressedLinkOwnerLayout != null) {
                return true;
            } else {
                return false;
            }
        }
        z = false;
        if (z) {
        }
        if (motionEvent.getAction() == 0) {
        }
        cancelCheckLongPress();
        if (!(view instanceof BlockDetailsCell)) {
        }
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private void removePressedLink() {
        if (this.pressedLink != null || this.pressedLinkOwnerView != null) {
            View view = this.pressedLinkOwnerView;
            this.pressedLink = null;
            this.pressedLinkOwnerLayout = null;
            this.pressedLinkOwnerView = null;
            if (view != null) {
                view.invalidate();
            }
        }
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private void openWebpageUrl(String str, String str2) {
        if (this.openUrlReqId != 0) {
            ConnectionsManager.getInstance(this.currentAccount).cancelRequest(this.openUrlReqId, false);
            this.openUrlReqId = 0;
        }
        int i = this.lastReqId + 1;
        this.lastReqId = i;
        closePhoto(false);
        showProgressView(true, true);
        TLRPC.TL_messages_getWebPage tL_messages_getWebPage = new TLRPC.TL_messages_getWebPage();
        tL_messages_getWebPage.url = str;
        tL_messages_getWebPage.hash = 0;
        this.openUrlReqId = ConnectionsManager.getInstance(this.currentAccount).sendRequest(tL_messages_getWebPage, new RequestDelegate(i, str2, tL_messages_getWebPage) {
            /* class im.guobwnxjuc.ui.$$Lambda$ArticleViewer$JER7ZhU7GOUhn6896460HBSOY */
            private final /* synthetic */ int f$1;
            private final /* synthetic */ String f$2;
            private final /* synthetic */ TLRPC.TL_messages_getWebPage f$3;

            {
                this.f$1 = r2;
                this.f$2 = r3;
                this.f$3 = r4;
            }

            @Override // im.guobwnxjuc.tgnet.RequestDelegate
            public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                ArticleViewer.this.lambda$openWebpageUrl$6$ArticleViewer(this.f$1, this.f$2, this.f$3, tLObject, tL_error);
            }
        });
    }

    public /* synthetic */ void lambda$openWebpageUrl$6$ArticleViewer(int i, String str, TLRPC.TL_messages_getWebPage tL_messages_getWebPage, TLObject tLObject, TLRPC.TL_error tL_error) {
        AndroidUtilities.runOnUIThread(new Runnable(i, tLObject, str, tL_messages_getWebPage) {
            /* class im.guobwnxjuc.ui.$$Lambda$ArticleViewer$G_l_t30tXTduGEYenK6GMzIdVEg */
            private final /* synthetic */ int f$1;
            private final /* synthetic */ TLObject f$2;
            private final /* synthetic */ String f$3;
            private final /* synthetic */ TLRPC.TL_messages_getWebPage f$4;

            {
                this.f$1 = r2;
                this.f$2 = r3;
                this.f$3 = r4;
                this.f$4 = r5;
            }

            public final void run() {
                ArticleViewer.this.lambda$null$5$ArticleViewer(this.f$1, this.f$2, this.f$3, this.f$4);
            }
        });
    }

    public /* synthetic */ void lambda$null$5$ArticleViewer(int i, TLObject tLObject, String str, TLRPC.TL_messages_getWebPage tL_messages_getWebPage) {
        if (this.openUrlReqId != 0 && i == this.lastReqId) {
            this.openUrlReqId = 0;
            showProgressView(true, false);
            if (this.isVisible) {
                if (tLObject instanceof TLRPC.TL_webPage) {
                    TLRPC.TL_webPage tL_webPage = (TLRPC.TL_webPage) tLObject;
                    if (tL_webPage.cached_page instanceof TLRPC.TL_page) {
                        addPageToStack(tL_webPage, str, 1);
                        return;
                    }
                }
                Browser.openUrl(this.parentActivity, tL_messages_getWebPage.url);
            }
        }
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private TLRPC.Photo getPhotoWithId(long j) {
        TLRPC.WebPage webPage = this.currentPage;
        if (!(webPage == null || webPage.cached_page == null)) {
            if (this.currentPage.photo != null && this.currentPage.photo.id == j) {
                return this.currentPage.photo;
            }
            for (int i = 0; i < this.currentPage.cached_page.photos.size(); i++) {
                TLRPC.Photo photo = this.currentPage.cached_page.photos.get(i);
                if (photo.id == j) {
                    return photo;
                }
            }
        }
        return null;
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private TLRPC.Document getDocumentWithId(long j) {
        TLRPC.WebPage webPage = this.currentPage;
        if (!(webPage == null || webPage.cached_page == null)) {
            if (this.currentPage.document != null && this.currentPage.document.id == j) {
                return this.currentPage.document;
            }
            for (int i = 0; i < this.currentPage.cached_page.documents.size(); i++) {
                TLRPC.Document document = this.currentPage.cached_page.documents.get(i);
                if (document.id == j) {
                    return document;
                }
            }
        }
        return null;
    }

    @Override // im.guobwnxjuc.messenger.NotificationCenter.NotificationCenterDelegate
    public void didReceivedNotification(int i, int i2, Object... objArr) {
        BlockAudioCell blockAudioCell;
        MessageObject messageObject;
        int i3 = 0;
        if (i == NotificationCenter.fileDidFailToLoad) {
            String str = (String) objArr[0];
            while (i3 < 3) {
                String[] strArr = this.currentFileNames;
                if (strArr[i3] == null || !strArr[i3].equals(str)) {
                    i3++;
                } else {
                    this.radialProgressViews[i3].setProgress(1.0f, true);
                    checkProgress(i3, true);
                    return;
                }
            }
        } else if (i == NotificationCenter.fileDidLoad) {
            String str2 = (String) objArr[0];
            for (int i4 = 0; i4 < 3; i4++) {
                String[] strArr2 = this.currentFileNames;
                if (strArr2[i4] != null && strArr2[i4].equals(str2)) {
                    this.radialProgressViews[i4].setProgress(1.0f, true);
                    checkProgress(i4, true);
                    if (i4 == 0 && isMediaVideo(this.currentIndex)) {
                        onActionClick(false);
                        return;
                    }
                    return;
                }
            }
        } else if (i == NotificationCenter.FileLoadProgressChanged) {
            String str3 = (String) objArr[0];
            while (i3 < 3) {
                String[] strArr3 = this.currentFileNames;
                if (strArr3[i3] != null && strArr3[i3].equals(str3)) {
                    this.radialProgressViews[i3].setProgress(((Float) objArr[1]).floatValue(), true);
                }
                i3++;
            }
        } else if (i == NotificationCenter.emojiDidLoad) {
            TextView textView = this.captionTextView;
            if (textView != null) {
                textView.invalidate();
            }
        } else if (i == NotificationCenter.needSetDayNightTheme) {
            if (!(!this.nightModeEnabled || this.selectedColor == 2 || this.adapter == null)) {
                updatePaintColors();
                while (i3 < this.listView.length) {
                    this.adapter[i3].notifyDataSetChanged();
                    i3++;
                }
            }
        } else if (i == NotificationCenter.messagePlayingDidStart) {
            MessageObject messageObject2 = (MessageObject) objArr[0];
            if (this.listView != null) {
                int i5 = 0;
                while (true) {
                    RecyclerListView[] recyclerListViewArr = this.listView;
                    if (i5 < recyclerListViewArr.length) {
                        int childCount = recyclerListViewArr[i5].getChildCount();
                        for (int i6 = 0; i6 < childCount; i6++) {
                            View childAt = this.listView[i5].getChildAt(i6);
                            if (childAt instanceof BlockAudioCell) {
                                ((BlockAudioCell) childAt).updateButtonState(true);
                            }
                        }
                        i5++;
                    } else {
                        return;
                    }
                }
            }
        } else if (i == NotificationCenter.messagePlayingDidReset || i == NotificationCenter.messagePlayingPlayStateChanged) {
            if (this.listView != null) {
                int i7 = 0;
                while (true) {
                    RecyclerListView[] recyclerListViewArr2 = this.listView;
                    if (i7 < recyclerListViewArr2.length) {
                        int childCount2 = recyclerListViewArr2[i7].getChildCount();
                        for (int i8 = 0; i8 < childCount2; i8++) {
                            View childAt2 = this.listView[i7].getChildAt(i8);
                            if (childAt2 instanceof BlockAudioCell) {
                                BlockAudioCell blockAudioCell2 = (BlockAudioCell) childAt2;
                                if (blockAudioCell2.getMessageObject() != null) {
                                    blockAudioCell2.updateButtonState(true);
                                }
                            }
                        }
                        i7++;
                    } else {
                        return;
                    }
                }
            }
        } else if (i == NotificationCenter.messagePlayingProgressDidChanged) {
            Integer num = (Integer) objArr[0];
            if (this.listView != null) {
                int i9 = 0;
                while (true) {
                    RecyclerListView[] recyclerListViewArr3 = this.listView;
                    if (i9 < recyclerListViewArr3.length) {
                        int childCount3 = recyclerListViewArr3[i9].getChildCount();
                        int i10 = 0;
                        while (true) {
                            if (i10 >= childCount3) {
                                break;
                            }
                            View childAt3 = this.listView[i9].getChildAt(i10);
                            if (!(childAt3 instanceof BlockAudioCell) || (messageObject = (blockAudioCell = (BlockAudioCell) childAt3).getMessageObject()) == null || messageObject.getId() != num.intValue()) {
                                i10++;
                            } else {
                                MessageObject playingMessageObject = MediaController.getInstance().getPlayingMessageObject();
                                if (playingMessageObject != null) {
                                    messageObject.audioProgress = playingMessageObject.audioProgress;
                                    messageObject.audioProgressSec = playingMessageObject.audioProgressSec;
                                    messageObject.audioPlayerDuration = playingMessageObject.audioPlayerDuration;
                                    blockAudioCell.updatePlayingMessageProgress();
                                }
                            }
                        }
                        i9++;
                    } else {
                        return;
                    }
                }
            }
        }
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private void updatePaintSize() {
        ApplicationLoader.applicationContext.getSharedPreferences("articles", 0).edit().putInt("font_size", this.selectedFontSize).commit();
        for (int i = 0; i < 2; i++) {
            this.adapter[i].notifyDataSetChanged();
        }
    }

    private void updatePaintFonts() {
        ApplicationLoader.applicationContext.getSharedPreferences("articles", 0).edit().putInt("font_type", this.selectedFont).commit();
        Typeface typeface = this.selectedFont == 0 ? Typeface.DEFAULT : Typeface.SERIF;
        Typeface typeface2 = this.selectedFont == 0 ? AndroidUtilities.getTypeface("fonts/ritalic.ttf") : Typeface.create(C.SERIF_NAME, 2);
        Typeface typeface3 = this.selectedFont == 0 ? AndroidUtilities.getTypeface("fonts/rmedium.ttf") : Typeface.create(C.SERIF_NAME, 1);
        Typeface typeface4 = this.selectedFont == 0 ? AndroidUtilities.getTypeface("fonts/rmediumitalic.ttf") : Typeface.create(C.SERIF_NAME, 3);
        for (int i = 0; i < quoteTextPaints.size(); i++) {
            updateFontEntry(quoteTextPaints.keyAt(i), quoteTextPaints.valueAt(i), typeface, typeface4, typeface3, typeface2);
        }
        for (int i2 = 0; i2 < preformattedTextPaints.size(); i2++) {
            updateFontEntry(preformattedTextPaints.keyAt(i2), preformattedTextPaints.valueAt(i2), typeface, typeface4, typeface3, typeface2);
        }
        for (int i3 = 0; i3 < paragraphTextPaints.size(); i3++) {
            updateFontEntry(paragraphTextPaints.keyAt(i3), paragraphTextPaints.valueAt(i3), typeface, typeface4, typeface3, typeface2);
        }
        for (int i4 = 0; i4 < listTextPaints.size(); i4++) {
            updateFontEntry(listTextPaints.keyAt(i4), listTextPaints.valueAt(i4), typeface, typeface4, typeface3, typeface2);
        }
        for (int i5 = 0; i5 < embedPostTextPaints.size(); i5++) {
            updateFontEntry(embedPostTextPaints.keyAt(i5), embedPostTextPaints.valueAt(i5), typeface, typeface4, typeface3, typeface2);
        }
        for (int i6 = 0; i6 < mediaCaptionTextPaints.size(); i6++) {
            updateFontEntry(mediaCaptionTextPaints.keyAt(i6), mediaCaptionTextPaints.valueAt(i6), typeface, typeface4, typeface3, typeface2);
        }
        for (int i7 = 0; i7 < mediaCreditTextPaints.size(); i7++) {
            updateFontEntry(mediaCreditTextPaints.keyAt(i7), mediaCreditTextPaints.valueAt(i7), typeface, typeface4, typeface3, typeface2);
        }
        for (int i8 = 0; i8 < photoCaptionTextPaints.size(); i8++) {
            updateFontEntry(photoCaptionTextPaints.keyAt(i8), photoCaptionTextPaints.valueAt(i8), typeface, typeface4, typeface3, typeface2);
        }
        for (int i9 = 0; i9 < photoCreditTextPaints.size(); i9++) {
            updateFontEntry(photoCreditTextPaints.keyAt(i9), photoCreditTextPaints.valueAt(i9), typeface, typeface4, typeface3, typeface2);
        }
        for (int i10 = 0; i10 < authorTextPaints.size(); i10++) {
            updateFontEntry(authorTextPaints.keyAt(i10), authorTextPaints.valueAt(i10), typeface, typeface4, typeface3, typeface2);
        }
        for (int i11 = 0; i11 < footerTextPaints.size(); i11++) {
            updateFontEntry(footerTextPaints.keyAt(i11), footerTextPaints.valueAt(i11), typeface, typeface4, typeface3, typeface2);
        }
        for (int i12 = 0; i12 < embedPostCaptionTextPaints.size(); i12++) {
            updateFontEntry(embedPostCaptionTextPaints.keyAt(i12), embedPostCaptionTextPaints.valueAt(i12), typeface, typeface4, typeface3, typeface2);
        }
        for (int i13 = 0; i13 < relatedArticleTextPaints.size(); i13++) {
            updateFontEntry(relatedArticleTextPaints.keyAt(i13), relatedArticleTextPaints.valueAt(i13), typeface, typeface4, typeface3, typeface2);
        }
        for (int i14 = 0; i14 < detailsTextPaints.size(); i14++) {
            updateFontEntry(detailsTextPaints.keyAt(i14), detailsTextPaints.valueAt(i14), typeface, typeface4, typeface3, typeface2);
        }
        for (int i15 = 0; i15 < tableTextPaints.size(); i15++) {
            updateFontEntry(tableTextPaints.keyAt(i15), tableTextPaints.valueAt(i15), typeface, typeface4, typeface3, typeface2);
        }
    }

    private void updateFontEntry(int i, TextPaint textPaint, Typeface typeface, Typeface typeface2, Typeface typeface3, Typeface typeface4) {
        int i2 = i & 1;
        if (i2 != 0 && (i & 2) != 0) {
            textPaint.setTypeface(typeface2);
        } else if (i2 != 0) {
            textPaint.setTypeface(typeface3);
        } else if ((i & 2) != 0) {
            textPaint.setTypeface(typeface4);
        } else if ((i & 4) == 0) {
            textPaint.setTypeface(typeface);
        }
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private int getSelectedColor() {
        int i = this.selectedColor;
        if (!this.nightModeEnabled || i == 2) {
            return i;
        }
        if (Theme.selectedAutoNightType == 0) {
            int i2 = Calendar.getInstance().get(11);
            if ((i2 < 22 || i2 > 24) && (i2 < 0 || i2 > 6)) {
                return i;
            }
        } else if (Theme.isCurrentThemeNight()) {
            return 2;
        } else {
            return i;
        }
        return 2;
    }

    private void updatePaintColors() {
        int i = 0;
        ApplicationLoader.applicationContext.getSharedPreferences("articles", 0).edit().putInt("font_color", this.selectedColor).commit();
        int selectedColor2 = getSelectedColor();
        if (selectedColor2 == 0) {
            this.backgroundPaint.setColor(-1);
            while (true) {
                RecyclerListView[] recyclerListViewArr = this.listView;
                if (i >= recyclerListViewArr.length) {
                    break;
                }
                recyclerListViewArr[i].setGlowColor(-657673);
                i++;
            }
        } else if (selectedColor2 == 1) {
            this.backgroundPaint.setColor(-659492);
            while (true) {
                RecyclerListView[] recyclerListViewArr2 = this.listView;
                if (i >= recyclerListViewArr2.length) {
                    break;
                }
                recyclerListViewArr2[i].setGlowColor(-659492);
                i++;
            }
        } else if (selectedColor2 == 2) {
            this.backgroundPaint.setColor(-15461356);
            while (true) {
                RecyclerListView[] recyclerListViewArr3 = this.listView;
                if (i >= recyclerListViewArr3.length) {
                    break;
                }
                recyclerListViewArr3[i].setGlowColor(-15461356);
                i++;
            }
        }
        TextPaint textPaint = listTextPointerPaint;
        if (textPaint != null) {
            textPaint.setColor(getTextColor());
        }
        TextPaint textPaint2 = listTextNumPaint;
        if (textPaint2 != null) {
            textPaint2.setColor(getTextColor());
        }
        TextPaint textPaint3 = embedPostAuthorPaint;
        if (textPaint3 != null) {
            textPaint3.setColor(getTextColor());
        }
        TextPaint textPaint4 = channelNamePaint;
        if (textPaint4 != null) {
            if (this.channelBlock == null) {
                textPaint4.setColor(getTextColor());
            } else {
                textPaint4.setColor(-1);
            }
        }
        TextPaint textPaint5 = relatedArticleHeaderPaint;
        if (textPaint5 != null) {
            textPaint5.setColor(getTextColor());
        }
        TextPaint textPaint6 = relatedArticleTextPaint;
        if (textPaint6 != null) {
            textPaint6.setColor(getGrayTextColor());
        }
        TextPaint textPaint7 = embedPostDatePaint;
        if (textPaint7 != null) {
            if (selectedColor2 == 0) {
                textPaint7.setColor(-7366752);
            } else {
                textPaint7.setColor(getGrayTextColor());
            }
        }
        createPaint(true);
        setMapColors(titleTextPaints);
        setMapColors(kickerTextPaints);
        setMapColors(subtitleTextPaints);
        setMapColors(headerTextPaints);
        setMapColors(subheaderTextPaints);
        setMapColors(quoteTextPaints);
        setMapColors(preformattedTextPaints);
        setMapColors(paragraphTextPaints);
        setMapColors(listTextPaints);
        setMapColors(embedPostTextPaints);
        setMapColors(mediaCaptionTextPaints);
        setMapColors(mediaCreditTextPaints);
        setMapColors(photoCaptionTextPaints);
        setMapColors(photoCreditTextPaints);
        setMapColors(authorTextPaints);
        setMapColors(footerTextPaints);
        setMapColors(embedPostCaptionTextPaints);
        setMapColors(relatedArticleTextPaints);
        setMapColors(detailsTextPaints);
        setMapColors(tableTextPaints);
    }

    private void setMapColors(SparseArray<TextPaint> sparseArray) {
        for (int i = 0; i < sparseArray.size(); i++) {
            int keyAt = sparseArray.keyAt(i);
            TextPaint valueAt = sparseArray.valueAt(i);
            if ((keyAt & 8) == 0 && (keyAt & 512) == 0) {
                valueAt.setColor(getTextColor());
            } else {
                valueAt.setColor(getLinkTextColor());
            }
        }
    }

    public void setParentActivity(Activity activity, BaseFragment baseFragment) {
        this.parentFragment = baseFragment;
        int i = UserConfig.selectedAccount;
        this.currentAccount = i;
        this.leftImage.setCurrentAccount(i);
        this.rightImage.setCurrentAccount(this.currentAccount);
        this.centerImage.setCurrentAccount(this.currentAccount);
        NotificationCenter.getInstance(this.currentAccount).addObserver(this, NotificationCenter.messagePlayingProgressDidChanged);
        NotificationCenter.getInstance(this.currentAccount).addObserver(this, NotificationCenter.messagePlayingDidReset);
        NotificationCenter.getInstance(this.currentAccount).addObserver(this, NotificationCenter.messagePlayingPlayStateChanged);
        NotificationCenter.getInstance(this.currentAccount).addObserver(this, NotificationCenter.messagePlayingDidStart);
        NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.needSetDayNightTheme);
        if (this.parentActivity == activity) {
            updatePaintColors();
            return;
        }
        this.parentActivity = activity;
        SharedPreferences sharedPreferences = ApplicationLoader.applicationContext.getSharedPreferences("articles", 0);
        this.selectedFontSize = sharedPreferences.getInt("font_size", 2);
        this.selectedFont = sharedPreferences.getInt("font_type", 0);
        this.selectedColor = sharedPreferences.getInt("font_color", 0);
        this.nightModeEnabled = sharedPreferences.getBoolean("nightModeEnabled", false);
        createPaint(false);
        this.backgroundPaint = new Paint();
        this.layerShadowDrawable = activity.getResources().getDrawable(R.drawable.layer_shadow);
        this.slideDotDrawable = activity.getResources().getDrawable(R.drawable.slide_dot_small);
        this.slideDotBigDrawable = activity.getResources().getDrawable(R.drawable.slide_dot_big);
        this.scrimPaint = new Paint();
        WindowView windowView2 = new WindowView(activity);
        this.windowView = windowView2;
        windowView2.setWillNotDraw(false);
        this.windowView.setClipChildren(true);
        this.windowView.setFocusable(false);
        AnonymousClass4 r2 = new FrameLayout(activity) {
            /* class im.guobwnxjuc.ui.ArticleViewer.AnonymousClass4 */

            /* access modifiers changed from: protected */
            /* JADX WARNING: Removed duplicated region for block: B:11:0x004d  */
            public boolean drawChild(Canvas canvas, View view, long j) {
                int i;
                int i2;
                if (!ArticleViewer.this.windowView.movingPage) {
                    return super.drawChild(canvas, view, j);
                }
                int measuredWidth = getMeasuredWidth();
                int translationX = (int) ArticleViewer.this.listView[0].getTranslationX();
                if (view == ArticleViewer.this.listView[1]) {
                    i = translationX;
                } else {
                    i = measuredWidth;
                    if (view == ArticleViewer.this.listView[0]) {
                        i2 = translationX;
                        int save = canvas.save();
                        canvas.clipRect(i2, 0, i, getHeight());
                        boolean drawChild = super.drawChild(canvas, view, j);
                        canvas.restoreToCount(save);
                        if (translationX != 0) {
                            float f = 0.0f;
                            if (view == ArticleViewer.this.listView[0]) {
                                float max = Math.max(0.0f, Math.min(((float) (measuredWidth - translationX)) / ((float) AndroidUtilities.dp(20.0f)), 1.0f));
                                ArticleViewer.this.layerShadowDrawable.setBounds(translationX - ArticleViewer.this.layerShadowDrawable.getIntrinsicWidth(), view.getTop(), translationX, view.getBottom());
                                ArticleViewer.this.layerShadowDrawable.setAlpha((int) (max * 255.0f));
                                ArticleViewer.this.layerShadowDrawable.draw(canvas);
                            } else if (view == ArticleViewer.this.listView[1]) {
                                float min = Math.min(0.8f, ((float) (measuredWidth - translationX)) / ((float) measuredWidth));
                                if (min >= 0.0f) {
                                    f = min;
                                }
                                ArticleViewer.this.scrimPaint.setColor(((int) (f * 153.0f)) << 24);
                                canvas.drawRect((float) i2, 0.0f, (float) i, (float) getHeight(), ArticleViewer.this.scrimPaint);
                            }
                        }
                        return drawChild;
                    }
                }
                i2 = 0;
                int save2 = canvas.save();
                canvas.clipRect(i2, 0, i, getHeight());
                boolean drawChild2 = super.drawChild(canvas, view, j);
                canvas.restoreToCount(save2);
                if (translationX != 0) {
                }
                return drawChild2;
            }
        };
        this.containerView = r2;
        this.windowView.addView(r2, LayoutHelper.createFrame(-1, -1, 51));
        this.containerView.setFitsSystemWindows(true);
        if (Build.VERSION.SDK_INT >= 21) {
            this.containerView.setOnApplyWindowInsetsListener(new View.OnApplyWindowInsetsListener() {
                /* class im.guobwnxjuc.ui.$$Lambda$ArticleViewer$6wXlr2u2FLUOIbMO8niWvjzqiw */

                public final WindowInsets onApplyWindowInsets(View view, WindowInsets windowInsets) {
                    return ArticleViewer.this.lambda$setParentActivity$7$ArticleViewer(view, windowInsets);
                }
            });
        }
        this.containerView.setSystemUiVisibility(1028);
        View view = new View(activity);
        this.photoContainerBackground = view;
        view.setVisibility(4);
        this.photoContainerBackground.setBackgroundDrawable(this.photoBackgroundDrawable);
        this.windowView.addView(this.photoContainerBackground, LayoutHelper.createFrame(-1, -1, 51));
        ClippingImageView clippingImageView = new ClippingImageView(activity);
        this.animatingImageView = clippingImageView;
        clippingImageView.setAnimationValues(this.animationValues);
        this.animatingImageView.setVisibility(8);
        this.windowView.addView(this.animatingImageView, LayoutHelper.createFrame(40, 40.0f));
        AnonymousClass5 r22 = new FrameLayoutDrawer(activity) {
            /* class im.guobwnxjuc.ui.ArticleViewer.AnonymousClass5 */

            /* access modifiers changed from: protected */
            public void onLayout(boolean z, int i, int i2, int i3, int i4) {
                super.onLayout(z, i, i2, i3, i4);
                int i5 = i4 - i2;
                int measuredHeight = i5 - ArticleViewer.this.captionTextView.getMeasuredHeight();
                int measuredHeight2 = i5 - ArticleViewer.this.groupedPhotosListView.getMeasuredHeight();
                if (ArticleViewer.this.bottomLayout.getVisibility() == 0) {
                    measuredHeight -= ArticleViewer.this.bottomLayout.getMeasuredHeight();
                    measuredHeight2 -= ArticleViewer.this.bottomLayout.getMeasuredHeight();
                }
                if (!ArticleViewer.this.groupedPhotosListView.currentPhotos.isEmpty()) {
                    measuredHeight -= ArticleViewer.this.groupedPhotosListView.getMeasuredHeight();
                }
                ArticleViewer.this.captionTextView.layout(0, measuredHeight, ArticleViewer.this.captionTextView.getMeasuredWidth(), ArticleViewer.this.captionTextView.getMeasuredHeight() + measuredHeight);
                ArticleViewer.this.captionTextViewNext.layout(0, measuredHeight, ArticleViewer.this.captionTextViewNext.getMeasuredWidth(), ArticleViewer.this.captionTextViewNext.getMeasuredHeight() + measuredHeight);
                ArticleViewer.this.groupedPhotosListView.layout(0, measuredHeight2, ArticleViewer.this.groupedPhotosListView.getMeasuredWidth(), ArticleViewer.this.groupedPhotosListView.getMeasuredHeight() + measuredHeight2);
            }
        };
        this.photoContainerView = r22;
        r22.setVisibility(4);
        this.photoContainerView.setWillNotDraw(false);
        this.windowView.addView(this.photoContainerView, LayoutHelper.createFrame(-1, -1, 51));
        FrameLayout frameLayout = new FrameLayout(activity);
        this.fullscreenVideoContainer = frameLayout;
        frameLayout.setBackgroundColor(-16777216);
        this.fullscreenVideoContainer.setVisibility(4);
        this.windowView.addView(this.fullscreenVideoContainer, LayoutHelper.createFrame(-1, -1.0f));
        AspectRatioFrameLayout aspectRatioFrameLayout2 = new AspectRatioFrameLayout(activity);
        this.fullscreenAspectRatioView = aspectRatioFrameLayout2;
        aspectRatioFrameLayout2.setVisibility(8);
        this.fullscreenVideoContainer.addView(this.fullscreenAspectRatioView, LayoutHelper.createFrame(-1, -1, 17));
        this.fullscreenTextureView = new TextureView(activity);
        this.listView = new RecyclerListView[2];
        this.adapter = new WebpageAdapter[2];
        this.layoutManager = new LinearLayoutManager[2];
        int i2 = 0;
        while (true) {
            RecyclerListView[] recyclerListViewArr = this.listView;
            if (i2 >= recyclerListViewArr.length) {
                break;
            }
            recyclerListViewArr[i2] = new RecyclerListView(activity) {
                /* class im.guobwnxjuc.ui.ArticleViewer.AnonymousClass6 */

                /* access modifiers changed from: protected */
                @Override // androidx.recyclerview.widget.RecyclerView, im.guobwnxjuc.ui.components.RecyclerListView
                public void onLayout(boolean z, int i, int i2, int i3, int i4) {
                    super.onLayout(z, i, i2, i3, i4);
                    int childCount = getChildCount();
                    for (int i5 = 0; i5 < childCount; i5++) {
                        View childAt = getChildAt(i5);
                        if ((childAt.getTag() instanceof Integer) && ((Integer) childAt.getTag()).intValue() == 90 && childAt.getBottom() < getMeasuredHeight()) {
                            int measuredHeight = getMeasuredHeight();
                            childAt.layout(0, measuredHeight - childAt.getMeasuredHeight(), childAt.getMeasuredWidth(), measuredHeight);
                            return;
                        }
                    }
                }

                @Override // androidx.recyclerview.widget.RecyclerView, im.guobwnxjuc.ui.components.RecyclerListView
                public boolean onInterceptTouchEvent(MotionEvent motionEvent) {
                    if (ArticleViewer.this.pressedLinkOwnerLayout != null && ArticleViewer.this.pressedLink == null && ((ArticleViewer.this.popupWindow == null || !ArticleViewer.this.popupWindow.isShowing()) && (motionEvent.getAction() == 1 || motionEvent.getAction() == 3))) {
                        ArticleViewer.this.pressedLink = null;
                        ArticleViewer.this.pressedLinkOwnerLayout = null;
                        ArticleViewer.this.pressedLinkOwnerView = null;
                    } else if (!(ArticleViewer.this.pressedLinkOwnerLayout == null || ArticleViewer.this.pressedLink == null || motionEvent.getAction() != 1)) {
                        ArticleViewer articleViewer = ArticleViewer.this;
                        articleViewer.checkLayoutForLinks(motionEvent, articleViewer.pressedLinkOwnerView, ArticleViewer.this.pressedLinkOwnerLayout, 0, 0);
                    }
                    return super.onInterceptTouchEvent(motionEvent);
                }

                @Override // androidx.recyclerview.widget.RecyclerView
                public boolean onTouchEvent(MotionEvent motionEvent) {
                    if (ArticleViewer.this.pressedLinkOwnerLayout != null && ArticleViewer.this.pressedLink == null && ((ArticleViewer.this.popupWindow == null || !ArticleViewer.this.popupWindow.isShowing()) && (motionEvent.getAction() == 1 || motionEvent.getAction() == 3))) {
                        ArticleViewer.this.pressedLink = null;
                        ArticleViewer.this.pressedLinkOwnerLayout = null;
                        ArticleViewer.this.pressedLinkOwnerView = null;
                    }
                    return super.onTouchEvent(motionEvent);
                }

                public void setTranslationX(float f) {
                    super.setTranslationX(f);
                    if (ArticleViewer.this.windowView.movingPage) {
                        ArticleViewer.this.containerView.invalidate();
                        float measuredWidth = f / ((float) getMeasuredWidth());
                        ArticleViewer articleViewer = ArticleViewer.this;
                        articleViewer.setCurrentHeaderHeight((int) (((float) articleViewer.windowView.startMovingHeaderHeight) + (((float) (AndroidUtilities.dp(56.0f) - ArticleViewer.this.windowView.startMovingHeaderHeight)) * measuredWidth)));
                    }
                }
            };
            ((DefaultItemAnimator) this.listView[i2].getItemAnimator()).setDelayAnimations(false);
            RecyclerListView recyclerListView = this.listView[i2];
            LinearLayoutManager[] linearLayoutManagerArr = this.layoutManager;
            LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this.parentActivity, 1, false);
            linearLayoutManagerArr[i2] = linearLayoutManager;
            recyclerListView.setLayoutManager(linearLayoutManager);
            WebpageAdapter[] webpageAdapterArr = this.adapter;
            WebpageAdapter webpageAdapter = new WebpageAdapter(this.parentActivity);
            webpageAdapterArr[i2] = webpageAdapter;
            this.listView[i2].setAdapter(webpageAdapter);
            this.listView[i2].setClipToPadding(false);
            this.listView[i2].setVisibility(i2 == 0 ? 0 : 8);
            this.listView[i2].setPadding(0, AndroidUtilities.dp(56.0f), 0, 0);
            this.listView[i2].setTopGlowOffset(AndroidUtilities.dp(56.0f));
            this.containerView.addView(this.listView[i2], LayoutHelper.createFrame(-1, -1.0f));
            this.listView[i2].setOnItemLongClickListener(new RecyclerListView.OnItemLongClickListener() {
                /* class im.guobwnxjuc.ui.$$Lambda$ArticleViewer$2uWTOf2B9vzdjdKjCNtLfNQisE */

                @Override // im.guobwnxjuc.ui.components.RecyclerListView.OnItemLongClickListener
                public final boolean onItemClick(View view, int i) {
                    return ArticleViewer.this.lambda$setParentActivity$8$ArticleViewer(view, i);
                }
            });
            this.listView[i2].setOnItemClickListener(new RecyclerListView.OnItemClickListener(webpageAdapter) {
                /* class im.guobwnxjuc.ui.$$Lambda$ArticleViewer$njQDIzMUAdbYPsTrwJq_ON0cZPs */
                private final /* synthetic */ ArticleViewer.WebpageAdapter f$1;

                {
                    this.f$1 = r2;
                }

                @Override // im.guobwnxjuc.ui.components.RecyclerListView.OnItemClickListener
                public final void onItemClick(View view, int i) {
                    ArticleViewer.this.lambda$setParentActivity$11$ArticleViewer(this.f$1, view, i);
                }
            });
            this.listView[i2].setOnScrollListener(new RecyclerView.OnScrollListener() {
                /* class im.guobwnxjuc.ui.ArticleViewer.AnonymousClass7 */

                @Override // androidx.recyclerview.widget.RecyclerView.OnScrollListener
                public void onScrolled(RecyclerView recyclerView, int i, int i2) {
                    if (recyclerView.getChildCount() != 0) {
                        ArticleViewer.this.headerView.invalidate();
                        ArticleViewer.this.checkScroll(i2);
                    }
                }
            });
            i2++;
        }
        this.headerPaint.setColor(-16777216);
        this.statusBarPaint.setColor(-16777216);
        this.headerProgressPaint.setColor(-14408666);
        AnonymousClass8 r23 = new FrameLayout(activity) {
            /* class im.guobwnxjuc.ui.ArticleViewer.AnonymousClass8 */

            /* access modifiers changed from: protected */
            public void onDraw(Canvas canvas) {
                View view;
                float f;
                float measuredWidth = (float) getMeasuredWidth();
                float measuredHeight = (float) getMeasuredHeight();
                canvas.drawRect(0.0f, 0.0f, measuredWidth, measuredHeight, ArticleViewer.this.headerPaint);
                if (ArticleViewer.this.layoutManager != null) {
                    int findFirstVisibleItemPosition = ArticleViewer.this.layoutManager[0].findFirstVisibleItemPosition();
                    int findLastVisibleItemPosition = ArticleViewer.this.layoutManager[0].findLastVisibleItemPosition();
                    int itemCount = ArticleViewer.this.layoutManager[0].getItemCount();
                    int i = itemCount - 2;
                    if (findLastVisibleItemPosition >= i) {
                        view = ArticleViewer.this.layoutManager[0].findViewByPosition(i);
                    } else {
                        view = ArticleViewer.this.layoutManager[0].findViewByPosition(findFirstVisibleItemPosition);
                    }
                    if (view != null) {
                        float f2 = measuredWidth / ((float) (itemCount - 1));
                        ArticleViewer.this.layoutManager[0].getChildCount();
                        float measuredHeight2 = (float) view.getMeasuredHeight();
                        if (findLastVisibleItemPosition >= i) {
                            f = ((((float) (i - findFirstVisibleItemPosition)) * f2) * ((float) (ArticleViewer.this.listView[0].getMeasuredHeight() - view.getTop()))) / measuredHeight2;
                        } else {
                            f = (1.0f - ((((float) Math.min(0, view.getTop() - ArticleViewer.this.listView[0].getPaddingTop())) + measuredHeight2) / measuredHeight2)) * f2;
                        }
                        canvas.drawRect(0.0f, 0.0f, (((float) findFirstVisibleItemPosition) * f2) + f, measuredHeight, ArticleViewer.this.headerProgressPaint);
                    }
                }
            }
        };
        this.headerView = r23;
        r23.setOnTouchListener($$Lambda$ArticleViewer$TpVT9rnGOmW0REBwK6NQYlvycpw.INSTANCE);
        this.headerView.setWillNotDraw(false);
        this.containerView.addView(this.headerView, LayoutHelper.createFrame(-1, 56.0f));
        ImageView imageView = new ImageView(activity);
        this.backButton = imageView;
        imageView.setScaleType(ImageView.ScaleType.CENTER);
        BackDrawable backDrawable2 = new BackDrawable(false);
        this.backDrawable = backDrawable2;
        backDrawable2.setAnimationTime(200.0f);
        this.backDrawable.setColor(-5000269);
        this.backDrawable.setRotated(false);
        this.backButton.setImageDrawable(this.backDrawable);
        this.backButton.setBackgroundDrawable(Theme.createSelectorDrawable(Theme.ACTION_BAR_WHITE_SELECTOR_COLOR));
        this.headerView.addView(this.backButton, LayoutHelper.createFrame(54, 56.0f));
        this.backButton.setOnClickListener(new View.OnClickListener() {
            /* class im.guobwnxjuc.ui.$$Lambda$ArticleViewer$7EkqG6KpRSv1ANgPsCsTeLHteRQ */

            public final void onClick(View view) {
                ArticleViewer.this.lambda$setParentActivity$13$ArticleViewer(view);
            }
        });
        this.backButton.setContentDescription(LocaleController.getString("AccDescrGoBack", R.string.AccDescrGoBack));
        SimpleTextView simpleTextView = new SimpleTextView(activity);
        this.titleTextView = simpleTextView;
        simpleTextView.setGravity(19);
        this.titleTextView.setTextSize(20);
        this.titleTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
        this.titleTextView.setTextColor(-5000269);
        this.titleTextView.setPivotX(0.0f);
        this.titleTextView.setPivotY((float) AndroidUtilities.dp(28.0f));
        this.headerView.addView(this.titleTextView, LayoutHelper.createFrame(-1.0f, 56.0f, 51, 72.0f, 0.0f, 96.0f, 0.0f));
        LineProgressView lineProgressView2 = new LineProgressView(activity);
        this.lineProgressView = lineProgressView2;
        lineProgressView2.setProgressColor(-1);
        this.lineProgressView.setPivotX(0.0f);
        this.lineProgressView.setPivotY((float) AndroidUtilities.dp(2.0f));
        this.headerView.addView(this.lineProgressView, LayoutHelper.createFrame(-1.0f, 2.0f, 83, 0.0f, 0.0f, 0.0f, 1.0f));
        this.lineProgressTickRunnable = new Runnable() {
            /* class im.guobwnxjuc.ui.$$Lambda$ArticleViewer$JD_RoMUT913l_Y1pJ1W4JxmEnkc */

            public final void run() {
                ArticleViewer.this.lambda$setParentActivity$14$ArticleViewer();
            }
        };
        LinearLayout linearLayout = new LinearLayout(this.parentActivity);
        linearLayout.setPadding(0, AndroidUtilities.dp(4.0f), 0, AndroidUtilities.dp(4.0f));
        linearLayout.setOrientation(1);
        int i3 = 0;
        while (i3 < 3) {
            this.colorCells[i3] = new ColorCell(this.parentActivity);
            if (i3 == 0) {
                ImageView imageView2 = new ImageView(this.parentActivity);
                this.nightModeImageView = imageView2;
                imageView2.setScaleType(ImageView.ScaleType.CENTER);
                this.nightModeImageView.setImageResource(R.drawable.moon);
                this.nightModeImageView.setColorFilter(new PorterDuffColorFilter((!this.nightModeEnabled || this.selectedColor == 2) ? -3355444 : -15428119, PorterDuff.Mode.MULTIPLY));
                this.nightModeImageView.setBackgroundDrawable(Theme.createSelectorDrawable(251658240));
                this.colorCells[i3].addView(this.nightModeImageView, LayoutHelper.createFrame(48, 48, (LocaleController.isRTL ? 3 : 5) | 48));
                this.nightModeImageView.setOnClickListener(new View.OnClickListener() {
                    /* class im.guobwnxjuc.ui.$$Lambda$ArticleViewer$q0Z3irOJRnsOw9qVv1MhgRqhJ7o */

                    public final void onClick(View view) {
                        ArticleViewer.this.lambda$setParentActivity$15$ArticleViewer(view);
                    }
                });
                this.colorCells[i3].setTextAndColor(LocaleController.getString("ColorWhite", R.string.ColorWhite), -1);
            } else if (i3 == 1) {
                this.colorCells[i3].setTextAndColor(LocaleController.getString("ColorSepia", R.string.ColorSepia), -1382967);
            } else if (i3 == 2) {
                this.colorCells[i3].setTextAndColor(LocaleController.getString("ColorDark", R.string.ColorDark), -14474461);
            }
            this.colorCells[i3].select(i3 == this.selectedColor);
            this.colorCells[i3].setTag(Integer.valueOf(i3));
            this.colorCells[i3].setOnClickListener(new View.OnClickListener() {
                /* class im.guobwnxjuc.ui.$$Lambda$ArticleViewer$ySqs_j8izzBnd18fDd6leEpW6n0 */

                public final void onClick(View view) {
                    ArticleViewer.this.lambda$setParentActivity$16$ArticleViewer(view);
                }
            });
            linearLayout.addView(this.colorCells[i3], LayoutHelper.createLinear(-1, 50));
            i3++;
        }
        updateNightModeButton();
        View view2 = new View(this.parentActivity);
        view2.setBackgroundColor(-2039584);
        linearLayout.addView(view2, LayoutHelper.createLinear(-1, 1, 15.0f, 4.0f, 15.0f, 4.0f));
        view2.getLayoutParams().height = 1;
        int i4 = 0;
        while (i4 < 2) {
            this.fontCells[i4] = new FontCell(this.parentActivity);
            if (i4 == 0) {
                this.fontCells[i4].setTextAndTypeface("Roboto", Typeface.DEFAULT);
            } else if (i4 == 1) {
                this.fontCells[i4].setTextAndTypeface("Serif", Typeface.SERIF);
            }
            this.fontCells[i4].select(i4 == this.selectedFont);
            this.fontCells[i4].setTag(Integer.valueOf(i4));
            this.fontCells[i4].setOnClickListener(new View.OnClickListener() {
                /* class im.guobwnxjuc.ui.$$Lambda$ArticleViewer$PhU1pOGbG__pM2jYnV4LwyABrM */

                public final void onClick(View view) {
                    ArticleViewer.this.lambda$setParentActivity$17$ArticleViewer(view);
                }
            });
            linearLayout.addView(this.fontCells[i4], LayoutHelper.createLinear(-1, 50));
            i4++;
        }
        View view3 = new View(this.parentActivity);
        view3.setBackgroundColor(-2039584);
        linearLayout.addView(view3, LayoutHelper.createLinear(-1, 1, 15.0f, 4.0f, 15.0f, 4.0f));
        view3.getLayoutParams().height = 1;
        TextView textView = new TextView(this.parentActivity);
        textView.setTextColor(-14606047);
        textView.setTextSize(1, 16.0f);
        textView.setLines(1);
        textView.setMaxLines(1);
        textView.setSingleLine(true);
        textView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
        textView.setGravity((LocaleController.isRTL ? 5 : 3) | 48);
        textView.setText(LocaleController.getString("FontSize", R.string.FontSize));
        linearLayout.addView(textView, LayoutHelper.createLinear(-2, -2, (LocaleController.isRTL ? 5 : 3) | 48, 17, 12, 17, 0));
        linearLayout.addView(new SizeChooseView(this.parentActivity), LayoutHelper.createLinear(-1, 38, 0.0f, 0.0f, 0.0f, 1.0f));
        ActionBarMenuItem actionBarMenuItem = new ActionBarMenuItem(this.parentActivity, null, Theme.ACTION_BAR_WHITE_SELECTOR_COLOR, -1);
        this.settingsButton = actionBarMenuItem;
        actionBarMenuItem.setPopupAnimationEnabled(false);
        this.settingsButton.setLayoutInScreen(true);
        TextView textView2 = new TextView(this.parentActivity);
        textView2.setTextSize(1, 18.0f);
        textView2.setText("Aa");
        textView2.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
        textView2.setTextColor(-5000269);
        textView2.setGravity(17);
        textView2.setImportantForAccessibility(2);
        this.settingsButton.addView(textView2, LayoutHelper.createFrame(-1, -1.0f));
        this.settingsButton.addSubItem(linearLayout, AndroidUtilities.dp(220.0f), -2);
        this.settingsButton.redrawPopup(-1);
        this.settingsButton.setContentDescription(LocaleController.getString("Settings", R.string.Settings));
        this.headerView.addView(this.settingsButton, LayoutHelper.createFrame(48.0f, 56.0f, 53, 0.0f, 0.0f, 56.0f, 0.0f));
        FrameLayout frameLayout2 = new FrameLayout(activity);
        this.shareContainer = frameLayout2;
        this.headerView.addView(frameLayout2, LayoutHelper.createFrame(48, 56, 53));
        this.shareContainer.setOnClickListener(new View.OnClickListener() {
            /* class im.guobwnxjuc.ui.$$Lambda$ArticleViewer$Y423H2T2whkqgIL9NujF9VFhX20 */

            public final void onClick(View view) {
                ArticleViewer.this.lambda$setParentActivity$18$ArticleViewer(view);
            }
        });
        ImageView imageView3 = new ImageView(activity);
        this.shareButton = imageView3;
        imageView3.setScaleType(ImageView.ScaleType.CENTER);
        this.shareButton.setImageResource(R.drawable.ic_share_article);
        this.shareButton.setBackgroundDrawable(Theme.createSelectorDrawable(Theme.ACTION_BAR_WHITE_SELECTOR_COLOR));
        this.shareButton.setContentDescription(LocaleController.getString("ShareFile", R.string.ShareFile));
        this.shareContainer.addView(this.shareButton, LayoutHelper.createFrame(48, 56.0f));
        ContextProgressView contextProgressView = new ContextProgressView(activity, 2);
        this.progressView = contextProgressView;
        contextProgressView.setVisibility(8);
        this.shareContainer.addView(this.progressView, LayoutHelper.createFrame(48, 56.0f));
        WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams();
        this.windowLayoutParams = layoutParams;
        layoutParams.height = -1;
        this.windowLayoutParams.format = -3;
        this.windowLayoutParams.width = -1;
        this.windowLayoutParams.gravity = 51;
        this.windowLayoutParams.type = 99;
        if (Build.VERSION.SDK_INT >= 21) {
            this.windowLayoutParams.flags = -2147417848;
            if (Build.VERSION.SDK_INT >= 28) {
                this.windowLayoutParams.layoutInDisplayCutoutMode = 1;
            }
        } else {
            this.windowLayoutParams.flags = 8;
        }
        if (progressDrawables == null) {
            Drawable[] drawableArr = new Drawable[4];
            progressDrawables = drawableArr;
            drawableArr[0] = this.parentActivity.getResources().getDrawable(R.drawable.circle_big);
            progressDrawables[1] = this.parentActivity.getResources().getDrawable(R.drawable.cancel_big);
            progressDrawables[2] = this.parentActivity.getResources().getDrawable(R.drawable.load_big);
            progressDrawables[3] = this.parentActivity.getResources().getDrawable(R.drawable.play_big);
        }
        this.scroller = new Scroller(activity);
        this.blackPaint.setColor(-16777216);
        ActionBar actionBar2 = new ActionBar(activity);
        this.actionBar = actionBar2;
        actionBar2.setBackgroundColor(Theme.ACTION_BAR_PHOTO_VIEWER_COLOR);
        this.actionBar.setOccupyStatusBar(false);
        this.actionBar.setTitleColor(-1);
        this.actionBar.setItemsBackgroundColor(Theme.ACTION_BAR_WHITE_SELECTOR_COLOR, false);
        this.actionBar.setBackButtonImage(R.mipmap.ic_back);
        this.actionBar.setTitle(LocaleController.formatString("Of", R.string.Of, 1, 1));
        this.photoContainerView.addView(this.actionBar, LayoutHelper.createFrame(-1, -2.0f));
        this.actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
            /* class im.guobwnxjuc.ui.ArticleViewer.AnonymousClass9 */

            @Override // im.guobwnxjuc.ui.actionbar.ActionBar.ActionBarMenuOnItemClick
            public void onItemClick(int i) {
                if (i == -1) {
                    ArticleViewer.this.closePhoto(true);
                } else if (i == 1) {
                    if (Build.VERSION.SDK_INT < 23 || ArticleViewer.this.parentActivity.checkSelfPermission(PermissionUtils.EXTERNAL_STORAGE) == 0) {
                        ArticleViewer articleViewer = ArticleViewer.this;
                        File mediaFile = articleViewer.getMediaFile(articleViewer.currentIndex);
                        if (mediaFile == null || !mediaFile.exists()) {
                            AlertDialog.Builder builder = new AlertDialog.Builder(ArticleViewer.this.parentActivity);
                            builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
                            builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), null);
                            builder.setMessage(LocaleController.getString("PleaseDownload", R.string.PleaseDownload));
                            ArticleViewer.this.showDialog(builder.create());
                            return;
                        }
                        String file = mediaFile.toString();
                        Activity activity = ArticleViewer.this.parentActivity;
                        ArticleViewer articleViewer2 = ArticleViewer.this;
                        MediaController.saveFile(file, activity, articleViewer2.isMediaVideo(articleViewer2.currentIndex) ? 1 : 0, null, null);
                        return;
                    }
                    ArticleViewer.this.parentActivity.requestPermissions(new String[]{PermissionUtils.EXTERNAL_STORAGE}, 4);
                } else if (i == 2) {
                    ArticleViewer.this.onSharePressed();
                } else if (i == 3) {
                    try {
                        AndroidUtilities.openForView(ArticleViewer.this.getMedia(ArticleViewer.this.currentIndex), ArticleViewer.this.parentActivity);
                        ArticleViewer.this.closePhoto(false);
                    } catch (Exception e) {
                        FileLog.e(e);
                    }
                }
            }

            @Override // im.guobwnxjuc.ui.actionbar.ActionBar.ActionBarMenuOnItemClick
            public boolean canOpenMenu() {
                ArticleViewer articleViewer = ArticleViewer.this;
                File mediaFile = articleViewer.getMediaFile(articleViewer.currentIndex);
                return mediaFile != null && mediaFile.exists();
            }
        });
        ActionBarMenu createMenu = this.actionBar.createMenu();
        createMenu.addItem(2, R.drawable.share);
        ActionBarMenuItem addItem = createMenu.addItem(0, R.drawable.ic_ab_other);
        this.menuItem = addItem;
        addItem.setLayoutInScreen(true);
        this.menuItem.addSubItem(3, R.drawable.msg_openin, LocaleController.getString("OpenInExternalApp", R.string.OpenInExternalApp)).setColors(-328966, -328966);
        this.menuItem.addSubItem(1, R.drawable.msg_gallery, LocaleController.getString("SaveToGallery", R.string.SaveToGallery)).setColors(-328966, -328966);
        this.menuItem.redrawPopup(-115203550);
        FrameLayout frameLayout3 = new FrameLayout(this.parentActivity);
        this.bottomLayout = frameLayout3;
        frameLayout3.setBackgroundColor(Theme.ACTION_BAR_PHOTO_VIEWER_COLOR);
        this.photoContainerView.addView(this.bottomLayout, LayoutHelper.createFrame(-1, 48, 83));
        GroupedPhotosListView groupedPhotosListView2 = new GroupedPhotosListView(this.parentActivity);
        this.groupedPhotosListView = groupedPhotosListView2;
        this.photoContainerView.addView(groupedPhotosListView2, LayoutHelper.createFrame(-1.0f, 62.0f, 83, 0.0f, 0.0f, 0.0f, 0.0f));
        this.groupedPhotosListView.setDelegate(new GroupedPhotosListView.GroupedPhotosListViewDelegate() {
            /* class im.guobwnxjuc.ui.ArticleViewer.AnonymousClass10 */

            @Override // im.guobwnxjuc.ui.components.GroupedPhotosListView.GroupedPhotosListViewDelegate
            public int getAvatarsDialogId() {
                return 0;
            }

            @Override // im.guobwnxjuc.ui.components.GroupedPhotosListView.GroupedPhotosListViewDelegate
            public ArrayList<MessageObject> getImagesArr() {
                return null;
            }

            @Override // im.guobwnxjuc.ui.components.GroupedPhotosListView.GroupedPhotosListViewDelegate
            public ArrayList<ImageLocation> getImagesArrLocations() {
                return null;
            }

            @Override // im.guobwnxjuc.ui.components.GroupedPhotosListView.GroupedPhotosListViewDelegate
            public int getSlideshowMessageId() {
                return 0;
            }

            @Override // im.guobwnxjuc.ui.components.GroupedPhotosListView.GroupedPhotosListViewDelegate
            public int getCurrentIndex() {
                return ArticleViewer.this.currentIndex;
            }

            @Override // im.guobwnxjuc.ui.components.GroupedPhotosListView.GroupedPhotosListViewDelegate
            public int getCurrentAccount() {
                return ArticleViewer.this.currentAccount;
            }

            @Override // im.guobwnxjuc.ui.components.GroupedPhotosListView.GroupedPhotosListViewDelegate
            public ArrayList<TLRPC.PageBlock> getPageBlockArr() {
                return ArticleViewer.this.imagesArr;
            }

            @Override // im.guobwnxjuc.ui.components.GroupedPhotosListView.GroupedPhotosListViewDelegate
            public Object getParentObject() {
                return ArticleViewer.this.currentPage;
            }

            @Override // im.guobwnxjuc.ui.components.GroupedPhotosListView.GroupedPhotosListViewDelegate
            public void setCurrentIndex(int i) {
                ArticleViewer.this.currentIndex = -1;
                if (ArticleViewer.this.currentThumb != null) {
                    ArticleViewer.this.currentThumb.release();
                    ArticleViewer.this.currentThumb = null;
                }
                ArticleViewer.this.setImageIndex(i, true);
            }
        });
        TextView textView3 = new TextView(activity);
        this.captionTextViewNext = textView3;
        textView3.setMaxLines(10);
        this.captionTextViewNext.setBackgroundColor(Theme.ACTION_BAR_PHOTO_VIEWER_COLOR);
        this.captionTextViewNext.setMovementMethod(new LinkMovementMethodMy());
        this.captionTextViewNext.setPadding(AndroidUtilities.dp(20.0f), AndroidUtilities.dp(8.0f), AndroidUtilities.dp(20.0f), AndroidUtilities.dp(8.0f));
        this.captionTextViewNext.setLinkTextColor(-1);
        this.captionTextViewNext.setTextColor(-1);
        this.captionTextViewNext.setHighlightColor(872415231);
        this.captionTextViewNext.setGravity(19);
        this.captionTextViewNext.setTextSize(1, 16.0f);
        this.captionTextViewNext.setVisibility(8);
        this.photoContainerView.addView(this.captionTextViewNext, LayoutHelper.createFrame(-1, -2, 83));
        TextView textView4 = new TextView(activity);
        this.captionTextView = textView4;
        textView4.setMaxLines(10);
        this.captionTextView.setBackgroundColor(Theme.ACTION_BAR_PHOTO_VIEWER_COLOR);
        this.captionTextView.setMovementMethod(new LinkMovementMethodMy());
        this.captionTextView.setPadding(AndroidUtilities.dp(20.0f), AndroidUtilities.dp(8.0f), AndroidUtilities.dp(20.0f), AndroidUtilities.dp(8.0f));
        this.captionTextView.setLinkTextColor(-1);
        this.captionTextView.setTextColor(-1);
        this.captionTextView.setHighlightColor(872415231);
        this.captionTextView.setGravity(19);
        this.captionTextView.setTextSize(1, 16.0f);
        this.captionTextView.setVisibility(8);
        this.photoContainerView.addView(this.captionTextView, LayoutHelper.createFrame(-1, -2, 83));
        this.radialProgressViews[0] = new RadialProgressView(activity, this.photoContainerView);
        this.radialProgressViews[0].setBackgroundState(0, false);
        this.radialProgressViews[1] = new RadialProgressView(activity, this.photoContainerView);
        this.radialProgressViews[1].setBackgroundState(0, false);
        this.radialProgressViews[2] = new RadialProgressView(activity, this.photoContainerView);
        this.radialProgressViews[2].setBackgroundState(0, false);
        SeekBar seekBar = new SeekBar(activity);
        this.videoPlayerSeekbar = seekBar;
        seekBar.setColors(1728053247, 1728053247, -2764585, -1, -1);
        this.videoPlayerSeekbar.setDelegate(new SeekBar.SeekBarDelegate() {
            /* class im.guobwnxjuc.ui.$$Lambda$ArticleViewer$pKcWu_3Ik4p6iH74mvxDxy1Kk0s */

            @Override // im.guobwnxjuc.ui.components.SeekBar.SeekBarDelegate
            public /* synthetic */ void onSeekBarContinuousDrag(float f) {
                SeekBar.SeekBarDelegate.CC.$default$onSeekBarContinuousDrag(this, f);
            }

            @Override // im.guobwnxjuc.ui.components.SeekBar.SeekBarDelegate
            public final void onSeekBarDrag(float f) {
                ArticleViewer.this.lambda$setParentActivity$19$ArticleViewer(f);
            }
        });
        AnonymousClass11 r24 = new FrameLayout(activity) {
            /* class im.guobwnxjuc.ui.ArticleViewer.AnonymousClass11 */

            public boolean onTouchEvent(MotionEvent motionEvent) {
                motionEvent.getX();
                motionEvent.getY();
                if (!ArticleViewer.this.videoPlayerSeekbar.onTouch(motionEvent.getAction(), motionEvent.getX() - ((float) AndroidUtilities.dp(48.0f)), motionEvent.getY())) {
                    return super.onTouchEvent(motionEvent);
                }
                getParent().requestDisallowInterceptTouchEvent(true);
                invalidate();
                return true;
            }

            /* access modifiers changed from: protected */
            public void onMeasure(int i, int i2) {
                super.onMeasure(i, i2);
                long j = 0;
                if (ArticleViewer.this.videoPlayer != null) {
                    long duration = ArticleViewer.this.videoPlayer.getDuration();
                    if (duration != C.TIME_UNSET) {
                        j = duration;
                    }
                }
                long j2 = j / 1000;
                TextPaint paint = ArticleViewer.this.videoPlayerTime.getPaint();
                long j3 = j2 / 60;
                long j4 = j2 % 60;
                Object[] objArr = {Long.valueOf(j3), Long.valueOf(j4), Long.valueOf(j3), Long.valueOf(j4)};
                ArticleViewer.this.videoPlayerSeekbar.setSize((getMeasuredWidth() - AndroidUtilities.dp(64.0f)) - ((int) Math.ceil((double) paint.measureText(String.format("%02d:%02d / %02d:%02d", objArr)))), getMeasuredHeight());
            }

            /* access modifiers changed from: protected */
            public void onLayout(boolean z, int i, int i2, int i3, int i4) {
                super.onLayout(z, i, i2, i3, i4);
                ArticleViewer.this.videoPlayerSeekbar.setProgress(ArticleViewer.this.videoPlayer != null ? ((float) ArticleViewer.this.videoPlayer.getCurrentPosition()) / ((float) ArticleViewer.this.videoPlayer.getDuration()) : 0.0f);
            }

            /* access modifiers changed from: protected */
            public void onDraw(Canvas canvas) {
                canvas.save();
                canvas.translate((float) AndroidUtilities.dp(48.0f), 0.0f);
                ArticleViewer.this.videoPlayerSeekbar.draw(canvas);
                canvas.restore();
            }
        };
        this.videoPlayerControlFrameLayout = r24;
        r24.setWillNotDraw(false);
        this.bottomLayout.addView(this.videoPlayerControlFrameLayout, LayoutHelper.createFrame(-1, -1, 51));
        ImageView imageView4 = new ImageView(activity);
        this.videoPlayButton = imageView4;
        imageView4.setScaleType(ImageView.ScaleType.CENTER);
        this.videoPlayerControlFrameLayout.addView(this.videoPlayButton, LayoutHelper.createFrame(48, 48, 51));
        this.videoPlayButton.setOnClickListener(new View.OnClickListener() {
            /* class im.guobwnxjuc.ui.$$Lambda$ArticleViewer$YkVvjjXyKsnwhX9fp0WWVkNnUec */

            public final void onClick(View view) {
                ArticleViewer.this.lambda$setParentActivity$20$ArticleViewer(view);
            }
        });
        TextView textView5 = new TextView(activity);
        this.videoPlayerTime = textView5;
        textView5.setTextColor(-1);
        this.videoPlayerTime.setGravity(16);
        this.videoPlayerTime.setTextSize(1, 13.0f);
        this.videoPlayerControlFrameLayout.addView(this.videoPlayerTime, LayoutHelper.createFrame(-2.0f, -1.0f, 53, 0.0f, 0.0f, 8.0f, 0.0f));
        GestureDetector gestureDetector2 = new GestureDetector(activity, this);
        this.gestureDetector = gestureDetector2;
        gestureDetector2.setOnDoubleTapListener(this);
        this.centerImage.setParentView(this.photoContainerView);
        this.centerImage.setCrossfadeAlpha((byte) 2);
        this.centerImage.setInvalidateAll(true);
        this.leftImage.setParentView(this.photoContainerView);
        this.leftImage.setCrossfadeAlpha((byte) 2);
        this.leftImage.setInvalidateAll(true);
        this.rightImage.setParentView(this.photoContainerView);
        this.rightImage.setCrossfadeAlpha((byte) 2);
        this.rightImage.setInvalidateAll(true);
        updatePaintColors();
    }

    public /* synthetic */ WindowInsets lambda$setParentActivity$7$ArticleViewer(View view, WindowInsets windowInsets) {
        DisplayCutout displayCutout;
        List<Rect> boundingRects;
        WindowInsets windowInsets2 = (WindowInsets) this.lastInsets;
        this.lastInsets = windowInsets;
        if (windowInsets2 == null || !windowInsets2.toString().equals(windowInsets.toString())) {
            this.windowView.requestLayout();
        }
        if (Build.VERSION.SDK_INT >= 28 && (displayCutout = this.parentActivity.getWindow().getDecorView().getRootWindowInsets().getDisplayCutout()) != null && (boundingRects = displayCutout.getBoundingRects()) != null && !boundingRects.isEmpty()) {
            boolean z = false;
            if (boundingRects.get(0).height() != 0) {
                z = true;
            }
            this.hasCutout = z;
        }
        return windowInsets.consumeSystemWindowInsets();
    }

    public /* synthetic */ boolean lambda$setParentActivity$8$ArticleViewer(View view, int i) {
        if (!(view instanceof BlockRelatedArticlesCell)) {
            return false;
        }
        BlockRelatedArticlesCell blockRelatedArticlesCell = (BlockRelatedArticlesCell) view;
        showCopyPopup(blockRelatedArticlesCell.currentBlock.parent.articles.get(blockRelatedArticlesCell.currentBlock.num).url);
        return true;
    }

    public /* synthetic */ void lambda$setParentActivity$11$ArticleViewer(WebpageAdapter webpageAdapter, View view, int i) {
        if (i != webpageAdapter.localBlocks.size() || this.currentPage == null) {
            if (i >= 0 && i < webpageAdapter.localBlocks.size()) {
                TLRPC.PageBlock pageBlock = (TLRPC.PageBlock) webpageAdapter.localBlocks.get(i);
                TLRPC.PageBlock lastNonListPageBlock = getLastNonListPageBlock(pageBlock);
                if (lastNonListPageBlock instanceof TL_pageBlockDetailsChild) {
                    lastNonListPageBlock = ((TL_pageBlockDetailsChild) lastNonListPageBlock).block;
                }
                if (lastNonListPageBlock instanceof TLRPC.TL_pageBlockChannel) {
                    MessagesController.getInstance(this.currentAccount).openByUserName(((TLRPC.TL_pageBlockChannel) lastNonListPageBlock).channel.username, this.parentFragment, 2);
                    close(false, true);
                } else if (lastNonListPageBlock instanceof TL_pageBlockRelatedArticlesChild) {
                    TL_pageBlockRelatedArticlesChild tL_pageBlockRelatedArticlesChild = (TL_pageBlockRelatedArticlesChild) lastNonListPageBlock;
                    openWebpageUrl(tL_pageBlockRelatedArticlesChild.parent.articles.get(tL_pageBlockRelatedArticlesChild.num).url, null);
                } else if (lastNonListPageBlock instanceof TLRPC.TL_pageBlockDetails) {
                    View lastNonListCell = getLastNonListCell(view);
                    if (lastNonListCell instanceof BlockDetailsCell) {
                        this.pressedLinkOwnerLayout = null;
                        this.pressedLinkOwnerView = null;
                        if (webpageAdapter.blocks.indexOf(pageBlock) >= 0) {
                            TLRPC.TL_pageBlockDetails tL_pageBlockDetails = (TLRPC.TL_pageBlockDetails) lastNonListPageBlock;
                            tL_pageBlockDetails.open = !tL_pageBlockDetails.open;
                            int itemCount = webpageAdapter.getItemCount();
                            webpageAdapter.updateRows();
                            int abs = Math.abs(webpageAdapter.getItemCount() - itemCount);
                            BlockDetailsCell blockDetailsCell = (BlockDetailsCell) lastNonListCell;
                            blockDetailsCell.arrow.setAnimationProgressAnimated(tL_pageBlockDetails.open ? 0.0f : 1.0f);
                            blockDetailsCell.invalidate();
                            if (abs == 0) {
                                return;
                            }
                            if (tL_pageBlockDetails.open) {
                                webpageAdapter.notifyItemRangeInserted(i + 1, abs);
                            } else {
                                webpageAdapter.notifyItemRangeRemoved(i + 1, abs);
                            }
                        }
                    }
                }
            }
        } else if (this.previewsReqId == 0) {
            TLObject userOrChat = MessagesController.getInstance(this.currentAccount).getUserOrChat("previews");
            if (userOrChat instanceof TLRPC.TL_user) {
                openPreviewsChat((TLRPC.User) userOrChat, this.currentPage.id);
                return;
            }
            int i2 = UserConfig.selectedAccount;
            long j = this.currentPage.id;
            showProgressView(true, true);
            TLRPC.TL_contacts_resolveUsername tL_contacts_resolveUsername = new TLRPC.TL_contacts_resolveUsername();
            tL_contacts_resolveUsername.username = "previews";
            this.previewsReqId = ConnectionsManager.getInstance(i2).sendRequest(tL_contacts_resolveUsername, new RequestDelegate(i2, j) {
                /* class im.guobwnxjuc.ui.$$Lambda$ArticleViewer$48LFfQ27FoAku5TENXq0YQ1ilA */
                private final /* synthetic */ int f$1;
                private final /* synthetic */ long f$2;

                {
                    this.f$1 = r2;
                    this.f$2 = r3;
                }

                @Override // im.guobwnxjuc.tgnet.RequestDelegate
                public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                    ArticleViewer.this.lambda$null$10$ArticleViewer(this.f$1, this.f$2, tLObject, tL_error);
                }
            });
        }
    }

    public /* synthetic */ void lambda$null$10$ArticleViewer(int i, long j, TLObject tLObject, TLRPC.TL_error tL_error) {
        AndroidUtilities.runOnUIThread(new Runnable(tLObject, i, j) {
            /* class im.guobwnxjuc.ui.$$Lambda$ArticleViewer$n_613retokqsDQfDW52TKUp9De0 */
            private final /* synthetic */ TLObject f$1;
            private final /* synthetic */ int f$2;
            private final /* synthetic */ long f$3;

            {
                this.f$1 = r2;
                this.f$2 = r3;
                this.f$3 = r4;
            }

            public final void run() {
                ArticleViewer.this.lambda$null$9$ArticleViewer(this.f$1, this.f$2, this.f$3);
            }
        });
    }

    public /* synthetic */ void lambda$null$9$ArticleViewer(TLObject tLObject, int i, long j) {
        if (this.previewsReqId != 0) {
            this.previewsReqId = 0;
            showProgressView(true, false);
            if (tLObject != null) {
                TLRPC.TL_contacts_resolvedPeer tL_contacts_resolvedPeer = (TLRPC.TL_contacts_resolvedPeer) tLObject;
                MessagesController.getInstance(i).putUsers(tL_contacts_resolvedPeer.users, false);
                MessagesStorage.getInstance(i).putUsersAndChats(tL_contacts_resolvedPeer.users, tL_contacts_resolvedPeer.chats, false, true);
                if (!tL_contacts_resolvedPeer.users.isEmpty()) {
                    openPreviewsChat(tL_contacts_resolvedPeer.users.get(0), j);
                }
            }
        }
    }

    public /* synthetic */ void lambda$setParentActivity$13$ArticleViewer(View view) {
        close(true, true);
    }

    public /* synthetic */ void lambda$setParentActivity$14$ArticleViewer() {
        float currentProgress = 0.7f - this.lineProgressView.getCurrentProgress();
        if (currentProgress > 0.0f) {
            float f = currentProgress < 0.25f ? 0.01f : 0.02f;
            LineProgressView lineProgressView2 = this.lineProgressView;
            lineProgressView2.setProgress(lineProgressView2.getCurrentProgress() + f, true);
            AndroidUtilities.runOnUIThread(this.lineProgressTickRunnable, 100);
        }
    }

    public /* synthetic */ void lambda$setParentActivity$15$ArticleViewer(View view) {
        this.nightModeEnabled = !this.nightModeEnabled;
        ApplicationLoader.applicationContext.getSharedPreferences("articles", 0).edit().putBoolean("nightModeEnabled", this.nightModeEnabled).commit();
        updateNightModeButton();
        updatePaintColors();
        for (int i = 0; i < this.listView.length; i++) {
            this.adapter[i].notifyDataSetChanged();
        }
        if (this.nightModeEnabled) {
            showNightModeHint();
        }
    }

    public /* synthetic */ void lambda$setParentActivity$16$ArticleViewer(View view) {
        int intValue = ((Integer) view.getTag()).intValue();
        this.selectedColor = intValue;
        int i = 0;
        while (i < 3) {
            this.colorCells[i].select(i == intValue);
            i++;
        }
        updateNightModeButton();
        updatePaintColors();
        for (int i2 = 0; i2 < this.listView.length; i2++) {
            this.adapter[i2].notifyDataSetChanged();
        }
    }

    public /* synthetic */ void lambda$setParentActivity$17$ArticleViewer(View view) {
        int intValue = ((Integer) view.getTag()).intValue();
        this.selectedFont = intValue;
        int i = 0;
        while (i < 2) {
            this.fontCells[i].select(i == intValue);
            i++;
        }
        updatePaintFonts();
        for (int i2 = 0; i2 < this.listView.length; i2++) {
            this.adapter[i2].notifyDataSetChanged();
        }
    }

    public /* synthetic */ void lambda$setParentActivity$18$ArticleViewer(View view) {
        if (this.currentPage != null && this.parentActivity != null) {
            showDialog(new ShareAlert(this.parentActivity, null, this.currentPage.url, false, this.currentPage.url, true));
        }
    }

    public /* synthetic */ void lambda$setParentActivity$19$ArticleViewer(float f) {
        VideoPlayer videoPlayer2 = this.videoPlayer;
        if (videoPlayer2 != null) {
            videoPlayer2.seekTo((long) ((int) (f * ((float) videoPlayer2.getDuration()))));
        }
    }

    public /* synthetic */ void lambda$setParentActivity$20$ArticleViewer(View view) {
        VideoPlayer videoPlayer2 = this.videoPlayer;
        if (videoPlayer2 == null) {
            return;
        }
        if (this.isPlaying) {
            videoPlayer2.pause();
        } else {
            videoPlayer2.play();
        }
    }

    private void showNightModeHint() {
        if (this.parentActivity != null && this.nightModeHintView == null && this.nightModeEnabled) {
            FrameLayout frameLayout = new FrameLayout(this.parentActivity);
            this.nightModeHintView = frameLayout;
            frameLayout.setBackgroundColor(Theme.ACTION_BAR_MEDIA_PICKER_COLOR);
            this.containerView.addView(this.nightModeHintView, LayoutHelper.createFrame(-1, -2, 83));
            ImageView imageView = new ImageView(this.parentActivity);
            imageView.setScaleType(ImageView.ScaleType.CENTER);
            imageView.setImageResource(R.drawable.moon);
            int i = 5;
            int i2 = 56;
            this.nightModeHintView.addView(imageView, LayoutHelper.createFrame(56, 56, (LocaleController.isRTL ? 5 : 3) | 16));
            TextView textView = new TextView(this.parentActivity);
            textView.setText(LocaleController.getString("InstantViewNightMode", R.string.InstantViewNightMode));
            textView.setTextColor(-1);
            textView.setTextSize(1, 15.0f);
            FrameLayout frameLayout2 = this.nightModeHintView;
            if (!LocaleController.isRTL) {
                i = 3;
            }
            int i3 = i | 48;
            float f = (float) (LocaleController.isRTL ? 10 : 56);
            if (!LocaleController.isRTL) {
                i2 = 10;
            }
            frameLayout2.addView(textView, LayoutHelper.createFrame(-1.0f, -1.0f, i3, f, 11.0f, (float) i2, 12.0f));
            AnimatorSet animatorSet = new AnimatorSet();
            animatorSet.playTogether(ObjectAnimator.ofFloat(this.nightModeHintView, View.TRANSLATION_Y, (float) AndroidUtilities.dp(100.0f), 0.0f));
            animatorSet.setInterpolator(new DecelerateInterpolator(1.5f));
            animatorSet.addListener(new AnimatorListenerAdapter() {
                /* class im.guobwnxjuc.ui.ArticleViewer.AnonymousClass12 */

                public void onAnimationEnd(Animator animator) {
                    AndroidUtilities.runOnUIThread(new Runnable() {
                        /* class im.guobwnxjuc.ui.$$Lambda$ArticleViewer$12$zJK4ma8STuDVDaOndHm_YumKw */

                        public final void run() {
                            ArticleViewer.AnonymousClass12.this.lambda$onAnimationEnd$0$ArticleViewer$12();
                        }
                    }, 3000);
                }

                public /* synthetic */ void lambda$onAnimationEnd$0$ArticleViewer$12() {
                    AnimatorSet animatorSet = new AnimatorSet();
                    animatorSet.playTogether(ObjectAnimator.ofFloat(ArticleViewer.this.nightModeHintView, View.TRANSLATION_Y, (float) AndroidUtilities.dp(100.0f)));
                    animatorSet.setInterpolator(new DecelerateInterpolator(1.5f));
                    animatorSet.setDuration(250L);
                    animatorSet.start();
                }
            });
            animatorSet.setDuration(250L);
            animatorSet.start();
        }
    }

    private void updateNightModeButton() {
        this.nightModeImageView.setEnabled(this.selectedColor != 2);
        this.nightModeImageView.setAlpha(this.selectedColor == 2 ? 0.5f : 1.0f);
        this.nightModeImageView.setColorFilter(new PorterDuffColorFilter((!this.nightModeEnabled || this.selectedColor == 2) ? -3355444 : -15428119, PorterDuff.Mode.MULTIPLY));
    }

    public class ScrollEvaluator extends IntEvaluator {
        public ScrollEvaluator() {
        }

        @Override // android.animation.IntEvaluator
        public Integer evaluate(float f, Integer num, Integer num2) {
            return super.evaluate(f, num, num2);
        }
    }

    private void checkScrollAnimated() {
        if (this.currentHeaderHeight != AndroidUtilities.dp(56.0f)) {
            ValueAnimator duration = ValueAnimator.ofObject(new IntEvaluator(), Integer.valueOf(this.currentHeaderHeight), Integer.valueOf(AndroidUtilities.dp(56.0f))).setDuration(180L);
            duration.setInterpolator(new DecelerateInterpolator());
            duration.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
                /* class im.guobwnxjuc.ui.$$Lambda$ArticleViewer$Tyf0e2g7R3IDl6R8qAHvNpuq3IQ */

                public final void onAnimationUpdate(ValueAnimator valueAnimator) {
                    ArticleViewer.this.lambda$checkScrollAnimated$21$ArticleViewer(valueAnimator);
                }
            });
            duration.start();
        }
    }

    public /* synthetic */ void lambda$checkScrollAnimated$21$ArticleViewer(ValueAnimator valueAnimator) {
        setCurrentHeaderHeight(((Integer) valueAnimator.getAnimatedValue()).intValue());
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private void setCurrentHeaderHeight(int i) {
        int dp = AndroidUtilities.dp(56.0f);
        int max = Math.max(AndroidUtilities.statusBarHeight, AndroidUtilities.dp(24.0f));
        if (i < max) {
            i = max;
        } else if (i > dp) {
            i = dp;
        }
        float f = (float) (dp - max);
        this.currentHeaderHeight = i;
        float f2 = ((((float) (i - max)) / f) * 0.2f) + 0.8f;
        this.backButton.setScaleX(f2);
        this.backButton.setScaleY(f2);
        this.backButton.setTranslationY((float) ((dp - this.currentHeaderHeight) / 2));
        this.shareContainer.setScaleX(f2);
        this.shareContainer.setScaleY(f2);
        this.settingsButton.setScaleX(f2);
        this.settingsButton.setScaleY(f2);
        this.titleTextView.setScaleX(f2);
        this.titleTextView.setScaleY(f2);
        this.lineProgressView.setScaleY(((((float) (i - max)) / f) * 0.5f) + 0.5f);
        this.shareContainer.setTranslationY((float) ((dp - this.currentHeaderHeight) / 2));
        this.settingsButton.setTranslationY((float) ((dp - this.currentHeaderHeight) / 2));
        this.titleTextView.setTranslationY((float) ((dp - this.currentHeaderHeight) / 2));
        this.headerView.setTranslationY((float) (this.currentHeaderHeight - dp));
        int i2 = 0;
        while (true) {
            RecyclerListView[] recyclerListViewArr = this.listView;
            if (i2 < recyclerListViewArr.length) {
                recyclerListViewArr[i2].setTopGlowOffset(this.currentHeaderHeight);
                i2++;
            } else {
                return;
            }
        }
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private void checkScroll(int i) {
        setCurrentHeaderHeight(this.currentHeaderHeight - i);
    }

    private void openPreviewsChat(TLRPC.User user, long j) {
        if (user != null && this.parentActivity != null) {
            Bundle bundle = new Bundle();
            bundle.putInt("user_id", user.id);
            bundle.putString("botUser", "webpage" + j);
            ((LaunchActivity) this.parentActivity).presentFragment(new ChatActivity(bundle), false, true);
            close(false, true);
        }
    }

    public boolean open(MessageObject messageObject) {
        return open(messageObject, null, null, true);
    }

    public boolean open(TLRPC.TL_webPage tL_webPage, String str) {
        return open(null, tL_webPage, str, true);
    }

    /* JADX WARNING: Can't wrap try/catch for region: R(6:58|(2:60|61)|62|63|(2:65|(1:67))|68) */
    /* JADX WARNING: Code restructure failed: missing block: B:69:0x018b, code lost:
        r12 = move-exception;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:70:0x018c, code lost:
        im.guobwnxjuc.messenger.FileLog.e(r12);
     */
    /* JADX WARNING: Code restructure failed: missing block: B:71:0x018f, code lost:
        return false;
     */
    /* JADX WARNING: Failed to process nested try/catch */
    /* JADX WARNING: Missing exception handler attribute for start block: B:62:0x015a */
    /* JADX WARNING: Removed duplicated region for block: B:41:0x00fb  */
    /* JADX WARNING: Removed duplicated region for block: B:42:0x0103  */
    /* JADX WARNING: Removed duplicated region for block: B:45:0x010c  */
    /* JADX WARNING: Removed duplicated region for block: B:58:0x0149  */
    /* JADX WARNING: Removed duplicated region for block: B:65:0x0160 A[Catch:{ Exception -> 0x018b }] */
    /* JADX WARNING: Removed duplicated region for block: B:72:0x0190  */
    /* JADX WARNING: Removed duplicated region for block: B:75:0x0221  */
    private boolean open(MessageObject messageObject, TLRPC.WebPage webPage, String str, boolean z) {
        String str2;
        TLRPC.WebPage webPage2;
        int lastIndexOf;
        String lowerCase;
        String str3;
        if (this.parentActivity == null || ((this.isVisible && !this.collapsed) || (messageObject == null && webPage == null))) {
            return false;
        }
        if (messageObject != null) {
            webPage = messageObject.messageOwner.media.webpage;
        }
        if (messageObject != null) {
            webPage = messageObject.messageOwner.media.webpage;
            int i = 0;
            while (true) {
                if (i >= messageObject.messageOwner.entities.size()) {
                    break;
                }
                TLRPC.MessageEntity messageEntity = messageObject.messageOwner.entities.get(i);
                if (messageEntity instanceof TLRPC.TL_messageEntityUrl) {
                    try {
                        lowerCase = messageObject.messageOwner.message.substring(messageEntity.offset, messageEntity.offset + messageEntity.length).toLowerCase();
                        if (!TextUtils.isEmpty(webPage.cached_page.url)) {
                            str3 = webPage.cached_page.url.toLowerCase();
                        } else {
                            str3 = webPage.url.toLowerCase();
                        }
                        if (lowerCase.contains(str3) || str3.contains(lowerCase)) {
                            int lastIndexOf2 = lowerCase.lastIndexOf(35);
                        }
                    } catch (Exception e) {
                        FileLog.e(e);
                    }
                }
                i++;
            }
            int lastIndexOf22 = lowerCase.lastIndexOf(35);
            if (lastIndexOf22 != -1) {
                str2 = lowerCase.substring(lastIndexOf22 + 1);
            }
            str2 = null;
        } else if (str == null || (lastIndexOf = str.lastIndexOf(35)) == -1) {
            webPage2 = webPage;
            str2 = null;
            this.pagesStack.clear();
            this.collapsed = false;
            this.backDrawable.setRotation(0.0f, false);
            this.containerView.setTranslationX(0.0f);
            this.containerView.setTranslationY(0.0f);
            this.listView[0].setTranslationY(0.0f);
            this.listView[0].setTranslationX(0.0f);
            this.listView[1].setTranslationX(0.0f);
            this.listView[0].setAlpha(1.0f);
            this.windowView.setInnerTranslationX(0.0f);
            this.actionBar.setVisibility(8);
            this.bottomLayout.setVisibility(8);
            this.captionTextView.setVisibility(8);
            this.captionTextViewNext.setVisibility(8);
            this.layoutManager[0].scrollToPositionWithOffset(0, 0);
            if (!z) {
                setCurrentHeaderHeight(AndroidUtilities.dp(56.0f));
            } else {
                checkScrollAnimated();
            }
            boolean addPageToStack = addPageToStack(webPage2, str2, 0);
            if (z) {
                String str4 = (addPageToStack || str2 == null) ? null : str2;
                TLRPC.TL_messages_getWebPage tL_messages_getWebPage = new TLRPC.TL_messages_getWebPage();
                tL_messages_getWebPage.url = webPage2.url;
                if ((webPage2.cached_page instanceof TLRPC.TL_pagePart_layer82) || webPage2.cached_page.part) {
                    tL_messages_getWebPage.hash = 0;
                } else {
                    tL_messages_getWebPage.hash = webPage2.hash;
                }
                int i2 = UserConfig.selectedAccount;
                ConnectionsManager.getInstance(i2).sendRequest(tL_messages_getWebPage, new RequestDelegate(webPage2, messageObject, str4, i2) {
                    /* class im.guobwnxjuc.ui.$$Lambda$ArticleViewer$mIEvXiOWfbZQuYJFMCraS1aGnmE */
                    private final /* synthetic */ TLRPC.WebPage f$1;
                    private final /* synthetic */ MessageObject f$2;
                    private final /* synthetic */ String f$3;
                    private final /* synthetic */ int f$4;

                    {
                        this.f$1 = r2;
                        this.f$2 = r3;
                        this.f$3 = r4;
                        this.f$4 = r5;
                    }

                    @Override // im.guobwnxjuc.tgnet.RequestDelegate
                    public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                        ArticleViewer.this.lambda$open$23$ArticleViewer(this.f$1, this.f$2, this.f$3, this.f$4, tLObject, tL_error);
                    }
                });
            }
            this.lastInsets = null;
            if (this.isVisible) {
                WindowManager windowManager = (WindowManager) this.parentActivity.getSystemService("window");
                if (this.attachedToWindow) {
                    windowManager.removeView(this.windowView);
                }
                if (Build.VERSION.SDK_INT >= 21) {
                    this.windowLayoutParams.flags = -2147417856;
                    if (Build.VERSION.SDK_INT >= 28) {
                        this.windowLayoutParams.layoutInDisplayCutoutMode = 1;
                    }
                }
                this.windowLayoutParams.flags |= 1032;
                this.windowView.setFocusable(false);
                this.containerView.setFocusable(false);
                windowManager.addView(this.windowView, this.windowLayoutParams);
            } else {
                this.windowLayoutParams.flags &= -17;
                ((WindowManager) this.parentActivity.getSystemService("window")).updateViewLayout(this.windowView, this.windowLayoutParams);
            }
            this.isVisible = true;
            this.animationInProgress = 1;
            this.windowView.setAlpha(0.0f);
            this.containerView.setAlpha(0.0f);
            AnimatorSet animatorSet = new AnimatorSet();
            animatorSet.playTogether(ObjectAnimator.ofFloat(this.windowView, View.ALPHA, 0.0f, 1.0f), ObjectAnimator.ofFloat(this.containerView, View.ALPHA, 0.0f, 1.0f), ObjectAnimator.ofFloat(this.windowView, View.TRANSLATION_X, (float) AndroidUtilities.dp(56.0f), 0.0f));
            this.animationEndRunnable = new Runnable() {
                /* class im.guobwnxjuc.ui.$$Lambda$ArticleViewer$g9Yu2NVuz7lupm5f4mUGzF5G5hk */

                public final void run() {
                    ArticleViewer.this.lambda$open$24$ArticleViewer();
                }
            };
            animatorSet.setDuration(150L);
            animatorSet.setInterpolator(this.interpolator);
            animatorSet.addListener(new AnimatorListenerAdapter() {
                /* class im.guobwnxjuc.ui.ArticleViewer.AnonymousClass13 */

                public void onAnimationEnd(Animator animator) {
                    AndroidUtilities.runOnUIThread(new Runnable() {
                        /* class im.guobwnxjuc.ui.$$Lambda$ArticleViewer$13$Gs2pH5aY8znW9OaF1SHFZ8vRAHg */

                        public final void run() {
                            ArticleViewer.AnonymousClass13.this.lambda$onAnimationEnd$0$ArticleViewer$13();
                        }
                    });
                }

                public /* synthetic */ void lambda$onAnimationEnd$0$ArticleViewer$13() {
                    NotificationCenter.getInstance(ArticleViewer.this.currentAccount).setAnimationInProgress(false);
                    if (ArticleViewer.this.animationEndRunnable != null) {
                        ArticleViewer.this.animationEndRunnable.run();
                        ArticleViewer.this.animationEndRunnable = null;
                    }
                }
            });
            this.transitionAnimationStartTime = System.currentTimeMillis();
            AndroidUtilities.runOnUIThread(new Runnable(animatorSet) {
                /* class im.guobwnxjuc.ui.$$Lambda$ArticleViewer$JGHeizSe3o4sw45YIoznP2AkmU */
                private final /* synthetic */ AnimatorSet f$1;

                {
                    this.f$1 = r2;
                }

                public final void run() {
                    ArticleViewer.this.lambda$open$25$ArticleViewer(this.f$1);
                }
            });
            if (Build.VERSION.SDK_INT >= 18) {
                this.containerView.setLayerType(2, null);
            }
            return true;
        } else {
            str2 = str.substring(lastIndexOf + 1);
        }
        webPage2 = webPage;
        this.pagesStack.clear();
        this.collapsed = false;
        this.backDrawable.setRotation(0.0f, false);
        this.containerView.setTranslationX(0.0f);
        this.containerView.setTranslationY(0.0f);
        this.listView[0].setTranslationY(0.0f);
        this.listView[0].setTranslationX(0.0f);
        this.listView[1].setTranslationX(0.0f);
        this.listView[0].setAlpha(1.0f);
        this.windowView.setInnerTranslationX(0.0f);
        this.actionBar.setVisibility(8);
        this.bottomLayout.setVisibility(8);
        this.captionTextView.setVisibility(8);
        this.captionTextViewNext.setVisibility(8);
        this.layoutManager[0].scrollToPositionWithOffset(0, 0);
        if (!z) {
        }
        boolean addPageToStack2 = addPageToStack(webPage2, str2, 0);
        if (z) {
        }
        this.lastInsets = null;
        if (this.isVisible) {
        }
        this.isVisible = true;
        this.animationInProgress = 1;
        this.windowView.setAlpha(0.0f);
        this.containerView.setAlpha(0.0f);
        AnimatorSet animatorSet2 = new AnimatorSet();
        animatorSet2.playTogether(ObjectAnimator.ofFloat(this.windowView, View.ALPHA, 0.0f, 1.0f), ObjectAnimator.ofFloat(this.containerView, View.ALPHA, 0.0f, 1.0f), ObjectAnimator.ofFloat(this.windowView, View.TRANSLATION_X, (float) AndroidUtilities.dp(56.0f), 0.0f));
        this.animationEndRunnable = new Runnable() {
            /* class im.guobwnxjuc.ui.$$Lambda$ArticleViewer$g9Yu2NVuz7lupm5f4mUGzF5G5hk */

            public final void run() {
                ArticleViewer.this.lambda$open$24$ArticleViewer();
            }
        };
        animatorSet2.setDuration(150L);
        animatorSet2.setInterpolator(this.interpolator);
        animatorSet2.addListener(new AnimatorListenerAdapter() {
            /* class im.guobwnxjuc.ui.ArticleViewer.AnonymousClass13 */

            public void onAnimationEnd(Animator animator) {
                AndroidUtilities.runOnUIThread(new Runnable() {
                    /* class im.guobwnxjuc.ui.$$Lambda$ArticleViewer$13$Gs2pH5aY8znW9OaF1SHFZ8vRAHg */

                    public final void run() {
                        ArticleViewer.AnonymousClass13.this.lambda$onAnimationEnd$0$ArticleViewer$13();
                    }
                });
            }

            public /* synthetic */ void lambda$onAnimationEnd$0$ArticleViewer$13() {
                NotificationCenter.getInstance(ArticleViewer.this.currentAccount).setAnimationInProgress(false);
                if (ArticleViewer.this.animationEndRunnable != null) {
                    ArticleViewer.this.animationEndRunnable.run();
                    ArticleViewer.this.animationEndRunnable = null;
                }
            }
        });
        this.transitionAnimationStartTime = System.currentTimeMillis();
        AndroidUtilities.runOnUIThread(new Runnable(animatorSet2) {
            /* class im.guobwnxjuc.ui.$$Lambda$ArticleViewer$JGHeizSe3o4sw45YIoznP2AkmU */
            private final /* synthetic */ AnimatorSet f$1;

            {
                this.f$1 = r2;
            }

            public final void run() {
                ArticleViewer.this.lambda$open$25$ArticleViewer(this.f$1);
            }
        });
        if (Build.VERSION.SDK_INT >= 18) {
        }
        return true;
    }

    public /* synthetic */ void lambda$open$23$ArticleViewer(TLRPC.WebPage webPage, MessageObject messageObject, String str, int i, TLObject tLObject, TLRPC.TL_error tL_error) {
        if (tLObject instanceof TLRPC.TL_webPage) {
            TLRPC.TL_webPage tL_webPage = (TLRPC.TL_webPage) tLObject;
            if (tL_webPage.cached_page != null) {
                AndroidUtilities.runOnUIThread(new Runnable(webPage, tL_webPage, messageObject, str) {
                    /* class im.guobwnxjuc.ui.$$Lambda$ArticleViewer$9zGYf9d0Gax6wIZVskPEkJXquIs */
                    private final /* synthetic */ TLRPC.WebPage f$1;
                    private final /* synthetic */ TLRPC.TL_webPage f$2;
                    private final /* synthetic */ MessageObject f$3;
                    private final /* synthetic */ String f$4;

                    {
                        this.f$1 = r2;
                        this.f$2 = r3;
                        this.f$3 = r4;
                        this.f$4 = r5;
                    }

                    public final void run() {
                        ArticleViewer.this.lambda$null$22$ArticleViewer(this.f$1, this.f$2, this.f$3, this.f$4);
                    }
                });
                LongSparseArray<TLRPC.WebPage> longSparseArray = new LongSparseArray<>(1);
                longSparseArray.put(tL_webPage.id, tL_webPage);
                MessagesStorage.getInstance(i).putWebPages(longSparseArray);
            }
        }
    }

    public /* synthetic */ void lambda$null$22$ArticleViewer(TLRPC.WebPage webPage, TLRPC.TL_webPage tL_webPage, MessageObject messageObject, String str) {
        if (!this.pagesStack.isEmpty() && this.pagesStack.get(0) == webPage && tL_webPage.cached_page != null) {
            if (messageObject != null) {
                messageObject.messageOwner.media.webpage = tL_webPage;
            }
            this.pagesStack.set(0, tL_webPage);
            if (this.pagesStack.size() == 1) {
                this.currentPage = tL_webPage;
                SharedPreferences.Editor edit = ApplicationLoader.applicationContext.getSharedPreferences("articles", 0).edit();
                edit.remove("article" + this.currentPage.id).commit();
                updateInterfaceForCurrentPage(0);
                if (str != null) {
                    scrollToAnchor(str);
                }
            }
        }
    }

    public /* synthetic */ void lambda$open$24$ArticleViewer() {
        if (this.containerView != null && this.windowView != null) {
            if (Build.VERSION.SDK_INT >= 18) {
                this.containerView.setLayerType(0, null);
            }
            this.animationInProgress = 0;
            AndroidUtilities.hideKeyboard(this.parentActivity.getCurrentFocus());
        }
    }

    public /* synthetic */ void lambda$open$25$ArticleViewer(AnimatorSet animatorSet) {
        NotificationCenter.getInstance(this.currentAccount).setAllowedNotificationsDutingAnimation(new int[]{NotificationCenter.dialogsNeedReload, NotificationCenter.closeChats});
        NotificationCenter.getInstance(this.currentAccount).setAnimationInProgress(true);
        animatorSet.start();
    }

    private void showProgressView(boolean z, final boolean z2) {
        if (z) {
            AndroidUtilities.cancelRunOnUIThread(this.lineProgressTickRunnable);
            if (z2) {
                this.lineProgressView.setProgress(0.0f, false);
                this.lineProgressView.setProgress(0.3f, true);
                AndroidUtilities.runOnUIThread(this.lineProgressTickRunnable, 100);
                return;
            }
            this.lineProgressView.setProgress(1.0f, true);
            return;
        }
        AnimatorSet animatorSet = this.progressViewAnimation;
        if (animatorSet != null) {
            animatorSet.cancel();
        }
        this.progressViewAnimation = new AnimatorSet();
        if (z2) {
            this.progressView.setVisibility(0);
            this.shareContainer.setEnabled(false);
            this.progressViewAnimation.playTogether(ObjectAnimator.ofFloat(this.shareButton, View.SCALE_X, 0.1f), ObjectAnimator.ofFloat(this.shareButton, View.SCALE_Y, 0.1f), ObjectAnimator.ofFloat(this.shareButton, View.ALPHA, 0.0f), ObjectAnimator.ofFloat(this.progressView, View.SCALE_X, 1.0f), ObjectAnimator.ofFloat(this.progressView, View.SCALE_Y, 1.0f), ObjectAnimator.ofFloat(this.progressView, View.ALPHA, 1.0f));
        } else {
            this.shareButton.setVisibility(0);
            this.shareContainer.setEnabled(true);
            this.progressViewAnimation.playTogether(ObjectAnimator.ofFloat(this.progressView, View.SCALE_X, 0.1f), ObjectAnimator.ofFloat(this.progressView, View.SCALE_Y, 0.1f), ObjectAnimator.ofFloat(this.progressView, View.ALPHA, 0.0f), ObjectAnimator.ofFloat(this.shareButton, View.SCALE_X, 1.0f), ObjectAnimator.ofFloat(this.shareButton, View.SCALE_Y, 1.0f), ObjectAnimator.ofFloat(this.shareButton, View.ALPHA, 1.0f));
        }
        this.progressViewAnimation.addListener(new AnimatorListenerAdapter() {
            /* class im.guobwnxjuc.ui.ArticleViewer.AnonymousClass14 */

            public void onAnimationEnd(Animator animator) {
                if (ArticleViewer.this.progressViewAnimation != null && ArticleViewer.this.progressViewAnimation.equals(animator)) {
                    if (!z2) {
                        ArticleViewer.this.progressView.setVisibility(4);
                    } else {
                        ArticleViewer.this.shareButton.setVisibility(4);
                    }
                }
            }

            public void onAnimationCancel(Animator animator) {
                if (ArticleViewer.this.progressViewAnimation != null && ArticleViewer.this.progressViewAnimation.equals(animator)) {
                    ArticleViewer.this.progressViewAnimation = null;
                }
            }
        });
        this.progressViewAnimation.setDuration(150L);
        this.progressViewAnimation.start();
    }

    public void collapse() {
        if (this.parentActivity != null && this.isVisible && !checkAnimation()) {
            if (this.fullscreenVideoContainer.getVisibility() == 0) {
                if (this.customView != null) {
                    this.fullscreenVideoContainer.setVisibility(4);
                    this.customViewCallback.onCustomViewHidden();
                    this.fullscreenVideoContainer.removeView(this.customView);
                    this.customView = null;
                } else {
                    WebPlayerView webPlayerView = this.fullscreenedVideo;
                    if (webPlayerView != null) {
                        webPlayerView.exitFullscreen();
                    }
                }
            }
            if (this.isPhotoVisible) {
                closePhoto(false);
            }
            try {
                if (this.visibleDialog != null) {
                    this.visibleDialog.dismiss();
                    this.visibleDialog = null;
                }
            } catch (Exception e) {
                FileLog.e(e);
            }
            AnimatorSet animatorSet = new AnimatorSet();
            Animator[] animatorArr = new Animator[12];
            animatorArr[0] = ObjectAnimator.ofFloat(this.containerView, View.TRANSLATION_X, (float) (this.containerView.getMeasuredWidth() - AndroidUtilities.dp(56.0f)));
            FrameLayout frameLayout = this.containerView;
            Property property = View.TRANSLATION_Y;
            float[] fArr = new float[1];
            fArr[0] = (float) (ActionBar.getCurrentActionBarHeight() + (Build.VERSION.SDK_INT >= 21 ? AndroidUtilities.statusBarHeight : 0));
            animatorArr[1] = ObjectAnimator.ofFloat(frameLayout, property, fArr);
            animatorArr[2] = ObjectAnimator.ofFloat(this.windowView, View.ALPHA, 0.0f);
            animatorArr[3] = ObjectAnimator.ofFloat(this.listView[0], View.ALPHA, 0.0f);
            animatorArr[4] = ObjectAnimator.ofFloat(this.listView[0], View.TRANSLATION_Y, (float) (-AndroidUtilities.dp(56.0f)));
            animatorArr[5] = ObjectAnimator.ofFloat(this.headerView, View.TRANSLATION_Y, 0.0f);
            animatorArr[6] = ObjectAnimator.ofFloat(this.backButton, View.SCALE_X, 1.0f);
            animatorArr[7] = ObjectAnimator.ofFloat(this.backButton, View.SCALE_Y, 1.0f);
            animatorArr[8] = ObjectAnimator.ofFloat(this.backButton, View.TRANSLATION_Y, 0.0f);
            animatorArr[9] = ObjectAnimator.ofFloat(this.shareContainer, View.SCALE_X, 1.0f);
            animatorArr[10] = ObjectAnimator.ofFloat(this.shareContainer, View.TRANSLATION_Y, 0.0f);
            animatorArr[11] = ObjectAnimator.ofFloat(this.shareContainer, View.SCALE_Y, 1.0f);
            animatorSet.playTogether(animatorArr);
            this.collapsed = true;
            this.animationInProgress = 2;
            this.animationEndRunnable = new Runnable() {
                /* class im.guobwnxjuc.ui.$$Lambda$ArticleViewer$nS0zfkxL2n_deJk6c3lY5ZnChU */

                public final void run() {
                    ArticleViewer.this.lambda$collapse$26$ArticleViewer();
                }
            };
            animatorSet.setInterpolator(new DecelerateInterpolator());
            animatorSet.setDuration(250L);
            animatorSet.addListener(new AnimatorListenerAdapter() {
                /* class im.guobwnxjuc.ui.ArticleViewer.AnonymousClass15 */

                public void onAnimationEnd(Animator animator) {
                    if (ArticleViewer.this.animationEndRunnable != null) {
                        ArticleViewer.this.animationEndRunnable.run();
                        ArticleViewer.this.animationEndRunnable = null;
                    }
                }
            });
            this.transitionAnimationStartTime = System.currentTimeMillis();
            if (Build.VERSION.SDK_INT >= 18) {
                this.containerView.setLayerType(2, null);
            }
            this.backDrawable.setRotation(1.0f, true);
            animatorSet.start();
        }
    }

    public /* synthetic */ void lambda$collapse$26$ArticleViewer() {
        if (this.containerView != null) {
            if (Build.VERSION.SDK_INT >= 18) {
                this.containerView.setLayerType(0, null);
            }
            this.animationInProgress = 0;
            ((WindowManager) this.parentActivity.getSystemService("window")).updateViewLayout(this.windowView, this.windowLayoutParams);
        }
    }

    public void uncollapse() {
        if (this.parentActivity != null && this.isVisible && !checkAnimation()) {
            AnimatorSet animatorSet = new AnimatorSet();
            animatorSet.playTogether(ObjectAnimator.ofFloat(this.containerView, View.TRANSLATION_X, 0.0f), ObjectAnimator.ofFloat(this.containerView, View.TRANSLATION_Y, 0.0f), ObjectAnimator.ofFloat(this.windowView, View.ALPHA, 1.0f), ObjectAnimator.ofFloat(this.listView[0], View.ALPHA, 1.0f), ObjectAnimator.ofFloat(this.listView[0], View.TRANSLATION_Y, 0.0f), ObjectAnimator.ofFloat(this.headerView, View.TRANSLATION_Y, 0.0f), ObjectAnimator.ofFloat(this.backButton, View.SCALE_X, 1.0f), ObjectAnimator.ofFloat(this.backButton, View.SCALE_Y, 1.0f), ObjectAnimator.ofFloat(this.backButton, View.TRANSLATION_Y, 0.0f), ObjectAnimator.ofFloat(this.shareContainer, View.SCALE_X, 1.0f), ObjectAnimator.ofFloat(this.shareContainer, View.TRANSLATION_Y, 0.0f), ObjectAnimator.ofFloat(this.shareContainer, View.SCALE_Y, 1.0f));
            this.collapsed = false;
            this.animationInProgress = 2;
            this.animationEndRunnable = new Runnable() {
                /* class im.guobwnxjuc.ui.$$Lambda$ArticleViewer$QS_2v75r9FDR5vempl3kZfeGLnw */

                public final void run() {
                    ArticleViewer.this.lambda$uncollapse$27$ArticleViewer();
                }
            };
            animatorSet.setDuration(250L);
            animatorSet.setInterpolator(new DecelerateInterpolator());
            animatorSet.addListener(new AnimatorListenerAdapter() {
                /* class im.guobwnxjuc.ui.ArticleViewer.AnonymousClass16 */

                public void onAnimationEnd(Animator animator) {
                    if (ArticleViewer.this.animationEndRunnable != null) {
                        ArticleViewer.this.animationEndRunnable.run();
                        ArticleViewer.this.animationEndRunnable = null;
                    }
                }
            });
            this.transitionAnimationStartTime = System.currentTimeMillis();
            if (Build.VERSION.SDK_INT >= 18) {
                this.containerView.setLayerType(2, null);
            }
            this.backDrawable.setRotation(0.0f, true);
            animatorSet.start();
        }
    }

    public /* synthetic */ void lambda$uncollapse$27$ArticleViewer() {
        if (this.containerView != null) {
            if (Build.VERSION.SDK_INT >= 18) {
                this.containerView.setLayerType(0, null);
            }
            this.animationInProgress = 0;
        }
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private void saveCurrentPagePosition() {
        if (this.currentPage != null) {
            boolean z = false;
            int findFirstVisibleItemPosition = this.layoutManager[0].findFirstVisibleItemPosition();
            if (findFirstVisibleItemPosition != -1) {
                View findViewByPosition = this.layoutManager[0].findViewByPosition(findFirstVisibleItemPosition);
                int top = findViewByPosition != null ? findViewByPosition.getTop() : 0;
                String str = "article" + this.currentPage.id;
                SharedPreferences.Editor putInt = ApplicationLoader.applicationContext.getSharedPreferences("articles", 0).edit().putInt(str, findFirstVisibleItemPosition).putInt(str + "o", top);
                String str2 = str + "r";
                if (AndroidUtilities.displaySize.x > AndroidUtilities.displaySize.y) {
                    z = true;
                }
                putInt.putBoolean(str2, z).commit();
            }
        }
    }

    public void close(boolean z, boolean z2) {
        if (this.parentActivity != null && this.isVisible && !checkAnimation()) {
            if (this.fullscreenVideoContainer.getVisibility() == 0) {
                if (this.customView != null) {
                    this.fullscreenVideoContainer.setVisibility(4);
                    this.customViewCallback.onCustomViewHidden();
                    this.fullscreenVideoContainer.removeView(this.customView);
                    this.customView = null;
                } else {
                    WebPlayerView webPlayerView = this.fullscreenedVideo;
                    if (webPlayerView != null) {
                        webPlayerView.exitFullscreen();
                    }
                }
                if (!z2) {
                    return;
                }
            }
            if (this.isPhotoVisible) {
                closePhoto(!z2);
                if (!z2) {
                    return;
                }
            }
            if (this.openUrlReqId != 0) {
                ConnectionsManager.getInstance(this.currentAccount).cancelRequest(this.openUrlReqId, true);
                this.openUrlReqId = 0;
                showProgressView(true, false);
            }
            if (this.previewsReqId != 0) {
                ConnectionsManager.getInstance(this.currentAccount).cancelRequest(this.previewsReqId, true);
                this.previewsReqId = 0;
                showProgressView(true, false);
            }
            saveCurrentPagePosition();
            if (!z || z2 || !removeLastPageFromStack()) {
                NotificationCenter.getInstance(this.currentAccount).removeObserver(this, NotificationCenter.messagePlayingProgressDidChanged);
                NotificationCenter.getInstance(this.currentAccount).removeObserver(this, NotificationCenter.messagePlayingDidReset);
                NotificationCenter.getInstance(this.currentAccount).removeObserver(this, NotificationCenter.messagePlayingPlayStateChanged);
                NotificationCenter.getInstance(this.currentAccount).removeObserver(this, NotificationCenter.messagePlayingDidStart);
                NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.needSetDayNightTheme);
                this.parentFragment = null;
                try {
                    if (this.visibleDialog != null) {
                        this.visibleDialog.dismiss();
                        this.visibleDialog = null;
                    }
                } catch (Exception e) {
                    FileLog.e(e);
                }
                AnimatorSet animatorSet = new AnimatorSet();
                animatorSet.playTogether(ObjectAnimator.ofFloat(this.windowView, View.ALPHA, 0.0f), ObjectAnimator.ofFloat(this.containerView, View.ALPHA, 0.0f), ObjectAnimator.ofFloat(this.windowView, View.TRANSLATION_X, 0.0f, (float) AndroidUtilities.dp(56.0f)));
                this.animationInProgress = 2;
                this.animationEndRunnable = new Runnable() {
                    /* class im.guobwnxjuc.ui.$$Lambda$ArticleViewer$YwNrsOnGKlBZlpahhfnRl_2RnZw */

                    public final void run() {
                        ArticleViewer.this.lambda$close$28$ArticleViewer();
                    }
                };
                animatorSet.setDuration(150L);
                animatorSet.setInterpolator(this.interpolator);
                animatorSet.addListener(new AnimatorListenerAdapter() {
                    /* class im.guobwnxjuc.ui.ArticleViewer.AnonymousClass17 */

                    public void onAnimationEnd(Animator animator) {
                        if (ArticleViewer.this.animationEndRunnable != null) {
                            ArticleViewer.this.animationEndRunnable.run();
                            ArticleViewer.this.animationEndRunnable = null;
                        }
                    }
                });
                this.transitionAnimationStartTime = System.currentTimeMillis();
                if (Build.VERSION.SDK_INT >= 18) {
                    this.containerView.setLayerType(2, null);
                }
                animatorSet.start();
            }
        }
    }

    public /* synthetic */ void lambda$close$28$ArticleViewer() {
        if (this.containerView != null) {
            if (Build.VERSION.SDK_INT >= 18) {
                this.containerView.setLayerType(0, null);
            }
            this.animationInProgress = 0;
            onClosed();
        }
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private void onClosed() {
        this.isVisible = false;
        this.currentPage = null;
        for (int i = 0; i < this.listView.length; i++) {
            this.adapter[i].cleanup();
        }
        try {
            this.parentActivity.getWindow().clearFlags(128);
        } catch (Exception e) {
            FileLog.e(e);
        }
        for (int i2 = 0; i2 < this.createdWebViews.size(); i2++) {
            this.createdWebViews.get(i2).destroyWebView(false);
        }
        this.containerView.post(new Runnable() {
            /* class im.guobwnxjuc.ui.$$Lambda$ArticleViewer$HGIw4rFZ4lN_GJI_6uJsXaPXMek */

            public final void run() {
                ArticleViewer.this.lambda$onClosed$29$ArticleViewer();
            }
        });
    }

    public /* synthetic */ void lambda$onClosed$29$ArticleViewer() {
        try {
            if (this.windowView.getParent() != null) {
                ((WindowManager) this.parentActivity.getSystemService("window")).removeView(this.windowView);
            }
        } catch (Exception e) {
            FileLog.e(e);
        }
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private void loadChannel(BlockChannelCell blockChannelCell, WebpageAdapter webpageAdapter, TLRPC.Chat chat) {
        if (!this.loadingChannel && !TextUtils.isEmpty(chat.username)) {
            this.loadingChannel = true;
            TLRPC.TL_contacts_resolveUsername tL_contacts_resolveUsername = new TLRPC.TL_contacts_resolveUsername();
            tL_contacts_resolveUsername.username = chat.username;
            int i = UserConfig.selectedAccount;
            ConnectionsManager.getInstance(i).sendRequest(tL_contacts_resolveUsername, new RequestDelegate(webpageAdapter, i, blockChannelCell) {
                /* class im.guobwnxjuc.ui.$$Lambda$ArticleViewer$r66pzAKapov8rcv7211y81LyAD4 */
                private final /* synthetic */ ArticleViewer.WebpageAdapter f$1;
                private final /* synthetic */ int f$2;
                private final /* synthetic */ ArticleViewer.BlockChannelCell f$3;

                {
                    this.f$1 = r2;
                    this.f$2 = r3;
                    this.f$3 = r4;
                }

                @Override // im.guobwnxjuc.tgnet.RequestDelegate
                public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                    ArticleViewer.this.lambda$loadChannel$31$ArticleViewer(this.f$1, this.f$2, this.f$3, tLObject, tL_error);
                }
            });
        }
    }

    public /* synthetic */ void lambda$loadChannel$31$ArticleViewer(WebpageAdapter webpageAdapter, int i, BlockChannelCell blockChannelCell, TLObject tLObject, TLRPC.TL_error tL_error) {
        AndroidUtilities.runOnUIThread(new Runnable(webpageAdapter, tL_error, tLObject, i, blockChannelCell) {
            /* class im.guobwnxjuc.ui.$$Lambda$ArticleViewer$WAL6pGm6h9njSYDlD5ImbWVO2O0 */
            private final /* synthetic */ ArticleViewer.WebpageAdapter f$1;
            private final /* synthetic */ TLRPC.TL_error f$2;
            private final /* synthetic */ TLObject f$3;
            private final /* synthetic */ int f$4;
            private final /* synthetic */ ArticleViewer.BlockChannelCell f$5;

            {
                this.f$1 = r2;
                this.f$2 = r3;
                this.f$3 = r4;
                this.f$4 = r5;
                this.f$5 = r6;
            }

            public final void run() {
                ArticleViewer.this.lambda$null$30$ArticleViewer(this.f$1, this.f$2, this.f$3, this.f$4, this.f$5);
            }
        });
    }

    public /* synthetic */ void lambda$null$30$ArticleViewer(WebpageAdapter webpageAdapter, TLRPC.TL_error tL_error, TLObject tLObject, int i, BlockChannelCell blockChannelCell) {
        this.loadingChannel = false;
        if (this.parentFragment != null && !webpageAdapter.blocks.isEmpty()) {
            if (tL_error == null) {
                TLRPC.TL_contacts_resolvedPeer tL_contacts_resolvedPeer = (TLRPC.TL_contacts_resolvedPeer) tLObject;
                if (!tL_contacts_resolvedPeer.chats.isEmpty()) {
                    MessagesController.getInstance(i).putUsers(tL_contacts_resolvedPeer.users, false);
                    MessagesController.getInstance(i).putChats(tL_contacts_resolvedPeer.chats, false);
                    MessagesStorage.getInstance(i).putUsersAndChats(tL_contacts_resolvedPeer.users, tL_contacts_resolvedPeer.chats, false, true);
                    TLRPC.Chat chat = tL_contacts_resolvedPeer.chats.get(0);
                    this.loadedChannel = chat;
                    if (!chat.left || this.loadedChannel.kicked) {
                        blockChannelCell.setState(4, false);
                    } else {
                        blockChannelCell.setState(0, false);
                    }
                } else {
                    blockChannelCell.setState(4, false);
                }
            } else {
                blockChannelCell.setState(4, false);
            }
        }
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private void joinChannel(BlockChannelCell blockChannelCell, TLRPC.Chat chat) {
        TLRPC.TL_channels_joinChannel tL_channels_joinChannel = new TLRPC.TL_channels_joinChannel();
        tL_channels_joinChannel.channel = MessagesController.getInputChannel(chat);
        int i = UserConfig.selectedAccount;
        ConnectionsManager.getInstance(i).sendRequest(tL_channels_joinChannel, new RequestDelegate(blockChannelCell, i, tL_channels_joinChannel, chat) {
            /* class im.guobwnxjuc.ui.$$Lambda$ArticleViewer$WJ7w5IUNSWq2cN8CB1PsA50wD3Q */
            private final /* synthetic */ ArticleViewer.BlockChannelCell f$1;
            private final /* synthetic */ int f$2;
            private final /* synthetic */ TLRPC.TL_channels_joinChannel f$3;
            private final /* synthetic */ TLRPC.Chat f$4;

            {
                this.f$1 = r2;
                this.f$2 = r3;
                this.f$3 = r4;
                this.f$4 = r5;
            }

            @Override // im.guobwnxjuc.tgnet.RequestDelegate
            public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                ArticleViewer.this.lambda$joinChannel$35$ArticleViewer(this.f$1, this.f$2, this.f$3, this.f$4, tLObject, tL_error);
            }
        });
    }

    public /* synthetic */ void lambda$joinChannel$35$ArticleViewer(BlockChannelCell blockChannelCell, int i, TLRPC.TL_channels_joinChannel tL_channels_joinChannel, TLRPC.Chat chat, TLObject tLObject, TLRPC.TL_error tL_error) {
        boolean z;
        if (tL_error != null) {
            AndroidUtilities.runOnUIThread(new Runnable(blockChannelCell, i, tL_error, tL_channels_joinChannel) {
                /* class im.guobwnxjuc.ui.$$Lambda$ArticleViewer$xh5LaFFmEXOsydnCZT42JDiNwhY */
                private final /* synthetic */ ArticleViewer.BlockChannelCell f$1;
                private final /* synthetic */ int f$2;
                private final /* synthetic */ TLRPC.TL_error f$3;
                private final /* synthetic */ TLRPC.TL_channels_joinChannel f$4;

                {
                    this.f$1 = r2;
                    this.f$2 = r3;
                    this.f$3 = r4;
                    this.f$4 = r5;
                }

                public final void run() {
                    ArticleViewer.this.lambda$null$32$ArticleViewer(this.f$1, this.f$2, this.f$3, this.f$4);
                }
            });
            return;
        }
        TLRPC.Updates updates = (TLRPC.Updates) tLObject;
        int i2 = 0;
        while (true) {
            if (i2 >= updates.updates.size()) {
                z = false;
                break;
            }
            TLRPC.Update update = updates.updates.get(i2);
            if ((update instanceof TLRPC.TL_updateNewChannelMessage) && (((TLRPC.TL_updateNewChannelMessage) update).message.action instanceof TLRPC.TL_messageActionChatAddUser)) {
                z = true;
                break;
            }
            i2++;
        }
        MessagesController.getInstance(i).processUpdates(updates, false);
        if (!z) {
            MessagesController.getInstance(i).generateJoinMessage(chat.id, true);
        }
        AndroidUtilities.runOnUIThread(new Runnable() {
            /* class im.guobwnxjuc.ui.$$Lambda$ArticleViewer$gsIjTzc63jrErK4PyjXOYLvt4hM */

            public final void run() {
                ArticleViewer.BlockChannelCell.this.setState(2, false);
            }
        });
        AndroidUtilities.runOnUIThread(new Runnable(i, chat) {
            /* class im.guobwnxjuc.ui.$$Lambda$ArticleViewer$xINoHhIEnQ5NqVBLBNQVFiBBhyk */
            private final /* synthetic */ int f$0;
            private final /* synthetic */ TLRPC.Chat f$1;

            {
                this.f$0 = r1;
                this.f$1 = r2;
            }

            public final void run() {
                MessagesController.getInstance(this.f$0).loadFullChat(this.f$1.id, 0, true);
            }
        }, 1000);
        MessagesStorage.getInstance(i).updateDialogsWithDeletedMessages(new ArrayList<>(), null, true, chat.id);
    }

    public /* synthetic */ void lambda$null$32$ArticleViewer(BlockChannelCell blockChannelCell, int i, TLRPC.TL_error tL_error, TLRPC.TL_channels_joinChannel tL_channels_joinChannel) {
        blockChannelCell.setState(0, false);
        AlertsCreator.processError(i, tL_error, this.parentFragment, tL_channels_joinChannel, true);
    }

    private boolean checkAnimation() {
        if (this.animationInProgress != 0 && Math.abs(this.transitionAnimationStartTime - System.currentTimeMillis()) >= 500) {
            Runnable runnable = this.animationEndRunnable;
            if (runnable != null) {
                runnable.run();
                this.animationEndRunnable = null;
            }
            this.animationInProgress = 0;
        }
        if (this.animationInProgress != 0) {
            return true;
        }
        return false;
    }

    public void destroyArticleViewer() {
        if (!(this.parentActivity == null || this.windowView == null)) {
            releasePlayer();
            try {
                if (this.windowView.getParent() != null) {
                    ((WindowManager) this.parentActivity.getSystemService("window")).removeViewImmediate(this.windowView);
                }
                this.windowView = null;
            } catch (Exception e) {
                FileLog.e(e);
            }
            for (int i = 0; i < this.createdWebViews.size(); i++) {
                this.createdWebViews.get(i).destroyWebView(true);
            }
            this.createdWebViews.clear();
            try {
                this.parentActivity.getWindow().clearFlags(128);
            } catch (Exception e2) {
                FileLog.e(e2);
            }
            ImageReceiver.BitmapHolder bitmapHolder = this.currentThumb;
            if (bitmapHolder != null) {
                bitmapHolder.release();
                this.currentThumb = null;
            }
            this.animatingImageView.setImageBitmap(null);
            this.parentActivity = null;
            this.parentFragment = null;
            Instance = null;
        }
    }

    public boolean isVisible() {
        return this.isVisible;
    }

    public void showDialog(Dialog dialog) {
        if (this.parentActivity != null) {
            try {
                if (this.visibleDialog != null) {
                    this.visibleDialog.dismiss();
                    this.visibleDialog = null;
                }
            } catch (Exception e) {
                FileLog.e(e);
            }
            try {
                this.visibleDialog = dialog;
                dialog.setCanceledOnTouchOutside(true);
                this.visibleDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
                    /* class im.guobwnxjuc.ui.$$Lambda$ArticleViewer$ijOb6ufDzbU1ajJvQLT80sScg94 */

                    public final void onDismiss(DialogInterface dialogInterface) {
                        ArticleViewer.this.lambda$showDialog$36$ArticleViewer(dialogInterface);
                    }
                });
                dialog.show();
            } catch (Exception e2) {
                FileLog.e(e2);
            }
        }
    }

    public /* synthetic */ void lambda$showDialog$36$ArticleViewer(DialogInterface dialogInterface) {
        this.visibleDialog = null;
    }

    /* access modifiers changed from: private */
    public class WebpageAdapter extends RecyclerListView.SelectionAdapter {
        private HashMap<String, Integer> anchors = new HashMap<>();
        private HashMap<String, Integer> anchorsOffset = new HashMap<>();
        private HashMap<String, TLRPC.TL_textAnchor> anchorsParent = new HashMap<>();
        private HashMap<TLRPC.TL_pageBlockAudio, MessageObject> audioBlocks = new HashMap<>();
        private ArrayList<MessageObject> audioMessages = new ArrayList<>();
        private ArrayList<TLRPC.PageBlock> blocks = new ArrayList<>();
        private Context context;
        private ArrayList<TLRPC.PageBlock> localBlocks = new ArrayList<>();
        private ArrayList<TLRPC.PageBlock> photoBlocks = new ArrayList<>();

        public WebpageAdapter(Context context2) {
            this.context = context2;
        }

        private void setRichTextParents(TLRPC.RichText richText, TLRPC.RichText richText2) {
            if (richText2 != null) {
                richText2.parentRichText = richText;
                if (richText2 instanceof TLRPC.TL_textFixed) {
                    setRichTextParents(richText2, ((TLRPC.TL_textFixed) richText2).text);
                } else if (richText2 instanceof TLRPC.TL_textItalic) {
                    setRichTextParents(richText2, ((TLRPC.TL_textItalic) richText2).text);
                } else if (richText2 instanceof TLRPC.TL_textBold) {
                    setRichTextParents(richText2, ((TLRPC.TL_textBold) richText2).text);
                } else if (richText2 instanceof TLRPC.TL_textUnderline) {
                    setRichTextParents(richText2, ((TLRPC.TL_textUnderline) richText2).text);
                } else if (richText2 instanceof TLRPC.TL_textStrike) {
                    setRichTextParents(richText2, ((TLRPC.TL_textStrike) richText2).text);
                } else if (richText2 instanceof TLRPC.TL_textEmail) {
                    setRichTextParents(richText2, ((TLRPC.TL_textEmail) richText2).text);
                } else if (richText2 instanceof TLRPC.TL_textPhone) {
                    setRichTextParents(richText2, ((TLRPC.TL_textPhone) richText2).text);
                } else if (richText2 instanceof TLRPC.TL_textUrl) {
                    setRichTextParents(richText2, ((TLRPC.TL_textUrl) richText2).text);
                } else if (richText2 instanceof TLRPC.TL_textConcat) {
                    int size = richText2.texts.size();
                    for (int i = 0; i < size; i++) {
                        setRichTextParents(richText2, richText2.texts.get(i));
                    }
                } else if (richText2 instanceof TLRPC.TL_textSubscript) {
                    setRichTextParents(richText2, ((TLRPC.TL_textSubscript) richText2).text);
                } else if (richText2 instanceof TLRPC.TL_textSuperscript) {
                    setRichTextParents(richText2, ((TLRPC.TL_textSuperscript) richText2).text);
                } else if (richText2 instanceof TLRPC.TL_textMarked) {
                    setRichTextParents(richText2, ((TLRPC.TL_textMarked) richText2).text);
                } else if (richText2 instanceof TLRPC.TL_textAnchor) {
                    TLRPC.TL_textAnchor tL_textAnchor = (TLRPC.TL_textAnchor) richText2;
                    setRichTextParents(richText2, tL_textAnchor.text);
                    String lowerCase = tL_textAnchor.name.toLowerCase();
                    this.anchors.put(lowerCase, Integer.valueOf(this.blocks.size()));
                    if (tL_textAnchor.text instanceof TLRPC.TL_textPlain) {
                        if (!TextUtils.isEmpty(((TLRPC.TL_textPlain) tL_textAnchor.text).text)) {
                            this.anchorsParent.put(lowerCase, tL_textAnchor);
                        }
                    } else if (!(tL_textAnchor.text instanceof TLRPC.TL_textEmpty)) {
                        this.anchorsParent.put(lowerCase, tL_textAnchor);
                    }
                    this.anchorsOffset.put(lowerCase, -1);
                }
            }
        }

        private void setRichTextParents(TLRPC.PageBlock pageBlock) {
            if (pageBlock instanceof TLRPC.TL_pageBlockEmbedPost) {
                TLRPC.TL_pageBlockEmbedPost tL_pageBlockEmbedPost = (TLRPC.TL_pageBlockEmbedPost) pageBlock;
                setRichTextParents(null, tL_pageBlockEmbedPost.caption.text);
                setRichTextParents(null, tL_pageBlockEmbedPost.caption.credit);
            } else if (pageBlock instanceof TLRPC.TL_pageBlockParagraph) {
                setRichTextParents(null, ((TLRPC.TL_pageBlockParagraph) pageBlock).text);
            } else if (pageBlock instanceof TLRPC.TL_pageBlockKicker) {
                setRichTextParents(null, ((TLRPC.TL_pageBlockKicker) pageBlock).text);
            } else if (pageBlock instanceof TLRPC.TL_pageBlockFooter) {
                setRichTextParents(null, ((TLRPC.TL_pageBlockFooter) pageBlock).text);
            } else if (pageBlock instanceof TLRPC.TL_pageBlockHeader) {
                setRichTextParents(null, ((TLRPC.TL_pageBlockHeader) pageBlock).text);
            } else if (pageBlock instanceof TLRPC.TL_pageBlockPreformatted) {
                setRichTextParents(null, ((TLRPC.TL_pageBlockPreformatted) pageBlock).text);
            } else if (pageBlock instanceof TLRPC.TL_pageBlockSubheader) {
                setRichTextParents(null, ((TLRPC.TL_pageBlockSubheader) pageBlock).text);
            } else {
                int i = 0;
                if (pageBlock instanceof TLRPC.TL_pageBlockSlideshow) {
                    TLRPC.TL_pageBlockSlideshow tL_pageBlockSlideshow = (TLRPC.TL_pageBlockSlideshow) pageBlock;
                    setRichTextParents(null, tL_pageBlockSlideshow.caption.text);
                    setRichTextParents(null, tL_pageBlockSlideshow.caption.credit);
                    int size = tL_pageBlockSlideshow.items.size();
                    while (i < size) {
                        setRichTextParents(tL_pageBlockSlideshow.items.get(i));
                        i++;
                    }
                } else if (pageBlock instanceof TLRPC.TL_pageBlockPhoto) {
                    TLRPC.TL_pageBlockPhoto tL_pageBlockPhoto = (TLRPC.TL_pageBlockPhoto) pageBlock;
                    setRichTextParents(null, tL_pageBlockPhoto.caption.text);
                    setRichTextParents(null, tL_pageBlockPhoto.caption.credit);
                } else if (pageBlock instanceof TL_pageBlockListItem) {
                    TL_pageBlockListItem tL_pageBlockListItem = (TL_pageBlockListItem) pageBlock;
                    if (tL_pageBlockListItem.textItem != null) {
                        setRichTextParents(null, tL_pageBlockListItem.textItem);
                    } else if (tL_pageBlockListItem.blockItem != null) {
                        setRichTextParents(tL_pageBlockListItem.blockItem);
                    }
                } else if (pageBlock instanceof TL_pageBlockOrderedListItem) {
                    TL_pageBlockOrderedListItem tL_pageBlockOrderedListItem = (TL_pageBlockOrderedListItem) pageBlock;
                    if (tL_pageBlockOrderedListItem.textItem != null) {
                        setRichTextParents(null, tL_pageBlockOrderedListItem.textItem);
                    } else if (tL_pageBlockOrderedListItem.blockItem != null) {
                        setRichTextParents(tL_pageBlockOrderedListItem.blockItem);
                    }
                } else if (pageBlock instanceof TLRPC.TL_pageBlockCollage) {
                    TLRPC.TL_pageBlockCollage tL_pageBlockCollage = (TLRPC.TL_pageBlockCollage) pageBlock;
                    setRichTextParents(null, tL_pageBlockCollage.caption.text);
                    setRichTextParents(null, tL_pageBlockCollage.caption.credit);
                    int size2 = tL_pageBlockCollage.items.size();
                    while (i < size2) {
                        setRichTextParents(tL_pageBlockCollage.items.get(i));
                        i++;
                    }
                } else if (pageBlock instanceof TLRPC.TL_pageBlockEmbed) {
                    TLRPC.TL_pageBlockEmbed tL_pageBlockEmbed = (TLRPC.TL_pageBlockEmbed) pageBlock;
                    setRichTextParents(null, tL_pageBlockEmbed.caption.text);
                    setRichTextParents(null, tL_pageBlockEmbed.caption.credit);
                } else if (pageBlock instanceof TLRPC.TL_pageBlockSubtitle) {
                    setRichTextParents(null, ((TLRPC.TL_pageBlockSubtitle) pageBlock).text);
                } else if (pageBlock instanceof TLRPC.TL_pageBlockBlockquote) {
                    TLRPC.TL_pageBlockBlockquote tL_pageBlockBlockquote = (TLRPC.TL_pageBlockBlockquote) pageBlock;
                    setRichTextParents(null, tL_pageBlockBlockquote.text);
                    setRichTextParents(null, tL_pageBlockBlockquote.caption);
                } else if (pageBlock instanceof TLRPC.TL_pageBlockDetails) {
                    TLRPC.TL_pageBlockDetails tL_pageBlockDetails = (TLRPC.TL_pageBlockDetails) pageBlock;
                    setRichTextParents(null, tL_pageBlockDetails.title);
                    int size3 = tL_pageBlockDetails.blocks.size();
                    while (i < size3) {
                        setRichTextParents(tL_pageBlockDetails.blocks.get(i));
                        i++;
                    }
                } else if (pageBlock instanceof TLRPC.TL_pageBlockVideo) {
                    TLRPC.TL_pageBlockVideo tL_pageBlockVideo = (TLRPC.TL_pageBlockVideo) pageBlock;
                    setRichTextParents(null, tL_pageBlockVideo.caption.text);
                    setRichTextParents(null, tL_pageBlockVideo.caption.credit);
                } else if (pageBlock instanceof TLRPC.TL_pageBlockPullquote) {
                    TLRPC.TL_pageBlockPullquote tL_pageBlockPullquote = (TLRPC.TL_pageBlockPullquote) pageBlock;
                    setRichTextParents(null, tL_pageBlockPullquote.text);
                    setRichTextParents(null, tL_pageBlockPullquote.caption);
                } else if (pageBlock instanceof TLRPC.TL_pageBlockAudio) {
                    TLRPC.TL_pageBlockAudio tL_pageBlockAudio = (TLRPC.TL_pageBlockAudio) pageBlock;
                    setRichTextParents(null, tL_pageBlockAudio.caption.text);
                    setRichTextParents(null, tL_pageBlockAudio.caption.credit);
                } else if (pageBlock instanceof TLRPC.TL_pageBlockTable) {
                    TLRPC.TL_pageBlockTable tL_pageBlockTable = (TLRPC.TL_pageBlockTable) pageBlock;
                    setRichTextParents(null, tL_pageBlockTable.title);
                    int size4 = tL_pageBlockTable.rows.size();
                    for (int i2 = 0; i2 < size4; i2++) {
                        TLRPC.TL_pageTableRow tL_pageTableRow = tL_pageBlockTable.rows.get(i2);
                        int size5 = tL_pageTableRow.cells.size();
                        for (int i3 = 0; i3 < size5; i3++) {
                            setRichTextParents(null, tL_pageTableRow.cells.get(i3).text);
                        }
                    }
                } else if (pageBlock instanceof TLRPC.TL_pageBlockTitle) {
                    setRichTextParents(null, ((TLRPC.TL_pageBlockTitle) pageBlock).text);
                } else if (pageBlock instanceof TLRPC.TL_pageBlockCover) {
                    setRichTextParents(((TLRPC.TL_pageBlockCover) pageBlock).cover);
                } else if (pageBlock instanceof TLRPC.TL_pageBlockAuthorDate) {
                    setRichTextParents(null, ((TLRPC.TL_pageBlockAuthorDate) pageBlock).author);
                } else if (pageBlock instanceof TLRPC.TL_pageBlockMap) {
                    TLRPC.TL_pageBlockMap tL_pageBlockMap = (TLRPC.TL_pageBlockMap) pageBlock;
                    setRichTextParents(null, tL_pageBlockMap.caption.text);
                    setRichTextParents(null, tL_pageBlockMap.caption.credit);
                } else if (pageBlock instanceof TLRPC.TL_pageBlockRelatedArticles) {
                    setRichTextParents(null, ((TLRPC.TL_pageBlockRelatedArticles) pageBlock).title);
                }
            }
        }

        /* JADX WARN: Multi-variable type inference failed */
        /* JADX WARN: Type inference failed for: r24v0, types: [im.guobwnxjuc.ui.ArticleViewer$WebpageAdapter] */
        /* JADX WARN: Type inference failed for: r11v4, types: [im.guobwnxjuc.tgnet.TLRPC$PageBlock] */
        /* JADX WARN: Type inference failed for: r10v12, types: [im.guobwnxjuc.tgnet.TLRPC$PageBlock] */
        /* access modifiers changed from: private */
        /* access modifiers changed from: public */
        /* JADX WARNING: Removed duplicated region for block: B:128:0x0498  */
        /* JADX WARNING: Removed duplicated region for block: B:129:0x04b5  */
        /* JADX WARNING: Removed duplicated region for block: B:135:0x04c8  */
        /* JADX WARNING: Removed duplicated region for block: B:160:0x051c A[SYNTHETIC] */
        /* JADX WARNING: Unknown variable types count: 2 */
        private void addBlock(TLRPC.PageBlock pageBlock, int i, int i2, int i3) {
            int i4;
            TLRPC.TL_pageBlockOrderedList tL_pageBlockOrderedList;
            String str;
            TLRPC.PageListOrderedItem pageListOrderedItem;
            String str2;
            boolean z;
            TLRPC.TL_pageListOrderedItemText tL_pageListOrderedItemText;
            TLRPC.TL_pageListItemText tL_pageListItemText;
            String str3;
            TLRPC.TL_pageBlockList tL_pageBlockList;
            TLRPC.TL_pageListItemBlocks tL_pageListItemBlocks;
            int i5;
            TLRPC.PageBlock pageBlock2 = pageBlock;
            boolean z2 = pageBlock2 instanceof TL_pageBlockDetailsChild;
            TLRPC.PageBlock pageBlock3 = z2 ? ((TL_pageBlockDetailsChild) pageBlock2).block : pageBlock2;
            if (!(pageBlock3 instanceof TLRPC.TL_pageBlockList) && !(pageBlock3 instanceof TLRPC.TL_pageBlockOrderedList)) {
                setRichTextParents(pageBlock3);
                addAllMediaFromBlock(pageBlock3);
            }
            TLRPC.PageBlock lastNonListPageBlock = ArticleViewer.this.getLastNonListPageBlock(pageBlock3);
            if (!(lastNonListPageBlock instanceof TLRPC.TL_pageBlockUnsupported)) {
                if (lastNonListPageBlock instanceof TLRPC.TL_pageBlockAnchor) {
                    this.anchors.put(((TLRPC.TL_pageBlockAnchor) lastNonListPageBlock).name.toLowerCase(), Integer.valueOf(this.blocks.size()));
                    return;
                }
                boolean z3 = lastNonListPageBlock instanceof TLRPC.TL_pageBlockList;
                if (!z3 && !(lastNonListPageBlock instanceof TLRPC.TL_pageBlockOrderedList)) {
                    this.blocks.add(pageBlock2);
                }
                int i6 = 0;
                if (lastNonListPageBlock instanceof TLRPC.TL_pageBlockAudio) {
                    TLRPC.TL_pageBlockAudio tL_pageBlockAudio = (TLRPC.TL_pageBlockAudio) lastNonListPageBlock;
                    TLRPC.TL_message tL_message = new TLRPC.TL_message();
                    tL_message.out = true;
                    int i7 = -Long.valueOf(tL_pageBlockAudio.audio_id).hashCode();
                    lastNonListPageBlock.mid = i7;
                    tL_message.id = i7;
                    tL_message.to_id = new TLRPC.TL_peerUser();
                    TLRPC.Peer peer = tL_message.to_id;
                    int clientUserId = UserConfig.getInstance(ArticleViewer.this.currentAccount).getClientUserId();
                    tL_message.from_id = clientUserId;
                    peer.user_id = clientUserId;
                    tL_message.date = (int) (System.currentTimeMillis() / 1000);
                    tL_message.message = "";
                    tL_message.media = new TLRPC.TL_messageMediaDocument();
                    tL_message.media.webpage = ArticleViewer.this.currentPage;
                    tL_message.media.flags |= 3;
                    tL_message.media.document = ArticleViewer.this.getDocumentWithId(tL_pageBlockAudio.audio_id);
                    tL_message.flags |= 768;
                    MessageObject messageObject = new MessageObject(UserConfig.selectedAccount, tL_message, false);
                    this.audioMessages.add(messageObject);
                    this.audioBlocks.put(tL_pageBlockAudio, messageObject);
                    return;
                }
                AnonymousClass1 r11 = null;
                if (lastNonListPageBlock instanceof TLRPC.TL_pageBlockEmbedPost) {
                    TLRPC.TL_pageBlockEmbedPost tL_pageBlockEmbedPost = (TLRPC.TL_pageBlockEmbedPost) lastNonListPageBlock;
                    if (!tL_pageBlockEmbedPost.blocks.isEmpty()) {
                        lastNonListPageBlock.level = -1;
                        while (i6 < tL_pageBlockEmbedPost.blocks.size()) {
                            TLRPC.PageBlock pageBlock4 = tL_pageBlockEmbedPost.blocks.get(i6);
                            if (!(pageBlock4 instanceof TLRPC.TL_pageBlockUnsupported)) {
                                if (pageBlock4 instanceof TLRPC.TL_pageBlockAnchor) {
                                    this.anchors.put(((TLRPC.TL_pageBlockAnchor) pageBlock4).name.toLowerCase(), Integer.valueOf(this.blocks.size()));
                                } else {
                                    pageBlock4.level = 1;
                                    if (i6 == tL_pageBlockEmbedPost.blocks.size() - 1) {
                                        pageBlock4.bottom = true;
                                    }
                                    this.blocks.add(pageBlock4);
                                    addAllMediaFromBlock(pageBlock4);
                                }
                            }
                            i6++;
                        }
                        if (!TextUtils.isEmpty(ArticleViewer.getPlainText(tL_pageBlockEmbedPost.caption.text)) || !TextUtils.isEmpty(ArticleViewer.getPlainText(tL_pageBlockEmbedPost.caption.credit))) {
                            TL_pageBlockEmbedPostCaption tL_pageBlockEmbedPostCaption = new TL_pageBlockEmbedPostCaption();
                            tL_pageBlockEmbedPostCaption.parent = tL_pageBlockEmbedPost;
                            tL_pageBlockEmbedPostCaption.caption = tL_pageBlockEmbedPost.caption;
                            this.blocks.add(tL_pageBlockEmbedPostCaption);
                        }
                    }
                } else if (lastNonListPageBlock instanceof TLRPC.TL_pageBlockRelatedArticles) {
                    TLRPC.TL_pageBlockRelatedArticles tL_pageBlockRelatedArticles = (TLRPC.TL_pageBlockRelatedArticles) lastNonListPageBlock;
                    TL_pageBlockRelatedArticlesShadow tL_pageBlockRelatedArticlesShadow = new TL_pageBlockRelatedArticlesShadow();
                    tL_pageBlockRelatedArticlesShadow.parent = tL_pageBlockRelatedArticles;
                    ArrayList<TLRPC.PageBlock> arrayList = this.blocks;
                    arrayList.add(arrayList.size() - 1, tL_pageBlockRelatedArticlesShadow);
                    int size = tL_pageBlockRelatedArticles.articles.size();
                    while (i6 < size) {
                        TL_pageBlockRelatedArticlesChild tL_pageBlockRelatedArticlesChild = new TL_pageBlockRelatedArticlesChild();
                        tL_pageBlockRelatedArticlesChild.parent = tL_pageBlockRelatedArticles;
                        tL_pageBlockRelatedArticlesChild.num = i6;
                        this.blocks.add(tL_pageBlockRelatedArticlesChild);
                        i6++;
                    }
                    if (i3 == 0) {
                        TL_pageBlockRelatedArticlesShadow tL_pageBlockRelatedArticlesShadow2 = new TL_pageBlockRelatedArticlesShadow();
                        tL_pageBlockRelatedArticlesShadow2.parent = tL_pageBlockRelatedArticles;
                        this.blocks.add(tL_pageBlockRelatedArticlesShadow2);
                    }
                } else if (lastNonListPageBlock instanceof TLRPC.TL_pageBlockDetails) {
                    TLRPC.TL_pageBlockDetails tL_pageBlockDetails = (TLRPC.TL_pageBlockDetails) lastNonListPageBlock;
                    int size2 = tL_pageBlockDetails.blocks.size();
                    while (i6 < size2) {
                        TL_pageBlockDetailsChild tL_pageBlockDetailsChild = new TL_pageBlockDetailsChild();
                        tL_pageBlockDetailsChild.parent = pageBlock2;
                        tL_pageBlockDetailsChild.block = tL_pageBlockDetails.blocks.get(i6);
                        addBlock(ArticleViewer.this.wrapInTableBlock(pageBlock2, tL_pageBlockDetailsChild), i + 1, i2, i3);
                        i6++;
                    }
                } else {
                    String str4 = " ";
                    String str5 = ".%d";
                    if (z3) {
                        TLRPC.TL_pageBlockList tL_pageBlockList2 = (TLRPC.TL_pageBlockList) lastNonListPageBlock;
                        TL_pageBlockListParent tL_pageBlockListParent = new TL_pageBlockListParent();
                        tL_pageBlockListParent.pageBlockList = tL_pageBlockList2;
                        tL_pageBlockListParent.level = i2;
                        int size3 = tL_pageBlockList2.items.size();
                        int i8 = 0;
                        while (i8 < size3) {
                            TLRPC.PageListItem pageListItem = tL_pageBlockList2.items.get(i8);
                            TL_pageBlockListItem tL_pageBlockListItem = new TL_pageBlockListItem();
                            tL_pageBlockListItem.index = i8;
                            tL_pageBlockListItem.parent = tL_pageBlockListParent;
                            if (!tL_pageBlockList2.ordered) {
                                tL_pageBlockListItem.num = "•";
                            } else if (ArticleViewer.this.isRtl) {
                                tL_pageBlockListItem.num = String.format(str5, Integer.valueOf(i8 + 1));
                            } else {
                                tL_pageBlockListItem.num = String.format("%d.", Integer.valueOf(i8 + 1));
                            }
                            tL_pageBlockListParent.items.add(tL_pageBlockListItem);
                            if (pageListItem instanceof TLRPC.TL_pageListItemText) {
                                tL_pageBlockListItem.textItem = ((TLRPC.TL_pageListItemText) pageListItem).text;
                                tL_pageListItemText = pageListItem;
                            } else {
                                boolean z4 = pageListItem instanceof TLRPC.TL_pageListItemBlocks;
                                tL_pageListItemText = pageListItem;
                                if (z4) {
                                    TLRPC.TL_pageListItemBlocks tL_pageListItemBlocks2 = (TLRPC.TL_pageListItemBlocks) pageListItem;
                                    if (!tL_pageListItemBlocks2.blocks.isEmpty()) {
                                        tL_pageBlockListItem.blockItem = tL_pageListItemBlocks2.blocks.get(0);
                                        tL_pageListItemText = pageListItem;
                                    } else {
                                        TLRPC.TL_pageListItemText tL_pageListItemText2 = new TLRPC.TL_pageListItemText();
                                        TLRPC.TL_textPlain tL_textPlain = new TLRPC.TL_textPlain();
                                        tL_textPlain.text = str4;
                                        tL_pageListItemText2.text = tL_textPlain;
                                        tL_pageListItemText = tL_pageListItemText2;
                                    }
                                }
                            }
                            if (z2) {
                                tL_pageBlockList = tL_pageBlockList2;
                                str3 = str4;
                                TL_pageBlockDetailsChild tL_pageBlockDetailsChild2 = new TL_pageBlockDetailsChild();
                                tL_pageBlockDetailsChild2.parent = ((TL_pageBlockDetailsChild) pageBlock2).parent;
                                tL_pageBlockDetailsChild2.block = tL_pageBlockListItem;
                                addBlock(tL_pageBlockDetailsChild2, i, i2 + 1, i3);
                            } else {
                                tL_pageBlockList = tL_pageBlockList2;
                                str3 = str4;
                                TL_pageBlockListItem tL_pageBlockListItem2 = tL_pageBlockListItem;
                                if (i8 == 0) {
                                    tL_pageBlockListItem2 = ArticleViewer.this.fixListBlock(pageBlock2, tL_pageBlockListItem);
                                }
                                addBlock(tL_pageBlockListItem2, i, i2 + 1, i3);
                            }
                            if (tL_pageListItemText instanceof TLRPC.TL_pageListItemBlocks) {
                                TLRPC.TL_pageListItemBlocks tL_pageListItemBlocks3 = (TLRPC.TL_pageListItemBlocks) tL_pageListItemText;
                                int size4 = tL_pageListItemBlocks3.blocks.size();
                                int i9 = 1;
                                while (i9 < size4) {
                                    TL_pageBlockListItem tL_pageBlockListItem3 = new TL_pageBlockListItem();
                                    tL_pageBlockListItem3.blockItem = tL_pageListItemBlocks3.blocks.get(i9);
                                    tL_pageBlockListItem3.parent = tL_pageBlockListParent;
                                    if (z2) {
                                        i5 = size4;
                                        tL_pageListItemBlocks = tL_pageListItemBlocks3;
                                        TL_pageBlockDetailsChild tL_pageBlockDetailsChild3 = new TL_pageBlockDetailsChild();
                                        tL_pageBlockDetailsChild3.parent = ((TL_pageBlockDetailsChild) pageBlock2).parent;
                                        tL_pageBlockDetailsChild3.block = tL_pageBlockListItem3;
                                        addBlock(tL_pageBlockDetailsChild3, i, i2 + 1, i3);
                                    } else {
                                        i5 = size4;
                                        tL_pageListItemBlocks = tL_pageListItemBlocks3;
                                        addBlock(tL_pageBlockListItem3, i, i2 + 1, i3);
                                    }
                                    tL_pageBlockListParent.items.add(tL_pageBlockListItem3);
                                    i9++;
                                    size4 = i5;
                                    tL_pageListItemBlocks3 = tL_pageListItemBlocks;
                                }
                            }
                            i8++;
                            size3 = size3;
                            tL_pageBlockList2 = tL_pageBlockList;
                            str4 = str3;
                            r11 = null;
                        }
                        return;
                    }
                    String str6 = str4;
                    if (lastNonListPageBlock instanceof TLRPC.TL_pageBlockOrderedList) {
                        TLRPC.TL_pageBlockOrderedList tL_pageBlockOrderedList2 = (TLRPC.TL_pageBlockOrderedList) lastNonListPageBlock;
                        TL_pageBlockOrderedListParent tL_pageBlockOrderedListParent = new TL_pageBlockOrderedListParent();
                        tL_pageBlockOrderedListParent.pageBlockOrderedList = tL_pageBlockOrderedList2;
                        tL_pageBlockOrderedListParent.level = i2;
                        int size5 = tL_pageBlockOrderedList2.items.size();
                        int i10 = 0;
                        while (i10 < size5) {
                            TLRPC.PageListOrderedItem pageListOrderedItem2 = tL_pageBlockOrderedList2.items.get(i10);
                            TL_pageBlockOrderedListItem tL_pageBlockOrderedListItem = new TL_pageBlockOrderedListItem();
                            tL_pageBlockOrderedListItem.index = i10;
                            tL_pageBlockOrderedListItem.parent = tL_pageBlockOrderedListParent;
                            tL_pageBlockOrderedListParent.items.add(tL_pageBlockOrderedListItem);
                            if (pageListOrderedItem2 instanceof TLRPC.TL_pageListOrderedItemText) {
                                TLRPC.TL_pageListOrderedItemText tL_pageListOrderedItemText2 = (TLRPC.TL_pageListOrderedItemText) pageListOrderedItem2;
                                tL_pageBlockOrderedList = tL_pageBlockOrderedList2;
                                tL_pageBlockOrderedListItem.textItem = tL_pageListOrderedItemText2.text;
                                if (TextUtils.isEmpty(tL_pageListOrderedItemText2.num)) {
                                    if (ArticleViewer.this.isRtl) {
                                        tL_pageBlockOrderedListItem.num = String.format(str5, Integer.valueOf(i10 + 1));
                                    } else {
                                        tL_pageBlockOrderedListItem.num = String.format("%d.", Integer.valueOf(i10 + 1));
                                    }
                                } else if (ArticleViewer.this.isRtl) {
                                    tL_pageBlockOrderedListItem.num = "." + tL_pageListOrderedItemText2.num;
                                } else {
                                    tL_pageBlockOrderedListItem.num = tL_pageListOrderedItemText2.num + ".";
                                }
                            } else {
                                tL_pageBlockOrderedList = tL_pageBlockOrderedList2;
                                if (pageListOrderedItem2 instanceof TLRPC.TL_pageListOrderedItemBlocks) {
                                    TLRPC.TL_pageListOrderedItemBlocks tL_pageListOrderedItemBlocks = (TLRPC.TL_pageListOrderedItemBlocks) pageListOrderedItem2;
                                    if (!tL_pageListOrderedItemBlocks.blocks.isEmpty()) {
                                        i4 = size5;
                                        tL_pageBlockOrderedListItem.blockItem = tL_pageListOrderedItemBlocks.blocks.get(0);
                                        str = str6;
                                        tL_pageListOrderedItemText = pageListOrderedItem2;
                                    } else {
                                        i4 = size5;
                                        TLRPC.TL_pageListOrderedItemText tL_pageListOrderedItemText3 = new TLRPC.TL_pageListOrderedItemText();
                                        TLRPC.TL_textPlain tL_textPlain2 = new TLRPC.TL_textPlain();
                                        str = str6;
                                        tL_textPlain2.text = str;
                                        tL_pageListOrderedItemText3.text = tL_textPlain2;
                                        tL_pageListOrderedItemText = tL_pageListOrderedItemText3;
                                    }
                                    if (TextUtils.isEmpty(tL_pageListOrderedItemBlocks.num)) {
                                        if (ArticleViewer.this.isRtl) {
                                            tL_pageBlockOrderedListItem.num = String.format(str5, Integer.valueOf(i10 + 1));
                                            pageListOrderedItem = tL_pageListOrderedItemText;
                                        } else {
                                            tL_pageBlockOrderedListItem.num = String.format("%d.", Integer.valueOf(i10 + 1));
                                            pageListOrderedItem = tL_pageListOrderedItemText;
                                        }
                                    } else if (ArticleViewer.this.isRtl) {
                                        tL_pageBlockOrderedListItem.num = "." + tL_pageListOrderedItemBlocks.num;
                                        pageListOrderedItem = tL_pageListOrderedItemText;
                                    } else {
                                        tL_pageBlockOrderedListItem.num = tL_pageListOrderedItemBlocks.num + ".";
                                        pageListOrderedItem = tL_pageListOrderedItemText;
                                    }
                                    if (!z2) {
                                        str2 = str5;
                                        TL_pageBlockDetailsChild tL_pageBlockDetailsChild4 = new TL_pageBlockDetailsChild();
                                        tL_pageBlockDetailsChild4.parent = ((TL_pageBlockDetailsChild) pageBlock2).parent;
                                        tL_pageBlockDetailsChild4.block = tL_pageBlockOrderedListItem;
                                        addBlock(tL_pageBlockDetailsChild4, i, i2 + 1, i3);
                                    } else {
                                        str2 = str5;
                                        TL_pageBlockOrderedListItem tL_pageBlockOrderedListItem2 = tL_pageBlockOrderedListItem;
                                        if (i10 == 0) {
                                            tL_pageBlockOrderedListItem2 = ArticleViewer.this.fixListBlock(pageBlock2, tL_pageBlockOrderedListItem);
                                        }
                                        addBlock(tL_pageBlockOrderedListItem2, i, i2 + 1, i3);
                                    }
                                    if (!(pageListOrderedItem instanceof TLRPC.TL_pageListOrderedItemBlocks)) {
                                        TLRPC.TL_pageListOrderedItemBlocks tL_pageListOrderedItemBlocks2 = (TLRPC.TL_pageListOrderedItemBlocks) pageListOrderedItem;
                                        int size6 = tL_pageListOrderedItemBlocks2.blocks.size();
                                        int i11 = 1;
                                        while (i11 < size6) {
                                            TL_pageBlockOrderedListItem tL_pageBlockOrderedListItem3 = new TL_pageBlockOrderedListItem();
                                            tL_pageBlockOrderedListItem3.blockItem = tL_pageListOrderedItemBlocks2.blocks.get(i11);
                                            tL_pageBlockOrderedListItem3.parent = tL_pageBlockOrderedListParent;
                                            if (z2) {
                                                TL_pageBlockDetailsChild tL_pageBlockDetailsChild5 = (TL_pageBlockDetailsChild) pageBlock2;
                                                z = z2;
                                                TL_pageBlockDetailsChild tL_pageBlockDetailsChild6 = new TL_pageBlockDetailsChild();
                                                tL_pageBlockDetailsChild6.parent = tL_pageBlockDetailsChild5.parent;
                                                tL_pageBlockDetailsChild6.block = tL_pageBlockOrderedListItem3;
                                                addBlock(tL_pageBlockDetailsChild6, i, i2 + 1, i3);
                                            } else {
                                                z = z2;
                                                addBlock(tL_pageBlockOrderedListItem3, i, i2 + 1, i3);
                                            }
                                            tL_pageBlockOrderedListParent.items.add(tL_pageBlockOrderedListItem3);
                                            i11++;
                                            pageBlock2 = pageBlock;
                                            z2 = z;
                                        }
                                        continue;
                                    }
                                    i10++;
                                    pageBlock2 = pageBlock;
                                    tL_pageBlockOrderedList2 = tL_pageBlockOrderedList;
                                    z2 = z2;
                                    size5 = i4;
                                    str5 = str2;
                                    str6 = str;
                                }
                            }
                            i4 = size5;
                            str = str6;
                            pageListOrderedItem = pageListOrderedItem2;
                            if (!z2) {
                            }
                            if (!(pageListOrderedItem instanceof TLRPC.TL_pageListOrderedItemBlocks)) {
                            }
                            i10++;
                            pageBlock2 = pageBlock;
                            tL_pageBlockOrderedList2 = tL_pageBlockOrderedList;
                            z2 = z2;
                            size5 = i4;
                            str5 = str2;
                            str6 = str;
                        }
                    }
                }
            }
        }

        private void addAllMediaFromBlock(TLRPC.PageBlock pageBlock) {
            if (pageBlock instanceof TLRPC.TL_pageBlockPhoto) {
                TLRPC.TL_pageBlockPhoto tL_pageBlockPhoto = (TLRPC.TL_pageBlockPhoto) pageBlock;
                TLRPC.Photo photoWithId = ArticleViewer.this.getPhotoWithId(tL_pageBlockPhoto.photo_id);
                if (photoWithId != null) {
                    tL_pageBlockPhoto.thumb = FileLoader.getClosestPhotoSizeWithSize(photoWithId.sizes, 56, true);
                    tL_pageBlockPhoto.thumbObject = photoWithId;
                    this.photoBlocks.add(pageBlock);
                }
            } else if (!(pageBlock instanceof TLRPC.TL_pageBlockVideo) || !ArticleViewer.this.isVideoBlock(pageBlock)) {
                int i = 0;
                if (pageBlock instanceof TLRPC.TL_pageBlockSlideshow) {
                    TLRPC.TL_pageBlockSlideshow tL_pageBlockSlideshow = (TLRPC.TL_pageBlockSlideshow) pageBlock;
                    int size = tL_pageBlockSlideshow.items.size();
                    while (i < size) {
                        TLRPC.PageBlock pageBlock2 = tL_pageBlockSlideshow.items.get(i);
                        pageBlock2.groupId = ArticleViewer.this.lastBlockNum;
                        addAllMediaFromBlock(pageBlock2);
                        i++;
                    }
                    ArticleViewer.access$13108(ArticleViewer.this);
                } else if (pageBlock instanceof TLRPC.TL_pageBlockCollage) {
                    TLRPC.TL_pageBlockCollage tL_pageBlockCollage = (TLRPC.TL_pageBlockCollage) pageBlock;
                    int size2 = tL_pageBlockCollage.items.size();
                    while (i < size2) {
                        TLRPC.PageBlock pageBlock3 = tL_pageBlockCollage.items.get(i);
                        pageBlock3.groupId = ArticleViewer.this.lastBlockNum;
                        addAllMediaFromBlock(pageBlock3);
                        i++;
                    }
                    ArticleViewer.access$13108(ArticleViewer.this);
                } else if (pageBlock instanceof TLRPC.TL_pageBlockCover) {
                    addAllMediaFromBlock(((TLRPC.TL_pageBlockCover) pageBlock).cover);
                }
            } else {
                TLRPC.TL_pageBlockVideo tL_pageBlockVideo = (TLRPC.TL_pageBlockVideo) pageBlock;
                TLRPC.Document documentWithId = ArticleViewer.this.getDocumentWithId(tL_pageBlockVideo.video_id);
                if (documentWithId != null) {
                    tL_pageBlockVideo.thumb = FileLoader.getClosestPhotoSizeWithSize(documentWithId.thumbs, 56, true);
                    tL_pageBlockVideo.thumbObject = documentWithId;
                    this.photoBlocks.add(pageBlock);
                }
            }
        }

        /* JADX WARN: Multi-variable type inference failed */
        /* JADX WARN: Type inference failed for: r11v3, types: [android.widget.FrameLayout, im.guobwnxjuc.ui.ArticleViewer$WebpageAdapter$1] */
        /* JADX WARN: Type inference failed for: r11v4 */
        /* JADX WARN: Type inference failed for: r11v10, types: [im.guobwnxjuc.ui.ArticleViewer$BlockVideoCell] */
        /* JADX WARN: Type inference failed for: r11v14, types: [im.guobwnxjuc.ui.ArticleViewer$BlockPhotoCell] */
        /* JADX WARN: Type inference failed for: r11v23, types: [im.guobwnxjuc.ui.ArticleViewer$BlockChannelCell] */
        /* JADX WARN: Type inference failed for: r11v27, types: [im.guobwnxjuc.ui.ArticleViewer$BlockMapCell] */
        /* JADX WARNING: Unknown variable types count: 1 */
        @Override // androidx.recyclerview.widget.RecyclerView.Adapter
        public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
            TextView textView;
            ?? r11;
            if (i != 90) {
                switch (i) {
                    case 0:
                        textView = new BlockParagraphCell(this.context, this);
                        break;
                    case 1:
                        textView = new BlockHeaderCell(this.context, this);
                        break;
                    case 2:
                        textView = new BlockDividerCell(this.context);
                        break;
                    case 3:
                        textView = new BlockEmbedCell(this.context, this);
                        break;
                    case 4:
                        textView = new BlockSubtitleCell(this.context, this);
                        break;
                    case 5:
                        r11 = new BlockVideoCell(this.context, this, 0);
                        break;
                    case 6:
                        textView = new BlockPullquoteCell(this.context, this);
                        break;
                    case 7:
                        textView = new BlockBlockquoteCell(this.context, this);
                        break;
                    case 8:
                        textView = new BlockSlideshowCell(this.context, this);
                        break;
                    case 9:
                        r11 = new BlockPhotoCell(this.context, this, 0);
                        break;
                    case 10:
                        textView = new BlockAuthorDateCell(this.context, this);
                        break;
                    case 11:
                        textView = new BlockTitleCell(this.context, this);
                        break;
                    case 12:
                        textView = new BlockListItemCell(this.context, this);
                        break;
                    case 13:
                        textView = new BlockFooterCell(this.context, this);
                        break;
                    case 14:
                        textView = new BlockPreformattedCell(this.context, this);
                        break;
                    case 15:
                        textView = new BlockSubheaderCell(this.context, this);
                        break;
                    case 16:
                        textView = new BlockEmbedPostCell(this.context, this);
                        break;
                    case 17:
                        textView = new BlockCollageCell(this.context, this);
                        break;
                    case 18:
                        r11 = new BlockChannelCell(this.context, this, 0);
                        break;
                    case 19:
                        textView = new BlockAudioCell(this.context, this);
                        break;
                    case 20:
                        textView = new BlockKickerCell(this.context, this);
                        break;
                    case 21:
                        textView = new BlockOrderedListItemCell(this.context, this);
                        break;
                    case 22:
                        r11 = new BlockMapCell(this.context, this, 0);
                        break;
                    case 23:
                        textView = new BlockRelatedArticlesCell(this.context, this);
                        break;
                    case 24:
                        textView = new BlockDetailsCell(this.context, this);
                        break;
                    case 25:
                        textView = new BlockTableCell(this.context, this);
                        break;
                    case 26:
                        textView = new BlockRelatedArticlesHeaderCell(this.context, this);
                        break;
                    case 27:
                        textView = new BlockDetailsBottomCell(this.context);
                        break;
                    case 28:
                        textView = new BlockRelatedArticlesShadowCell(this.context);
                        break;
                    default:
                        TextView textView2 = new TextView(this.context);
                        textView2.setBackgroundColor(SupportMenu.CATEGORY_MASK);
                        textView2.setTextColor(-16777216);
                        textView2.setTextSize(1, 20.0f);
                        textView = textView2;
                        break;
                }
                textView.setLayoutParams(new RecyclerView.LayoutParams(-1, -2));
                textView.setFocusable(true);
                return new RecyclerListView.Holder(textView);
            }
            r11 = new FrameLayout(this.context) {
                /* class im.guobwnxjuc.ui.ArticleViewer.WebpageAdapter.AnonymousClass1 */

                /* access modifiers changed from: protected */
                public void onMeasure(int i, int i2) {
                    super.onMeasure(i, View.MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(44.0f), 1073741824));
                }
            };
            r11.setTag(90);
            TextView textView3 = new TextView(this.context);
            r11.addView(textView3, LayoutHelper.createFrame(-1.0f, 34.0f, 51, 0.0f, 10.0f, 0.0f, 0.0f));
            textView3.setText(LocaleController.getString("PreviewFeedback", R.string.PreviewFeedback));
            textView3.setTextSize(1, 12.0f);
            textView3.setGravity(17);
            textView = r11;
            textView.setLayoutParams(new RecyclerView.LayoutParams(-1, -2));
            textView.setFocusable(true);
            return new RecyclerListView.Holder(textView);
        }

        @Override // im.guobwnxjuc.ui.components.RecyclerListView.SelectionAdapter
        public boolean isEnabled(RecyclerView.ViewHolder viewHolder) {
            int itemViewType = viewHolder.getItemViewType();
            return itemViewType == 23 || itemViewType == 24;
        }

        @Override // androidx.recyclerview.widget.RecyclerView.Adapter
        public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, int i) {
            if (i < this.localBlocks.size()) {
                bindBlockToHolder(viewHolder.getItemViewType(), viewHolder, this.localBlocks.get(i), i, this.localBlocks.size());
            } else if (viewHolder.getItemViewType() == 90) {
                TextView textView = (TextView) ((ViewGroup) viewHolder.itemView).getChildAt(0);
                int selectedColor = ArticleViewer.this.getSelectedColor();
                if (selectedColor == 0) {
                    textView.setTextColor(-8879475);
                    textView.setBackgroundColor(-1183760);
                } else if (selectedColor == 1) {
                    textView.setTextColor(ArticleViewer.this.getGrayTextColor());
                    textView.setBackgroundColor(-1712440);
                } else if (selectedColor == 2) {
                    textView.setTextColor(ArticleViewer.this.getGrayTextColor());
                    textView.setBackgroundColor(-15000805);
                }
            }
        }

        /* access modifiers changed from: private */
        /* access modifiers changed from: public */
        private void bindBlockToHolder(int i, RecyclerView.ViewHolder viewHolder, TLRPC.PageBlock pageBlock, int i2, int i3) {
            TLRPC.PageBlock pageBlock2;
            if (pageBlock instanceof TLRPC.TL_pageBlockCover) {
                pageBlock2 = ((TLRPC.TL_pageBlockCover) pageBlock).cover;
            } else if (pageBlock instanceof TL_pageBlockDetailsChild) {
                pageBlock2 = ((TL_pageBlockDetailsChild) pageBlock).block;
            } else {
                pageBlock2 = pageBlock;
            }
            if (i != 100) {
                boolean z = false;
                switch (i) {
                    case 0:
                        ((BlockParagraphCell) viewHolder.itemView).setBlock((TLRPC.TL_pageBlockParagraph) pageBlock2);
                        return;
                    case 1:
                        ((BlockHeaderCell) viewHolder.itemView).setBlock((TLRPC.TL_pageBlockHeader) pageBlock2);
                        return;
                    case 2:
                        BlockDividerCell blockDividerCell = (BlockDividerCell) viewHolder.itemView;
                        return;
                    case 3:
                        ((BlockEmbedCell) viewHolder.itemView).setBlock((TLRPC.TL_pageBlockEmbed) pageBlock2);
                        return;
                    case 4:
                        ((BlockSubtitleCell) viewHolder.itemView).setBlock((TLRPC.TL_pageBlockSubtitle) pageBlock2);
                        return;
                    case 5:
                        BlockVideoCell blockVideoCell = (BlockVideoCell) viewHolder.itemView;
                        TLRPC.TL_pageBlockVideo tL_pageBlockVideo = (TLRPC.TL_pageBlockVideo) pageBlock2;
                        boolean z2 = i2 == 0;
                        if (i2 == i3 - 1) {
                            z = true;
                        }
                        blockVideoCell.setBlock(tL_pageBlockVideo, z2, z);
                        blockVideoCell.setParentBlock(pageBlock);
                        return;
                    case 6:
                        ((BlockPullquoteCell) viewHolder.itemView).setBlock((TLRPC.TL_pageBlockPullquote) pageBlock2);
                        return;
                    case 7:
                        ((BlockBlockquoteCell) viewHolder.itemView).setBlock((TLRPC.TL_pageBlockBlockquote) pageBlock2);
                        return;
                    case 8:
                        ((BlockSlideshowCell) viewHolder.itemView).setBlock((TLRPC.TL_pageBlockSlideshow) pageBlock2);
                        return;
                    case 9:
                        BlockPhotoCell blockPhotoCell = (BlockPhotoCell) viewHolder.itemView;
                        TLRPC.TL_pageBlockPhoto tL_pageBlockPhoto = (TLRPC.TL_pageBlockPhoto) pageBlock2;
                        boolean z3 = i2 == 0;
                        if (i2 == i3 - 1) {
                            z = true;
                        }
                        blockPhotoCell.setBlock(tL_pageBlockPhoto, z3, z);
                        blockPhotoCell.setParentBlock(pageBlock);
                        return;
                    case 10:
                        ((BlockAuthorDateCell) viewHolder.itemView).setBlock((TLRPC.TL_pageBlockAuthorDate) pageBlock2);
                        return;
                    case 11:
                        ((BlockTitleCell) viewHolder.itemView).setBlock((TLRPC.TL_pageBlockTitle) pageBlock2);
                        return;
                    case 12:
                        ((BlockListItemCell) viewHolder.itemView).setBlock((TL_pageBlockListItem) pageBlock2);
                        return;
                    case 13:
                        ((BlockFooterCell) viewHolder.itemView).setBlock((TLRPC.TL_pageBlockFooter) pageBlock2);
                        return;
                    case 14:
                        ((BlockPreformattedCell) viewHolder.itemView).setBlock((TLRPC.TL_pageBlockPreformatted) pageBlock2);
                        return;
                    case 15:
                        ((BlockSubheaderCell) viewHolder.itemView).setBlock((TLRPC.TL_pageBlockSubheader) pageBlock2);
                        return;
                    case 16:
                        ((BlockEmbedPostCell) viewHolder.itemView).setBlock((TLRPC.TL_pageBlockEmbedPost) pageBlock2);
                        return;
                    case 17:
                        ((BlockCollageCell) viewHolder.itemView).setBlock((TLRPC.TL_pageBlockCollage) pageBlock2);
                        return;
                    case 18:
                        ((BlockChannelCell) viewHolder.itemView).setBlock((TLRPC.TL_pageBlockChannel) pageBlock2);
                        return;
                    case 19:
                        BlockAudioCell blockAudioCell = (BlockAudioCell) viewHolder.itemView;
                        TLRPC.TL_pageBlockAudio tL_pageBlockAudio = (TLRPC.TL_pageBlockAudio) pageBlock2;
                        boolean z4 = i2 == 0;
                        if (i2 == i3 - 1) {
                            z = true;
                        }
                        blockAudioCell.setBlock(tL_pageBlockAudio, z4, z);
                        return;
                    case 20:
                        ((BlockKickerCell) viewHolder.itemView).setBlock((TLRPC.TL_pageBlockKicker) pageBlock2);
                        return;
                    case 21:
                        ((BlockOrderedListItemCell) viewHolder.itemView).setBlock((TL_pageBlockOrderedListItem) pageBlock2);
                        return;
                    case 22:
                        BlockMapCell blockMapCell = (BlockMapCell) viewHolder.itemView;
                        TLRPC.TL_pageBlockMap tL_pageBlockMap = (TLRPC.TL_pageBlockMap) pageBlock2;
                        boolean z5 = i2 == 0;
                        if (i2 == i3 - 1) {
                            z = true;
                        }
                        blockMapCell.setBlock(tL_pageBlockMap, z5, z);
                        return;
                    case 23:
                        ((BlockRelatedArticlesCell) viewHolder.itemView).setBlock((TL_pageBlockRelatedArticlesChild) pageBlock2);
                        return;
                    case 24:
                        ((BlockDetailsCell) viewHolder.itemView).setBlock((TLRPC.TL_pageBlockDetails) pageBlock2);
                        return;
                    case 25:
                        ((BlockTableCell) viewHolder.itemView).setBlock((TLRPC.TL_pageBlockTable) pageBlock2);
                        return;
                    case 26:
                        ((BlockRelatedArticlesHeaderCell) viewHolder.itemView).setBlock((TLRPC.TL_pageBlockRelatedArticles) pageBlock2);
                        return;
                    case 27:
                        BlockDetailsBottomCell blockDetailsBottomCell = (BlockDetailsBottomCell) viewHolder.itemView;
                        return;
                    default:
                        return;
                }
            } else {
                ((TextView) viewHolder.itemView).setText("unsupported block " + pageBlock2);
            }
        }

        /* access modifiers changed from: private */
        /* access modifiers changed from: public */
        private int getTypeForBlock(TLRPC.PageBlock pageBlock) {
            if (pageBlock instanceof TLRPC.TL_pageBlockParagraph) {
                return 0;
            }
            if (pageBlock instanceof TLRPC.TL_pageBlockHeader) {
                return 1;
            }
            if (pageBlock instanceof TLRPC.TL_pageBlockDivider) {
                return 2;
            }
            if (pageBlock instanceof TLRPC.TL_pageBlockEmbed) {
                return 3;
            }
            if (pageBlock instanceof TLRPC.TL_pageBlockSubtitle) {
                return 4;
            }
            if (pageBlock instanceof TLRPC.TL_pageBlockVideo) {
                return 5;
            }
            if (pageBlock instanceof TLRPC.TL_pageBlockPullquote) {
                return 6;
            }
            if (pageBlock instanceof TLRPC.TL_pageBlockBlockquote) {
                return 7;
            }
            if (pageBlock instanceof TLRPC.TL_pageBlockSlideshow) {
                return 8;
            }
            if (pageBlock instanceof TLRPC.TL_pageBlockPhoto) {
                return 9;
            }
            if (pageBlock instanceof TLRPC.TL_pageBlockAuthorDate) {
                return 10;
            }
            if (pageBlock instanceof TLRPC.TL_pageBlockTitle) {
                return 11;
            }
            if (pageBlock instanceof TL_pageBlockListItem) {
                return 12;
            }
            if (pageBlock instanceof TLRPC.TL_pageBlockFooter) {
                return 13;
            }
            if (pageBlock instanceof TLRPC.TL_pageBlockPreformatted) {
                return 14;
            }
            if (pageBlock instanceof TLRPC.TL_pageBlockSubheader) {
                return 15;
            }
            if (pageBlock instanceof TLRPC.TL_pageBlockEmbedPost) {
                return 16;
            }
            if (pageBlock instanceof TLRPC.TL_pageBlockCollage) {
                return 17;
            }
            if (pageBlock instanceof TLRPC.TL_pageBlockChannel) {
                return 18;
            }
            if (pageBlock instanceof TLRPC.TL_pageBlockAudio) {
                return 19;
            }
            if (pageBlock instanceof TLRPC.TL_pageBlockKicker) {
                return 20;
            }
            if (pageBlock instanceof TL_pageBlockOrderedListItem) {
                return 21;
            }
            if (pageBlock instanceof TLRPC.TL_pageBlockMap) {
                return 22;
            }
            if (pageBlock instanceof TL_pageBlockRelatedArticlesChild) {
                return 23;
            }
            if (pageBlock instanceof TLRPC.TL_pageBlockDetails) {
                return 24;
            }
            if (pageBlock instanceof TLRPC.TL_pageBlockTable) {
                return 25;
            }
            if (pageBlock instanceof TLRPC.TL_pageBlockRelatedArticles) {
                return 26;
            }
            if (pageBlock instanceof TL_pageBlockDetailsBottom) {
                return 27;
            }
            if (pageBlock instanceof TL_pageBlockRelatedArticlesShadow) {
                return 28;
            }
            if (pageBlock instanceof TL_pageBlockDetailsChild) {
                return getTypeForBlock(((TL_pageBlockDetailsChild) pageBlock).block);
            }
            if (pageBlock instanceof TLRPC.TL_pageBlockCover) {
                return getTypeForBlock(((TLRPC.TL_pageBlockCover) pageBlock).cover);
            }
            return 100;
        }

        @Override // androidx.recyclerview.widget.RecyclerView.Adapter
        public int getItemViewType(int i) {
            if (i == this.localBlocks.size()) {
                return 90;
            }
            return getTypeForBlock(this.localBlocks.get(i));
        }

        public TLRPC.PageBlock getItem(int i) {
            return this.localBlocks.get(i);
        }

        @Override // androidx.recyclerview.widget.RecyclerView.Adapter
        public int getItemCount() {
            if (ArticleViewer.this.currentPage == null || ArticleViewer.this.currentPage.cached_page == null) {
                return 0;
            }
            return this.localBlocks.size() + 1;
        }

        private boolean isBlockOpened(TL_pageBlockDetailsChild tL_pageBlockDetailsChild) {
            TLRPC.PageBlock lastNonListPageBlock = ArticleViewer.this.getLastNonListPageBlock(tL_pageBlockDetailsChild.parent);
            if (lastNonListPageBlock instanceof TLRPC.TL_pageBlockDetails) {
                return ((TLRPC.TL_pageBlockDetails) lastNonListPageBlock).open;
            }
            if (!(lastNonListPageBlock instanceof TL_pageBlockDetailsChild)) {
                return false;
            }
            TL_pageBlockDetailsChild tL_pageBlockDetailsChild2 = (TL_pageBlockDetailsChild) lastNonListPageBlock;
            TLRPC.PageBlock lastNonListPageBlock2 = ArticleViewer.this.getLastNonListPageBlock(tL_pageBlockDetailsChild2.block);
            if (!(lastNonListPageBlock2 instanceof TLRPC.TL_pageBlockDetails) || ((TLRPC.TL_pageBlockDetails) lastNonListPageBlock2).open) {
                return isBlockOpened(tL_pageBlockDetailsChild2);
            }
            return false;
        }

        /* access modifiers changed from: private */
        /* access modifiers changed from: public */
        private void updateRows() {
            this.localBlocks.clear();
            int size = this.blocks.size();
            for (int i = 0; i < size; i++) {
                TLRPC.PageBlock pageBlock = this.blocks.get(i);
                TLRPC.PageBlock lastNonListPageBlock = ArticleViewer.this.getLastNonListPageBlock(pageBlock);
                if (!(lastNonListPageBlock instanceof TL_pageBlockDetailsChild) || isBlockOpened((TL_pageBlockDetailsChild) lastNonListPageBlock)) {
                    this.localBlocks.add(pageBlock);
                }
            }
        }

        /* access modifiers changed from: private */
        /* access modifiers changed from: public */
        private void cleanup() {
            this.blocks.clear();
            this.photoBlocks.clear();
            this.audioBlocks.clear();
            this.audioMessages.clear();
            this.anchors.clear();
            this.anchorsParent.clear();
            this.anchorsOffset.clear();
            notifyDataSetChanged();
        }

        @Override // androidx.recyclerview.widget.RecyclerView.Adapter
        public void notifyDataSetChanged() {
            updateRows();
            super.notifyDataSetChanged();
        }

        @Override // androidx.recyclerview.widget.RecyclerView.Adapter
        public void notifyItemChanged(int i) {
            updateRows();
            super.notifyItemChanged(i);
        }

        @Override // androidx.recyclerview.widget.RecyclerView.Adapter
        public void notifyItemChanged(int i, Object obj) {
            updateRows();
            super.notifyItemChanged(i, obj);
        }

        @Override // androidx.recyclerview.widget.RecyclerView.Adapter
        public void notifyItemRangeChanged(int i, int i2) {
            updateRows();
            super.notifyItemRangeChanged(i, i2);
        }

        @Override // androidx.recyclerview.widget.RecyclerView.Adapter
        public void notifyItemRangeChanged(int i, int i2, Object obj) {
            updateRows();
            super.notifyItemRangeChanged(i, i2, obj);
        }

        @Override // androidx.recyclerview.widget.RecyclerView.Adapter
        public void notifyItemInserted(int i) {
            updateRows();
            super.notifyItemInserted(i);
        }

        @Override // androidx.recyclerview.widget.RecyclerView.Adapter
        public void notifyItemMoved(int i, int i2) {
            updateRows();
            super.notifyItemMoved(i, i2);
        }

        @Override // androidx.recyclerview.widget.RecyclerView.Adapter
        public void notifyItemRangeInserted(int i, int i2) {
            updateRows();
            super.notifyItemRangeInserted(i, i2);
        }

        @Override // androidx.recyclerview.widget.RecyclerView.Adapter
        public void notifyItemRemoved(int i) {
            updateRows();
            super.notifyItemRemoved(i);
        }

        @Override // androidx.recyclerview.widget.RecyclerView.Adapter
        public void notifyItemRangeRemoved(int i, int i2) {
            updateRows();
            super.notifyItemRangeRemoved(i, i2);
        }
    }

    /* access modifiers changed from: private */
    public class BlockVideoCell extends FrameLayout implements DownloadController.FileDownloadProgressListener {
        private int TAG;
        private boolean autoDownload;
        private int buttonPressed;
        private int buttonState;
        private int buttonX;
        private int buttonY;
        private boolean cancelLoading;
        private DrawingText captionLayout;
        private BlockChannelCell channelCell;
        private DrawingText creditLayout;
        private int creditOffset;
        private TLRPC.TL_pageBlockVideo currentBlock;
        private TLRPC.Document currentDocument;
        private int currentType;
        private MessageObject.GroupedMessagePosition groupPosition;
        private ImageReceiver imageView;
        private boolean isFirst;
        private boolean isGif;
        private boolean isLast;
        private WebpageAdapter parentAdapter;
        private TLRPC.PageBlock parentBlock;
        private boolean photoPressed;
        private RadialProgress2 radialProgress;
        private int textX;
        private int textY;

        @Override // im.guobwnxjuc.messenger.DownloadController.FileDownloadProgressListener
        public void onProgressUpload(String str, float f, boolean z) {
        }

        public BlockVideoCell(Context context, WebpageAdapter webpageAdapter, int i) {
            super(context);
            this.parentAdapter = webpageAdapter;
            setWillNotDraw(false);
            ImageReceiver imageReceiver = new ImageReceiver(this);
            this.imageView = imageReceiver;
            imageReceiver.setNeedsQualityThumb(true);
            this.imageView.setShouldGenerateQualityThumb(true);
            this.currentType = i;
            RadialProgress2 radialProgress2 = new RadialProgress2(this);
            this.radialProgress = radialProgress2;
            radialProgress2.setProgressColor(-1);
            this.radialProgress.setColors(1711276032, Theme.ACTION_BAR_PHOTO_VIEWER_COLOR, -1, -2500135);
            this.TAG = DownloadController.getInstance(ArticleViewer.this.currentAccount).generateObserverTag();
            BlockChannelCell blockChannelCell = new BlockChannelCell(context, this.parentAdapter, 1);
            this.channelCell = blockChannelCell;
            addView(blockChannelCell, LayoutHelper.createFrame(-1, -2.0f));
        }

        public void setBlock(TLRPC.TL_pageBlockVideo tL_pageBlockVideo, boolean z, boolean z2) {
            this.currentBlock = tL_pageBlockVideo;
            this.parentBlock = null;
            this.cancelLoading = false;
            TLRPC.Document documentWithId = ArticleViewer.this.getDocumentWithId(tL_pageBlockVideo.video_id);
            this.currentDocument = documentWithId;
            this.isGif = MessageObject.isGifDocument(documentWithId);
            this.isFirst = z;
            this.isLast = z2;
            this.channelCell.setVisibility(4);
            updateButtonState(false);
            requestLayout();
        }

        public void setParentBlock(TLRPC.PageBlock pageBlock) {
            this.parentBlock = pageBlock;
            if (ArticleViewer.this.channelBlock != null && (this.parentBlock instanceof TLRPC.TL_pageBlockCover)) {
                this.channelCell.setBlock(ArticleViewer.this.channelBlock);
                this.channelCell.setVisibility(0);
            }
        }

        public View getChannelCell() {
            return this.channelCell;
        }

        /* JADX WARNING: Code restructure failed: missing block: B:25:0x0095, code lost:
            if (r1 <= ((float) (r0 + im.guobwnxjuc.messenger.AndroidUtilities.dp(48.0f)))) goto L_0x009b;
         */
        public boolean onTouchEvent(MotionEvent motionEvent) {
            float x = motionEvent.getX();
            float y = motionEvent.getY();
            if (this.channelCell.getVisibility() != 0 || y <= this.channelCell.getTranslationY() || y >= this.channelCell.getTranslationY() + ((float) AndroidUtilities.dp(39.0f))) {
                if (motionEvent.getAction() == 0 && this.imageView.isInsideImage(x, y)) {
                    if (this.buttonState != -1) {
                        int i = this.buttonX;
                        if (x >= ((float) i) && x <= ((float) (i + AndroidUtilities.dp(48.0f)))) {
                            int i2 = this.buttonY;
                            if (y >= ((float) i2)) {
                            }
                        }
                    }
                    if (this.buttonState != 0) {
                        this.photoPressed = true;
                    }
                    this.buttonPressed = 1;
                    invalidate();
                } else if (motionEvent.getAction() == 1) {
                    if (this.photoPressed) {
                        this.photoPressed = false;
                        ArticleViewer.this.openPhoto(this.currentBlock);
                    } else if (this.buttonPressed == 1) {
                        this.buttonPressed = 0;
                        playSoundEffect(0);
                        didPressedButton(true);
                        invalidate();
                    }
                } else if (motionEvent.getAction() == 3) {
                    this.photoPressed = false;
                }
                if (this.photoPressed || this.buttonPressed != 0 || ArticleViewer.this.checkLayoutForLinks(motionEvent, this, this.captionLayout, this.textX, this.textY) || ArticleViewer.this.checkLayoutForLinks(motionEvent, this, this.creditLayout, this.textX, this.textY + this.creditOffset) || super.onTouchEvent(motionEvent)) {
                    return true;
                }
                return false;
            }
            if (ArticleViewer.this.channelBlock != null && motionEvent.getAction() == 1) {
                MessagesController.getInstance(ArticleViewer.this.currentAccount).openByUserName(ArticleViewer.this.channelBlock.channel.username, ArticleViewer.this.parentFragment, 2);
                ArticleViewer.this.close(false, true);
            }
            return true;
        }

        /* access modifiers changed from: protected */
        /* JADX WARNING: Removed duplicated region for block: B:103:0x0313  */
        /* JADX WARNING: Removed duplicated region for block: B:64:0x017a  */
        /* JADX WARNING: Removed duplicated region for block: B:70:0x0209  */
        /* JADX WARNING: Removed duplicated region for block: B:9:0x0049  */
        public void onMeasure(int i, int i2) {
            int i3;
            int i4;
            TLRPC.TL_pageBlockVideo tL_pageBlockVideo;
            int i5;
            int i6;
            int i7;
            int i8;
            int i9;
            int i10;
            int i11;
            boolean z;
            int size = View.MeasureSpec.getSize(i);
            int i12 = this.currentType;
            boolean z2 = false;
            if (i12 == 1) {
                size = ((View) getParent()).getMeasuredWidth();
                i4 = ((View) getParent()).getMeasuredHeight();
            } else if (i12 == 2) {
                i4 = (int) Math.ceil((double) (this.groupPosition.ph * ((float) Math.max(AndroidUtilities.displaySize.x, AndroidUtilities.displaySize.y)) * 0.5f));
            } else {
                i3 = size;
                i4 = 0;
                tL_pageBlockVideo = this.currentBlock;
                if (tL_pageBlockVideo == null) {
                    if (this.currentType != 0 || tL_pageBlockVideo.level <= 0) {
                        this.textX = AndroidUtilities.dp(18.0f);
                        i6 = i3 - AndroidUtilities.dp(36.0f);
                        i7 = i3;
                        i8 = 0;
                    } else {
                        i8 = AndroidUtilities.dp((float) (this.currentBlock.level * 14)) + AndroidUtilities.dp(18.0f);
                        this.textX = i8;
                        i7 = i3 - (AndroidUtilities.dp(18.0f) + i8);
                        i6 = i7;
                    }
                    if (this.currentDocument != null) {
                        int dp = AndroidUtilities.dp(48.0f);
                        TLRPC.PhotoSize closestPhotoSizeWithSize = FileLoader.getClosestPhotoSizeWithSize(this.currentDocument.thumbs, 48);
                        int i13 = this.currentType;
                        if (i13 == 0) {
                            int size2 = this.currentDocument.attributes.size();
                            int i14 = 0;
                            while (true) {
                                if (i14 >= size2) {
                                    z = false;
                                    break;
                                }
                                TLRPC.DocumentAttribute documentAttribute = this.currentDocument.attributes.get(i14);
                                if (documentAttribute instanceof TLRPC.TL_documentAttributeVideo) {
                                    i4 = (int) ((((float) i7) / ((float) documentAttribute.w)) * ((float) documentAttribute.h));
                                    z = true;
                                    break;
                                }
                                i14++;
                            }
                            float f = closestPhotoSizeWithSize != null ? (float) closestPhotoSizeWithSize.w : 100.0f;
                            float f2 = closestPhotoSizeWithSize != null ? (float) closestPhotoSizeWithSize.h : 100.0f;
                            if (!z) {
                                i4 = (int) ((((float) i7) / f) * f2);
                            }
                            if (this.parentBlock instanceof TLRPC.TL_pageBlockCover) {
                                i4 = Math.min(i4, i7);
                            } else {
                                int max = (int) (((float) (Math.max(ArticleViewer.this.listView[0].getMeasuredWidth(), ArticleViewer.this.listView[0].getMeasuredHeight()) - AndroidUtilities.dp(56.0f))) * 0.9f);
                                if (i4 > max) {
                                    int i15 = (int) ((((float) max) / f2) * f);
                                    i8 += ((i3 - i8) - i15) / 2;
                                    i7 = i15;
                                    i4 = max;
                                }
                            }
                            if (i4 == 0) {
                                i4 = AndroidUtilities.dp(100.0f);
                            } else if (i4 < dp) {
                                i4 = dp;
                            }
                        } else if (i13 == 2) {
                            if ((this.groupPosition.flags & 2) == 0) {
                                i7 -= AndroidUtilities.dp(2.0f);
                            }
                            if ((this.groupPosition.flags & 8) == 0) {
                                i10 = i4;
                                i4 -= AndroidUtilities.dp(2.0f);
                                i9 = i7;
                                this.imageView.setQualityThumbDocument(this.currentDocument);
                                this.imageView.setImageCoords(i8, (!this.isFirst || (i11 = this.currentType) == 1 || i11 == 2 || this.currentBlock.level > 0) ? 0 : AndroidUtilities.dp(8.0f), i9, i4);
                                if (!this.isGif) {
                                    this.autoDownload = DownloadController.getInstance(ArticleViewer.this.currentAccount).canDownloadMedia(4, this.currentDocument.size);
                                    File pathToAttach = FileLoader.getPathToAttach(this.currentDocument, true);
                                    if (this.autoDownload || pathToAttach.exists()) {
                                        this.imageView.setStrippedLocation(null);
                                        this.imageView.setImage(ImageLocation.getForDocument(this.currentDocument), null, null, null, ImageLocation.getForDocument(closestPhotoSizeWithSize, this.currentDocument), "80_80_b", null, this.currentDocument.size, null, ArticleViewer.this.currentPage, 1);
                                    } else {
                                        this.imageView.setStrippedLocation(ImageLocation.getForDocument(this.currentDocument));
                                        this.imageView.setImage(null, null, null, null, ImageLocation.getForDocument(closestPhotoSizeWithSize, this.currentDocument), "80_80_b", null, this.currentDocument.size, null, ArticleViewer.this.currentPage, 1);
                                    }
                                } else {
                                    this.imageView.setStrippedLocation(null);
                                    this.imageView.setImage(null, null, ImageLocation.getForDocument(closestPhotoSizeWithSize, this.currentDocument), "80_80_b", 0, null, ArticleViewer.this.currentPage, 1);
                                }
                                this.imageView.setAspectFit(true);
                                this.buttonX = (int) (((float) this.imageView.getImageX()) + (((float) (this.imageView.getImageWidth() - dp)) / 2.0f));
                                int imageY = (int) (((float) this.imageView.getImageY()) + (((float) (this.imageView.getImageHeight() - dp)) / 2.0f));
                                this.buttonY = imageY;
                                RadialProgress2 radialProgress2 = this.radialProgress;
                                int i16 = this.buttonX;
                                radialProgress2.setProgressRect(i16, imageY, i16 + dp, dp + imageY);
                                i5 = i10;
                            }
                        }
                        i9 = i7;
                        i10 = i4;
                        this.imageView.setQualityThumbDocument(this.currentDocument);
                        this.imageView.setImageCoords(i8, (!this.isFirst || (i11 = this.currentType) == 1 || i11 == 2 || this.currentBlock.level > 0) ? 0 : AndroidUtilities.dp(8.0f), i9, i4);
                        if (!this.isGif) {
                        }
                        this.imageView.setAspectFit(true);
                        this.buttonX = (int) (((float) this.imageView.getImageX()) + (((float) (this.imageView.getImageWidth() - dp)) / 2.0f));
                        int imageY2 = (int) (((float) this.imageView.getImageY()) + (((float) (this.imageView.getImageHeight() - dp)) / 2.0f));
                        this.buttonY = imageY2;
                        RadialProgress2 radialProgress22 = this.radialProgress;
                        int i162 = this.buttonX;
                        radialProgress22.setProgressRect(i162, imageY2, i162 + dp, dp + imageY2);
                        i5 = i10;
                    } else {
                        i5 = i4;
                    }
                    if (this.currentType == 0) {
                        DrawingText createLayoutForText = ArticleViewer.this.createLayoutForText(this, null, this.currentBlock.caption.text, i6, this.currentBlock, this.parentAdapter);
                        this.captionLayout = createLayoutForText;
                        if (createLayoutForText != null) {
                            int dp2 = AndroidUtilities.dp(4.0f) + this.captionLayout.getHeight();
                            this.creditOffset = dp2;
                            i5 += dp2 + AndroidUtilities.dp(4.0f);
                        }
                        DrawingText createLayoutForText2 = ArticleViewer.this.createLayoutForText((ArticleViewer) this, (View) null, (CharSequence) this.currentBlock.caption.credit, (TLRPC.RichText) i6, (int) this.currentBlock, (TLRPC.PageBlock) (ArticleViewer.this.isRtl ? StaticLayoutEx.ALIGN_RIGHT() : Layout.Alignment.ALIGN_NORMAL), (Layout.Alignment) this.parentAdapter);
                        this.creditLayout = createLayoutForText2;
                        if (createLayoutForText2 != null) {
                            i5 += AndroidUtilities.dp(4.0f) + this.creditLayout.getHeight();
                        }
                    }
                    if (!this.isFirst && this.currentType == 0 && this.currentBlock.level <= 0) {
                        i5 += AndroidUtilities.dp(8.0f);
                    }
                    if ((this.parentBlock instanceof TLRPC.TL_pageBlockCover) && this.parentAdapter.blocks.size() > 1 && (this.parentAdapter.blocks.get(1) instanceof TLRPC.TL_pageBlockChannel)) {
                        z2 = true;
                    }
                    if (this.currentType != 2 && !z2) {
                        i5 += AndroidUtilities.dp(8.0f);
                    }
                } else {
                    i5 = 1;
                }
                this.channelCell.measure(i, i2);
                this.channelCell.setTranslationY((float) (this.imageView.getImageHeight() - AndroidUtilities.dp(39.0f)));
                setMeasuredDimension(i3, i5);
            }
            i3 = size;
            tL_pageBlockVideo = this.currentBlock;
            if (tL_pageBlockVideo == null) {
            }
            this.channelCell.measure(i, i2);
            this.channelCell.setTranslationY((float) (this.imageView.getImageHeight() - AndroidUtilities.dp(39.0f)));
            setMeasuredDimension(i3, i5);
        }

        /* access modifiers changed from: protected */
        public void onDraw(Canvas canvas) {
            if (this.currentBlock != null) {
                if (!this.imageView.hasBitmapImage() || this.imageView.getCurrentAlpha() != 1.0f) {
                    canvas.drawRect(this.imageView.getDrawRegion(), ArticleViewer.photoBackgroundPaint);
                }
                this.imageView.draw(canvas);
                if (this.imageView.getVisible()) {
                    this.radialProgress.draw(canvas);
                }
                this.textY = this.imageView.getImageY() + this.imageView.getImageHeight() + AndroidUtilities.dp(8.0f);
                if (this.captionLayout != null) {
                    canvas.save();
                    canvas.translate((float) this.textX, (float) this.textY);
                    this.captionLayout.draw(canvas);
                    canvas.restore();
                }
                if (this.creditLayout != null) {
                    canvas.save();
                    canvas.translate((float) this.textX, (float) (this.textY + this.creditOffset));
                    this.creditLayout.draw(canvas);
                    canvas.restore();
                }
                if (this.currentBlock.level > 0) {
                    canvas.drawRect((float) AndroidUtilities.dp(18.0f), 0.0f, (float) AndroidUtilities.dp(20.0f), (float) (getMeasuredHeight() - (this.currentBlock.bottom ? AndroidUtilities.dp(6.0f) : 0)), ArticleViewer.quoteLinePaint);
                }
            }
        }

        private int getIconForCurrentState() {
            int i = this.buttonState;
            if (i == 0) {
                return 2;
            }
            if (i == 1) {
                return 3;
            }
            if (i == 2) {
                return 8;
            }
            return i == 3 ? 0 : 4;
        }

        public void updateButtonState(boolean z) {
            String attachFileName = FileLoader.getAttachFileName(this.currentDocument);
            boolean z2 = true;
            boolean exists = FileLoader.getPathToAttach(this.currentDocument, true).exists();
            if (TextUtils.isEmpty(attachFileName)) {
                this.radialProgress.setIcon(4, false, false);
            } else if (exists) {
                DownloadController.getInstance(ArticleViewer.this.currentAccount).removeLoadingFileObserver(this);
                if (!this.isGif) {
                    this.buttonState = 3;
                } else {
                    this.buttonState = -1;
                }
                this.radialProgress.setIcon(getIconForCurrentState(), false, z);
                invalidate();
            } else {
                DownloadController.getInstance(ArticleViewer.this.currentAccount).addLoadingFileObserver(attachFileName, null, this);
                float f = 0.0f;
                if (FileLoader.getInstance(ArticleViewer.this.currentAccount).isLoadingFile(attachFileName)) {
                    this.buttonState = 1;
                    Float fileProgress = ImageLoader.getInstance().getFileProgress(attachFileName);
                    if (fileProgress != null) {
                        f = fileProgress.floatValue();
                    }
                } else if (this.cancelLoading || !this.autoDownload || !this.isGif) {
                    this.buttonState = 0;
                    z2 = false;
                } else {
                    this.buttonState = 1;
                }
                this.radialProgress.setIcon(getIconForCurrentState(), z2, z);
                this.radialProgress.setProgress(f, false);
                invalidate();
            }
        }

        private void didPressedButton(boolean z) {
            int i = this.buttonState;
            if (i == 0) {
                this.cancelLoading = false;
                this.radialProgress.setProgress(0.0f, false);
                if (this.isGif) {
                    this.imageView.setImage(ImageLocation.getForDocument(this.currentDocument), null, ImageLocation.getForDocument(FileLoader.getClosestPhotoSizeWithSize(this.currentDocument.thumbs, 40), this.currentDocument), "80_80_b", this.currentDocument.size, null, ArticleViewer.this.currentPage, 1);
                } else {
                    FileLoader.getInstance(ArticleViewer.this.currentAccount).loadFile(this.currentDocument, ArticleViewer.this.currentPage, 1, 1);
                }
                this.buttonState = 1;
                this.radialProgress.setIcon(getIconForCurrentState(), true, z);
                invalidate();
            } else if (i == 1) {
                this.cancelLoading = true;
                if (this.isGif) {
                    this.imageView.cancelLoadImage();
                } else {
                    FileLoader.getInstance(ArticleViewer.this.currentAccount).cancelLoadFile(this.currentDocument);
                }
                this.buttonState = 0;
                this.radialProgress.setIcon(getIconForCurrentState(), false, z);
                invalidate();
            } else if (i == 2) {
                this.imageView.setAllowStartAnimation(true);
                this.imageView.startAnimation();
                this.buttonState = -1;
                this.radialProgress.setIcon(getIconForCurrentState(), false, z);
            } else if (i == 3) {
                ArticleViewer.this.openPhoto(this.currentBlock);
            }
        }

        /* access modifiers changed from: protected */
        public void onDetachedFromWindow() {
            super.onDetachedFromWindow();
            this.imageView.onDetachedFromWindow();
            DownloadController.getInstance(ArticleViewer.this.currentAccount).removeLoadingFileObserver(this);
        }

        /* access modifiers changed from: protected */
        public void onAttachedToWindow() {
            super.onAttachedToWindow();
            this.imageView.onAttachedToWindow();
            updateButtonState(false);
        }

        @Override // im.guobwnxjuc.messenger.DownloadController.FileDownloadProgressListener
        public void onFailedDownload(String str, boolean z) {
            updateButtonState(false);
        }

        @Override // im.guobwnxjuc.messenger.DownloadController.FileDownloadProgressListener
        public void onSuccessDownload(String str) {
            this.radialProgress.setProgress(1.0f, true);
            if (this.isGif) {
                this.buttonState = 2;
                didPressedButton(true);
                return;
            }
            updateButtonState(true);
        }

        @Override // im.guobwnxjuc.messenger.DownloadController.FileDownloadProgressListener
        public void onProgressDownload(String str, float f) {
            this.radialProgress.setProgress(f, true);
            if (this.buttonState != 1) {
                updateButtonState(true);
            }
        }

        @Override // im.guobwnxjuc.messenger.DownloadController.FileDownloadProgressListener
        public int getObserverTag() {
            return this.TAG;
        }

        public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo accessibilityNodeInfo) {
            super.onInitializeAccessibilityNodeInfo(accessibilityNodeInfo);
            accessibilityNodeInfo.setEnabled(true);
            StringBuilder sb = new StringBuilder(LocaleController.getString("AttachVideo", R.string.AttachVideo));
            if (this.captionLayout != null) {
                sb.append(", ");
                sb.append(this.captionLayout.getText());
            }
            accessibilityNodeInfo.setText(sb.toString());
        }
    }

    /* access modifiers changed from: private */
    public class BlockAudioCell extends View implements DownloadController.FileDownloadProgressListener {
        private int TAG;
        private int buttonPressed;
        private int buttonState;
        private int buttonX;
        private int buttonY;
        private DrawingText captionLayout;
        private DrawingText creditLayout;
        private int creditOffset;
        private TLRPC.TL_pageBlockAudio currentBlock;
        private TLRPC.Document currentDocument;
        private MessageObject currentMessageObject;
        private StaticLayout durationLayout;
        private boolean isFirst;
        private boolean isLast;
        private String lastTimeString;
        private WebpageAdapter parentAdapter;
        private RadialProgress2 radialProgress;
        private SeekBar seekBar;
        private int seekBarX;
        private int seekBarY;
        private int textX;
        private int textY = AndroidUtilities.dp(54.0f);
        private StaticLayout titleLayout;

        @Override // im.guobwnxjuc.messenger.DownloadController.FileDownloadProgressListener
        public void onProgressUpload(String str, float f, boolean z) {
        }

        public BlockAudioCell(Context context, WebpageAdapter webpageAdapter) {
            super(context);
            this.parentAdapter = webpageAdapter;
            RadialProgress2 radialProgress2 = new RadialProgress2(this);
            this.radialProgress = radialProgress2;
            radialProgress2.setBackgroundStroke(AndroidUtilities.dp(3.0f));
            this.radialProgress.setCircleRadius(AndroidUtilities.dp(24.0f));
            this.TAG = DownloadController.getInstance(ArticleViewer.this.currentAccount).generateObserverTag();
            SeekBar seekBar2 = new SeekBar(context);
            this.seekBar = seekBar2;
            seekBar2.setDelegate(new SeekBar.SeekBarDelegate() {
                /* class im.guobwnxjuc.ui.$$Lambda$ArticleViewer$BlockAudioCell$brON4NnhCeEjEUL_Sjbu0D8bVwk */

                @Override // im.guobwnxjuc.ui.components.SeekBar.SeekBarDelegate
                public /* synthetic */ void onSeekBarContinuousDrag(float f) {
                    SeekBar.SeekBarDelegate.CC.$default$onSeekBarContinuousDrag(this, f);
                }

                @Override // im.guobwnxjuc.ui.components.SeekBar.SeekBarDelegate
                public final void onSeekBarDrag(float f) {
                    ArticleViewer.BlockAudioCell.this.lambda$new$0$ArticleViewer$BlockAudioCell(f);
                }
            });
        }

        public /* synthetic */ void lambda$new$0$ArticleViewer$BlockAudioCell(float f) {
            MessageObject messageObject = this.currentMessageObject;
            if (messageObject != null) {
                messageObject.audioProgress = f;
                MediaController.getInstance().seekToProgress(this.currentMessageObject, f);
            }
        }

        public void setBlock(TLRPC.TL_pageBlockAudio tL_pageBlockAudio, boolean z, boolean z2) {
            this.currentBlock = tL_pageBlockAudio;
            MessageObject messageObject = (MessageObject) this.parentAdapter.audioBlocks.get(this.currentBlock);
            this.currentMessageObject = messageObject;
            this.currentDocument = messageObject.getDocument();
            this.isFirst = z;
            this.isLast = z2;
            this.radialProgress.setProgressColor(ArticleViewer.this.getTextColor());
            this.seekBar.setColors(ArticleViewer.this.getTextColor() & 1073741823, ArticleViewer.this.getTextColor() & 1073741823, ArticleViewer.this.getTextColor(), ArticleViewer.this.getTextColor(), ArticleViewer.this.getTextColor());
            updateButtonState(false);
            requestLayout();
        }

        public MessageObject getMessageObject() {
            return this.currentMessageObject;
        }

        /* JADX WARNING: Code restructure failed: missing block: B:18:0x0064, code lost:
            if (r1 <= ((float) (r0 + im.guobwnxjuc.messenger.AndroidUtilities.dp(48.0f)))) goto L_0x006a;
         */
        /* JADX WARNING: Code restructure failed: missing block: B:20:0x0068, code lost:
            if (r11.buttonState == 0) goto L_0x006a;
         */
        /* JADX WARNING: Code restructure failed: missing block: B:21:0x006a, code lost:
            r11.buttonPressed = 1;
            invalidate();
         */
        public boolean onTouchEvent(MotionEvent motionEvent) {
            float x = motionEvent.getX();
            float y = motionEvent.getY();
            if (this.seekBar.onTouch(motionEvent.getAction(), motionEvent.getX() - ((float) this.seekBarX), motionEvent.getY() - ((float) this.seekBarY))) {
                if (motionEvent.getAction() == 0) {
                    getParent().requestDisallowInterceptTouchEvent(true);
                }
                invalidate();
                return true;
            }
            if (motionEvent.getAction() == 0) {
                if (this.buttonState != -1) {
                    int i = this.buttonX;
                    if (x >= ((float) i) && x <= ((float) (i + AndroidUtilities.dp(48.0f)))) {
                        int i2 = this.buttonY;
                        if (y >= ((float) i2)) {
                        }
                    }
                }
            } else if (motionEvent.getAction() == 1) {
                if (this.buttonPressed == 1) {
                    this.buttonPressed = 0;
                    playSoundEffect(0);
                    didPressedButton(true);
                    invalidate();
                }
            } else if (motionEvent.getAction() == 3) {
                this.buttonPressed = 0;
            }
            if (this.buttonPressed != 0 || ArticleViewer.this.checkLayoutForLinks(motionEvent, this, this.captionLayout, this.textX, this.textY) || ArticleViewer.this.checkLayoutForLinks(motionEvent, this, this.creditLayout, this.textX, this.textY + this.creditOffset) || super.onTouchEvent(motionEvent)) {
                return true;
            }
            return false;
        }

        /* access modifiers changed from: protected */
        public void onMeasure(int i, int i2) {
            SpannableStringBuilder spannableStringBuilder;
            int size = View.MeasureSpec.getSize(i);
            int dp = AndroidUtilities.dp(54.0f);
            TLRPC.TL_pageBlockAudio tL_pageBlockAudio = this.currentBlock;
            int i3 = 1;
            if (tL_pageBlockAudio != null) {
                if (tL_pageBlockAudio.level > 0) {
                    this.textX = AndroidUtilities.dp((float) (this.currentBlock.level * 14)) + AndroidUtilities.dp(18.0f);
                } else {
                    this.textX = AndroidUtilities.dp(18.0f);
                }
                int dp2 = (size - this.textX) - AndroidUtilities.dp(18.0f);
                int dp3 = AndroidUtilities.dp(44.0f);
                this.buttonX = AndroidUtilities.dp(16.0f);
                int dp4 = AndroidUtilities.dp(5.0f);
                this.buttonY = dp4;
                RadialProgress2 radialProgress2 = this.radialProgress;
                int i4 = this.buttonX;
                radialProgress2.setProgressRect(i4, dp4, i4 + dp3, dp4 + dp3);
                DrawingText createLayoutForText = ArticleViewer.this.createLayoutForText(this, null, this.currentBlock.caption.text, dp2, this.currentBlock, this.parentAdapter);
                this.captionLayout = createLayoutForText;
                if (createLayoutForText != null) {
                    int dp5 = AndroidUtilities.dp(4.0f) + this.captionLayout.getHeight();
                    this.creditOffset = dp5;
                    dp += dp5 + AndroidUtilities.dp(4.0f);
                }
                int i5 = dp;
                DrawingText createLayoutForText2 = ArticleViewer.this.createLayoutForText((ArticleViewer) this, (View) null, (CharSequence) this.currentBlock.caption.credit, (TLRPC.RichText) dp2, (int) this.currentBlock, (TLRPC.PageBlock) (ArticleViewer.this.isRtl ? StaticLayoutEx.ALIGN_RIGHT() : Layout.Alignment.ALIGN_NORMAL), (Layout.Alignment) this.parentAdapter);
                this.creditLayout = createLayoutForText2;
                if (createLayoutForText2 != null) {
                    i5 += AndroidUtilities.dp(4.0f) + this.creditLayout.getHeight();
                }
                if (!this.isFirst && this.currentBlock.level <= 0) {
                    i5 += AndroidUtilities.dp(8.0f);
                }
                String musicAuthor = this.currentMessageObject.getMusicAuthor(false);
                String musicTitle = this.currentMessageObject.getMusicTitle(false);
                int dp6 = this.buttonX + AndroidUtilities.dp(50.0f) + dp3;
                this.seekBarX = dp6;
                int dp7 = (size - dp6) - AndroidUtilities.dp(18.0f);
                if (!TextUtils.isEmpty(musicTitle) || !TextUtils.isEmpty(musicAuthor)) {
                    if (!TextUtils.isEmpty(musicTitle) && !TextUtils.isEmpty(musicAuthor)) {
                        spannableStringBuilder = new SpannableStringBuilder(String.format("%s - %s", musicAuthor, musicTitle));
                    } else if (!TextUtils.isEmpty(musicTitle)) {
                        spannableStringBuilder = new SpannableStringBuilder(musicTitle);
                    } else {
                        spannableStringBuilder = new SpannableStringBuilder(musicAuthor);
                    }
                    if (!TextUtils.isEmpty(musicAuthor)) {
                        spannableStringBuilder.setSpan(new TypefaceSpan(AndroidUtilities.getTypeface("fonts/rmedium.ttf")), 0, musicAuthor.length(), 18);
                    }
                    this.titleLayout = new StaticLayout(TextUtils.ellipsize(spannableStringBuilder, Theme.chat_audioTitlePaint, (float) dp7, TextUtils.TruncateAt.END), ArticleViewer.audioTimePaint, dp7, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
                    this.seekBarY = this.buttonY + ((dp3 - AndroidUtilities.dp(30.0f)) / 2) + AndroidUtilities.dp(11.0f);
                } else {
                    this.titleLayout = null;
                    this.seekBarY = this.buttonY + ((dp3 - AndroidUtilities.dp(30.0f)) / 2);
                }
                this.seekBar.setSize(dp7, AndroidUtilities.dp(30.0f));
                i3 = i5;
            }
            setMeasuredDimension(size, i3);
            updatePlayingMessageProgress();
        }

        /* access modifiers changed from: protected */
        public void onDraw(Canvas canvas) {
            if (this.currentBlock != null) {
                this.radialProgress.setColors(ArticleViewer.this.getTextColor(), ArticleViewer.this.getTextColor(), ArticleViewer.this.getTextColor(), ArticleViewer.this.getTextColor());
                this.radialProgress.draw(canvas);
                canvas.save();
                canvas.translate((float) this.seekBarX, (float) this.seekBarY);
                this.seekBar.draw(canvas);
                canvas.restore();
                if (this.durationLayout != null) {
                    canvas.save();
                    canvas.translate((float) (this.buttonX + AndroidUtilities.dp(54.0f)), (float) (this.seekBarY + AndroidUtilities.dp(6.0f)));
                    this.durationLayout.draw(canvas);
                    canvas.restore();
                }
                if (this.titleLayout != null) {
                    canvas.save();
                    canvas.translate((float) (this.buttonX + AndroidUtilities.dp(54.0f)), (float) (this.seekBarY - AndroidUtilities.dp(16.0f)));
                    this.titleLayout.draw(canvas);
                    canvas.restore();
                }
                if (this.captionLayout != null) {
                    canvas.save();
                    canvas.translate((float) this.textX, (float) this.textY);
                    this.captionLayout.draw(canvas);
                    canvas.restore();
                }
                if (this.creditLayout != null) {
                    canvas.save();
                    canvas.translate((float) this.textX, (float) (this.textY + this.creditOffset));
                    this.creditLayout.draw(canvas);
                    canvas.restore();
                }
                if (this.currentBlock.level > 0) {
                    canvas.drawRect((float) AndroidUtilities.dp(18.0f), 0.0f, (float) AndroidUtilities.dp(20.0f), (float) (getMeasuredHeight() - (this.currentBlock.bottom ? AndroidUtilities.dp(6.0f) : 0)), ArticleViewer.quoteLinePaint);
                }
            }
        }

        private int getIconForCurrentState() {
            int i = this.buttonState;
            if (i == 1) {
                return 1;
            }
            if (i == 2) {
                return 2;
            }
            return i == 3 ? 3 : 0;
        }

        public void updatePlayingMessageProgress() {
            int i;
            if (this.currentDocument != null && this.currentMessageObject != null) {
                if (!this.seekBar.isDragging()) {
                    this.seekBar.setProgress(this.currentMessageObject.audioProgress);
                }
                if (!MediaController.getInstance().isPlayingMessage(this.currentMessageObject)) {
                    int i2 = 0;
                    while (true) {
                        if (i2 >= this.currentDocument.attributes.size()) {
                            i = 0;
                            break;
                        }
                        TLRPC.DocumentAttribute documentAttribute = this.currentDocument.attributes.get(i2);
                        if (documentAttribute instanceof TLRPC.TL_documentAttributeAudio) {
                            i = documentAttribute.duration;
                            break;
                        }
                        i2++;
                    }
                } else {
                    i = this.currentMessageObject.audioProgressSec;
                }
                String format = String.format("%d:%02d", Integer.valueOf(i / 60), Integer.valueOf(i % 60));
                String str = this.lastTimeString;
                if (str == null || (str != null && !str.equals(format))) {
                    this.lastTimeString = format;
                    ArticleViewer.audioTimePaint.setTextSize((float) AndroidUtilities.dp(16.0f));
                    this.durationLayout = new StaticLayout(format, ArticleViewer.audioTimePaint, (int) Math.ceil((double) ArticleViewer.audioTimePaint.measureText(format)), Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
                }
                ArticleViewer.audioTimePaint.setColor(ArticleViewer.this.getTextColor());
                invalidate();
            }
        }

        public void updateButtonState(boolean z) {
            String attachFileName = FileLoader.getAttachFileName(this.currentDocument);
            boolean exists = FileLoader.getPathToAttach(this.currentDocument, true).exists();
            if (TextUtils.isEmpty(attachFileName)) {
                this.radialProgress.setIcon(4, false, false);
                return;
            }
            if (exists) {
                DownloadController.getInstance(ArticleViewer.this.currentAccount).removeLoadingFileObserver(this);
                boolean isPlayingMessage = MediaController.getInstance().isPlayingMessage(this.currentMessageObject);
                if (!isPlayingMessage || (isPlayingMessage && MediaController.getInstance().isMessagePaused())) {
                    this.buttonState = 0;
                } else {
                    this.buttonState = 1;
                }
                this.radialProgress.setIcon(getIconForCurrentState(), false, z);
            } else {
                DownloadController.getInstance(ArticleViewer.this.currentAccount).addLoadingFileObserver(attachFileName, null, this);
                if (!FileLoader.getInstance(ArticleViewer.this.currentAccount).isLoadingFile(attachFileName)) {
                    this.buttonState = 2;
                    this.radialProgress.setProgress(0.0f, z);
                    this.radialProgress.setIcon(getIconForCurrentState(), false, z);
                } else {
                    this.buttonState = 3;
                    Float fileProgress = ImageLoader.getInstance().getFileProgress(attachFileName);
                    if (fileProgress != null) {
                        this.radialProgress.setProgress(fileProgress.floatValue(), z);
                    } else {
                        this.radialProgress.setProgress(0.0f, z);
                    }
                    this.radialProgress.setIcon(getIconForCurrentState(), true, z);
                }
            }
            updatePlayingMessageProgress();
        }

        private void didPressedButton(boolean z) {
            int i = this.buttonState;
            if (i == 0) {
                if (MediaController.getInstance().setPlaylist(this.parentAdapter.audioMessages, this.currentMessageObject, false)) {
                    this.buttonState = 1;
                    this.radialProgress.setIcon(getIconForCurrentState(), false, z);
                    invalidate();
                }
            } else if (i == 1) {
                if (MediaController.getInstance().lambda$startAudioAgain$5$MediaController(this.currentMessageObject)) {
                    this.buttonState = 0;
                    this.radialProgress.setIcon(getIconForCurrentState(), false, z);
                    invalidate();
                }
            } else if (i == 2) {
                this.radialProgress.setProgress(0.0f, false);
                FileLoader.getInstance(ArticleViewer.this.currentAccount).loadFile(this.currentDocument, ArticleViewer.this.currentPage, 1, 1);
                this.buttonState = 3;
                this.radialProgress.setIcon(getIconForCurrentState(), true, z);
                invalidate();
            } else if (i == 3) {
                FileLoader.getInstance(ArticleViewer.this.currentAccount).cancelLoadFile(this.currentDocument);
                this.buttonState = 2;
                this.radialProgress.setIcon(getIconForCurrentState(), false, z);
                invalidate();
            }
        }

        /* access modifiers changed from: protected */
        public void onDetachedFromWindow() {
            super.onDetachedFromWindow();
            DownloadController.getInstance(ArticleViewer.this.currentAccount).removeLoadingFileObserver(this);
        }

        /* access modifiers changed from: protected */
        public void onAttachedToWindow() {
            super.onAttachedToWindow();
            updateButtonState(false);
        }

        @Override // im.guobwnxjuc.messenger.DownloadController.FileDownloadProgressListener
        public void onFailedDownload(String str, boolean z) {
            updateButtonState(true);
        }

        @Override // im.guobwnxjuc.messenger.DownloadController.FileDownloadProgressListener
        public void onSuccessDownload(String str) {
            this.radialProgress.setProgress(1.0f, true);
            updateButtonState(true);
        }

        @Override // im.guobwnxjuc.messenger.DownloadController.FileDownloadProgressListener
        public void onProgressDownload(String str, float f) {
            this.radialProgress.setProgress(f, true);
            if (this.buttonState != 3) {
                updateButtonState(true);
            }
        }

        @Override // im.guobwnxjuc.messenger.DownloadController.FileDownloadProgressListener
        public int getObserverTag() {
            return this.TAG;
        }
    }

    /* access modifiers changed from: private */
    public class BlockEmbedPostCell extends View {
        private AvatarDrawable avatarDrawable = new AvatarDrawable();
        private ImageReceiver avatarImageView;
        private boolean avatarVisible;
        private DrawingText captionLayout;
        private DrawingText creditLayout;
        private int creditOffset;
        private TLRPC.TL_pageBlockEmbedPost currentBlock;
        private DrawingText dateLayout;
        private int dateX;
        private int lineHeight;
        private DrawingText nameLayout;
        private int nameX;
        private WebpageAdapter parentAdapter;
        private int textX;
        private int textY;

        public BlockEmbedPostCell(Context context, WebpageAdapter webpageAdapter) {
            super(context);
            this.parentAdapter = webpageAdapter;
            ImageReceiver imageReceiver = new ImageReceiver(this);
            this.avatarImageView = imageReceiver;
            imageReceiver.setRoundRadius(AndroidUtilities.dp(20.0f));
            this.avatarImageView.setImageCoords(AndroidUtilities.dp(32.0f), AndroidUtilities.dp(8.0f), AndroidUtilities.dp(40.0f), AndroidUtilities.dp(40.0f));
        }

        public void setBlock(TLRPC.TL_pageBlockEmbedPost tL_pageBlockEmbedPost) {
            this.currentBlock = tL_pageBlockEmbedPost;
            requestLayout();
        }

        public boolean onTouchEvent(MotionEvent motionEvent) {
            return ArticleViewer.this.checkLayoutForLinks(motionEvent, this, this.captionLayout, this.textX, this.textY) || ArticleViewer.this.checkLayoutForLinks(motionEvent, this, this.creditLayout, this.textX, this.textY + this.creditOffset) || super.onTouchEvent(motionEvent);
        }

        /* access modifiers changed from: protected */
        public void onMeasure(int i, int i2) {
            int size = View.MeasureSpec.getSize(i);
            TLRPC.TL_pageBlockEmbedPost tL_pageBlockEmbedPost = this.currentBlock;
            int i3 = 1;
            if (tL_pageBlockEmbedPost != null) {
                int i4 = 0;
                if (tL_pageBlockEmbedPost instanceof TL_pageBlockEmbedPostCaption) {
                    int dp = size - AndroidUtilities.dp(50.0f);
                    DrawingText createLayoutForText = ArticleViewer.this.createLayoutForText(this, null, this.currentBlock.caption.text, dp, this.currentBlock, this.parentAdapter);
                    this.captionLayout = createLayoutForText;
                    if (createLayoutForText != null) {
                        int dp2 = AndroidUtilities.dp(4.0f) + this.captionLayout.getHeight();
                        this.creditOffset = dp2;
                        i4 = 0 + dp2 + AndroidUtilities.dp(4.0f);
                    }
                    DrawingText createLayoutForText2 = ArticleViewer.this.createLayoutForText((ArticleViewer) this, (View) null, (CharSequence) this.currentBlock.caption.credit, (TLRPC.RichText) dp, (int) this.currentBlock, (TLRPC.PageBlock) (ArticleViewer.this.isRtl ? StaticLayoutEx.ALIGN_RIGHT() : Layout.Alignment.ALIGN_NORMAL), (Layout.Alignment) this.parentAdapter);
                    this.creditLayout = createLayoutForText2;
                    if (createLayoutForText2 != null) {
                        i4 += AndroidUtilities.dp(4.0f) + this.creditLayout.getHeight();
                    }
                    this.textX = AndroidUtilities.dp(18.0f);
                    this.textY = AndroidUtilities.dp(4.0f);
                    i3 = i4;
                } else {
                    boolean z = tL_pageBlockEmbedPost.author_photo_id != 0;
                    this.avatarVisible = z;
                    if (z) {
                        TLRPC.Photo photoWithId = ArticleViewer.this.getPhotoWithId(this.currentBlock.author_photo_id);
                        boolean z2 = photoWithId instanceof TLRPC.TL_photo;
                        this.avatarVisible = z2;
                        if (z2) {
                            this.avatarDrawable.setInfo(0, this.currentBlock.author, null);
                            this.avatarImageView.setImage(ImageLocation.getForPhoto(FileLoader.getClosestPhotoSizeWithSize(photoWithId.sizes, AndroidUtilities.dp(40.0f), true), photoWithId), "40_40", this.avatarDrawable, 0, (String) null, ArticleViewer.this.currentPage, 1);
                        }
                    }
                    this.nameLayout = ArticleViewer.this.createLayoutForText(this, this.currentBlock.author, null, size - AndroidUtilities.dp((float) ((this.avatarVisible ? 54 : 0) + 50)), 0, this.currentBlock, Layout.Alignment.ALIGN_NORMAL, 1, this.parentAdapter);
                    if (this.currentBlock.date != 0) {
                        ArticleViewer articleViewer = ArticleViewer.this;
                        String format = LocaleController.getInstance().chatFullDate.format(((long) this.currentBlock.date) * 1000);
                        if (this.avatarVisible) {
                            i4 = 54;
                        }
                        this.dateLayout = articleViewer.createLayoutForText(this, format, null, size - AndroidUtilities.dp((float) (i4 + 50)), this.currentBlock, this.parentAdapter);
                    } else {
                        this.dateLayout = null;
                    }
                    int dp3 = AndroidUtilities.dp(56.0f);
                    if (this.currentBlock.blocks.isEmpty()) {
                        int dp4 = size - AndroidUtilities.dp(50.0f);
                        DrawingText createLayoutForText3 = ArticleViewer.this.createLayoutForText(this, null, this.currentBlock.caption.text, dp4, this.currentBlock, this.parentAdapter);
                        this.captionLayout = createLayoutForText3;
                        if (createLayoutForText3 != null) {
                            int dp5 = AndroidUtilities.dp(4.0f) + this.captionLayout.getHeight();
                            this.creditOffset = dp5;
                            dp3 += dp5 + AndroidUtilities.dp(4.0f);
                        }
                        int i5 = dp3;
                        DrawingText createLayoutForText4 = ArticleViewer.this.createLayoutForText((ArticleViewer) this, (View) null, (CharSequence) this.currentBlock.caption.credit, (TLRPC.RichText) dp4, (int) this.currentBlock, (TLRPC.PageBlock) (ArticleViewer.this.isRtl ? StaticLayoutEx.ALIGN_RIGHT() : Layout.Alignment.ALIGN_NORMAL), (Layout.Alignment) this.parentAdapter);
                        this.creditLayout = createLayoutForText4;
                        if (createLayoutForText4 != null) {
                            i5 += AndroidUtilities.dp(4.0f) + this.creditLayout.getHeight();
                        }
                        this.textX = AndroidUtilities.dp(32.0f);
                        this.textY = AndroidUtilities.dp(56.0f);
                        i3 = i5;
                    } else {
                        this.captionLayout = null;
                        this.creditLayout = null;
                        i3 = dp3;
                    }
                }
                this.lineHeight = i3;
            }
            setMeasuredDimension(size, i3);
        }

        /* access modifiers changed from: protected */
        public void onDraw(Canvas canvas) {
            TLRPC.TL_pageBlockEmbedPost tL_pageBlockEmbedPost = this.currentBlock;
            if (tL_pageBlockEmbedPost != null) {
                if (!(tL_pageBlockEmbedPost instanceof TL_pageBlockEmbedPostCaption)) {
                    if (this.avatarVisible) {
                        this.avatarImageView.draw(canvas);
                    }
                    int i = 54;
                    int i2 = 0;
                    if (this.nameLayout != null) {
                        canvas.save();
                        canvas.translate((float) AndroidUtilities.dp((float) ((this.avatarVisible ? 54 : 0) + 32)), (float) AndroidUtilities.dp(this.dateLayout != null ? 10.0f : 19.0f));
                        this.nameLayout.draw(canvas);
                        canvas.restore();
                    }
                    if (this.dateLayout != null) {
                        canvas.save();
                        if (!this.avatarVisible) {
                            i = 0;
                        }
                        canvas.translate((float) AndroidUtilities.dp((float) (i + 32)), (float) AndroidUtilities.dp(29.0f));
                        this.dateLayout.draw(canvas);
                        canvas.restore();
                    }
                    float dp = (float) AndroidUtilities.dp(18.0f);
                    float dp2 = (float) AndroidUtilities.dp(6.0f);
                    float dp3 = (float) AndroidUtilities.dp(20.0f);
                    int i3 = this.lineHeight;
                    if (this.currentBlock.level == 0) {
                        i2 = AndroidUtilities.dp(6.0f);
                    }
                    canvas.drawRect(dp, dp2, dp3, (float) (i3 - i2), ArticleViewer.quoteLinePaint);
                }
                if (this.captionLayout != null) {
                    canvas.save();
                    canvas.translate((float) this.textX, (float) this.textY);
                    this.captionLayout.draw(canvas);
                    canvas.restore();
                }
                if (this.creditLayout != null) {
                    canvas.save();
                    canvas.translate((float) this.textX, (float) (this.textY + this.creditOffset));
                    this.creditLayout.draw(canvas);
                    canvas.restore();
                }
            }
        }
    }

    /* access modifiers changed from: private */
    public class BlockParagraphCell extends View {
        private TLRPC.TL_pageBlockParagraph currentBlock;
        private WebpageAdapter parentAdapter;
        private DrawingText textLayout;
        private int textX;
        private int textY;

        public BlockParagraphCell(Context context, WebpageAdapter webpageAdapter) {
            super(context);
            this.parentAdapter = webpageAdapter;
        }

        public void setBlock(TLRPC.TL_pageBlockParagraph tL_pageBlockParagraph) {
            this.currentBlock = tL_pageBlockParagraph;
            requestLayout();
        }

        public boolean onTouchEvent(MotionEvent motionEvent) {
            return ArticleViewer.this.checkLayoutForLinks(motionEvent, this, this.textLayout, this.textX, this.textY) || super.onTouchEvent(motionEvent);
        }

        /* access modifiers changed from: protected */
        public void onMeasure(int i, int i2) {
            int i3;
            int size = View.MeasureSpec.getSize(i);
            TLRPC.TL_pageBlockParagraph tL_pageBlockParagraph = this.currentBlock;
            int i4 = 0;
            if (tL_pageBlockParagraph != null) {
                if (tL_pageBlockParagraph.level == 0) {
                    this.textY = AndroidUtilities.dp(8.0f);
                    this.textX = AndroidUtilities.dp(18.0f);
                } else {
                    this.textY = 0;
                    this.textX = AndroidUtilities.dp((float) ((this.currentBlock.level * 14) + 18));
                }
                DrawingText createLayoutForText = ArticleViewer.this.createLayoutForText(this, null, this.currentBlock.text, (size - AndroidUtilities.dp(18.0f)) - this.textX, this.textY, this.currentBlock, ArticleViewer.this.isRtl ? StaticLayoutEx.ALIGN_RIGHT() : Layout.Alignment.ALIGN_NORMAL, 0, this.parentAdapter);
                this.textLayout = createLayoutForText;
                if (createLayoutForText != null) {
                    int height = createLayoutForText.getHeight();
                    if (this.currentBlock.level > 0) {
                        i3 = AndroidUtilities.dp(8.0f);
                    } else {
                        i3 = AndroidUtilities.dp(16.0f);
                    }
                    i4 = i3 + height;
                }
            } else {
                i4 = 1;
            }
            setMeasuredDimension(size, i4);
        }

        /* access modifiers changed from: protected */
        public void onDraw(Canvas canvas) {
            if (this.currentBlock != null) {
                if (this.textLayout != null) {
                    canvas.save();
                    canvas.translate((float) this.textX, (float) this.textY);
                    this.textLayout.draw(canvas);
                    canvas.restore();
                }
                if (this.currentBlock.level > 0) {
                    canvas.drawRect((float) AndroidUtilities.dp(18.0f), 0.0f, (float) AndroidUtilities.dp(20.0f), (float) (getMeasuredHeight() - (this.currentBlock.bottom ? AndroidUtilities.dp(6.0f) : 0)), ArticleViewer.quoteLinePaint);
                }
            }
        }

        public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo accessibilityNodeInfo) {
            super.onInitializeAccessibilityNodeInfo(accessibilityNodeInfo);
            accessibilityNodeInfo.setEnabled(true);
            DrawingText drawingText = this.textLayout;
            if (drawingText != null) {
                accessibilityNodeInfo.setText(drawingText.getText());
            }
        }
    }

    /* access modifiers changed from: private */
    public class BlockEmbedCell extends FrameLayout {
        private DrawingText captionLayout;
        private DrawingText creditLayout;
        private int creditOffset;
        private TLRPC.TL_pageBlockEmbed currentBlock;
        private int exactWebViewHeight;
        private int listX;
        private WebpageAdapter parentAdapter;
        private int textX;
        private int textY;
        private WebPlayerView videoView;
        private boolean wasUserInteraction;
        private TouchyWebView webView;

        /* access modifiers changed from: private */
        public class WebviewProxy {
            private WebviewProxy() {
            }

            @JavascriptInterface
            public void postEvent(String str, String str2) {
                AndroidUtilities.runOnUIThread(new Runnable(str, str2) {
                    /* class im.guobwnxjuc.ui.$$Lambda$ArticleViewer$BlockEmbedCell$WebviewProxy$j_bu7XN3JQlllgMSgburb77HPY */
                    private final /* synthetic */ String f$1;
                    private final /* synthetic */ String f$2;

                    {
                        this.f$1 = r2;
                        this.f$2 = r3;
                    }

                    public final void run() {
                        ArticleViewer.BlockEmbedCell.WebviewProxy.this.lambda$postEvent$0$ArticleViewer$BlockEmbedCell$WebviewProxy(this.f$1, this.f$2);
                    }
                });
            }

            public /* synthetic */ void lambda$postEvent$0$ArticleViewer$BlockEmbedCell$WebviewProxy(String str, String str2) {
                if ("resize_frame".equals(str)) {
                    try {
                        JSONObject jSONObject = new JSONObject(str2);
                        BlockEmbedCell.this.exactWebViewHeight = Utilities.parseInt(jSONObject.getString("height")).intValue();
                        BlockEmbedCell.this.requestLayout();
                    } catch (Throwable unused) {
                    }
                }
            }
        }

        public class TouchyWebView extends WebView {
            public TouchyWebView(Context context) {
                super(context);
                setFocusable(false);
            }

            public boolean onTouchEvent(MotionEvent motionEvent) {
                BlockEmbedCell.this.wasUserInteraction = true;
                if (BlockEmbedCell.this.currentBlock != null) {
                    if (BlockEmbedCell.this.currentBlock.allow_scrolling) {
                        requestDisallowInterceptTouchEvent(true);
                    } else {
                        ArticleViewer.this.windowView.requestDisallowInterceptTouchEvent(true);
                    }
                }
                return super.onTouchEvent(motionEvent);
            }
        }

        public BlockEmbedCell(Context context, WebpageAdapter webpageAdapter) {
            super(context);
            this.parentAdapter = webpageAdapter;
            setWillNotDraw(false);
            WebPlayerView webPlayerView = new WebPlayerView(context, false, false, new WebPlayerView.WebPlayerViewDelegate(ArticleViewer.this) {
                /* class im.guobwnxjuc.ui.ArticleViewer.BlockEmbedCell.AnonymousClass1 */

                @Override // im.guobwnxjuc.ui.components.WebPlayerView.WebPlayerViewDelegate
                public boolean checkInlinePermissions() {
                    return false;
                }

                @Override // im.guobwnxjuc.ui.components.WebPlayerView.WebPlayerViewDelegate
                public ViewGroup getTextureViewContainer() {
                    return null;
                }

                @Override // im.guobwnxjuc.ui.components.WebPlayerView.WebPlayerViewDelegate
                public void onInlineSurfaceTextureReady() {
                }

                @Override // im.guobwnxjuc.ui.components.WebPlayerView.WebPlayerViewDelegate
                public TextureView onSwitchInlineMode(View view, boolean z, float f, int i, boolean z2) {
                    return null;
                }

                @Override // im.guobwnxjuc.ui.components.WebPlayerView.WebPlayerViewDelegate
                public void prepareToSwitchInlineMode(boolean z, Runnable runnable, float f, boolean z2) {
                }

                @Override // im.guobwnxjuc.ui.components.WebPlayerView.WebPlayerViewDelegate
                public void onInitFailed() {
                    BlockEmbedCell.this.webView.setVisibility(0);
                    BlockEmbedCell.this.videoView.setVisibility(4);
                    BlockEmbedCell.this.videoView.loadVideo(null, null, null, null, false);
                    HashMap hashMap = new HashMap();
                    hashMap.put("Referer", "http://youtube.com");
                    BlockEmbedCell.this.webView.loadUrl(BlockEmbedCell.this.currentBlock.url, hashMap);
                }

                @Override // im.guobwnxjuc.ui.components.WebPlayerView.WebPlayerViewDelegate
                public void onVideoSizeChanged(float f, int i) {
                    ArticleViewer.this.fullscreenAspectRatioView.setAspectRatio(f, i);
                }

                @Override // im.guobwnxjuc.ui.components.WebPlayerView.WebPlayerViewDelegate
                public TextureView onSwitchToFullscreen(View view, boolean z, float f, int i, boolean z2) {
                    if (z) {
                        ArticleViewer.this.fullscreenAspectRatioView.addView(ArticleViewer.this.fullscreenTextureView, LayoutHelper.createFrame(-1, -1.0f));
                        ArticleViewer.this.fullscreenAspectRatioView.setVisibility(0);
                        ArticleViewer.this.fullscreenAspectRatioView.setAspectRatio(f, i);
                        ArticleViewer.this.fullscreenedVideo = BlockEmbedCell.this.videoView;
                        ArticleViewer.this.fullscreenVideoContainer.addView(view, LayoutHelper.createFrame(-1, -1.0f));
                        ArticleViewer.this.fullscreenVideoContainer.setVisibility(0);
                    } else {
                        ArticleViewer.this.fullscreenAspectRatioView.removeView(ArticleViewer.this.fullscreenTextureView);
                        ArticleViewer.this.fullscreenedVideo = null;
                        ArticleViewer.this.fullscreenAspectRatioView.setVisibility(8);
                        ArticleViewer.this.fullscreenVideoContainer.setVisibility(4);
                    }
                    return ArticleViewer.this.fullscreenTextureView;
                }

                @Override // im.guobwnxjuc.ui.components.WebPlayerView.WebPlayerViewDelegate
                public void onSharePressed() {
                    if (ArticleViewer.this.parentActivity != null) {
                        ArticleViewer.this.showDialog(new ShareAlert(ArticleViewer.this.parentActivity, null, BlockEmbedCell.this.currentBlock.url, false, BlockEmbedCell.this.currentBlock.url, true));
                    }
                }

                @Override // im.guobwnxjuc.ui.components.WebPlayerView.WebPlayerViewDelegate
                public void onPlayStateChanged(WebPlayerView webPlayerView, boolean z) {
                    if (z) {
                        if (!(ArticleViewer.this.currentPlayingVideo == null || ArticleViewer.this.currentPlayingVideo == webPlayerView)) {
                            ArticleViewer.this.currentPlayingVideo.pause();
                        }
                        ArticleViewer.this.currentPlayingVideo = webPlayerView;
                        try {
                            ArticleViewer.this.parentActivity.getWindow().addFlags(128);
                        } catch (Exception e) {
                            FileLog.e(e);
                        }
                    } else {
                        if (ArticleViewer.this.currentPlayingVideo == webPlayerView) {
                            ArticleViewer.this.currentPlayingVideo = null;
                        }
                        try {
                            ArticleViewer.this.parentActivity.getWindow().clearFlags(128);
                        } catch (Exception e2) {
                            FileLog.e(e2);
                        }
                    }
                }
            });
            this.videoView = webPlayerView;
            addView(webPlayerView);
            ArticleViewer.this.createdWebViews.add(this);
            TouchyWebView touchyWebView = new TouchyWebView(context);
            this.webView = touchyWebView;
            touchyWebView.getSettings().setJavaScriptEnabled(true);
            this.webView.getSettings().setDomStorageEnabled(true);
            this.webView.getSettings().setAllowContentAccess(true);
            if (Build.VERSION.SDK_INT >= 17) {
                this.webView.getSettings().setMediaPlaybackRequiresUserGesture(false);
                this.webView.addJavascriptInterface(new WebviewProxy(), "WebviewProxy");
            }
            if (Build.VERSION.SDK_INT >= 21) {
                this.webView.getSettings().setMixedContentMode(0);
                CookieManager.getInstance().setAcceptThirdPartyCookies(this.webView, true);
            }
            this.webView.setWebChromeClient(new WebChromeClient(ArticleViewer.this) {
                /* class im.guobwnxjuc.ui.ArticleViewer.BlockEmbedCell.AnonymousClass2 */

                public void onShowCustomView(View view, int i, WebChromeClient.CustomViewCallback customViewCallback) {
                    onShowCustomView(view, customViewCallback);
                }

                public void onShowCustomView(View view, WebChromeClient.CustomViewCallback customViewCallback) {
                    if (ArticleViewer.this.customView != null) {
                        customViewCallback.onCustomViewHidden();
                        return;
                    }
                    ArticleViewer.this.customView = view;
                    ArticleViewer.this.customViewCallback = customViewCallback;
                    AndroidUtilities.runOnUIThread(new Runnable() {
                        /* class im.guobwnxjuc.ui.$$Lambda$ArticleViewer$BlockEmbedCell$2$zK8n1qJn63dHkfevSNtWD9ailc */

                        public final void run() {
                            ArticleViewer.BlockEmbedCell.AnonymousClass2.this.lambda$onShowCustomView$0$ArticleViewer$BlockEmbedCell$2();
                        }
                    }, 100);
                }

                public /* synthetic */ void lambda$onShowCustomView$0$ArticleViewer$BlockEmbedCell$2() {
                    if (ArticleViewer.this.customView != null) {
                        ArticleViewer.this.fullscreenVideoContainer.addView(ArticleViewer.this.customView, LayoutHelper.createFrame(-1, -1.0f));
                        ArticleViewer.this.fullscreenVideoContainer.setVisibility(0);
                    }
                }

                public void onHideCustomView() {
                    super.onHideCustomView();
                    if (ArticleViewer.this.customView != null) {
                        ArticleViewer.this.fullscreenVideoContainer.setVisibility(4);
                        ArticleViewer.this.fullscreenVideoContainer.removeView(ArticleViewer.this.customView);
                        if (ArticleViewer.this.customViewCallback != null && !ArticleViewer.this.customViewCallback.getClass().getName().contains(".chromium.")) {
                            ArticleViewer.this.customViewCallback.onCustomViewHidden();
                        }
                        ArticleViewer.this.customView = null;
                    }
                }
            });
            this.webView.setWebViewClient(new WebViewClient(ArticleViewer.this) {
                /* class im.guobwnxjuc.ui.ArticleViewer.BlockEmbedCell.AnonymousClass3 */

                public void onLoadResource(WebView webView, String str) {
                    super.onLoadResource(webView, str);
                }

                public void onPageFinished(WebView webView, String str) {
                    super.onPageFinished(webView, str);
                }

                @Override // android.webkit.WebViewClient
                public boolean shouldOverrideUrlLoading(WebView webView, String str) {
                    if (!BlockEmbedCell.this.wasUserInteraction) {
                        return false;
                    }
                    Browser.openUrl(ArticleViewer.this.parentActivity, str);
                    return true;
                }
            });
            addView(this.webView);
        }

        public void destroyWebView(boolean z) {
            try {
                this.webView.stopLoading();
                this.webView.loadUrl("about:blank");
                if (z) {
                    this.webView.destroy();
                }
                this.currentBlock = null;
            } catch (Exception e) {
                FileLog.e(e);
            }
            this.videoView.destroy();
        }

        public void setBlock(TLRPC.TL_pageBlockEmbed tL_pageBlockEmbed) {
            TLRPC.TL_pageBlockEmbed tL_pageBlockEmbed2 = this.currentBlock;
            this.currentBlock = tL_pageBlockEmbed;
            if (tL_pageBlockEmbed2 != tL_pageBlockEmbed) {
                this.wasUserInteraction = false;
                if (tL_pageBlockEmbed.allow_scrolling) {
                    this.webView.setVerticalScrollBarEnabled(true);
                    this.webView.setHorizontalScrollBarEnabled(true);
                } else {
                    this.webView.setVerticalScrollBarEnabled(false);
                    this.webView.setHorizontalScrollBarEnabled(false);
                }
                this.exactWebViewHeight = 0;
                try {
                    this.webView.loadUrl("about:blank");
                } catch (Exception e) {
                    FileLog.e(e);
                }
                try {
                    if (this.currentBlock.html != null) {
                        this.webView.loadDataWithBaseURL("https://m12345.cc/embed", this.currentBlock.html, "text/html", "UTF-8", null);
                        this.videoView.setVisibility(4);
                        this.videoView.loadVideo(null, null, null, null, false);
                        this.webView.setVisibility(0);
                    } else {
                        if (this.videoView.loadVideo(tL_pageBlockEmbed.url, this.currentBlock.poster_photo_id != 0 ? ArticleViewer.this.getPhotoWithId(this.currentBlock.poster_photo_id) : null, ArticleViewer.this.currentPage, null, false)) {
                            this.webView.setVisibility(4);
                            this.videoView.setVisibility(0);
                            this.webView.stopLoading();
                            this.webView.loadUrl("about:blank");
                        } else {
                            this.webView.setVisibility(0);
                            this.videoView.setVisibility(4);
                            this.videoView.loadVideo(null, null, null, null, false);
                            HashMap hashMap = new HashMap();
                            hashMap.put("Referer", "http://youtube.com");
                            this.webView.loadUrl(this.currentBlock.url, hashMap);
                        }
                    }
                } catch (Exception e2) {
                    FileLog.e(e2);
                }
            }
            requestLayout();
        }

        /* access modifiers changed from: protected */
        public void onDetachedFromWindow() {
            super.onDetachedFromWindow();
            if (!ArticleViewer.this.isVisible) {
                this.currentBlock = null;
            }
        }

        /* access modifiers changed from: protected */
        public void onAttachedToWindow() {
            super.onAttachedToWindow();
        }

        public boolean onTouchEvent(MotionEvent motionEvent) {
            return ArticleViewer.this.checkLayoutForLinks(motionEvent, this, this.captionLayout, this.textX, this.textY) || ArticleViewer.this.checkLayoutForLinks(motionEvent, this, this.creditLayout, this.textX, this.textY + this.creditOffset) || super.onTouchEvent(motionEvent);
        }

        /* access modifiers changed from: protected */
        public void onMeasure(int i, int i2) {
            int i3;
            int i4;
            int i5;
            float f;
            int i6;
            int dp;
            int size = View.MeasureSpec.getSize(i);
            TLRPC.TL_pageBlockEmbed tL_pageBlockEmbed = this.currentBlock;
            if (tL_pageBlockEmbed != null) {
                if (tL_pageBlockEmbed.level > 0) {
                    int dp2 = AndroidUtilities.dp((float) (this.currentBlock.level * 14)) + AndroidUtilities.dp(18.0f);
                    this.listX = dp2;
                    this.textX = dp2;
                    i4 = size - (dp2 + AndroidUtilities.dp(18.0f));
                    i5 = i4;
                } else {
                    this.listX = 0;
                    this.textX = AndroidUtilities.dp(18.0f);
                    int dp3 = size - AndroidUtilities.dp(36.0f);
                    if (!this.currentBlock.full_width) {
                        i4 = size - AndroidUtilities.dp(36.0f);
                        this.listX += AndroidUtilities.dp(18.0f);
                    } else {
                        i4 = size;
                    }
                    i5 = dp3;
                }
                if (this.currentBlock.w == 0) {
                    f = 1.0f;
                } else {
                    f = ((float) size) / ((float) this.currentBlock.w);
                }
                int i7 = this.exactWebViewHeight;
                if (i7 != 0) {
                    i6 = AndroidUtilities.dp((float) i7);
                } else {
                    i6 = (int) (((float) (this.currentBlock.w == 0 ? AndroidUtilities.dp((float) this.currentBlock.h) : this.currentBlock.h)) * f);
                }
                if (i6 == 0) {
                    i6 = AndroidUtilities.dp(10.0f);
                }
                int i8 = i6;
                this.webView.measure(View.MeasureSpec.makeMeasureSpec(i4, 1073741824), View.MeasureSpec.makeMeasureSpec(i8, 1073741824));
                if (this.videoView.getParent() == this) {
                    this.videoView.measure(View.MeasureSpec.makeMeasureSpec(i4, 1073741824), View.MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(10.0f) + i8, 1073741824));
                }
                DrawingText createLayoutForText = ArticleViewer.this.createLayoutForText(this, null, this.currentBlock.caption.text, i5, this.currentBlock, this.parentAdapter);
                this.captionLayout = createLayoutForText;
                if (createLayoutForText != null) {
                    this.textY = AndroidUtilities.dp(8.0f) + i8;
                    int dp4 = AndroidUtilities.dp(4.0f) + this.captionLayout.getHeight();
                    this.creditOffset = dp4;
                    i8 += dp4 + AndroidUtilities.dp(4.0f);
                }
                DrawingText createLayoutForText2 = ArticleViewer.this.createLayoutForText((ArticleViewer) this, (View) null, (CharSequence) this.currentBlock.caption.credit, (TLRPC.RichText) i5, (int) this.currentBlock, (TLRPC.PageBlock) (ArticleViewer.this.isRtl ? StaticLayoutEx.ALIGN_RIGHT() : Layout.Alignment.ALIGN_NORMAL), (Layout.Alignment) this.parentAdapter);
                this.creditLayout = createLayoutForText2;
                if (createLayoutForText2 != null) {
                    i8 += AndroidUtilities.dp(4.0f) + this.creditLayout.getHeight();
                }
                i3 = i8 + AndroidUtilities.dp(5.0f);
                if (this.currentBlock.level > 0 && !this.currentBlock.bottom) {
                    dp = AndroidUtilities.dp(8.0f);
                } else if (this.currentBlock.level == 0 && this.captionLayout != null) {
                    dp = AndroidUtilities.dp(8.0f);
                }
                i3 += dp;
            } else {
                i3 = 1;
            }
            setMeasuredDimension(size, i3);
        }

        /* access modifiers changed from: protected */
        public void onLayout(boolean z, int i, int i2, int i3, int i4) {
            TouchyWebView touchyWebView = this.webView;
            int i5 = this.listX;
            touchyWebView.layout(i5, 0, touchyWebView.getMeasuredWidth() + i5, this.webView.getMeasuredHeight());
            if (this.videoView.getParent() == this) {
                WebPlayerView webPlayerView = this.videoView;
                int i6 = this.listX;
                webPlayerView.layout(i6, 0, webPlayerView.getMeasuredWidth() + i6, this.videoView.getMeasuredHeight());
            }
        }

        /* access modifiers changed from: protected */
        public void onDraw(Canvas canvas) {
            if (this.currentBlock != null) {
                if (this.captionLayout != null) {
                    canvas.save();
                    canvas.translate((float) this.textX, (float) this.textY);
                    this.captionLayout.draw(canvas);
                    canvas.restore();
                }
                if (this.creditLayout != null) {
                    canvas.save();
                    canvas.translate((float) this.textX, (float) (this.textY + this.creditOffset));
                    this.creditLayout.draw(canvas);
                    canvas.restore();
                }
                if (this.currentBlock.level > 0) {
                    canvas.drawRect((float) AndroidUtilities.dp(18.0f), 0.0f, (float) AndroidUtilities.dp(20.0f), (float) (getMeasuredHeight() - (this.currentBlock.bottom ? AndroidUtilities.dp(6.0f) : 0)), ArticleViewer.quoteLinePaint);
                }
            }
        }
    }

    /* access modifiers changed from: private */
    public class BlockTableCell extends FrameLayout implements TableLayout.TableLayoutDelegate {
        private TLRPC.TL_pageBlockTable currentBlock;
        private boolean firstLayout;
        private boolean inLayout;
        private int listX;
        private int listY;
        private WebpageAdapter parentAdapter;
        private HorizontalScrollView scrollView;
        private TableLayout tableLayout;
        private int textX;
        private int textY;
        private DrawingText titleLayout;

        public BlockTableCell(Context context, WebpageAdapter webpageAdapter) {
            super(context);
            this.parentAdapter = webpageAdapter;
            AnonymousClass1 r5 = new HorizontalScrollView(context, ArticleViewer.this) {
                /* class im.guobwnxjuc.ui.ArticleViewer.BlockTableCell.AnonymousClass1 */

                public boolean onInterceptTouchEvent(MotionEvent motionEvent) {
                    if (BlockTableCell.this.tableLayout.getMeasuredWidth() > getMeasuredWidth() - AndroidUtilities.dp(36.0f)) {
                        ArticleViewer.this.windowView.requestDisallowInterceptTouchEvent(true);
                    }
                    return super.onInterceptTouchEvent(motionEvent);
                }

                /* access modifiers changed from: protected */
                public void onScrollChanged(int i, int i2, int i3, int i4) {
                    super.onScrollChanged(i, i2, i3, i4);
                    if (ArticleViewer.this.pressedLinkOwnerLayout != null) {
                        ArticleViewer.this.pressedLinkOwnerLayout = null;
                        ArticleViewer.this.pressedLinkOwnerView = null;
                    }
                }

                /* access modifiers changed from: protected */
                public boolean overScrollBy(int i, int i2, int i3, int i4, int i5, int i6, int i7, int i8, boolean z) {
                    ArticleViewer.this.removePressedLink();
                    return super.overScrollBy(i, i2, i3, i4, i5, i6, i7, i8, z);
                }

                /* access modifiers changed from: protected */
                public void onMeasure(int i, int i2) {
                    BlockTableCell.this.tableLayout.measure(View.MeasureSpec.makeMeasureSpec((View.MeasureSpec.getSize(i) - getPaddingLeft()) - getPaddingRight(), 0), i2);
                    setMeasuredDimension(View.MeasureSpec.getSize(i), BlockTableCell.this.tableLayout.getMeasuredHeight());
                }
            };
            this.scrollView = r5;
            r5.setPadding(AndroidUtilities.dp(18.0f), 0, AndroidUtilities.dp(18.0f), 0);
            this.scrollView.setClipToPadding(false);
            addView(this.scrollView, LayoutHelper.createFrame(-1, -2.0f));
            TableLayout tableLayout2 = new TableLayout(context, this);
            this.tableLayout = tableLayout2;
            tableLayout2.setOrientation(0);
            this.tableLayout.setRowOrderPreserved(true);
            this.scrollView.addView(this.tableLayout, new FrameLayout.LayoutParams(-2, -2));
            setWillNotDraw(false);
        }

        @Override // im.guobwnxjuc.ui.components.TableLayout.TableLayoutDelegate
        public DrawingText createTextLayout(TLRPC.TL_pageTableCell tL_pageTableCell, int i) {
            Layout.Alignment alignment;
            if (tL_pageTableCell == null) {
                return null;
            }
            if (tL_pageTableCell.align_right) {
                alignment = Layout.Alignment.ALIGN_OPPOSITE;
            } else if (tL_pageTableCell.align_center) {
                alignment = Layout.Alignment.ALIGN_CENTER;
            } else {
                alignment = Layout.Alignment.ALIGN_NORMAL;
            }
            return ArticleViewer.this.createLayoutForText(this, null, tL_pageTableCell.text, i, 0, this.currentBlock, alignment, 0, this.parentAdapter);
        }

        @Override // im.guobwnxjuc.ui.components.TableLayout.TableLayoutDelegate
        public Paint getLinePaint() {
            return ArticleViewer.tableLinePaint;
        }

        @Override // im.guobwnxjuc.ui.components.TableLayout.TableLayoutDelegate
        public Paint getHalfLinePaint() {
            return ArticleViewer.tableHalfLinePaint;
        }

        @Override // im.guobwnxjuc.ui.components.TableLayout.TableLayoutDelegate
        public Paint getHeaderPaint() {
            return ArticleViewer.tableHeaderPaint;
        }

        @Override // im.guobwnxjuc.ui.components.TableLayout.TableLayoutDelegate
        public Paint getStripPaint() {
            return ArticleViewer.tableStripPaint;
        }

        public void setBlock(TLRPC.TL_pageBlockTable tL_pageBlockTable) {
            int i;
            this.currentBlock = tL_pageBlockTable;
            int selectedColor = ArticleViewer.this.getSelectedColor();
            if (selectedColor == 0) {
                AndroidUtilities.setScrollViewEdgeEffectColor(this.scrollView, -657673);
            } else if (selectedColor == 1) {
                AndroidUtilities.setScrollViewEdgeEffectColor(this.scrollView, -659492);
            } else if (selectedColor == 2) {
                AndroidUtilities.setScrollViewEdgeEffectColor(this.scrollView, -15461356);
            }
            this.tableLayout.removeAllChildrens();
            this.tableLayout.setDrawLines(this.currentBlock.bordered);
            this.tableLayout.setStriped(this.currentBlock.striped);
            this.tableLayout.setRtl(ArticleViewer.this.isRtl);
            if (!this.currentBlock.rows.isEmpty()) {
                TLRPC.TL_pageTableRow tL_pageTableRow = this.currentBlock.rows.get(0);
                int size = tL_pageTableRow.cells.size();
                i = 0;
                for (int i2 = 0; i2 < size; i2++) {
                    TLRPC.TL_pageTableCell tL_pageTableCell = tL_pageTableRow.cells.get(i2);
                    i += tL_pageTableCell.colspan != 0 ? tL_pageTableCell.colspan : 1;
                }
            } else {
                i = 0;
            }
            int size2 = this.currentBlock.rows.size();
            for (int i3 = 0; i3 < size2; i3++) {
                TLRPC.TL_pageTableRow tL_pageTableRow2 = this.currentBlock.rows.get(i3);
                int size3 = tL_pageTableRow2.cells.size();
                int i4 = 0;
                for (int i5 = 0; i5 < size3; i5++) {
                    TLRPC.TL_pageTableCell tL_pageTableCell2 = tL_pageTableRow2.cells.get(i5);
                    int i6 = tL_pageTableCell2.colspan != 0 ? tL_pageTableCell2.colspan : 1;
                    int i7 = tL_pageTableCell2.rowspan != 0 ? tL_pageTableCell2.rowspan : 1;
                    if (tL_pageTableCell2.text != null) {
                        this.tableLayout.addChild(tL_pageTableCell2, i4, i3, i6);
                    } else {
                        this.tableLayout.addChild(i4, i3, i6, i7);
                    }
                    i4 += i6;
                }
            }
            this.tableLayout.setColumnCount(i);
            this.firstLayout = true;
            requestLayout();
        }

        public boolean onTouchEvent(MotionEvent motionEvent) {
            int childCount = this.tableLayout.getChildCount();
            for (int i = 0; i < childCount; i++) {
                TableLayout.Child childAt = this.tableLayout.getChildAt(i);
                if (ArticleViewer.this.checkLayoutForLinks(motionEvent, this, childAt.textLayout, (this.scrollView.getPaddingLeft() - this.scrollView.getScrollX()) + this.listX + childAt.getTextX(), this.listY + childAt.getTextY())) {
                    return true;
                }
            }
            if (ArticleViewer.this.checkLayoutForLinks(motionEvent, this, this.titleLayout, this.textX, this.textY) || super.onTouchEvent(motionEvent)) {
                return true;
            }
            return false;
        }

        public void invalidate() {
            super.invalidate();
            this.tableLayout.invalidate();
        }

        /* access modifiers changed from: protected */
        public void onMeasure(int i, int i2) {
            int i3;
            int i4;
            int i5 = 1;
            this.inLayout = true;
            int size = View.MeasureSpec.getSize(i);
            TLRPC.TL_pageBlockTable tL_pageBlockTable = this.currentBlock;
            if (tL_pageBlockTable != null) {
                if (tL_pageBlockTable.level > 0) {
                    int dp = AndroidUtilities.dp((float) (this.currentBlock.level * 14));
                    this.listX = dp;
                    i3 = dp + AndroidUtilities.dp(18.0f);
                    this.textX = i3;
                } else {
                    this.listX = 0;
                    this.textX = AndroidUtilities.dp(18.0f);
                    i3 = AndroidUtilities.dp(36.0f);
                }
                DrawingText createLayoutForText = ArticleViewer.this.createLayoutForText(this, null, this.currentBlock.title, size - i3, 0, this.currentBlock, Layout.Alignment.ALIGN_CENTER, 0, this.parentAdapter);
                this.titleLayout = createLayoutForText;
                if (createLayoutForText != null) {
                    this.textY = 0;
                    i4 = createLayoutForText.getHeight() + AndroidUtilities.dp(8.0f) + 0;
                    this.listY = i4;
                } else {
                    this.listY = AndroidUtilities.dp(8.0f);
                    i4 = 0;
                }
                this.scrollView.measure(View.MeasureSpec.makeMeasureSpec(size - this.listX, 1073741824), View.MeasureSpec.makeMeasureSpec(0, 0));
                i5 = i4 + this.scrollView.getMeasuredHeight() + AndroidUtilities.dp(8.0f);
                if (this.currentBlock.level > 0 && !this.currentBlock.bottom) {
                    i5 += AndroidUtilities.dp(8.0f);
                }
            }
            setMeasuredDimension(size, i5);
            this.inLayout = false;
        }

        /* access modifiers changed from: protected */
        public void onLayout(boolean z, int i, int i2, int i3, int i4) {
            HorizontalScrollView horizontalScrollView = this.scrollView;
            int i5 = this.listX;
            horizontalScrollView.layout(i5, this.listY, horizontalScrollView.getMeasuredWidth() + i5, this.listY + this.scrollView.getMeasuredHeight());
            if (this.firstLayout) {
                if (ArticleViewer.this.isRtl) {
                    this.scrollView.setScrollX((this.tableLayout.getMeasuredWidth() - this.scrollView.getMeasuredWidth()) + AndroidUtilities.dp(36.0f));
                } else {
                    this.scrollView.setScrollX(0);
                }
                this.firstLayout = false;
            }
        }

        /* access modifiers changed from: protected */
        public void onDraw(Canvas canvas) {
            if (this.currentBlock != null) {
                if (this.titleLayout != null) {
                    canvas.save();
                    canvas.translate((float) this.textX, (float) this.textY);
                    this.titleLayout.draw(canvas);
                    canvas.restore();
                }
                if (this.currentBlock.level > 0) {
                    canvas.drawRect((float) AndroidUtilities.dp(18.0f), 0.0f, (float) AndroidUtilities.dp(20.0f), (float) (getMeasuredHeight() - (this.currentBlock.bottom ? AndroidUtilities.dp(6.0f) : 0)), ArticleViewer.quoteLinePaint);
                }
            }
        }
    }

    /* access modifiers changed from: private */
    public class BlockCollageCell extends FrameLayout {
        private DrawingText captionLayout;
        private DrawingText creditLayout;
        private int creditOffset;
        private TLRPC.TL_pageBlockCollage currentBlock;
        private GridLayoutManager gridLayoutManager;
        private GroupedMessages group = new GroupedMessages();
        private boolean inLayout;
        private RecyclerView.Adapter innerAdapter;
        private RecyclerListView innerListView;
        private int listX;
        private WebpageAdapter parentAdapter;
        private int textX;
        private int textY;

        public class GroupedMessages {
            public long groupId;
            public boolean hasSibling;
            private int maxSizeWidth = 1000;
            public ArrayList<MessageObject.GroupedMessagePosition> posArray = new ArrayList<>();
            public HashMap<TLObject, MessageObject.GroupedMessagePosition> positions = new HashMap<>();

            public GroupedMessages() {
            }

            /* access modifiers changed from: private */
            public class MessageGroupedLayoutAttempt {
                public float[] heights;
                public int[] lineCounts;

                public MessageGroupedLayoutAttempt(int i, int i2, float f, float f2) {
                    this.lineCounts = new int[]{i, i2};
                    this.heights = new float[]{f, f2};
                }

                public MessageGroupedLayoutAttempt(int i, int i2, int i3, float f, float f2, float f3) {
                    this.lineCounts = new int[]{i, i2, i3};
                    this.heights = new float[]{f, f2, f3};
                }

                public MessageGroupedLayoutAttempt(int i, int i2, int i3, int i4, float f, float f2, float f3, float f4) {
                    this.lineCounts = new int[]{i, i2, i3, i4};
                    this.heights = new float[]{f, f2, f3, f4};
                }
            }

            private float multiHeight(float[] fArr, int i, int i2) {
                float f = 0.0f;
                while (i < i2) {
                    f += fArr[i];
                    i++;
                }
                return ((float) this.maxSizeWidth) / f;
            }

            public void calculate() {
                int i;
                int i2;
                float f;
                int i3;
                int i4;
                int i5;
                int i6;
                int i7;
                int i8;
                int i9;
                int i10;
                TLRPC.PhotoSize photoSize;
                float f2;
                TLRPC.Document documentWithId;
                this.posArray.clear();
                this.positions.clear();
                int size = BlockCollageCell.this.currentBlock.items.size();
                if (size > 1) {
                    StringBuilder sb = new StringBuilder();
                    this.hasSibling = false;
                    int i11 = 0;
                    float f3 = 1.0f;
                    boolean z = false;
                    while (i11 < size) {
                        TLRPC.PageBlock pageBlock = BlockCollageCell.this.currentBlock.items.get(i11);
                        if (pageBlock instanceof TLRPC.TL_pageBlockPhoto) {
                            TLRPC.Photo photoWithId = ArticleViewer.this.getPhotoWithId(((TLRPC.TL_pageBlockPhoto) pageBlock).photo_id);
                            if (photoWithId == null) {
                                i11++;
                            } else {
                                photoSize = FileLoader.getClosestPhotoSizeWithSize(photoWithId.sizes, AndroidUtilities.getPhotoSize());
                            }
                        } else {
                            if ((pageBlock instanceof TLRPC.TL_pageBlockVideo) && (documentWithId = ArticleViewer.this.getDocumentWithId(((TLRPC.TL_pageBlockVideo) pageBlock).video_id)) != null) {
                                photoSize = FileLoader.getClosestPhotoSizeWithSize(documentWithId.thumbs, 90);
                            }
                            i11++;
                        }
                        MessageObject.GroupedMessagePosition groupedMessagePosition = new MessageObject.GroupedMessagePosition();
                        groupedMessagePosition.last = i11 == size + -1;
                        if (photoSize == null) {
                            f2 = 1.0f;
                        } else {
                            f2 = ((float) photoSize.w) / ((float) photoSize.h);
                        }
                        groupedMessagePosition.aspectRatio = f2;
                        if (groupedMessagePosition.aspectRatio > 1.2f) {
                            sb.append("w");
                        } else if (groupedMessagePosition.aspectRatio < 0.8f) {
                            sb.append("n");
                        } else {
                            sb.append("q");
                        }
                        f3 += groupedMessagePosition.aspectRatio;
                        if (groupedMessagePosition.aspectRatio > 2.0f) {
                            z = true;
                        }
                        this.positions.put(pageBlock, groupedMessagePosition);
                        this.posArray.add(groupedMessagePosition);
                        i11++;
                    }
                    int dp = AndroidUtilities.dp(120.0f);
                    int dp2 = (int) (((float) AndroidUtilities.dp(120.0f)) / (((float) Math.min(AndroidUtilities.displaySize.x, AndroidUtilities.displaySize.y)) / ((float) this.maxSizeWidth)));
                    int i12 = this.maxSizeWidth;
                    int dp3 = (int) (((float) AndroidUtilities.dp(40.0f)) / (((float) Math.min(AndroidUtilities.displaySize.x, AndroidUtilities.displaySize.y)) / ((float) i12)));
                    float f4 = ((float) i12) / 814.0f;
                    float f5 = f3 / ((float) size);
                    int i13 = 3;
                    if (z || !(size == 2 || size == 3 || size == 4)) {
                        int size2 = this.posArray.size();
                        float[] fArr = new float[size2];
                        for (int i14 = 0; i14 < size; i14++) {
                            if (f5 > 1.1f) {
                                fArr[i14] = Math.max(1.0f, this.posArray.get(i14).aspectRatio);
                            } else {
                                fArr[i14] = Math.min(1.0f, this.posArray.get(i14).aspectRatio);
                            }
                            fArr[i14] = Math.max(0.66667f, Math.min(1.7f, fArr[i14]));
                        }
                        ArrayList arrayList = new ArrayList();
                        for (int i15 = 1; i15 < size2; i15++) {
                            int i16 = size2 - i15;
                            if (i15 <= 3 && i16 <= 3) {
                                arrayList.add(new MessageGroupedLayoutAttempt(i15, i16, multiHeight(fArr, 0, i15), multiHeight(fArr, i15, size2)));
                            }
                        }
                        int i17 = 1;
                        while (i17 < size2 - 1) {
                            int i18 = 1;
                            while (true) {
                                int i19 = size2 - i17;
                                if (i18 >= i19) {
                                    break;
                                }
                                int i20 = i19 - i18;
                                if (i17 <= i13) {
                                    if (i18 <= (f5 < 0.85f ? 4 : 3) && i20 <= i13) {
                                        int i21 = i17 + i18;
                                        i10 = i18;
                                        i9 = i17;
                                        arrayList.add(new MessageGroupedLayoutAttempt(i17, i18, i20, multiHeight(fArr, 0, i17), multiHeight(fArr, i17, i21), multiHeight(fArr, i21, size2)));
                                        i18 = i10 + 1;
                                        i17 = i9;
                                        i13 = 3;
                                    }
                                }
                                i10 = i18;
                                i9 = i17;
                                i18 = i10 + 1;
                                i17 = i9;
                                i13 = 3;
                            }
                            i17++;
                            i13 = 3;
                        }
                        int i22 = 1;
                        while (i22 < size2 - 2) {
                            int i23 = 1;
                            while (true) {
                                int i24 = size2 - i22;
                                if (i23 >= i24) {
                                    break;
                                }
                                int i25 = 1;
                                while (true) {
                                    int i26 = i24 - i23;
                                    if (i25 >= i26) {
                                        break;
                                    }
                                    int i27 = i26 - i25;
                                    if (i22 > 3 || i23 > 3 || i25 > 3 || i27 > 3) {
                                        i3 = i25;
                                        i7 = i24;
                                        i6 = i23;
                                        i5 = size;
                                        i4 = size2;
                                        i8 = dp2;
                                    } else {
                                        int i28 = i22 + i23;
                                        int i29 = i28 + i25;
                                        i4 = size2;
                                        i3 = i25;
                                        i7 = i24;
                                        i6 = i23;
                                        i5 = size;
                                        i8 = dp2;
                                        arrayList.add(new MessageGroupedLayoutAttempt(i22, i23, i25, i27, multiHeight(fArr, 0, i22), multiHeight(fArr, i22, i28), multiHeight(fArr, i28, i29), multiHeight(fArr, i29, size2)));
                                    }
                                    i25 = i3 + 1;
                                    dp2 = i8;
                                    i24 = i7;
                                    i23 = i6;
                                    size = i5;
                                    size2 = i4;
                                }
                                i23++;
                                size = size;
                            }
                            i22++;
                            size = size;
                        }
                        i = size;
                        float f6 = (float) ((this.maxSizeWidth / 3) * 4);
                        MessageGroupedLayoutAttempt messageGroupedLayoutAttempt = null;
                        float f7 = 0.0f;
                        for (int i30 = 0; i30 < arrayList.size(); i30++) {
                            MessageGroupedLayoutAttempt messageGroupedLayoutAttempt2 = (MessageGroupedLayoutAttempt) arrayList.get(i30);
                            float f8 = Float.MAX_VALUE;
                            float f9 = 0.0f;
                            for (int i31 = 0; i31 < messageGroupedLayoutAttempt2.heights.length; i31++) {
                                f9 += messageGroupedLayoutAttempt2.heights[i31];
                                if (messageGroupedLayoutAttempt2.heights[i31] < f8) {
                                    f8 = messageGroupedLayoutAttempt2.heights[i31];
                                }
                            }
                            float abs = Math.abs(f9 - f6);
                            if (messageGroupedLayoutAttempt2.lineCounts.length > 1) {
                                if (messageGroupedLayoutAttempt2.lineCounts[0] <= messageGroupedLayoutAttempt2.lineCounts[1]) {
                                    if (messageGroupedLayoutAttempt2.lineCounts.length > 2 && messageGroupedLayoutAttempt2.lineCounts[1] > messageGroupedLayoutAttempt2.lineCounts[2]) {
                                        f = 1.2f;
                                        abs *= f;
                                    } else if (messageGroupedLayoutAttempt2.lineCounts.length <= 3 || messageGroupedLayoutAttempt2.lineCounts[2] <= messageGroupedLayoutAttempt2.lineCounts[3]) {
                                    }
                                }
                                f = 1.2f;
                                abs *= f;
                            }
                            if (f8 < ((float) dp2)) {
                                abs *= 1.5f;
                            }
                            if (messageGroupedLayoutAttempt == null || abs < f7) {
                                messageGroupedLayoutAttempt = messageGroupedLayoutAttempt2;
                                f7 = abs;
                            }
                        }
                        if (messageGroupedLayoutAttempt != null) {
                            int i32 = 0;
                            int i33 = 0;
                            while (i33 < messageGroupedLayoutAttempt.lineCounts.length) {
                                int i34 = messageGroupedLayoutAttempt.lineCounts[i33];
                                float f10 = messageGroupedLayoutAttempt.heights[i33];
                                int i35 = this.maxSizeWidth;
                                MessageObject.GroupedMessagePosition groupedMessagePosition2 = null;
                                for (int i36 = 0; i36 < i34; i36++) {
                                    int i37 = (int) (fArr[i32] * f10);
                                    i35 -= i37;
                                    MessageObject.GroupedMessagePosition groupedMessagePosition3 = this.posArray.get(i32);
                                    int i38 = i33 == 0 ? 4 : 0;
                                    if (i33 == messageGroupedLayoutAttempt.lineCounts.length - 1) {
                                        i38 |= 8;
                                    }
                                    if (i36 == 0) {
                                        i38 |= 1;
                                    }
                                    if (i36 == i34 - 1) {
                                        i2 = i38 | 2;
                                        groupedMessagePosition2 = groupedMessagePosition3;
                                    } else {
                                        i2 = i38;
                                    }
                                    groupedMessagePosition3.set(i36, i36, i33, i33, i37, f10 / 814.0f, i2);
                                    i32++;
                                }
                                groupedMessagePosition2.pw += i35;
                                groupedMessagePosition2.spanSize += i35;
                                i33++;
                            }
                        } else {
                            return;
                        }
                    } else {
                        if (size == 2) {
                            MessageObject.GroupedMessagePosition groupedMessagePosition4 = this.posArray.get(0);
                            MessageObject.GroupedMessagePosition groupedMessagePosition5 = this.posArray.get(1);
                            String sb2 = sb.toString();
                            if (sb2.equals("ww")) {
                                double d = (double) f4;
                                Double.isNaN(d);
                                if (((double) f5) > d * 1.4d && ((double) (groupedMessagePosition4.aspectRatio - groupedMessagePosition5.aspectRatio)) < 0.2d) {
                                    float round = ((float) Math.round(Math.min(((float) this.maxSizeWidth) / groupedMessagePosition4.aspectRatio, Math.min(((float) this.maxSizeWidth) / groupedMessagePosition5.aspectRatio, 407.0f)))) / 814.0f;
                                    groupedMessagePosition4.set(0, 0, 0, 0, this.maxSizeWidth, round, 7);
                                    groupedMessagePosition5.set(0, 0, 1, 1, this.maxSizeWidth, round, 11);
                                }
                            }
                            if (sb2.equals("ww") || sb2.equals("qq")) {
                                int i39 = this.maxSizeWidth / 2;
                                float f11 = (float) i39;
                                float round2 = ((float) Math.round(Math.min(f11 / groupedMessagePosition4.aspectRatio, Math.min(f11 / groupedMessagePosition5.aspectRatio, 814.0f)))) / 814.0f;
                                groupedMessagePosition4.set(0, 0, 0, 0, i39, round2, 13);
                                groupedMessagePosition5.set(1, 1, 0, 0, i39, round2, 14);
                            } else {
                                int i40 = this.maxSizeWidth;
                                int max = (int) Math.max(((float) i40) * 0.4f, (float) Math.round((((float) i40) / groupedMessagePosition4.aspectRatio) / ((1.0f / groupedMessagePosition4.aspectRatio) + (1.0f / groupedMessagePosition5.aspectRatio))));
                                int i41 = this.maxSizeWidth - max;
                                if (i41 < dp2) {
                                    max -= dp2 - i41;
                                    i41 = dp2;
                                }
                                float min = Math.min(814.0f, (float) Math.round(Math.min(((float) i41) / groupedMessagePosition4.aspectRatio, ((float) max) / groupedMessagePosition5.aspectRatio))) / 814.0f;
                                groupedMessagePosition4.set(0, 0, 0, 0, i41, min, 13);
                                groupedMessagePosition5.set(1, 1, 0, 0, max, min, 14);
                            }
                        } else if (size == 3) {
                            MessageObject.GroupedMessagePosition groupedMessagePosition6 = this.posArray.get(0);
                            MessageObject.GroupedMessagePosition groupedMessagePosition7 = this.posArray.get(1);
                            MessageObject.GroupedMessagePosition groupedMessagePosition8 = this.posArray.get(2);
                            if (sb.charAt(0) == 'n') {
                                float min2 = Math.min(407.0f, (float) Math.round((groupedMessagePosition7.aspectRatio * ((float) this.maxSizeWidth)) / (groupedMessagePosition8.aspectRatio + groupedMessagePosition7.aspectRatio)));
                                float f12 = 814.0f - min2;
                                int max2 = (int) Math.max((float) dp2, Math.min(((float) this.maxSizeWidth) * 0.5f, (float) Math.round(Math.min(groupedMessagePosition8.aspectRatio * min2, groupedMessagePosition7.aspectRatio * f12))));
                                int round3 = Math.round(Math.min((groupedMessagePosition6.aspectRatio * 814.0f) + ((float) dp3), (float) (this.maxSizeWidth - max2)));
                                groupedMessagePosition6.set(0, 0, 0, 1, round3, 1.0f, 13);
                                float f13 = f12 / 814.0f;
                                groupedMessagePosition7.set(1, 1, 0, 0, max2, f13, 6);
                                float f14 = min2 / 814.0f;
                                groupedMessagePosition8.set(0, 1, 1, 1, max2, f14, 10);
                                groupedMessagePosition8.spanSize = this.maxSizeWidth;
                                groupedMessagePosition6.siblingHeights = new float[]{f14, f13};
                                groupedMessagePosition7.spanSize = this.maxSizeWidth - round3;
                                groupedMessagePosition8.leftSpanOffset = round3;
                                this.hasSibling = true;
                            } else {
                                float round4 = ((float) Math.round(Math.min(((float) this.maxSizeWidth) / groupedMessagePosition6.aspectRatio, 537.24005f))) / 814.0f;
                                groupedMessagePosition6.set(0, 1, 0, 0, this.maxSizeWidth, round4, 7);
                                int i42 = this.maxSizeWidth / 2;
                                float f15 = 814.0f - round4;
                                float f16 = (float) i42;
                                float min3 = Math.min(f15, (float) Math.round(Math.min(f16 / groupedMessagePosition7.aspectRatio, f16 / groupedMessagePosition8.aspectRatio))) / 814.0f;
                                groupedMessagePosition7.set(0, 0, 1, 1, i42, min3, 9);
                                groupedMessagePosition8.set(1, 1, 1, 1, i42, min3, 10);
                            }
                        } else if (size == 4) {
                            MessageObject.GroupedMessagePosition groupedMessagePosition9 = this.posArray.get(0);
                            MessageObject.GroupedMessagePosition groupedMessagePosition10 = this.posArray.get(1);
                            MessageObject.GroupedMessagePosition groupedMessagePosition11 = this.posArray.get(2);
                            MessageObject.GroupedMessagePosition groupedMessagePosition12 = this.posArray.get(3);
                            if (sb.charAt(0) == 'w') {
                                float round5 = ((float) Math.round(Math.min(((float) this.maxSizeWidth) / groupedMessagePosition9.aspectRatio, 537.24005f))) / 814.0f;
                                groupedMessagePosition9.set(0, 2, 0, 0, this.maxSizeWidth, round5, 7);
                                float round6 = (float) Math.round(((float) this.maxSizeWidth) / ((groupedMessagePosition10.aspectRatio + groupedMessagePosition11.aspectRatio) + groupedMessagePosition12.aspectRatio));
                                float f17 = (float) dp2;
                                int max3 = (int) Math.max(f17, Math.min(((float) this.maxSizeWidth) * 0.4f, groupedMessagePosition10.aspectRatio * round6));
                                int max4 = (int) Math.max(Math.max(f17, ((float) this.maxSizeWidth) * 0.33f), groupedMessagePosition12.aspectRatio * round6);
                                float min4 = Math.min(814.0f - round5, round6) / 814.0f;
                                groupedMessagePosition10.set(0, 0, 1, 1, max3, min4, 9);
                                groupedMessagePosition11.set(1, 1, 1, 1, (this.maxSizeWidth - max3) - max4, min4, 8);
                                groupedMessagePosition12.set(2, 2, 1, 1, max4, min4, 10);
                            } else {
                                int max5 = Math.max(dp2, Math.round(814.0f / (((1.0f / groupedMessagePosition10.aspectRatio) + (1.0f / groupedMessagePosition11.aspectRatio)) + (1.0f / this.posArray.get(3).aspectRatio))));
                                float f18 = (float) dp;
                                float f19 = (float) max5;
                                float min5 = Math.min(0.33f, Math.max(f18, f19 / groupedMessagePosition10.aspectRatio) / 814.0f);
                                float min6 = Math.min(0.33f, Math.max(f18, f19 / groupedMessagePosition11.aspectRatio) / 814.0f);
                                float f20 = (1.0f - min5) - min6;
                                int round7 = Math.round(Math.min((814.0f * groupedMessagePosition9.aspectRatio) + ((float) dp3), (float) (this.maxSizeWidth - max5)));
                                groupedMessagePosition9.set(0, 0, 0, 2, round7, min5 + min6 + f20, 13);
                                groupedMessagePosition10.set(1, 1, 0, 0, max5, min5, 6);
                                groupedMessagePosition11.set(0, 1, 1, 1, max5, min6, 2);
                                groupedMessagePosition11.spanSize = this.maxSizeWidth;
                                groupedMessagePosition12.set(0, 1, 2, 2, max5, f20, 10);
                                groupedMessagePosition12.spanSize = this.maxSizeWidth;
                                groupedMessagePosition10.spanSize = this.maxSizeWidth - round7;
                                groupedMessagePosition11.leftSpanOffset = round7;
                                groupedMessagePosition12.leftSpanOffset = round7;
                                groupedMessagePosition9.siblingHeights = new float[]{min5, min6, f20};
                                this.hasSibling = true;
                            }
                        }
                        i = size;
                    }
                    for (int i43 = 0; i43 < i; i43++) {
                        MessageObject.GroupedMessagePosition groupedMessagePosition13 = this.posArray.get(i43);
                        if ((groupedMessagePosition13.flags & 1) != 0) {
                            groupedMessagePosition13.edge = true;
                        }
                    }
                }
            }
        }

        public BlockCollageCell(Context context, WebpageAdapter webpageAdapter) {
            super(context);
            this.parentAdapter = webpageAdapter;
            AnonymousClass1 r11 = new RecyclerListView(context, ArticleViewer.this) {
                /* class im.guobwnxjuc.ui.ArticleViewer.BlockCollageCell.AnonymousClass1 */

                @Override // androidx.recyclerview.widget.RecyclerView
                public void requestLayout() {
                    if (!BlockCollageCell.this.inLayout) {
                        super.requestLayout();
                    }
                }
            };
            this.innerListView = r11;
            r11.addItemDecoration(new RecyclerView.ItemDecoration(ArticleViewer.this) {
                /* class im.guobwnxjuc.ui.ArticleViewer.BlockCollageCell.AnonymousClass2 */

                @Override // androidx.recyclerview.widget.RecyclerView.ItemDecoration
                public void getItemOffsets(Rect rect, View view, RecyclerView recyclerView, RecyclerView.State state) {
                    MessageObject.GroupedMessagePosition groupedMessagePosition;
                    int i = 0;
                    rect.bottom = 0;
                    if (view instanceof BlockPhotoCell) {
                        groupedMessagePosition = BlockCollageCell.this.group.positions.get(((BlockPhotoCell) view).currentBlock);
                    } else {
                        groupedMessagePosition = view instanceof BlockVideoCell ? BlockCollageCell.this.group.positions.get(((BlockVideoCell) view).currentBlock) : null;
                    }
                    if (!(groupedMessagePosition == null || groupedMessagePosition.siblingHeights == null)) {
                        float max = ((float) Math.max(AndroidUtilities.displaySize.x, AndroidUtilities.displaySize.y)) * 0.5f;
                        int i2 = 0;
                        for (int i3 = 0; i3 < groupedMessagePosition.siblingHeights.length; i3++) {
                            i2 += (int) Math.ceil((double) (groupedMessagePosition.siblingHeights[i3] * max));
                        }
                        int dp2 = i2 + ((groupedMessagePosition.maxY - groupedMessagePosition.minY) * AndroidUtilities.dp2(11.0f));
                        int size = BlockCollageCell.this.group.posArray.size();
                        while (true) {
                            if (i >= size) {
                                break;
                            }
                            MessageObject.GroupedMessagePosition groupedMessagePosition2 = BlockCollageCell.this.group.posArray.get(i);
                            if (groupedMessagePosition2.minY == groupedMessagePosition.minY && (!(groupedMessagePosition2.minX == groupedMessagePosition.minX && groupedMessagePosition2.maxX == groupedMessagePosition.maxX && groupedMessagePosition2.minY == groupedMessagePosition.minY && groupedMessagePosition2.maxY == groupedMessagePosition.maxY) && groupedMessagePosition2.minY == groupedMessagePosition.minY)) {
                                dp2 -= ((int) Math.ceil((double) (max * groupedMessagePosition2.ph))) - AndroidUtilities.dp(4.0f);
                                break;
                            }
                            i++;
                        }
                        rect.bottom = -dp2;
                    }
                }
            });
            AnonymousClass3 r112 = new GridLayoutManagerFixed(context, 1000, 1, true, ArticleViewer.this) {
                /* class im.guobwnxjuc.ui.ArticleViewer.BlockCollageCell.AnonymousClass3 */

                @Override // androidx.recyclerview.widget.GridLayoutManagerFixed
                public boolean shouldLayoutChildFromOpositeSide(View view) {
                    return false;
                }

                @Override // androidx.recyclerview.widget.GridLayoutManager, androidx.recyclerview.widget.RecyclerView.LayoutManager, androidx.recyclerview.widget.LinearLayoutManager
                public boolean supportsPredictiveItemAnimations() {
                    return false;
                }

                /* access modifiers changed from: protected */
                @Override // androidx.recyclerview.widget.GridLayoutManagerFixed
                public boolean hasSiblingChild(int i) {
                    MessageObject.GroupedMessagePosition groupedMessagePosition = BlockCollageCell.this.group.positions.get(BlockCollageCell.this.currentBlock.items.get((BlockCollageCell.this.currentBlock.items.size() - i) - 1));
                    if (!(groupedMessagePosition.minX == groupedMessagePosition.maxX || groupedMessagePosition.minY != groupedMessagePosition.maxY || groupedMessagePosition.minY == 0)) {
                        int size = BlockCollageCell.this.group.posArray.size();
                        for (int i2 = 0; i2 < size; i2++) {
                            MessageObject.GroupedMessagePosition groupedMessagePosition2 = BlockCollageCell.this.group.posArray.get(i2);
                            if (groupedMessagePosition2 != groupedMessagePosition && groupedMessagePosition2.minY <= groupedMessagePosition.minY && groupedMessagePosition2.maxY >= groupedMessagePosition.minY) {
                                return true;
                            }
                        }
                    }
                    return false;
                }
            };
            this.gridLayoutManager = r112;
            r112.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup(ArticleViewer.this) {
                /* class im.guobwnxjuc.ui.ArticleViewer.BlockCollageCell.AnonymousClass4 */

                @Override // androidx.recyclerview.widget.GridLayoutManager.SpanSizeLookup
                public int getSpanSize(int i) {
                    return BlockCollageCell.this.group.positions.get(BlockCollageCell.this.currentBlock.items.get((BlockCollageCell.this.currentBlock.items.size() - i) - 1)).spanSize;
                }
            });
            this.innerListView.setLayoutManager(this.gridLayoutManager);
            RecyclerListView recyclerListView = this.innerListView;
            AnonymousClass5 r113 = new RecyclerView.Adapter(ArticleViewer.this) {
                /* class im.guobwnxjuc.ui.ArticleViewer.BlockCollageCell.AnonymousClass5 */

                @Override // androidx.recyclerview.widget.RecyclerView.Adapter
                public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
                    return new RecyclerListView.Holder(i != 0 ? new BlockVideoCell(BlockCollageCell.this.getContext(), BlockCollageCell.this.parentAdapter, 2) : new BlockPhotoCell(BlockCollageCell.this.getContext(), BlockCollageCell.this.parentAdapter, 2));
                }

                @Override // androidx.recyclerview.widget.RecyclerView.Adapter
                public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, int i) {
                    TLRPC.PageBlock pageBlock = BlockCollageCell.this.currentBlock.items.get((BlockCollageCell.this.currentBlock.items.size() - i) - 1);
                    if (viewHolder.getItemViewType() != 0) {
                        BlockVideoCell blockVideoCell = (BlockVideoCell) viewHolder.itemView;
                        blockVideoCell.groupPosition = BlockCollageCell.this.group.positions.get(pageBlock);
                        blockVideoCell.setBlock((TLRPC.TL_pageBlockVideo) pageBlock, true, true);
                        return;
                    }
                    BlockPhotoCell blockPhotoCell = (BlockPhotoCell) viewHolder.itemView;
                    blockPhotoCell.groupPosition = BlockCollageCell.this.group.positions.get(pageBlock);
                    blockPhotoCell.setBlock((TLRPC.TL_pageBlockPhoto) pageBlock, true, true);
                }

                @Override // androidx.recyclerview.widget.RecyclerView.Adapter
                public int getItemCount() {
                    if (BlockCollageCell.this.currentBlock == null) {
                        return 0;
                    }
                    return BlockCollageCell.this.currentBlock.items.size();
                }

                @Override // androidx.recyclerview.widget.RecyclerView.Adapter
                public int getItemViewType(int i) {
                    if (BlockCollageCell.this.currentBlock.items.get((BlockCollageCell.this.currentBlock.items.size() - i) - 1) instanceof TLRPC.TL_pageBlockPhoto) {
                        return 0;
                    }
                    return 1;
                }
            };
            this.innerAdapter = r113;
            recyclerListView.setAdapter(r113);
            addView(this.innerListView, LayoutHelper.createFrame(-1, -2.0f));
            setWillNotDraw(false);
        }

        public void setBlock(TLRPC.TL_pageBlockCollage tL_pageBlockCollage) {
            if (this.currentBlock != tL_pageBlockCollage) {
                this.currentBlock = tL_pageBlockCollage;
                this.group.calculate();
            }
            this.innerAdapter.notifyDataSetChanged();
            int selectedColor = ArticleViewer.this.getSelectedColor();
            if (selectedColor == 0) {
                this.innerListView.setGlowColor(-657673);
            } else if (selectedColor == 1) {
                this.innerListView.setGlowColor(-659492);
            } else if (selectedColor == 2) {
                this.innerListView.setGlowColor(-15461356);
            }
            requestLayout();
        }

        public boolean onTouchEvent(MotionEvent motionEvent) {
            return ArticleViewer.this.checkLayoutForLinks(motionEvent, this, this.captionLayout, this.textX, this.textY) || ArticleViewer.this.checkLayoutForLinks(motionEvent, this, this.creditLayout, this.textX, this.textY + this.creditOffset) || super.onTouchEvent(motionEvent);
        }

        /* access modifiers changed from: protected */
        public void onMeasure(int i, int i2) {
            int i3;
            int i4;
            int i5 = 1;
            this.inLayout = true;
            int size = View.MeasureSpec.getSize(i);
            TLRPC.TL_pageBlockCollage tL_pageBlockCollage = this.currentBlock;
            if (tL_pageBlockCollage != null) {
                if (tL_pageBlockCollage.level > 0) {
                    int dp = AndroidUtilities.dp((float) (this.currentBlock.level * 14)) + AndroidUtilities.dp(18.0f);
                    this.listX = dp;
                    this.textX = dp;
                    i3 = size - (dp + AndroidUtilities.dp(18.0f));
                    i4 = i3;
                } else {
                    this.listX = 0;
                    this.textX = AndroidUtilities.dp(18.0f);
                    i4 = size - AndroidUtilities.dp(36.0f);
                    i3 = size;
                }
                this.innerListView.measure(View.MeasureSpec.makeMeasureSpec(i3, 1073741824), View.MeasureSpec.makeMeasureSpec(0, 0));
                int measuredHeight = this.innerListView.getMeasuredHeight();
                DrawingText createLayoutForText = ArticleViewer.this.createLayoutForText(this, null, this.currentBlock.caption.text, i4, this.currentBlock, this.parentAdapter);
                this.captionLayout = createLayoutForText;
                if (createLayoutForText != null) {
                    this.textY = AndroidUtilities.dp(8.0f) + measuredHeight;
                    int dp2 = AndroidUtilities.dp(4.0f) + this.captionLayout.getHeight();
                    this.creditOffset = dp2;
                    measuredHeight += dp2 + AndroidUtilities.dp(4.0f);
                }
                DrawingText createLayoutForText2 = ArticleViewer.this.createLayoutForText((ArticleViewer) this, (View) null, (CharSequence) this.currentBlock.caption.credit, (TLRPC.RichText) i4, (int) this.currentBlock, (TLRPC.PageBlock) (ArticleViewer.this.isRtl ? StaticLayoutEx.ALIGN_RIGHT() : Layout.Alignment.ALIGN_NORMAL), (Layout.Alignment) this.parentAdapter);
                this.creditLayout = createLayoutForText2;
                if (createLayoutForText2 != null) {
                    measuredHeight += AndroidUtilities.dp(4.0f) + this.creditLayout.getHeight();
                }
                i5 = measuredHeight + AndroidUtilities.dp(16.0f);
                if (this.currentBlock.level > 0 && !this.currentBlock.bottom) {
                    i5 += AndroidUtilities.dp(8.0f);
                }
            }
            setMeasuredDimension(size, i5);
            this.inLayout = false;
        }

        /* access modifiers changed from: protected */
        public void onLayout(boolean z, int i, int i2, int i3, int i4) {
            this.innerListView.layout(this.listX, AndroidUtilities.dp(8.0f), this.listX + this.innerListView.getMeasuredWidth(), this.innerListView.getMeasuredHeight() + AndroidUtilities.dp(8.0f));
        }

        /* access modifiers changed from: protected */
        public void onDraw(Canvas canvas) {
            if (this.currentBlock != null) {
                if (this.captionLayout != null) {
                    canvas.save();
                    canvas.translate((float) this.textX, (float) this.textY);
                    this.captionLayout.draw(canvas);
                    canvas.restore();
                }
                if (this.creditLayout != null) {
                    canvas.save();
                    canvas.translate((float) this.textX, (float) (this.textY + this.creditOffset));
                    this.creditLayout.draw(canvas);
                    canvas.restore();
                }
                if (this.currentBlock.level > 0) {
                    canvas.drawRect((float) AndroidUtilities.dp(18.0f), 0.0f, (float) AndroidUtilities.dp(20.0f), (float) (getMeasuredHeight() - (this.currentBlock.bottom ? AndroidUtilities.dp(6.0f) : 0)), ArticleViewer.quoteLinePaint);
                }
            }
        }
    }

    /* access modifiers changed from: private */
    public class BlockSlideshowCell extends FrameLayout {
        private DrawingText captionLayout;
        private DrawingText creditLayout;
        private int creditOffset;
        private TLRPC.TL_pageBlockSlideshow currentBlock;
        private int currentPage;
        private View dotsContainer;
        private PagerAdapter innerAdapter;
        private ViewPager innerListView;
        private float pageOffset;
        private WebpageAdapter parentAdapter;
        private int textX = AndroidUtilities.dp(18.0f);
        private int textY;

        public BlockSlideshowCell(Context context, WebpageAdapter webpageAdapter) {
            super(context);
            this.parentAdapter = webpageAdapter;
            if (ArticleViewer.dotsPaint == null) {
                Paint unused = ArticleViewer.dotsPaint = new Paint(1);
                ArticleViewer.dotsPaint.setColor(-1);
            }
            AnonymousClass1 r5 = new ViewPager(context, ArticleViewer.this) {
                /* class im.guobwnxjuc.ui.ArticleViewer.BlockSlideshowCell.AnonymousClass1 */

                @Override // androidx.viewpager.widget.ViewPager
                public boolean onTouchEvent(MotionEvent motionEvent) {
                    return super.onTouchEvent(motionEvent);
                }

                @Override // androidx.viewpager.widget.ViewPager
                public boolean onInterceptTouchEvent(MotionEvent motionEvent) {
                    ArticleViewer.this.windowView.requestDisallowInterceptTouchEvent(true);
                    return super.onInterceptTouchEvent(motionEvent);
                }
            };
            this.innerListView = r5;
            r5.addOnPageChangeListener(new ViewPager.OnPageChangeListener(ArticleViewer.this) {
                /* class im.guobwnxjuc.ui.ArticleViewer.BlockSlideshowCell.AnonymousClass2 */

                @Override // androidx.viewpager.widget.ViewPager.OnPageChangeListener
                public void onPageScrollStateChanged(int i) {
                }

                @Override // androidx.viewpager.widget.ViewPager.OnPageChangeListener
                public void onPageScrolled(int i, float f, int i2) {
                    float measuredWidth = (float) BlockSlideshowCell.this.innerListView.getMeasuredWidth();
                    if (measuredWidth != 0.0f) {
                        BlockSlideshowCell blockSlideshowCell = BlockSlideshowCell.this;
                        blockSlideshowCell.pageOffset = (((((float) i) * measuredWidth) + ((float) i2)) - (((float) blockSlideshowCell.currentPage) * measuredWidth)) / measuredWidth;
                        BlockSlideshowCell.this.dotsContainer.invalidate();
                    }
                }

                @Override // androidx.viewpager.widget.ViewPager.OnPageChangeListener
                public void onPageSelected(int i) {
                    BlockSlideshowCell.this.currentPage = i;
                    BlockSlideshowCell.this.dotsContainer.invalidate();
                }
            });
            ViewPager viewPager = this.innerListView;
            AnonymousClass3 r1 = new PagerAdapter(ArticleViewer.this) {
                /* class im.guobwnxjuc.ui.ArticleViewer.BlockSlideshowCell.AnonymousClass3 */

                /* renamed from: im.guobwnxjuc.ui.ArticleViewer$BlockSlideshowCell$3$ObjectContainer */
                class ObjectContainer {
                    private TLRPC.PageBlock block;
                    private View view;

                    ObjectContainer() {
                    }
                }

                @Override // androidx.viewpager.widget.PagerAdapter
                public int getCount() {
                    if (BlockSlideshowCell.this.currentBlock == null) {
                        return 0;
                    }
                    return BlockSlideshowCell.this.currentBlock.items.size();
                }

                @Override // androidx.viewpager.widget.PagerAdapter
                public boolean isViewFromObject(View view, Object obj) {
                    return ((ObjectContainer) obj).view == view;
                }

                @Override // androidx.viewpager.widget.PagerAdapter
                public int getItemPosition(Object obj) {
                    return BlockSlideshowCell.this.currentBlock.items.contains(((ObjectContainer) obj).block) ? -1 : -2;
                }

                @Override // androidx.viewpager.widget.PagerAdapter
                public Object instantiateItem(ViewGroup viewGroup, int i) {
                    View view;
                    TLRPC.PageBlock pageBlock = BlockSlideshowCell.this.currentBlock.items.get(i);
                    if (pageBlock instanceof TLRPC.TL_pageBlockPhoto) {
                        view = new BlockPhotoCell(BlockSlideshowCell.this.getContext(), BlockSlideshowCell.this.parentAdapter, 1);
                        ((BlockPhotoCell) view).setBlock((TLRPC.TL_pageBlockPhoto) pageBlock, true, true);
                    } else {
                        view = new BlockVideoCell(BlockSlideshowCell.this.getContext(), BlockSlideshowCell.this.parentAdapter, 1);
                        ((BlockVideoCell) view).setBlock((TLRPC.TL_pageBlockVideo) pageBlock, true, true);
                    }
                    viewGroup.addView(view);
                    ObjectContainer objectContainer = new ObjectContainer();
                    objectContainer.view = view;
                    objectContainer.block = pageBlock;
                    return objectContainer;
                }

                @Override // androidx.viewpager.widget.PagerAdapter
                public void destroyItem(ViewGroup viewGroup, int i, Object obj) {
                    viewGroup.removeView(((ObjectContainer) obj).view);
                }

                @Override // androidx.viewpager.widget.PagerAdapter
                public void unregisterDataSetObserver(DataSetObserver dataSetObserver) {
                    if (dataSetObserver != null) {
                        super.unregisterDataSetObserver(dataSetObserver);
                    }
                }
            };
            this.innerAdapter = r1;
            viewPager.setAdapter(r1);
            int selectedColor = ArticleViewer.this.getSelectedColor();
            if (selectedColor == 0) {
                AndroidUtilities.setViewPagerEdgeEffectColor(this.innerListView, -657673);
            } else if (selectedColor == 1) {
                AndroidUtilities.setViewPagerEdgeEffectColor(this.innerListView, -659492);
            } else if (selectedColor == 2) {
                AndroidUtilities.setViewPagerEdgeEffectColor(this.innerListView, -15461356);
            }
            addView(this.innerListView);
            AnonymousClass4 r52 = new View(context, ArticleViewer.this) {
                /* class im.guobwnxjuc.ui.ArticleViewer.BlockSlideshowCell.AnonymousClass4 */

                /* access modifiers changed from: protected */
                public void onDraw(Canvas canvas) {
                    int i;
                    int i2;
                    if (BlockSlideshowCell.this.currentBlock != null) {
                        int count = BlockSlideshowCell.this.innerAdapter.getCount();
                        int dp = (AndroidUtilities.dp(7.0f) * count) + ((count - 1) * AndroidUtilities.dp(6.0f)) + AndroidUtilities.dp(4.0f);
                        if (dp < getMeasuredWidth()) {
                            i = (getMeasuredWidth() - dp) / 2;
                        } else {
                            int dp2 = AndroidUtilities.dp(4.0f);
                            int dp3 = AndroidUtilities.dp(13.0f);
                            int measuredWidth = ((getMeasuredWidth() - AndroidUtilities.dp(8.0f)) / 2) / dp3;
                            int i3 = (count - measuredWidth) - 1;
                            if (BlockSlideshowCell.this.currentPage != i3 || BlockSlideshowCell.this.pageOffset >= 0.0f) {
                                if (BlockSlideshowCell.this.currentPage >= i3) {
                                    i2 = ((count - (measuredWidth * 2)) - 1) * dp3;
                                } else if (BlockSlideshowCell.this.currentPage > measuredWidth) {
                                    i2 = ((int) (BlockSlideshowCell.this.pageOffset * ((float) dp3))) + ((BlockSlideshowCell.this.currentPage - measuredWidth) * dp3);
                                } else if (BlockSlideshowCell.this.currentPage != measuredWidth || BlockSlideshowCell.this.pageOffset <= 0.0f) {
                                    i = dp2;
                                } else {
                                    i2 = (int) (BlockSlideshowCell.this.pageOffset * ((float) dp3));
                                }
                                i = dp2 - i2;
                            } else {
                                i = dp2 - (((int) (BlockSlideshowCell.this.pageOffset * ((float) dp3))) + (((count - (measuredWidth * 2)) - 1) * dp3));
                            }
                        }
                        int i4 = 0;
                        while (i4 < BlockSlideshowCell.this.currentBlock.items.size()) {
                            int dp4 = AndroidUtilities.dp(4.0f) + i + (AndroidUtilities.dp(13.0f) * i4);
                            Drawable drawable = BlockSlideshowCell.this.currentPage == i4 ? ArticleViewer.this.slideDotBigDrawable : ArticleViewer.this.slideDotDrawable;
                            drawable.setBounds(dp4 - AndroidUtilities.dp(5.0f), 0, dp4 + AndroidUtilities.dp(5.0f), AndroidUtilities.dp(10.0f));
                            drawable.draw(canvas);
                            i4++;
                        }
                    }
                }
            };
            this.dotsContainer = r52;
            addView(r52);
            setWillNotDraw(false);
        }

        public void setBlock(TLRPC.TL_pageBlockSlideshow tL_pageBlockSlideshow) {
            this.currentBlock = tL_pageBlockSlideshow;
            this.innerAdapter.notifyDataSetChanged();
            this.innerListView.setCurrentItem(0, false);
            this.innerListView.forceLayout();
            requestLayout();
        }

        public boolean onTouchEvent(MotionEvent motionEvent) {
            return ArticleViewer.this.checkLayoutForLinks(motionEvent, this, this.captionLayout, this.textX, this.textY) || ArticleViewer.this.checkLayoutForLinks(motionEvent, this, this.creditLayout, this.textX, this.textY + this.creditOffset) || super.onTouchEvent(motionEvent);
        }

        /* access modifiers changed from: protected */
        public void onMeasure(int i, int i2) {
            int i3;
            int size = View.MeasureSpec.getSize(i);
            if (this.currentBlock != null) {
                int dp = AndroidUtilities.dp(310.0f);
                this.innerListView.measure(View.MeasureSpec.makeMeasureSpec(size, 1073741824), View.MeasureSpec.makeMeasureSpec(dp, 1073741824));
                this.currentBlock.items.size();
                this.dotsContainer.measure(View.MeasureSpec.makeMeasureSpec(size, 1073741824), View.MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(10.0f), 1073741824));
                int dp2 = size - AndroidUtilities.dp(36.0f);
                this.textY = AndroidUtilities.dp(16.0f) + dp;
                DrawingText createLayoutForText = ArticleViewer.this.createLayoutForText(this, null, this.currentBlock.caption.text, dp2, this.currentBlock, this.parentAdapter);
                this.captionLayout = createLayoutForText;
                if (createLayoutForText != null) {
                    int dp3 = AndroidUtilities.dp(4.0f) + this.captionLayout.getHeight();
                    this.creditOffset = dp3;
                    dp += dp3 + AndroidUtilities.dp(4.0f);
                }
                DrawingText createLayoutForText2 = ArticleViewer.this.createLayoutForText((ArticleViewer) this, (View) null, (CharSequence) this.currentBlock.caption.credit, (TLRPC.RichText) dp2, (int) this.currentBlock, (TLRPC.PageBlock) (ArticleViewer.this.isRtl ? StaticLayoutEx.ALIGN_RIGHT() : Layout.Alignment.ALIGN_NORMAL), (Layout.Alignment) this.parentAdapter);
                this.creditLayout = createLayoutForText2;
                if (createLayoutForText2 != null) {
                    dp += AndroidUtilities.dp(4.0f) + this.creditLayout.getHeight();
                }
                i3 = dp + AndroidUtilities.dp(16.0f);
            } else {
                i3 = 1;
            }
            setMeasuredDimension(size, i3);
        }

        /* access modifiers changed from: protected */
        public void onLayout(boolean z, int i, int i2, int i3, int i4) {
            this.innerListView.layout(0, AndroidUtilities.dp(8.0f), this.innerListView.getMeasuredWidth(), AndroidUtilities.dp(8.0f) + this.innerListView.getMeasuredHeight());
            int bottom = this.innerListView.getBottom() - AndroidUtilities.dp(23.0f);
            View view = this.dotsContainer;
            view.layout(0, bottom, view.getMeasuredWidth(), this.dotsContainer.getMeasuredHeight() + bottom);
        }

        /* access modifiers changed from: protected */
        public void onDraw(Canvas canvas) {
            if (this.currentBlock != null) {
                if (this.captionLayout != null) {
                    canvas.save();
                    canvas.translate((float) this.textX, (float) this.textY);
                    this.captionLayout.draw(canvas);
                    canvas.restore();
                }
                if (this.creditLayout != null) {
                    canvas.save();
                    canvas.translate((float) this.textX, (float) (this.textY + this.creditOffset));
                    this.creditLayout.draw(canvas);
                    canvas.restore();
                }
            }
        }
    }

    /* access modifiers changed from: private */
    public class BlockListItemCell extends ViewGroup {
        private RecyclerView.ViewHolder blockLayout;
        private int blockX;
        private int blockY;
        private TL_pageBlockListItem currentBlock;
        private int currentBlockType;
        private boolean drawDot;
        private int numOffsetY;
        private WebpageAdapter parentAdapter;
        private boolean parentIsList;
        private DrawingText textLayout;
        private int textX;
        private int textY;
        private boolean verticalAlign;

        public BlockListItemCell(Context context, WebpageAdapter webpageAdapter) {
            super(context);
            this.parentAdapter = webpageAdapter;
            setWillNotDraw(false);
        }

        public void setBlock(TL_pageBlockListItem tL_pageBlockListItem) {
            if (this.currentBlock != tL_pageBlockListItem) {
                this.currentBlock = tL_pageBlockListItem;
                RecyclerView.ViewHolder viewHolder = this.blockLayout;
                if (viewHolder != null) {
                    removeView(viewHolder.itemView);
                    this.blockLayout = null;
                }
                if (this.currentBlock.blockItem != null) {
                    int typeForBlock = this.parentAdapter.getTypeForBlock(this.currentBlock.blockItem);
                    this.currentBlockType = typeForBlock;
                    RecyclerView.ViewHolder onCreateViewHolder = this.parentAdapter.onCreateViewHolder(this, typeForBlock);
                    this.blockLayout = onCreateViewHolder;
                    addView(onCreateViewHolder.itemView);
                }
            }
            if (this.currentBlock.blockItem != null) {
                this.parentAdapter.bindBlockToHolder(this.currentBlockType, this.blockLayout, this.currentBlock.blockItem, 0, 0);
            }
            requestLayout();
        }

        public boolean onTouchEvent(MotionEvent motionEvent) {
            if (ArticleViewer.this.checkLayoutForLinks(motionEvent, this, this.textLayout, this.textX, this.textY)) {
                return true;
            }
            return super.onTouchEvent(motionEvent);
        }

        /* access modifiers changed from: protected */
        /* JADX WARNING: Removed duplicated region for block: B:119:0x03d5  */
        public void onMeasure(int i, int i2) {
            int i3;
            int i4;
            int i5;
            int size = View.MeasureSpec.getSize(i);
            TL_pageBlockListItem tL_pageBlockListItem = this.currentBlock;
            int i6 = 1;
            if (tL_pageBlockListItem != null) {
                this.textLayout = null;
                int i7 = 0;
                this.textY = (tL_pageBlockListItem.index == 0 && this.currentBlock.parent.level == 0) ? AndroidUtilities.dp(10.0f) : 0;
                this.numOffsetY = 0;
                if (!(this.currentBlock.parent.lastMaxNumCalcWidth == size && this.currentBlock.parent.lastFontSize == ArticleViewer.this.selectedFontSize)) {
                    this.currentBlock.parent.lastMaxNumCalcWidth = size;
                    this.currentBlock.parent.lastFontSize = ArticleViewer.this.selectedFontSize;
                    this.currentBlock.parent.maxNumWidth = 0;
                    int size2 = this.currentBlock.parent.items.size();
                    for (int i8 = 0; i8 < size2; i8++) {
                        TL_pageBlockListItem tL_pageBlockListItem2 = (TL_pageBlockListItem) this.currentBlock.parent.items.get(i8);
                        if (tL_pageBlockListItem2.num != null) {
                            tL_pageBlockListItem2.numLayout = ArticleViewer.this.createLayoutForText(this, tL_pageBlockListItem2.num, null, size - AndroidUtilities.dp(54.0f), this.currentBlock, this.parentAdapter);
                            this.currentBlock.parent.maxNumWidth = Math.max(this.currentBlock.parent.maxNumWidth, (int) Math.ceil((double) tL_pageBlockListItem2.numLayout.getLineWidth(0)));
                        }
                    }
                    this.currentBlock.parent.maxNumWidth = Math.max(this.currentBlock.parent.maxNumWidth, (int) Math.ceil((double) ArticleViewer.listTextNumPaint.measureText("00.")));
                }
                this.drawDot = !this.currentBlock.parent.pageBlockList.ordered;
                this.parentIsList = (getParent() instanceof BlockListItemCell) || (getParent() instanceof BlockOrderedListItemCell);
                if (ArticleViewer.this.isRtl) {
                    this.textX = AndroidUtilities.dp(18.0f);
                } else {
                    this.textX = AndroidUtilities.dp(24.0f) + this.currentBlock.parent.maxNumWidth + (this.currentBlock.parent.level * AndroidUtilities.dp(12.0f));
                }
                int dp = (size - AndroidUtilities.dp(18.0f)) - this.textX;
                if (ArticleViewer.this.isRtl) {
                    dp -= (AndroidUtilities.dp(6.0f) + this.currentBlock.parent.maxNumWidth) + (this.currentBlock.parent.level * AndroidUtilities.dp(12.0f));
                }
                int i9 = dp;
                if (this.currentBlock.textItem != null) {
                    DrawingText createLayoutForText = ArticleViewer.this.createLayoutForText((ArticleViewer) this, (View) null, (CharSequence) this.currentBlock.textItem, (TLRPC.RichText) i9, (int) this.currentBlock, (TLRPC.PageBlock) (ArticleViewer.this.isRtl ? StaticLayoutEx.ALIGN_RIGHT() : Layout.Alignment.ALIGN_NORMAL), (Layout.Alignment) this.parentAdapter);
                    this.textLayout = createLayoutForText;
                    if (createLayoutForText != null && createLayoutForText.getLineCount() > 0) {
                        if (this.currentBlock.numLayout != null && this.currentBlock.numLayout.getLineCount() > 0) {
                            this.numOffsetY = (this.currentBlock.numLayout.getLineAscent(0) + AndroidUtilities.dp(2.5f)) - this.textLayout.getLineAscent(0);
                        }
                        i3 = this.textLayout.getHeight() + AndroidUtilities.dp(8.0f);
                    }
                    if (this.currentBlock.parent.items.get(this.currentBlock.parent.items.size() - 1) == this.currentBlock) {
                        i7 += AndroidUtilities.dp(8.0f);
                    }
                    if (this.currentBlock.index == 0 && this.currentBlock.parent.level == 0) {
                        i7 += AndroidUtilities.dp(10.0f);
                    }
                    i6 = i7;
                } else {
                    if (this.currentBlock.blockItem != null) {
                        this.blockX = this.textX;
                        this.blockY = this.textY;
                        RecyclerView.ViewHolder viewHolder = this.blockLayout;
                        if (viewHolder != null) {
                            if (viewHolder.itemView instanceof BlockParagraphCell) {
                                this.blockY -= AndroidUtilities.dp(8.0f);
                                if (!ArticleViewer.this.isRtl) {
                                    this.blockX -= AndroidUtilities.dp(18.0f);
                                }
                                i9 += AndroidUtilities.dp(18.0f);
                                i4 = 0 - AndroidUtilities.dp(8.0f);
                            } else {
                                if ((this.blockLayout.itemView instanceof BlockHeaderCell) || (this.blockLayout.itemView instanceof BlockSubheaderCell) || (this.blockLayout.itemView instanceof BlockTitleCell) || (this.blockLayout.itemView instanceof BlockSubtitleCell)) {
                                    if (!ArticleViewer.this.isRtl) {
                                        this.blockX -= AndroidUtilities.dp(18.0f);
                                    }
                                    i5 = AndroidUtilities.dp(18.0f);
                                } else if (ArticleViewer.this.isListItemBlock(this.currentBlock.blockItem)) {
                                    this.blockX = 0;
                                    this.blockY = 0;
                                    this.textY = 0;
                                    i4 = ((this.currentBlock.index == 0 && this.currentBlock.parent.level == 0) ? 0 - AndroidUtilities.dp(10.0f) : 0) - AndroidUtilities.dp(8.0f);
                                    i9 = size;
                                } else {
                                    if (this.blockLayout.itemView instanceof BlockTableCell) {
                                        this.blockX -= AndroidUtilities.dp(18.0f);
                                        i5 = AndroidUtilities.dp(36.0f);
                                    }
                                    i4 = 0;
                                }
                                i9 += i5;
                                i4 = 0;
                            }
                            this.blockLayout.itemView.measure(View.MeasureSpec.makeMeasureSpec(i9, 1073741824), View.MeasureSpec.makeMeasureSpec(0, 0));
                            if ((this.blockLayout.itemView instanceof BlockParagraphCell) && this.currentBlock.numLayout != null && this.currentBlock.numLayout.getLineCount() > 0) {
                                BlockParagraphCell blockParagraphCell = (BlockParagraphCell) this.blockLayout.itemView;
                                if (blockParagraphCell.textLayout != null && blockParagraphCell.textLayout.getLineCount() > 0) {
                                    this.numOffsetY = (this.currentBlock.numLayout.getLineAscent(0) + AndroidUtilities.dp(2.5f)) - blockParagraphCell.textLayout.getLineAscent(0);
                                }
                            }
                            if (this.currentBlock.blockItem instanceof TLRPC.TL_pageBlockDetails) {
                                this.verticalAlign = true;
                                this.blockY = 0;
                                if (this.currentBlock.index == 0 && this.currentBlock.parent.level == 0) {
                                    i4 -= AndroidUtilities.dp(10.0f);
                                }
                                i4 -= AndroidUtilities.dp(8.0f);
                            } else if (this.blockLayout.itemView instanceof BlockOrderedListItemCell) {
                                this.verticalAlign = ((BlockOrderedListItemCell) this.blockLayout.itemView).verticalAlign;
                            } else if (this.blockLayout.itemView instanceof BlockListItemCell) {
                                this.verticalAlign = ((BlockListItemCell) this.blockLayout.itemView).verticalAlign;
                            }
                            if (this.verticalAlign && this.currentBlock.numLayout != null) {
                                this.textY = ((this.blockLayout.itemView.getMeasuredHeight() - this.currentBlock.numLayout.getHeight()) / 2) - AndroidUtilities.dp(4.0f);
                                this.drawDot = false;
                            }
                            i7 = i4 + this.blockLayout.itemView.getMeasuredHeight();
                        }
                        i3 = AndroidUtilities.dp(8.0f);
                    }
                    if (this.currentBlock.parent.items.get(this.currentBlock.parent.items.size() - 1) == this.currentBlock) {
                    }
                    i7 += AndroidUtilities.dp(10.0f);
                    i6 = i7;
                }
                i7 += i3;
                if (this.currentBlock.parent.items.get(this.currentBlock.parent.items.size() - 1) == this.currentBlock) {
                }
                i7 += AndroidUtilities.dp(10.0f);
                i6 = i7;
            }
            setMeasuredDimension(size, i6);
        }

        /* access modifiers changed from: protected */
        public void onLayout(boolean z, int i, int i2, int i3, int i4) {
            RecyclerView.ViewHolder viewHolder = this.blockLayout;
            if (viewHolder != null) {
                View view = viewHolder.itemView;
                int i5 = this.blockX;
                view.layout(i5, this.blockY, this.blockLayout.itemView.getMeasuredWidth() + i5, this.blockY + this.blockLayout.itemView.getMeasuredHeight());
            }
        }

        /* access modifiers changed from: protected */
        public void onDraw(Canvas canvas) {
            if (this.currentBlock != null) {
                int measuredWidth = getMeasuredWidth();
                if (this.currentBlock.numLayout != null) {
                    canvas.save();
                    int i = 0;
                    if (ArticleViewer.this.isRtl) {
                        float dp = (float) (((measuredWidth - AndroidUtilities.dp(15.0f)) - this.currentBlock.parent.maxNumWidth) - (this.currentBlock.parent.level * AndroidUtilities.dp(12.0f)));
                        int i2 = this.textY + this.numOffsetY;
                        if (this.drawDot) {
                            i = AndroidUtilities.dp(1.0f);
                        }
                        canvas.translate(dp, (float) (i2 - i));
                    } else {
                        float dp2 = (float) (((AndroidUtilities.dp(15.0f) + this.currentBlock.parent.maxNumWidth) - ((int) Math.ceil((double) this.currentBlock.numLayout.getLineWidth(0)))) + (this.currentBlock.parent.level * AndroidUtilities.dp(12.0f)));
                        int i3 = this.textY + this.numOffsetY;
                        if (this.drawDot) {
                            i = AndroidUtilities.dp(1.0f);
                        }
                        canvas.translate(dp2, (float) (i3 - i));
                    }
                    this.currentBlock.numLayout.draw(canvas);
                    canvas.restore();
                }
                if (this.textLayout != null) {
                    canvas.save();
                    canvas.translate((float) this.textX, (float) this.textY);
                    this.textLayout.draw(canvas);
                    canvas.restore();
                }
            }
        }

        public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo accessibilityNodeInfo) {
            super.onInitializeAccessibilityNodeInfo(accessibilityNodeInfo);
            accessibilityNodeInfo.setEnabled(true);
            DrawingText drawingText = this.textLayout;
            if (drawingText != null) {
                accessibilityNodeInfo.setText(drawingText.getText());
            }
        }
    }

    /* access modifiers changed from: private */
    public class BlockOrderedListItemCell extends ViewGroup {
        private RecyclerView.ViewHolder blockLayout;
        private int blockX;
        private int blockY;
        private TL_pageBlockOrderedListItem currentBlock;
        private int currentBlockType;
        private int numOffsetY;
        private WebpageAdapter parentAdapter;
        private boolean parentIsList;
        private DrawingText textLayout;
        private int textX;
        private int textY;
        private boolean verticalAlign;

        public BlockOrderedListItemCell(Context context, WebpageAdapter webpageAdapter) {
            super(context);
            this.parentAdapter = webpageAdapter;
            setWillNotDraw(false);
        }

        public void setBlock(TL_pageBlockOrderedListItem tL_pageBlockOrderedListItem) {
            if (this.currentBlock != tL_pageBlockOrderedListItem) {
                this.currentBlock = tL_pageBlockOrderedListItem;
                RecyclerView.ViewHolder viewHolder = this.blockLayout;
                if (viewHolder != null) {
                    removeView(viewHolder.itemView);
                    this.blockLayout = null;
                }
                if (this.currentBlock.blockItem != null) {
                    int typeForBlock = this.parentAdapter.getTypeForBlock(this.currentBlock.blockItem);
                    this.currentBlockType = typeForBlock;
                    RecyclerView.ViewHolder onCreateViewHolder = this.parentAdapter.onCreateViewHolder(this, typeForBlock);
                    this.blockLayout = onCreateViewHolder;
                    addView(onCreateViewHolder.itemView);
                }
            }
            if (this.currentBlock.blockItem != null) {
                this.parentAdapter.bindBlockToHolder(this.currentBlockType, this.blockLayout, this.currentBlock.blockItem, 0, 0);
            }
            requestLayout();
        }

        public boolean onTouchEvent(MotionEvent motionEvent) {
            if (ArticleViewer.this.checkLayoutForLinks(motionEvent, this, this.textLayout, this.textX, this.textY)) {
                return true;
            }
            return super.onTouchEvent(motionEvent);
        }

        /* access modifiers changed from: protected */
        /* JADX WARNING: Removed duplicated region for block: B:102:0x0365  */
        public void onMeasure(int i, int i2) {
            int i3;
            int i4;
            int i5;
            int size = View.MeasureSpec.getSize(i);
            TL_pageBlockOrderedListItem tL_pageBlockOrderedListItem = this.currentBlock;
            int i6 = 1;
            if (tL_pageBlockOrderedListItem != null) {
                this.textLayout = null;
                int i7 = 0;
                this.textY = (tL_pageBlockOrderedListItem.index == 0 && this.currentBlock.parent.level == 0) ? AndroidUtilities.dp(10.0f) : 0;
                this.numOffsetY = 0;
                if (!(this.currentBlock.parent.lastMaxNumCalcWidth == size && this.currentBlock.parent.lastFontSize == ArticleViewer.this.selectedFontSize)) {
                    this.currentBlock.parent.lastMaxNumCalcWidth = size;
                    this.currentBlock.parent.lastFontSize = ArticleViewer.this.selectedFontSize;
                    this.currentBlock.parent.maxNumWidth = 0;
                    int size2 = this.currentBlock.parent.items.size();
                    for (int i8 = 0; i8 < size2; i8++) {
                        TL_pageBlockOrderedListItem tL_pageBlockOrderedListItem2 = (TL_pageBlockOrderedListItem) this.currentBlock.parent.items.get(i8);
                        if (tL_pageBlockOrderedListItem2.num != null) {
                            tL_pageBlockOrderedListItem2.numLayout = ArticleViewer.this.createLayoutForText(this, tL_pageBlockOrderedListItem2.num, null, size - AndroidUtilities.dp(54.0f), this.currentBlock, this.parentAdapter);
                            this.currentBlock.parent.maxNumWidth = Math.max(this.currentBlock.parent.maxNumWidth, (int) Math.ceil((double) tL_pageBlockOrderedListItem2.numLayout.getLineWidth(0)));
                        }
                    }
                    this.currentBlock.parent.maxNumWidth = Math.max(this.currentBlock.parent.maxNumWidth, (int) Math.ceil((double) ArticleViewer.listTextNumPaint.measureText("00.")));
                }
                if (ArticleViewer.this.isRtl) {
                    this.textX = AndroidUtilities.dp(18.0f);
                } else {
                    this.textX = AndroidUtilities.dp(24.0f) + this.currentBlock.parent.maxNumWidth + (this.currentBlock.parent.level * AndroidUtilities.dp(20.0f));
                }
                this.verticalAlign = false;
                int dp = (size - AndroidUtilities.dp(18.0f)) - this.textX;
                if (ArticleViewer.this.isRtl) {
                    dp -= (AndroidUtilities.dp(6.0f) + this.currentBlock.parent.maxNumWidth) + (this.currentBlock.parent.level * AndroidUtilities.dp(20.0f));
                }
                int i9 = dp;
                if (this.currentBlock.textItem != null) {
                    DrawingText createLayoutForText = ArticleViewer.this.createLayoutForText((ArticleViewer) this, (View) null, (CharSequence) this.currentBlock.textItem, (TLRPC.RichText) i9, (int) this.currentBlock, (TLRPC.PageBlock) (ArticleViewer.this.isRtl ? StaticLayoutEx.ALIGN_RIGHT() : Layout.Alignment.ALIGN_NORMAL), (Layout.Alignment) this.parentAdapter);
                    this.textLayout = createLayoutForText;
                    if (createLayoutForText != null && createLayoutForText.getLineCount() > 0) {
                        if (this.currentBlock.numLayout != null && this.currentBlock.numLayout.getLineCount() > 0) {
                            this.numOffsetY = this.currentBlock.numLayout.getLineAscent(0) - this.textLayout.getLineAscent(0);
                        }
                        i3 = this.textLayout.getHeight() + AndroidUtilities.dp(8.0f);
                    }
                    if (this.currentBlock.parent.items.get(this.currentBlock.parent.items.size() - 1) == this.currentBlock) {
                        i7 += AndroidUtilities.dp(8.0f);
                    }
                    if (this.currentBlock.index == 0 && this.currentBlock.parent.level == 0) {
                        i7 += AndroidUtilities.dp(10.0f);
                    }
                    i6 = i7;
                } else {
                    if (this.currentBlock.blockItem != null) {
                        this.blockX = this.textX;
                        this.blockY = this.textY;
                        RecyclerView.ViewHolder viewHolder = this.blockLayout;
                        if (viewHolder != null) {
                            if (viewHolder.itemView instanceof BlockParagraphCell) {
                                this.blockY -= AndroidUtilities.dp(8.0f);
                                if (!ArticleViewer.this.isRtl) {
                                    this.blockX -= AndroidUtilities.dp(18.0f);
                                }
                                i9 += AndroidUtilities.dp(18.0f);
                                i4 = 0 - AndroidUtilities.dp(8.0f);
                            } else {
                                if ((this.blockLayout.itemView instanceof BlockHeaderCell) || (this.blockLayout.itemView instanceof BlockSubheaderCell) || (this.blockLayout.itemView instanceof BlockTitleCell) || (this.blockLayout.itemView instanceof BlockSubtitleCell)) {
                                    if (!ArticleViewer.this.isRtl) {
                                        this.blockX -= AndroidUtilities.dp(18.0f);
                                    }
                                    i5 = AndroidUtilities.dp(18.0f);
                                } else if (ArticleViewer.this.isListItemBlock(this.currentBlock.blockItem)) {
                                    this.blockX = 0;
                                    this.blockY = 0;
                                    this.textY = 0;
                                    i4 = 0 - AndroidUtilities.dp(8.0f);
                                    i9 = size;
                                } else {
                                    if (this.blockLayout.itemView instanceof BlockTableCell) {
                                        this.blockX -= AndroidUtilities.dp(18.0f);
                                        i5 = AndroidUtilities.dp(36.0f);
                                    }
                                    i4 = 0;
                                }
                                i9 += i5;
                                i4 = 0;
                            }
                            this.blockLayout.itemView.measure(View.MeasureSpec.makeMeasureSpec(i9, 1073741824), View.MeasureSpec.makeMeasureSpec(0, 0));
                            if ((this.blockLayout.itemView instanceof BlockParagraphCell) && this.currentBlock.numLayout != null && this.currentBlock.numLayout.getLineCount() > 0) {
                                BlockParagraphCell blockParagraphCell = (BlockParagraphCell) this.blockLayout.itemView;
                                if (blockParagraphCell.textLayout != null && blockParagraphCell.textLayout.getLineCount() > 0) {
                                    this.numOffsetY = this.currentBlock.numLayout.getLineAscent(0) - blockParagraphCell.textLayout.getLineAscent(0);
                                }
                            }
                            if (this.currentBlock.blockItem instanceof TLRPC.TL_pageBlockDetails) {
                                this.verticalAlign = true;
                                this.blockY = 0;
                                i4 -= AndroidUtilities.dp(8.0f);
                            } else if (this.blockLayout.itemView instanceof BlockOrderedListItemCell) {
                                this.verticalAlign = ((BlockOrderedListItemCell) this.blockLayout.itemView).verticalAlign;
                            } else if (this.blockLayout.itemView instanceof BlockListItemCell) {
                                this.verticalAlign = ((BlockListItemCell) this.blockLayout.itemView).verticalAlign;
                            }
                            if (this.verticalAlign && this.currentBlock.numLayout != null) {
                                this.textY = (this.blockLayout.itemView.getMeasuredHeight() - this.currentBlock.numLayout.getHeight()) / 2;
                            }
                            i7 = this.blockLayout.itemView.getMeasuredHeight() + i4;
                        }
                        i3 = AndroidUtilities.dp(8.0f);
                    }
                    if (this.currentBlock.parent.items.get(this.currentBlock.parent.items.size() - 1) == this.currentBlock) {
                    }
                    i7 += AndroidUtilities.dp(10.0f);
                    i6 = i7;
                }
                i7 += i3;
                if (this.currentBlock.parent.items.get(this.currentBlock.parent.items.size() - 1) == this.currentBlock) {
                }
                i7 += AndroidUtilities.dp(10.0f);
                i6 = i7;
            }
            setMeasuredDimension(size, i6);
        }

        /* access modifiers changed from: protected */
        public void onLayout(boolean z, int i, int i2, int i3, int i4) {
            RecyclerView.ViewHolder viewHolder = this.blockLayout;
            if (viewHolder != null) {
                View view = viewHolder.itemView;
                int i5 = this.blockX;
                view.layout(i5, this.blockY, this.blockLayout.itemView.getMeasuredWidth() + i5, this.blockY + this.blockLayout.itemView.getMeasuredHeight());
            }
        }

        /* access modifiers changed from: protected */
        public void onDraw(Canvas canvas) {
            if (this.currentBlock != null) {
                int measuredWidth = getMeasuredWidth();
                if (this.currentBlock.numLayout != null) {
                    canvas.save();
                    if (ArticleViewer.this.isRtl) {
                        canvas.translate((float) (((measuredWidth - AndroidUtilities.dp(18.0f)) - this.currentBlock.parent.maxNumWidth) - (this.currentBlock.parent.level * AndroidUtilities.dp(20.0f))), (float) (this.textY + this.numOffsetY));
                    } else {
                        canvas.translate((float) (((AndroidUtilities.dp(18.0f) + this.currentBlock.parent.maxNumWidth) - ((int) Math.ceil((double) this.currentBlock.numLayout.getLineWidth(0)))) + (this.currentBlock.parent.level * AndroidUtilities.dp(20.0f))), (float) (this.textY + this.numOffsetY));
                    }
                    this.currentBlock.numLayout.draw(canvas);
                    canvas.restore();
                }
                if (this.textLayout != null) {
                    canvas.save();
                    canvas.translate((float) this.textX, (float) this.textY);
                    this.textLayout.draw(canvas);
                    canvas.restore();
                }
            }
        }

        public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo accessibilityNodeInfo) {
            super.onInitializeAccessibilityNodeInfo(accessibilityNodeInfo);
            accessibilityNodeInfo.setEnabled(true);
            DrawingText drawingText = this.textLayout;
            if (drawingText != null) {
                accessibilityNodeInfo.setText(drawingText.getText());
            }
        }
    }

    /* access modifiers changed from: private */
    public class BlockDetailsCell extends View implements Drawable.Callback {
        private AnimatedArrowDrawable arrow;
        private TLRPC.TL_pageBlockDetails currentBlock;
        private WebpageAdapter parentAdapter;
        private DrawingText textLayout;
        private int textX = AndroidUtilities.dp(50.0f);
        private int textY = (AndroidUtilities.dp(11.0f) + 1);

        public void scheduleDrawable(Drawable drawable, Runnable runnable, long j) {
        }

        public void unscheduleDrawable(Drawable drawable, Runnable runnable) {
        }

        public BlockDetailsCell(Context context, WebpageAdapter webpageAdapter) {
            super(context);
            this.parentAdapter = webpageAdapter;
            this.arrow = new AnimatedArrowDrawable(ArticleViewer.this.getGrayTextColor(), true);
        }

        public void invalidateDrawable(Drawable drawable) {
            invalidate();
        }

        public void setBlock(TLRPC.TL_pageBlockDetails tL_pageBlockDetails) {
            this.currentBlock = tL_pageBlockDetails;
            this.arrow.setAnimationProgress(tL_pageBlockDetails.open ? 0.0f : 1.0f);
            this.arrow.setCallback(this);
            requestLayout();
        }

        public boolean onTouchEvent(MotionEvent motionEvent) {
            return ArticleViewer.this.checkLayoutForLinks(motionEvent, this, this.textLayout, this.textX, this.textY) || super.onTouchEvent(motionEvent);
        }

        /* access modifiers changed from: protected */
        public void onMeasure(int i, int i2) {
            int size = View.MeasureSpec.getSize(i);
            int dp = AndroidUtilities.dp(39.0f);
            TLRPC.TL_pageBlockDetails tL_pageBlockDetails = this.currentBlock;
            if (tL_pageBlockDetails != null) {
                DrawingText createLayoutForText = ArticleViewer.this.createLayoutForText((ArticleViewer) this, (View) null, (CharSequence) tL_pageBlockDetails.title, (TLRPC.RichText) (size - AndroidUtilities.dp(52.0f)), (int) this.currentBlock, (TLRPC.PageBlock) (ArticleViewer.this.isRtl ? StaticLayoutEx.ALIGN_RIGHT() : Layout.Alignment.ALIGN_NORMAL), (Layout.Alignment) this.parentAdapter);
                this.textLayout = createLayoutForText;
                if (createLayoutForText != null) {
                    dp = Math.max(dp, AndroidUtilities.dp(21.0f) + this.textLayout.getHeight());
                    this.textY = ((this.textLayout.getHeight() + AndroidUtilities.dp(21.0f)) - this.textLayout.getHeight()) / 2;
                }
            }
            setMeasuredDimension(size, dp + 1);
        }

        /* access modifiers changed from: protected */
        public void onDraw(Canvas canvas) {
            if (this.currentBlock != null) {
                canvas.save();
                canvas.translate((float) AndroidUtilities.dp(18.0f), (float) (((getMeasuredHeight() - AndroidUtilities.dp(13.0f)) - 1) / 2));
                this.arrow.draw(canvas);
                canvas.restore();
                if (this.textLayout != null) {
                    canvas.save();
                    canvas.translate((float) this.textX, (float) this.textY);
                    this.textLayout.draw(canvas);
                    canvas.restore();
                }
                float measuredHeight = (float) (getMeasuredHeight() - 1);
                canvas.drawLine(0.0f, measuredHeight, (float) getMeasuredWidth(), measuredHeight, ArticleViewer.dividerPaint);
            }
        }
    }

    /* access modifiers changed from: private */
    public class BlockDetailsBottomCell extends View {
        private RectF rect = new RectF();

        public BlockDetailsBottomCell(Context context) {
            super(context);
        }

        /* access modifiers changed from: protected */
        public void onMeasure(int i, int i2) {
            setMeasuredDimension(View.MeasureSpec.getSize(i), AndroidUtilities.dp(4.0f) + 1);
        }

        /* access modifiers changed from: protected */
        public void onDraw(Canvas canvas) {
            canvas.drawLine(0.0f, 0.0f, (float) getMeasuredWidth(), 0.0f, ArticleViewer.dividerPaint);
        }
    }

    /* access modifiers changed from: private */
    public class BlockRelatedArticlesShadowCell extends View {
        private CombinedDrawable shadowDrawable;

        public BlockRelatedArticlesShadowCell(Context context) {
            super(context);
            CombinedDrawable combinedDrawable = new CombinedDrawable(new ColorDrawable(-986896), Theme.getThemedDrawable(context, (int) R.drawable.greydivider_bottom, -16777216));
            this.shadowDrawable = combinedDrawable;
            combinedDrawable.setFullsize(true);
            setBackgroundDrawable(this.shadowDrawable);
        }

        /* access modifiers changed from: protected */
        public void onMeasure(int i, int i2) {
            setMeasuredDimension(View.MeasureSpec.getSize(i), AndroidUtilities.dp(12.0f));
            int selectedColor = ArticleViewer.this.getSelectedColor();
            if (selectedColor == 0) {
                Theme.setCombinedDrawableColor(this.shadowDrawable, -986896, false);
            } else if (selectedColor == 1) {
                Theme.setCombinedDrawableColor(this.shadowDrawable, -1712440, false);
            } else if (selectedColor == 2) {
                Theme.setCombinedDrawableColor(this.shadowDrawable, -15000805, false);
            }
        }
    }

    /* access modifiers changed from: private */
    public class BlockRelatedArticlesHeaderCell extends View {
        private TLRPC.TL_pageBlockRelatedArticles currentBlock;
        private WebpageAdapter parentAdapter;
        private DrawingText textLayout;
        private int textX = AndroidUtilities.dp(18.0f);
        private int textY;

        public BlockRelatedArticlesHeaderCell(Context context, WebpageAdapter webpageAdapter) {
            super(context);
            this.parentAdapter = webpageAdapter;
        }

        public void setBlock(TLRPC.TL_pageBlockRelatedArticles tL_pageBlockRelatedArticles) {
            this.currentBlock = tL_pageBlockRelatedArticles;
            requestLayout();
        }

        public boolean onTouchEvent(MotionEvent motionEvent) {
            return ArticleViewer.this.checkLayoutForLinks(motionEvent, this, this.textLayout, this.textX, this.textY) || super.onTouchEvent(motionEvent);
        }

        /* access modifiers changed from: protected */
        public void onMeasure(int i, int i2) {
            int size = View.MeasureSpec.getSize(i);
            TLRPC.TL_pageBlockRelatedArticles tL_pageBlockRelatedArticles = this.currentBlock;
            if (tL_pageBlockRelatedArticles != null) {
                DrawingText createLayoutForText = ArticleViewer.this.createLayoutForText(this, null, tL_pageBlockRelatedArticles.title, size - AndroidUtilities.dp(52.0f), 0, this.currentBlock, Layout.Alignment.ALIGN_NORMAL, 1, this.parentAdapter);
                this.textLayout = createLayoutForText;
                if (createLayoutForText != null) {
                    this.textY = AndroidUtilities.dp(6.0f) + ((AndroidUtilities.dp(32.0f) - this.textLayout.getHeight()) / 2);
                }
            }
            if (this.textLayout != null) {
                setMeasuredDimension(size, AndroidUtilities.dp(38.0f));
            } else {
                setMeasuredDimension(size, 1);
            }
        }

        /* access modifiers changed from: protected */
        public void onDraw(Canvas canvas) {
            if (this.currentBlock != null && this.textLayout != null) {
                canvas.save();
                canvas.translate((float) this.textX, (float) this.textY);
                this.textLayout.draw(canvas);
                canvas.restore();
            }
        }
    }

    /* access modifiers changed from: private */
    public class BlockRelatedArticlesCell extends View {
        private int additionalHeight;
        private TL_pageBlockRelatedArticlesChild currentBlock;
        private boolean divider;
        private boolean drawImage;
        private ImageReceiver imageView;
        private WebpageAdapter parentAdapter;
        private DrawingText textLayout;
        private DrawingText textLayout2;
        private int textOffset;
        private int textX = AndroidUtilities.dp(18.0f);
        private int textY = AndroidUtilities.dp(10.0f);

        public BlockRelatedArticlesCell(Context context, WebpageAdapter webpageAdapter) {
            super(context);
            this.parentAdapter = webpageAdapter;
            ImageReceiver imageReceiver = new ImageReceiver(this);
            this.imageView = imageReceiver;
            imageReceiver.setRoundRadius(AndroidUtilities.dp(6.0f));
        }

        public void setBlock(TL_pageBlockRelatedArticlesChild tL_pageBlockRelatedArticlesChild) {
            this.currentBlock = tL_pageBlockRelatedArticlesChild;
            requestLayout();
        }

        /* access modifiers changed from: protected */
        public void onMeasure(int i, int i2) {
            int i3;
            int i4;
            boolean z;
            String str;
            int size = View.MeasureSpec.getSize(i);
            this.divider = this.currentBlock.num != this.currentBlock.parent.articles.size() - 1;
            TLRPC.TL_pageRelatedArticle tL_pageRelatedArticle = this.currentBlock.parent.articles.get(this.currentBlock.num);
            this.additionalHeight = 0;
            if (ArticleViewer.this.selectedFontSize == 0) {
                this.additionalHeight = -AndroidUtilities.dp(4.0f);
            } else if (ArticleViewer.this.selectedFontSize == 1) {
                this.additionalHeight = -AndroidUtilities.dp(2.0f);
            } else if (ArticleViewer.this.selectedFontSize == 3) {
                this.additionalHeight = AndroidUtilities.dp(2.0f);
            } else if (ArticleViewer.this.selectedFontSize == 4) {
                this.additionalHeight = AndroidUtilities.dp(4.0f);
            }
            TLRPC.PhotoSize photoSize = null;
            TLRPC.Photo photoWithId = tL_pageRelatedArticle.photo_id != 0 ? ArticleViewer.this.getPhotoWithId(tL_pageRelatedArticle.photo_id) : null;
            if (photoWithId != null) {
                this.drawImage = true;
                TLRPC.PhotoSize closestPhotoSizeWithSize = FileLoader.getClosestPhotoSizeWithSize(photoWithId.sizes, AndroidUtilities.getPhotoSize());
                TLRPC.PhotoSize closestPhotoSizeWithSize2 = FileLoader.getClosestPhotoSizeWithSize(photoWithId.sizes, 80, true);
                if (closestPhotoSizeWithSize != closestPhotoSizeWithSize2) {
                    photoSize = closestPhotoSizeWithSize2;
                }
                this.imageView.setImage(ImageLocation.getForPhoto(closestPhotoSizeWithSize, photoWithId), "64_64", ImageLocation.getForPhoto(photoSize, photoWithId), "64_64_b", closestPhotoSizeWithSize.size, null, ArticleViewer.this.currentPage, 1);
            } else {
                this.drawImage = false;
            }
            int dp = AndroidUtilities.dp(60.0f);
            int dp2 = size - AndroidUtilities.dp(36.0f);
            if (this.drawImage) {
                int dp3 = AndroidUtilities.dp(44.0f);
                this.imageView.setImageCoords((size - dp3) - AndroidUtilities.dp(8.0f), AndroidUtilities.dp(8.0f), dp3, dp3);
                dp2 -= this.imageView.getImageWidth() + AndroidUtilities.dp(6.0f);
            }
            int dp4 = AndroidUtilities.dp(18.0f);
            if (tL_pageRelatedArticle.title != null) {
                i3 = dp;
                this.textLayout = ArticleViewer.this.createLayoutForText(this, tL_pageRelatedArticle.title, null, dp2, this.textY, this.currentBlock, Layout.Alignment.ALIGN_NORMAL, 3, this.parentAdapter);
            } else {
                i3 = dp;
            }
            DrawingText drawingText = this.textLayout;
            if (drawingText != null) {
                int lineCount = drawingText.getLineCount();
                int i5 = 4 - lineCount;
                this.textOffset = this.textLayout.getHeight() + AndroidUtilities.dp(6.0f) + this.additionalHeight;
                dp4 += this.textLayout.getHeight();
                int i6 = 0;
                while (true) {
                    if (i6 >= lineCount) {
                        z = false;
                        break;
                    } else if (this.textLayout.getLineLeft(i6) != 0.0f) {
                        z = true;
                        break;
                    } else {
                        i6++;
                    }
                }
                i4 = i5;
            } else {
                this.textOffset = 0;
                z = false;
                i4 = 4;
            }
            if (tL_pageRelatedArticle.published_date != 0 && !TextUtils.isEmpty(tL_pageRelatedArticle.author)) {
                str = LocaleController.formatString("ArticleDateByAuthor", R.string.ArticleDateByAuthor, LocaleController.getInstance().chatFullDate.format(((long) tL_pageRelatedArticle.published_date) * 1000), tL_pageRelatedArticle.author);
            } else if (!TextUtils.isEmpty(tL_pageRelatedArticle.author)) {
                str = LocaleController.formatString("ArticleByAuthor", R.string.ArticleByAuthor, tL_pageRelatedArticle.author);
            } else if (tL_pageRelatedArticle.published_date != 0) {
                str = LocaleController.getInstance().chatFullDate.format(((long) tL_pageRelatedArticle.published_date) * 1000);
            } else if (!TextUtils.isEmpty(tL_pageRelatedArticle.description)) {
                str = tL_pageRelatedArticle.description;
            } else {
                str = tL_pageRelatedArticle.url;
            }
            ArticleViewer articleViewer = ArticleViewer.this;
            DrawingText createLayoutForText = articleViewer.createLayoutForText(this, str, null, dp2, this.textOffset + this.textY, this.currentBlock, (articleViewer.isRtl || z) ? StaticLayoutEx.ALIGN_RIGHT() : Layout.Alignment.ALIGN_NORMAL, i4, this.parentAdapter);
            this.textLayout2 = createLayoutForText;
            if (createLayoutForText != null) {
                dp4 += createLayoutForText.getHeight();
                if (this.textLayout != null) {
                    dp4 += AndroidUtilities.dp(6.0f) + this.additionalHeight;
                }
            }
            setMeasuredDimension(size, Math.max(i3, dp4) + (this.divider ? 1 : 0));
        }

        /* access modifiers changed from: protected */
        public void onDraw(Canvas canvas) {
            if (this.currentBlock != null) {
                if (this.drawImage) {
                    this.imageView.draw(canvas);
                }
                canvas.save();
                canvas.translate((float) this.textX, (float) AndroidUtilities.dp(10.0f));
                DrawingText drawingText = this.textLayout;
                if (drawingText != null) {
                    drawingText.draw(canvas);
                }
                if (this.textLayout2 != null) {
                    canvas.translate(0.0f, (float) this.textOffset);
                    this.textLayout2.draw(canvas);
                }
                canvas.restore();
                if (this.divider) {
                    canvas.drawLine(ArticleViewer.this.isRtl ? 0.0f : (float) AndroidUtilities.dp(17.0f), (float) (getMeasuredHeight() - 1), (float) (getMeasuredWidth() - (ArticleViewer.this.isRtl ? AndroidUtilities.dp(17.0f) : 0)), (float) (getMeasuredHeight() - 1), ArticleViewer.dividerPaint);
                }
            }
        }
    }

    /* access modifiers changed from: private */
    public class BlockHeaderCell extends View {
        private TLRPC.TL_pageBlockHeader currentBlock;
        private WebpageAdapter parentAdapter;
        private DrawingText textLayout;
        private int textX = AndroidUtilities.dp(18.0f);
        private int textY = AndroidUtilities.dp(8.0f);

        public BlockHeaderCell(Context context, WebpageAdapter webpageAdapter) {
            super(context);
            this.parentAdapter = webpageAdapter;
        }

        public void setBlock(TLRPC.TL_pageBlockHeader tL_pageBlockHeader) {
            this.currentBlock = tL_pageBlockHeader;
            requestLayout();
        }

        public boolean onTouchEvent(MotionEvent motionEvent) {
            return ArticleViewer.this.checkLayoutForLinks(motionEvent, this, this.textLayout, this.textX, this.textY) || super.onTouchEvent(motionEvent);
        }

        /* access modifiers changed from: protected */
        public void onMeasure(int i, int i2) {
            int size = View.MeasureSpec.getSize(i);
            TLRPC.TL_pageBlockHeader tL_pageBlockHeader = this.currentBlock;
            int i3 = 0;
            if (tL_pageBlockHeader != null) {
                DrawingText createLayoutForText = ArticleViewer.this.createLayoutForText((ArticleViewer) this, (View) null, (CharSequence) tL_pageBlockHeader.text, (TLRPC.RichText) (size - AndroidUtilities.dp(36.0f)), (int) this.currentBlock, (TLRPC.PageBlock) (ArticleViewer.this.isRtl ? StaticLayoutEx.ALIGN_RIGHT() : Layout.Alignment.ALIGN_NORMAL), (Layout.Alignment) this.parentAdapter);
                this.textLayout = createLayoutForText;
                if (createLayoutForText != null) {
                    i3 = 0 + AndroidUtilities.dp(16.0f) + this.textLayout.getHeight();
                }
            } else {
                i3 = 1;
            }
            setMeasuredDimension(size, i3);
        }

        /* access modifiers changed from: protected */
        public void onDraw(Canvas canvas) {
            if (this.currentBlock != null && this.textLayout != null) {
                canvas.save();
                canvas.translate((float) this.textX, (float) this.textY);
                this.textLayout.draw(canvas);
                canvas.restore();
            }
        }

        public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo accessibilityNodeInfo) {
            super.onInitializeAccessibilityNodeInfo(accessibilityNodeInfo);
            accessibilityNodeInfo.setEnabled(true);
            if (this.textLayout != null) {
                accessibilityNodeInfo.setText(((Object) this.textLayout.getText()) + ", " + LocaleController.getString("AccDescrIVHeading", R.string.AccDescrIVHeading));
            }
        }
    }

    /* access modifiers changed from: private */
    public class BlockDividerCell extends View {
        private RectF rect = new RectF();

        public BlockDividerCell(Context context) {
            super(context);
        }

        /* access modifiers changed from: protected */
        public void onMeasure(int i, int i2) {
            setMeasuredDimension(View.MeasureSpec.getSize(i), AndroidUtilities.dp(18.0f));
        }

        /* access modifiers changed from: protected */
        public void onDraw(Canvas canvas) {
            int measuredWidth = getMeasuredWidth() / 3;
            this.rect.set((float) measuredWidth, (float) AndroidUtilities.dp(8.0f), (float) (measuredWidth * 2), (float) AndroidUtilities.dp(10.0f));
            canvas.drawRoundRect(this.rect, (float) AndroidUtilities.dp(1.0f), (float) AndroidUtilities.dp(1.0f), ArticleViewer.dividerPaint);
        }
    }

    /* access modifiers changed from: private */
    public class BlockSubtitleCell extends View {
        private TLRPC.TL_pageBlockSubtitle currentBlock;
        private WebpageAdapter parentAdapter;
        private DrawingText textLayout;
        private int textX = AndroidUtilities.dp(18.0f);
        private int textY = AndroidUtilities.dp(8.0f);

        public BlockSubtitleCell(Context context, WebpageAdapter webpageAdapter) {
            super(context);
            this.parentAdapter = webpageAdapter;
        }

        public void setBlock(TLRPC.TL_pageBlockSubtitle tL_pageBlockSubtitle) {
            this.currentBlock = tL_pageBlockSubtitle;
            requestLayout();
        }

        public boolean onTouchEvent(MotionEvent motionEvent) {
            return ArticleViewer.this.checkLayoutForLinks(motionEvent, this, this.textLayout, this.textX, this.textY) || super.onTouchEvent(motionEvent);
        }

        /* access modifiers changed from: protected */
        public void onMeasure(int i, int i2) {
            int size = View.MeasureSpec.getSize(i);
            TLRPC.TL_pageBlockSubtitle tL_pageBlockSubtitle = this.currentBlock;
            int i3 = 0;
            if (tL_pageBlockSubtitle != null) {
                DrawingText createLayoutForText = ArticleViewer.this.createLayoutForText((ArticleViewer) this, (View) null, (CharSequence) tL_pageBlockSubtitle.text, (TLRPC.RichText) (size - AndroidUtilities.dp(36.0f)), (int) this.currentBlock, (TLRPC.PageBlock) (ArticleViewer.this.isRtl ? StaticLayoutEx.ALIGN_RIGHT() : Layout.Alignment.ALIGN_NORMAL), (Layout.Alignment) this.parentAdapter);
                this.textLayout = createLayoutForText;
                if (createLayoutForText != null) {
                    i3 = 0 + AndroidUtilities.dp(16.0f) + this.textLayout.getHeight();
                }
            } else {
                i3 = 1;
            }
            setMeasuredDimension(size, i3);
        }

        /* access modifiers changed from: protected */
        public void onDraw(Canvas canvas) {
            if (this.currentBlock != null && this.textLayout != null) {
                canvas.save();
                canvas.translate((float) this.textX, (float) this.textY);
                this.textLayout.draw(canvas);
                canvas.restore();
            }
        }

        public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo accessibilityNodeInfo) {
            super.onInitializeAccessibilityNodeInfo(accessibilityNodeInfo);
            accessibilityNodeInfo.setEnabled(true);
            if (this.textLayout != null) {
                accessibilityNodeInfo.setText(((Object) this.textLayout.getText()) + ", " + LocaleController.getString("AccDescrIVHeading", R.string.AccDescrIVHeading));
            }
        }
    }

    /* access modifiers changed from: private */
    public class BlockPullquoteCell extends View {
        private TLRPC.TL_pageBlockPullquote currentBlock;
        private WebpageAdapter parentAdapter;
        private DrawingText textLayout;
        private DrawingText textLayout2;
        private int textX = AndroidUtilities.dp(18.0f);
        private int textY = AndroidUtilities.dp(8.0f);
        private int textY2;

        public BlockPullquoteCell(Context context, WebpageAdapter webpageAdapter) {
            super(context);
            this.parentAdapter = webpageAdapter;
        }

        public void setBlock(TLRPC.TL_pageBlockPullquote tL_pageBlockPullquote) {
            this.currentBlock = tL_pageBlockPullquote;
            requestLayout();
        }

        public boolean onTouchEvent(MotionEvent motionEvent) {
            return ArticleViewer.this.checkLayoutForLinks(motionEvent, this, this.textLayout, this.textX, this.textY) || ArticleViewer.this.checkLayoutForLinks(motionEvent, this, this.textLayout2, this.textX, this.textY2) || super.onTouchEvent(motionEvent);
        }

        /* access modifiers changed from: protected */
        public void onMeasure(int i, int i2) {
            int i3;
            int size = View.MeasureSpec.getSize(i);
            TLRPC.TL_pageBlockPullquote tL_pageBlockPullquote = this.currentBlock;
            if (tL_pageBlockPullquote != null) {
                DrawingText createLayoutForText = ArticleViewer.this.createLayoutForText(this, null, tL_pageBlockPullquote.text, size - AndroidUtilities.dp(36.0f), this.currentBlock, this.parentAdapter);
                this.textLayout = createLayoutForText;
                i3 = 0;
                if (createLayoutForText != null) {
                    i3 = 0 + AndroidUtilities.dp(8.0f) + this.textLayout.getHeight();
                }
                DrawingText createLayoutForText2 = ArticleViewer.this.createLayoutForText(this, null, this.currentBlock.caption, size - AndroidUtilities.dp(36.0f), this.currentBlock, this.parentAdapter);
                this.textLayout2 = createLayoutForText2;
                if (createLayoutForText2 != null) {
                    this.textY2 = AndroidUtilities.dp(2.0f) + i3;
                    i3 += AndroidUtilities.dp(8.0f) + this.textLayout2.getHeight();
                }
                if (i3 != 0) {
                    i3 += AndroidUtilities.dp(8.0f);
                }
            } else {
                i3 = 1;
            }
            setMeasuredDimension(size, i3);
        }

        /* access modifiers changed from: protected */
        public void onDraw(Canvas canvas) {
            if (this.currentBlock != null) {
                if (this.textLayout != null) {
                    canvas.save();
                    canvas.translate((float) this.textX, (float) this.textY);
                    this.textLayout.draw(canvas);
                    canvas.restore();
                }
                if (this.textLayout2 != null) {
                    canvas.save();
                    canvas.translate((float) this.textX, (float) this.textY2);
                    this.textLayout2.draw(canvas);
                    canvas.restore();
                }
            }
        }
    }

    /* access modifiers changed from: private */
    public class BlockBlockquoteCell extends View {
        private TLRPC.TL_pageBlockBlockquote currentBlock;
        private WebpageAdapter parentAdapter;
        private DrawingText textLayout;
        private DrawingText textLayout2;
        private int textX;
        private int textY = AndroidUtilities.dp(8.0f);
        private int textY2;

        public BlockBlockquoteCell(Context context, WebpageAdapter webpageAdapter) {
            super(context);
            this.parentAdapter = webpageAdapter;
        }

        public void setBlock(TLRPC.TL_pageBlockBlockquote tL_pageBlockBlockquote) {
            this.currentBlock = tL_pageBlockBlockquote;
            requestLayout();
        }

        public boolean onTouchEvent(MotionEvent motionEvent) {
            return ArticleViewer.this.checkLayoutForLinks(motionEvent, this, this.textLayout, this.textX, this.textY) || ArticleViewer.this.checkLayoutForLinks(motionEvent, this, this.textLayout2, this.textX, this.textY2) || super.onTouchEvent(motionEvent);
        }

        /* access modifiers changed from: protected */
        public void onMeasure(int i, int i2) {
            int i3;
            int size = View.MeasureSpec.getSize(i);
            if (this.currentBlock != null) {
                int dp = size - AndroidUtilities.dp(50.0f);
                if (this.currentBlock.level > 0) {
                    dp -= AndroidUtilities.dp((float) (this.currentBlock.level * 14));
                }
                DrawingText createLayoutForText = ArticleViewer.this.createLayoutForText(this, null, this.currentBlock.text, dp, this.currentBlock, this.parentAdapter);
                this.textLayout = createLayoutForText;
                i3 = createLayoutForText != null ? 0 + AndroidUtilities.dp(8.0f) + this.textLayout.getHeight() : 0;
                if (this.currentBlock.level > 0) {
                    if (ArticleViewer.this.isRtl) {
                        this.textX = AndroidUtilities.dp((float) ((this.currentBlock.level * 14) + 14));
                    } else {
                        this.textX = AndroidUtilities.dp((float) (this.currentBlock.level * 14)) + AndroidUtilities.dp(32.0f);
                    }
                } else if (ArticleViewer.this.isRtl) {
                    this.textX = AndroidUtilities.dp(14.0f);
                } else {
                    this.textX = AndroidUtilities.dp(32.0f);
                }
                DrawingText createLayoutForText2 = ArticleViewer.this.createLayoutForText(this, null, this.currentBlock.caption, dp, this.currentBlock, this.parentAdapter);
                this.textLayout2 = createLayoutForText2;
                if (createLayoutForText2 != null) {
                    this.textY2 = AndroidUtilities.dp(8.0f) + i3;
                    i3 += AndroidUtilities.dp(8.0f) + this.textLayout2.getHeight();
                }
                if (i3 != 0) {
                    i3 += AndroidUtilities.dp(8.0f);
                }
            } else {
                i3 = 1;
            }
            setMeasuredDimension(size, i3);
        }

        /* access modifiers changed from: protected */
        public void onDraw(Canvas canvas) {
            if (this.currentBlock != null) {
                if (this.textLayout != null) {
                    canvas.save();
                    canvas.translate((float) this.textX, (float) this.textY);
                    this.textLayout.draw(canvas);
                    canvas.restore();
                }
                if (this.textLayout2 != null) {
                    canvas.save();
                    canvas.translate((float) this.textX, (float) this.textY2);
                    this.textLayout2.draw(canvas);
                    canvas.restore();
                }
                if (ArticleViewer.this.isRtl) {
                    int measuredWidth = getMeasuredWidth() - AndroidUtilities.dp(20.0f);
                    canvas.drawRect((float) measuredWidth, (float) AndroidUtilities.dp(6.0f), (float) (measuredWidth + AndroidUtilities.dp(2.0f)), (float) (getMeasuredHeight() - AndroidUtilities.dp(6.0f)), ArticleViewer.quoteLinePaint);
                } else {
                    canvas.drawRect((float) AndroidUtilities.dp((float) ((this.currentBlock.level * 14) + 18)), (float) AndroidUtilities.dp(6.0f), (float) AndroidUtilities.dp((float) ((this.currentBlock.level * 14) + 20)), (float) (getMeasuredHeight() - AndroidUtilities.dp(6.0f)), ArticleViewer.quoteLinePaint);
                }
                if (this.currentBlock.level > 0) {
                    canvas.drawRect((float) AndroidUtilities.dp(18.0f), 0.0f, (float) AndroidUtilities.dp(20.0f), (float) (getMeasuredHeight() - (this.currentBlock.bottom ? AndroidUtilities.dp(6.0f) : 0)), ArticleViewer.quoteLinePaint);
                }
            }
        }
    }

    /* access modifiers changed from: private */
    public class BlockPhotoCell extends FrameLayout implements DownloadController.FileDownloadProgressListener {
        private int TAG;
        boolean autoDownload;
        private int buttonPressed;
        private int buttonState;
        private int buttonX;
        private int buttonY;
        private boolean cancelLoading;
        private DrawingText captionLayout;
        private BlockChannelCell channelCell;
        private DrawingText creditLayout;
        private int creditOffset;
        private TLRPC.TL_pageBlockPhoto currentBlock;
        private String currentFilter;
        private TLRPC.Photo currentPhoto;
        private TLRPC.PhotoSize currentPhotoObject;
        private TLRPC.PhotoSize currentPhotoObjectThumb;
        private String currentThumbFilter;
        private int currentType;
        private MessageObject.GroupedMessagePosition groupPosition;
        private ImageReceiver imageView = new ImageReceiver(this);
        private boolean isFirst;
        private boolean isLast;
        private Drawable linkDrawable;
        private WebpageAdapter parentAdapter;
        private TLRPC.PageBlock parentBlock;
        private boolean photoPressed;
        private RadialProgress2 radialProgress;
        private int textX;
        private int textY;

        @Override // im.guobwnxjuc.messenger.DownloadController.FileDownloadProgressListener
        public void onProgressUpload(String str, float f, boolean z) {
        }

        public BlockPhotoCell(Context context, WebpageAdapter webpageAdapter, int i) {
            super(context);
            this.parentAdapter = webpageAdapter;
            setWillNotDraw(false);
            this.channelCell = new BlockChannelCell(context, this.parentAdapter, 1);
            RadialProgress2 radialProgress2 = new RadialProgress2(this);
            this.radialProgress = radialProgress2;
            radialProgress2.setProgressColor(-1);
            this.radialProgress.setColors(1711276032, Theme.ACTION_BAR_PHOTO_VIEWER_COLOR, -1, -2500135);
            this.TAG = DownloadController.getInstance(ArticleViewer.this.currentAccount).generateObserverTag();
            addView(this.channelCell, LayoutHelper.createFrame(-1, -2.0f));
            this.currentType = i;
        }

        public void setBlock(TLRPC.TL_pageBlockPhoto tL_pageBlockPhoto, boolean z, boolean z2) {
            this.parentBlock = null;
            this.currentBlock = tL_pageBlockPhoto;
            this.isFirst = z;
            this.isLast = z2;
            this.channelCell.setVisibility(4);
            if (!TextUtils.isEmpty(this.currentBlock.url)) {
                this.linkDrawable = getResources().getDrawable(R.drawable.instant_link);
            }
            TLRPC.TL_pageBlockPhoto tL_pageBlockPhoto2 = this.currentBlock;
            if (tL_pageBlockPhoto2 != null) {
                TLRPC.Photo photoWithId = ArticleViewer.this.getPhotoWithId(tL_pageBlockPhoto2.photo_id);
                if (photoWithId != null) {
                    this.currentPhotoObject = FileLoader.getClosestPhotoSizeWithSize(photoWithId.sizes, AndroidUtilities.getPhotoSize());
                } else {
                    this.currentPhotoObject = null;
                }
            } else {
                this.currentPhotoObject = null;
            }
            updateButtonState(false);
            requestLayout();
        }

        public void setParentBlock(TLRPC.PageBlock pageBlock) {
            this.parentBlock = pageBlock;
            if (ArticleViewer.this.channelBlock != null && (this.parentBlock instanceof TLRPC.TL_pageBlockCover)) {
                this.channelCell.setBlock(ArticleViewer.this.channelBlock);
                this.channelCell.setVisibility(0);
            }
        }

        public View getChannelCell() {
            return this.channelCell;
        }

        /* JADX WARNING: Code restructure failed: missing block: B:25:0x0095, code lost:
            if (r1 <= ((float) (r0 + im.guobwnxjuc.messenger.AndroidUtilities.dp(48.0f)))) goto L_0x009b;
         */
        public boolean onTouchEvent(MotionEvent motionEvent) {
            float x = motionEvent.getX();
            float y = motionEvent.getY();
            if (this.channelCell.getVisibility() != 0 || y <= this.channelCell.getTranslationY() || y >= this.channelCell.getTranslationY() + ((float) AndroidUtilities.dp(39.0f))) {
                if (motionEvent.getAction() == 0 && this.imageView.isInsideImage(x, y)) {
                    if (this.buttonState != -1) {
                        int i = this.buttonX;
                        if (x >= ((float) i) && x <= ((float) (i + AndroidUtilities.dp(48.0f)))) {
                            int i2 = this.buttonY;
                            if (y >= ((float) i2)) {
                            }
                        }
                    }
                    if (this.buttonState != 0) {
                        this.photoPressed = true;
                    }
                    this.buttonPressed = 1;
                    invalidate();
                } else if (motionEvent.getAction() == 1) {
                    if (this.photoPressed) {
                        this.photoPressed = false;
                        ArticleViewer.this.openPhoto(this.currentBlock);
                    } else if (this.buttonPressed == 1) {
                        this.buttonPressed = 0;
                        playSoundEffect(0);
                        didPressedButton(true);
                        invalidate();
                    }
                } else if (motionEvent.getAction() == 3) {
                    this.photoPressed = false;
                    this.buttonPressed = 0;
                }
                if (this.photoPressed || this.buttonPressed != 0 || ArticleViewer.this.checkLayoutForLinks(motionEvent, this, this.captionLayout, this.textX, this.textY) || ArticleViewer.this.checkLayoutForLinks(motionEvent, this, this.creditLayout, this.textX, this.textY + this.creditOffset) || super.onTouchEvent(motionEvent)) {
                    return true;
                }
                return false;
            }
            if (ArticleViewer.this.channelBlock != null && motionEvent.getAction() == 1) {
                MessagesController.getInstance(ArticleViewer.this.currentAccount).openByUserName(ArticleViewer.this.channelBlock.channel.username, ArticleViewer.this.parentFragment, 2);
                ArticleViewer.this.close(false, true);
            }
            return true;
        }

        /* access modifiers changed from: protected */
        /* JADX WARNING: Removed duplicated region for block: B:54:0x0170  */
        /* JADX WARNING: Removed duplicated region for block: B:55:0x0173  */
        /* JADX WARNING: Removed duplicated region for block: B:58:0x01a0  */
        /* JADX WARNING: Removed duplicated region for block: B:59:0x01a2  */
        /* JADX WARNING: Removed duplicated region for block: B:9:0x0049  */
        public void onMeasure(int i, int i2) {
            int i3;
            int i4;
            TLRPC.TL_pageBlockPhoto tL_pageBlockPhoto;
            int i5;
            int i6;
            int i7;
            int i8;
            int i9;
            int i10;
            int i11;
            int i12;
            int size = View.MeasureSpec.getSize(i);
            int i13 = this.currentType;
            boolean z = false;
            int i14 = 1;
            if (i13 == 1) {
                size = ((View) getParent()).getMeasuredWidth();
                i4 = ((View) getParent()).getMeasuredHeight();
            } else if (i13 == 2) {
                i4 = (int) Math.ceil((double) (this.groupPosition.ph * ((float) Math.max(AndroidUtilities.displaySize.x, AndroidUtilities.displaySize.y)) * 0.5f));
            } else {
                i3 = size;
                i4 = 0;
                tL_pageBlockPhoto = this.currentBlock;
                if (tL_pageBlockPhoto != null) {
                    this.currentPhoto = ArticleViewer.this.getPhotoWithId(tL_pageBlockPhoto.photo_id);
                    int dp = AndroidUtilities.dp(48.0f);
                    if (this.currentType != 0 || this.currentBlock.level <= 0) {
                        this.textX = AndroidUtilities.dp(18.0f);
                        i5 = i3 - AndroidUtilities.dp(36.0f);
                        i6 = i3;
                        i7 = 0;
                    } else {
                        i7 = AndroidUtilities.dp((float) (this.currentBlock.level * 14)) + AndroidUtilities.dp(18.0f);
                        this.textX = i7;
                        i6 = i3 - (AndroidUtilities.dp(18.0f) + i7);
                        i5 = i6;
                    }
                    TLRPC.Photo photo = this.currentPhoto;
                    if (photo == null || this.currentPhotoObject == null) {
                        i8 = i4;
                    } else {
                        TLRPC.PhotoSize closestPhotoSizeWithSize = FileLoader.getClosestPhotoSizeWithSize(photo.sizes, 40, true);
                        this.currentPhotoObjectThumb = closestPhotoSizeWithSize;
                        if (this.currentPhotoObject == closestPhotoSizeWithSize) {
                            this.currentPhotoObjectThumb = null;
                        }
                        int i15 = this.currentType;
                        if (i15 == 0) {
                            i4 = (int) ((((float) i6) / ((float) this.currentPhotoObject.w)) * ((float) this.currentPhotoObject.h));
                            if (this.parentBlock instanceof TLRPC.TL_pageBlockCover) {
                                i4 = Math.min(i4, i6);
                            } else {
                                int max = (int) (((float) (Math.max(ArticleViewer.this.listView[0].getMeasuredWidth(), ArticleViewer.this.listView[0].getMeasuredHeight()) - AndroidUtilities.dp(56.0f))) * 0.9f);
                                if (i4 > max) {
                                    i6 = (int) ((((float) max) / ((float) this.currentPhotoObject.h)) * ((float) this.currentPhotoObject.w));
                                    i7 += ((i3 - i7) - i6) / 2;
                                    i4 = max;
                                }
                            }
                        } else if (i15 == 2) {
                            if ((this.groupPosition.flags & 2) == 0) {
                                i6 -= AndroidUtilities.dp(2.0f);
                            }
                            int dp2 = (this.groupPosition.flags & 8) == 0 ? i4 - AndroidUtilities.dp(2.0f) : i4;
                            if (this.groupPosition.leftSpanOffset != 0) {
                                int ceil = (int) Math.ceil((double) (((float) (this.groupPosition.leftSpanOffset * i3)) / 1000.0f));
                                i6 -= ceil;
                                i7 += ceil;
                            }
                            i11 = i4;
                            i4 = dp2;
                            i9 = i6;
                            i10 = i7;
                            this.imageView.setImageCoords(i10, (!this.isFirst || (i12 = this.currentType) == 1 || i12 == 2 || this.currentBlock.level > 0) ? 0 : AndroidUtilities.dp(8.0f), i9, i4);
                            if (this.currentType != 0) {
                                this.currentFilter = null;
                            } else {
                                this.currentFilter = String.format(Locale.US, "%d_%d", Integer.valueOf(i9), Integer.valueOf(i4));
                            }
                            this.currentThumbFilter = "80_80_b";
                            this.autoDownload = (DownloadController.getInstance(ArticleViewer.this.currentAccount).getCurrentDownloadMask() & 1) == 0;
                            File pathToAttach = FileLoader.getPathToAttach(this.currentPhotoObject, true);
                            if (!this.autoDownload || pathToAttach.exists()) {
                                this.imageView.setStrippedLocation(null);
                                this.imageView.setImage(ImageLocation.getForPhoto(this.currentPhotoObject, this.currentPhoto), this.currentFilter, ImageLocation.getForPhoto(this.currentPhotoObjectThumb, this.currentPhoto), this.currentThumbFilter, this.currentPhotoObject.size, null, ArticleViewer.this.currentPage, 1);
                            } else {
                                this.imageView.setStrippedLocation(ImageLocation.getForPhoto(this.currentPhotoObject, this.currentPhoto));
                                this.imageView.setImage(null, this.currentFilter, ImageLocation.getForPhoto(this.currentPhotoObjectThumb, this.currentPhoto), this.currentThumbFilter, this.currentPhotoObject.size, null, ArticleViewer.this.currentPage, 1);
                            }
                            this.buttonX = (int) (((float) this.imageView.getImageX()) + (((float) (this.imageView.getImageWidth() - dp)) / 2.0f));
                            int imageY = (int) (((float) this.imageView.getImageY()) + (((float) (this.imageView.getImageHeight() - dp)) / 2.0f));
                            this.buttonY = imageY;
                            RadialProgress2 radialProgress2 = this.radialProgress;
                            int i16 = this.buttonX;
                            radialProgress2.setProgressRect(i16, imageY, i16 + dp, dp + imageY);
                            i8 = i11;
                        }
                        i9 = i6;
                        i10 = i7;
                        i11 = i4;
                        this.imageView.setImageCoords(i10, (!this.isFirst || (i12 = this.currentType) == 1 || i12 == 2 || this.currentBlock.level > 0) ? 0 : AndroidUtilities.dp(8.0f), i9, i4);
                        if (this.currentType != 0) {
                        }
                        this.currentThumbFilter = "80_80_b";
                        this.autoDownload = (DownloadController.getInstance(ArticleViewer.this.currentAccount).getCurrentDownloadMask() & 1) == 0;
                        File pathToAttach2 = FileLoader.getPathToAttach(this.currentPhotoObject, true);
                        if (!this.autoDownload) {
                        }
                        this.imageView.setStrippedLocation(null);
                        this.imageView.setImage(ImageLocation.getForPhoto(this.currentPhotoObject, this.currentPhoto), this.currentFilter, ImageLocation.getForPhoto(this.currentPhotoObjectThumb, this.currentPhoto), this.currentThumbFilter, this.currentPhotoObject.size, null, ArticleViewer.this.currentPage, 1);
                        this.buttonX = (int) (((float) this.imageView.getImageX()) + (((float) (this.imageView.getImageWidth() - dp)) / 2.0f));
                        int imageY2 = (int) (((float) this.imageView.getImageY()) + (((float) (this.imageView.getImageHeight() - dp)) / 2.0f));
                        this.buttonY = imageY2;
                        RadialProgress2 radialProgress22 = this.radialProgress;
                        int i162 = this.buttonX;
                        radialProgress22.setProgressRect(i162, imageY2, i162 + dp, dp + imageY2);
                        i8 = i11;
                    }
                    if (this.currentType == 0) {
                        DrawingText createLayoutForText = ArticleViewer.this.createLayoutForText(this, null, this.currentBlock.caption.text, i5, this.currentBlock, this.parentAdapter);
                        this.captionLayout = createLayoutForText;
                        if (createLayoutForText != null) {
                            int dp3 = AndroidUtilities.dp(4.0f) + this.captionLayout.getHeight();
                            this.creditOffset = dp3;
                            i8 += dp3 + AndroidUtilities.dp(4.0f);
                        }
                        DrawingText createLayoutForText2 = ArticleViewer.this.createLayoutForText((ArticleViewer) this, (View) null, (CharSequence) this.currentBlock.caption.credit, (TLRPC.RichText) i5, (int) this.currentBlock, (TLRPC.PageBlock) (ArticleViewer.this.isRtl ? StaticLayoutEx.ALIGN_RIGHT() : Layout.Alignment.ALIGN_NORMAL), (Layout.Alignment) this.parentAdapter);
                        this.creditLayout = createLayoutForText2;
                        if (createLayoutForText2 != null) {
                            i8 += AndroidUtilities.dp(4.0f) + this.creditLayout.getHeight();
                        }
                    }
                    if (!this.isFirst && this.currentType == 0 && this.currentBlock.level <= 0) {
                        i8 += AndroidUtilities.dp(8.0f);
                    }
                    if ((this.parentBlock instanceof TLRPC.TL_pageBlockCover) && this.parentAdapter.blocks != null && this.parentAdapter.blocks.size() > 1 && (this.parentAdapter.blocks.get(1) instanceof TLRPC.TL_pageBlockChannel)) {
                        z = true;
                    }
                    if (this.currentType != 2 && !z) {
                        i8 += AndroidUtilities.dp(8.0f);
                    }
                    i14 = i8;
                }
                this.channelCell.measure(i, i2);
                this.channelCell.setTranslationY((float) (this.imageView.getImageHeight() - AndroidUtilities.dp(39.0f)));
                setMeasuredDimension(i3, i14);
            }
            i3 = size;
            tL_pageBlockPhoto = this.currentBlock;
            if (tL_pageBlockPhoto != null) {
            }
            this.channelCell.measure(i, i2);
            this.channelCell.setTranslationY((float) (this.imageView.getImageHeight() - AndroidUtilities.dp(39.0f)));
            setMeasuredDimension(i3, i14);
        }

        /* access modifiers changed from: protected */
        public void onDraw(Canvas canvas) {
            if (this.currentBlock != null) {
                if (!this.imageView.hasBitmapImage() || this.imageView.getCurrentAlpha() != 1.0f) {
                    canvas.drawRect((float) this.imageView.getImageX(), (float) this.imageView.getImageY(), (float) this.imageView.getImageX2(), (float) this.imageView.getImageY2(), ArticleViewer.photoBackgroundPaint);
                }
                this.imageView.draw(canvas);
                if (this.imageView.getVisible()) {
                    this.radialProgress.draw(canvas);
                }
                if (!TextUtils.isEmpty(this.currentBlock.url)) {
                    int measuredWidth = getMeasuredWidth() - AndroidUtilities.dp(35.0f);
                    int imageY = this.imageView.getImageY() + AndroidUtilities.dp(11.0f);
                    this.linkDrawable.setBounds(measuredWidth, imageY, AndroidUtilities.dp(24.0f) + measuredWidth, AndroidUtilities.dp(24.0f) + imageY);
                    this.linkDrawable.draw(canvas);
                }
                this.textY = this.imageView.getImageY() + this.imageView.getImageHeight() + AndroidUtilities.dp(8.0f);
                if (this.captionLayout != null) {
                    canvas.save();
                    canvas.translate((float) this.textX, (float) this.textY);
                    this.captionLayout.draw(canvas);
                    canvas.restore();
                }
                if (this.creditLayout != null) {
                    canvas.save();
                    canvas.translate((float) this.textX, (float) (this.textY + this.creditOffset));
                    this.creditLayout.draw(canvas);
                    canvas.restore();
                }
                if (this.currentBlock.level > 0) {
                    canvas.drawRect((float) AndroidUtilities.dp(18.0f), 0.0f, (float) AndroidUtilities.dp(20.0f), (float) (getMeasuredHeight() - (this.currentBlock.bottom ? AndroidUtilities.dp(6.0f) : 0)), ArticleViewer.quoteLinePaint);
                }
            }
        }

        private int getIconForCurrentState() {
            int i = this.buttonState;
            if (i == 0) {
                return 2;
            }
            return i == 1 ? 3 : 4;
        }

        private void didPressedButton(boolean z) {
            int i = this.buttonState;
            if (i == 0) {
                this.cancelLoading = false;
                this.radialProgress.setProgress(0.0f, z);
                this.imageView.setImage(ImageLocation.getForPhoto(this.currentPhotoObject, this.currentPhoto), this.currentFilter, ImageLocation.getForPhoto(this.currentPhotoObjectThumb, this.currentPhoto), this.currentThumbFilter, this.currentPhotoObject.size, null, ArticleViewer.this.currentPage, 1);
                this.buttonState = 1;
                this.radialProgress.setIcon(getIconForCurrentState(), true, z);
                invalidate();
            } else if (i == 1) {
                this.cancelLoading = true;
                this.imageView.cancelLoadImage();
                this.buttonState = 0;
                this.radialProgress.setIcon(getIconForCurrentState(), false, z);
                invalidate();
            }
        }

        public void updateButtonState(boolean z) {
            String attachFileName = FileLoader.getAttachFileName(this.currentPhotoObject);
            boolean exists = FileLoader.getPathToAttach(this.currentPhotoObject, true).exists();
            if (TextUtils.isEmpty(attachFileName)) {
                this.radialProgress.setIcon(4, false, false);
            } else if (exists) {
                DownloadController.getInstance(ArticleViewer.this.currentAccount).removeLoadingFileObserver(this);
                this.buttonState = -1;
                this.radialProgress.setIcon(getIconForCurrentState(), false, z);
                invalidate();
            } else {
                DownloadController.getInstance(ArticleViewer.this.currentAccount).addLoadingFileObserver(attachFileName, null, this);
                float f = 0.0f;
                if (this.autoDownload || FileLoader.getInstance(ArticleViewer.this.currentAccount).isLoadingFile(attachFileName)) {
                    this.buttonState = 1;
                    Float fileProgress = ImageLoader.getInstance().getFileProgress(attachFileName);
                    if (fileProgress != null) {
                        f = fileProgress.floatValue();
                    }
                } else {
                    this.buttonState = 0;
                }
                this.radialProgress.setIcon(getIconForCurrentState(), true, z);
                this.radialProgress.setProgress(f, false);
                invalidate();
            }
        }

        /* access modifiers changed from: protected */
        public void onDetachedFromWindow() {
            super.onDetachedFromWindow();
            this.imageView.onDetachedFromWindow();
            DownloadController.getInstance(ArticleViewer.this.currentAccount).removeLoadingFileObserver(this);
        }

        /* access modifiers changed from: protected */
        public void onAttachedToWindow() {
            super.onAttachedToWindow();
            this.imageView.onAttachedToWindow();
            updateButtonState(false);
        }

        @Override // im.guobwnxjuc.messenger.DownloadController.FileDownloadProgressListener
        public void onFailedDownload(String str, boolean z) {
            updateButtonState(false);
        }

        @Override // im.guobwnxjuc.messenger.DownloadController.FileDownloadProgressListener
        public void onSuccessDownload(String str) {
            this.radialProgress.setProgress(1.0f, true);
            updateButtonState(true);
        }

        @Override // im.guobwnxjuc.messenger.DownloadController.FileDownloadProgressListener
        public void onProgressDownload(String str, float f) {
            this.radialProgress.setProgress(f, true);
            if (this.buttonState != 1) {
                updateButtonState(true);
            }
        }

        @Override // im.guobwnxjuc.messenger.DownloadController.FileDownloadProgressListener
        public int getObserverTag() {
            return this.TAG;
        }

        public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo accessibilityNodeInfo) {
            super.onInitializeAccessibilityNodeInfo(accessibilityNodeInfo);
            accessibilityNodeInfo.setEnabled(true);
            StringBuilder sb = new StringBuilder(LocaleController.getString("AttachPhoto", R.string.AttachPhoto));
            if (this.captionLayout != null) {
                sb.append(", ");
                sb.append(this.captionLayout.getText());
            }
            accessibilityNodeInfo.setText(sb.toString());
        }
    }

    /* access modifiers changed from: private */
    public class BlockMapCell extends FrameLayout {
        private DrawingText captionLayout;
        private DrawingText creditLayout;
        private int creditOffset;
        private TLRPC.TL_pageBlockMap currentBlock;
        private int currentMapProvider;
        private int currentType;
        private ImageReceiver imageView = new ImageReceiver(this);
        private boolean isFirst;
        private boolean isLast;
        private WebpageAdapter parentAdapter;
        private boolean photoPressed;
        private int textX;
        private int textY;

        public BlockMapCell(Context context, WebpageAdapter webpageAdapter, int i) {
            super(context);
            this.parentAdapter = webpageAdapter;
            setWillNotDraw(false);
            this.currentType = i;
        }

        public void setBlock(TLRPC.TL_pageBlockMap tL_pageBlockMap, boolean z, boolean z2) {
            this.currentBlock = tL_pageBlockMap;
            this.isFirst = z;
            this.isLast = z2;
            requestLayout();
        }

        public boolean onTouchEvent(MotionEvent motionEvent) {
            float x = motionEvent.getX();
            float y = motionEvent.getY();
            if (motionEvent.getAction() == 0 && this.imageView.isInsideImage(x, y)) {
                this.photoPressed = true;
            } else if (motionEvent.getAction() == 1 && this.photoPressed) {
                this.photoPressed = false;
                try {
                    double d = this.currentBlock.geo.lat;
                    double d2 = this.currentBlock.geo._long;
                    Activity activity = ArticleViewer.this.parentActivity;
                    activity.startActivity(new Intent("android.intent.action.VIEW", Uri.parse("geo:" + d + "," + d2 + "?q=" + d + "," + d2)));
                } catch (Exception e) {
                    FileLog.e(e);
                }
            } else if (motionEvent.getAction() == 3) {
                this.photoPressed = false;
            }
            if (this.photoPressed || ArticleViewer.this.checkLayoutForLinks(motionEvent, this, this.captionLayout, this.textX, this.textY) || ArticleViewer.this.checkLayoutForLinks(motionEvent, this, this.creditLayout, this.textX, this.textY + this.creditOffset) || super.onTouchEvent(motionEvent)) {
                return true;
            }
            return false;
        }

        /* access modifiers changed from: protected */
        public void onMeasure(int i, int i2) {
            int i3;
            int i4;
            int i5;
            int i6;
            int i7;
            int i8;
            int max;
            int size = View.MeasureSpec.getSize(i);
            int i9 = this.currentType;
            int i10 = 1;
            if (i9 == 1) {
                i3 = ((View) getParent()).getMeasuredWidth();
                size = ((View) getParent()).getMeasuredHeight();
            } else {
                i3 = size;
                if (i9 != 2) {
                    size = 0;
                }
            }
            TLRPC.TL_pageBlockMap tL_pageBlockMap = this.currentBlock;
            if (tL_pageBlockMap != null) {
                if (this.currentType != 0 || tL_pageBlockMap.level <= 0) {
                    this.textX = AndroidUtilities.dp(18.0f);
                    i4 = i3 - AndroidUtilities.dp(36.0f);
                    i5 = i3;
                    i6 = 0;
                } else {
                    i6 = AndroidUtilities.dp((float) (this.currentBlock.level * 14)) + AndroidUtilities.dp(18.0f);
                    this.textX = i6;
                    i5 = i3 - (AndroidUtilities.dp(18.0f) + i6);
                    i4 = i5;
                }
                if (this.currentType != 0 || (size = (int) ((((float) i5) / ((float) this.currentBlock.w)) * ((float) this.currentBlock.h))) <= (max = (int) (((float) (Math.max(ArticleViewer.this.listView[0].getMeasuredWidth(), ArticleViewer.this.listView[0].getMeasuredHeight()) - AndroidUtilities.dp(56.0f))) * 0.9f))) {
                    i7 = size;
                } else {
                    i5 = (int) ((((float) max) / ((float) this.currentBlock.h)) * ((float) this.currentBlock.w));
                    i6 += ((i3 - i6) - i5) / 2;
                    i7 = max;
                }
                this.imageView.setImageCoords(i6, (this.isFirst || (i8 = this.currentType) == 1 || i8 == 2 || this.currentBlock.level > 0) ? 0 : AndroidUtilities.dp(8.0f), i5, i7);
                float f = (float) i5;
                float f2 = (float) i7;
                String formapMapUrl = AndroidUtilities.formapMapUrl(ArticleViewer.this.currentAccount, this.currentBlock.geo.lat, this.currentBlock.geo._long, (int) (f / AndroidUtilities.density), (int) (f2 / AndroidUtilities.density), true, 15);
                WebFile createWithGeoPoint = WebFile.createWithGeoPoint(this.currentBlock.geo, (int) (f / AndroidUtilities.density), (int) (f2 / AndroidUtilities.density), 15, Math.min(2, (int) Math.ceil((double) AndroidUtilities.density)));
                int i11 = MessagesController.getInstance(ArticleViewer.this.currentAccount).mapProvider;
                this.currentMapProvider = i11;
                if (i11 == 2) {
                    if (createWithGeoPoint != null) {
                        this.imageView.setImage(ImageLocation.getForWebFile(createWithGeoPoint), null, Theme.chat_locationDrawable[0], null, ArticleViewer.this.currentPage, 0);
                    }
                } else if (formapMapUrl != null) {
                    this.imageView.setImage(formapMapUrl, null, Theme.chat_locationDrawable[0], null, 0);
                }
                if (this.currentType == 0) {
                    DrawingText createLayoutForText = ArticleViewer.this.createLayoutForText(this, null, this.currentBlock.caption.text, i4, this.currentBlock, this.parentAdapter);
                    this.captionLayout = createLayoutForText;
                    if (createLayoutForText != null) {
                        int dp = AndroidUtilities.dp(4.0f) + this.captionLayout.getHeight();
                        this.creditOffset = dp;
                        i7 += dp + AndroidUtilities.dp(4.0f);
                    }
                    DrawingText createLayoutForText2 = ArticleViewer.this.createLayoutForText((ArticleViewer) this, (View) null, (CharSequence) this.currentBlock.caption.credit, (TLRPC.RichText) i4, (int) this.currentBlock, (TLRPC.PageBlock) (ArticleViewer.this.isRtl ? StaticLayoutEx.ALIGN_RIGHT() : Layout.Alignment.ALIGN_NORMAL), (Layout.Alignment) this.parentAdapter);
                    this.creditLayout = createLayoutForText2;
                    if (createLayoutForText2 != null) {
                        i7 += AndroidUtilities.dp(4.0f) + this.creditLayout.getHeight();
                    }
                }
                if (!this.isFirst && this.currentType == 0 && this.currentBlock.level <= 0) {
                    i7 += AndroidUtilities.dp(8.0f);
                }
                if (this.currentType != 2) {
                    i7 += AndroidUtilities.dp(8.0f);
                }
                i10 = i7;
            }
            setMeasuredDimension(i3, i10);
        }

        /* access modifiers changed from: protected */
        public void onDraw(Canvas canvas) {
            if (this.currentBlock != null) {
                this.imageView.draw(canvas);
                if (this.currentMapProvider == 2 && this.imageView.hasNotThumb()) {
                    int intrinsicWidth = (int) (((float) Theme.chat_redLocationIcon.getIntrinsicWidth()) * 0.8f);
                    int intrinsicHeight = (int) (((float) Theme.chat_redLocationIcon.getIntrinsicHeight()) * 0.8f);
                    int imageX = this.imageView.getImageX() + ((this.imageView.getImageWidth() - intrinsicWidth) / 2);
                    int imageY = this.imageView.getImageY() + ((this.imageView.getImageHeight() / 2) - intrinsicHeight);
                    Theme.chat_redLocationIcon.setAlpha((int) (this.imageView.getCurrentAlpha() * 255.0f));
                    Theme.chat_redLocationIcon.setBounds(imageX, imageY, intrinsicWidth + imageX, intrinsicHeight + imageY);
                    Theme.chat_redLocationIcon.draw(canvas);
                }
                this.textY = this.imageView.getImageY() + this.imageView.getImageHeight() + AndroidUtilities.dp(8.0f);
                if (this.captionLayout != null) {
                    canvas.save();
                    canvas.translate((float) this.textX, (float) this.textY);
                    this.captionLayout.draw(canvas);
                    canvas.restore();
                }
                if (this.creditLayout != null) {
                    canvas.save();
                    canvas.translate((float) this.textX, (float) (this.textY + this.creditOffset));
                    this.creditLayout.draw(canvas);
                    canvas.restore();
                }
                if (this.currentBlock.level > 0) {
                    canvas.drawRect((float) AndroidUtilities.dp(18.0f), 0.0f, (float) AndroidUtilities.dp(20.0f), (float) (getMeasuredHeight() - (this.currentBlock.bottom ? AndroidUtilities.dp(6.0f) : 0)), ArticleViewer.quoteLinePaint);
                }
            }
        }

        public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo accessibilityNodeInfo) {
            super.onInitializeAccessibilityNodeInfo(accessibilityNodeInfo);
            accessibilityNodeInfo.setEnabled(true);
            StringBuilder sb = new StringBuilder(LocaleController.getString("Map", R.string.Map));
            if (this.captionLayout != null) {
                sb.append(", ");
                sb.append(this.captionLayout.getText());
            }
            accessibilityNodeInfo.setText(sb.toString());
        }
    }

    /* access modifiers changed from: private */
    public class BlockChannelCell extends FrameLayout {
        private Paint backgroundPaint;
        private int buttonWidth;
        private AnimatorSet currentAnimation;
        private TLRPC.TL_pageBlockChannel currentBlock;
        private int currentState;
        private int currentType;
        private ImageView imageView;
        private WebpageAdapter parentAdapter;
        private ContextProgressView progressView;
        private DrawingText textLayout;
        private TextView textView;
        private int textX = AndroidUtilities.dp(18.0f);
        private int textX2;
        private int textY = AndroidUtilities.dp(11.0f);

        public BlockChannelCell(Context context, WebpageAdapter webpageAdapter, int i) {
            super(context);
            this.parentAdapter = webpageAdapter;
            setWillNotDraw(false);
            this.backgroundPaint = new Paint();
            this.currentType = i;
            TextView textView2 = new TextView(context);
            this.textView = textView2;
            textView2.setTextSize(1, 14.0f);
            this.textView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
            this.textView.setText(LocaleController.getString("ChannelJoin", R.string.ChannelJoin));
            this.textView.setGravity(19);
            addView(this.textView, LayoutHelper.createFrame(-2, 39, 53));
            this.textView.setOnClickListener(new View.OnClickListener() {
                /* class im.guobwnxjuc.ui.$$Lambda$ArticleViewer$BlockChannelCell$hv732T1Ql87L8gYZ0Kdv6Skxknk */

                public final void onClick(View view) {
                    ArticleViewer.BlockChannelCell.this.lambda$new$0$ArticleViewer$BlockChannelCell(view);
                }
            });
            ImageView imageView2 = new ImageView(context);
            this.imageView = imageView2;
            imageView2.setImageResource(R.drawable.list_check);
            this.imageView.setScaleType(ImageView.ScaleType.CENTER);
            addView(this.imageView, LayoutHelper.createFrame(39, 39, 53));
            ContextProgressView contextProgressView = new ContextProgressView(context, 0);
            this.progressView = contextProgressView;
            addView(contextProgressView, LayoutHelper.createFrame(39, 39, 53));
        }

        public /* synthetic */ void lambda$new$0$ArticleViewer$BlockChannelCell(View view) {
            if (this.currentState == 0) {
                setState(1, true);
                ArticleViewer articleViewer = ArticleViewer.this;
                articleViewer.joinChannel(this, articleViewer.loadedChannel);
            }
        }

        public void setBlock(TLRPC.TL_pageBlockChannel tL_pageBlockChannel) {
            this.currentBlock = tL_pageBlockChannel;
            int selectedColor = ArticleViewer.this.getSelectedColor();
            if (this.currentType == 0) {
                this.textView.setTextColor(-14840360);
                if (selectedColor == 0) {
                    this.backgroundPaint.setColor(-526345);
                } else if (selectedColor == 1) {
                    this.backgroundPaint.setColor(-1712440);
                } else if (selectedColor == 2) {
                    this.backgroundPaint.setColor(-15000805);
                }
                this.imageView.setColorFilter(new PorterDuffColorFilter(-6710887, PorterDuff.Mode.MULTIPLY));
            } else {
                this.textView.setTextColor(-1);
                this.backgroundPaint.setColor(Theme.ACTION_BAR_PHOTO_VIEWER_COLOR);
                this.imageView.setColorFilter(new PorterDuffColorFilter(-1, PorterDuff.Mode.MULTIPLY));
            }
            TLRPC.Chat chat = MessagesController.getInstance(ArticleViewer.this.currentAccount).getChat(Integer.valueOf(tL_pageBlockChannel.channel.id));
            if (chat == null || chat.min) {
                ArticleViewer.this.loadChannel(this, this.parentAdapter, tL_pageBlockChannel.channel);
                setState(1, false);
            } else {
                ArticleViewer.this.loadedChannel = chat;
                if (!chat.left || chat.kicked) {
                    setState(4, false);
                } else {
                    setState(0, false);
                }
            }
            requestLayout();
        }

        public void setState(int i, boolean z) {
            AnimatorSet animatorSet = this.currentAnimation;
            if (animatorSet != null) {
                animatorSet.cancel();
            }
            this.currentState = i;
            float f = 0.0f;
            float f2 = 0.1f;
            if (z) {
                AnimatorSet animatorSet2 = new AnimatorSet();
                this.currentAnimation = animatorSet2;
                Animator[] animatorArr = new Animator[9];
                TextView textView2 = this.textView;
                Property property = View.ALPHA;
                float[] fArr = new float[1];
                fArr[0] = i == 0 ? 1.0f : 0.0f;
                animatorArr[0] = ObjectAnimator.ofFloat(textView2, property, fArr);
                TextView textView3 = this.textView;
                Property property2 = View.SCALE_X;
                float[] fArr2 = new float[1];
                fArr2[0] = i == 0 ? 1.0f : 0.1f;
                animatorArr[1] = ObjectAnimator.ofFloat(textView3, property2, fArr2);
                TextView textView4 = this.textView;
                Property property3 = View.SCALE_Y;
                float[] fArr3 = new float[1];
                fArr3[0] = i == 0 ? 1.0f : 0.1f;
                animatorArr[2] = ObjectAnimator.ofFloat(textView4, property3, fArr3);
                ContextProgressView contextProgressView = this.progressView;
                Property property4 = View.ALPHA;
                float[] fArr4 = new float[1];
                fArr4[0] = i == 1 ? 1.0f : 0.0f;
                animatorArr[3] = ObjectAnimator.ofFloat(contextProgressView, property4, fArr4);
                ContextProgressView contextProgressView2 = this.progressView;
                Property property5 = View.SCALE_X;
                float[] fArr5 = new float[1];
                fArr5[0] = i == 1 ? 1.0f : 0.1f;
                animatorArr[4] = ObjectAnimator.ofFloat(contextProgressView2, property5, fArr5);
                ContextProgressView contextProgressView3 = this.progressView;
                Property property6 = View.SCALE_Y;
                float[] fArr6 = new float[1];
                fArr6[0] = i == 1 ? 1.0f : 0.1f;
                animatorArr[5] = ObjectAnimator.ofFloat(contextProgressView3, property6, fArr6);
                ImageView imageView2 = this.imageView;
                Property property7 = View.ALPHA;
                float[] fArr7 = new float[1];
                if (i == 2) {
                    f = 1.0f;
                }
                fArr7[0] = f;
                animatorArr[6] = ObjectAnimator.ofFloat(imageView2, property7, fArr7);
                ImageView imageView3 = this.imageView;
                Property property8 = View.SCALE_X;
                float[] fArr8 = new float[1];
                fArr8[0] = i == 2 ? 1.0f : 0.1f;
                animatorArr[7] = ObjectAnimator.ofFloat(imageView3, property8, fArr8);
                ImageView imageView4 = this.imageView;
                Property property9 = View.SCALE_Y;
                float[] fArr9 = new float[1];
                if (i == 2) {
                    f2 = 1.0f;
                }
                fArr9[0] = f2;
                animatorArr[8] = ObjectAnimator.ofFloat(imageView4, property9, fArr9);
                animatorSet2.playTogether(animatorArr);
                this.currentAnimation.setDuration(150L);
                this.currentAnimation.start();
                return;
            }
            this.textView.setAlpha(i == 0 ? 1.0f : 0.0f);
            this.textView.setScaleX(i == 0 ? 1.0f : 0.1f);
            this.textView.setScaleY(i == 0 ? 1.0f : 0.1f);
            this.progressView.setAlpha(i == 1 ? 1.0f : 0.0f);
            this.progressView.setScaleX(i == 1 ? 1.0f : 0.1f);
            this.progressView.setScaleY(i == 1 ? 1.0f : 0.1f);
            ImageView imageView5 = this.imageView;
            if (i == 2) {
                f = 1.0f;
            }
            imageView5.setAlpha(f);
            this.imageView.setScaleX(i == 2 ? 1.0f : 0.1f);
            ImageView imageView6 = this.imageView;
            if (i == 2) {
                f2 = 1.0f;
            }
            imageView6.setScaleY(f2);
        }

        public boolean onTouchEvent(MotionEvent motionEvent) {
            if (this.currentType != 0) {
                return super.onTouchEvent(motionEvent);
            }
            return ArticleViewer.this.checkLayoutForLinks(motionEvent, this, this.textLayout, this.textX, this.textY) || super.onTouchEvent(motionEvent);
        }

        /* access modifiers changed from: protected */
        public void onMeasure(int i, int i2) {
            int size = View.MeasureSpec.getSize(i);
            setMeasuredDimension(size, AndroidUtilities.dp(48.0f));
            this.textView.measure(View.MeasureSpec.makeMeasureSpec(View.MeasureSpec.getSize(i), Integer.MIN_VALUE), View.MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(39.0f), 1073741824));
            this.buttonWidth = this.textView.getMeasuredWidth();
            this.progressView.measure(View.MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(39.0f), 1073741824), View.MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(39.0f), 1073741824));
            this.imageView.measure(View.MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(39.0f), 1073741824), View.MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(39.0f), 1073741824));
            TLRPC.TL_pageBlockChannel tL_pageBlockChannel = this.currentBlock;
            if (tL_pageBlockChannel != null) {
                this.textLayout = ArticleViewer.this.createLayoutForText((ArticleViewer) this, (View) tL_pageBlockChannel.channel.title, (CharSequence) null, (TLRPC.RichText) ((size - AndroidUtilities.dp(52.0f)) - this.buttonWidth), (int) this.currentBlock, (TLRPC.PageBlock) StaticLayoutEx.ALIGN_LEFT(), (Layout.Alignment) this.parentAdapter);
                if (ArticleViewer.this.isRtl) {
                    this.textX2 = this.textX;
                } else {
                    this.textX2 = (getMeasuredWidth() - this.textX) - this.buttonWidth;
                }
            }
        }

        /* access modifiers changed from: protected */
        public void onLayout(boolean z, int i, int i2, int i3, int i4) {
            this.imageView.layout((this.textX2 + (this.buttonWidth / 2)) - AndroidUtilities.dp(19.0f), 0, this.textX2 + (this.buttonWidth / 2) + AndroidUtilities.dp(20.0f), AndroidUtilities.dp(39.0f));
            this.progressView.layout((this.textX2 + (this.buttonWidth / 2)) - AndroidUtilities.dp(19.0f), 0, this.textX2 + (this.buttonWidth / 2) + AndroidUtilities.dp(20.0f), AndroidUtilities.dp(39.0f));
            TextView textView2 = this.textView;
            int i5 = this.textX2;
            textView2.layout(i5, 0, textView2.getMeasuredWidth() + i5, this.textView.getMeasuredHeight());
        }

        /* access modifiers changed from: protected */
        public void onDraw(Canvas canvas) {
            if (this.currentBlock != null) {
                canvas.drawRect(0.0f, 0.0f, (float) getMeasuredWidth(), (float) AndroidUtilities.dp(39.0f), this.backgroundPaint);
                DrawingText drawingText = this.textLayout;
                if (drawingText != null && drawingText.getLineCount() > 0) {
                    canvas.save();
                    if (ArticleViewer.this.isRtl) {
                        canvas.translate((((float) getMeasuredWidth()) - this.textLayout.getLineWidth(0)) - ((float) this.textX), (float) this.textY);
                    } else {
                        canvas.translate((float) this.textX, (float) this.textY);
                    }
                    this.textLayout.draw(canvas);
                    canvas.restore();
                }
            }
        }
    }

    /* access modifiers changed from: private */
    public class BlockAuthorDateCell extends View {
        private TLRPC.TL_pageBlockAuthorDate currentBlock;
        private WebpageAdapter parentAdapter;
        private DrawingText textLayout;
        private int textX;
        private int textY = AndroidUtilities.dp(8.0f);

        public BlockAuthorDateCell(Context context, WebpageAdapter webpageAdapter) {
            super(context);
            this.parentAdapter = webpageAdapter;
        }

        public void setBlock(TLRPC.TL_pageBlockAuthorDate tL_pageBlockAuthorDate) {
            this.currentBlock = tL_pageBlockAuthorDate;
            requestLayout();
        }

        public boolean onTouchEvent(MotionEvent motionEvent) {
            return ArticleViewer.this.checkLayoutForLinks(motionEvent, this, this.textLayout, this.textX, this.textY) || super.onTouchEvent(motionEvent);
        }

        /* JADX DEBUG: Failed to insert an additional move for type inference into block B:15:0x0088 */
        /* JADX WARN: Multi-variable type inference failed */
        /* JADX WARN: Type inference failed for: r3v12, types: [java.lang.String] */
        /* JADX WARN: Type inference failed for: r3v15, types: [java.lang.String] */
        /* access modifiers changed from: protected */
        /* JADX WARNING: Unknown variable types count: 2 */
        public void onMeasure(int i, int i2) {
            Spannable spannable;
            Spannable spannable2;
            int indexOf;
            int size = View.MeasureSpec.getSize(i);
            TLRPC.TL_pageBlockAuthorDate tL_pageBlockAuthorDate = this.currentBlock;
            int i3 = 1;
            if (tL_pageBlockAuthorDate != null) {
                CharSequence text = ArticleViewer.this.getText(this, tL_pageBlockAuthorDate.author, this.currentBlock.author, this.currentBlock, size);
                MetricAffectingSpan[] metricAffectingSpanArr = null;
                if (text instanceof Spannable) {
                    Spannable spannable3 = (Spannable) text;
                    metricAffectingSpanArr = (MetricAffectingSpan[]) spannable3.getSpans(0, text.length(), MetricAffectingSpan.class);
                    spannable = spannable3;
                } else {
                    spannable = null;
                }
                if (this.currentBlock.published_date != 0 && !TextUtils.isEmpty(text)) {
                    spannable2 = LocaleController.formatString("ArticleDateByAuthor", R.string.ArticleDateByAuthor, LocaleController.getInstance().chatFullDate.format(((long) this.currentBlock.published_date) * 1000), text);
                } else if (!TextUtils.isEmpty(text)) {
                    spannable2 = LocaleController.formatString("ArticleByAuthor", R.string.ArticleByAuthor, text);
                } else {
                    spannable2 = LocaleController.getInstance().chatFullDate.format(((long) this.currentBlock.published_date) * 1000);
                }
                if (metricAffectingSpanArr != null) {
                    try {
                        if (metricAffectingSpanArr.length > 0 && (indexOf = TextUtils.indexOf(spannable2, text)) != -1) {
                            spannable2 = Spannable.Factory.getInstance().newSpannable(spannable2);
                            for (int i4 = 0; i4 < metricAffectingSpanArr.length; i4++) {
                                spannable2.setSpan(metricAffectingSpanArr[i4], spannable.getSpanStart(metricAffectingSpanArr[i4]) + indexOf, spannable.getSpanEnd(metricAffectingSpanArr[i4]) + indexOf, 33);
                            }
                        }
                    } catch (Exception e) {
                        FileLog.e(e);
                    }
                }
                DrawingText createLayoutForText = ArticleViewer.this.createLayoutForText(this, spannable2, null, size - AndroidUtilities.dp(36.0f), this.currentBlock, this.parentAdapter);
                this.textLayout = createLayoutForText;
                if (createLayoutForText != null) {
                    int dp = AndroidUtilities.dp(16.0f) + this.textLayout.getHeight() + 0;
                    if (ArticleViewer.this.isRtl) {
                        this.textX = (int) Math.floor((double) ((((float) size) - this.textLayout.getLineWidth(0)) - ((float) AndroidUtilities.dp(16.0f))));
                    } else {
                        this.textX = AndroidUtilities.dp(18.0f);
                    }
                    i3 = dp;
                } else {
                    i3 = 0;
                }
            }
            setMeasuredDimension(size, i3);
        }

        /* access modifiers changed from: protected */
        public void onDraw(Canvas canvas) {
            if (this.currentBlock != null && this.textLayout != null) {
                canvas.save();
                canvas.translate((float) this.textX, (float) this.textY);
                this.textLayout.draw(canvas);
                canvas.restore();
            }
        }

        public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo accessibilityNodeInfo) {
            super.onInitializeAccessibilityNodeInfo(accessibilityNodeInfo);
            accessibilityNodeInfo.setEnabled(true);
            DrawingText drawingText = this.textLayout;
            if (drawingText != null) {
                accessibilityNodeInfo.setText(drawingText.getText());
            }
        }
    }

    /* access modifiers changed from: private */
    public class BlockTitleCell extends View {
        private TLRPC.TL_pageBlockTitle currentBlock;
        private WebpageAdapter parentAdapter;
        private DrawingText textLayout;
        private int textX = AndroidUtilities.dp(18.0f);
        private int textY;

        public BlockTitleCell(Context context, WebpageAdapter webpageAdapter) {
            super(context);
            this.parentAdapter = webpageAdapter;
        }

        public void setBlock(TLRPC.TL_pageBlockTitle tL_pageBlockTitle) {
            this.currentBlock = tL_pageBlockTitle;
            requestLayout();
        }

        public boolean onTouchEvent(MotionEvent motionEvent) {
            return ArticleViewer.this.checkLayoutForLinks(motionEvent, this, this.textLayout, this.textX, this.textY) || super.onTouchEvent(motionEvent);
        }

        /* access modifiers changed from: protected */
        public void onMeasure(int i, int i2) {
            int i3;
            int size = View.MeasureSpec.getSize(i);
            TLRPC.TL_pageBlockTitle tL_pageBlockTitle = this.currentBlock;
            if (tL_pageBlockTitle != null) {
                DrawingText createLayoutForText = ArticleViewer.this.createLayoutForText((ArticleViewer) this, (View) null, (CharSequence) tL_pageBlockTitle.text, (TLRPC.RichText) (size - AndroidUtilities.dp(36.0f)), (int) this.currentBlock, (TLRPC.PageBlock) (ArticleViewer.this.isRtl ? StaticLayoutEx.ALIGN_RIGHT() : Layout.Alignment.ALIGN_NORMAL), (Layout.Alignment) this.parentAdapter);
                this.textLayout = createLayoutForText;
                i3 = 0;
                if (createLayoutForText != null) {
                    i3 = 0 + AndroidUtilities.dp(16.0f) + this.textLayout.getHeight();
                }
                if (this.currentBlock.first) {
                    i3 += AndroidUtilities.dp(8.0f);
                    this.textY = AndroidUtilities.dp(16.0f);
                } else {
                    this.textY = AndroidUtilities.dp(8.0f);
                }
            } else {
                i3 = 1;
            }
            setMeasuredDimension(size, i3);
        }

        /* access modifiers changed from: protected */
        public void onDraw(Canvas canvas) {
            if (this.currentBlock != null && this.textLayout != null) {
                canvas.save();
                canvas.translate((float) this.textX, (float) this.textY);
                this.textLayout.draw(canvas);
                canvas.restore();
            }
        }

        public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo accessibilityNodeInfo) {
            super.onInitializeAccessibilityNodeInfo(accessibilityNodeInfo);
            accessibilityNodeInfo.setEnabled(true);
            if (this.textLayout != null) {
                accessibilityNodeInfo.setText(((Object) this.textLayout.getText()) + ", " + LocaleController.getString("AccDescrIVTitle", R.string.AccDescrIVTitle));
            }
        }
    }

    /* access modifiers changed from: private */
    public class BlockKickerCell extends View {
        private TLRPC.TL_pageBlockKicker currentBlock;
        private WebpageAdapter parentAdapter;
        private DrawingText textLayout;
        private int textX = AndroidUtilities.dp(18.0f);
        private int textY;

        public BlockKickerCell(Context context, WebpageAdapter webpageAdapter) {
            super(context);
            this.parentAdapter = webpageAdapter;
        }

        public void setBlock(TLRPC.TL_pageBlockKicker tL_pageBlockKicker) {
            this.currentBlock = tL_pageBlockKicker;
            requestLayout();
        }

        public boolean onTouchEvent(MotionEvent motionEvent) {
            return ArticleViewer.this.checkLayoutForLinks(motionEvent, this, this.textLayout, this.textX, this.textY) || super.onTouchEvent(motionEvent);
        }

        /* access modifiers changed from: protected */
        public void onMeasure(int i, int i2) {
            int i3;
            int size = View.MeasureSpec.getSize(i);
            TLRPC.TL_pageBlockKicker tL_pageBlockKicker = this.currentBlock;
            if (tL_pageBlockKicker != null) {
                DrawingText createLayoutForText = ArticleViewer.this.createLayoutForText((ArticleViewer) this, (View) null, (CharSequence) tL_pageBlockKicker.text, (TLRPC.RichText) (size - AndroidUtilities.dp(36.0f)), (int) this.currentBlock, (TLRPC.PageBlock) (ArticleViewer.this.isRtl ? StaticLayoutEx.ALIGN_RIGHT() : Layout.Alignment.ALIGN_NORMAL), (Layout.Alignment) this.parentAdapter);
                this.textLayout = createLayoutForText;
                i3 = 0;
                if (createLayoutForText != null) {
                    i3 = 0 + AndroidUtilities.dp(16.0f) + this.textLayout.getHeight();
                }
                if (this.currentBlock.first) {
                    i3 += AndroidUtilities.dp(8.0f);
                    this.textY = AndroidUtilities.dp(16.0f);
                } else {
                    this.textY = AndroidUtilities.dp(8.0f);
                }
            } else {
                i3 = 1;
            }
            setMeasuredDimension(size, i3);
        }

        /* access modifiers changed from: protected */
        public void onDraw(Canvas canvas) {
            if (this.currentBlock != null && this.textLayout != null) {
                canvas.save();
                canvas.translate((float) this.textX, (float) this.textY);
                this.textLayout.draw(canvas);
                canvas.restore();
            }
        }
    }

    /* access modifiers changed from: private */
    public class BlockFooterCell extends View {
        private TLRPC.TL_pageBlockFooter currentBlock;
        private WebpageAdapter parentAdapter;
        private DrawingText textLayout;
        private int textX = AndroidUtilities.dp(18.0f);
        private int textY = AndroidUtilities.dp(8.0f);

        public BlockFooterCell(Context context, WebpageAdapter webpageAdapter) {
            super(context);
            this.parentAdapter = webpageAdapter;
        }

        public void setBlock(TLRPC.TL_pageBlockFooter tL_pageBlockFooter) {
            this.currentBlock = tL_pageBlockFooter;
            requestLayout();
        }

        public boolean onTouchEvent(MotionEvent motionEvent) {
            return ArticleViewer.this.checkLayoutForLinks(motionEvent, this, this.textLayout, this.textX, this.textY) || super.onTouchEvent(motionEvent);
        }

        /* access modifiers changed from: protected */
        public void onMeasure(int i, int i2) {
            int i3;
            int size = View.MeasureSpec.getSize(i);
            TLRPC.TL_pageBlockFooter tL_pageBlockFooter = this.currentBlock;
            int i4 = 0;
            if (tL_pageBlockFooter != null) {
                if (tL_pageBlockFooter.level == 0) {
                    this.textY = AndroidUtilities.dp(8.0f);
                    this.textX = AndroidUtilities.dp(18.0f);
                } else {
                    this.textY = 0;
                    this.textX = AndroidUtilities.dp((float) ((this.currentBlock.level * 14) + 18));
                }
                DrawingText createLayoutForText = ArticleViewer.this.createLayoutForText((ArticleViewer) this, (View) null, (CharSequence) this.currentBlock.text, (TLRPC.RichText) ((size - AndroidUtilities.dp(18.0f)) - this.textX), (int) this.currentBlock, (TLRPC.PageBlock) (ArticleViewer.this.isRtl ? StaticLayoutEx.ALIGN_RIGHT() : Layout.Alignment.ALIGN_NORMAL), (Layout.Alignment) this.parentAdapter);
                this.textLayout = createLayoutForText;
                if (createLayoutForText != null) {
                    int height = createLayoutForText.getHeight();
                    if (this.currentBlock.level > 0) {
                        i3 = AndroidUtilities.dp(8.0f);
                    } else {
                        i3 = AndroidUtilities.dp(16.0f);
                    }
                    i4 = i3 + height;
                }
            } else {
                i4 = 1;
            }
            setMeasuredDimension(size, i4);
        }

        /* access modifiers changed from: protected */
        public void onDraw(Canvas canvas) {
            if (this.currentBlock != null) {
                if (this.textLayout != null) {
                    canvas.save();
                    canvas.translate((float) this.textX, (float) this.textY);
                    this.textLayout.draw(canvas);
                    canvas.restore();
                }
                if (this.currentBlock.level > 0) {
                    canvas.drawRect((float) AndroidUtilities.dp(18.0f), 0.0f, (float) AndroidUtilities.dp(20.0f), (float) (getMeasuredHeight() - (this.currentBlock.bottom ? AndroidUtilities.dp(6.0f) : 0)), ArticleViewer.quoteLinePaint);
                }
            }
        }
    }

    /* access modifiers changed from: private */
    public class BlockPreformattedCell extends FrameLayout {
        private TLRPC.TL_pageBlockPreformatted currentBlock;
        private WebpageAdapter parentAdapter;
        private HorizontalScrollView scrollView;
        private View textContainer;
        private DrawingText textLayout;

        public BlockPreformattedCell(Context context, WebpageAdapter webpageAdapter) {
            super(context);
            this.parentAdapter = webpageAdapter;
            AnonymousClass1 r6 = new HorizontalScrollView(context, ArticleViewer.this) {
                /* class im.guobwnxjuc.ui.ArticleViewer.BlockPreformattedCell.AnonymousClass1 */

                public boolean onInterceptTouchEvent(MotionEvent motionEvent) {
                    if (BlockPreformattedCell.this.textContainer.getMeasuredWidth() > getMeasuredWidth()) {
                        ArticleViewer.this.windowView.requestDisallowInterceptTouchEvent(true);
                    }
                    return super.onInterceptTouchEvent(motionEvent);
                }

                /* access modifiers changed from: protected */
                public void onScrollChanged(int i, int i2, int i3, int i4) {
                    super.onScrollChanged(i, i2, i3, i4);
                    if (ArticleViewer.this.pressedLinkOwnerLayout != null) {
                        ArticleViewer.this.pressedLinkOwnerLayout = null;
                        ArticleViewer.this.pressedLinkOwnerView = null;
                    }
                }
            };
            this.scrollView = r6;
            r6.setPadding(0, AndroidUtilities.dp(8.0f), 0, AndroidUtilities.dp(8.0f));
            addView(this.scrollView, LayoutHelper.createFrame(-1, -2.0f));
            this.textContainer = new View(context, ArticleViewer.this) {
                /* class im.guobwnxjuc.ui.ArticleViewer.BlockPreformattedCell.AnonymousClass2 */

                /* access modifiers changed from: protected */
                public void onMeasure(int i, int i2) {
                    int i3 = 0;
                    int i4 = 1;
                    if (BlockPreformattedCell.this.currentBlock != null) {
                        BlockPreformattedCell blockPreformattedCell = BlockPreformattedCell.this;
                        blockPreformattedCell.textLayout = ArticleViewer.this.createLayoutForText(this, null, BlockPreformattedCell.this.currentBlock.text, AndroidUtilities.dp(5000.0f), BlockPreformattedCell.this.currentBlock, BlockPreformattedCell.this.parentAdapter);
                        if (BlockPreformattedCell.this.textLayout != null) {
                            int height = BlockPreformattedCell.this.textLayout.getHeight() + 0;
                            int lineCount = BlockPreformattedCell.this.textLayout.getLineCount();
                            while (i3 < lineCount) {
                                i4 = Math.max((int) Math.ceil((double) BlockPreformattedCell.this.textLayout.getLineWidth(i3)), i4);
                                i3++;
                            }
                            i3 = height;
                        }
                    } else {
                        i3 = 1;
                    }
                    setMeasuredDimension(i4 + AndroidUtilities.dp(32.0f), i3);
                }

                /* access modifiers changed from: protected */
                public void onDraw(Canvas canvas) {
                    if (BlockPreformattedCell.this.textLayout != null) {
                        canvas.save();
                        BlockPreformattedCell.this.textLayout.draw(canvas);
                        canvas.restore();
                    }
                }
            };
            FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(-2, -1);
            int dp = AndroidUtilities.dp(16.0f);
            layoutParams.rightMargin = dp;
            layoutParams.leftMargin = dp;
            int dp2 = AndroidUtilities.dp(12.0f);
            layoutParams.bottomMargin = dp2;
            layoutParams.topMargin = dp2;
            this.scrollView.addView(this.textContainer, layoutParams);
            setWillNotDraw(false);
        }

        public void setBlock(TLRPC.TL_pageBlockPreformatted tL_pageBlockPreformatted) {
            this.currentBlock = tL_pageBlockPreformatted;
            this.scrollView.setScrollX(0);
            this.textContainer.requestLayout();
        }

        /* access modifiers changed from: protected */
        public void onMeasure(int i, int i2) {
            int size = View.MeasureSpec.getSize(i);
            this.scrollView.measure(View.MeasureSpec.makeMeasureSpec(size, 1073741824), View.MeasureSpec.makeMeasureSpec(0, 0));
            setMeasuredDimension(size, this.scrollView.getMeasuredHeight());
        }

        /* access modifiers changed from: protected */
        public void onDraw(Canvas canvas) {
            if (this.currentBlock != null) {
                canvas.drawRect(0.0f, (float) AndroidUtilities.dp(8.0f), (float) getMeasuredWidth(), (float) (getMeasuredHeight() - AndroidUtilities.dp(8.0f)), ArticleViewer.preformattedBackgroundPaint);
            }
        }
    }

    /* access modifiers changed from: private */
    public class BlockSubheaderCell extends View {
        private TLRPC.TL_pageBlockSubheader currentBlock;
        private WebpageAdapter parentAdapter;
        private DrawingText textLayout;
        private int textX = AndroidUtilities.dp(18.0f);
        private int textY = AndroidUtilities.dp(8.0f);

        public BlockSubheaderCell(Context context, WebpageAdapter webpageAdapter) {
            super(context);
            this.parentAdapter = webpageAdapter;
        }

        public void setBlock(TLRPC.TL_pageBlockSubheader tL_pageBlockSubheader) {
            this.currentBlock = tL_pageBlockSubheader;
            requestLayout();
        }

        public boolean onTouchEvent(MotionEvent motionEvent) {
            return ArticleViewer.this.checkLayoutForLinks(motionEvent, this, this.textLayout, this.textX, this.textY) || super.onTouchEvent(motionEvent);
        }

        /* access modifiers changed from: protected */
        public void onMeasure(int i, int i2) {
            int size = View.MeasureSpec.getSize(i);
            TLRPC.TL_pageBlockSubheader tL_pageBlockSubheader = this.currentBlock;
            int i3 = 0;
            if (tL_pageBlockSubheader != null) {
                DrawingText createLayoutForText = ArticleViewer.this.createLayoutForText((ArticleViewer) this, (View) null, (CharSequence) tL_pageBlockSubheader.text, (TLRPC.RichText) (size - AndroidUtilities.dp(36.0f)), (int) this.currentBlock, (TLRPC.PageBlock) (ArticleViewer.this.isRtl ? StaticLayoutEx.ALIGN_RIGHT() : Layout.Alignment.ALIGN_NORMAL), (Layout.Alignment) this.parentAdapter);
                this.textLayout = createLayoutForText;
                if (createLayoutForText != null) {
                    i3 = 0 + AndroidUtilities.dp(16.0f) + this.textLayout.getHeight();
                }
            } else {
                i3 = 1;
            }
            setMeasuredDimension(size, i3);
        }

        /* access modifiers changed from: protected */
        public void onDraw(Canvas canvas) {
            if (this.currentBlock != null && this.textLayout != null) {
                canvas.save();
                canvas.translate((float) this.textX, (float) this.textY);
                this.textLayout.draw(canvas);
                canvas.restore();
            }
        }

        public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo accessibilityNodeInfo) {
            super.onInitializeAccessibilityNodeInfo(accessibilityNodeInfo);
            accessibilityNodeInfo.setEnabled(true);
            if (this.textLayout != null) {
                accessibilityNodeInfo.setText(((Object) this.textLayout.getText()) + ", " + LocaleController.getString("AccDescrIVHeading", R.string.AccDescrIVHeading));
            }
        }
    }

    /* access modifiers changed from: private */
    public class LinkMovementMethodMy extends LinkMovementMethod {
        private LinkMovementMethodMy() {
        }

        public boolean onTouchEvent(TextView textView, Spannable spannable, MotionEvent motionEvent) {
            try {
                boolean onTouchEvent = super.onTouchEvent(textView, spannable, motionEvent);
                if (motionEvent.getAction() == 1 || motionEvent.getAction() == 3) {
                    Selection.removeSelection(spannable);
                }
                return onTouchEvent;
            } catch (Exception e) {
                FileLog.e(e);
                return false;
            }
        }
    }

    /* access modifiers changed from: private */
    public class PhotoBackgroundDrawable extends ColorDrawable {
        private Runnable drawRunnable;

        public PhotoBackgroundDrawable(int i) {
            super(i);
        }

        public void setAlpha(int i) {
            if (ArticleViewer.this.parentActivity instanceof LaunchActivity) {
                ((LaunchActivity) ArticleViewer.this.parentActivity).drawerLayoutContainer.setAllowDrawContent(!ArticleViewer.this.isPhotoVisible || i != 255);
            }
            super.setAlpha(i);
        }

        public void draw(Canvas canvas) {
            Runnable runnable;
            super.draw(canvas);
            if (getAlpha() != 0 && (runnable = this.drawRunnable) != null) {
                runnable.run();
                this.drawRunnable = null;
            }
        }
    }

    /* access modifiers changed from: private */
    public class RadialProgressView {
        private float alpha = 1.0f;
        private float animatedAlphaValue = 1.0f;
        private float animatedProgressValue = 0.0f;
        private float animationProgressStart = 0.0f;
        private int backgroundState = -1;
        private float currentProgress = 0.0f;
        private long currentProgressTime = 0;
        private long lastUpdateTime = 0;
        private View parent;
        private int previousBackgroundState = -2;
        private RectF progressRect = new RectF();
        private float radOffset = 0.0f;
        private float scale = 1.0f;
        private int size = AndroidUtilities.dp(64.0f);

        public RadialProgressView(Context context, View view) {
            if (ArticleViewer.decelerateInterpolator == null) {
                DecelerateInterpolator unused = ArticleViewer.decelerateInterpolator = new DecelerateInterpolator(1.5f);
                Paint unused2 = ArticleViewer.progressPaint = new Paint(1);
                ArticleViewer.progressPaint.setStyle(Paint.Style.STROKE);
                ArticleViewer.progressPaint.setStrokeCap(Paint.Cap.ROUND);
                ArticleViewer.progressPaint.setStrokeWidth((float) AndroidUtilities.dp(3.0f));
                ArticleViewer.progressPaint.setColor(-1);
            }
            this.parent = view;
        }

        private void updateAnimation() {
            long currentTimeMillis = System.currentTimeMillis();
            long j = currentTimeMillis - this.lastUpdateTime;
            this.lastUpdateTime = currentTimeMillis;
            if (this.animatedProgressValue != 1.0f) {
                this.radOffset += ((float) (360 * j)) / 3000.0f;
                float f = this.currentProgress;
                float f2 = this.animationProgressStart;
                float f3 = f - f2;
                if (f3 > 0.0f) {
                    long j2 = this.currentProgressTime + j;
                    this.currentProgressTime = j2;
                    if (j2 >= 300) {
                        this.animatedProgressValue = f;
                        this.animationProgressStart = f;
                        this.currentProgressTime = 0;
                    } else {
                        this.animatedProgressValue = f2 + (f3 * ArticleViewer.decelerateInterpolator.getInterpolation(((float) this.currentProgressTime) / 300.0f));
                    }
                }
                this.parent.invalidate();
            }
            if (this.animatedProgressValue >= 1.0f && this.previousBackgroundState != -2) {
                float f4 = this.animatedAlphaValue - (((float) j) / 200.0f);
                this.animatedAlphaValue = f4;
                if (f4 <= 0.0f) {
                    this.animatedAlphaValue = 0.0f;
                    this.previousBackgroundState = -2;
                }
                this.parent.invalidate();
            }
        }

        public void setProgress(float f, boolean z) {
            if (!z) {
                this.animatedProgressValue = f;
                this.animationProgressStart = f;
            } else {
                this.animationProgressStart = this.animatedProgressValue;
            }
            this.currentProgress = f;
            this.currentProgressTime = 0;
        }

        public void setBackgroundState(int i, boolean z) {
            int i2;
            this.lastUpdateTime = System.currentTimeMillis();
            if (!z || (i2 = this.backgroundState) == i) {
                this.previousBackgroundState = -2;
            } else {
                this.previousBackgroundState = i2;
                this.animatedAlphaValue = 1.0f;
            }
            this.backgroundState = i;
            this.parent.invalidate();
        }

        public void setAlpha(float f) {
            this.alpha = f;
        }

        public void setScale(float f) {
            this.scale = f;
        }

        public void onDraw(Canvas canvas) {
            int i;
            Drawable drawable;
            Drawable drawable2;
            int i2 = (int) (((float) this.size) * this.scale);
            int containerViewWidth = (ArticleViewer.this.getContainerViewWidth() - i2) / 2;
            int containerViewHeight = (ArticleViewer.this.getContainerViewHeight() - i2) / 2;
            int i3 = this.previousBackgroundState;
            if (i3 >= 0 && i3 < 4 && (drawable2 = ArticleViewer.progressDrawables[this.previousBackgroundState]) != null) {
                drawable2.setAlpha((int) (this.animatedAlphaValue * 255.0f * this.alpha));
                drawable2.setBounds(containerViewWidth, containerViewHeight, containerViewWidth + i2, containerViewHeight + i2);
                drawable2.draw(canvas);
            }
            int i4 = this.backgroundState;
            if (i4 >= 0 && i4 < 4 && (drawable = ArticleViewer.progressDrawables[this.backgroundState]) != null) {
                if (this.previousBackgroundState != -2) {
                    drawable.setAlpha((int) ((1.0f - this.animatedAlphaValue) * 255.0f * this.alpha));
                } else {
                    drawable.setAlpha((int) (this.alpha * 255.0f));
                }
                drawable.setBounds(containerViewWidth, containerViewHeight, containerViewWidth + i2, containerViewHeight + i2);
                drawable.draw(canvas);
            }
            int i5 = this.backgroundState;
            if (i5 == 0 || i5 == 1 || (i = this.previousBackgroundState) == 0 || i == 1) {
                int dp = AndroidUtilities.dp(4.0f);
                if (this.previousBackgroundState != -2) {
                    ArticleViewer.progressPaint.setAlpha((int) (this.animatedAlphaValue * 255.0f * this.alpha));
                } else {
                    ArticleViewer.progressPaint.setAlpha((int) (this.alpha * 255.0f));
                }
                this.progressRect.set((float) (containerViewWidth + dp), (float) (containerViewHeight + dp), (float) ((containerViewWidth + i2) - dp), (float) ((containerViewHeight + i2) - dp));
                canvas.drawArc(this.progressRect, this.radOffset - 0.049804688f, Math.max(4.0f, this.animatedProgressValue * 360.0f), false, ArticleViewer.progressPaint);
                updateAnimation();
            }
        }
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private void onSharePressed() {
        if (this.parentActivity != null && this.currentMedia != null) {
            try {
                File mediaFile = getMediaFile(this.currentIndex);
                if (mediaFile == null || !mediaFile.exists()) {
                    AlertDialog.Builder builder = new AlertDialog.Builder(this.parentActivity);
                    builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
                    builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), null);
                    builder.setMessage(LocaleController.getString("PleaseDownload", R.string.PleaseDownload));
                    showDialog(builder.create());
                    return;
                }
                Intent intent = new Intent("android.intent.action.SEND");
                intent.setType(getMediaMime(this.currentIndex));
                if (Build.VERSION.SDK_INT >= 24) {
                    try {
                        intent.putExtra("android.intent.extra.STREAM", FileProvider.getUriForFile(this.parentActivity, "im.guobwnxjuc.messenger.provider", mediaFile));
                        intent.setFlags(1);
                    } catch (Exception unused) {
                        intent.putExtra("android.intent.extra.STREAM", Uri.fromFile(mediaFile));
                    }
                } else {
                    intent.putExtra("android.intent.extra.STREAM", Uri.fromFile(mediaFile));
                }
                this.parentActivity.startActivityForResult(Intent.createChooser(intent, LocaleController.getString("ShareFile", R.string.ShareFile)), 500);
            } catch (Exception e) {
                FileLog.e(e);
            }
        }
    }

    private void setScaleToFill() {
        float bitmapWidth = (float) this.centerImage.getBitmapWidth();
        float containerViewWidth = (float) getContainerViewWidth();
        float bitmapHeight = (float) this.centerImage.getBitmapHeight();
        float containerViewHeight = (float) getContainerViewHeight();
        float min = Math.min(containerViewHeight / bitmapHeight, containerViewWidth / bitmapWidth);
        float max = Math.max(containerViewWidth / ((float) ((int) (bitmapWidth * min))), containerViewHeight / ((float) ((int) (bitmapHeight * min))));
        this.scale = max;
        updateMinMax(max);
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private void updateVideoPlayerTime() {
        String str;
        VideoPlayer videoPlayer2 = this.videoPlayer;
        if (videoPlayer2 == null) {
            str = String.format("%02d:%02d / %02d:%02d", 0, 0, 0, 0);
        } else {
            long currentPosition = videoPlayer2.getCurrentPosition() / 1000;
            long duration = this.videoPlayer.getDuration() / 1000;
            if (duration == C.TIME_UNSET || currentPosition == C.TIME_UNSET) {
                str = String.format("%02d:%02d / %02d:%02d", 0, 0, 0, 0);
            } else {
                str = String.format("%02d:%02d / %02d:%02d", Long.valueOf(currentPosition / 60), Long.valueOf(currentPosition % 60), Long.valueOf(duration / 60), Long.valueOf(duration % 60));
            }
        }
        if (!TextUtils.equals(this.videoPlayerTime.getText(), str)) {
            this.videoPlayerTime.setText(str);
        }
    }

    private void preparePlayer(File file, boolean z) {
        if (this.parentActivity != null) {
            releasePlayer();
            if (this.videoTextureView == null) {
                AspectRatioFrameLayout aspectRatioFrameLayout2 = new AspectRatioFrameLayout(this.parentActivity);
                this.aspectRatioFrameLayout = aspectRatioFrameLayout2;
                aspectRatioFrameLayout2.setVisibility(4);
                this.photoContainerView.addView(this.aspectRatioFrameLayout, 0, LayoutHelper.createFrame(-1, -1, 17));
                TextureView textureView = new TextureView(this.parentActivity);
                this.videoTextureView = textureView;
                textureView.setOpaque(false);
                this.aspectRatioFrameLayout.addView(this.videoTextureView, LayoutHelper.createFrame(-1, -1, 17));
            }
            this.textureUploaded = false;
            this.videoCrossfadeStarted = false;
            TextureView textureView2 = this.videoTextureView;
            this.videoCrossfadeAlpha = 0.0f;
            textureView2.setAlpha(0.0f);
            this.videoPlayButton.setImageResource(R.drawable.inline_video_play);
            if (this.videoPlayer == null) {
                VideoPlayer videoPlayer2 = new VideoPlayer();
                this.videoPlayer = videoPlayer2;
                videoPlayer2.setTextureView(this.videoTextureView);
                this.videoPlayer.setDelegate(new VideoPlayer.VideoPlayerDelegate() {
                    /* class im.guobwnxjuc.ui.ArticleViewer.AnonymousClass19 */

                    @Override // im.guobwnxjuc.ui.components.VideoPlayer.VideoPlayerDelegate
                    public boolean onSurfaceDestroyed(SurfaceTexture surfaceTexture) {
                        return false;
                    }

                    @Override // im.guobwnxjuc.ui.components.VideoPlayer.VideoPlayerDelegate
                    public void onSurfaceTextureUpdated(SurfaceTexture surfaceTexture) {
                    }

                    @Override // im.guobwnxjuc.ui.components.VideoPlayer.VideoPlayerDelegate
                    public void onStateChanged(boolean z, int i) {
                        if (ArticleViewer.this.videoPlayer != null) {
                            if (i == 4 || i == 1) {
                                try {
                                    ArticleViewer.this.parentActivity.getWindow().clearFlags(128);
                                } catch (Exception e) {
                                    FileLog.e(e);
                                }
                            } else {
                                try {
                                    ArticleViewer.this.parentActivity.getWindow().addFlags(128);
                                } catch (Exception e2) {
                                    FileLog.e(e2);
                                }
                            }
                            if (i == 3 && ArticleViewer.this.aspectRatioFrameLayout.getVisibility() != 0) {
                                ArticleViewer.this.aspectRatioFrameLayout.setVisibility(0);
                            }
                            if (!ArticleViewer.this.videoPlayer.isPlaying() || i == 4) {
                                if (ArticleViewer.this.isPlaying) {
                                    ArticleViewer.this.isPlaying = false;
                                    ArticleViewer.this.videoPlayButton.setImageResource(R.drawable.inline_video_play);
                                    AndroidUtilities.cancelRunOnUIThread(ArticleViewer.this.updateProgressRunnable);
                                    if (i == 4 && !ArticleViewer.this.videoPlayerSeekbar.isDragging()) {
                                        ArticleViewer.this.videoPlayerSeekbar.setProgress(0.0f);
                                        ArticleViewer.this.videoPlayerControlFrameLayout.invalidate();
                                        ArticleViewer.this.videoPlayer.seekTo(0);
                                        ArticleViewer.this.videoPlayer.pause();
                                    }
                                }
                            } else if (!ArticleViewer.this.isPlaying) {
                                ArticleViewer.this.isPlaying = true;
                                ArticleViewer.this.videoPlayButton.setImageResource(R.drawable.inline_video_pause);
                                AndroidUtilities.runOnUIThread(ArticleViewer.this.updateProgressRunnable);
                            }
                            ArticleViewer.this.updateVideoPlayerTime();
                        }
                    }

                    @Override // im.guobwnxjuc.ui.components.VideoPlayer.VideoPlayerDelegate
                    public void onError(Exception exc) {
                        FileLog.e(exc);
                    }

                    @Override // im.guobwnxjuc.ui.components.VideoPlayer.VideoPlayerDelegate
                    public void onVideoSizeChanged(int i, int i2, int i3, float f) {
                        if (ArticleViewer.this.aspectRatioFrameLayout != null) {
                            if (!(i3 == 90 || i3 == 270)) {
                                i2 = i;
                                i = i2;
                            }
                            ArticleViewer.this.aspectRatioFrameLayout.setAspectRatio(i == 0 ? 1.0f : (((float) i2) * f) / ((float) i), i3);
                        }
                    }

                    @Override // im.guobwnxjuc.ui.components.VideoPlayer.VideoPlayerDelegate
                    public void onRenderedFirstFrame() {
                        if (!ArticleViewer.this.textureUploaded) {
                            ArticleViewer.this.textureUploaded = true;
                            ArticleViewer.this.containerView.invalidate();
                        }
                    }
                });
                VideoPlayer videoPlayer3 = this.videoPlayer;
                long j = 0;
                if (videoPlayer3 != null) {
                    long duration = videoPlayer3.getDuration();
                    if (duration != C.TIME_UNSET) {
                        j = duration;
                    }
                }
                long j2 = j / 1000;
                long j3 = j2 / 60;
                long j4 = j2 % 60;
                Math.ceil((double) this.videoPlayerTime.getPaint().measureText(String.format("%02d:%02d / %02d:%02d", Long.valueOf(j3), Long.valueOf(j4), Long.valueOf(j3), Long.valueOf(j4))));
            }
            this.videoPlayer.preparePlayer(Uri.fromFile(file), "other");
            this.bottomLayout.setVisibility(0);
            this.videoPlayer.setPlayWhenReady(z);
        }
    }

    private void releasePlayer() {
        VideoPlayer videoPlayer2 = this.videoPlayer;
        if (videoPlayer2 != null) {
            videoPlayer2.releasePlayer(true);
            this.videoPlayer = null;
        }
        try {
            this.parentActivity.getWindow().clearFlags(128);
        } catch (Exception e) {
            FileLog.e(e);
        }
        AspectRatioFrameLayout aspectRatioFrameLayout2 = this.aspectRatioFrameLayout;
        if (aspectRatioFrameLayout2 != null) {
            this.photoContainerView.removeView(aspectRatioFrameLayout2);
            this.aspectRatioFrameLayout = null;
        }
        if (this.videoTextureView != null) {
            this.videoTextureView = null;
        }
        if (this.isPlaying) {
            this.isPlaying = false;
            this.videoPlayButton.setImageResource(R.drawable.inline_video_play);
            AndroidUtilities.cancelRunOnUIThread(this.updateProgressRunnable);
        }
        this.bottomLayout.setVisibility(8);
    }

    private void toggleActionBar(boolean z, boolean z2) {
        if (z) {
            this.actionBar.setVisibility(0);
            if (this.videoPlayer != null) {
                this.bottomLayout.setVisibility(0);
            }
            if (this.captionTextView.getTag() != null) {
                this.captionTextView.setVisibility(0);
            }
        }
        this.isActionBarVisible = z;
        this.actionBar.setEnabled(z);
        this.bottomLayout.setEnabled(z);
        float f = 1.0f;
        if (z2) {
            ArrayList arrayList = new ArrayList();
            ActionBar actionBar2 = this.actionBar;
            Property property = View.ALPHA;
            float[] fArr = new float[1];
            fArr[0] = z ? 1.0f : 0.0f;
            arrayList.add(ObjectAnimator.ofFloat(actionBar2, property, fArr));
            GroupedPhotosListView groupedPhotosListView2 = this.groupedPhotosListView;
            Property property2 = View.ALPHA;
            float[] fArr2 = new float[1];
            fArr2[0] = z ? 1.0f : 0.0f;
            arrayList.add(ObjectAnimator.ofFloat(groupedPhotosListView2, property2, fArr2));
            FrameLayout frameLayout = this.bottomLayout;
            Property property3 = View.ALPHA;
            float[] fArr3 = new float[1];
            fArr3[0] = z ? 1.0f : 0.0f;
            arrayList.add(ObjectAnimator.ofFloat(frameLayout, property3, fArr3));
            if (this.captionTextView.getTag() != null) {
                TextView textView = this.captionTextView;
                Property property4 = View.ALPHA;
                float[] fArr4 = new float[1];
                if (!z) {
                    f = 0.0f;
                }
                fArr4[0] = f;
                arrayList.add(ObjectAnimator.ofFloat(textView, property4, fArr4));
            }
            AnimatorSet animatorSet = new AnimatorSet();
            this.currentActionBarAnimation = animatorSet;
            animatorSet.playTogether(arrayList);
            if (!z) {
                this.currentActionBarAnimation.addListener(new AnimatorListenerAdapter() {
                    /* class im.guobwnxjuc.ui.ArticleViewer.AnonymousClass20 */

                    public void onAnimationEnd(Animator animator) {
                        if (ArticleViewer.this.currentActionBarAnimation != null && ArticleViewer.this.currentActionBarAnimation.equals(animator)) {
                            ArticleViewer.this.actionBar.setVisibility(8);
                            if (ArticleViewer.this.videoPlayer != null) {
                                ArticleViewer.this.bottomLayout.setVisibility(8);
                            }
                            if (ArticleViewer.this.captionTextView.getTag() != null) {
                                ArticleViewer.this.captionTextView.setVisibility(8);
                            }
                            ArticleViewer.this.currentActionBarAnimation = null;
                        }
                    }
                });
            }
            this.currentActionBarAnimation.setDuration(200L);
            this.currentActionBarAnimation.start();
            return;
        }
        this.actionBar.setAlpha(z ? 1.0f : 0.0f);
        this.bottomLayout.setAlpha(z ? 1.0f : 0.0f);
        if (this.captionTextView.getTag() != null) {
            TextView textView2 = this.captionTextView;
            if (!z) {
                f = 0.0f;
            }
            textView2.setAlpha(f);
        }
        if (!z) {
            this.actionBar.setVisibility(8);
            if (this.videoPlayer != null) {
                this.bottomLayout.setVisibility(8);
            }
            if (this.captionTextView.getTag() != null) {
                this.captionTextView.setVisibility(8);
            }
        }
    }

    private String getFileName(int i) {
        TLObject media = getMedia(i);
        if (media instanceof TLRPC.Photo) {
            media = FileLoader.getClosestPhotoSizeWithSize(((TLRPC.Photo) media).sizes, AndroidUtilities.getPhotoSize());
        }
        return FileLoader.getAttachFileName(media);
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private TLObject getMedia(int i) {
        if (!this.imagesArr.isEmpty() && i < this.imagesArr.size() && i >= 0) {
            TLRPC.PageBlock pageBlock = this.imagesArr.get(i);
            if (pageBlock instanceof TLRPC.TL_pageBlockPhoto) {
                return getPhotoWithId(((TLRPC.TL_pageBlockPhoto) pageBlock).photo_id);
            }
            if (pageBlock instanceof TLRPC.TL_pageBlockVideo) {
                return getDocumentWithId(((TLRPC.TL_pageBlockVideo) pageBlock).video_id);
            }
        }
        return null;
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private File getMediaFile(int i) {
        TLRPC.Document documentWithId;
        TLRPC.PhotoSize closestPhotoSizeWithSize;
        if (!this.imagesArr.isEmpty() && i < this.imagesArr.size() && i >= 0) {
            TLRPC.PageBlock pageBlock = this.imagesArr.get(i);
            if (pageBlock instanceof TLRPC.TL_pageBlockPhoto) {
                TLRPC.Photo photoWithId = getPhotoWithId(((TLRPC.TL_pageBlockPhoto) pageBlock).photo_id);
                if (!(photoWithId == null || (closestPhotoSizeWithSize = FileLoader.getClosestPhotoSizeWithSize(photoWithId.sizes, AndroidUtilities.getPhotoSize())) == null)) {
                    return FileLoader.getPathToAttach(closestPhotoSizeWithSize, true);
                }
            } else if ((pageBlock instanceof TLRPC.TL_pageBlockVideo) && (documentWithId = getDocumentWithId(((TLRPC.TL_pageBlockVideo) pageBlock).video_id)) != null) {
                return FileLoader.getPathToAttach(documentWithId, true);
            }
        }
        return null;
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private boolean isVideoBlock(TLRPC.PageBlock pageBlock) {
        TLRPC.Document documentWithId;
        if (!(pageBlock instanceof TLRPC.TL_pageBlockVideo) || (documentWithId = getDocumentWithId(((TLRPC.TL_pageBlockVideo) pageBlock).video_id)) == null) {
            return false;
        }
        return MessageObject.isVideoDocument(documentWithId);
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private boolean isMediaVideo(int i) {
        return !this.imagesArr.isEmpty() && i < this.imagesArr.size() && i >= 0 && isVideoBlock(this.imagesArr.get(i));
    }

    private String getMediaMime(int i) {
        TLRPC.Document documentWithId;
        if (i < this.imagesArr.size() && i >= 0) {
            TLRPC.PageBlock pageBlock = this.imagesArr.get(i);
            if ((pageBlock instanceof TLRPC.TL_pageBlockVideo) && (documentWithId = getDocumentWithId(((TLRPC.TL_pageBlockVideo) pageBlock).video_id)) != null) {
                return documentWithId.mime_type;
            }
        }
        return "image/jpeg";
    }

    private TLRPC.PhotoSize getFileLocation(TLObject tLObject, int[] iArr) {
        TLRPC.PhotoSize closestPhotoSizeWithSize;
        if (tLObject instanceof TLRPC.Photo) {
            TLRPC.PhotoSize closestPhotoSizeWithSize2 = FileLoader.getClosestPhotoSizeWithSize(((TLRPC.Photo) tLObject).sizes, AndroidUtilities.getPhotoSize());
            if (closestPhotoSizeWithSize2 != null) {
                iArr[0] = closestPhotoSizeWithSize2.size;
                if (iArr[0] == 0) {
                    iArr[0] = -1;
                }
                return closestPhotoSizeWithSize2;
            }
            iArr[0] = -1;
            return null;
        } else if (!(tLObject instanceof TLRPC.Document) || (closestPhotoSizeWithSize = FileLoader.getClosestPhotoSizeWithSize(((TLRPC.Document) tLObject).thumbs, 90)) == null) {
            return null;
        } else {
            iArr[0] = closestPhotoSizeWithSize.size;
            if (iArr[0] == 0) {
                iArr[0] = -1;
            }
            return closestPhotoSizeWithSize;
        }
    }

    private void onPhotoShow(int i, PlaceProviderObject placeProviderObject) {
        this.currentIndex = -1;
        String[] strArr = this.currentFileNames;
        strArr[0] = null;
        strArr[1] = null;
        strArr[2] = null;
        ImageReceiver.BitmapHolder bitmapHolder = this.currentThumb;
        if (bitmapHolder != null) {
            bitmapHolder.release();
        }
        this.currentThumb = placeProviderObject != null ? placeProviderObject.thumb : null;
        this.menuItem.setVisibility(0);
        this.menuItem.hideSubItem(3);
        this.actionBar.setTranslationY(0.0f);
        this.captionTextView.setTag(null);
        this.captionTextView.setVisibility(8);
        for (int i2 = 0; i2 < 3; i2++) {
            RadialProgressView[] radialProgressViewArr = this.radialProgressViews;
            if (radialProgressViewArr[i2] != null) {
                radialProgressViewArr[i2].setBackgroundState(-1, false);
            }
        }
        setImageIndex(i, true);
        if (this.currentMedia != null && isMediaVideo(this.currentIndex)) {
            onActionClick(false);
        }
    }

    private void setImages() {
        if (this.photoAnimationInProgress == 0) {
            setIndexToImage(this.centerImage, this.currentIndex);
            setIndexToImage(this.rightImage, this.currentIndex + 1);
            setIndexToImage(this.leftImage, this.currentIndex - 1);
        }
    }

    /* JADX DEBUG: Failed to insert an additional move for type inference into block B:28:0x0096 */
    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    /* JADX WARNING: Removed duplicated region for block: B:29:0x0098  */
    /* JADX WARNING: Removed duplicated region for block: B:32:0x00b6  */
    /* JADX WARNING: Removed duplicated region for block: B:33:0x00d1  */
    private void setImageIndex(int i, boolean z) {
        boolean z2;
        boolean z3;
        boolean z4;
        CharSequence charSequence;
        ImageReceiver.BitmapHolder bitmapHolder;
        if (this.currentIndex != i) {
            if (!z && (bitmapHolder = this.currentThumb) != null) {
                bitmapHolder.release();
                this.currentThumb = null;
            }
            this.currentFileNames[0] = getFileName(i);
            this.currentFileNames[1] = getFileName(i + 1);
            this.currentFileNames[2] = getFileName(i - 1);
            int i2 = this.currentIndex;
            this.currentIndex = i;
            if (!this.imagesArr.isEmpty()) {
                int i3 = this.currentIndex;
                if (i3 < 0 || i3 >= this.imagesArr.size()) {
                    closePhoto(false);
                    return;
                }
                TLRPC.PageBlock pageBlock = this.imagesArr.get(this.currentIndex);
                TLRPC.PageBlock pageBlock2 = this.currentMedia;
                z3 = pageBlock2 != null && pageBlock2 == pageBlock;
                this.currentMedia = pageBlock;
                z2 = isMediaVideo(this.currentIndex);
                if (z2) {
                    this.menuItem.showSubItem(3);
                }
                if (pageBlock instanceof TLRPC.TL_pageBlockPhoto) {
                    String str = ((TLRPC.TL_pageBlockPhoto) pageBlock).url;
                    if (!TextUtils.isEmpty(str)) {
                        SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(str);
                        spannableStringBuilder.setSpan(new URLSpan(str) {
                            /* class im.guobwnxjuc.ui.ArticleViewer.AnonymousClass21 */

                            public void onClick(View view) {
                                ArticleViewer.this.openWebpageUrl(getURL(), null);
                            }
                        }, 0, str.length(), 34);
                        z4 = true;
                        charSequence = spannableStringBuilder;
                        if (charSequence == null) {
                            TLRPC.RichText blockCaption = getBlockCaption(this.currentMedia, 2);
                            charSequence = getText(null, blockCaption, blockCaption, this.currentMedia, -AndroidUtilities.dp(100.0f));
                        }
                        setCurrentCaption(charSequence, z4);
                        if (this.currentAnimation == null) {
                            this.menuItem.setVisibility(8);
                            this.menuItem.hideSubItem(1);
                            this.actionBar.setTitle(LocaleController.getString("AttachGif", R.string.AttachGif));
                        } else {
                            this.menuItem.setVisibility(0);
                            if (this.imagesArr.size() != 1) {
                                this.actionBar.setTitle(LocaleController.formatString("Of", R.string.Of, Integer.valueOf(this.currentIndex + 1), Integer.valueOf(this.imagesArr.size())));
                            } else if (z2) {
                                this.actionBar.setTitle(LocaleController.getString("AttachVideo", R.string.AttachVideo));
                            } else {
                                this.actionBar.setTitle(LocaleController.getString("AttachPhoto", R.string.AttachPhoto));
                            }
                            this.menuItem.showSubItem(1);
                        }
                        this.groupedPhotosListView.fillList();
                    }
                }
                charSequence = null;
                z4 = false;
                if (charSequence == null) {
                }
                setCurrentCaption(charSequence, z4);
                if (this.currentAnimation == null) {
                }
                this.groupedPhotosListView.fillList();
            } else {
                z3 = false;
                z2 = false;
            }
            int childCount = this.listView[0].getChildCount();
            int i4 = 0;
            while (true) {
                if (i4 >= childCount) {
                    break;
                }
                View childAt = this.listView[0].getChildAt(i4);
                if (childAt instanceof BlockSlideshowCell) {
                    BlockSlideshowCell blockSlideshowCell = (BlockSlideshowCell) childAt;
                    int indexOf = blockSlideshowCell.currentBlock.items.indexOf(this.currentMedia);
                    if (indexOf != -1) {
                        blockSlideshowCell.innerListView.setCurrentItem(indexOf, false);
                        break;
                    }
                }
                i4++;
            }
            PlaceProviderObject placeProviderObject = this.currentPlaceObject;
            if (placeProviderObject != null) {
                if (this.photoAnimationInProgress == 0) {
                    placeProviderObject.imageReceiver.setVisible(true, true);
                } else {
                    this.showAfterAnimation = placeProviderObject;
                }
            }
            PlaceProviderObject placeForPhoto = getPlaceForPhoto(this.currentMedia);
            this.currentPlaceObject = placeForPhoto;
            if (placeForPhoto != null) {
                if (this.photoAnimationInProgress == 0) {
                    placeForPhoto.imageReceiver.setVisible(false, true);
                } else {
                    this.hideAfterAnimation = placeForPhoto;
                }
            }
            if (!z3) {
                this.draggingDown = false;
                this.translationX = 0.0f;
                this.translationY = 0.0f;
                this.scale = 1.0f;
                this.animateToX = 0.0f;
                this.animateToY = 0.0f;
                this.animateToScale = 1.0f;
                this.animationStartTime = 0;
                this.imageMoveAnimation = null;
                AspectRatioFrameLayout aspectRatioFrameLayout2 = this.aspectRatioFrameLayout;
                if (aspectRatioFrameLayout2 != null) {
                    aspectRatioFrameLayout2.setVisibility(4);
                }
                releasePlayer();
                this.pinchStartDistance = 0.0f;
                this.pinchStartScale = 1.0f;
                this.pinchCenterX = 0.0f;
                this.pinchCenterY = 0.0f;
                this.pinchStartX = 0.0f;
                this.pinchStartY = 0.0f;
                this.moveStartX = 0.0f;
                this.moveStartY = 0.0f;
                this.zooming = false;
                this.moving = false;
                this.doubleTap = false;
                this.invalidCoords = false;
                this.canDragDown = true;
                this.changingPage = false;
                this.switchImageAfterAnimation = 0;
                this.canZoom = (this.currentFileNames[0] == null || z2 || this.radialProgressViews[0].backgroundState == 0) ? false : true;
                updateMinMax(this.scale);
            }
            if (i2 == -1) {
                setImages();
                for (int i5 = 0; i5 < 3; i5++) {
                    checkProgress(i5, false);
                }
                return;
            }
            checkProgress(0, false);
            int i6 = this.currentIndex;
            if (i2 > i6) {
                ImageReceiver imageReceiver = this.rightImage;
                this.rightImage = this.centerImage;
                this.centerImage = this.leftImage;
                this.leftImage = imageReceiver;
                RadialProgressView[] radialProgressViewArr = this.radialProgressViews;
                RadialProgressView radialProgressView = radialProgressViewArr[0];
                radialProgressViewArr[0] = radialProgressViewArr[2];
                radialProgressViewArr[2] = radialProgressView;
                setIndexToImage(imageReceiver, i6 - 1);
                checkProgress(1, false);
                checkProgress(2, false);
            } else if (i2 < i6) {
                ImageReceiver imageReceiver2 = this.leftImage;
                this.leftImage = this.centerImage;
                this.centerImage = this.rightImage;
                this.rightImage = imageReceiver2;
                RadialProgressView[] radialProgressViewArr2 = this.radialProgressViews;
                RadialProgressView radialProgressView2 = radialProgressViewArr2[0];
                radialProgressViewArr2[0] = radialProgressViewArr2[1];
                radialProgressViewArr2[1] = radialProgressView2;
                setIndexToImage(imageReceiver2, i6 + 1);
                checkProgress(1, false);
                checkProgress(2, false);
            }
        }
    }

    private void setCurrentCaption(CharSequence charSequence, boolean z) {
        if (!TextUtils.isEmpty(charSequence)) {
            Theme.createChatResources(null, true);
            if (!z) {
                if (charSequence instanceof Spannable) {
                    Spannable spannable = (Spannable) charSequence;
                    TextPaintUrlSpan[] textPaintUrlSpanArr = (TextPaintUrlSpan[]) spannable.getSpans(0, charSequence.length(), TextPaintUrlSpan.class);
                    SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(charSequence.toString());
                    if (textPaintUrlSpanArr != null && textPaintUrlSpanArr.length > 0) {
                        for (int i = 0; i < textPaintUrlSpanArr.length; i++) {
                            spannableStringBuilder.setSpan(new URLSpan(textPaintUrlSpanArr[i].getUrl()) {
                                /* class im.guobwnxjuc.ui.ArticleViewer.AnonymousClass22 */

                                public void onClick(View view) {
                                    ArticleViewer.this.openWebpageUrl(getURL(), null);
                                }
                            }, spannable.getSpanStart(textPaintUrlSpanArr[i]), spannable.getSpanEnd(textPaintUrlSpanArr[i]), 33);
                        }
                    }
                    charSequence = spannableStringBuilder;
                } else {
                    charSequence = new SpannableStringBuilder(charSequence.toString());
                }
            }
            CharSequence replaceEmoji = Emoji.replaceEmoji(charSequence, this.captionTextView.getPaint().getFontMetricsInt(), AndroidUtilities.dp(20.0f), false);
            this.captionTextView.setTag(replaceEmoji);
            this.captionTextView.setText(replaceEmoji);
            this.captionTextView.setVisibility(0);
            return;
        }
        this.captionTextView.setTag(null);
        this.captionTextView.setVisibility(8);
    }

    private void checkProgress(int i, boolean z) {
        if (this.currentFileNames[i] != null) {
            int i2 = this.currentIndex;
            boolean z2 = true;
            if (i == 1) {
                i2++;
            } else if (i == 2) {
                i2--;
            }
            File mediaFile = getMediaFile(i2);
            boolean isMediaVideo = isMediaVideo(i2);
            if (mediaFile == null || !mediaFile.exists()) {
                if (!isMediaVideo) {
                    this.radialProgressViews[i].setBackgroundState(0, z);
                } else if (!FileLoader.getInstance(this.currentAccount).isLoadingFile(this.currentFileNames[i])) {
                    this.radialProgressViews[i].setBackgroundState(2, false);
                } else {
                    this.radialProgressViews[i].setBackgroundState(1, false);
                }
                Float fileProgress = ImageLoader.getInstance().getFileProgress(this.currentFileNames[i]);
                if (fileProgress == null) {
                    fileProgress = Float.valueOf(0.0f);
                }
                this.radialProgressViews[i].setProgress(fileProgress.floatValue(), false);
            } else if (isMediaVideo) {
                this.radialProgressViews[i].setBackgroundState(3, z);
            } else {
                this.radialProgressViews[i].setBackgroundState(-1, z);
            }
            if (i == 0) {
                if (this.currentFileNames[0] == null || isMediaVideo || this.radialProgressViews[0].backgroundState == 0) {
                    z2 = false;
                }
                this.canZoom = z2;
                return;
            }
            return;
        }
        this.radialProgressViews[i].setBackgroundState(-1, z);
    }

    private void setIndexToImage(ImageReceiver imageReceiver, int i) {
        imageReceiver.setOrientation(0, false);
        int[] iArr = new int[1];
        TLObject media = getMedia(i);
        TLRPC.PhotoSize fileLocation = getFileLocation(media, iArr);
        if (fileLocation != null) {
            if (media instanceof TLRPC.Photo) {
                TLRPC.Photo photo = (TLRPC.Photo) media;
                ImageReceiver.BitmapHolder bitmapHolder = this.currentThumb;
                if (bitmapHolder == null || imageReceiver != this.centerImage) {
                    bitmapHolder = null;
                }
                if (iArr[0] == 0) {
                    iArr[0] = -1;
                }
                imageReceiver.setImage(ImageLocation.getForPhoto(fileLocation, photo), null, ImageLocation.getForPhoto(FileLoader.getClosestPhotoSizeWithSize(photo.sizes, 80), photo), "b", bitmapHolder != null ? new BitmapDrawable(bitmapHolder.bitmap) : null, iArr[0], null, this.currentPage, 1);
            } else if (!isMediaVideo(i)) {
                AnimatedFileDrawable animatedFileDrawable = this.currentAnimation;
                if (animatedFileDrawable != null) {
                    imageReceiver.setImageBitmap(animatedFileDrawable);
                    this.currentAnimation.setSecondParentView(this.photoContainerView);
                }
            } else if (!(fileLocation.location instanceof TLRPC.TL_fileLocationUnavailable)) {
                ImageReceiver.BitmapHolder bitmapHolder2 = this.currentThumb;
                if (bitmapHolder2 == null || imageReceiver != this.centerImage) {
                    bitmapHolder2 = null;
                }
                imageReceiver.setImage(null, null, ImageLocation.getForDocument(fileLocation, (TLRPC.Document) media), "b", bitmapHolder2 != null ? new BitmapDrawable(bitmapHolder2.bitmap) : null, 0, null, this.currentPage, 1);
            } else {
                imageReceiver.setImageBitmap(this.parentActivity.getResources().getDrawable(R.drawable.photoview_placeholder));
            }
        } else if (iArr[0] == 0) {
            imageReceiver.setImageBitmap((Bitmap) null);
        } else {
            imageReceiver.setImageBitmap(this.parentActivity.getResources().getDrawable(R.drawable.photoview_placeholder));
        }
    }

    public boolean isShowingImage(TLRPC.PageBlock pageBlock) {
        return this.isPhotoVisible && !this.disableShowCheck && pageBlock != null && this.currentMedia == pageBlock;
    }

    private boolean checkPhotoAnimation() {
        if (this.photoAnimationInProgress != 0 && Math.abs(this.photoTransitionAnimationStartTime - System.currentTimeMillis()) >= 500) {
            Runnable runnable = this.photoAnimationEndRunnable;
            if (runnable != null) {
                runnable.run();
                this.photoAnimationEndRunnable = null;
            }
            this.photoAnimationInProgress = 0;
        }
        if (this.photoAnimationInProgress != 0) {
            return true;
        }
        return false;
    }

    public boolean openPhoto(TLRPC.PageBlock pageBlock) {
        PlaceProviderObject placeForPhoto;
        int i;
        Object obj;
        if (this.pageSwitchAnimation != null || this.parentActivity == null || this.isPhotoVisible || checkPhotoAnimation() || pageBlock == null || (placeForPhoto = getPlaceForPhoto(pageBlock)) == null) {
            return false;
        }
        NotificationCenter.getInstance(this.currentAccount).addObserver(this, NotificationCenter.fileDidFailToLoad);
        NotificationCenter.getInstance(this.currentAccount).addObserver(this, NotificationCenter.fileDidLoad);
        NotificationCenter.getInstance(this.currentAccount).addObserver(this, NotificationCenter.FileLoadProgressChanged);
        NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.emojiDidLoad);
        if (this.velocityTracker == null) {
            this.velocityTracker = VelocityTracker.obtain();
        }
        this.isPhotoVisible = true;
        toggleActionBar(true, false);
        this.actionBar.setAlpha(0.0f);
        this.bottomLayout.setAlpha(0.0f);
        this.captionTextView.setAlpha(0.0f);
        this.photoBackgroundDrawable.setAlpha(0);
        this.groupedPhotosListView.setAlpha(0.0f);
        this.photoContainerView.setAlpha(1.0f);
        this.disableShowCheck = true;
        this.photoAnimationInProgress = 1;
        if (pageBlock != null) {
            this.currentAnimation = placeForPhoto.imageReceiver.getAnimation();
        }
        int indexOf = this.adapter[0].photoBlocks.indexOf(pageBlock);
        this.imagesArr.clear();
        if (!(pageBlock instanceof TLRPC.TL_pageBlockVideo) || isVideoBlock(pageBlock)) {
            this.imagesArr.addAll(this.adapter[0].photoBlocks);
        } else {
            this.imagesArr.add(pageBlock);
            indexOf = 0;
        }
        onPhotoShow(indexOf, placeForPhoto);
        RectF drawRegion = placeForPhoto.imageReceiver.getDrawRegion();
        int orientation = placeForPhoto.imageReceiver.getOrientation();
        int animatedOrientation = placeForPhoto.imageReceiver.getAnimatedOrientation();
        if (animatedOrientation != 0) {
            orientation = animatedOrientation;
        }
        this.animatingImageView.setVisibility(0);
        this.animatingImageView.setRadius(placeForPhoto.radius);
        this.animatingImageView.setOrientation(orientation);
        this.animatingImageView.setNeedRadius(placeForPhoto.radius != 0);
        this.animatingImageView.setImageBitmap(placeForPhoto.thumb);
        this.animatingImageView.setAlpha(1.0f);
        this.animatingImageView.setPivotX(0.0f);
        this.animatingImageView.setPivotY(0.0f);
        this.animatingImageView.setScaleX(placeForPhoto.scale);
        this.animatingImageView.setScaleY(placeForPhoto.scale);
        this.animatingImageView.setTranslationX(((float) placeForPhoto.viewX) + (drawRegion.left * placeForPhoto.scale));
        this.animatingImageView.setTranslationY(((float) placeForPhoto.viewY) + (drawRegion.top * placeForPhoto.scale));
        ViewGroup.LayoutParams layoutParams = this.animatingImageView.getLayoutParams();
        layoutParams.width = (int) drawRegion.width();
        layoutParams.height = (int) drawRegion.height();
        this.animatingImageView.setLayoutParams(layoutParams);
        float f = ((float) AndroidUtilities.displaySize.x) / ((float) layoutParams.width);
        float f2 = ((float) (AndroidUtilities.displaySize.y + AndroidUtilities.statusBarHeight)) / ((float) layoutParams.height);
        if (f > f2) {
            f = f2;
        }
        float f3 = ((float) layoutParams.height) * f;
        float f4 = (((float) AndroidUtilities.displaySize.x) - (((float) layoutParams.width) * f)) / 2.0f;
        if (Build.VERSION.SDK_INT >= 21 && (obj = this.lastInsets) != null) {
            f4 += (float) ((WindowInsets) obj).getSystemWindowInsetLeft();
        }
        float f5 = (((float) (AndroidUtilities.displaySize.y + AndroidUtilities.statusBarHeight)) - f3) / 2.0f;
        if (placeForPhoto.imageReceiver.isAspectFit()) {
            i = 0;
        } else {
            i = (int) Math.abs(drawRegion.left - ((float) placeForPhoto.imageReceiver.getImageX()));
        }
        int abs = (int) Math.abs(drawRegion.top - ((float) placeForPhoto.imageReceiver.getImageY()));
        int[] iArr = new int[2];
        placeForPhoto.parentView.getLocationInWindow(iArr);
        int i2 = (int) ((((float) iArr[1]) - (((float) placeForPhoto.viewY) + drawRegion.top)) + ((float) placeForPhoto.clipTopAddition));
        if (i2 < 0) {
            i2 = 0;
        }
        int height = (int) ((((((float) placeForPhoto.viewY) + drawRegion.top) + ((float) layoutParams.height)) - ((float) (iArr[1] + placeForPhoto.parentView.getHeight()))) + ((float) placeForPhoto.clipBottomAddition));
        if (height < 0) {
            height = 0;
        }
        int max = Math.max(i2, abs);
        int max2 = Math.max(height, abs);
        this.animationValues[0][0] = this.animatingImageView.getScaleX();
        this.animationValues[0][1] = this.animatingImageView.getScaleY();
        this.animationValues[0][2] = this.animatingImageView.getTranslationX();
        this.animationValues[0][3] = this.animatingImageView.getTranslationY();
        float f6 = (float) i;
        this.animationValues[0][4] = placeForPhoto.scale * f6;
        this.animationValues[0][5] = ((float) max) * placeForPhoto.scale;
        this.animationValues[0][6] = ((float) max2) * placeForPhoto.scale;
        this.animationValues[0][7] = (float) this.animatingImageView.getRadius();
        this.animationValues[0][8] = ((float) abs) * placeForPhoto.scale;
        this.animationValues[0][9] = f6 * placeForPhoto.scale;
        float[][] fArr = this.animationValues;
        fArr[1][0] = f;
        fArr[1][1] = f;
        fArr[1][2] = f4;
        fArr[1][3] = f5;
        fArr[1][4] = 0.0f;
        fArr[1][5] = 0.0f;
        fArr[1][6] = 0.0f;
        fArr[1][7] = 0.0f;
        fArr[1][8] = 0.0f;
        fArr[1][9] = 0.0f;
        this.photoContainerView.setVisibility(0);
        this.photoContainerBackground.setVisibility(0);
        this.animatingImageView.setAnimationProgress(0.0f);
        AnimatorSet animatorSet = new AnimatorSet();
        animatorSet.playTogether(ObjectAnimator.ofFloat(this.animatingImageView, "animationProgress", 0.0f, 1.0f), ObjectAnimator.ofInt(this.photoBackgroundDrawable, AnimationProperties.COLOR_DRAWABLE_ALPHA, 0, 255), ObjectAnimator.ofFloat(this.actionBar, View.ALPHA, 0.0f, 1.0f), ObjectAnimator.ofFloat(this.bottomLayout, View.ALPHA, 0.0f, 1.0f), ObjectAnimator.ofFloat(this.captionTextView, View.ALPHA, 0.0f, 1.0f), ObjectAnimator.ofFloat(this.groupedPhotosListView, View.ALPHA, 0.0f, 1.0f));
        this.photoAnimationEndRunnable = new Runnable() {
            /* class im.guobwnxjuc.ui.$$Lambda$ArticleViewer$irgN5P39t9uvpnyxoO5UgfE35Fk */

            public final void run() {
                ArticleViewer.this.lambda$openPhoto$37$ArticleViewer();
            }
        };
        animatorSet.setDuration(200L);
        animatorSet.addListener(new AnimatorListenerAdapter() {
            /* class im.guobwnxjuc.ui.ArticleViewer.AnonymousClass23 */

            public void onAnimationEnd(Animator animator) {
                AndroidUtilities.runOnUIThread(new Runnable() {
                    /* class im.guobwnxjuc.ui.$$Lambda$ArticleViewer$23$CqOfjbPFPlu2AL_jxw2MRVM2z_8 */

                    public final void run() {
                        ArticleViewer.AnonymousClass23.this.lambda$onAnimationEnd$0$ArticleViewer$23();
                    }
                });
            }

            public /* synthetic */ void lambda$onAnimationEnd$0$ArticleViewer$23() {
                NotificationCenter.getInstance(ArticleViewer.this.currentAccount).setAnimationInProgress(false);
                if (ArticleViewer.this.photoAnimationEndRunnable != null) {
                    ArticleViewer.this.photoAnimationEndRunnable.run();
                    ArticleViewer.this.photoAnimationEndRunnable = null;
                }
            }
        });
        this.photoTransitionAnimationStartTime = System.currentTimeMillis();
        AndroidUtilities.runOnUIThread(new Runnable(animatorSet) {
            /* class im.guobwnxjuc.ui.$$Lambda$ArticleViewer$XzPzlcjJNTqGoTrYywG1x4fC3q4 */
            private final /* synthetic */ AnimatorSet f$1;

            {
                this.f$1 = r2;
            }

            public final void run() {
                ArticleViewer.this.lambda$openPhoto$38$ArticleViewer(this.f$1);
            }
        });
        if (Build.VERSION.SDK_INT >= 18) {
            this.photoContainerView.setLayerType(2, null);
        }
        this.photoBackgroundDrawable.drawRunnable = new Runnable(placeForPhoto) {
            /* class im.guobwnxjuc.ui.$$Lambda$ArticleViewer$Ov8TnubqV1ISBZAKwfAm_ReAvWY */
            private final /* synthetic */ ArticleViewer.PlaceProviderObject f$1;

            {
                this.f$1 = r2;
            }

            public final void run() {
                ArticleViewer.this.lambda$openPhoto$39$ArticleViewer(this.f$1);
            }
        };
        return true;
    }

    public /* synthetic */ void lambda$openPhoto$37$ArticleViewer() {
        if (this.photoContainerView != null) {
            if (Build.VERSION.SDK_INT >= 18) {
                this.photoContainerView.setLayerType(0, null);
            }
            this.photoAnimationInProgress = 0;
            this.photoTransitionAnimationStartTime = 0;
            setImages();
            this.photoContainerView.invalidate();
            this.animatingImageView.setVisibility(8);
            PlaceProviderObject placeProviderObject = this.showAfterAnimation;
            if (placeProviderObject != null) {
                placeProviderObject.imageReceiver.setVisible(true, true);
            }
            PlaceProviderObject placeProviderObject2 = this.hideAfterAnimation;
            if (placeProviderObject2 != null) {
                placeProviderObject2.imageReceiver.setVisible(false, true);
            }
        }
    }

    public /* synthetic */ void lambda$openPhoto$38$ArticleViewer(AnimatorSet animatorSet) {
        NotificationCenter.getInstance(this.currentAccount).setAllowedNotificationsDutingAnimation(new int[]{NotificationCenter.dialogsNeedReload, NotificationCenter.closeChats});
        NotificationCenter.getInstance(this.currentAccount).setAnimationInProgress(true);
        animatorSet.start();
    }

    public /* synthetic */ void lambda$openPhoto$39$ArticleViewer(PlaceProviderObject placeProviderObject) {
        this.disableShowCheck = false;
        placeProviderObject.imageReceiver.setVisible(false, true);
    }

    public void closePhoto(boolean z) {
        RectF rectF;
        int i;
        Object obj;
        if (this.parentActivity != null && this.isPhotoVisible && !checkPhotoAnimation()) {
            releasePlayer();
            NotificationCenter.getInstance(this.currentAccount).removeObserver(this, NotificationCenter.fileDidFailToLoad);
            NotificationCenter.getInstance(this.currentAccount).removeObserver(this, NotificationCenter.fileDidLoad);
            NotificationCenter.getInstance(this.currentAccount).removeObserver(this, NotificationCenter.FileLoadProgressChanged);
            NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.needSetDayNightTheme);
            NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.emojiDidLoad);
            this.isActionBarVisible = false;
            VelocityTracker velocityTracker2 = this.velocityTracker;
            if (velocityTracker2 != null) {
                velocityTracker2.recycle();
                this.velocityTracker = null;
            }
            PlaceProviderObject placeForPhoto = getPlaceForPhoto(this.currentMedia);
            if (z) {
                this.photoAnimationInProgress = 1;
                this.animatingImageView.setVisibility(0);
                this.photoContainerView.invalidate();
                AnimatorSet animatorSet = new AnimatorSet();
                ViewGroup.LayoutParams layoutParams = this.animatingImageView.getLayoutParams();
                int orientation = this.centerImage.getOrientation();
                int animatedOrientation = (placeForPhoto == null || placeForPhoto.imageReceiver == null) ? 0 : placeForPhoto.imageReceiver.getAnimatedOrientation();
                if (animatedOrientation != 0) {
                    orientation = animatedOrientation;
                }
                this.animatingImageView.setOrientation(orientation);
                if (placeForPhoto != null) {
                    this.animatingImageView.setNeedRadius(placeForPhoto.radius != 0);
                    rectF = placeForPhoto.imageReceiver.getDrawRegion();
                    layoutParams.width = (int) rectF.width();
                    layoutParams.height = (int) rectF.height();
                    this.animatingImageView.setImageBitmap(placeForPhoto.thumb);
                } else {
                    this.animatingImageView.setNeedRadius(false);
                    layoutParams.width = this.centerImage.getImageWidth();
                    layoutParams.height = this.centerImage.getImageHeight();
                    this.animatingImageView.setImageBitmap(this.centerImage.getBitmapSafe());
                    rectF = null;
                }
                this.animatingImageView.setLayoutParams(layoutParams);
                float f = ((float) AndroidUtilities.displaySize.x) / ((float) layoutParams.width);
                float f2 = ((float) (AndroidUtilities.displaySize.y + AndroidUtilities.statusBarHeight)) / ((float) layoutParams.height);
                if (f > f2) {
                    f = f2;
                }
                float f3 = ((float) layoutParams.height) * this.scale * f;
                float f4 = (((float) AndroidUtilities.displaySize.x) - ((((float) layoutParams.width) * this.scale) * f)) / 2.0f;
                if (Build.VERSION.SDK_INT >= 21 && (obj = this.lastInsets) != null) {
                    f4 += (float) ((WindowInsets) obj).getSystemWindowInsetLeft();
                }
                this.animatingImageView.setTranslationX(f4 + this.translationX);
                this.animatingImageView.setTranslationY(((((float) (AndroidUtilities.displaySize.y + AndroidUtilities.statusBarHeight)) - f3) / 2.0f) + this.translationY);
                this.animatingImageView.setScaleX(this.scale * f);
                this.animatingImageView.setScaleY(this.scale * f);
                if (placeForPhoto != null) {
                    placeForPhoto.imageReceiver.setVisible(false, true);
                    if (placeForPhoto.imageReceiver.isAspectFit()) {
                        i = 0;
                    } else {
                        i = (int) Math.abs(rectF.left - ((float) placeForPhoto.imageReceiver.getImageX()));
                    }
                    int abs = (int) Math.abs(rectF.top - ((float) placeForPhoto.imageReceiver.getImageY()));
                    int[] iArr = new int[2];
                    placeForPhoto.parentView.getLocationInWindow(iArr);
                    int i2 = (int) ((((float) iArr[1]) - (((float) placeForPhoto.viewY) + rectF.top)) + ((float) placeForPhoto.clipTopAddition));
                    if (i2 < 0) {
                        i2 = 0;
                    }
                    int height = (int) ((((((float) placeForPhoto.viewY) + rectF.top) + (rectF.bottom - rectF.top)) - ((float) (iArr[1] + placeForPhoto.parentView.getHeight()))) + ((float) placeForPhoto.clipBottomAddition));
                    if (height < 0) {
                        height = 0;
                    }
                    int max = Math.max(i2, abs);
                    int max2 = Math.max(height, abs);
                    this.animationValues[0][0] = this.animatingImageView.getScaleX();
                    this.animationValues[0][1] = this.animatingImageView.getScaleY();
                    this.animationValues[0][2] = this.animatingImageView.getTranslationX();
                    this.animationValues[0][3] = this.animatingImageView.getTranslationY();
                    float[][] fArr = this.animationValues;
                    fArr[0][4] = 0.0f;
                    fArr[0][5] = 0.0f;
                    fArr[0][6] = 0.0f;
                    fArr[0][7] = 0.0f;
                    fArr[0][8] = 0.0f;
                    fArr[0][9] = 0.0f;
                    fArr[1][0] = placeForPhoto.scale;
                    this.animationValues[1][1] = placeForPhoto.scale;
                    this.animationValues[1][2] = ((float) placeForPhoto.viewX) + (rectF.left * placeForPhoto.scale);
                    this.animationValues[1][3] = ((float) placeForPhoto.viewY) + (rectF.top * placeForPhoto.scale);
                    float f5 = (float) i;
                    this.animationValues[1][4] = placeForPhoto.scale * f5;
                    this.animationValues[1][5] = ((float) max) * placeForPhoto.scale;
                    this.animationValues[1][6] = ((float) max2) * placeForPhoto.scale;
                    this.animationValues[1][7] = (float) placeForPhoto.radius;
                    this.animationValues[1][8] = ((float) abs) * placeForPhoto.scale;
                    this.animationValues[1][9] = f5 * placeForPhoto.scale;
                    animatorSet.playTogether(ObjectAnimator.ofFloat(this.animatingImageView, "animationProgress", 0.0f, 1.0f), ObjectAnimator.ofInt(this.photoBackgroundDrawable, AnimationProperties.COLOR_DRAWABLE_ALPHA, 0), ObjectAnimator.ofFloat(this.actionBar, View.ALPHA, 0.0f), ObjectAnimator.ofFloat(this.bottomLayout, View.ALPHA, 0.0f), ObjectAnimator.ofFloat(this.captionTextView, View.ALPHA, 0.0f), ObjectAnimator.ofFloat(this.groupedPhotosListView, View.ALPHA, 0.0f));
                } else {
                    int i3 = AndroidUtilities.displaySize.y + AndroidUtilities.statusBarHeight;
                    Animator[] animatorArr = new Animator[7];
                    animatorArr[0] = ObjectAnimator.ofInt(this.photoBackgroundDrawable, AnimationProperties.COLOR_DRAWABLE_ALPHA, 0);
                    animatorArr[1] = ObjectAnimator.ofFloat(this.animatingImageView, View.ALPHA, 0.0f);
                    ClippingImageView clippingImageView = this.animatingImageView;
                    Property property = View.TRANSLATION_Y;
                    float[] fArr2 = new float[1];
                    if (this.translationY < 0.0f) {
                        i3 = -i3;
                    }
                    fArr2[0] = (float) i3;
                    animatorArr[2] = ObjectAnimator.ofFloat(clippingImageView, property, fArr2);
                    animatorArr[3] = ObjectAnimator.ofFloat(this.actionBar, View.ALPHA, 0.0f);
                    animatorArr[4] = ObjectAnimator.ofFloat(this.bottomLayout, View.ALPHA, 0.0f);
                    animatorArr[5] = ObjectAnimator.ofFloat(this.captionTextView, View.ALPHA, 0.0f);
                    animatorArr[6] = ObjectAnimator.ofFloat(this.groupedPhotosListView, View.ALPHA, 0.0f);
                    animatorSet.playTogether(animatorArr);
                }
                this.photoAnimationEndRunnable = new Runnable(placeForPhoto) {
                    /* class im.guobwnxjuc.ui.$$Lambda$ArticleViewer$kB8UPj_q1oVZrrgq17bv5XVyIAI */
                    private final /* synthetic */ ArticleViewer.PlaceProviderObject f$1;

                    {
                        this.f$1 = r2;
                    }

                    public final void run() {
                        ArticleViewer.this.lambda$closePhoto$40$ArticleViewer(this.f$1);
                    }
                };
                animatorSet.setDuration(200L);
                animatorSet.addListener(new AnimatorListenerAdapter() {
                    /* class im.guobwnxjuc.ui.ArticleViewer.AnonymousClass24 */

                    public void onAnimationEnd(Animator animator) {
                        AndroidUtilities.runOnUIThread(new Runnable() {
                            /* class im.guobwnxjuc.ui.$$Lambda$ArticleViewer$24$YOILkOOvpqKW2tNd2ds5dgbzg */

                            public final void run() {
                                ArticleViewer.AnonymousClass24.this.lambda$onAnimationEnd$0$ArticleViewer$24();
                            }
                        });
                    }

                    public /* synthetic */ void lambda$onAnimationEnd$0$ArticleViewer$24() {
                        if (ArticleViewer.this.photoAnimationEndRunnable != null) {
                            ArticleViewer.this.photoAnimationEndRunnable.run();
                            ArticleViewer.this.photoAnimationEndRunnable = null;
                        }
                    }
                });
                this.photoTransitionAnimationStartTime = System.currentTimeMillis();
                if (Build.VERSION.SDK_INT >= 18) {
                    this.photoContainerView.setLayerType(2, null);
                }
                animatorSet.start();
            } else {
                this.photoContainerView.setVisibility(4);
                this.photoContainerBackground.setVisibility(4);
                this.photoAnimationInProgress = 0;
                onPhotoClosed(placeForPhoto);
                this.photoContainerView.setScaleX(1.0f);
                this.photoContainerView.setScaleY(1.0f);
            }
            AnimatedFileDrawable animatedFileDrawable = this.currentAnimation;
            if (animatedFileDrawable != null) {
                animatedFileDrawable.setSecondParentView(null);
                this.currentAnimation = null;
                this.centerImage.setImageBitmap((Drawable) null);
            }
        }
    }

    public /* synthetic */ void lambda$closePhoto$40$ArticleViewer(PlaceProviderObject placeProviderObject) {
        if (Build.VERSION.SDK_INT >= 18) {
            this.photoContainerView.setLayerType(0, null);
        }
        this.photoContainerView.setVisibility(4);
        this.photoContainerBackground.setVisibility(4);
        this.photoAnimationInProgress = 0;
        onPhotoClosed(placeProviderObject);
    }

    private void onPhotoClosed(PlaceProviderObject placeProviderObject) {
        this.isPhotoVisible = false;
        this.disableShowCheck = true;
        this.currentMedia = null;
        ImageReceiver.BitmapHolder bitmapHolder = this.currentThumb;
        if (bitmapHolder != null) {
            bitmapHolder.release();
            this.currentThumb = null;
        }
        AnimatedFileDrawable animatedFileDrawable = this.currentAnimation;
        if (animatedFileDrawable != null) {
            animatedFileDrawable.setSecondParentView(null);
            this.currentAnimation = null;
        }
        for (int i = 0; i < 3; i++) {
            RadialProgressView[] radialProgressViewArr = this.radialProgressViews;
            if (radialProgressViewArr[i] != null) {
                radialProgressViewArr[i].setBackgroundState(-1, false);
            }
        }
        Bitmap bitmap = null;
        this.centerImage.setImageBitmap(bitmap);
        this.leftImage.setImageBitmap(bitmap);
        this.rightImage.setImageBitmap(bitmap);
        this.photoContainerView.post(new Runnable() {
            /* class im.guobwnxjuc.ui.$$Lambda$ArticleViewer$0NZKQmRNOMFERMHVzJ_yhBNwvyw */

            public final void run() {
                ArticleViewer.this.lambda$onPhotoClosed$41$ArticleViewer();
            }
        });
        this.disableShowCheck = false;
        if (placeProviderObject != null) {
            placeProviderObject.imageReceiver.setVisible(true, true);
        }
        this.groupedPhotosListView.clear();
    }

    public /* synthetic */ void lambda$onPhotoClosed$41$ArticleViewer() {
        this.animatingImageView.setImageBitmap(null);
    }

    public void onPause() {
        if (this.currentAnimation != null) {
            closePhoto(false);
        }
    }

    private void updateMinMax(float f) {
        int imageWidth = ((int) ((((float) this.centerImage.getImageWidth()) * f) - ((float) getContainerViewWidth()))) / 2;
        int imageHeight = ((int) ((((float) this.centerImage.getImageHeight()) * f) - ((float) getContainerViewHeight()))) / 2;
        if (imageWidth > 0) {
            this.minX = (float) (-imageWidth);
            this.maxX = (float) imageWidth;
        } else {
            this.maxX = 0.0f;
            this.minX = 0.0f;
        }
        if (imageHeight > 0) {
            this.minY = (float) (-imageHeight);
            this.maxY = (float) imageHeight;
            return;
        }
        this.maxY = 0.0f;
        this.minY = 0.0f;
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private int getContainerViewWidth() {
        return this.photoContainerView.getWidth();
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private int getContainerViewHeight() {
        return this.photoContainerView.getHeight();
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    /* JADX WARNING: Code restructure failed: missing block: B:118:0x028a, code lost:
        if (r13 > r3) goto L_0x0284;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:123:0x0299, code lost:
        if (r0 > r3) goto L_0x0293;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:161:0x034d, code lost:
        if (r2 > r3) goto L_0x0347;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:166:0x035e, code lost:
        if (r2 > r3) goto L_0x0358;
     */
    /* JADX WARNING: Removed duplicated region for block: B:98:0x01fc  */
    private boolean processTouchEvent(MotionEvent motionEvent) {
        if (this.photoAnimationInProgress == 0 && this.animationStartTime == 0) {
            if (motionEvent.getPointerCount() == 1 && this.gestureDetector.onTouchEvent(motionEvent) && this.doubleTap) {
                this.doubleTap = false;
                this.moving = false;
                this.zooming = false;
                checkMinMax(false);
                return true;
            } else if (motionEvent.getActionMasked() == 0 || motionEvent.getActionMasked() == 5) {
                this.discardTap = false;
                if (!this.scroller.isFinished()) {
                    this.scroller.abortAnimation();
                }
                if (!this.draggingDown && !this.changingPage) {
                    if (this.canZoom && motionEvent.getPointerCount() == 2) {
                        this.pinchStartDistance = (float) Math.hypot((double) (motionEvent.getX(1) - motionEvent.getX(0)), (double) (motionEvent.getY(1) - motionEvent.getY(0)));
                        this.pinchStartScale = this.scale;
                        this.pinchCenterX = (motionEvent.getX(0) + motionEvent.getX(1)) / 2.0f;
                        this.pinchCenterY = (motionEvent.getY(0) + motionEvent.getY(1)) / 2.0f;
                        this.pinchStartX = this.translationX;
                        this.pinchStartY = this.translationY;
                        this.zooming = true;
                        this.moving = false;
                        VelocityTracker velocityTracker2 = this.velocityTracker;
                        if (velocityTracker2 != null) {
                            velocityTracker2.clear();
                        }
                    } else if (motionEvent.getPointerCount() == 1) {
                        this.moveStartX = motionEvent.getX();
                        float y = motionEvent.getY();
                        this.moveStartY = y;
                        this.dragY = y;
                        this.draggingDown = false;
                        this.canDragDown = true;
                        VelocityTracker velocityTracker3 = this.velocityTracker;
                        if (velocityTracker3 != null) {
                            velocityTracker3.clear();
                        }
                    }
                }
            } else {
                float f = 0.0f;
                if (motionEvent.getActionMasked() == 2) {
                    if (this.canZoom && motionEvent.getPointerCount() == 2 && !this.draggingDown && this.zooming && !this.changingPage) {
                        this.discardTap = true;
                        this.scale = (((float) Math.hypot((double) (motionEvent.getX(1) - motionEvent.getX(0)), (double) (motionEvent.getY(1) - motionEvent.getY(0)))) / this.pinchStartDistance) * this.pinchStartScale;
                        this.translationX = (this.pinchCenterX - ((float) (getContainerViewWidth() / 2))) - (((this.pinchCenterX - ((float) (getContainerViewWidth() / 2))) - this.pinchStartX) * (this.scale / this.pinchStartScale));
                        float containerViewHeight = this.pinchCenterY - ((float) (getContainerViewHeight() / 2));
                        float containerViewHeight2 = (this.pinchCenterY - ((float) (getContainerViewHeight() / 2))) - this.pinchStartY;
                        float f2 = this.scale;
                        this.translationY = containerViewHeight - (containerViewHeight2 * (f2 / this.pinchStartScale));
                        updateMinMax(f2);
                        this.photoContainerView.invalidate();
                    } else if (motionEvent.getPointerCount() == 1) {
                        VelocityTracker velocityTracker4 = this.velocityTracker;
                        if (velocityTracker4 != null) {
                            velocityTracker4.addMovement(motionEvent);
                        }
                        float abs = Math.abs(motionEvent.getX() - this.moveStartX);
                        float abs2 = Math.abs(motionEvent.getY() - this.dragY);
                        if (abs > ((float) AndroidUtilities.dp(3.0f)) || abs2 > ((float) AndroidUtilities.dp(3.0f))) {
                            this.discardTap = true;
                        }
                        if (this.canDragDown && !this.draggingDown && this.scale == 1.0f && abs2 >= ((float) AndroidUtilities.dp(30.0f)) && abs2 / 2.0f > abs) {
                            this.draggingDown = true;
                            this.moving = false;
                            this.dragY = motionEvent.getY();
                            if (this.isActionBarVisible) {
                                toggleActionBar(false, true);
                            }
                            return true;
                        } else if (this.draggingDown) {
                            this.translationY = motionEvent.getY() - this.dragY;
                            this.photoContainerView.invalidate();
                        } else if (this.invalidCoords || this.animationStartTime != 0) {
                            this.invalidCoords = false;
                            this.moveStartX = motionEvent.getX();
                            this.moveStartY = motionEvent.getY();
                        } else {
                            float x = this.moveStartX - motionEvent.getX();
                            float y2 = this.moveStartY - motionEvent.getY();
                            if (this.moving || ((this.scale == 1.0f && Math.abs(y2) + ((float) AndroidUtilities.dp(12.0f)) < Math.abs(x)) || this.scale != 1.0f)) {
                                if (!this.moving) {
                                    this.moving = true;
                                    this.canDragDown = false;
                                    x = 0.0f;
                                    y2 = 0.0f;
                                }
                                this.moveStartX = motionEvent.getX();
                                this.moveStartY = motionEvent.getY();
                                updateMinMax(this.scale);
                                if ((this.translationX < this.minX && !this.rightImage.hasImageSet()) || (this.translationX > this.maxX && !this.leftImage.hasImageSet())) {
                                    x /= 3.0f;
                                }
                                float f3 = this.maxY;
                                if (f3 == 0.0f) {
                                    float f4 = this.minY;
                                    if (f4 == 0.0f) {
                                        float f5 = this.translationY;
                                        if (f5 - y2 < f4) {
                                            this.translationY = f4;
                                        } else {
                                            if (f5 - y2 > f3) {
                                                this.translationY = f3;
                                            }
                                            f = y2;
                                        }
                                        this.translationX -= x;
                                        if (this.scale != 1.0f) {
                                            this.translationY -= f;
                                        }
                                        this.photoContainerView.invalidate();
                                    }
                                }
                                float f6 = this.translationY;
                                if (f6 < this.minY || f6 > this.maxY) {
                                    f = y2 / 3.0f;
                                    this.translationX -= x;
                                    if (this.scale != 1.0f) {
                                    }
                                    this.photoContainerView.invalidate();
                                }
                                f = y2;
                                this.translationX -= x;
                                if (this.scale != 1.0f) {
                                }
                                this.photoContainerView.invalidate();
                            }
                        }
                    }
                } else if (motionEvent.getActionMasked() == 3 || motionEvent.getActionMasked() == 1 || motionEvent.getActionMasked() == 6) {
                    if (this.zooming) {
                        this.invalidCoords = true;
                        float f7 = this.scale;
                        if (f7 < 1.0f) {
                            updateMinMax(1.0f);
                            animateTo(1.0f, 0.0f, 0.0f, true);
                        } else if (f7 > 3.0f) {
                            float containerViewWidth = (this.pinchCenterX - ((float) (getContainerViewWidth() / 2))) - (((this.pinchCenterX - ((float) (getContainerViewWidth() / 2))) - this.pinchStartX) * (3.0f / this.pinchStartScale));
                            float containerViewHeight3 = (this.pinchCenterY - ((float) (getContainerViewHeight() / 2))) - (((this.pinchCenterY - ((float) (getContainerViewHeight() / 2))) - this.pinchStartY) * (3.0f / this.pinchStartScale));
                            updateMinMax(3.0f);
                            float f8 = this.minX;
                            if (containerViewWidth >= f8) {
                                f8 = this.maxX;
                            }
                            containerViewWidth = f8;
                            float f9 = this.minY;
                            if (containerViewHeight3 >= f9) {
                                f9 = this.maxY;
                            }
                            containerViewHeight3 = f9;
                            animateTo(3.0f, containerViewWidth, containerViewHeight3, true);
                        } else {
                            checkMinMax(true);
                        }
                        this.zooming = false;
                    } else if (this.draggingDown) {
                        if (Math.abs(this.dragY - motionEvent.getY()) > ((float) getContainerViewHeight()) / 6.0f) {
                            closePhoto(true);
                        } else {
                            animateTo(1.0f, 0.0f, 0.0f, false);
                        }
                        this.draggingDown = false;
                    } else if (this.moving) {
                        float f10 = this.translationX;
                        float f11 = this.translationY;
                        updateMinMax(this.scale);
                        this.moving = false;
                        this.canDragDown = true;
                        VelocityTracker velocityTracker5 = this.velocityTracker;
                        if (velocityTracker5 != null && this.scale == 1.0f) {
                            velocityTracker5.computeCurrentVelocity(1000);
                            f = this.velocityTracker.getXVelocity();
                        }
                        if ((this.translationX < this.minX - ((float) (getContainerViewWidth() / 3)) || f < ((float) (-AndroidUtilities.dp(650.0f)))) && this.rightImage.hasImageSet()) {
                            goToNext();
                            return true;
                        } else if ((this.translationX > this.maxX + ((float) (getContainerViewWidth() / 3)) || f > ((float) AndroidUtilities.dp(650.0f))) && this.leftImage.hasImageSet()) {
                            goToPrev();
                            return true;
                        } else {
                            float f12 = this.translationX;
                            float f13 = this.minX;
                            if (f12 >= f13) {
                                f13 = this.maxX;
                            }
                            f10 = f13;
                            float f14 = this.translationY;
                            float f15 = this.minY;
                            if (f14 >= f15) {
                                f15 = this.maxY;
                            }
                            f11 = f15;
                            animateTo(this.scale, f10, f11, false);
                        }
                    }
                }
            }
        }
        return false;
    }

    /* JADX WARNING: Code restructure failed: missing block: B:4:0x0017, code lost:
        if (r2 > r3) goto L_0x0011;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:9:0x0028, code lost:
        if (r2 > r3) goto L_0x0022;
     */
    private void checkMinMax(boolean z) {
        float f = this.translationX;
        float f2 = this.translationY;
        updateMinMax(this.scale);
        float f3 = this.translationX;
        float f4 = this.minX;
        if (f3 >= f4) {
            f4 = this.maxX;
        }
        f = f4;
        float f5 = this.translationY;
        float f6 = this.minY;
        if (f5 >= f6) {
            f6 = this.maxY;
        }
        f2 = f6;
        animateTo(this.scale, f, f2, z);
    }

    private void goToNext() {
        float containerViewWidth = this.scale != 1.0f ? ((float) ((getContainerViewWidth() - this.centerImage.getImageWidth()) / 2)) * this.scale : 0.0f;
        this.switchImageAfterAnimation = 1;
        animateTo(this.scale, ((this.minX - ((float) getContainerViewWidth())) - containerViewWidth) - ((float) (AndroidUtilities.dp(30.0f) / 2)), this.translationY, false);
    }

    private void goToPrev() {
        float containerViewWidth = this.scale != 1.0f ? ((float) ((getContainerViewWidth() - this.centerImage.getImageWidth()) / 2)) * this.scale : 0.0f;
        this.switchImageAfterAnimation = 2;
        animateTo(this.scale, this.maxX + ((float) getContainerViewWidth()) + containerViewWidth + ((float) (AndroidUtilities.dp(30.0f) / 2)), this.translationY, false);
    }

    private void animateTo(float f, float f2, float f3, boolean z) {
        animateTo(f, f2, f3, z, ItemTouchHelper.Callback.DEFAULT_SWIPE_ANIMATION_DURATION);
    }

    private void animateTo(float f, float f2, float f3, boolean z, int i) {
        if (this.scale != f || this.translationX != f2 || this.translationY != f3) {
            this.zoomAnimation = z;
            this.animateToScale = f;
            this.animateToX = f2;
            this.animateToY = f3;
            this.animationStartTime = System.currentTimeMillis();
            AnimatorSet animatorSet = new AnimatorSet();
            this.imageMoveAnimation = animatorSet;
            animatorSet.playTogether(ObjectAnimator.ofFloat(this, "animationValue", 0.0f, 1.0f));
            this.imageMoveAnimation.setInterpolator(this.interpolator);
            this.imageMoveAnimation.setDuration((long) i);
            this.imageMoveAnimation.addListener(new AnimatorListenerAdapter() {
                /* class im.guobwnxjuc.ui.ArticleViewer.AnonymousClass25 */

                public void onAnimationEnd(Animator animator) {
                    ArticleViewer.this.imageMoveAnimation = null;
                    ArticleViewer.this.photoContainerView.invalidate();
                }
            });
            this.imageMoveAnimation.start();
        }
    }

    public void setAnimationValue(float f) {
        this.animationValue = f;
        this.photoContainerView.invalidate();
    }

    public float getAnimationValue() {
        return this.animationValue;
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    /* JADX WARNING: Removed duplicated region for block: B:103:0x0280  */
    /* JADX WARNING: Removed duplicated region for block: B:142:0x03a5  */
    /* JADX WARNING: Removed duplicated region for block: B:152:? A[RETURN, SYNTHETIC] */
    /* JADX WARNING: Removed duplicated region for block: B:84:0x01ad  */
    private void drawContent(Canvas canvas) {
        float f;
        float f2;
        float f3;
        float f4;
        float f5;
        float f6;
        float f7;
        float f8;
        float f9;
        float f10;
        float f11;
        int i = this.photoAnimationInProgress;
        if (i == 1) {
            return;
        }
        if (this.isPhotoVisible || i == 2) {
            if (this.imageMoveAnimation != null) {
                if (!this.scroller.isFinished()) {
                    this.scroller.abortAnimation();
                }
                float f12 = this.scale;
                float f13 = this.animateToScale;
                float f14 = this.animationValue;
                f3 = ((f13 - f12) * f14) + f12;
                float f15 = this.translationX;
                f2 = ((this.animateToX - f15) * f14) + f15;
                float f16 = this.translationY;
                f = f16 + ((this.animateToY - f16) * f14);
                f4 = (f13 == 1.0f && f12 == 1.0f && f15 == 0.0f) ? f : -1.0f;
                this.photoContainerView.invalidate();
            } else {
                if (this.animationStartTime != 0) {
                    this.translationX = this.animateToX;
                    this.translationY = this.animateToY;
                    float f17 = this.animateToScale;
                    this.scale = f17;
                    this.animationStartTime = 0;
                    updateMinMax(f17);
                    this.zoomAnimation = false;
                }
                if (!this.scroller.isFinished() && this.scroller.computeScrollOffset()) {
                    if (((float) this.scroller.getStartX()) < this.maxX && ((float) this.scroller.getStartX()) > this.minX) {
                        this.translationX = (float) this.scroller.getCurrX();
                    }
                    if (((float) this.scroller.getStartY()) < this.maxY && ((float) this.scroller.getStartY()) > this.minY) {
                        this.translationY = (float) this.scroller.getCurrY();
                    }
                    this.photoContainerView.invalidate();
                }
                int i2 = this.switchImageAfterAnimation;
                if (i2 != 0) {
                    if (i2 == 1) {
                        AndroidUtilities.runOnUIThread(new Runnable() {
                            /* class im.guobwnxjuc.ui.$$Lambda$ArticleViewer$8X3E4NtQf0WaVeYeK2Zg2sFA68g */

                            public final void run() {
                                ArticleViewer.this.lambda$drawContent$42$ArticleViewer();
                            }
                        });
                    } else if (i2 == 2) {
                        AndroidUtilities.runOnUIThread(new Runnable() {
                            /* class im.guobwnxjuc.ui.$$Lambda$ArticleViewer$YwmE97sdj5Yh7nR2VhxsTywD6xA */

                            public final void run() {
                                ArticleViewer.this.lambda$drawContent$43$ArticleViewer();
                            }
                        });
                    }
                    this.switchImageAfterAnimation = 0;
                }
                f3 = this.scale;
                f = this.translationY;
                f2 = this.translationX;
                f4 = !this.moving ? f : -1.0f;
            }
            if (this.photoAnimationInProgress != 2) {
                if (this.scale != 1.0f || f4 == -1.0f || this.zoomAnimation) {
                    this.photoBackgroundDrawable.setAlpha(255);
                } else {
                    float containerViewHeight = ((float) getContainerViewHeight()) / 4.0f;
                    this.photoBackgroundDrawable.setAlpha((int) Math.max(127.0f, (1.0f - (Math.min(Math.abs(f4), containerViewHeight) / containerViewHeight)) * 255.0f));
                }
            }
            ImageReceiver imageReceiver = null;
            if (this.scale >= 1.0f && !this.zoomAnimation && !this.zooming) {
                if (f2 > this.maxX + ((float) AndroidUtilities.dp(5.0f))) {
                    imageReceiver = this.leftImage;
                } else if (f2 < this.minX - ((float) AndroidUtilities.dp(5.0f))) {
                    imageReceiver = this.rightImage;
                } else {
                    this.groupedPhotosListView.setMoveProgress(0.0f);
                }
            }
            this.changingPage = imageReceiver != null;
            if (imageReceiver == this.rightImage) {
                if (!this.zoomAnimation) {
                    float f18 = this.minX;
                    if (f2 < f18) {
                        f11 = Math.min(1.0f, (f18 - f2) / ((float) canvas.getWidth()));
                        f9 = (1.0f - f11) * 0.3f;
                        f10 = (float) ((-canvas.getWidth()) - (AndroidUtilities.dp(30.0f) / 2));
                        if (imageReceiver.hasBitmapImage()) {
                            canvas.save();
                            canvas.translate((float) (getContainerViewWidth() / 2), (float) (getContainerViewHeight() / 2));
                            canvas.translate(((float) (canvas.getWidth() + (AndroidUtilities.dp(30.0f) / 2))) + f10, 0.0f);
                            float f19 = 1.0f - f9;
                            canvas.scale(f19, f19);
                            int bitmapWidth = imageReceiver.getBitmapWidth();
                            int bitmapHeight = imageReceiver.getBitmapHeight();
                            float f20 = (float) bitmapWidth;
                            float containerViewWidth = ((float) getContainerViewWidth()) / f20;
                            float f21 = (float) bitmapHeight;
                            float containerViewHeight2 = ((float) getContainerViewHeight()) / f21;
                            if (containerViewWidth > containerViewHeight2) {
                                containerViewWidth = containerViewHeight2;
                            }
                            int i3 = (int) (f20 * containerViewWidth);
                            int i4 = (int) (f21 * containerViewWidth);
                            imageReceiver.setAlpha(f11);
                            imageReceiver.setImageCoords((-i3) / 2, (-i4) / 2, i3, i4);
                            imageReceiver.draw(canvas);
                            canvas.restore();
                        }
                        this.groupedPhotosListView.setMoveProgress(-f11);
                        canvas.save();
                        canvas.translate(f10, f / f3);
                        canvas.translate(((((float) canvas.getWidth()) * (this.scale + 1.0f)) + ((float) AndroidUtilities.dp(30.0f))) / 2.0f, (-f) / f3);
                        this.radialProgressViews[1].setScale(1.0f - f9);
                        this.radialProgressViews[1].setAlpha(f11);
                        this.radialProgressViews[1].onDraw(canvas);
                        canvas.restore();
                    }
                }
                f10 = f2;
                f11 = 1.0f;
                f9 = 0.0f;
                if (imageReceiver.hasBitmapImage()) {
                }
                this.groupedPhotosListView.setMoveProgress(-f11);
                canvas.save();
                canvas.translate(f10, f / f3);
                canvas.translate(((((float) canvas.getWidth()) * (this.scale + 1.0f)) + ((float) AndroidUtilities.dp(30.0f))) / 2.0f, (-f) / f3);
                this.radialProgressViews[1].setScale(1.0f - f9);
                this.radialProgressViews[1].setAlpha(f11);
                this.radialProgressViews[1].onDraw(canvas);
                canvas.restore();
            }
            if (!this.zoomAnimation) {
                float f22 = this.maxX;
                if (f2 > f22) {
                    float min = Math.min(1.0f, (f2 - f22) / ((float) canvas.getWidth()));
                    f6 = 0.3f * min;
                    f7 = 1.0f - min;
                    f5 = this.maxX;
                    AspectRatioFrameLayout aspectRatioFrameLayout2 = this.aspectRatioFrameLayout;
                    boolean z = aspectRatioFrameLayout2 == null && aspectRatioFrameLayout2.getVisibility() == 0;
                    if (this.centerImage.hasBitmapImage()) {
                        canvas.save();
                        canvas.translate((float) (getContainerViewWidth() / 2), (float) (getContainerViewHeight() / 2));
                        canvas.translate(f5, f);
                        float f23 = f3 - f6;
                        canvas.scale(f23, f23);
                        int bitmapWidth2 = this.centerImage.getBitmapWidth();
                        int bitmapHeight2 = this.centerImage.getBitmapHeight();
                        if (z && this.textureUploaded && Math.abs((((float) bitmapWidth2) / ((float) bitmapHeight2)) - (((float) this.videoTextureView.getMeasuredWidth()) / ((float) this.videoTextureView.getMeasuredHeight()))) > 0.01f) {
                            bitmapWidth2 = this.videoTextureView.getMeasuredWidth();
                            bitmapHeight2 = this.videoTextureView.getMeasuredHeight();
                        }
                        float f24 = (float) bitmapWidth2;
                        float containerViewWidth2 = ((float) getContainerViewWidth()) / f24;
                        float f25 = (float) bitmapHeight2;
                        float containerViewHeight3 = ((float) getContainerViewHeight()) / f25;
                        if (containerViewWidth2 > containerViewHeight3) {
                            containerViewWidth2 = containerViewHeight3;
                        }
                        int i5 = (int) (f24 * containerViewWidth2);
                        int i6 = (int) (f25 * containerViewWidth2);
                        if (!z || !this.textureUploaded || !this.videoCrossfadeStarted || this.videoCrossfadeAlpha != 1.0f) {
                            this.centerImage.setAlpha(f7);
                            this.centerImage.setImageCoords((-i5) / 2, (-i6) / 2, i5, i6);
                            this.centerImage.draw(canvas);
                        }
                        if (z) {
                            if (!this.videoCrossfadeStarted && this.textureUploaded) {
                                this.videoCrossfadeStarted = true;
                                this.videoCrossfadeAlpha = 0.0f;
                                this.videoCrossfadeAlphaLastTime = System.currentTimeMillis();
                            }
                            canvas.translate((float) ((-i5) / 2), (float) ((-i6) / 2));
                            this.videoTextureView.setAlpha(this.videoCrossfadeAlpha * f7);
                            this.aspectRatioFrameLayout.draw(canvas);
                            if (this.videoCrossfadeStarted && this.videoCrossfadeAlpha < 1.0f) {
                                long currentTimeMillis = System.currentTimeMillis();
                                this.videoCrossfadeAlphaLastTime = currentTimeMillis;
                                this.videoCrossfadeAlpha += ((float) (currentTimeMillis - this.videoCrossfadeAlphaLastTime)) / 300.0f;
                                this.photoContainerView.invalidate();
                                if (this.videoCrossfadeAlpha > 1.0f) {
                                    this.videoCrossfadeAlpha = 1.0f;
                                }
                            }
                        }
                        canvas.restore();
                    }
                    if (!z && this.bottomLayout.getVisibility() != 0) {
                        canvas.save();
                        canvas.translate(f5, f / f3);
                        this.radialProgressViews[0].setScale(1.0f - f6);
                        this.radialProgressViews[0].setAlpha(f7);
                        this.radialProgressViews[0].onDraw(canvas);
                        canvas.restore();
                    }
                    if (imageReceiver != this.leftImage) {
                        if (imageReceiver.hasBitmapImage()) {
                            canvas.save();
                            canvas.translate((float) (getContainerViewWidth() / 2), (float) (getContainerViewHeight() / 2));
                            canvas.translate(((-((((float) canvas.getWidth()) * (this.scale + 1.0f)) + ((float) AndroidUtilities.dp(30.0f)))) / 2.0f) + f2, 0.0f);
                            int bitmapWidth3 = imageReceiver.getBitmapWidth();
                            int bitmapHeight3 = imageReceiver.getBitmapHeight();
                            float f26 = (float) bitmapWidth3;
                            float containerViewWidth3 = ((float) getContainerViewWidth()) / f26;
                            float f27 = (float) bitmapHeight3;
                            float containerViewHeight4 = ((float) getContainerViewHeight()) / f27;
                            if (containerViewWidth3 > containerViewHeight4) {
                                containerViewWidth3 = containerViewHeight4;
                            }
                            int i7 = (int) (f26 * containerViewWidth3);
                            int i8 = (int) (f27 * containerViewWidth3);
                            f8 = 1.0f;
                            imageReceiver.setAlpha(1.0f);
                            imageReceiver.setImageCoords((-i7) / 2, (-i8) / 2, i7, i8);
                            imageReceiver.draw(canvas);
                            canvas.restore();
                        } else {
                            f8 = 1.0f;
                        }
                        this.groupedPhotosListView.setMoveProgress(f8 - f7);
                        canvas.save();
                        canvas.translate(f2, f / f3);
                        canvas.translate((-((((float) canvas.getWidth()) * (this.scale + f8)) + ((float) AndroidUtilities.dp(30.0f)))) / 2.0f, (-f) / f3);
                        this.radialProgressViews[2].setScale(1.0f);
                        this.radialProgressViews[2].setAlpha(1.0f);
                        this.radialProgressViews[2].onDraw(canvas);
                        canvas.restore();
                        return;
                    }
                    return;
                }
            }
            f5 = f2;
            f7 = 1.0f;
            f6 = 0.0f;
            AspectRatioFrameLayout aspectRatioFrameLayout22 = this.aspectRatioFrameLayout;
            if (aspectRatioFrameLayout22 == null) {
            }
            if (this.centerImage.hasBitmapImage()) {
            }
            canvas.save();
            canvas.translate(f5, f / f3);
            this.radialProgressViews[0].setScale(1.0f - f6);
            this.radialProgressViews[0].setAlpha(f7);
            this.radialProgressViews[0].onDraw(canvas);
            canvas.restore();
            if (imageReceiver != this.leftImage) {
            }
        }
    }

    public /* synthetic */ void lambda$drawContent$42$ArticleViewer() {
        setImageIndex(this.currentIndex + 1, false);
    }

    public /* synthetic */ void lambda$drawContent$43$ArticleViewer() {
        setImageIndex(this.currentIndex - 1, false);
    }

    private void onActionClick(boolean z) {
        File mediaFile;
        TLObject media = getMedia(this.currentIndex);
        if ((media instanceof TLRPC.Document) && this.currentFileNames[0] != null) {
            TLRPC.Document document = (TLRPC.Document) media;
            File file = null;
            if (this.currentMedia != null && ((mediaFile = getMediaFile(this.currentIndex)) == null || mediaFile.exists())) {
                file = mediaFile;
            }
            if (file != null) {
                preparePlayer(file, true);
            } else if (!z) {
            } else {
                if (!FileLoader.getInstance(this.currentAccount).isLoadingFile(this.currentFileNames[0])) {
                    FileLoader.getInstance(this.currentAccount).loadFile(document, this.currentPage, 1, 1);
                } else {
                    FileLoader.getInstance(this.currentAccount).cancelLoadFile(document);
                }
            }
        }
    }

    public boolean onFling(MotionEvent motionEvent, MotionEvent motionEvent2, float f, float f2) {
        if (this.scale == 1.0f) {
            return false;
        }
        this.scroller.abortAnimation();
        this.scroller.fling(Math.round(this.translationX), Math.round(this.translationY), Math.round(f), Math.round(f2), (int) this.minX, (int) this.maxX, (int) this.minY, (int) this.maxY);
        this.photoContainerView.postInvalidate();
        return false;
    }

    public boolean onSingleTapConfirmed(MotionEvent motionEvent) {
        int i;
        if (this.discardTap) {
            return false;
        }
        AspectRatioFrameLayout aspectRatioFrameLayout2 = this.aspectRatioFrameLayout;
        boolean z = aspectRatioFrameLayout2 != null && aspectRatioFrameLayout2.getVisibility() == 0;
        RadialProgressView[] radialProgressViewArr = this.radialProgressViews;
        if (radialProgressViewArr[0] != null && this.photoContainerView != null && !z && (i = radialProgressViewArr[0].backgroundState) > 0 && i <= 3) {
            float x = motionEvent.getX();
            float y = motionEvent.getY();
            if (x >= ((float) (getContainerViewWidth() - AndroidUtilities.dp(100.0f))) / 2.0f && x <= ((float) (getContainerViewWidth() + AndroidUtilities.dp(100.0f))) / 2.0f && y >= ((float) (getContainerViewHeight() - AndroidUtilities.dp(100.0f))) / 2.0f && y <= ((float) (getContainerViewHeight() + AndroidUtilities.dp(100.0f))) / 2.0f) {
                onActionClick(true);
                checkProgress(0, true);
                return true;
            }
        }
        toggleActionBar(!this.isActionBarVisible, true);
        return true;
    }

    /* JADX WARNING: Code restructure failed: missing block: B:18:0x0086, code lost:
        if (r0 > r9) goto L_0x0080;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:23:0x0095, code lost:
        if (r2 > r9) goto L_0x008f;
     */
    public boolean onDoubleTap(MotionEvent motionEvent) {
        boolean z = false;
        if (this.canZoom && ((this.scale != 1.0f || (this.translationY == 0.0f && this.translationX == 0.0f)) && this.animationStartTime == 0 && this.photoAnimationInProgress == 0)) {
            z = true;
            if (this.scale == 1.0f) {
                float x = (motionEvent.getX() - ((float) (getContainerViewWidth() / 2))) - (((motionEvent.getX() - ((float) (getContainerViewWidth() / 2))) - this.translationX) * (3.0f / this.scale));
                float y = (motionEvent.getY() - ((float) (getContainerViewHeight() / 2))) - (((motionEvent.getY() - ((float) (getContainerViewHeight() / 2))) - this.translationY) * (3.0f / this.scale));
                updateMinMax(3.0f);
                float f = this.minX;
                if (x >= f) {
                    f = this.maxX;
                }
                x = f;
                float f2 = this.minY;
                if (y >= f2) {
                    f2 = this.maxY;
                }
                y = f2;
                animateTo(3.0f, x, y, true);
            } else {
                animateTo(1.0f, 0.0f, 0.0f, true);
            }
            this.doubleTap = true;
        }
        return z;
    }

    private ImageReceiver getImageReceiverView(View view, TLRPC.PageBlock pageBlock, int[] iArr) {
        ImageReceiver imageReceiverView;
        ImageReceiver imageReceiverView2;
        if (view instanceof BlockPhotoCell) {
            BlockPhotoCell blockPhotoCell = (BlockPhotoCell) view;
            if (blockPhotoCell.currentBlock != pageBlock) {
                return null;
            }
            view.getLocationInWindow(iArr);
            return blockPhotoCell.imageView;
        } else if (view instanceof BlockVideoCell) {
            BlockVideoCell blockVideoCell = (BlockVideoCell) view;
            if (blockVideoCell.currentBlock != pageBlock) {
                return null;
            }
            view.getLocationInWindow(iArr);
            return blockVideoCell.imageView;
        } else if (view instanceof BlockCollageCell) {
            ImageReceiver imageReceiverFromListView = getImageReceiverFromListView(((BlockCollageCell) view).innerListView, pageBlock, iArr);
            if (imageReceiverFromListView != null) {
                return imageReceiverFromListView;
            }
            return null;
        } else if (view instanceof BlockSlideshowCell) {
            ImageReceiver imageReceiverFromListView2 = getImageReceiverFromListView(((BlockSlideshowCell) view).innerListView, pageBlock, iArr);
            if (imageReceiverFromListView2 != null) {
                return imageReceiverFromListView2;
            }
            return null;
        } else if (view instanceof BlockListItemCell) {
            BlockListItemCell blockListItemCell = (BlockListItemCell) view;
            if (blockListItemCell.blockLayout == null || (imageReceiverView2 = getImageReceiverView(blockListItemCell.blockLayout.itemView, pageBlock, iArr)) == null) {
                return null;
            }
            return imageReceiverView2;
        } else if (!(view instanceof BlockOrderedListItemCell)) {
            return null;
        } else {
            BlockOrderedListItemCell blockOrderedListItemCell = (BlockOrderedListItemCell) view;
            if (blockOrderedListItemCell.blockLayout == null || (imageReceiverView = getImageReceiverView(blockOrderedListItemCell.blockLayout.itemView, pageBlock, iArr)) == null) {
                return null;
            }
            return imageReceiverView;
        }
    }

    private ImageReceiver getImageReceiverFromListView(ViewGroup viewGroup, TLRPC.PageBlock pageBlock, int[] iArr) {
        int childCount = viewGroup.getChildCount();
        for (int i = 0; i < childCount; i++) {
            ImageReceiver imageReceiverView = getImageReceiverView(viewGroup.getChildAt(i), pageBlock, iArr);
            if (imageReceiverView != null) {
                return imageReceiverView;
            }
        }
        return null;
    }

    private PlaceProviderObject getPlaceForPhoto(TLRPC.PageBlock pageBlock) {
        ImageReceiver imageReceiverFromListView = getImageReceiverFromListView(this.listView[0], pageBlock, this.coords);
        if (imageReceiverFromListView == null) {
            return null;
        }
        PlaceProviderObject placeProviderObject = new PlaceProviderObject();
        placeProviderObject.viewX = this.coords[0];
        placeProviderObject.viewY = this.coords[1];
        placeProviderObject.parentView = this.listView[0];
        placeProviderObject.imageReceiver = imageReceiverFromListView;
        placeProviderObject.thumb = imageReceiverFromListView.getBitmapSafe();
        placeProviderObject.radius = imageReceiverFromListView.getRoundRadius();
        placeProviderObject.clipTopAddition = this.currentHeaderHeight;
        return placeProviderObject;
    }
}