ZஜZ v2.7.0版本的 MD5 值为:1bef67e030daecb0566ac755017d6792
以下内容为反编译后的 ArticleViewer.java 源代码,内容仅作参考
package im.jpgxbngtig.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.jpgxbngtig.messenger.AndroidUtilities;
import im.jpgxbngtig.messenger.ApplicationLoader;
import im.jpgxbngtig.messenger.DownloadController;
import im.jpgxbngtig.messenger.Emoji;
import im.jpgxbngtig.messenger.FileLoader;
import im.jpgxbngtig.messenger.FileLog;
import im.jpgxbngtig.messenger.ImageLoader;
import im.jpgxbngtig.messenger.ImageLocation;
import im.jpgxbngtig.messenger.ImageReceiver;
import im.jpgxbngtig.messenger.LocaleController;
import im.jpgxbngtig.messenger.MediaController;
import im.jpgxbngtig.messenger.MessageObject;
import im.jpgxbngtig.messenger.MessagesController;
import im.jpgxbngtig.messenger.MessagesStorage;
import im.jpgxbngtig.messenger.NotificationCenter;
import im.jpgxbngtig.messenger.R;
import im.jpgxbngtig.messenger.UserConfig;
import im.jpgxbngtig.messenger.Utilities;
import im.jpgxbngtig.messenger.WebFile;
import im.jpgxbngtig.messenger.browser.Browser;
import im.jpgxbngtig.tgnet.ConnectionsManager;
import im.jpgxbngtig.tgnet.RequestDelegate;
import im.jpgxbngtig.tgnet.TLObject;
import im.jpgxbngtig.tgnet.TLRPC;
import im.jpgxbngtig.ui.ArticleViewer;
import im.jpgxbngtig.ui.actionbar.ActionBar;
import im.jpgxbngtig.ui.actionbar.ActionBarMenu;
import im.jpgxbngtig.ui.actionbar.ActionBarMenuItem;
import im.jpgxbngtig.ui.actionbar.ActionBarPopupWindow;
import im.jpgxbngtig.ui.actionbar.AlertDialog;
import im.jpgxbngtig.ui.actionbar.BackDrawable;
import im.jpgxbngtig.ui.actionbar.BaseFragment;
import im.jpgxbngtig.ui.actionbar.BottomSheet;
import im.jpgxbngtig.ui.actionbar.SimpleTextView;
import im.jpgxbngtig.ui.actionbar.Theme;
import im.jpgxbngtig.ui.components.AlertsCreator;
import im.jpgxbngtig.ui.components.AnchorSpan;
import im.jpgxbngtig.ui.components.AnimatedArrowDrawable;
import im.jpgxbngtig.ui.components.AnimatedFileDrawable;
import im.jpgxbngtig.ui.components.AnimationProperties;
import im.jpgxbngtig.ui.components.AvatarDrawable;
import im.jpgxbngtig.ui.components.ClippingImageView;
import im.jpgxbngtig.ui.components.CombinedDrawable;
import im.jpgxbngtig.ui.components.ContextProgressView;
import im.jpgxbngtig.ui.components.GroupedPhotosListView;
import im.jpgxbngtig.ui.components.LayoutHelper;
import im.jpgxbngtig.ui.components.LineProgressView;
import im.jpgxbngtig.ui.components.LinkPath;
import im.jpgxbngtig.ui.components.RadialProgress2;
import im.jpgxbngtig.ui.components.RecyclerListView;
import im.jpgxbngtig.ui.components.Scroller;
import im.jpgxbngtig.ui.components.SeekBar;
import im.jpgxbngtig.ui.components.ShareAlert;
import im.jpgxbngtig.ui.components.StaticLayoutEx;
import im.jpgxbngtig.ui.components.TableLayout;
import im.jpgxbngtig.ui.components.TextPaintImageReceiverSpan;
import im.jpgxbngtig.ui.components.TextPaintMarkSpan;
import im.jpgxbngtig.ui.components.TextPaintSpan;
import im.jpgxbngtig.ui.components.TextPaintUrlSpan;
import im.jpgxbngtig.ui.components.TextPaintWebpageUrlSpan;
import im.jpgxbngtig.ui.components.TypefaceSpan;
import im.jpgxbngtig.ui.components.VideoPlayer;
import im.jpgxbngtig.ui.components.WebPlayerView;
import im.jpgxbngtig.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.Iterator;
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 {
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 channelNamePaint = null;
private static Paint colorPaint = null;
private static DecelerateInterpolator decelerateInterpolator = null;
private static Paint dividerPaint = null;
private static Paint dotsPaint = null;
private static TextPaint embedPostAuthorPaint = null;
private static TextPaint embedPostDatePaint = null;
private static TextPaint errorTextPaint = null;
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 TextPaint listTextNumPaint;
private static TextPaint listTextPointerPaint;
private static Paint photoBackgroundPaint;
private static Paint preformattedBackgroundPaint;
private static Drawable[] progressDrawables;
private static Paint progressPaint;
private static Paint quoteLinePaint;
private static TextPaint relatedArticleHeaderPaint;
private static TextPaint relatedArticleTextPaint;
private static Paint selectorPaint;
private static Paint tableHalfLinePaint;
private static Paint tableHeaderPaint;
private static Paint tableLinePaint;
private static Paint tableStripPaint;
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 AspectRatioFrameLayout aspectRatioFrameLayout;
private boolean attachedToWindow;
private ImageView backButton;
private BackDrawable backDrawable;
private Paint backgroundPaint;
private FrameLayout bottomLayout;
private TextView captionTextView;
private TextView captionTextViewNext;
private boolean changingPage;
private TLRPC.TL_pageBlockChannel channelBlock;
private boolean collapsed;
private FrameLayout containerView;
private Drawable copyBackgroundDrawable;
private int currentAccount;
private AnimatorSet currentActionBarAnimation;
private AnimatedFileDrawable currentAnimation;
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 AspectRatioFrameLayout fullscreenAspectRatioView;
private TextureView fullscreenTextureView;
private FrameLayout fullscreenVideoContainer;
private WebPlayerView fullscreenedVideo;
private GestureDetector gestureDetector;
private GroupedPhotosListView groupedPhotosListView;
boolean hasCutout;
private FrameLayout headerView;
private PlaceProviderObject hideAfterAnimation;
private AnimatorSet imageMoveAnimation;
private boolean invalidCoords;
private boolean isPhotoVisible;
private boolean isPlaying;
private boolean isRtl;
private boolean isVisible;
private Object lastInsets;
private int lastReqId;
private Drawable layerShadowDrawable;
private LinearLayoutManager[] layoutManager;
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 Activity parentActivity;
private BaseFragment parentFragment;
private Runnable photoAnimationEndRunnable;
private int photoAnimationInProgress;
private View photoContainerBackground;
private FrameLayoutDrawer photoContainerView;
private long photoTransitionAnimationStartTime;
private float pinchCenterX;
private float pinchCenterY;
private float pinchStartDistance;
private float pinchStartX;
private float pinchStartY;
private ActionBarPopupWindow.ActionBarPopupWindowLayout popupLayout;
private Rect popupRect;
private ActionBarPopupWindow popupWindow;
private int pressedLayoutY;
private TextPaintUrlSpan pressedLink;
private DrawingText pressedLinkOwnerLayout;
private View pressedLinkOwnerView;
private int previewsReqId;
private ContextProgressView progressView;
private AnimatorSet progressViewAnimation;
private Paint scrimPaint;
private Scroller scroller;
private ActionBarMenuItem settingsButton;
private ImageView shareButton;
private FrameLayout shareContainer;
private PlaceProviderObject showAfterAnimation;
private Drawable slideDotBigDrawable;
private Drawable slideDotDrawable;
private int switchImageAfterAnimation;
private boolean textureUploaded;
private SimpleTextView titleTextView;
private long transitionAnimationStartTime;
private float translationX;
private float translationY;
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 final Property<WindowView, Float> ARTICLE_VIEWER_INNER_TRANSLATION_X = new AnimationProperties.FloatProperty<WindowView>("innerTranslationX") {
@Override
public void setValue(WindowView windowView, float f) {
windowView.setInnerTranslationX(f);
}
@Override
public Float get(WindowView windowView) {
return Float.valueOf(windowView.getInnerTranslationX());
}
};
private static TextPaint audioTimePaint = new TextPaint(1);
private static SparseArray<TextPaint> photoCaptionTextPaints = new SparseArray<>();
private static SparseArray<TextPaint> photoCreditTextPaints = new SparseArray<>();
private static SparseArray<TextPaint> titleTextPaints = new SparseArray<>();
private static SparseArray<TextPaint> kickerTextPaints = new SparseArray<>();
private static SparseArray<TextPaint> headerTextPaints = new SparseArray<>();
private static SparseArray<TextPaint> subtitleTextPaints = new SparseArray<>();
private static SparseArray<TextPaint> subheaderTextPaints = new SparseArray<>();
private static SparseArray<TextPaint> authorTextPaints = new SparseArray<>();
private static SparseArray<TextPaint> footerTextPaints = new SparseArray<>();
private static SparseArray<TextPaint> paragraphTextPaints = new SparseArray<>();
private static SparseArray<TextPaint> listTextPaints = new SparseArray<>();
private static SparseArray<TextPaint> preformattedTextPaints = new SparseArray<>();
private static SparseArray<TextPaint> quoteTextPaints = new SparseArray<>();
private static SparseArray<TextPaint> embedPostTextPaints = new SparseArray<>();
private static SparseArray<TextPaint> embedPostCaptionTextPaints = new SparseArray<>();
private static SparseArray<TextPaint> mediaCaptionTextPaints = new SparseArray<>();
private static SparseArray<TextPaint> mediaCreditTextPaints = new SparseArray<>();
private static SparseArray<TextPaint> relatedArticleTextPaints = new SparseArray<>();
private static SparseArray<TextPaint> detailsTextPaints = new SparseArray<>();
private static SparseArray<TextPaint> tableTextPaints = new SparseArray<>();
private ArrayList<BlockEmbedCell> createdWebViews = new ArrayList<>();
private int lastBlockNum = 1;
private ArrayList<TLRPC.WebPage> pagesStack = new ArrayList<>();
private Paint headerPaint = new Paint();
private Paint statusBarPaint = new Paint();
private Paint headerProgressPaint = new Paint();
private boolean checkingForLongPress = false;
private CheckForLongPress pendingCheckForLongPress = null;
private int pressCount = 0;
private CheckForTap pendingCheckForTap = null;
private LinkPath urlPath = new LinkPath();
private final int fontSizeCount = 5;
private int selectedFontSize = 2;
private int selectedColor = 0;
private int selectedFont = 0;
private ColorCell[] colorCells = new ColorCell[3];
private FontCell[] fontCells = new FontCell[2];
private int[] coords = new int[2];
private boolean isActionBarVisible = true;
private PhotoBackgroundDrawable photoBackgroundDrawable = new PhotoBackgroundDrawable(-16777216);
private Paint blackPaint = new Paint();
private RadialProgressView[] radialProgressViews = new RadialProgressView[3];
private Runnable updateProgressRunnable = new Runnable() {
@Override
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, 100L);
}
}
};
private float[][] animationValues = (float[][]) Array.newInstance((Class<?>) float.class, 2, 10);
private ImageReceiver leftImage = new ImageReceiver();
private ImageReceiver centerImage = new ImageReceiver();
private ImageReceiver rightImage = new ImageReceiver();
private String[] currentFileNames = new String[3];
private float scale = 1.0f;
private DecelerateInterpolator interpolator = new DecelerateInterpolator(1.5f);
private float pinchStartScale = 1.0f;
private boolean canZoom = true;
private boolean canDragDown = true;
private ArrayList<TLRPC.PageBlock> imagesArr = new ArrayList<>();
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;
}
public static boolean lambda$setParentActivity$12(View view, MotionEvent motionEvent) {
return true;
}
@Override
public boolean onDoubleTapEvent(MotionEvent motionEvent) {
return false;
}
@Override
public boolean onDown(MotionEvent motionEvent) {
return false;
}
@Override
public void onLongPress(MotionEvent motionEvent) {
}
@Override
public boolean onScroll(MotionEvent motionEvent, MotionEvent motionEvent2, float f, float f2) {
return false;
}
@Override
public void onShowPress(MotionEvent motionEvent) {
}
@Override
public boolean onSingleTapUp(MotionEvent motionEvent) {
return false;
}
static int access$1104(ArticleViewer articleViewer) {
int i = articleViewer.pressCount + 1;
articleViewer.pressCount = i;
return i;
}
static 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;
}
public class TL_pageBlockRelatedArticlesChild extends TLRPC.PageBlock {
private int num;
private TLRPC.TL_pageBlockRelatedArticles parent;
private TL_pageBlockRelatedArticlesChild() {
}
}
public class TL_pageBlockRelatedArticlesShadow extends TLRPC.PageBlock {
private TLRPC.TL_pageBlockRelatedArticles parent;
private TL_pageBlockRelatedArticlesShadow() {
}
}
public class TL_pageBlockDetailsChild extends TLRPC.PageBlock {
private TLRPC.PageBlock block;
private TLRPC.PageBlock parent;
private TL_pageBlockDetailsChild() {
}
}
public class TL_pageBlockDetailsBottom extends TLRPC.PageBlock {
private TLRPC.TL_pageBlockDetails parent;
private TL_pageBlockDetailsBottom() {
}
}
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<>();
}
}
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;
}
}
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<>();
}
}
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;
}
}
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();
}
}
public class SizeChooseView extends View {
private int circleSize;
private int gapSize;
private int lineSize;
private boolean moving;
private Paint paint;
private int sideSide;
private boolean startMoving;
private int startMovingQuality;
private float startX;
public SizeChooseView(Context context) {
super(context);
this.paint = new Paint(1);
}
@Override
public boolean onTouchEvent(MotionEvent motionEvent) {
float x = motionEvent.getX();
int i = 0;
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 <= i6 - AndroidUtilities.dp(15.0f) || x >= i6 + AndroidUtilities.dp(15.0f)) {
i2++;
} else {
this.startMoving = i2 == ArticleViewer.this.selectedFontSize;
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 <= i11 - i12 || x >= 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 <= i17 - AndroidUtilities.dp(15.0f) || x >= 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;
}
@Override
protected 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;
}
@Override
protected 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(i5, measuredHeight, i == ArticleViewer.this.selectedFontSize ? AndroidUtilities.dp(4.0f) : this.circleSize / 2, this.paint);
if (i != 0) {
canvas.drawRect(((i5 - (this.circleSize / 2)) - this.gapSize) - this.lineSize, measuredHeight - AndroidUtilities.dp(1.0f), r2 + this.lineSize, 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(AndroidUtilities.dp(2.0f));
}
setBackgroundDrawable(Theme.createSelectorDrawable(251658240, 2));
setWillNotDraw(false);
TextView textView = new TextView(context);
this.textView = textView;
textView.setTextColor(-14606047);
this.textView.setTextSize(1, 16.0f);
this.textView.setLines(1);
this.textView.setMaxLines(1);
this.textView.setSingleLine(true);
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 ? 5 : 3) | 48, LocaleController.isRTL ? 17 : 53, 0.0f, LocaleController.isRTL ? 53 : 17, 0.0f));
}
@Override
protected 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) {
return;
}
this.selected = z;
invalidate();
}
@Override
protected void onDraw(Canvas canvas) {
ArticleViewer.colorPaint.setColor(this.currentColor);
canvas.drawCircle(!LocaleController.isRTL ? AndroidUtilities.dp(28.0f) : getMeasuredWidth() - AndroidUtilities.dp(28.0f), getMeasuredHeight() / 2, AndroidUtilities.dp(10.0f), ArticleViewer.colorPaint);
if (this.selected) {
ArticleViewer.selectorPaint.setStrokeWidth(AndroidUtilities.dp(2.0f));
ArticleViewer.selectorPaint.setColor(-15428119);
canvas.drawCircle(!LocaleController.isRTL ? AndroidUtilities.dp(28.0f) : getMeasuredWidth() - AndroidUtilities.dp(28.0f), getMeasuredHeight() / 2, AndroidUtilities.dp(10.0f), ArticleViewer.selectorPaint);
} else if (this.currentColor == -1) {
ArticleViewer.selectorPaint.setStrokeWidth(AndroidUtilities.dp(1.0f));
ArticleViewer.selectorPaint.setColor(-4539718);
canvas.drawCircle(!LocaleController.isRTL ? AndroidUtilities.dp(28.0f) : getMeasuredWidth() - AndroidUtilities.dp(28.0f), getMeasuredHeight() / 2, 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 textView = new TextView(context);
this.textView = textView;
textView.setTextColor(-14606047);
this.textView.setTextSize(1, 16.0f);
this.textView.setLines(1);
this.textView.setMaxLines(1);
this.textView.setSingleLine(true);
this.textView.setGravity((LocaleController.isRTL ? 5 : 3) | 16);
addView(this.textView, LayoutHelper.createFrame(-1.0f, -1.0f, (LocaleController.isRTL ? 5 : 3) | 48, LocaleController.isRTL ? 17 : 53, 0.0f, LocaleController.isRTL ? 53 : 17, 0.0f));
TextView textView2 = new TextView(context);
this.textView2 = textView2;
textView2.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 ? 5 : 3) | 48, 17.0f, 0.0f, 17.0f, 0.0f));
}
@Override
protected 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();
}
}
public class FrameLayoutDrawer extends FrameLayout {
public FrameLayoutDrawer(Context context) {
super(context);
}
@Override
public boolean onTouchEvent(MotionEvent motionEvent) {
ArticleViewer.this.processTouchEvent(motionEvent);
return true;
}
@Override
protected void onDraw(Canvas canvas) {
ArticleViewer.this.drawContent(canvas);
}
@Override
protected boolean drawChild(Canvas canvas, View view, long j) {
return view != ArticleViewer.this.aspectRatioFrameLayout && super.drawChild(canvas, view, j);
}
}
public final class CheckForTap implements Runnable {
private CheckForTap() {
}
@Override
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, ViewConfiguration.getLongPressTimeout() - ViewConfiguration.getTapTimeout());
}
}
}
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);
}
@Override
protected 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);
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();
} else {
setMeasuredDimension(size, size2);
}
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));
}
@Override
protected void onLayout(boolean z, int i, int i2, int i3, int i4) {
int i5;
int i6;
if (this.selfLayout) {
return;
}
int i7 = i3 - i;
if (ArticleViewer.this.anchorsOffsetMeasuredWidth != i7) {
for (int i8 = 0; i8 < ArticleViewer.this.listView.length; i8++) {
Iterator it = ArticleViewer.this.adapter[i8].anchorsOffset.entrySet().iterator();
while (it.hasNext()) {
((Map.Entry) it.next()).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());
}
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
ArticleViewer.this.attachedToWindow = true;
}
@Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
ArticleViewer.this.attachedToWindow = false;
}
@Override
public void requestDisallowInterceptTouchEvent(boolean z) {
handleTouchEvent(null);
super.requestDisallowInterceptTouchEvent(z);
}
@Override
public boolean onInterceptTouchEvent(MotionEvent motionEvent) {
return !ArticleViewer.this.collapsed && (handleTouchEvent(motionEvent) || super.onInterceptTouchEvent(motionEvent));
}
@Override
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();
}
@Override
protected 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 = measuredWidth - i;
float min = Math.min(0.8f, f / measuredWidth);
if (min < 0.0f) {
min = 0.0f;
}
ArticleViewer.this.scrimPaint.setColor(((int) (min * 153.0f)) << 24);
canvas.drawRect(0.0f, 0.0f, i, getHeight(), ArticleViewer.this.scrimPaint);
float max = Math.max(0.0f, Math.min(f / 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() - this.startedTrackingX));
int abs = Math.abs(((int) motionEvent.getY()) - this.startedTrackingY);
this.tracker.addMovement(motionEvent);
if (this.maybeStartTracking && !this.startedTracking && 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(max);
} else {
float f = 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 = view.getMeasuredWidth() - x;
if (this.movingPage) {
animatorSet.playTogether(ObjectAnimator.ofFloat(ArticleViewer.this.listView[0], (Property<RecyclerListView, Float>) View.TRANSLATION_X, view.getMeasuredWidth()));
} else {
animatorSet.playTogether(ObjectAnimator.ofFloat(ArticleViewer.this.containerView, (Property<FrameLayout, Float>) View.TRANSLATION_X, view.getMeasuredWidth()), ObjectAnimator.ofFloat(this, ArticleViewer.ARTICLE_VIEWER_INNER_TRANSLATION_X, view.getMeasuredWidth()));
}
} else if (this.movingPage) {
animatorSet.playTogether(ObjectAnimator.ofFloat(ArticleViewer.this.listView[0], (Property<RecyclerListView, Float>) View.TRANSLATION_X, 0.0f));
} else {
animatorSet.playTogether(ObjectAnimator.ofFloat(ArticleViewer.this.containerView, (Property<FrameLayout, Float>) View.TRANSLATION_X, 0.0f), ObjectAnimator.ofFloat(this, ArticleViewer.ARTICLE_VIEWER_INNER_TRANSLATION_X, 0.0f));
}
animatorSet.setDuration(Math.max((int) ((200.0f / view.getMeasuredWidth()) * x), 50));
animatorSet.addListener(new AnimatorListenerAdapter() {
@Override
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;
}
@Override
protected void dispatchDraw(Canvas canvas) {
int i;
int i2;
super.dispatchDraw(canvas);
if (this.bWidth == 0 || (i = this.bHeight) == 0) {
return;
}
int i3 = this.bX;
if (i3 != 0 || (i2 = this.bY) != 0) {
canvas.drawRect(this.bX - getTranslationX(), this.bY, (this.bX + this.bWidth) - getTranslationX(), this.bY + this.bHeight, ArticleViewer.this.blackPaint);
} else {
canvas.drawRect(i3, i2, i3 + r0, i2 + i, ArticleViewer.this.blackPaint);
}
}
@Override
protected void onDraw(Canvas canvas) {
canvas.drawRect(this.innerTranslationX, 0.0f, getMeasuredWidth(), getMeasuredHeight(), ArticleViewer.this.backgroundPaint);
if (Build.VERSION.SDK_INT < 21 || !ArticleViewer.this.hasCutout || ArticleViewer.this.lastInsets == null) {
return;
}
canvas.drawRect(this.innerTranslationX, 0.0f, getMeasuredWidth(), ((WindowInsets) ArticleViewer.this.lastInsets).getSystemWindowInsetBottom(), ArticleViewer.this.statusBarPaint);
}
@Override
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();
}
@Override
public float getAlpha() {
return this.alpha;
}
}
public class CheckForLongPress implements Runnable {
public int currentPressCount;
CheckForLongPress() {
}
@Override
public void run() {
if (!ArticleViewer.this.checkingForLongPress || ArticleViewer.this.windowView == null) {
return;
}
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();
return;
}
return;
}
if (ArticleViewer.this.pressedLinkOwnerLayout == null || ArticleViewer.this.pressedLinkOwnerView == null) {
return;
}
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(AndroidUtilities.dp(1.0f));
Paint paint2 = new Paint();
tableHalfLinePaint = paint2;
paint2.setStyle(Paint.Style.STROKE);
tableHalfLinePaint.setStrokeWidth(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 selectedColor = getSelectedColor();
if (selectedColor == 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 (selectedColor == 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 (selectedColor == 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());
}
public void showCopyPopup(final String str) {
if (this.parentActivity == null) {
return;
}
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() {
@Override
public final void onClick(DialogInterface dialogInterface, int i) {
ArticleViewer.this.lambda$showCopyPopup$0$ArticleViewer(str, 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 void lambda$showCopyPopup$0$ArticleViewer(String str, DialogInterface dialogInterface, int i) {
String lowerCase;
String str2;
if (this.parentActivity == null) {
return;
}
if (i != 0) {
if (i == 1) {
if (str.startsWith("mailto:")) {
str = str.substring(7);
} else if (str.startsWith("tel:")) {
str = str.substring(4);
}
AndroidUtilities.addToClipboard(str);
return;
}
return;
}
int lastIndexOf = str.lastIndexOf(35);
if (lastIndexOf != -1) {
if (!TextUtils.isEmpty(this.currentPage.cached_page.url)) {
lowerCase = this.currentPage.cached_page.url.toLowerCase();
} else {
lowerCase = this.currentPage.url.toLowerCase();
}
try {
str2 = URLDecoder.decode(str.substring(lastIndexOf + 1), "UTF-8");
} catch (Exception unused) {
str2 = "";
}
if (str.toLowerCase().contains(lowerCase)) {
if (TextUtils.isEmpty(str2)) {
this.layoutManager[0].scrollToPositionWithOffset(0, 0);
checkScrollAnimated();
return;
} else {
scrollToAnchor(str2);
return;
}
}
}
Browser.openUrl(this.parentActivity, str);
}
public void showPopup(View view, int i, int i2, int i3) {
ActionBarPopupWindow actionBarPopupWindow = this.popupWindow;
if (actionBarPopupWindow != null && actionBarPopupWindow.isShowing()) {
this.popupWindow.dismiss();
return;
}
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() {
@Override
public final boolean onTouch(View view2, MotionEvent motionEvent) {
return ArticleViewer.this.lambda$showPopup$1$ArticleViewer(view2, motionEvent);
}
});
this.popupLayout.setDispatchKeyEventListener(new ActionBarPopupWindow.OnDispatchKeyEventListener() {
@Override
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() {
@Override
public final void onClick(View view2) {
ArticleViewer.this.lambda$showPopup$3$ArticleViewer(view2);
}
});
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() {
@Override
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();
}
public 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 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 void lambda$showPopup$3$ArticleViewer(View view) {
DrawingText drawingText = this.pressedLinkOwnerLayout;
if (drawingText != null) {
AndroidUtilities.addToClipboard(drawingText.getText());
ToastUtils.show(R.string.TextCopied);
}
ActionBarPopupWindow actionBarPopupWindow = this.popupWindow;
if (actionBarPopupWindow == null || !actionBarPopupWindow.isShowing()) {
return;
}
this.popupWindow.dismiss(true);
}
public 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;
}
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;
}
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);
}
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;
return blockListItemCell.blockLayout != null ? getLastNonListCell(blockListItemCell.blockLayout.itemView) : view;
}
if (!(view instanceof BlockOrderedListItemCell)) {
return view;
}
BlockOrderedListItemCell blockOrderedListItemCell = (BlockOrderedListItemCell) view;
return blockOrderedListItemCell.blockLayout != null ? getLastNonListCell(blockOrderedListItemCell.blockLayout.itemView) : view;
}
public boolean isListItemBlock(TLRPC.PageBlock pageBlock) {
return (pageBlock instanceof TL_pageBlockListItem) || (pageBlock instanceof TL_pageBlockOrderedListItem);
}
public TLRPC.PageBlock getLastNonListPageBlock(TLRPC.PageBlock pageBlock) {
if (pageBlock instanceof TL_pageBlockListItem) {
TL_pageBlockListItem tL_pageBlockListItem = (TL_pageBlockListItem) pageBlock;
return tL_pageBlockListItem.blockItem != null ? getLastNonListPageBlock(tL_pageBlockListItem.blockItem) : tL_pageBlockListItem.blockItem;
}
if (!(pageBlock instanceof TL_pageBlockOrderedListItem)) {
return pageBlock;
}
TL_pageBlockOrderedListItem tL_pageBlockOrderedListItem = (TL_pageBlockOrderedListItem) pageBlock;
return tL_pageBlockOrderedListItem.blockItem != null ? getLastNonListPageBlock(tL_pageBlockOrderedListItem.blockItem) : 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;
}
if (!(lastNonListPageBlock instanceof TL_pageBlockDetailsChild)) {
return false;
}
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;
return !openAllParentBlocks(tL_pageBlockDetailsChild2) || z;
}
}
z = false;
if (openAllParentBlocks(tL_pageBlockDetailsChild2)) {
}
}
public TLRPC.PageBlock fixListBlock(TLRPC.PageBlock pageBlock, TLRPC.PageBlock pageBlock2) {
if (pageBlock instanceof TL_pageBlockListItem) {
((TL_pageBlockListItem) pageBlock).blockItem = pageBlock2;
return pageBlock;
}
if (!(pageBlock instanceof TL_pageBlockOrderedListItem)) {
return pageBlock2;
}
((TL_pageBlockOrderedListItem) pageBlock).blockItem = pageBlock2;
return pageBlock;
}
public 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;
}
if (!(pageBlock instanceof TL_pageBlockOrderedListItem)) {
return pageBlock2;
}
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;
int dp;
TLRPC.WebPage webPage = this.currentPage;
if (webPage == null || webPage.cached_page == null) {
return;
}
this.isRtl = this.currentPage.cached_page.rtl;
this.channelBlock = null;
this.titleTextView.setText(this.currentPage.site_name == null ? "" : this.currentPage.site_name);
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], (Property<RecyclerListView, Float>) View.TRANSLATION_X, AndroidUtilities.dp(56.0f), 0.0f), ObjectAnimator.ofFloat(this.listView[0], (Property<RecyclerListView, Float>) 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], (Property<RecyclerListView, Float>) View.TRANSLATION_X, 0.0f, AndroidUtilities.dp(56.0f)), ObjectAnimator.ofFloat(this.listView[1], (Property<RecyclerListView, Float>) View.ALPHA, 1.0f, 0.0f));
}
this.pageSwitchAnimation.setDuration(150L);
this.pageSwitchAnimation.setInterpolator(this.interpolator);
this.pageSwitchAnimation.addListener(new AnimatorListenerAdapter() {
@Override
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();
while (i2 < size) {
TLRPC.PageBlock pageBlock = this.currentPage.cached_page.blocks.get(i2);
if (i2 == 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 {
i2 = (i2 == 1 && this.channelBlock != null) ? i2 + 1 : 0;
}
this.adapter[0].addBlock(pageBlock, 0, 0, i2 == size + (-1) ? i2 : 0);
}
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 i4 = sharedPreferences.getInt(str, -1);
if (sharedPreferences.getBoolean(str + "r", true) == (AndroidUtilities.displaySize.x > AndroidUtilities.displaySize.y)) {
dp = sharedPreferences.getInt(str + "o", 0) - this.listView[0].getPaddingTop();
} else {
dp = AndroidUtilities.dp(10.0f);
}
if (i4 != -1) {
this.layoutManager[0].scrollToPositionWithOffset(i4, dp);
}
} 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);
TextView textView = new TextView(this.parentActivity) {
@Override
protected void onDraw(Canvas canvas) {
canvas.drawLine(0.0f, getMeasuredHeight() - 1, getMeasuredWidth(), getMeasuredHeight() - 1, ArticleViewer.dividerPaint);
super.onDraw(canvas);
}
};
textView.setTextSize(1, 16.0f);
textView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
textView.setText(LocaleController.getString("InstantViewReference", R.string.InstantViewReference));
textView.setGravity((this.isRtl ? 5 : 3) | 16);
textView.setTextColor(getTextColor());
textView.setPadding(AndroidUtilities.dp(18.0f), 0, AndroidUtilities.dp(18.0f), 0);
linearLayout.addView(textView, 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;
}
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;
}
protected void startCheckLongPress() {
if (this.checkingForLongPress) {
return;
}
this.checkingForLongPress = true;
if (this.pendingCheckForTap == null) {
this.pendingCheckForTap = new CheckForTap();
}
this.windowView.postDelayed(this.pendingCheckForTap, ViewConfiguration.getTapTimeout());
}
protected 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;
}
if (richText instanceof TLRPC.TL_textSubscript) {
return getTextFlags(richText.parentRichText) | 128;
}
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;
}
if (richText instanceof TLRPC.TL_textSubscript) {
return getLastRichText(((TLRPC.TL_textSubscript) richText).text);
}
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;
}
public CharSequence getText(View view, TLRPC.RichText richText, TLRPC.RichText richText2, TLRPC.PageBlock pageBlock, int i) {
int i2;
int i3;
Object textPaintUrlSpan;
Object textPaintUrlSpan2;
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) {
spannableStringBuilder.setSpan(new TextPaintUrlSpan((metricAffectingSpanArr == null || metricAffectingSpanArr.length == 0) ? getTextPaint(richText, richText2, pageBlock) : null, "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 textPaint = (metricAffectingSpanArr2 == null || metricAffectingSpanArr2.length == 0) ? getTextPaint(richText, richText2, pageBlock) : null;
if (tL_textUrl.webpage_id != 0) {
textPaintUrlSpan2 = new TextPaintWebpageUrlSpan(textPaint, getUrl(richText2));
} else {
textPaintUrlSpan2 = new TextPaintUrlSpan(textPaint, getUrl(richText2));
}
if (spannableStringBuilder2.length() != 0) {
spannableStringBuilder2.setSpan(textPaintUrlSpan2, 0, spannableStringBuilder2.length(), 33);
}
return spannableStringBuilder2;
}
if (richText2 instanceof TLRPC.TL_textPlain) {
return ((TLRPC.TL_textPlain) richText2).text;
}
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;
}
if (richText2 instanceof TLRPC.TL_textEmpty) {
return "";
}
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) " ");
}
int i6 = i5;
int i7 = size;
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) {
textPaintUrlSpan = new TextPaintWebpageUrlSpan(getTextPaint(richText, lastRichText, pageBlock), url);
} else {
textPaintUrlSpan = new TextPaintUrlSpan(getTextPaint(richText, lastRichText, pageBlock), url);
}
if (length != spannableStringBuilder4.length()) {
spannableStringBuilder4.setSpan(textPaintUrlSpan, length, spannableStringBuilder4.length(), 33);
}
} else if (length != spannableStringBuilder4.length()) {
spannableStringBuilder4.setSpan(new TextPaintSpan(getTextPaint(richText, lastRichText, pageBlock)), length, spannableStringBuilder4.length(), 33);
}
}
if (z && i6 != i7 - 1) {
spannableStringBuilder4.append((CharSequence) " ");
}
i5 = i6 + 1;
size = i7;
i4 = 1;
j = 0;
}
return spannableStringBuilder4;
}
if (richText2 instanceof TLRPC.TL_textSubscript) {
return getText(view, richText, ((TLRPC.TL_textSubscript) richText2).text, pageBlock, i);
}
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;
}
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) {
spannableStringBuilder6.setSpan(new TextPaintUrlSpan((metricAffectingSpanArr4 == null || metricAffectingSpanArr4.length == 0) ? getTextPaint(richText, richText2, pageBlock) : null, "tel:" + getUrl(richText2)), 0, spannableStringBuilder6.length(), 33);
}
return spannableStringBuilder6;
}
if (richText2 instanceof TLRPC.TL_textImage) {
TLRPC.Document documentWithId = getDocumentWithId(((TLRPC.TL_textImage) richText2).document_id);
if (documentWithId == null) {
return "";
}
SpannableStringBuilder spannableStringBuilder7 = new SpannableStringBuilder("*");
int dp = AndroidUtilities.dp(r0.w);
int dp2 = AndroidUtilities.dp(r0.h);
int abs = Math.abs(i);
if (dp > abs) {
i2 = (int) (dp2 * (abs / 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;
}
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;
}
if (richText instanceof TLRPC.TL_textSubscript) {
return getPlainText(((TLRPC.TL_textSubscript) richText).text);
}
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;
}
public int getTextColor() {
int selectedColor = getSelectedColor();
return (selectedColor == 0 || selectedColor == 1) ? -14606047 : -6710887;
}
private int getInstantLinkBackgroundColor() {
int selectedColor = getSelectedColor();
if (selectedColor != 0) {
return selectedColor != 1 ? -14536904 : -2498337;
}
return -1707782;
}
private int getLinkTextColor() {
int selectedColor = getSelectedColor();
if (selectedColor != 0) {
return selectedColor != 1 ? -10838585 : -13471296;
}
return -15435321;
}
public int getGrayTextColor() {
int selectedColor = getSelectedColor();
if (selectedColor != 0) {
return selectedColor != 1 ? -10066330 : -11711675;
}
return -8156010;
}
private TextPaint getTextPaint(TLRPC.RichText richText, TLRPC.RichText richText2, TLRPC.PageBlock pageBlock) {
int dp;
int dp2;
SparseArray<TextPaint> sparseArray;
int i;
SparseArray<TextPaint> sparseArray2;
int dp3;
int textColor;
SparseArray<TextPaint> sparseArray3;
int dp4;
SparseArray<TextPaint> sparseArray4;
int dp5;
SparseArray<TextPaint> sparseArray5;
int dp6;
SparseArray<TextPaint> sparseArray6;
int dp7;
int i2;
SparseArray<TextPaint> sparseArray7;
int dp8;
int textFlags = getTextFlags(richText2);
int dp9 = AndroidUtilities.dp(14.0f);
int i3 = this.selectedFontSize;
if (i3 == 0) {
dp2 = AndroidUtilities.dp(4.0f);
} else if (i3 == 1) {
dp2 = AndroidUtilities.dp(2.0f);
} else {
if (i3 == 3) {
dp = AndroidUtilities.dp(2.0f);
} else {
dp = i3 == 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;
dp8 = AndroidUtilities.dp(14.0f);
} else {
sparseArray7 = photoCreditTextPaints;
dp8 = AndroidUtilities.dp(12.0f);
}
sparseArray8 = sparseArray7;
dp9 = dp8;
i = 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;
dp7 = AndroidUtilities.dp(14.0f);
} else {
sparseArray6 = photoCreditTextPaints;
dp7 = AndroidUtilities.dp(12.0f);
}
sparseArray8 = sparseArray6;
dp9 = dp7;
i = getGrayTextColor();
} else if (pageBlock instanceof TLRPC.TL_pageBlockTitle) {
sparseArray8 = titleTextPaints;
dp9 = AndroidUtilities.dp(24.0f);
i = getTextColor();
} else if (pageBlock instanceof TLRPC.TL_pageBlockKicker) {
sparseArray8 = kickerTextPaints;
dp9 = AndroidUtilities.dp(14.0f);
i = getTextColor();
} else if (pageBlock instanceof TLRPC.TL_pageBlockAuthorDate) {
sparseArray8 = authorTextPaints;
dp9 = AndroidUtilities.dp(14.0f);
i = getGrayTextColor();
} else if (pageBlock instanceof TLRPC.TL_pageBlockFooter) {
sparseArray8 = footerTextPaints;
dp9 = AndroidUtilities.dp(14.0f);
i = getGrayTextColor();
} else if (pageBlock instanceof TLRPC.TL_pageBlockSubtitle) {
sparseArray8 = subtitleTextPaints;
dp9 = AndroidUtilities.dp(21.0f);
i = getTextColor();
} else if (pageBlock instanceof TLRPC.TL_pageBlockHeader) {
sparseArray8 = headerTextPaints;
dp9 = AndroidUtilities.dp(21.0f);
i = getTextColor();
} else if (pageBlock instanceof TLRPC.TL_pageBlockSubheader) {
sparseArray8 = subheaderTextPaints;
dp9 = AndroidUtilities.dp(18.0f);
i = getTextColor();
} else {
if (pageBlock instanceof TLRPC.TL_pageBlockBlockquote) {
TLRPC.TL_pageBlockBlockquote tL_pageBlockBlockquote = (TLRPC.TL_pageBlockBlockquote) pageBlock;
if (tL_pageBlockBlockquote.text == richText) {
sparseArray8 = quoteTextPaints;
dp9 = AndroidUtilities.dp(15.0f);
i = getTextColor();
} else {
if (tL_pageBlockBlockquote.caption == richText) {
sparseArray8 = photoCaptionTextPaints;
dp9 = AndroidUtilities.dp(14.0f);
i = getGrayTextColor();
}
i = SupportMenu.CATEGORY_MASK;
}
} else if (pageBlock instanceof TLRPC.TL_pageBlockPullquote) {
TLRPC.TL_pageBlockPullquote tL_pageBlockPullquote = (TLRPC.TL_pageBlockPullquote) pageBlock;
if (tL_pageBlockPullquote.text == richText) {
sparseArray8 = quoteTextPaints;
dp9 = AndroidUtilities.dp(15.0f);
i = getTextColor();
} else {
if (tL_pageBlockPullquote.caption == richText) {
sparseArray8 = photoCaptionTextPaints;
dp9 = AndroidUtilities.dp(14.0f);
i = getGrayTextColor();
}
i = SupportMenu.CATEGORY_MASK;
}
} else if (pageBlock instanceof TLRPC.TL_pageBlockPreformatted) {
sparseArray8 = preformattedTextPaints;
dp9 = AndroidUtilities.dp(14.0f);
i = getTextColor();
} else if (pageBlock instanceof TLRPC.TL_pageBlockParagraph) {
sparseArray8 = paragraphTextPaints;
dp9 = AndroidUtilities.dp(16.0f);
i = getTextColor();
} else if (isListItemBlock(pageBlock)) {
sparseArray8 = listTextPaints;
dp9 = AndroidUtilities.dp(16.0f);
i = 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;
dp6 = AndroidUtilities.dp(14.0f);
} else {
sparseArray5 = photoCreditTextPaints;
dp6 = AndroidUtilities.dp(12.0f);
}
sparseArray8 = sparseArray5;
dp9 = dp6;
i = 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;
dp5 = AndroidUtilities.dp(14.0f);
} else {
sparseArray4 = photoCreditTextPaints;
dp5 = AndroidUtilities.dp(12.0f);
}
sparseArray8 = sparseArray4;
dp9 = dp5;
i = 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;
dp4 = AndroidUtilities.dp(14.0f);
} else {
sparseArray3 = photoCreditTextPaints;
dp4 = AndroidUtilities.dp(12.0f);
}
sparseArray8 = sparseArray3;
dp9 = dp4;
i = 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;
dp9 = AndroidUtilities.dp(14.0f);
i = getGrayTextColor();
} else if (richText2 == tL_pageBlockEmbedPost.caption.credit) {
sparseArray8 = photoCreditTextPaints;
dp9 = AndroidUtilities.dp(12.0f);
i = getGrayTextColor();
} else {
if (richText2 != null) {
sparseArray8 = embedPostTextPaints;
dp9 = AndroidUtilities.dp(14.0f);
i = getTextColor();
}
i = SupportMenu.CATEGORY_MASK;
}
} else {
if (pageBlock instanceof TLRPC.TL_pageBlockVideo) {
if (richText2 == ((TLRPC.TL_pageBlockVideo) pageBlock).caption.text) {
sparseArray2 = mediaCaptionTextPaints;
dp3 = AndroidUtilities.dp(14.0f);
textColor = getTextColor();
} else {
sparseArray2 = mediaCreditTextPaints;
dp3 = AndroidUtilities.dp(12.0f);
textColor = getTextColor();
}
} else if (pageBlock instanceof TLRPC.TL_pageBlockAudio) {
if (richText2 == ((TLRPC.TL_pageBlockAudio) pageBlock).caption.text) {
sparseArray2 = mediaCaptionTextPaints;
dp3 = AndroidUtilities.dp(14.0f);
textColor = getTextColor();
} else {
sparseArray2 = mediaCreditTextPaints;
dp3 = AndroidUtilities.dp(12.0f);
textColor = getTextColor();
}
} else if (pageBlock instanceof TLRPC.TL_pageBlockRelatedArticles) {
sparseArray8 = relatedArticleTextPaints;
dp9 = AndroidUtilities.dp(15.0f);
i = getGrayTextColor();
} else if (pageBlock instanceof TLRPC.TL_pageBlockDetails) {
sparseArray8 = detailsTextPaints;
dp9 = AndroidUtilities.dp(15.0f);
i = getTextColor();
} else if (pageBlock instanceof TLRPC.TL_pageBlockTable) {
sparseArray8 = tableTextPaints;
dp9 = AndroidUtilities.dp(15.0f);
i = getTextColor();
} else {
sparseArray = null;
i = SupportMenu.CATEGORY_MASK;
}
sparseArray8 = sparseArray2;
i = textColor;
dp9 = dp3;
}
i2 = textFlags & 256;
if (i2 == 0 || (textFlags & 128) != 0) {
dp9 -= AndroidUtilities.dp(4.0f);
}
if (sparseArray == null) {
if (errorTextPaint == null) {
TextPaint textPaint = new TextPaint(1);
errorTextPaint = textPaint;
textPaint.setColor(SupportMenu.CATEGORY_MASK);
}
errorTextPaint.setTextSize(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 i4 = textFlags & 1;
if (i4 != 0 && (textFlags & 2) != 0) {
textPaint2.setTypeface(Typeface.create(C.SERIF_NAME, 3));
} else if (i4 != 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 i5 = textFlags & 1;
if (i5 != 0 && (textFlags & 2) != 0) {
textPaint2.setTypeface(AndroidUtilities.getTypeface("fonts/rmediumitalic.ttf"));
} else if (i5 != 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());
i = getLinkTextColor();
}
if (i2 != 0) {
textPaint2.baselineShift -= AndroidUtilities.dp(6.0f);
} else if ((textFlags & 128) != 0) {
textPaint2.baselineShift += AndroidUtilities.dp(2.0f);
}
textPaint2.setColor(i);
sparseArray.put(textFlags, textPaint2);
}
textPaint2.setTextSize(dp9 + dp);
return textPaint2;
}
sparseArray = sparseArray8;
i2 = textFlags & 256;
if (i2 == 0) {
}
dp9 -= AndroidUtilities.dp(4.0f);
if (sparseArray == null) {
}
}
dp = -dp2;
SparseArray<TextPaint> sparseArray82 = null;
if (!(pageBlock instanceof TLRPC.TL_pageBlockPhoto)) {
}
sparseArray = sparseArray82;
i2 = textFlags & 256;
if (i2 == 0) {
}
dp9 -= AndroidUtilities.dp(4.0f);
if (sparseArray == null) {
}
}
public 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);
}
public 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);
}
public DrawingText createLayoutForText(View view, CharSequence charSequence, TLRPC.RichText richText, int i, int i2, TLRPC.PageBlock pageBlock, Layout.Alignment alignment, int i3, WebpageAdapter webpageAdapter) {
int dp;
int dp2;
TextPaint textPaint;
?? r0;
LinkPath linkPath;
?? r9;
TextPaintMarkSpan[] textPaintMarkSpanArr;
?? linkPath2;
int i4;
int i5;
TextPaintWebpageUrlSpan[] textPaintWebpageUrlSpanArr;
int i6;
LinkPath linkPath3 = null;
if (charSequence == null && (richText == null || (richText instanceof TLRPC.TL_textEmpty))) {
return null;
}
int dp3 = i < 0 ? AndroidUtilities.dp(10.0f) : i;
int selectedColor = getSelectedColor();
CharSequence text = charSequence != null ? charSequence : getText(view, richText, richText, pageBlock, dp3);
if (TextUtils.isEmpty(text)) {
return null;
}
int i7 = this.selectedFontSize;
if (i7 == 0) {
dp2 = AndroidUtilities.dp(4.0f);
} else if (i7 == 1) {
dp2 = AndroidUtilities.dp(2.0f);
} else {
if (i7 == 3) {
dp = AndroidUtilities.dp(2.0f);
} else {
dp = i7 == 4 ? AndroidUtilities.dp(4.0f) : 0;
}
if (!(pageBlock instanceof TLRPC.TL_pageBlockEmbedPost) && richText == null) {
if (((TLRPC.TL_pageBlockEmbedPost) pageBlock).author == charSequence) {
if (embedPostAuthorPaint == null) {
TextPaint textPaint2 = new TextPaint(1);
embedPostAuthorPaint = textPaint2;
textPaint2.setColor(getTextColor());
}
embedPostAuthorPaint.setTextSize(AndroidUtilities.dp(15.0f) + dp);
textPaint = embedPostAuthorPaint;
} else {
if (embedPostDatePaint == null) {
TextPaint textPaint3 = new TextPaint(1);
embedPostDatePaint = textPaint3;
if (selectedColor == 0) {
textPaint3.setColor(-7366752);
} else {
textPaint3.setColor(getGrayTextColor());
}
}
embedPostDatePaint.setTextSize(AndroidUtilities.dp(14.0f) + dp);
textPaint = embedPostDatePaint;
}
} else if (!(pageBlock instanceof TLRPC.TL_pageBlockChannel)) {
if (channelNamePaint == null) {
TextPaint textPaint4 = new TextPaint(1);
channelNamePaint = textPaint4;
textPaint4.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
}
if (this.channelBlock == null) {
channelNamePaint.setColor(getTextColor());
} else {
channelNamePaint.setColor(-1);
}
channelNamePaint.setTextSize(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 textPaint5 = new TextPaint(1);
relatedArticleHeaderPaint = textPaint5;
textPaint5.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
}
relatedArticleHeaderPaint.setColor(getTextColor());
relatedArticleHeaderPaint.setTextSize(AndroidUtilities.dp(15.0f) + dp);
textPaint = relatedArticleHeaderPaint;
} else {
if (relatedArticleTextPaint == null) {
relatedArticleTextPaint = new TextPaint(1);
}
relatedArticleTextPaint.setColor(getGrayTextColor());
relatedArticleTextPaint.setTextSize(AndroidUtilities.dp(14.0f) + dp);
textPaint = relatedArticleTextPaint;
}
} else if (isListItemBlock(pageBlock) && charSequence != null) {
if (listTextPointerPaint == null) {
TextPaint textPaint6 = new TextPaint(1);
listTextPointerPaint = textPaint6;
textPaint6.setColor(getTextColor());
}
if (listTextNumPaint == null) {
TextPaint textPaint7 = new TextPaint(1);
listTextNumPaint = textPaint7;
textPaint7.setColor(getTextColor());
}
listTextPointerPaint.setTextSize(AndroidUtilities.dp(19.0f) + dp);
listTextNumPaint.setTextSize(AndroidUtilities.dp(16.0f) + dp);
if ((pageBlock instanceof TL_pageBlockListItem) && !((TL_pageBlockListItem) pageBlock).parent.pageBlockList.ordered) {
textPaint = listTextPointerPaint;
} else {
textPaint = listTextNumPaint;
}
} else {
textPaint = getTextPaint(richText, richText, pageBlock);
}
TextPaint textPaint8 = textPaint;
if (i3 == 0) {
if (pageBlock instanceof TLRPC.TL_pageBlockPullquote) {
r0 = StaticLayoutEx.createStaticLayout(text, textPaint8, dp3, Layout.Alignment.ALIGN_CENTER, 1.0f, 0.0f, false, TextUtils.TruncateAt.END, dp3, i3);
} else {
r0 = StaticLayoutEx.createStaticLayout(text, textPaint8, dp3, alignment, 1.0f, AndroidUtilities.dp(4.0f), false, TextUtils.TruncateAt.END, dp3, i3);
}
} else {
if (text.charAt(text.length() - 1) == '\n') {
text = text.subSequence(0, text.length() - 1);
}
CharSequence charSequence2 = text;
if (pageBlock instanceof TLRPC.TL_pageBlockPullquote) {
r0 = new StaticLayout(charSequence2, textPaint8, dp3, Layout.Alignment.ALIGN_CENTER, 1.0f, 0.0f, false);
} else {
r0 = new StaticLayout(charSequence2, textPaint8, dp3, alignment, 1.0f, AndroidUtilities.dp(4.0f), false);
}
}
if (r0 != 0) {
return null;
}
CharSequence text2 = r0.getText();
if (r0 == 0 || !(text2 instanceof Spanned)) {
linkPath = null;
} else {
Spanned spanned = (Spanned) text2;
try {
AnchorSpan[] anchorSpanArr = (AnchorSpan[]) spanned.getSpans(0, spanned.length(), AnchorSpan.class);
int lineCount = r0.getLineCount();
if (anchorSpanArr != null && anchorSpanArr.length > 0) {
for (int i8 = 0; i8 < anchorSpanArr.length; i8++) {
if (lineCount <= 1) {
webpageAdapter.anchorsOffset.put(anchorSpanArr[i8].getName(), Integer.valueOf(i2));
} else {
webpageAdapter.anchorsOffset.put(anchorSpanArr[i8].getName(), Integer.valueOf(i2 + r0.getLineTop(r0.getLineForOffset(spanned.getSpanStart(anchorSpanArr[i8])))));
}
}
}
} catch (Exception unused) {
}
try {
textPaintWebpageUrlSpanArr = (TextPaintWebpageUrlSpan[]) spanned.getSpans(0, spanned.length(), TextPaintWebpageUrlSpan.class);
} catch (Exception unused2) {
}
if (textPaintWebpageUrlSpanArr != null && textPaintWebpageUrlSpanArr.length > 0) {
r9 = new LinkPath(true);
try {
r9.setAllowReset(false);
for (int i9 = 0; i9 < textPaintWebpageUrlSpanArr.length; i9++) {
int spanStart = spanned.getSpanStart(textPaintWebpageUrlSpanArr[i9]);
int spanEnd = spanned.getSpanEnd(textPaintWebpageUrlSpanArr[i9]);
r9.setCurrentLayout(r0, spanStart, 0.0f);
int i10 = textPaintWebpageUrlSpanArr[i9].getTextPaint() != null ? textPaintWebpageUrlSpanArr[i9].getTextPaint().baselineShift : 0;
if (i10 != 0) {
i6 = i10 + AndroidUtilities.dp(i10 > 0 ? 5.0f : -2.0f);
} else {
i6 = 0;
}
r9.setBaselineShift(i6);
r0.getSelectionPath(spanStart, spanEnd, r9);
}
r9.setAllowReset(true);
} catch (Exception unused3) {
}
textPaintMarkSpanArr = (TextPaintMarkSpan[]) spanned.getSpans(0, spanned.length(), TextPaintMarkSpan.class);
if (textPaintMarkSpanArr != null && textPaintMarkSpanArr.length > 0) {
linkPath2 = new LinkPath(true);
try {
linkPath2.setAllowReset(false);
for (i4 = 0; i4 < textPaintMarkSpanArr.length; i4++) {
int spanStart2 = spanned.getSpanStart(textPaintMarkSpanArr[i4]);
int spanEnd2 = spanned.getSpanEnd(textPaintMarkSpanArr[i4]);
linkPath2.setCurrentLayout(r0, spanStart2, 0.0f);
int i11 = textPaintMarkSpanArr[i4].getTextPaint() != null ? textPaintMarkSpanArr[i4].getTextPaint().baselineShift : 0;
if (i11 != 0) {
i5 = i11 + AndroidUtilities.dp(i11 > 0 ? 5.0f : -2.0f);
} else {
i5 = 0;
}
linkPath2.setBaselineShift(i5);
r0.getSelectionPath(spanStart2, spanEnd2, linkPath2);
}
linkPath2.setAllowReset(true);
} catch (Exception unused4) {
}
linkPath3 = linkPath2;
}
linkPath = linkPath3;
linkPath3 = r9;
}
r9 = 0;
textPaintMarkSpanArr = (TextPaintMarkSpan[]) spanned.getSpans(0, spanned.length(), TextPaintMarkSpan.class);
if (textPaintMarkSpanArr != null) {
linkPath2 = new LinkPath(true);
linkPath2.setAllowReset(false);
while (i4 < textPaintMarkSpanArr.length) {
}
linkPath2.setAllowReset(true);
linkPath3 = linkPath2;
}
linkPath = linkPath3;
linkPath3 = r9;
}
DrawingText drawingText = new DrawingText();
drawingText.textLayout = r0;
drawingText.textPath = linkPath3;
drawingText.markPath = linkPath;
return drawingText;
}
dp = -dp2;
if (!(pageBlock instanceof TLRPC.TL_pageBlockEmbedPost)) {
}
if (!(pageBlock instanceof TLRPC.TL_pageBlockChannel)) {
}
TextPaint textPaint82 = textPaint;
if (i3 == 0) {
}
if (r0 != 0) {
}
}
public void drawLayoutLink(Canvas canvas, DrawingText drawingText) {
float width;
float f;
if (canvas == null || drawingText == null || this.pressedLinkOwnerLayout != drawingText) {
return;
}
if (this.pressedLink != null) {
canvas.drawPath(this.urlPath, urlPaint);
return;
}
if (!this.drawBlockSelection || drawingText == null) {
return;
}
if (drawingText.getLineCount() == 1) {
width = drawingText.getLineWidth(0);
f = drawingText.getLineLeft(0);
} else {
width = drawingText.getWidth();
f = 0.0f;
}
canvas.drawRect((-AndroidUtilities.dp(2.0f)) + f, 0.0f, f + width + AndroidUtilities.dp(2.0f), drawingText.getHeight(), urlPaint);
}
public boolean checkLayoutForLinks(MotionEvent motionEvent, View view, DrawingText drawingText, int i, int i2) {
boolean z;
boolean z2;
String lowerCase;
String str;
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 = x;
float f4 = 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 = 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 str2 = 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)) {
lowerCase = this.currentPage.cached_page.url.toLowerCase();
} else {
lowerCase = this.currentPage.url.toLowerCase();
}
try {
str = URLDecoder.decode(url.substring(lastIndexOf + 1), "UTF-8");
} catch (Exception unused) {
str = "";
}
if (url.toLowerCase().contains(lowerCase)) {
if (TextUtils.isEmpty(str)) {
this.layoutManager[0].scrollToPositionWithOffset(0, 0);
checkScrollAnimated();
} else {
scrollToAnchor(str);
}
z2 = true;
} else {
z2 = false;
}
str2 = str;
} else {
z2 = false;
}
if (!z2) {
openWebpageUrl(this.pressedLink.getUrl(), str2);
}
}
}
} 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();
}
return !(view instanceof BlockDetailsCell) ? this.pressedLink != null : this.pressedLinkOwnerLayout != null;
}
z = false;
if (z) {
}
if (motionEvent.getAction() == 0) {
}
if (motionEvent.getAction() != 0) {
cancelCheckLongPress();
}
if (!(view instanceof BlockDetailsCell)) {
}
}
public void removePressedLink() {
if (this.pressedLink == null && this.pressedLinkOwnerView == null) {
return;
}
View view = this.pressedLinkOwnerView;
this.pressedLink = null;
this.pressedLinkOwnerLayout = null;
this.pressedLinkOwnerView = null;
if (view != null) {
view.invalidate();
}
}
public void openWebpageUrl(String str, final String str2) {
if (this.openUrlReqId != 0) {
ConnectionsManager.getInstance(this.currentAccount).cancelRequest(this.openUrlReqId, false);
this.openUrlReqId = 0;
}
final int i = this.lastReqId + 1;
this.lastReqId = i;
closePhoto(false);
showProgressView(true, true);
final 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() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
ArticleViewer.this.lambda$openWebpageUrl$6$ArticleViewer(i, str2, tL_messages_getWebPage, tLObject, tL_error);
}
});
}
public void lambda$openWebpageUrl$6$ArticleViewer(final int i, final String str, final TLRPC.TL_messages_getWebPage tL_messages_getWebPage, final TLObject tLObject, TLRPC.TL_error tL_error) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
ArticleViewer.this.lambda$null$5$ArticleViewer(i, tLObject, str, tL_messages_getWebPage);
}
});
}
public 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) {
return;
}
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);
}
}
public 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;
}
public 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
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)) {
this.radialProgressViews[i3].setProgress(1.0f, true);
checkProgress(i3, true);
return;
}
i3++;
}
return;
}
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;
}
}
return;
}
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++;
}
return;
}
if (i == NotificationCenter.emojiDidLoad) {
TextView textView = this.captionTextView;
if (textView != null) {
textView.invalidate();
return;
}
return;
}
if (i == NotificationCenter.needSetDayNightTheme) {
if (!this.nightModeEnabled || this.selectedColor == 2 || this.adapter == null) {
return;
}
updatePaintColors();
while (i3 < this.listView.length) {
this.adapter[i3].notifyDataSetChanged();
i3++;
}
return;
}
if (i == NotificationCenter.messagePlayingDidStart) {
if (this.listView == null) {
return;
}
int i5 = 0;
while (true) {
RecyclerListView[] recyclerListViewArr = this.listView;
if (i5 >= recyclerListViewArr.length) {
return;
}
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 if (i == NotificationCenter.messagePlayingDidReset || i == NotificationCenter.messagePlayingPlayStateChanged) {
if (this.listView == null) {
return;
}
int i7 = 0;
while (true) {
RecyclerListView[] recyclerListViewArr2 = this.listView;
if (i7 >= recyclerListViewArr2.length) {
return;
}
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 {
if (i != NotificationCenter.messagePlayingProgressDidChanged) {
return;
}
Integer num = (Integer) objArr[0];
if (this.listView == null) {
return;
}
int i9 = 0;
while (true) {
RecyclerListView[] recyclerListViewArr3 = this.listView;
if (i9 >= recyclerListViewArr3.length) {
return;
}
int childCount3 = recyclerListViewArr3[i9].getChildCount();
int i10 = 0;
while (true) {
if (i10 < childCount3) {
View childAt3 = this.listView[i9].getChildAt(i10);
if ((childAt3 instanceof BlockAudioCell) && (messageObject = (blockAudioCell = (BlockAudioCell) childAt3).getMessageObject()) != null && messageObject.getId() == num.intValue()) {
MessageObject playingMessageObject = MediaController.getInstance().getPlayingMessageObject();
if (playingMessageObject != null) {
messageObject.audioProgress = playingMessageObject.audioProgress;
messageObject.audioProgressSec = playingMessageObject.audioProgressSec;
messageObject.audioPlayerDuration = playingMessageObject.audioPlayerDuration;
blockAudioCell.updatePlayingMessageProgress();
}
} else {
i10++;
}
}
}
i9++;
}
}
}
public 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);
return;
}
if (i2 != 0) {
textPaint.setTypeface(typeface3);
} else if ((i & 2) != 0) {
textPaint.setTypeface(typeface4);
} else {
if ((i & 4) != 0) {
return;
}
textPaint.setTypeface(typeface);
}
}
public int getSelectedColor() {
int i = this.selectedColor;
if (!this.nightModeEnabled || i == 2) {
return i;
}
if (Theme.selectedAutoNightType != 0) {
if (!Theme.isCurrentThemeNight()) {
return i;
}
} else {
int i2 = Calendar.getInstance().get(11);
if ((i2 < 22 || i2 > 24) && (i2 < 0 || i2 > 6)) {
return i;
}
}
return 2;
}
private void updatePaintColors() {
int i = 0;
ApplicationLoader.applicationContext.getSharedPreferences("articles", 0).edit().putInt("font_color", this.selectedColor).commit();
int selectedColor = getSelectedColor();
if (selectedColor == 0) {
this.backgroundPaint.setColor(-1);
while (true) {
RecyclerListView[] recyclerListViewArr = this.listView;
if (i >= recyclerListViewArr.length) {
break;
}
recyclerListViewArr[i].setGlowColor(-657673);
i++;
}
} else if (selectedColor == 1) {
this.backgroundPaint.setColor(-659492);
while (true) {
RecyclerListView[] recyclerListViewArr2 = this.listView;
if (i >= recyclerListViewArr2.length) {
break;
}
recyclerListViewArr2[i].setGlowColor(-659492);
i++;
}
} else if (selectedColor == 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 (selectedColor == 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(getLinkTextColor());
} else {
valueAt.setColor(getTextColor());
}
}
}
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 windowView = new WindowView(activity);
this.windowView = windowView;
windowView.setWillNotDraw(false);
this.windowView.setClipChildren(true);
this.windowView.setFocusable(false);
FrameLayout frameLayout = new FrameLayout(activity) {
@Override
protected boolean drawChild(Canvas canvas, View view, long j) {
int i2;
int i3;
if (ArticleViewer.this.windowView.movingPage) {
int measuredWidth = getMeasuredWidth();
int translationX = (int) ArticleViewer.this.listView[0].getTranslationX();
if (view == ArticleViewer.this.listView[1]) {
i2 = translationX;
} else {
i2 = measuredWidth;
if (view == ArticleViewer.this.listView[0]) {
i3 = translationX;
int save = canvas.save();
canvas.clipRect(i3, 0, i2, getHeight());
boolean drawChild = super.drawChild(canvas, view, j);
canvas.restoreToCount(save);
if (translationX != 0) {
if (view != ArticleViewer.this.listView[0]) {
if (view == ArticleViewer.this.listView[1]) {
float min = Math.min(0.8f, (measuredWidth - translationX) / measuredWidth);
ArticleViewer.this.scrimPaint.setColor(((int) ((min >= 0.0f ? min : 0.0f) * 153.0f)) << 24);
canvas.drawRect(i3, 0.0f, i2, getHeight(), ArticleViewer.this.scrimPaint);
}
} else {
float max = Math.max(0.0f, Math.min((measuredWidth - translationX) / 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);
}
}
return drawChild;
}
}
i3 = 0;
int save2 = canvas.save();
canvas.clipRect(i3, 0, i2, getHeight());
boolean drawChild2 = super.drawChild(canvas, view, j);
canvas.restoreToCount(save2);
if (translationX != 0) {
}
return drawChild2;
}
return super.drawChild(canvas, view, j);
}
};
this.containerView = frameLayout;
this.windowView.addView(frameLayout, LayoutHelper.createFrame(-1, -1, 51));
this.containerView.setFitsSystemWindows(true);
if (Build.VERSION.SDK_INT >= 21) {
this.containerView.setOnApplyWindowInsetsListener(new View.OnApplyWindowInsetsListener() {
@Override
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));
FrameLayoutDrawer frameLayoutDrawer = new FrameLayoutDrawer(activity) {
@Override
protected void onLayout(boolean z, int i2, int i3, int i4, int i5) {
super.onLayout(z, i2, i3, i4, i5);
int i6 = i5 - i3;
int measuredHeight = i6 - ArticleViewer.this.captionTextView.getMeasuredHeight();
int measuredHeight2 = i6 - 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 = frameLayoutDrawer;
frameLayoutDrawer.setVisibility(4);
this.photoContainerView.setWillNotDraw(false);
this.windowView.addView(this.photoContainerView, LayoutHelper.createFrame(-1, -1, 51));
FrameLayout frameLayout2 = new FrameLayout(activity);
this.fullscreenVideoContainer = frameLayout2;
frameLayout2.setBackgroundColor(-16777216);
this.fullscreenVideoContainer.setVisibility(4);
this.windowView.addView(this.fullscreenVideoContainer, LayoutHelper.createFrame(-1, -1.0f));
AspectRatioFrameLayout aspectRatioFrameLayout = new AspectRatioFrameLayout(activity);
this.fullscreenAspectRatioView = aspectRatioFrameLayout;
aspectRatioFrameLayout.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) {
@Override
public void onLayout(boolean z, int i3, int i4, int i5, int i6) {
super.onLayout(z, i3, i4, i5, i6);
int childCount = getChildCount();
for (int i7 = 0; i7 < childCount; i7++) {
View childAt = getChildAt(i7);
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
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))) {
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);
}
} else {
ArticleViewer.this.pressedLink = null;
ArticleViewer.this.pressedLinkOwnerLayout = null;
ArticleViewer.this.pressedLinkOwnerView = null;
}
return super.onInterceptTouchEvent(motionEvent);
}
@Override
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);
}
@Override
public void setTranslationX(float f) {
super.setTranslationX(f);
if (ArticleViewer.this.windowView.movingPage) {
ArticleViewer.this.containerView.invalidate();
ArticleViewer articleViewer = ArticleViewer.this;
articleViewer.setCurrentHeaderHeight((int) (articleViewer.windowView.startMovingHeaderHeight + ((AndroidUtilities.dp(56.0f) - ArticleViewer.this.windowView.startMovingHeaderHeight) * (f / getMeasuredWidth()))));
}
}
};
((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;
final 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() {
@Override
public final boolean onItemClick(View view2, int i3) {
return ArticleViewer.this.lambda$setParentActivity$8$ArticleViewer(view2, i3);
}
});
this.listView[i2].setOnItemClickListener(new RecyclerListView.OnItemClickListener() {
@Override
public final void onItemClick(View view2, int i3) {
ArticleViewer.this.lambda$setParentActivity$11$ArticleViewer(webpageAdapter, view2, i3);
}
});
this.listView[i2].setOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrolled(RecyclerView recyclerView, int i3, int i4) {
if (recyclerView.getChildCount() == 0) {
return;
}
ArticleViewer.this.headerView.invalidate();
ArticleViewer.this.checkScroll(i4);
}
});
i2++;
}
this.headerPaint.setColor(-16777216);
this.statusBarPaint.setColor(-16777216);
this.headerProgressPaint.setColor(-14408666);
FrameLayout frameLayout3 = new FrameLayout(activity) {
@Override
protected void onDraw(Canvas canvas) {
float measuredWidth = getMeasuredWidth();
float measuredHeight = getMeasuredHeight();
canvas.drawRect(0.0f, 0.0f, measuredWidth, measuredHeight, ArticleViewer.this.headerPaint);
if (ArticleViewer.this.layoutManager == null) {
return;
}
int findFirstVisibleItemPosition = ArticleViewer.this.layoutManager[0].findFirstVisibleItemPosition();
int findLastVisibleItemPosition = ArticleViewer.this.layoutManager[0].findLastVisibleItemPosition();
int itemCount = ArticleViewer.this.layoutManager[0].getItemCount() - 2;
View findViewByPosition = findLastVisibleItemPosition >= itemCount ? ArticleViewer.this.layoutManager[0].findViewByPosition(itemCount) : ArticleViewer.this.layoutManager[0].findViewByPosition(findFirstVisibleItemPosition);
if (findViewByPosition == null) {
return;
}
float f = measuredWidth / (r5 - 1);
ArticleViewer.this.layoutManager[0].getChildCount();
float measuredHeight2 = findViewByPosition.getMeasuredHeight();
canvas.drawRect(0.0f, 0.0f, (findFirstVisibleItemPosition * f) + (findLastVisibleItemPosition >= itemCount ? (((itemCount - findFirstVisibleItemPosition) * f) * (ArticleViewer.this.listView[0].getMeasuredHeight() - findViewByPosition.getTop())) / measuredHeight2 : (1.0f - ((Math.min(0, findViewByPosition.getTop() - ArticleViewer.this.listView[0].getPaddingTop()) + measuredHeight2) / measuredHeight2)) * f), measuredHeight, ArticleViewer.this.headerProgressPaint);
}
};
this.headerView = frameLayout3;
frameLayout3.setOnTouchListener(new View.OnTouchListener() {
@Override
public final boolean onTouch(View view2, MotionEvent motionEvent) {
return ArticleViewer.lambda$setParentActivity$12(view2, motionEvent);
}
});
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 backDrawable = new BackDrawable(false);
this.backDrawable = backDrawable;
backDrawable.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() {
@Override
public final void onClick(View view2) {
ArticleViewer.this.lambda$setParentActivity$13$ArticleViewer(view2);
}
});
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(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 lineProgressView = new LineProgressView(activity);
this.lineProgressView = lineProgressView;
lineProgressView.setProgressColor(-1);
this.lineProgressView.setPivotX(0.0f);
this.lineProgressView.setPivotY(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() {
@Override
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() {
@Override
public final void onClick(View view2) {
ArticleViewer.this.lambda$setParentActivity$15$ArticleViewer(view2);
}
});
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() {
@Override
public final void onClick(View view2) {
ArticleViewer.this.lambda$setParentActivity$16$ArticleViewer(view2);
}
});
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() {
@Override
public final void onClick(View view3) {
ArticleViewer.this.lambda$setParentActivity$17$ArticleViewer(view3);
}
});
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 frameLayout4 = new FrameLayout(activity);
this.shareContainer = frameLayout4;
this.headerView.addView(frameLayout4, LayoutHelper.createFrame(48, 56, 53));
this.shareContainer.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view4) {
ArticleViewer.this.lambda$setParentActivity$18$ArticleViewer(view4);
}
});
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 actionBar = new ActionBar(activity);
this.actionBar = actionBar;
actionBar.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() {
@Override
public void onItemClick(int i5) {
if (i5 == -1) {
ArticleViewer.this.closePhoto(true);
return;
}
if (i5 != 1) {
if (i5 == 2) {
ArticleViewer.this.onSharePressed();
return;
}
if (i5 == 3) {
try {
AndroidUtilities.openForView(ArticleViewer.this.getMedia(ArticleViewer.this.currentIndex), ArticleViewer.this.parentActivity);
ArticleViewer.this.closePhoto(false);
return;
} catch (Exception e) {
FileLog.e(e);
return;
}
}
return;
}
if (Build.VERSION.SDK_INT >= 23 && ArticleViewer.this.parentActivity.checkSelfPermission(PermissionUtils.EXTERNAL_STORAGE) != 0) {
ArticleViewer.this.parentActivity.requestPermissions(new String[]{PermissionUtils.EXTERNAL_STORAGE}, 4);
return;
}
ArticleViewer articleViewer = ArticleViewer.this;
File mediaFile = articleViewer.getMediaFile(articleViewer.currentIndex);
if (mediaFile != null && mediaFile.exists()) {
String file = mediaFile.toString();
Activity activity2 = ArticleViewer.this.parentActivity;
ArticleViewer articleViewer2 = ArticleViewer.this;
MediaController.saveFile(file, activity2, articleViewer2.isMediaVideo(articleViewer2.currentIndex) ? 1 : 0, null, null);
return;
}
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());
}
@Override
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 frameLayout5 = new FrameLayout(this.parentActivity);
this.bottomLayout = frameLayout5;
frameLayout5.setBackgroundColor(Theme.ACTION_BAR_PHOTO_VIEWER_COLOR);
this.photoContainerView.addView(this.bottomLayout, LayoutHelper.createFrame(-1, 48, 83));
GroupedPhotosListView groupedPhotosListView = new GroupedPhotosListView(this.parentActivity);
this.groupedPhotosListView = groupedPhotosListView;
this.photoContainerView.addView(groupedPhotosListView, LayoutHelper.createFrame(-1.0f, 62.0f, 83, 0.0f, 0.0f, 0.0f, 0.0f));
this.groupedPhotosListView.setDelegate(new GroupedPhotosListView.GroupedPhotosListViewDelegate() {
@Override
public int getAvatarsDialogId() {
return 0;
}
@Override
public ArrayList<MessageObject> getImagesArr() {
return null;
}
@Override
public ArrayList<ImageLocation> getImagesArrLocations() {
return null;
}
@Override
public int getSlideshowMessageId() {
return 0;
}
@Override
public int getCurrentIndex() {
return ArticleViewer.this.currentIndex;
}
@Override
public int getCurrentAccount() {
return ArticleViewer.this.currentAccount;
}
@Override
public ArrayList<TLRPC.PageBlock> getPageBlockArr() {
return ArticleViewer.this.imagesArr;
}
@Override
public Object getParentObject() {
return ArticleViewer.this.currentPage;
}
@Override
public void setCurrentIndex(int i5) {
ArticleViewer.this.currentIndex = -1;
if (ArticleViewer.this.currentThumb != null) {
ArticleViewer.this.currentThumb.release();
ArticleViewer.this.currentThumb = null;
}
ArticleViewer.this.setImageIndex(i5, 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() {
@Override
public void onSeekBarContinuousDrag(float f) {
SeekBar.SeekBarDelegate.CC.$default$onSeekBarContinuousDrag(this, f);
}
@Override
public final void onSeekBarDrag(float f) {
ArticleViewer.this.lambda$setParentActivity$19$ArticleViewer(f);
}
});
FrameLayout frameLayout6 = new FrameLayout(activity) {
@Override
public boolean onTouchEvent(MotionEvent motionEvent) {
motionEvent.getX();
motionEvent.getY();
if (ArticleViewer.this.videoPlayerSeekbar.onTouch(motionEvent.getAction(), motionEvent.getX() - AndroidUtilities.dp(48.0f), motionEvent.getY())) {
getParent().requestDisallowInterceptTouchEvent(true);
invalidate();
return true;
}
return super.onTouchEvent(motionEvent);
}
@Override
protected void onMeasure(int i5, int i6) {
super.onMeasure(i5, i6);
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;
long j3 = j2 / 60;
long j4 = j2 % 60;
ArticleViewer.this.videoPlayerSeekbar.setSize((getMeasuredWidth() - AndroidUtilities.dp(64.0f)) - ((int) Math.ceil(ArticleViewer.this.videoPlayerTime.getPaint().measureText(String.format("%02d:%02d / %02d:%02d", Long.valueOf(j3), Long.valueOf(j4), Long.valueOf(j3), Long.valueOf(j4))))), getMeasuredHeight());
}
@Override
protected void onLayout(boolean z, int i5, int i6, int i7, int i8) {
super.onLayout(z, i5, i6, i7, i8);
ArticleViewer.this.videoPlayerSeekbar.setProgress(ArticleViewer.this.videoPlayer != null ? ((float) ArticleViewer.this.videoPlayer.getCurrentPosition()) / ((float) ArticleViewer.this.videoPlayer.getDuration()) : 0.0f);
}
@Override
protected void onDraw(Canvas canvas) {
canvas.save();
canvas.translate(AndroidUtilities.dp(48.0f), 0.0f);
ArticleViewer.this.videoPlayerSeekbar.draw(canvas);
canvas.restore();
}
};
this.videoPlayerControlFrameLayout = frameLayout6;
frameLayout6.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() {
@Override
public final void onClick(View view4) {
ArticleViewer.this.lambda$setParentActivity$20$ArticleViewer(view4);
}
});
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 gestureDetector = new GestureDetector(activity, this);
this.gestureDetector = gestureDetector;
gestureDetector.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 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()) {
this.hasCutout = boundingRects.get(0).height() != 0;
}
return windowInsets.consumeSystemWindowInsets();
}
public 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 void lambda$setParentActivity$11$ArticleViewer(WebpageAdapter webpageAdapter, View view, int i) {
if (i == webpageAdapter.localBlocks.size() && this.currentPage != null) {
if (this.previewsReqId != 0) {
return;
}
TLObject userOrChat = MessagesController.getInstance(this.currentAccount).getUserOrChat("previews");
if (userOrChat instanceof TLRPC.TL_user) {
openPreviewsChat((TLRPC.User) userOrChat, this.currentPage.id);
return;
}
final int i2 = UserConfig.selectedAccount;
final 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() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
ArticleViewer.this.lambda$null$10$ArticleViewer(i2, j, tLObject, tL_error);
}
});
return;
}
if (i < 0 || i >= webpageAdapter.localBlocks.size()) {
return;
}
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);
return;
}
if (lastNonListPageBlock instanceof TL_pageBlockRelatedArticlesChild) {
TL_pageBlockRelatedArticlesChild tL_pageBlockRelatedArticlesChild = (TL_pageBlockRelatedArticlesChild) lastNonListPageBlock;
openWebpageUrl(tL_pageBlockRelatedArticlesChild.parent.articles.get(tL_pageBlockRelatedArticlesChild.num).url, null);
return;
}
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) {
return;
}
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) {
if (tL_pageBlockDetails.open) {
webpageAdapter.notifyItemRangeInserted(i + 1, abs);
} else {
webpageAdapter.notifyItemRangeRemoved(i + 1, abs);
}
}
}
}
}
public void lambda$null$10$ArticleViewer(final int i, final long j, final TLObject tLObject, TLRPC.TL_error tL_error) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
ArticleViewer.this.lambda$null$9$ArticleViewer(tLObject, i, j);
}
});
}
public void lambda$null$9$ArticleViewer(TLObject tLObject, int i, long j) {
if (this.previewsReqId == 0) {
return;
}
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()) {
return;
}
openPreviewsChat(tL_contacts_resolvedPeer.users.get(0), j);
}
}
public void lambda$setParentActivity$13$ArticleViewer(View view) {
close(true, true);
}
public 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 lineProgressView = this.lineProgressView;
lineProgressView.setProgress(lineProgressView.getCurrentProgress() + f, true);
AndroidUtilities.runOnUIThread(this.lineProgressTickRunnable, 100L);
}
}
public 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 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 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 void lambda$setParentActivity$18$ArticleViewer(View view) {
if (this.currentPage == null || this.parentActivity == null) {
return;
}
showDialog(new ShareAlert(this.parentActivity, null, this.currentPage.url, false, this.currentPage.url, true));
}
public void lambda$setParentActivity$19$ArticleViewer(float f) {
VideoPlayer videoPlayer = this.videoPlayer;
if (videoPlayer != null) {
videoPlayer.seekTo((int) (f * ((float) videoPlayer.getDuration())));
}
}
public void lambda$setParentActivity$20$ArticleViewer(View view) {
VideoPlayer videoPlayer = this.videoPlayer;
if (videoPlayer != null) {
if (this.isPlaying) {
videoPlayer.pause();
} else {
videoPlayer.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);
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);
this.nightModeHintView.addView(textView, LayoutHelper.createFrame(-1.0f, -1.0f, (LocaleController.isRTL ? 5 : 3) | 48, LocaleController.isRTL ? 10 : 56, 11.0f, LocaleController.isRTL ? 56 : 10, 12.0f));
AnimatorSet animatorSet = new AnimatorSet();
animatorSet.playTogether(ObjectAnimator.ofFloat(this.nightModeHintView, (Property<FrameLayout, Float>) View.TRANSLATION_Y, AndroidUtilities.dp(100.0f), 0.0f));
animatorSet.setInterpolator(new DecelerateInterpolator(1.5f));
animatorSet.addListener(new AnonymousClass12());
animatorSet.setDuration(250L);
animatorSet.start();
}
}
public class AnonymousClass12 extends AnimatorListenerAdapter {
AnonymousClass12() {
}
@Override
public void onAnimationEnd(Animator animator) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
ArticleViewer.AnonymousClass12.this.lambda$onAnimationEnd$0$ArticleViewer$12();
}
}, 3000L);
}
public void lambda$onAnimationEnd$0$ArticleViewer$12() {
AnimatorSet animatorSet = new AnimatorSet();
animatorSet.playTogether(ObjectAnimator.ofFloat(ArticleViewer.this.nightModeHintView, (Property<FrameLayout, Float>) View.TRANSLATION_Y, AndroidUtilities.dp(100.0f)));
animatorSet.setInterpolator(new DecelerateInterpolator(1.5f));
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
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)) {
return;
}
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() {
@Override
public final void onAnimationUpdate(ValueAnimator valueAnimator) {
ArticleViewer.this.lambda$checkScrollAnimated$21$ArticleViewer(valueAnimator);
}
});
duration.start();
}
public void lambda$checkScrollAnimated$21$ArticleViewer(ValueAnimator valueAnimator) {
setCurrentHeaderHeight(((Integer) valueAnimator.getAnimatedValue()).intValue());
}
public 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 = dp - max;
this.currentHeaderHeight = i;
float f2 = (((i - max) / f) * 0.2f) + 0.8f;
this.backButton.setScaleX(f2);
this.backButton.setScaleY(f2);
this.backButton.setTranslationY((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((((i - max) / f) * 0.5f) + 0.5f);
this.shareContainer.setTranslationY((dp - this.currentHeaderHeight) / 2);
this.settingsButton.setTranslationY((dp - this.currentHeaderHeight) / 2);
this.titleTextView.setTranslationY((dp - this.currentHeaderHeight) / 2);
this.headerView.setTranslationY(this.currentHeaderHeight - dp);
int i2 = 0;
while (true) {
RecyclerListView[] recyclerListViewArr = this.listView;
if (i2 >= recyclerListViewArr.length) {
return;
}
recyclerListViewArr[i2].setTopGlowOffset(this.currentHeaderHeight);
i2++;
}
}
public void checkScroll(int i) {
setCurrentHeaderHeight(this.currentHeaderHeight - i);
}
private void openPreviewsChat(TLRPC.User user, long j) {
if (user == null || this.parentActivity == null) {
return;
}
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);
}
private boolean open(final MessageObject messageObject, TLRPC.WebPage webPage, String str, boolean z) {
final TLRPC.WebPage webPage2;
String str2;
int lastIndexOf;
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;
for (int i = 0; i < messageObject.messageOwner.entities.size(); i++) {
TLRPC.MessageEntity messageEntity = messageObject.messageOwner.entities.get(i);
if (messageEntity instanceof TLRPC.TL_messageEntityUrl) {
try {
String 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);
if (lastIndexOf2 == -1) {
break;
}
str2 = lowerCase.substring(lastIndexOf2 + 1);
break;
}
} catch (Exception e) {
FileLog.e(e);
}
}
}
str2 = null;
} else if (str != null && (lastIndexOf = str.lastIndexOf(35)) != -1) {
str2 = str.substring(lastIndexOf + 1);
} else {
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) {
final 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;
}
final int i2 = UserConfig.selectedAccount;
ConnectionsManager.getInstance(i2).sendRequest(tL_messages_getWebPage, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
ArticleViewer.this.lambda$open$23$ArticleViewer(webPage2, messageObject, str4, i2, tLObject, tL_error);
}
});
}
this.lastInsets = null;
if (this.isVisible) {
WindowManager windowManager = (WindowManager) this.parentActivity.getSystemService("window");
if (this.attachedToWindow) {
try {
windowManager.removeView(this.windowView);
} catch (Exception unused) {
}
}
try {
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);
} catch (Exception e2) {
FileLog.e(e2);
return false;
}
} 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);
final AnimatorSet animatorSet = new AnimatorSet();
animatorSet.playTogether(ObjectAnimator.ofFloat(this.windowView, (Property<WindowView, Float>) View.ALPHA, 0.0f, 1.0f), ObjectAnimator.ofFloat(this.containerView, (Property<FrameLayout, Float>) View.ALPHA, 0.0f, 1.0f), ObjectAnimator.ofFloat(this.windowView, (Property<WindowView, Float>) View.TRANSLATION_X, AndroidUtilities.dp(56.0f), 0.0f));
this.animationEndRunnable = new Runnable() {
@Override
public final void run() {
ArticleViewer.this.lambda$open$24$ArticleViewer();
}
};
animatorSet.setDuration(150L);
animatorSet.setInterpolator(this.interpolator);
animatorSet.addListener(new AnonymousClass13());
this.transitionAnimationStartTime = System.currentTimeMillis();
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
ArticleViewer.this.lambda$open$25$ArticleViewer(animatorSet);
}
});
if (Build.VERSION.SDK_INT >= 18) {
this.containerView.setLayerType(2, null);
}
return true;
}
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);
final AnimatorSet animatorSet2 = new AnimatorSet();
animatorSet2.playTogether(ObjectAnimator.ofFloat(this.windowView, (Property<WindowView, Float>) View.ALPHA, 0.0f, 1.0f), ObjectAnimator.ofFloat(this.containerView, (Property<FrameLayout, Float>) View.ALPHA, 0.0f, 1.0f), ObjectAnimator.ofFloat(this.windowView, (Property<WindowView, Float>) View.TRANSLATION_X, AndroidUtilities.dp(56.0f), 0.0f));
this.animationEndRunnable = new Runnable() {
@Override
public final void run() {
ArticleViewer.this.lambda$open$24$ArticleViewer();
}
};
animatorSet2.setDuration(150L);
animatorSet2.setInterpolator(this.interpolator);
animatorSet2.addListener(new AnonymousClass13());
this.transitionAnimationStartTime = System.currentTimeMillis();
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
ArticleViewer.this.lambda$open$25$ArticleViewer(animatorSet2);
}
});
if (Build.VERSION.SDK_INT >= 18) {
}
return true;
}
public void lambda$open$23$ArticleViewer(final TLRPC.WebPage webPage, final MessageObject messageObject, final String str, int i, TLObject tLObject, TLRPC.TL_error tL_error) {
if (tLObject instanceof TLRPC.TL_webPage) {
final TLRPC.TL_webPage tL_webPage = (TLRPC.TL_webPage) tLObject;
if (tL_webPage.cached_page == null) {
return;
}
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
ArticleViewer.this.lambda$null$22$ArticleViewer(webPage, tL_webPage, messageObject, str);
}
});
LongSparseArray<TLRPC.WebPage> longSparseArray = new LongSparseArray<>(1);
longSparseArray.put(tL_webPage.id, tL_webPage);
MessagesStorage.getInstance(i).putWebPages(longSparseArray);
}
}
public 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) {
return;
}
if (messageObject != null) {
messageObject.messageOwner.media.webpage = tL_webPage;
}
this.pagesStack.set(0, tL_webPage);
if (this.pagesStack.size() == 1) {
this.currentPage = tL_webPage;
ApplicationLoader.applicationContext.getSharedPreferences("articles", 0).edit().remove("article" + this.currentPage.id).commit();
updateInterfaceForCurrentPage(0);
if (str != null) {
scrollToAnchor(str);
}
}
}
public void lambda$open$24$ArticleViewer() {
if (this.containerView == null || this.windowView == null) {
return;
}
if (Build.VERSION.SDK_INT >= 18) {
this.containerView.setLayerType(0, null);
}
this.animationInProgress = 0;
AndroidUtilities.hideKeyboard(this.parentActivity.getCurrentFocus());
}
public class AnonymousClass13 extends AnimatorListenerAdapter {
AnonymousClass13() {
}
@Override
public void onAnimationEnd(Animator animator) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
ArticleViewer.AnonymousClass13.this.lambda$onAnimationEnd$0$ArticleViewer$13();
}
});
}
public 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;
}
}
}
public 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, 100L);
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, (Property<ImageView, Float>) View.SCALE_X, 0.1f), ObjectAnimator.ofFloat(this.shareButton, (Property<ImageView, Float>) View.SCALE_Y, 0.1f), ObjectAnimator.ofFloat(this.shareButton, (Property<ImageView, Float>) View.ALPHA, 0.0f), ObjectAnimator.ofFloat(this.progressView, (Property<ContextProgressView, Float>) View.SCALE_X, 1.0f), ObjectAnimator.ofFloat(this.progressView, (Property<ContextProgressView, Float>) View.SCALE_Y, 1.0f), ObjectAnimator.ofFloat(this.progressView, (Property<ContextProgressView, Float>) View.ALPHA, 1.0f));
} else {
this.shareButton.setVisibility(0);
this.shareContainer.setEnabled(true);
this.progressViewAnimation.playTogether(ObjectAnimator.ofFloat(this.progressView, (Property<ContextProgressView, Float>) View.SCALE_X, 0.1f), ObjectAnimator.ofFloat(this.progressView, (Property<ContextProgressView, Float>) View.SCALE_Y, 0.1f), ObjectAnimator.ofFloat(this.progressView, (Property<ContextProgressView, Float>) View.ALPHA, 0.0f), ObjectAnimator.ofFloat(this.shareButton, (Property<ImageView, Float>) View.SCALE_X, 1.0f), ObjectAnimator.ofFloat(this.shareButton, (Property<ImageView, Float>) View.SCALE_Y, 1.0f), ObjectAnimator.ofFloat(this.shareButton, (Property<ImageView, Float>) View.ALPHA, 1.0f));
}
this.progressViewAnimation.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animator) {
if (ArticleViewer.this.progressViewAnimation == null || !ArticleViewer.this.progressViewAnimation.equals(animator)) {
return;
}
if (!z2) {
ArticleViewer.this.progressView.setVisibility(4);
} else {
ArticleViewer.this.shareButton.setVisibility(4);
}
}
@Override
public void onAnimationCancel(Animator animator) {
if (ArticleViewer.this.progressViewAnimation == null || !ArticleViewer.this.progressViewAnimation.equals(animator)) {
return;
}
ArticleViewer.this.progressViewAnimation = null;
}
});
this.progressViewAnimation.setDuration(150L);
this.progressViewAnimation.start();
}
public void collapse() {
if (this.parentActivity == null || !this.isVisible || checkAnimation()) {
return;
}
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, (Property<FrameLayout, Float>) View.TRANSLATION_X, this.containerView.getMeasuredWidth() - AndroidUtilities.dp(56.0f));
FrameLayout frameLayout = this.containerView;
Property property = View.TRANSLATION_Y;
float[] fArr = new float[1];
fArr[0] = ActionBar.getCurrentActionBarHeight() + (Build.VERSION.SDK_INT >= 21 ? AndroidUtilities.statusBarHeight : 0);
animatorArr[1] = ObjectAnimator.ofFloat(frameLayout, (Property<FrameLayout, Float>) property, fArr);
animatorArr[2] = ObjectAnimator.ofFloat(this.windowView, (Property<WindowView, Float>) View.ALPHA, 0.0f);
animatorArr[3] = ObjectAnimator.ofFloat(this.listView[0], (Property<RecyclerListView, Float>) View.ALPHA, 0.0f);
animatorArr[4] = ObjectAnimator.ofFloat(this.listView[0], (Property<RecyclerListView, Float>) View.TRANSLATION_Y, -AndroidUtilities.dp(56.0f));
animatorArr[5] = ObjectAnimator.ofFloat(this.headerView, (Property<FrameLayout, Float>) View.TRANSLATION_Y, 0.0f);
animatorArr[6] = ObjectAnimator.ofFloat(this.backButton, (Property<ImageView, Float>) View.SCALE_X, 1.0f);
animatorArr[7] = ObjectAnimator.ofFloat(this.backButton, (Property<ImageView, Float>) View.SCALE_Y, 1.0f);
animatorArr[8] = ObjectAnimator.ofFloat(this.backButton, (Property<ImageView, Float>) View.TRANSLATION_Y, 0.0f);
animatorArr[9] = ObjectAnimator.ofFloat(this.shareContainer, (Property<FrameLayout, Float>) View.SCALE_X, 1.0f);
animatorArr[10] = ObjectAnimator.ofFloat(this.shareContainer, (Property<FrameLayout, Float>) View.TRANSLATION_Y, 0.0f);
animatorArr[11] = ObjectAnimator.ofFloat(this.shareContainer, (Property<FrameLayout, Float>) View.SCALE_Y, 1.0f);
animatorSet.playTogether(animatorArr);
this.collapsed = true;
this.animationInProgress = 2;
this.animationEndRunnable = new Runnable() {
@Override
public final void run() {
ArticleViewer.this.lambda$collapse$26$ArticleViewer();
}
};
animatorSet.setInterpolator(new DecelerateInterpolator());
animatorSet.setDuration(250L);
animatorSet.addListener(new AnimatorListenerAdapter() {
@Override
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 void lambda$collapse$26$ArticleViewer() {
if (this.containerView == null) {
return;
}
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()) {
return;
}
AnimatorSet animatorSet = new AnimatorSet();
animatorSet.playTogether(ObjectAnimator.ofFloat(this.containerView, (Property<FrameLayout, Float>) View.TRANSLATION_X, 0.0f), ObjectAnimator.ofFloat(this.containerView, (Property<FrameLayout, Float>) View.TRANSLATION_Y, 0.0f), ObjectAnimator.ofFloat(this.windowView, (Property<WindowView, Float>) View.ALPHA, 1.0f), ObjectAnimator.ofFloat(this.listView[0], (Property<RecyclerListView, Float>) View.ALPHA, 1.0f), ObjectAnimator.ofFloat(this.listView[0], (Property<RecyclerListView, Float>) View.TRANSLATION_Y, 0.0f), ObjectAnimator.ofFloat(this.headerView, (Property<FrameLayout, Float>) View.TRANSLATION_Y, 0.0f), ObjectAnimator.ofFloat(this.backButton, (Property<ImageView, Float>) View.SCALE_X, 1.0f), ObjectAnimator.ofFloat(this.backButton, (Property<ImageView, Float>) View.SCALE_Y, 1.0f), ObjectAnimator.ofFloat(this.backButton, (Property<ImageView, Float>) View.TRANSLATION_Y, 0.0f), ObjectAnimator.ofFloat(this.shareContainer, (Property<FrameLayout, Float>) View.SCALE_X, 1.0f), ObjectAnimator.ofFloat(this.shareContainer, (Property<FrameLayout, Float>) View.TRANSLATION_Y, 0.0f), ObjectAnimator.ofFloat(this.shareContainer, (Property<FrameLayout, Float>) View.SCALE_Y, 1.0f));
this.collapsed = false;
this.animationInProgress = 2;
this.animationEndRunnable = new Runnable() {
@Override
public final void run() {
ArticleViewer.this.lambda$uncollapse$27$ArticleViewer();
}
};
animatorSet.setDuration(250L);
animatorSet.setInterpolator(new DecelerateInterpolator());
animatorSet.addListener(new AnimatorListenerAdapter() {
@Override
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 void lambda$uncollapse$27$ArticleViewer() {
if (this.containerView == null) {
return;
}
if (Build.VERSION.SDK_INT >= 18) {
this.containerView.setLayerType(0, null);
}
this.animationInProgress = 0;
}
public void saveCurrentPagePosition() {
if (this.currentPage == null) {
return;
}
int findFirstVisibleItemPosition = this.layoutManager[0].findFirstVisibleItemPosition();
if (findFirstVisibleItemPosition != -1) {
View findViewByPosition = this.layoutManager[0].findViewByPosition(findFirstVisibleItemPosition);
int top = findViewByPosition != null ? findViewByPosition.getTop() : 0;
SharedPreferences.Editor edit = ApplicationLoader.applicationContext.getSharedPreferences("articles", 0).edit();
String str = "article" + this.currentPage.id;
edit.putInt(str, findFirstVisibleItemPosition).putInt(str + "o", top).putBoolean(str + "r", AndroidUtilities.displaySize.x > AndroidUtilities.displaySize.y).commit();
}
}
public void close(boolean z, boolean z2) {
if (this.parentActivity == null || !this.isVisible || checkAnimation()) {
return;
}
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()) {
return;
}
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, (Property<WindowView, Float>) View.ALPHA, 0.0f), ObjectAnimator.ofFloat(this.containerView, (Property<FrameLayout, Float>) View.ALPHA, 0.0f), ObjectAnimator.ofFloat(this.windowView, (Property<WindowView, Float>) View.TRANSLATION_X, 0.0f, AndroidUtilities.dp(56.0f)));
this.animationInProgress = 2;
this.animationEndRunnable = new Runnable() {
@Override
public final void run() {
ArticleViewer.this.lambda$close$28$ArticleViewer();
}
};
animatorSet.setDuration(150L);
animatorSet.setInterpolator(this.interpolator);
animatorSet.addListener(new AnimatorListenerAdapter() {
@Override
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 void lambda$close$28$ArticleViewer() {
if (this.containerView == null) {
return;
}
if (Build.VERSION.SDK_INT >= 18) {
this.containerView.setLayerType(0, null);
}
this.animationInProgress = 0;
onClosed();
}
public 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() {
@Override
public final void run() {
ArticleViewer.this.lambda$onClosed$29$ArticleViewer();
}
});
}
public 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);
}
}
public void loadChannel(final BlockChannelCell blockChannelCell, final WebpageAdapter webpageAdapter, TLRPC.Chat chat) {
if (this.loadingChannel || TextUtils.isEmpty(chat.username)) {
return;
}
this.loadingChannel = true;
TLRPC.TL_contacts_resolveUsername tL_contacts_resolveUsername = new TLRPC.TL_contacts_resolveUsername();
tL_contacts_resolveUsername.username = chat.username;
final int i = UserConfig.selectedAccount;
ConnectionsManager.getInstance(i).sendRequest(tL_contacts_resolveUsername, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
ArticleViewer.this.lambda$loadChannel$31$ArticleViewer(webpageAdapter, i, blockChannelCell, tLObject, tL_error);
}
});
}
public void lambda$loadChannel$31$ArticleViewer(final WebpageAdapter webpageAdapter, final int i, final BlockChannelCell blockChannelCell, final TLObject tLObject, final TLRPC.TL_error tL_error) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
ArticleViewer.this.lambda$null$30$ArticleViewer(webpageAdapter, tL_error, tLObject, i, blockChannelCell);
}
});
}
public 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()) {
return;
}
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(0, false);
return;
} else {
blockChannelCell.setState(4, false);
return;
}
}
blockChannelCell.setState(4, false);
return;
}
blockChannelCell.setState(4, false);
}
public void joinChannel(final BlockChannelCell blockChannelCell, final TLRPC.Chat chat) {
final TLRPC.TL_channels_joinChannel tL_channels_joinChannel = new TLRPC.TL_channels_joinChannel();
tL_channels_joinChannel.channel = MessagesController.getInputChannel(chat);
final int i = UserConfig.selectedAccount;
ConnectionsManager.getInstance(i).sendRequest(tL_channels_joinChannel, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
ArticleViewer.this.lambda$joinChannel$35$ArticleViewer(blockChannelCell, i, tL_channels_joinChannel, chat, tLObject, tL_error);
}
});
}
public void lambda$joinChannel$35$ArticleViewer(final BlockChannelCell blockChannelCell, final int i, final TLRPC.TL_channels_joinChannel tL_channels_joinChannel, final TLRPC.Chat chat, TLObject tLObject, final TLRPC.TL_error tL_error) {
boolean z;
if (tL_error != null) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
ArticleViewer.this.lambda$null$32$ArticleViewer(blockChannelCell, i, tL_error, tL_channels_joinChannel);
}
});
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() {
@Override
public final void run() {
ArticleViewer.BlockChannelCell.this.setState(2, false);
}
});
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.getInstance(i).loadFullChat(chat.id, 0, true);
}
}, 1000L);
MessagesStorage.getInstance(i).updateDialogsWithDeletedMessages(new ArrayList<>(), null, true, chat.id);
}
public 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;
}
return this.animationInProgress != 0;
}
public void destroyArticleViewer() {
if (this.parentActivity == null || this.windowView == null) {
return;
}
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) {
return;
}
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() {
@Override
public final void onDismiss(DialogInterface dialogInterface) {
ArticleViewer.this.lambda$showDialog$36$ArticleViewer(dialogInterface);
}
});
dialog.show();
} catch (Exception e2) {
FileLog.e(e2);
}
}
public void lambda$showDialog$36$ArticleViewer(DialogInterface dialogInterface) {
this.visibleDialog = null;
}
public class WebpageAdapter extends RecyclerListView.SelectionAdapter {
private Context context;
private ArrayList<TLRPC.PageBlock> localBlocks = new ArrayList<>();
private ArrayList<TLRPC.PageBlock> blocks = new ArrayList<>();
private ArrayList<TLRPC.PageBlock> photoBlocks = new ArrayList<>();
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<>();
public WebpageAdapter(Context context) {
this.context = context;
}
private void setRichTextParents(TLRPC.RichText richText, TLRPC.RichText richText2) {
if (richText2 == null) {
return;
}
richText2.parentRichText = richText;
if (richText2 instanceof TLRPC.TL_textFixed) {
setRichTextParents(richText2, ((TLRPC.TL_textFixed) richText2).text);
return;
}
if (richText2 instanceof TLRPC.TL_textItalic) {
setRichTextParents(richText2, ((TLRPC.TL_textItalic) richText2).text);
return;
}
if (richText2 instanceof TLRPC.TL_textBold) {
setRichTextParents(richText2, ((TLRPC.TL_textBold) richText2).text);
return;
}
if (richText2 instanceof TLRPC.TL_textUnderline) {
setRichTextParents(richText2, ((TLRPC.TL_textUnderline) richText2).text);
return;
}
if (richText2 instanceof TLRPC.TL_textStrike) {
setRichTextParents(richText2, ((TLRPC.TL_textStrike) richText2).text);
return;
}
if (richText2 instanceof TLRPC.TL_textEmail) {
setRichTextParents(richText2, ((TLRPC.TL_textEmail) richText2).text);
return;
}
if (richText2 instanceof TLRPC.TL_textPhone) {
setRichTextParents(richText2, ((TLRPC.TL_textPhone) richText2).text);
return;
}
if (richText2 instanceof TLRPC.TL_textUrl) {
setRichTextParents(richText2, ((TLRPC.TL_textUrl) richText2).text);
return;
}
if (richText2 instanceof TLRPC.TL_textConcat) {
int size = richText2.texts.size();
for (int i = 0; i < size; i++) {
setRichTextParents(richText2, richText2.texts.get(i));
}
return;
}
if (richText2 instanceof TLRPC.TL_textSubscript) {
setRichTextParents(richText2, ((TLRPC.TL_textSubscript) richText2).text);
return;
}
if (richText2 instanceof TLRPC.TL_textSuperscript) {
setRichTextParents(richText2, ((TLRPC.TL_textSuperscript) richText2).text);
return;
}
if (richText2 instanceof TLRPC.TL_textMarked) {
setRichTextParents(richText2, ((TLRPC.TL_textMarked) richText2).text);
return;
}
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);
return;
}
if (pageBlock instanceof TLRPC.TL_pageBlockParagraph) {
setRichTextParents(null, ((TLRPC.TL_pageBlockParagraph) pageBlock).text);
return;
}
if (pageBlock instanceof TLRPC.TL_pageBlockKicker) {
setRichTextParents(null, ((TLRPC.TL_pageBlockKicker) pageBlock).text);
return;
}
if (pageBlock instanceof TLRPC.TL_pageBlockFooter) {
setRichTextParents(null, ((TLRPC.TL_pageBlockFooter) pageBlock).text);
return;
}
if (pageBlock instanceof TLRPC.TL_pageBlockHeader) {
setRichTextParents(null, ((TLRPC.TL_pageBlockHeader) pageBlock).text);
return;
}
if (pageBlock instanceof TLRPC.TL_pageBlockPreformatted) {
setRichTextParents(null, ((TLRPC.TL_pageBlockPreformatted) pageBlock).text);
return;
}
if (pageBlock instanceof TLRPC.TL_pageBlockSubheader) {
setRichTextParents(null, ((TLRPC.TL_pageBlockSubheader) pageBlock).text);
return;
}
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++;
}
return;
}
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);
return;
}
if (pageBlock instanceof TL_pageBlockListItem) {
TL_pageBlockListItem tL_pageBlockListItem = (TL_pageBlockListItem) pageBlock;
if (tL_pageBlockListItem.textItem != null) {
setRichTextParents(null, tL_pageBlockListItem.textItem);
return;
} else {
if (tL_pageBlockListItem.blockItem != null) {
setRichTextParents(tL_pageBlockListItem.blockItem);
return;
}
return;
}
}
if (pageBlock instanceof TL_pageBlockOrderedListItem) {
TL_pageBlockOrderedListItem tL_pageBlockOrderedListItem = (TL_pageBlockOrderedListItem) pageBlock;
if (tL_pageBlockOrderedListItem.textItem != null) {
setRichTextParents(null, tL_pageBlockOrderedListItem.textItem);
return;
} else {
if (tL_pageBlockOrderedListItem.blockItem != null) {
setRichTextParents(tL_pageBlockOrderedListItem.blockItem);
return;
}
return;
}
}
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++;
}
return;
}
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);
return;
}
if (pageBlock instanceof TLRPC.TL_pageBlockSubtitle) {
setRichTextParents(null, ((TLRPC.TL_pageBlockSubtitle) pageBlock).text);
return;
}
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);
return;
}
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++;
}
return;
}
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);
return;
}
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);
return;
}
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);
return;
}
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);
}
}
return;
}
if (pageBlock instanceof TLRPC.TL_pageBlockTitle) {
setRichTextParents(null, ((TLRPC.TL_pageBlockTitle) pageBlock).text);
return;
}
if (pageBlock instanceof TLRPC.TL_pageBlockCover) {
setRichTextParents(((TLRPC.TL_pageBlockCover) pageBlock).cover);
return;
}
if (pageBlock instanceof TLRPC.TL_pageBlockAuthorDate) {
setRichTextParents(null, ((TLRPC.TL_pageBlockAuthorDate) pageBlock).author);
return;
}
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);
}
}
public void addBlock(TLRPC.PageBlock pageBlock, int i, int i2, int i3) {
TLRPC.TL_pageBlockOrderedList tL_pageBlockOrderedList;
int i4;
String str;
TLRPC.PageListOrderedItem pageListOrderedItem;
TLRPC.PageListOrderedItem pageListOrderedItem2;
String str2;
boolean z;
TLRPC.PageListItem pageListItem;
TLRPC.TL_pageBlockList tL_pageBlockList;
String str3;
int i5;
TLRPC.TL_pageListItemBlocks tL_pageListItemBlocks;
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) {
return;
}
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 anonymousClass1 = null;
if (lastNonListPageBlock instanceof TLRPC.TL_pageBlockEmbedPost) {
TLRPC.TL_pageBlockEmbedPost tL_pageBlockEmbedPost = (TLRPC.TL_pageBlockEmbedPost) lastNonListPageBlock;
if (tL_pageBlockEmbedPost.blocks.isEmpty()) {
return;
}
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))) {
return;
}
TL_pageBlockEmbedPostCaption tL_pageBlockEmbedPostCaption = new TL_pageBlockEmbedPostCaption();
tL_pageBlockEmbedPostCaption.parent = tL_pageBlockEmbedPost;
tL_pageBlockEmbedPostCaption.caption = tL_pageBlockEmbedPost.caption;
this.blocks.add(tL_pageBlockEmbedPostCaption);
return;
}
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);
return;
}
return;
}
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++;
}
return;
}
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 pageListItem2 = tL_pageBlockList2.items.get(i8);
int i9 = size3;
TL_pageBlockListItem tL_pageBlockListItem = new TL_pageBlockListItem();
tL_pageBlockListItem.index = i8;
tL_pageBlockListItem.parent = tL_pageBlockListParent;
if (tL_pageBlockList2.ordered) {
if (ArticleViewer.this.isRtl) {
tL_pageBlockListItem.num = String.format(".%d", Integer.valueOf(i8 + 1));
} else {
tL_pageBlockListItem.num = String.format("%d.", Integer.valueOf(i8 + 1));
}
} else {
tL_pageBlockListItem.num = "•";
}
tL_pageBlockListParent.items.add(tL_pageBlockListItem);
if (pageListItem2 instanceof TLRPC.TL_pageListItemText) {
tL_pageBlockListItem.textItem = ((TLRPC.TL_pageListItemText) pageListItem2).text;
pageListItem = pageListItem2;
} else {
boolean z4 = pageListItem2 instanceof TLRPC.TL_pageListItemBlocks;
pageListItem = pageListItem2;
if (z4) {
TLRPC.TL_pageListItemBlocks tL_pageListItemBlocks2 = (TLRPC.TL_pageListItemBlocks) pageListItem2;
if (!tL_pageListItemBlocks2.blocks.isEmpty()) {
tL_pageBlockListItem.blockItem = tL_pageListItemBlocks2.blocks.get(0);
pageListItem = pageListItem2;
} else {
TLRPC.TL_pageListItemText tL_pageListItemText = new TLRPC.TL_pageListItemText();
TLRPC.TL_textPlain tL_textPlain = new TLRPC.TL_textPlain();
tL_textPlain.text = str4;
tL_pageListItemText.text = tL_textPlain;
pageListItem = tL_pageListItemText;
}
}
}
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 (pageListItem instanceof TLRPC.TL_pageListItemBlocks) {
TLRPC.TL_pageListItemBlocks tL_pageListItemBlocks3 = (TLRPC.TL_pageListItemBlocks) pageListItem;
int size4 = tL_pageListItemBlocks3.blocks.size();
int i10 = 1;
while (i10 < size4) {
TL_pageBlockListItem tL_pageBlockListItem3 = new TL_pageBlockListItem();
tL_pageBlockListItem3.blockItem = tL_pageListItemBlocks3.blocks.get(i10);
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);
i10++;
size4 = i5;
tL_pageListItemBlocks3 = tL_pageListItemBlocks;
}
}
i8++;
size3 = i9;
tL_pageBlockList2 = tL_pageBlockList;
str4 = str3;
anonymousClass1 = null;
}
return;
}
String str6 = " ";
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 i11 = 0;
while (i11 < size5) {
TLRPC.PageListOrderedItem pageListOrderedItem3 = tL_pageBlockOrderedList2.items.get(i11);
TL_pageBlockOrderedListItem tL_pageBlockOrderedListItem = new TL_pageBlockOrderedListItem();
tL_pageBlockOrderedListItem.index = i11;
tL_pageBlockOrderedListItem.parent = tL_pageBlockOrderedListParent;
tL_pageBlockOrderedListParent.items.add(tL_pageBlockOrderedListItem);
if (pageListOrderedItem3 instanceof TLRPC.TL_pageListOrderedItemText) {
TLRPC.TL_pageListOrderedItemText tL_pageListOrderedItemText = (TLRPC.TL_pageListOrderedItemText) pageListOrderedItem3;
tL_pageBlockOrderedList = tL_pageBlockOrderedList2;
tL_pageBlockOrderedListItem.textItem = tL_pageListOrderedItemText.text;
if (TextUtils.isEmpty(tL_pageListOrderedItemText.num)) {
if (ArticleViewer.this.isRtl) {
tL_pageBlockOrderedListItem.num = String.format(str5, Integer.valueOf(i11 + 1));
} else {
tL_pageBlockOrderedListItem.num = String.format("%d.", Integer.valueOf(i11 + 1));
}
} else if (ArticleViewer.this.isRtl) {
tL_pageBlockOrderedListItem.num = "." + tL_pageListOrderedItemText.num;
} else {
tL_pageBlockOrderedListItem.num = tL_pageListOrderedItemText.num + ".";
}
} else {
tL_pageBlockOrderedList = tL_pageBlockOrderedList2;
if (pageListOrderedItem3 instanceof TLRPC.TL_pageListOrderedItemBlocks) {
TLRPC.TL_pageListOrderedItemBlocks tL_pageListOrderedItemBlocks = (TLRPC.TL_pageListOrderedItemBlocks) pageListOrderedItem3;
if (!tL_pageListOrderedItemBlocks.blocks.isEmpty()) {
i4 = size5;
tL_pageBlockOrderedListItem.blockItem = tL_pageListOrderedItemBlocks.blocks.get(0);
str = str6;
pageListOrderedItem = pageListOrderedItem3;
} else {
i4 = size5;
TLRPC.TL_pageListOrderedItemText tL_pageListOrderedItemText2 = new TLRPC.TL_pageListOrderedItemText();
TLRPC.TL_textPlain tL_textPlain2 = new TLRPC.TL_textPlain();
str = str6;
tL_textPlain2.text = str;
tL_pageListOrderedItemText2.text = tL_textPlain2;
pageListOrderedItem = tL_pageListOrderedItemText2;
}
if (TextUtils.isEmpty(tL_pageListOrderedItemBlocks.num)) {
if (ArticleViewer.this.isRtl) {
tL_pageBlockOrderedListItem.num = String.format(str5, Integer.valueOf(i11 + 1));
pageListOrderedItem2 = pageListOrderedItem;
} else {
tL_pageBlockOrderedListItem.num = String.format("%d.", Integer.valueOf(i11 + 1));
pageListOrderedItem2 = pageListOrderedItem;
}
} else if (ArticleViewer.this.isRtl) {
tL_pageBlockOrderedListItem.num = "." + tL_pageListOrderedItemBlocks.num;
pageListOrderedItem2 = pageListOrderedItem;
} else {
tL_pageBlockOrderedListItem.num = tL_pageListOrderedItemBlocks.num + ".";
pageListOrderedItem2 = pageListOrderedItem;
}
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 (i11 == 0) {
tL_pageBlockOrderedListItem2 = ArticleViewer.this.fixListBlock(pageBlock2, tL_pageBlockOrderedListItem);
}
addBlock(tL_pageBlockOrderedListItem2, i, i2 + 1, i3);
}
if (!(pageListOrderedItem2 instanceof TLRPC.TL_pageListOrderedItemBlocks)) {
TLRPC.TL_pageListOrderedItemBlocks tL_pageListOrderedItemBlocks2 = (TLRPC.TL_pageListOrderedItemBlocks) pageListOrderedItem2;
int size6 = tL_pageListOrderedItemBlocks2.blocks.size();
int i12 = 1;
while (i12 < size6) {
TL_pageBlockOrderedListItem tL_pageBlockOrderedListItem3 = new TL_pageBlockOrderedListItem();
tL_pageBlockOrderedListItem3.blockItem = tL_pageListOrderedItemBlocks2.blocks.get(i12);
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);
i12++;
pageBlock2 = pageBlock;
z2 = z;
}
}
i11++;
pageBlock2 = pageBlock;
tL_pageBlockOrderedList2 = tL_pageBlockOrderedList;
z2 = z2;
size5 = i4;
str5 = str2;
str6 = str;
}
}
i4 = size5;
str = str6;
pageListOrderedItem2 = pageListOrderedItem3;
if (!z2) {
}
if (!(pageListOrderedItem2 instanceof TLRPC.TL_pageListOrderedItemBlocks)) {
}
i11++;
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);
return;
}
return;
}
if ((pageBlock instanceof TLRPC.TL_pageBlockVideo) && ArticleViewer.this.isVideoBlock(pageBlock)) {
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);
return;
}
return;
}
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);
return;
}
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);
return;
}
if (pageBlock instanceof TLRPC.TL_pageBlockCover) {
addAllMediaFromBlock(((TLRPC.TL_pageBlockCover) pageBlock).cover);
}
}
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
FrameLayout frameLayout;
View view;
if (i != 90) {
switch (i) {
case 0:
view = new BlockParagraphCell(this.context, this);
break;
case 1:
view = new BlockHeaderCell(this.context, this);
break;
case 2:
view = new BlockDividerCell(this.context);
break;
case 3:
view = new BlockEmbedCell(this.context, this);
break;
case 4:
view = new BlockSubtitleCell(this.context, this);
break;
case 5:
frameLayout = new BlockVideoCell(this.context, this, 0);
break;
case 6:
view = new BlockPullquoteCell(this.context, this);
break;
case 7:
view = new BlockBlockquoteCell(this.context, this);
break;
case 8:
view = new BlockSlideshowCell(this.context, this);
break;
case 9:
frameLayout = new BlockPhotoCell(this.context, this, 0);
break;
case 10:
view = new BlockAuthorDateCell(this.context, this);
break;
case 11:
view = new BlockTitleCell(this.context, this);
break;
case 12:
view = new BlockListItemCell(this.context, this);
break;
case 13:
view = new BlockFooterCell(this.context, this);
break;
case 14:
view = new BlockPreformattedCell(this.context, this);
break;
case 15:
view = new BlockSubheaderCell(this.context, this);
break;
case 16:
view = new BlockEmbedPostCell(this.context, this);
break;
case 17:
view = new BlockCollageCell(this.context, this);
break;
case 18:
frameLayout = new BlockChannelCell(this.context, this, 0);
break;
case 19:
view = new BlockAudioCell(this.context, this);
break;
case 20:
view = new BlockKickerCell(this.context, this);
break;
case 21:
view = new BlockOrderedListItemCell(this.context, this);
break;
case 22:
frameLayout = new BlockMapCell(this.context, this, 0);
break;
case 23:
view = new BlockRelatedArticlesCell(this.context, this);
break;
case 24:
view = new BlockDetailsCell(this.context, this);
break;
case 25:
view = new BlockTableCell(this.context, this);
break;
case 26:
view = new BlockRelatedArticlesHeaderCell(this.context, this);
break;
case 27:
view = new BlockDetailsBottomCell(this.context);
break;
case 28:
view = new BlockRelatedArticlesShadowCell(this.context);
break;
default:
TextView textView = new TextView(this.context);
textView.setBackgroundColor(SupportMenu.CATEGORY_MASK);
textView.setTextColor(-16777216);
textView.setTextSize(1, 20.0f);
view = textView;
break;
}
view.setLayoutParams(new RecyclerView.LayoutParams(-1, -2));
view.setFocusable(true);
return new RecyclerListView.Holder(view);
}
frameLayout = new FrameLayout(this.context) {
@Override
protected void onMeasure(int i2, int i3) {
super.onMeasure(i2, View.MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(44.0f), 1073741824));
}
};
frameLayout.setTag(90);
TextView textView2 = new TextView(this.context);
frameLayout.addView(textView2, LayoutHelper.createFrame(-1.0f, 34.0f, 51, 0.0f, 10.0f, 0.0f, 0.0f));
textView2.setText(LocaleController.getString("PreviewFeedback", R.string.PreviewFeedback));
textView2.setTextSize(1, 12.0f);
textView2.setGravity(17);
view = frameLayout;
view.setLayoutParams(new RecyclerView.LayoutParams(-1, -2));
view.setFocusable(true);
return new RecyclerListView.Holder(view);
}
@Override
public boolean isEnabled(RecyclerView.ViewHolder viewHolder) {
int itemViewType = viewHolder.getItemViewType();
return itemViewType == 23 || itemViewType == 24;
}
@Override
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());
return;
}
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);
}
}
}
public 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 {
pageBlock2 = pageBlock instanceof TL_pageBlockDetailsChild ? ((TL_pageBlockDetailsChild) pageBlock).block : pageBlock;
}
if (i != 100) {
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:
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;
blockVideoCell.setBlock((TLRPC.TL_pageBlockVideo) pageBlock2, i2 == 0, i2 == i3 - 1);
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;
blockPhotoCell.setBlock((TLRPC.TL_pageBlockPhoto) pageBlock2, i2 == 0, i2 == i3 - 1);
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) viewHolder.itemView).setBlock((TLRPC.TL_pageBlockAudio) pageBlock2, i2 == 0, i2 == i3 - 1);
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) viewHolder.itemView).setBlock((TLRPC.TL_pageBlockMap) pageBlock2, i2 == 0, i2 == i3 - 1);
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:
return;
default:
return;
}
}
((TextView) viewHolder.itemView).setText("unsupported block " + pageBlock2);
}
public 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
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
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;
}
public 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);
}
}
}
public 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
public void notifyDataSetChanged() {
updateRows();
super.notifyDataSetChanged();
}
@Override
public void notifyItemChanged(int i) {
updateRows();
super.notifyItemChanged(i);
}
@Override
public void notifyItemChanged(int i, Object obj) {
updateRows();
super.notifyItemChanged(i, obj);
}
@Override
public void notifyItemRangeChanged(int i, int i2) {
updateRows();
super.notifyItemRangeChanged(i, i2);
}
@Override
public void notifyItemRangeChanged(int i, int i2, Object obj) {
updateRows();
super.notifyItemRangeChanged(i, i2, obj);
}
@Override
public void notifyItemInserted(int i) {
updateRows();
super.notifyItemInserted(i);
}
@Override
public void notifyItemMoved(int i, int i2) {
updateRows();
super.notifyItemMoved(i, i2);
}
@Override
public void notifyItemRangeInserted(int i, int i2) {
updateRows();
super.notifyItemRangeInserted(i, i2);
}
@Override
public void notifyItemRemoved(int i) {
updateRows();
super.notifyItemRemoved(i);
}
@Override
public void notifyItemRangeRemoved(int i, int i2) {
updateRows();
super.notifyItemRangeRemoved(i, i2);
}
}
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
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)) {
return;
}
this.channelCell.setBlock(ArticleViewer.this.channelBlock);
this.channelCell.setVisibility(0);
}
public View getChannelCell() {
return this.channelCell;
}
@Override
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() + AndroidUtilities.dp(39.0f)) {
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;
}
if (motionEvent.getAction() == 0 && this.imageView.isInsideImage(x, y)) {
if (this.buttonState != -1) {
if (x >= this.buttonX && x <= r2 + AndroidUtilities.dp(48.0f)) {
if (y >= this.buttonY) {
}
}
}
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;
}
return 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);
}
@Override
protected void onMeasure(int i, int i2) {
int i3;
int i4;
TLRPC.TL_pageBlockVideo tL_pageBlockVideo;
int i5;
int dp;
int i6;
int i7;
int i8;
int i9;
int i10;
boolean z;
int size = View.MeasureSpec.getSize(i);
int i11 = this.currentType;
boolean z2 = false;
if (i11 == 1) {
size = ((View) getParent()).getMeasuredWidth();
i4 = ((View) getParent()).getMeasuredHeight();
} else if (i11 == 2) {
i4 = (int) Math.ceil(this.groupPosition.ph * 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) {
i7 = AndroidUtilities.dp(this.currentBlock.level * 14) + AndroidUtilities.dp(18.0f);
this.textX = i7;
i6 = i3 - (AndroidUtilities.dp(18.0f) + i7);
dp = i6;
} else {
this.textX = AndroidUtilities.dp(18.0f);
dp = i3 - AndroidUtilities.dp(36.0f);
i6 = i3;
i7 = 0;
}
if (this.currentDocument != null) {
int dp2 = AndroidUtilities.dp(48.0f);
TLRPC.PhotoSize closestPhotoSizeWithSize = FileLoader.getClosestPhotoSizeWithSize(this.currentDocument.thumbs, 48);
int i12 = this.currentType;
if (i12 == 0) {
int size2 = this.currentDocument.attributes.size();
int i13 = 0;
while (true) {
if (i13 >= size2) {
z = false;
break;
}
if (this.currentDocument.attributes.get(i13) instanceof TLRPC.TL_documentAttributeVideo) {
i4 = (int) ((i6 / r15.w) * r15.h);
z = true;
break;
}
i13++;
}
float f = closestPhotoSizeWithSize != null ? closestPhotoSizeWithSize.w : 100.0f;
float f2 = closestPhotoSizeWithSize != null ? closestPhotoSizeWithSize.h : 100.0f;
if (!z) {
i4 = (int) ((i6 / f) * f2);
}
if (!(this.parentBlock instanceof TLRPC.TL_pageBlockCover)) {
int max = (int) ((Math.max(ArticleViewer.this.listView[0].getMeasuredWidth(), ArticleViewer.this.listView[0].getMeasuredHeight()) - AndroidUtilities.dp(56.0f)) * 0.9f);
if (i4 > max) {
int i14 = (int) ((max / f2) * f);
i7 += ((i3 - i7) - i14) / 2;
i6 = i14;
i4 = max;
}
} else {
i4 = Math.min(i4, i6);
}
if (i4 == 0) {
i4 = AndroidUtilities.dp(100.0f);
} else if (i4 < dp2) {
i4 = dp2;
}
} else if (i12 == 2) {
if ((this.groupPosition.flags & 2) == 0) {
i6 -= AndroidUtilities.dp(2.0f);
}
if ((this.groupPosition.flags & 8) == 0) {
int i15 = i6;
i8 = i4;
i4 -= AndroidUtilities.dp(2.0f);
i9 = i15;
this.imageView.setQualityThumbDocument(this.currentDocument);
this.imageView.setImageCoords(i7, (!this.isFirst || (i10 = this.currentType) == 1 || i10 == 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) (this.imageView.getImageX() + ((this.imageView.getImageWidth() - dp2) / 2.0f));
int imageY = (int) (this.imageView.getImageY() + ((this.imageView.getImageHeight() - dp2) / 2.0f));
this.buttonY = imageY;
RadialProgress2 radialProgress2 = this.radialProgress;
int i16 = this.buttonX;
radialProgress2.setProgressRect(i16, imageY, i16 + dp2, dp2 + imageY);
i5 = i8;
}
}
i9 = i6;
i8 = i4;
this.imageView.setQualityThumbDocument(this.currentDocument);
this.imageView.setImageCoords(i7, (!this.isFirst || (i10 = this.currentType) == 1 || i10 == 2 || this.currentBlock.level > 0) ? 0 : AndroidUtilities.dp(8.0f), i9, i4);
if (!this.isGif) {
}
this.imageView.setAspectFit(true);
this.buttonX = (int) (this.imageView.getImageX() + ((this.imageView.getImageWidth() - dp2) / 2.0f));
int imageY2 = (int) (this.imageView.getImageY() + ((this.imageView.getImageHeight() - dp2) / 2.0f));
this.buttonY = imageY2;
RadialProgress2 radialProgress22 = this.radialProgress;
int i162 = this.buttonX;
radialProgress22.setProgressRect(i162, imageY2, i162 + dp2, dp2 + imageY2);
i5 = i8;
} else {
i5 = i4;
}
if (this.currentType == 0) {
DrawingText createLayoutForText = ArticleViewer.this.createLayoutForText(this, null, this.currentBlock.caption.text, dp, this.currentBlock, this.parentAdapter);
this.captionLayout = createLayoutForText;
if (createLayoutForText != null) {
int dp3 = AndroidUtilities.dp(4.0f) + this.captionLayout.getHeight();
this.creditOffset = dp3;
i5 += dp3 + AndroidUtilities.dp(4.0f);
}
DrawingText createLayoutForText2 = ArticleViewer.this.createLayoutForText(this, (CharSequence) null, this.currentBlock.caption.credit, dp, this.currentBlock, ArticleViewer.this.isRtl ? StaticLayoutEx.ALIGN_RIGHT() : Layout.Alignment.ALIGN_NORMAL, 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(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(this.imageView.getImageHeight() - AndroidUtilities.dp(39.0f));
setMeasuredDimension(i3, i5);
}
@Override
protected void onDraw(Canvas canvas) {
if (this.currentBlock == null) {
return;
}
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(this.textX, this.textY);
this.captionLayout.draw(canvas);
canvas.restore();
}
if (this.creditLayout != null) {
canvas.save();
canvas.translate(this.textX, this.textY + this.creditOffset);
this.creditLayout.draw(canvas);
canvas.restore();
}
if (this.currentBlock.level > 0) {
canvas.drawRect(AndroidUtilities.dp(18.0f), 0.0f, AndroidUtilities.dp(20.0f), 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);
return;
}
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();
return;
}
DownloadController.getInstance(ArticleViewer.this.currentAccount).addLoadingFileObserver(attachFileName, null, this);
float f = 0.0f;
if (!FileLoader.getInstance(ArticleViewer.this.currentAccount).isLoadingFile(attachFileName)) {
if (!this.cancelLoading && this.autoDownload && this.isGif) {
this.buttonState = 1;
} else {
this.buttonState = 0;
z2 = false;
}
} else {
this.buttonState = 1;
Float fileProgress = ImageLoader.getInstance().getFileProgress(attachFileName);
if (fileProgress != null) {
f = fileProgress.floatValue();
}
}
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) {
FileLoader.getInstance(ArticleViewer.this.currentAccount).loadFile(this.currentDocument, ArticleViewer.this.currentPage, 1, 1);
} else {
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);
}
this.buttonState = 1;
this.radialProgress.setIcon(getIconForCurrentState(), true, z);
invalidate();
return;
}
if (i == 1) {
this.cancelLoading = true;
if (!this.isGif) {
FileLoader.getInstance(ArticleViewer.this.currentAccount).cancelLoadFile(this.currentDocument);
} else {
this.imageView.cancelLoadImage();
}
this.buttonState = 0;
this.radialProgress.setIcon(getIconForCurrentState(), false, z);
invalidate();
return;
}
if (i != 2) {
if (i == 3) {
ArticleViewer.this.openPhoto(this.currentBlock);
}
} else {
this.imageView.setAllowStartAnimation(true);
this.imageView.startAnimation();
this.buttonState = -1;
this.radialProgress.setIcon(getIconForCurrentState(), false, z);
}
}
@Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
this.imageView.onDetachedFromWindow();
DownloadController.getInstance(ArticleViewer.this.currentAccount).removeLoadingFileObserver(this);
}
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
this.imageView.onAttachedToWindow();
updateButtonState(false);
}
@Override
public void onFailedDownload(String str, boolean z) {
updateButtonState(false);
}
@Override
public void onSuccessDownload(String str) {
this.radialProgress.setProgress(1.0f, true);
if (this.isGif) {
this.buttonState = 2;
didPressedButton(true);
} else {
updateButtonState(true);
}
}
@Override
public void onProgressDownload(String str, float f) {
this.radialProgress.setProgress(f, true);
if (this.buttonState != 1) {
updateButtonState(true);
}
}
@Override
public int getObserverTag() {
return this.TAG;
}
@Override
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());
}
}
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;
private StaticLayout titleLayout;
@Override
public void onProgressUpload(String str, float f, boolean z) {
}
public BlockAudioCell(Context context, WebpageAdapter webpageAdapter) {
super(context);
this.textY = AndroidUtilities.dp(54.0f);
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 seekBar = new SeekBar(context);
this.seekBar = seekBar;
seekBar.setDelegate(new SeekBar.SeekBarDelegate() {
@Override
public void onSeekBarContinuousDrag(float f) {
SeekBar.SeekBarDelegate.CC.$default$onSeekBarContinuousDrag(this, f);
}
@Override
public final void onSeekBarDrag(float f) {
ArticleViewer.BlockAudioCell.this.lambda$new$0$ArticleViewer$BlockAudioCell(f);
}
});
}
public void lambda$new$0$ArticleViewer$BlockAudioCell(float f) {
MessageObject messageObject = this.currentMessageObject;
if (messageObject == null) {
return;
}
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;
}
@Override
public boolean onTouchEvent(MotionEvent motionEvent) {
float x = motionEvent.getX();
float y = motionEvent.getY();
if (this.seekBar.onTouch(motionEvent.getAction(), motionEvent.getX() - this.seekBarX, motionEvent.getY() - this.seekBarY)) {
if (motionEvent.getAction() == 0) {
getParent().requestDisallowInterceptTouchEvent(true);
}
invalidate();
return true;
}
if (motionEvent.getAction() == 0) {
if (this.buttonState != -1) {
if (x >= this.buttonX && x <= r2 + AndroidUtilities.dp(48.0f)) {
if (y >= this.buttonY) {
}
}
}
} 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;
}
return 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);
}
@Override
protected 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(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(this, (CharSequence) null, this.currentBlock.caption.credit, dp2, this.currentBlock, ArticleViewer.this.isRtl ? StaticLayoutEx.ALIGN_RIGHT() : Layout.Alignment.ALIGN_NORMAL, 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, 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();
}
@Override
protected void onDraw(Canvas canvas) {
if (this.currentBlock == null) {
return;
}
this.radialProgress.setColors(ArticleViewer.this.getTextColor(), ArticleViewer.this.getTextColor(), ArticleViewer.this.getTextColor(), ArticleViewer.this.getTextColor());
this.radialProgress.draw(canvas);
canvas.save();
canvas.translate(this.seekBarX, this.seekBarY);
this.seekBar.draw(canvas);
canvas.restore();
if (this.durationLayout != null) {
canvas.save();
canvas.translate(this.buttonX + AndroidUtilities.dp(54.0f), this.seekBarY + AndroidUtilities.dp(6.0f));
this.durationLayout.draw(canvas);
canvas.restore();
}
if (this.titleLayout != null) {
canvas.save();
canvas.translate(this.buttonX + AndroidUtilities.dp(54.0f), this.seekBarY - AndroidUtilities.dp(16.0f));
this.titleLayout.draw(canvas);
canvas.restore();
}
if (this.captionLayout != null) {
canvas.save();
canvas.translate(this.textX, this.textY);
this.captionLayout.draw(canvas);
canvas.restore();
}
if (this.creditLayout != null) {
canvas.save();
canvas.translate(this.textX, this.textY + this.creditOffset);
this.creditLayout.draw(canvas);
canvas.restore();
}
if (this.currentBlock.level > 0) {
canvas.drawRect(AndroidUtilities.dp(18.0f), 0.0f, AndroidUtilities.dp(20.0f), 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) {
return;
}
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(AndroidUtilities.dp(16.0f));
this.durationLayout = new StaticLayout(format, ArticleViewer.audioTimePaint, (int) Math.ceil(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();
return;
}
return;
}
if (i == 1) {
if (MediaController.getInstance().lambda$startAudioAgain$5$MediaController(this.currentMessageObject)) {
this.buttonState = 0;
this.radialProgress.setIcon(getIconForCurrentState(), false, z);
invalidate();
return;
}
return;
}
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();
return;
}
if (i == 3) {
FileLoader.getInstance(ArticleViewer.this.currentAccount).cancelLoadFile(this.currentDocument);
this.buttonState = 2;
this.radialProgress.setIcon(getIconForCurrentState(), false, z);
invalidate();
}
}
@Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
DownloadController.getInstance(ArticleViewer.this.currentAccount).removeLoadingFileObserver(this);
}
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
updateButtonState(false);
}
@Override
public void onFailedDownload(String str, boolean z) {
updateButtonState(true);
}
@Override
public void onSuccessDownload(String str) {
this.radialProgress.setProgress(1.0f, true);
updateButtonState(true);
}
@Override
public void onProgressDownload(String str, float f) {
this.radialProgress.setProgress(f, true);
if (this.buttonState != 3) {
updateButtonState(true);
}
}
@Override
public int getObserverTag() {
return this.TAG;
}
}
public class BlockEmbedPostCell extends View {
private AvatarDrawable 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));
this.avatarDrawable = new AvatarDrawable();
}
public void setBlock(TLRPC.TL_pageBlockEmbedPost tL_pageBlockEmbedPost) {
this.currentBlock = tL_pageBlockEmbedPost;
requestLayout();
}
@Override
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);
}
@Override
protected 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) {
if (!(tL_pageBlockEmbedPost instanceof TL_pageBlockEmbedPostCaption)) {
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((this.avatarVisible ? 54 : 0) + 50), 0, this.currentBlock, Layout.Alignment.ALIGN_NORMAL, 1, this.parentAdapter);
if (this.currentBlock.date != 0) {
this.dateLayout = ArticleViewer.this.createLayoutForText(this, LocaleController.getInstance().chatFullDate.format(this.currentBlock.date * 1000), null, size - AndroidUtilities.dp((this.avatarVisible ? 54 : 0) + 50), this.currentBlock, this.parentAdapter);
} else {
this.dateLayout = null;
}
int dp = AndroidUtilities.dp(56.0f);
if (this.currentBlock.blocks.isEmpty()) {
int dp2 = size - AndroidUtilities.dp(50.0f);
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);
}
int i4 = dp;
DrawingText createLayoutForText2 = ArticleViewer.this.createLayoutForText(this, (CharSequence) null, this.currentBlock.caption.credit, dp2, this.currentBlock, ArticleViewer.this.isRtl ? StaticLayoutEx.ALIGN_RIGHT() : Layout.Alignment.ALIGN_NORMAL, this.parentAdapter);
this.creditLayout = createLayoutForText2;
if (createLayoutForText2 != null) {
i4 += AndroidUtilities.dp(4.0f) + this.creditLayout.getHeight();
}
this.textX = AndroidUtilities.dp(32.0f);
this.textY = AndroidUtilities.dp(56.0f);
i3 = i4;
} else {
this.captionLayout = null;
this.creditLayout = null;
i3 = dp;
}
} else {
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;
r13 = 0 + dp5 + AndroidUtilities.dp(4.0f);
}
DrawingText createLayoutForText4 = ArticleViewer.this.createLayoutForText(this, (CharSequence) null, this.currentBlock.caption.credit, dp4, this.currentBlock, ArticleViewer.this.isRtl ? StaticLayoutEx.ALIGN_RIGHT() : Layout.Alignment.ALIGN_NORMAL, this.parentAdapter);
this.creditLayout = createLayoutForText4;
if (createLayoutForText4 != null) {
r13 += AndroidUtilities.dp(4.0f) + this.creditLayout.getHeight();
}
this.textX = AndroidUtilities.dp(18.0f);
this.textY = AndroidUtilities.dp(4.0f);
i3 = r13;
}
this.lineHeight = i3;
}
setMeasuredDimension(size, i3);
}
@Override
protected void onDraw(Canvas canvas) {
TLRPC.TL_pageBlockEmbedPost tL_pageBlockEmbedPost = this.currentBlock;
if (tL_pageBlockEmbedPost == null) {
return;
}
if (!(tL_pageBlockEmbedPost instanceof TL_pageBlockEmbedPostCaption)) {
if (this.avatarVisible) {
this.avatarImageView.draw(canvas);
}
if (this.nameLayout != null) {
canvas.save();
canvas.translate(AndroidUtilities.dp((this.avatarVisible ? 54 : 0) + 32), AndroidUtilities.dp(this.dateLayout != null ? 10.0f : 19.0f));
this.nameLayout.draw(canvas);
canvas.restore();
}
if (this.dateLayout != null) {
canvas.save();
canvas.translate(AndroidUtilities.dp((this.avatarVisible ? 54 : 0) + 32), AndroidUtilities.dp(29.0f));
this.dateLayout.draw(canvas);
canvas.restore();
}
canvas.drawRect(AndroidUtilities.dp(18.0f), AndroidUtilities.dp(6.0f), AndroidUtilities.dp(20.0f), this.lineHeight - (this.currentBlock.level == 0 ? AndroidUtilities.dp(6.0f) : 0), ArticleViewer.quoteLinePaint);
}
if (this.captionLayout != null) {
canvas.save();
canvas.translate(this.textX, this.textY);
this.captionLayout.draw(canvas);
canvas.restore();
}
if (this.creditLayout != null) {
canvas.save();
canvas.translate(this.textX, this.textY + this.creditOffset);
this.creditLayout.draw(canvas);
canvas.restore();
}
}
}
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();
}
@Override
public boolean onTouchEvent(MotionEvent motionEvent) {
return ArticleViewer.this.checkLayoutForLinks(motionEvent, this, this.textLayout, this.textX, this.textY) || super.onTouchEvent(motionEvent);
}
@Override
protected void onMeasure(int i, int i2) {
int dp;
int size = View.MeasureSpec.getSize(i);
TLRPC.TL_pageBlockParagraph tL_pageBlockParagraph = this.currentBlock;
int i3 = 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((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) {
dp = AndroidUtilities.dp(8.0f);
} else {
dp = AndroidUtilities.dp(16.0f);
}
i3 = dp + height;
}
} else {
i3 = 1;
}
setMeasuredDimension(size, i3);
}
@Override
protected void onDraw(Canvas canvas) {
if (this.currentBlock == null) {
return;
}
if (this.textLayout != null) {
canvas.save();
canvas.translate(this.textX, this.textY);
this.textLayout.draw(canvas);
canvas.restore();
}
if (this.currentBlock.level > 0) {
canvas.drawRect(AndroidUtilities.dp(18.0f), 0.0f, AndroidUtilities.dp(20.0f), getMeasuredHeight() - (this.currentBlock.bottom ? AndroidUtilities.dp(6.0f) : 0), ArticleViewer.quoteLinePaint);
}
}
@Override
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo accessibilityNodeInfo) {
super.onInitializeAccessibilityNodeInfo(accessibilityNodeInfo);
accessibilityNodeInfo.setEnabled(true);
DrawingText drawingText = this.textLayout;
if (drawingText == null) {
return;
}
accessibilityNodeInfo.setText(drawingText.getText());
}
}
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;
public class WebviewProxy {
private WebviewProxy() {
}
@JavascriptInterface
public void postEvent(final String str, final String str2) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
ArticleViewer.BlockEmbedCell.WebviewProxy.this.lambda$postEvent$0$ArticleViewer$BlockEmbedCell$WebviewProxy(str, str2);
}
});
}
public 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);
}
@Override
public boolean onTouchEvent(MotionEvent motionEvent) {
BlockEmbedCell.this.wasUserInteraction = true;
if (BlockEmbedCell.this.currentBlock != null) {
if (!BlockEmbedCell.this.currentBlock.allow_scrolling) {
ArticleViewer.this.windowView.requestDisallowInterceptTouchEvent(true);
} else {
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() {
@Override
public boolean checkInlinePermissions() {
return false;
}
@Override
public ViewGroup getTextureViewContainer() {
return null;
}
@Override
public void onInlineSurfaceTextureReady() {
}
@Override
public TextureView onSwitchInlineMode(View view, boolean z, float f, int i, boolean z2) {
return null;
}
@Override
public void prepareToSwitchInlineMode(boolean z, Runnable runnable, float f, boolean z2) {
}
@Override
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
public void onVideoSizeChanged(float f, int i) {
ArticleViewer.this.fullscreenAspectRatioView.setAspectRatio(f, i);
}
@Override
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
public void onSharePressed() {
if (ArticleViewer.this.parentActivity == null) {
return;
}
ArticleViewer.this.showDialog(new ShareAlert(ArticleViewer.this.parentActivity, null, BlockEmbedCell.this.currentBlock.url, false, BlockEmbedCell.this.currentBlock.url, true));
}
@Override
public void onPlayStateChanged(WebPlayerView webPlayerView2, boolean z) {
if (z) {
if (ArticleViewer.this.currentPlayingVideo != null && ArticleViewer.this.currentPlayingVideo != webPlayerView2) {
ArticleViewer.this.currentPlayingVideo.pause();
}
ArticleViewer.this.currentPlayingVideo = webPlayerView2;
try {
ArticleViewer.this.parentActivity.getWindow().addFlags(128);
return;
} catch (Exception e) {
FileLog.e(e);
return;
}
}
if (ArticleViewer.this.currentPlayingVideo == webPlayerView2) {
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 AnonymousClass2(ArticleViewer.this));
this.webView.setWebViewClient(new WebViewClient() {
@Override
public void onLoadResource(WebView webView, String str) {
super.onLoadResource(webView, str);
}
@Override
public void onPageFinished(WebView webView, String str) {
super.onPageFinished(webView, str);
}
@Override
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 class AnonymousClass2 extends WebChromeClient {
final ArticleViewer val$this$0;
AnonymousClass2(ArticleViewer articleViewer) {
this.val$this$0 = articleViewer;
}
@Override
public void onShowCustomView(View view, int i, WebChromeClient.CustomViewCallback customViewCallback) {
onShowCustomView(view, customViewCallback);
}
@Override
public void onShowCustomView(View view, WebChromeClient.CustomViewCallback customViewCallback) {
if (ArticleViewer.this.customView == null) {
ArticleViewer.this.customView = view;
ArticleViewer.this.customViewCallback = customViewCallback;
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
ArticleViewer.BlockEmbedCell.AnonymousClass2.this.lambda$onShowCustomView$0$ArticleViewer$BlockEmbedCell$2();
}
}, 100L);
return;
}
customViewCallback.onCustomViewHidden();
}
public 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);
}
}
@Override
public void onHideCustomView() {
super.onHideCustomView();
if (ArticleViewer.this.customView == null) {
return;
}
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;
}
}
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) {
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);
}
} else {
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);
}
} catch (Exception e2) {
FileLog.e(e2);
}
}
requestLayout();
}
@Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
if (ArticleViewer.this.isVisible) {
return;
}
this.currentBlock = null;
}
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
}
@Override
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);
}
@Override
protected void onMeasure(int i, int i2) {
int i3;
int i4;
int i5;
int dp;
int dp2;
int size = View.MeasureSpec.getSize(i);
TLRPC.TL_pageBlockEmbed tL_pageBlockEmbed = this.currentBlock;
if (tL_pageBlockEmbed != null) {
if (tL_pageBlockEmbed.level > 0) {
int dp3 = AndroidUtilities.dp(this.currentBlock.level * 14) + AndroidUtilities.dp(18.0f);
this.listX = dp3;
this.textX = dp3;
i4 = size - (dp3 + AndroidUtilities.dp(18.0f));
i5 = i4;
} else {
this.listX = 0;
this.textX = AndroidUtilities.dp(18.0f);
int dp4 = size - AndroidUtilities.dp(36.0f);
if (this.currentBlock.full_width) {
i4 = size;
} else {
i4 = size - AndroidUtilities.dp(36.0f);
this.listX += AndroidUtilities.dp(18.0f);
}
i5 = dp4;
}
float f = this.currentBlock.w == 0 ? 1.0f : size / this.currentBlock.w;
int i6 = this.exactWebViewHeight;
if (i6 != 0) {
dp = AndroidUtilities.dp(i6);
} else {
dp = (int) ((this.currentBlock.w == 0 ? AndroidUtilities.dp(this.currentBlock.h) : this.currentBlock.h) * f);
}
if (dp == 0) {
dp = AndroidUtilities.dp(10.0f);
}
int i7 = dp;
this.webView.measure(View.MeasureSpec.makeMeasureSpec(i4, 1073741824), View.MeasureSpec.makeMeasureSpec(i7, 1073741824));
if (this.videoView.getParent() == this) {
this.videoView.measure(View.MeasureSpec.makeMeasureSpec(i4, 1073741824), View.MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(10.0f) + i7, 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) + i7;
int dp5 = AndroidUtilities.dp(4.0f) + this.captionLayout.getHeight();
this.creditOffset = dp5;
i7 += dp5 + AndroidUtilities.dp(4.0f);
}
DrawingText createLayoutForText2 = ArticleViewer.this.createLayoutForText(this, (CharSequence) null, this.currentBlock.caption.credit, i5, this.currentBlock, ArticleViewer.this.isRtl ? StaticLayoutEx.ALIGN_RIGHT() : Layout.Alignment.ALIGN_NORMAL, this.parentAdapter);
this.creditLayout = createLayoutForText2;
if (createLayoutForText2 != null) {
i7 += AndroidUtilities.dp(4.0f) + this.creditLayout.getHeight();
}
i3 = i7 + AndroidUtilities.dp(5.0f);
if (this.currentBlock.level > 0 && !this.currentBlock.bottom) {
dp2 = AndroidUtilities.dp(8.0f);
} else if (this.currentBlock.level == 0 && this.captionLayout != null) {
dp2 = AndroidUtilities.dp(8.0f);
}
i3 += dp2;
} else {
i3 = 1;
}
setMeasuredDimension(size, i3);
}
@Override
protected 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());
}
}
@Override
protected void onDraw(Canvas canvas) {
if (this.currentBlock == null) {
return;
}
if (this.captionLayout != null) {
canvas.save();
canvas.translate(this.textX, this.textY);
this.captionLayout.draw(canvas);
canvas.restore();
}
if (this.creditLayout != null) {
canvas.save();
canvas.translate(this.textX, this.textY + this.creditOffset);
this.creditLayout.draw(canvas);
canvas.restore();
}
if (this.currentBlock.level > 0) {
canvas.drawRect(AndroidUtilities.dp(18.0f), 0.0f, AndroidUtilities.dp(20.0f), getMeasuredHeight() - (this.currentBlock.bottom ? AndroidUtilities.dp(6.0f) : 0), ArticleViewer.quoteLinePaint);
}
}
}
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;
HorizontalScrollView horizontalScrollView = new HorizontalScrollView(context) {
@Override
public boolean onInterceptTouchEvent(MotionEvent motionEvent) {
if (BlockTableCell.this.tableLayout.getMeasuredWidth() > getMeasuredWidth() - AndroidUtilities.dp(36.0f)) {
ArticleViewer.this.windowView.requestDisallowInterceptTouchEvent(true);
}
return super.onInterceptTouchEvent(motionEvent);
}
@Override
protected 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;
}
}
@Override
protected 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);
}
@Override
protected 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 = horizontalScrollView;
horizontalScrollView.setPadding(AndroidUtilities.dp(18.0f), 0, AndroidUtilities.dp(18.0f), 0);
this.scrollView.setClipToPadding(false);
addView(this.scrollView, LayoutHelper.createFrame(-1, -2.0f));
TableLayout tableLayout = new TableLayout(context, this);
this.tableLayout = tableLayout;
tableLayout.setOrientation(0);
this.tableLayout.setRowOrderPreserved(true);
this.scrollView.addView(this.tableLayout, new FrameLayout.LayoutParams(-2, -2));
setWillNotDraw(false);
}
@Override
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
public Paint getLinePaint() {
return ArticleViewer.tableLinePaint;
}
@Override
public Paint getHalfLinePaint() {
return ArticleViewer.tableHalfLinePaint;
}
@Override
public Paint getHeaderPaint() {
return ArticleViewer.tableHeaderPaint;
}
@Override
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()) {
i = 0;
} else {
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;
}
}
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();
}
@Override
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;
}
}
return ArticleViewer.this.checkLayoutForLinks(motionEvent, this, this.titleLayout, this.textX, this.textY) || super.onTouchEvent(motionEvent);
}
@Override
public void invalidate() {
super.invalidate();
this.tableLayout.invalidate();
}
@Override
protected void onMeasure(int i, int i2) {
int dp;
int i3;
int i4 = 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 dp2 = AndroidUtilities.dp(this.currentBlock.level * 14);
this.listX = dp2;
dp = dp2 + AndroidUtilities.dp(18.0f);
this.textX = dp;
} else {
this.listX = 0;
this.textX = AndroidUtilities.dp(18.0f);
dp = AndroidUtilities.dp(36.0f);
}
DrawingText createLayoutForText = ArticleViewer.this.createLayoutForText(this, null, this.currentBlock.title, size - dp, 0, this.currentBlock, Layout.Alignment.ALIGN_CENTER, 0, this.parentAdapter);
this.titleLayout = createLayoutForText;
if (createLayoutForText != null) {
this.textY = 0;
i3 = createLayoutForText.getHeight() + AndroidUtilities.dp(8.0f) + 0;
this.listY = i3;
} else {
this.listY = AndroidUtilities.dp(8.0f);
i3 = 0;
}
this.scrollView.measure(View.MeasureSpec.makeMeasureSpec(size - this.listX, 1073741824), View.MeasureSpec.makeMeasureSpec(0, 0));
i4 = i3 + this.scrollView.getMeasuredHeight() + AndroidUtilities.dp(8.0f);
if (this.currentBlock.level > 0 && !this.currentBlock.bottom) {
i4 += AndroidUtilities.dp(8.0f);
}
}
setMeasuredDimension(size, i4);
this.inLayout = false;
}
@Override
protected 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;
}
}
@Override
protected void onDraw(Canvas canvas) {
if (this.currentBlock == null) {
return;
}
if (this.titleLayout != null) {
canvas.save();
canvas.translate(this.textX, this.textY);
this.titleLayout.draw(canvas);
canvas.restore();
}
if (this.currentBlock.level > 0) {
canvas.drawRect(AndroidUtilities.dp(18.0f), 0.0f, AndroidUtilities.dp(20.0f), getMeasuredHeight() - (this.currentBlock.bottom ? AndroidUtilities.dp(6.0f) : 0), ArticleViewer.quoteLinePaint);
}
}
}
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;
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;
public ArrayList<MessageObject.GroupedMessagePosition> posArray = new ArrayList<>();
public HashMap<TLObject, MessageObject.GroupedMessagePosition> positions = new HashMap<>();
private int maxSizeWidth = 1000;
public GroupedMessages() {
}
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 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.Document documentWithId;
TLRPC.PhotoSize closestPhotoSizeWithSize;
MessageObject.GroupedMessagePosition groupedMessagePosition;
this.posArray.clear();
this.positions.clear();
int size = BlockCollageCell.this.currentBlock.items.size();
if (size <= 1) {
return;
}
StringBuilder sb = new StringBuilder();
this.hasSibling = false;
int i11 = 0;
float f2 = 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 {
closestPhotoSizeWithSize = FileLoader.getClosestPhotoSizeWithSize(photoWithId.sizes, AndroidUtilities.getPhotoSize());
groupedMessagePosition = new MessageObject.GroupedMessagePosition();
groupedMessagePosition.last = i11 != size + (-1);
groupedMessagePosition.aspectRatio = closestPhotoSizeWithSize != null ? 1.0f : closestPhotoSizeWithSize.w / closestPhotoSizeWithSize.h;
if (groupedMessagePosition.aspectRatio <= 1.2f) {
sb.append("w");
} else if (groupedMessagePosition.aspectRatio < 0.8f) {
sb.append("n");
} else {
sb.append("q");
}
f2 += groupedMessagePosition.aspectRatio;
if (groupedMessagePosition.aspectRatio > 2.0f) {
z = true;
}
this.positions.put(pageBlock, groupedMessagePosition);
this.posArray.add(groupedMessagePosition);
i11++;
}
} else {
if ((pageBlock instanceof TLRPC.TL_pageBlockVideo) && (documentWithId = ArticleViewer.this.getDocumentWithId(((TLRPC.TL_pageBlockVideo) pageBlock).video_id)) != null) {
closestPhotoSizeWithSize = FileLoader.getClosestPhotoSizeWithSize(documentWithId.thumbs, 90);
groupedMessagePosition = new MessageObject.GroupedMessagePosition();
groupedMessagePosition.last = i11 != size + (-1);
groupedMessagePosition.aspectRatio = closestPhotoSizeWithSize != null ? 1.0f : closestPhotoSizeWithSize.w / closestPhotoSizeWithSize.h;
if (groupedMessagePosition.aspectRatio <= 1.2f) {
}
f2 += groupedMessagePosition.aspectRatio;
if (groupedMessagePosition.aspectRatio > 2.0f) {
}
this.positions.put(pageBlock, groupedMessagePosition);
this.posArray.add(groupedMessagePosition);
}
i11++;
}
}
int dp = AndroidUtilities.dp(120.0f);
int dp2 = (int) (AndroidUtilities.dp(120.0f) / (Math.min(AndroidUtilities.displaySize.x, AndroidUtilities.displaySize.y) / this.maxSizeWidth));
float dp3 = AndroidUtilities.dp(40.0f);
float min = Math.min(AndroidUtilities.displaySize.x, AndroidUtilities.displaySize.y);
int i12 = this.maxSizeWidth;
int i13 = (int) (dp3 / (min / i12));
float f3 = i12 / 814.0f;
float f4 = f2 / size;
int i14 = 3;
if (z || !(size == 2 || size == 3 || size == 4)) {
int size2 = this.posArray.size();
float[] fArr = new float[size2];
for (int i15 = 0; i15 < size; i15++) {
if (f4 > 1.1f) {
fArr[i15] = Math.max(1.0f, this.posArray.get(i15).aspectRatio);
} else {
fArr[i15] = Math.min(1.0f, this.posArray.get(i15).aspectRatio);
}
fArr[i15] = Math.max(0.66667f, Math.min(1.7f, fArr[i15]));
}
ArrayList arrayList = new ArrayList();
for (int i16 = 1; i16 < size2; i16++) {
int i17 = size2 - i16;
if (i16 <= 3 && i17 <= 3) {
arrayList.add(new MessageGroupedLayoutAttempt(i16, i17, multiHeight(fArr, 0, i16), multiHeight(fArr, i16, size2)));
}
}
int i18 = 1;
while (i18 < size2 - 1) {
int i19 = 1;
while (true) {
int i20 = size2 - i18;
if (i19 < i20) {
int i21 = i20 - i19;
if (i18 <= i14) {
if (i19 <= (f4 < 0.85f ? 4 : 3) && i21 <= i14) {
int i22 = i18 + i19;
i9 = i19;
i10 = i18;
arrayList.add(new MessageGroupedLayoutAttempt(i18, i19, i21, multiHeight(fArr, 0, i18), multiHeight(fArr, i18, i22), multiHeight(fArr, i22, size2)));
i19 = i9 + 1;
i18 = i10;
i14 = 3;
}
}
i9 = i19;
i10 = i18;
i19 = i9 + 1;
i18 = i10;
i14 = 3;
}
}
i18++;
i14 = 3;
}
int i23 = 1;
while (i23 < size2 - 2) {
int i24 = 1;
while (true) {
int i25 = size2 - i23;
if (i24 < i25) {
int i26 = 1;
while (true) {
int i27 = i25 - i24;
if (i26 < i27) {
int i28 = i27 - i26;
if (i23 > 3 || i24 > 3 || i26 > 3 || i28 > 3) {
i3 = i26;
i4 = i25;
i5 = i24;
i6 = size;
i7 = size2;
i8 = dp2;
} else {
int i29 = i23 + i24;
int i30 = i29 + i26;
i7 = size2;
i3 = i26;
i4 = i25;
i5 = i24;
i6 = size;
i8 = dp2;
arrayList.add(new MessageGroupedLayoutAttempt(i23, i24, i26, i28, multiHeight(fArr, 0, i23), multiHeight(fArr, i23, i29), multiHeight(fArr, i29, i30), multiHeight(fArr, i30, size2)));
}
i26 = i3 + 1;
dp2 = i8;
i25 = i4;
i24 = i5;
size = i6;
size2 = i7;
}
}
i24++;
size = size;
}
}
i23++;
size = size;
}
i = size;
int i31 = dp2;
float f5 = (this.maxSizeWidth / 3) * 4;
MessageGroupedLayoutAttempt messageGroupedLayoutAttempt = null;
float f6 = 0.0f;
for (int i32 = 0; i32 < arrayList.size(); i32++) {
MessageGroupedLayoutAttempt messageGroupedLayoutAttempt2 = (MessageGroupedLayoutAttempt) arrayList.get(i32);
float f7 = Float.MAX_VALUE;
float f8 = 0.0f;
for (int i33 = 0; i33 < messageGroupedLayoutAttempt2.heights.length; i33++) {
f8 += messageGroupedLayoutAttempt2.heights[i33];
if (messageGroupedLayoutAttempt2.heights[i33] < f7) {
f7 = messageGroupedLayoutAttempt2.heights[i33];
}
}
float abs = Math.abs(f8 - f5);
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 (f7 < i31) {
abs *= 1.5f;
}
if (messageGroupedLayoutAttempt == null || abs < f6) {
messageGroupedLayoutAttempt = messageGroupedLayoutAttempt2;
f6 = abs;
}
}
if (messageGroupedLayoutAttempt == null) {
return;
}
int i34 = 0;
int i35 = 0;
while (i35 < messageGroupedLayoutAttempt.lineCounts.length) {
int i36 = messageGroupedLayoutAttempt.lineCounts[i35];
float f9 = messageGroupedLayoutAttempt.heights[i35];
int i37 = this.maxSizeWidth;
MessageObject.GroupedMessagePosition groupedMessagePosition2 = null;
for (int i38 = 0; i38 < i36; i38++) {
int i39 = (int) (fArr[i34] * f9);
i37 -= i39;
MessageObject.GroupedMessagePosition groupedMessagePosition3 = this.posArray.get(i34);
int i40 = i35 == 0 ? 4 : 0;
if (i35 == messageGroupedLayoutAttempt.lineCounts.length - 1) {
i40 |= 8;
}
if (i38 == 0) {
i40 |= 1;
}
if (i38 == i36 - 1) {
i2 = i40 | 2;
groupedMessagePosition2 = groupedMessagePosition3;
} else {
i2 = i40;
}
groupedMessagePosition3.set(i38, i38, i35, i35, i39, f9 / 814.0f, i2);
i34++;
}
groupedMessagePosition2.pw += i37;
groupedMessagePosition2.spanSize += i37;
i35++;
}
} 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 = f4;
double d2 = f3;
Double.isNaN(d2);
if (d > d2 * 1.4d && groupedMessagePosition4.aspectRatio - groupedMessagePosition5.aspectRatio < 0.2d) {
float round = Math.round(Math.min(this.maxSizeWidth / groupedMessagePosition4.aspectRatio, Math.min(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 i41 = this.maxSizeWidth / 2;
float f10 = i41;
float round2 = Math.round(Math.min(f10 / groupedMessagePosition4.aspectRatio, Math.min(f10 / groupedMessagePosition5.aspectRatio, 814.0f))) / 814.0f;
groupedMessagePosition4.set(0, 0, 0, 0, i41, round2, 13);
groupedMessagePosition5.set(1, 1, 0, 0, i41, round2, 14);
} else {
int max = (int) Math.max(this.maxSizeWidth * 0.4f, Math.round((r0 / groupedMessagePosition4.aspectRatio) / ((1.0f / groupedMessagePosition4.aspectRatio) + (1.0f / groupedMessagePosition5.aspectRatio))));
int i42 = this.maxSizeWidth - max;
if (i42 < dp2) {
max -= dp2 - i42;
i42 = dp2;
}
float min2 = Math.min(814.0f, Math.round(Math.min(i42 / groupedMessagePosition4.aspectRatio, max / groupedMessagePosition5.aspectRatio))) / 814.0f;
groupedMessagePosition4.set(0, 0, 0, 0, i42, min2, 13);
groupedMessagePosition5.set(1, 1, 0, 0, max, min2, 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 min3 = Math.min(407.0f, Math.round((groupedMessagePosition7.aspectRatio * this.maxSizeWidth) / (groupedMessagePosition8.aspectRatio + groupedMessagePosition7.aspectRatio)));
int max2 = (int) Math.max(dp2, Math.min(this.maxSizeWidth * 0.5f, Math.round(Math.min(groupedMessagePosition8.aspectRatio * min3, groupedMessagePosition7.aspectRatio * r13))));
int round3 = Math.round(Math.min((groupedMessagePosition6.aspectRatio * 814.0f) + i13, this.maxSizeWidth - max2));
groupedMessagePosition6.set(0, 0, 0, 1, round3, 1.0f, 13);
float f11 = (814.0f - min3) / 814.0f;
groupedMessagePosition7.set(1, 1, 0, 0, max2, f11, 6);
float f12 = min3 / 814.0f;
groupedMessagePosition8.set(0, 1, 1, 1, max2, f12, 10);
groupedMessagePosition8.spanSize = this.maxSizeWidth;
groupedMessagePosition6.siblingHeights = new float[]{f12, f11};
groupedMessagePosition7.spanSize = this.maxSizeWidth - round3;
groupedMessagePosition8.leftSpanOffset = round3;
this.hasSibling = true;
} else {
float round4 = Math.round(Math.min(this.maxSizeWidth / groupedMessagePosition6.aspectRatio, 537.24005f)) / 814.0f;
groupedMessagePosition6.set(0, 1, 0, 0, this.maxSizeWidth, round4, 7);
int i43 = this.maxSizeWidth / 2;
float f13 = 814.0f - round4;
float f14 = i43;
float min4 = Math.min(f13, Math.round(Math.min(f14 / groupedMessagePosition7.aspectRatio, f14 / groupedMessagePosition8.aspectRatio))) / 814.0f;
groupedMessagePosition7.set(0, 0, 1, 1, i43, min4, 9);
groupedMessagePosition8.set(1, 1, 1, 1, i43, min4, 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 = Math.round(Math.min(this.maxSizeWidth / groupedMessagePosition9.aspectRatio, 537.24005f)) / 814.0f;
groupedMessagePosition9.set(0, 2, 0, 0, this.maxSizeWidth, round5, 7);
float round6 = Math.round(this.maxSizeWidth / ((groupedMessagePosition10.aspectRatio + groupedMessagePosition11.aspectRatio) + groupedMessagePosition12.aspectRatio));
float f15 = dp2;
int max3 = (int) Math.max(f15, Math.min(this.maxSizeWidth * 0.4f, groupedMessagePosition10.aspectRatio * round6));
int max4 = (int) Math.max(Math.max(f15, this.maxSizeWidth * 0.33f), groupedMessagePosition12.aspectRatio * round6);
int i44 = (this.maxSizeWidth - max3) - max4;
float min5 = Math.min(814.0f - round5, round6) / 814.0f;
groupedMessagePosition10.set(0, 0, 1, 1, max3, min5, 9);
groupedMessagePosition11.set(1, 1, 1, 1, i44, min5, 8);
groupedMessagePosition12.set(2, 2, 1, 1, max4, min5, 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 f16 = dp;
float f17 = max5;
float min6 = Math.min(0.33f, Math.max(f16, f17 / groupedMessagePosition10.aspectRatio) / 814.0f);
float min7 = Math.min(0.33f, Math.max(f16, f17 / groupedMessagePosition11.aspectRatio) / 814.0f);
float f18 = (1.0f - min6) - min7;
int round7 = Math.round(Math.min((814.0f * groupedMessagePosition9.aspectRatio) + i13, this.maxSizeWidth - max5));
groupedMessagePosition9.set(0, 0, 0, 2, round7, min6 + min7 + f18, 13);
groupedMessagePosition10.set(1, 1, 0, 0, max5, min6, 6);
groupedMessagePosition11.set(0, 1, 1, 1, max5, min7, 2);
groupedMessagePosition11.spanSize = this.maxSizeWidth;
groupedMessagePosition12.set(0, 1, 2, 2, max5, f18, 10);
groupedMessagePosition12.spanSize = this.maxSizeWidth;
groupedMessagePosition10.spanSize = this.maxSizeWidth - round7;
groupedMessagePosition11.leftSpanOffset = round7;
groupedMessagePosition12.leftSpanOffset = round7;
groupedMessagePosition9.siblingHeights = new float[]{min6, min7, f18};
this.hasSibling = true;
}
}
i = size;
}
int i45 = i;
for (int i46 = 0; i46 < i45; i46++) {
MessageObject.GroupedMessagePosition groupedMessagePosition13 = this.posArray.get(i46);
if ((groupedMessagePosition13.flags & 1) != 0) {
groupedMessagePosition13.edge = true;
}
}
}
}
public BlockCollageCell(Context context, WebpageAdapter webpageAdapter) {
super(context);
this.group = new GroupedMessages();
this.parentAdapter = webpageAdapter;
RecyclerListView recyclerListView = new RecyclerListView(context) {
@Override
public void requestLayout() {
if (BlockCollageCell.this.inLayout) {
return;
}
super.requestLayout();
}
};
this.innerListView = recyclerListView;
recyclerListView.addItemDecoration(new RecyclerView.ItemDecoration() {
@Override
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 = view instanceof BlockVideoCell ? BlockCollageCell.this.group.positions.get(((BlockVideoCell) view).currentBlock) : null;
} else {
groupedMessagePosition = BlockCollageCell.this.group.positions.get(((BlockPhotoCell) view).currentBlock);
}
if (groupedMessagePosition == null || groupedMessagePosition.siblingHeights == null) {
return;
}
float max = 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(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(max * groupedMessagePosition2.ph)) - AndroidUtilities.dp(4.0f);
break;
}
i++;
}
rect.bottom = -dp2;
}
});
GridLayoutManagerFixed gridLayoutManagerFixed = new GridLayoutManagerFixed(context, 1000, 1, true) {
@Override
public boolean shouldLayoutChildFromOpositeSide(View view) {
return false;
}
@Override
public boolean supportsPredictiveItemAnimations() {
return false;
}
@Override
protected 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 = gridLayoutManagerFixed;
gridLayoutManagerFixed.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
@Override
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 recyclerListView2 = this.innerListView;
RecyclerView.Adapter adapter = new RecyclerView.Adapter() {
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
View blockPhotoCell;
if (i == 0) {
blockPhotoCell = new BlockPhotoCell(BlockCollageCell.this.getContext(), BlockCollageCell.this.parentAdapter, 2);
} else {
blockPhotoCell = new BlockVideoCell(BlockCollageCell.this.getContext(), BlockCollageCell.this.parentAdapter, 2);
}
return new RecyclerListView.Holder(blockPhotoCell);
}
@Override
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) {
BlockPhotoCell blockPhotoCell = (BlockPhotoCell) viewHolder.itemView;
blockPhotoCell.groupPosition = BlockCollageCell.this.group.positions.get(pageBlock);
blockPhotoCell.setBlock((TLRPC.TL_pageBlockPhoto) pageBlock, true, true);
} else {
BlockVideoCell blockVideoCell = (BlockVideoCell) viewHolder.itemView;
blockVideoCell.groupPosition = BlockCollageCell.this.group.positions.get(pageBlock);
blockVideoCell.setBlock((TLRPC.TL_pageBlockVideo) pageBlock, true, true);
}
}
@Override
public int getItemCount() {
if (BlockCollageCell.this.currentBlock == null) {
return 0;
}
return BlockCollageCell.this.currentBlock.items.size();
}
@Override
public int getItemViewType(int i) {
return BlockCollageCell.this.currentBlock.items.get((BlockCollageCell.this.currentBlock.items.size() - i) - 1) instanceof TLRPC.TL_pageBlockPhoto ? 0 : 1;
}
};
this.innerAdapter = adapter;
recyclerListView2.setAdapter(adapter);
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();
}
@Override
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);
}
@Override
protected void onMeasure(int i, int i2) {
int dp;
int i3;
int i4 = 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 dp2 = AndroidUtilities.dp(this.currentBlock.level * 14) + AndroidUtilities.dp(18.0f);
this.listX = dp2;
this.textX = dp2;
i3 = size - (dp2 + AndroidUtilities.dp(18.0f));
dp = i3;
} else {
this.listX = 0;
this.textX = AndroidUtilities.dp(18.0f);
dp = 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, dp, this.currentBlock, this.parentAdapter);
this.captionLayout = createLayoutForText;
if (createLayoutForText != null) {
this.textY = AndroidUtilities.dp(8.0f) + measuredHeight;
int dp3 = AndroidUtilities.dp(4.0f) + this.captionLayout.getHeight();
this.creditOffset = dp3;
measuredHeight += dp3 + AndroidUtilities.dp(4.0f);
}
DrawingText createLayoutForText2 = ArticleViewer.this.createLayoutForText(this, (CharSequence) null, this.currentBlock.caption.credit, dp, this.currentBlock, ArticleViewer.this.isRtl ? StaticLayoutEx.ALIGN_RIGHT() : Layout.Alignment.ALIGN_NORMAL, this.parentAdapter);
this.creditLayout = createLayoutForText2;
if (createLayoutForText2 != null) {
measuredHeight += AndroidUtilities.dp(4.0f) + this.creditLayout.getHeight();
}
i4 = measuredHeight + AndroidUtilities.dp(16.0f);
if (this.currentBlock.level > 0 && !this.currentBlock.bottom) {
i4 += AndroidUtilities.dp(8.0f);
}
}
setMeasuredDimension(size, i4);
this.inLayout = false;
}
@Override
protected 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));
}
@Override
protected void onDraw(Canvas canvas) {
if (this.currentBlock == null) {
return;
}
if (this.captionLayout != null) {
canvas.save();
canvas.translate(this.textX, this.textY);
this.captionLayout.draw(canvas);
canvas.restore();
}
if (this.creditLayout != null) {
canvas.save();
canvas.translate(this.textX, this.textY + this.creditOffset);
this.creditLayout.draw(canvas);
canvas.restore();
}
if (this.currentBlock.level > 0) {
canvas.drawRect(AndroidUtilities.dp(18.0f), 0.0f, AndroidUtilities.dp(20.0f), getMeasuredHeight() - (this.currentBlock.bottom ? AndroidUtilities.dp(6.0f) : 0), ArticleViewer.quoteLinePaint);
}
}
}
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;
private int textY;
public BlockSlideshowCell(Context context, WebpageAdapter webpageAdapter) {
super(context);
this.textX = AndroidUtilities.dp(18.0f);
this.parentAdapter = webpageAdapter;
if (ArticleViewer.dotsPaint == null) {
Paint unused = ArticleViewer.dotsPaint = new Paint(1);
ArticleViewer.dotsPaint.setColor(-1);
}
ViewPager viewPager = new ViewPager(context) {
@Override
public boolean onTouchEvent(MotionEvent motionEvent) {
return super.onTouchEvent(motionEvent);
}
@Override
public boolean onInterceptTouchEvent(MotionEvent motionEvent) {
ArticleViewer.this.windowView.requestDisallowInterceptTouchEvent(true);
return super.onInterceptTouchEvent(motionEvent);
}
};
this.innerListView = viewPager;
viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageScrollStateChanged(int i) {
}
@Override
public void onPageScrolled(int i, float f, int i2) {
float measuredWidth = BlockSlideshowCell.this.innerListView.getMeasuredWidth();
if (measuredWidth == 0.0f) {
return;
}
BlockSlideshowCell.this.pageOffset = (((i * measuredWidth) + i2) - (r0.currentPage * measuredWidth)) / measuredWidth;
BlockSlideshowCell.this.dotsContainer.invalidate();
}
@Override
public void onPageSelected(int i) {
BlockSlideshowCell.this.currentPage = i;
BlockSlideshowCell.this.dotsContainer.invalidate();
}
});
ViewPager viewPager2 = this.innerListView;
PagerAdapter pagerAdapter = new PagerAdapter() {
class ObjectContainer {
private TLRPC.PageBlock block;
private View view;
ObjectContainer() {
}
}
@Override
public int getCount() {
if (BlockSlideshowCell.this.currentBlock == null) {
return 0;
}
return BlockSlideshowCell.this.currentBlock.items.size();
}
@Override
public boolean isViewFromObject(View view, Object obj) {
return ((ObjectContainer) obj).view == view;
}
@Override
public int getItemPosition(Object obj) {
return BlockSlideshowCell.this.currentBlock.items.contains(((ObjectContainer) obj).block) ? -1 : -2;
}
@Override
public Object instantiateItem(ViewGroup viewGroup, int i) {
View blockVideoCell;
TLRPC.PageBlock pageBlock = BlockSlideshowCell.this.currentBlock.items.get(i);
if (pageBlock instanceof TLRPC.TL_pageBlockPhoto) {
blockVideoCell = new BlockPhotoCell(BlockSlideshowCell.this.getContext(), BlockSlideshowCell.this.parentAdapter, 1);
((BlockPhotoCell) blockVideoCell).setBlock((TLRPC.TL_pageBlockPhoto) pageBlock, true, true);
} else {
blockVideoCell = new BlockVideoCell(BlockSlideshowCell.this.getContext(), BlockSlideshowCell.this.parentAdapter, 1);
((BlockVideoCell) blockVideoCell).setBlock((TLRPC.TL_pageBlockVideo) pageBlock, true, true);
}
viewGroup.addView(blockVideoCell);
ObjectContainer objectContainer = new ObjectContainer();
objectContainer.view = blockVideoCell;
objectContainer.block = pageBlock;
return objectContainer;
}
@Override
public void destroyItem(ViewGroup viewGroup, int i, Object obj) {
viewGroup.removeView(((ObjectContainer) obj).view);
}
@Override
public void unregisterDataSetObserver(DataSetObserver dataSetObserver) {
if (dataSetObserver != null) {
super.unregisterDataSetObserver(dataSetObserver);
}
}
};
this.innerAdapter = pagerAdapter;
viewPager2.setAdapter(pagerAdapter);
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);
View view = new View(context) {
@Override
protected void onDraw(Canvas canvas) {
int i;
int i2;
if (BlockSlideshowCell.this.currentBlock == null) {
return;
}
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 * 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 * dp3);
}
i = dp2 - i2;
} else {
i = dp2 - (((int) (BlockSlideshowCell.this.pageOffset * 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 = view;
addView(view);
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();
}
@Override
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);
}
@Override
protected 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(this, (CharSequence) null, this.currentBlock.caption.credit, dp2, this.currentBlock, ArticleViewer.this.isRtl ? StaticLayoutEx.ALIGN_RIGHT() : Layout.Alignment.ALIGN_NORMAL, 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);
}
@Override
protected 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);
}
@Override
protected void onDraw(Canvas canvas) {
if (this.currentBlock == null) {
return;
}
if (this.captionLayout != null) {
canvas.save();
canvas.translate(this.textX, this.textY);
this.captionLayout.draw(canvas);
canvas.restore();
}
if (this.creditLayout != null) {
canvas.save();
canvas.translate(this.textX, this.textY + this.creditOffset);
this.creditLayout.draw(canvas);
canvas.restore();
}
}
}
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();
}
@Override
public boolean onTouchEvent(MotionEvent motionEvent) {
if (ArticleViewer.this.checkLayoutForLinks(motionEvent, this, this.textLayout, this.textX, this.textY)) {
return true;
}
return super.onTouchEvent(motionEvent);
}
@Override
protected void onMeasure(int i, int i2) {
int dp;
int dp2;
int i3;
int size = View.MeasureSpec.getSize(i);
TL_pageBlockListItem tL_pageBlockListItem = this.currentBlock;
int i4 = 1;
if (tL_pageBlockListItem != null) {
this.textLayout = null;
int i5 = 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 i6 = 0; i6 < size2; i6++) {
TL_pageBlockListItem tL_pageBlockListItem2 = (TL_pageBlockListItem) this.currentBlock.parent.items.get(i6);
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(tL_pageBlockListItem2.numLayout.getLineWidth(0)));
}
}
this.currentBlock.parent.maxNumWidth = Math.max(this.currentBlock.parent.maxNumWidth, (int) Math.ceil(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(24.0f) + this.currentBlock.parent.maxNumWidth + (this.currentBlock.parent.level * AndroidUtilities.dp(12.0f));
} else {
this.textX = AndroidUtilities.dp(18.0f);
}
int dp3 = (size - AndroidUtilities.dp(18.0f)) - this.textX;
if (ArticleViewer.this.isRtl) {
dp3 -= (AndroidUtilities.dp(6.0f) + this.currentBlock.parent.maxNumWidth) + (this.currentBlock.parent.level * AndroidUtilities.dp(12.0f));
}
int i7 = dp3;
if (this.currentBlock.textItem != null) {
DrawingText createLayoutForText = ArticleViewer.this.createLayoutForText(this, (CharSequence) null, this.currentBlock.textItem, i7, this.currentBlock, ArticleViewer.this.isRtl ? StaticLayoutEx.ALIGN_RIGHT() : Layout.Alignment.ALIGN_NORMAL, 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);
}
dp = this.textLayout.getHeight() + AndroidUtilities.dp(8.0f);
i5 += dp;
}
if (this.currentBlock.parent.items.get(this.currentBlock.parent.items.size() - 1) == this.currentBlock) {
i5 += AndroidUtilities.dp(8.0f);
}
if (this.currentBlock.index == 0 && this.currentBlock.parent.level == 0) {
i5 += AndroidUtilities.dp(10.0f);
}
i4 = i5;
} 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);
}
i7 += AndroidUtilities.dp(18.0f);
i3 = 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);
}
dp2 = AndroidUtilities.dp(18.0f);
} else if (ArticleViewer.this.isListItemBlock(this.currentBlock.blockItem)) {
this.blockX = 0;
this.blockY = 0;
this.textY = 0;
i3 = ((this.currentBlock.index == 0 && this.currentBlock.parent.level == 0) ? 0 - AndroidUtilities.dp(10.0f) : 0) - AndroidUtilities.dp(8.0f);
i7 = size;
} else {
if (this.blockLayout.itemView instanceof BlockTableCell) {
this.blockX -= AndroidUtilities.dp(18.0f);
dp2 = AndroidUtilities.dp(36.0f);
}
i3 = 0;
}
i7 += dp2;
i3 = 0;
}
this.blockLayout.itemView.measure(View.MeasureSpec.makeMeasureSpec(i7, 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) {
i3 -= AndroidUtilities.dp(10.0f);
}
i3 -= AndroidUtilities.dp(8.0f);
} else if (!(this.blockLayout.itemView instanceof BlockOrderedListItemCell)) {
if (this.blockLayout.itemView instanceof BlockListItemCell) {
this.verticalAlign = ((BlockListItemCell) this.blockLayout.itemView).verticalAlign;
}
} else {
this.verticalAlign = ((BlockOrderedListItemCell) 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;
}
i5 = i3 + this.blockLayout.itemView.getMeasuredHeight();
}
dp = AndroidUtilities.dp(8.0f);
i5 += dp;
}
if (this.currentBlock.parent.items.get(this.currentBlock.parent.items.size() - 1) == this.currentBlock) {
}
if (this.currentBlock.index == 0) {
i5 += AndroidUtilities.dp(10.0f);
}
i4 = i5;
}
}
setMeasuredDimension(size, i4);
}
@Override
protected 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());
}
}
@Override
protected void onDraw(Canvas canvas) {
if (this.currentBlock == null) {
return;
}
int measuredWidth = getMeasuredWidth();
if (this.currentBlock.numLayout != null) {
canvas.save();
if (ArticleViewer.this.isRtl) {
canvas.translate(((measuredWidth - AndroidUtilities.dp(15.0f)) - this.currentBlock.parent.maxNumWidth) - (this.currentBlock.parent.level * AndroidUtilities.dp(12.0f)), (this.textY + this.numOffsetY) - (this.drawDot ? AndroidUtilities.dp(1.0f) : 0));
} else {
canvas.translate(((AndroidUtilities.dp(15.0f) + this.currentBlock.parent.maxNumWidth) - ((int) Math.ceil(this.currentBlock.numLayout.getLineWidth(0)))) + (this.currentBlock.parent.level * AndroidUtilities.dp(12.0f)), (this.textY + this.numOffsetY) - (this.drawDot ? AndroidUtilities.dp(1.0f) : 0));
}
this.currentBlock.numLayout.draw(canvas);
canvas.restore();
}
if (this.textLayout != null) {
canvas.save();
canvas.translate(this.textX, this.textY);
this.textLayout.draw(canvas);
canvas.restore();
}
}
@Override
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo accessibilityNodeInfo) {
super.onInitializeAccessibilityNodeInfo(accessibilityNodeInfo);
accessibilityNodeInfo.setEnabled(true);
DrawingText drawingText = this.textLayout;
if (drawingText == null) {
return;
}
accessibilityNodeInfo.setText(drawingText.getText());
}
}
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();
}
@Override
public boolean onTouchEvent(MotionEvent motionEvent) {
if (ArticleViewer.this.checkLayoutForLinks(motionEvent, this, this.textLayout, this.textX, this.textY)) {
return true;
}
return super.onTouchEvent(motionEvent);
}
@Override
protected void onMeasure(int i, int i2) {
int dp;
int dp2;
int i3;
int size = View.MeasureSpec.getSize(i);
TL_pageBlockOrderedListItem tL_pageBlockOrderedListItem = this.currentBlock;
int i4 = 1;
if (tL_pageBlockOrderedListItem != null) {
this.textLayout = null;
int i5 = 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 i6 = 0; i6 < size2; i6++) {
TL_pageBlockOrderedListItem tL_pageBlockOrderedListItem2 = (TL_pageBlockOrderedListItem) this.currentBlock.parent.items.get(i6);
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(tL_pageBlockOrderedListItem2.numLayout.getLineWidth(0)));
}
}
this.currentBlock.parent.maxNumWidth = Math.max(this.currentBlock.parent.maxNumWidth, (int) Math.ceil(ArticleViewer.listTextNumPaint.measureText("00.")));
}
if (!ArticleViewer.this.isRtl) {
this.textX = AndroidUtilities.dp(24.0f) + this.currentBlock.parent.maxNumWidth + (this.currentBlock.parent.level * AndroidUtilities.dp(20.0f));
} else {
this.textX = AndroidUtilities.dp(18.0f);
}
this.verticalAlign = false;
int dp3 = (size - AndroidUtilities.dp(18.0f)) - this.textX;
if (ArticleViewer.this.isRtl) {
dp3 -= (AndroidUtilities.dp(6.0f) + this.currentBlock.parent.maxNumWidth) + (this.currentBlock.parent.level * AndroidUtilities.dp(20.0f));
}
int i7 = dp3;
if (this.currentBlock.textItem != null) {
DrawingText createLayoutForText = ArticleViewer.this.createLayoutForText(this, (CharSequence) null, this.currentBlock.textItem, i7, this.currentBlock, ArticleViewer.this.isRtl ? StaticLayoutEx.ALIGN_RIGHT() : Layout.Alignment.ALIGN_NORMAL, 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);
}
dp = this.textLayout.getHeight() + AndroidUtilities.dp(8.0f);
i5 += dp;
}
if (this.currentBlock.parent.items.get(this.currentBlock.parent.items.size() - 1) == this.currentBlock) {
i5 += AndroidUtilities.dp(8.0f);
}
if (this.currentBlock.index == 0 && this.currentBlock.parent.level == 0) {
i5 += AndroidUtilities.dp(10.0f);
}
i4 = i5;
} 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);
}
i7 += AndroidUtilities.dp(18.0f);
i3 = 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);
}
dp2 = AndroidUtilities.dp(18.0f);
} else if (ArticleViewer.this.isListItemBlock(this.currentBlock.blockItem)) {
this.blockX = 0;
this.blockY = 0;
this.textY = 0;
i3 = 0 - AndroidUtilities.dp(8.0f);
i7 = size;
} else {
if (this.blockLayout.itemView instanceof BlockTableCell) {
this.blockX -= AndroidUtilities.dp(18.0f);
dp2 = AndroidUtilities.dp(36.0f);
}
i3 = 0;
}
i7 += dp2;
i3 = 0;
}
this.blockLayout.itemView.measure(View.MeasureSpec.makeMeasureSpec(i7, 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;
i3 -= 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;
}
i5 = this.blockLayout.itemView.getMeasuredHeight() + i3;
}
dp = AndroidUtilities.dp(8.0f);
i5 += dp;
}
if (this.currentBlock.parent.items.get(this.currentBlock.parent.items.size() - 1) == this.currentBlock) {
}
if (this.currentBlock.index == 0) {
i5 += AndroidUtilities.dp(10.0f);
}
i4 = i5;
}
}
setMeasuredDimension(size, i4);
}
@Override
protected 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());
}
}
@Override
protected void onDraw(Canvas canvas) {
if (this.currentBlock == null) {
return;
}
int measuredWidth = getMeasuredWidth();
if (this.currentBlock.numLayout != null) {
canvas.save();
if (ArticleViewer.this.isRtl) {
canvas.translate(((measuredWidth - AndroidUtilities.dp(18.0f)) - this.currentBlock.parent.maxNumWidth) - (this.currentBlock.parent.level * AndroidUtilities.dp(20.0f)), this.textY + this.numOffsetY);
} else {
canvas.translate(((AndroidUtilities.dp(18.0f) + this.currentBlock.parent.maxNumWidth) - ((int) Math.ceil(this.currentBlock.numLayout.getLineWidth(0)))) + (this.currentBlock.parent.level * AndroidUtilities.dp(20.0f)), this.textY + this.numOffsetY);
}
this.currentBlock.numLayout.draw(canvas);
canvas.restore();
}
if (this.textLayout != null) {
canvas.save();
canvas.translate(this.textX, this.textY);
this.textLayout.draw(canvas);
canvas.restore();
}
}
@Override
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo accessibilityNodeInfo) {
super.onInitializeAccessibilityNodeInfo(accessibilityNodeInfo);
accessibilityNodeInfo.setEnabled(true);
DrawingText drawingText = this.textLayout;
if (drawingText == null) {
return;
}
accessibilityNodeInfo.setText(drawingText.getText());
}
}
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;
private int textY;
@Override
public void scheduleDrawable(Drawable drawable, Runnable runnable, long j) {
}
@Override
public void unscheduleDrawable(Drawable drawable, Runnable runnable) {
}
public BlockDetailsCell(Context context, WebpageAdapter webpageAdapter) {
super(context);
this.textX = AndroidUtilities.dp(50.0f);
this.textY = AndroidUtilities.dp(11.0f) + 1;
this.parentAdapter = webpageAdapter;
this.arrow = new AnimatedArrowDrawable(ArticleViewer.this.getGrayTextColor(), true);
}
@Override
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();
}
@Override
public boolean onTouchEvent(MotionEvent motionEvent) {
return ArticleViewer.this.checkLayoutForLinks(motionEvent, this, this.textLayout, this.textX, this.textY) || super.onTouchEvent(motionEvent);
}
@Override
protected 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(this, (CharSequence) null, tL_pageBlockDetails.title, size - AndroidUtilities.dp(52.0f), this.currentBlock, ArticleViewer.this.isRtl ? StaticLayoutEx.ALIGN_RIGHT() : Layout.Alignment.ALIGN_NORMAL, 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);
}
@Override
protected void onDraw(Canvas canvas) {
if (this.currentBlock == null) {
return;
}
canvas.save();
canvas.translate(AndroidUtilities.dp(18.0f), ((getMeasuredHeight() - AndroidUtilities.dp(13.0f)) - 1) / 2);
this.arrow.draw(canvas);
canvas.restore();
if (this.textLayout != null) {
canvas.save();
canvas.translate(this.textX, this.textY);
this.textLayout.draw(canvas);
canvas.restore();
}
float measuredHeight = getMeasuredHeight() - 1;
canvas.drawLine(0.0f, measuredHeight, getMeasuredWidth(), measuredHeight, ArticleViewer.dividerPaint);
}
}
public class BlockDetailsBottomCell extends View {
private RectF rect;
public BlockDetailsBottomCell(Context context) {
super(context);
this.rect = new RectF();
}
@Override
protected void onMeasure(int i, int i2) {
setMeasuredDimension(View.MeasureSpec.getSize(i), AndroidUtilities.dp(4.0f) + 1);
}
@Override
protected void onDraw(Canvas canvas) {
canvas.drawLine(0.0f, 0.0f, getMeasuredWidth(), 0.0f, ArticleViewer.dividerPaint);
}
}
public class BlockRelatedArticlesShadowCell extends View {
private CombinedDrawable shadowDrawable;
public BlockRelatedArticlesShadowCell(Context context) {
super(context);
CombinedDrawable combinedDrawable = new CombinedDrawable(new ColorDrawable(-986896), Theme.getThemedDrawable(context, R.drawable.greydivider_bottom, -16777216));
this.shadowDrawable = combinedDrawable;
combinedDrawable.setFullsize(true);
setBackgroundDrawable(this.shadowDrawable);
}
@Override
protected 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);
}
}
}
public class BlockRelatedArticlesHeaderCell extends View {
private TLRPC.TL_pageBlockRelatedArticles currentBlock;
private WebpageAdapter parentAdapter;
private DrawingText textLayout;
private int textX;
private int textY;
public BlockRelatedArticlesHeaderCell(Context context, WebpageAdapter webpageAdapter) {
super(context);
this.textX = AndroidUtilities.dp(18.0f);
this.parentAdapter = webpageAdapter;
}
public void setBlock(TLRPC.TL_pageBlockRelatedArticles tL_pageBlockRelatedArticles) {
this.currentBlock = tL_pageBlockRelatedArticles;
requestLayout();
}
@Override
public boolean onTouchEvent(MotionEvent motionEvent) {
return ArticleViewer.this.checkLayoutForLinks(motionEvent, this, this.textLayout, this.textX, this.textY) || super.onTouchEvent(motionEvent);
}
@Override
protected 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);
}
}
@Override
protected void onDraw(Canvas canvas) {
if (this.currentBlock == null || this.textLayout == null) {
return;
}
canvas.save();
canvas.translate(this.textX, this.textY);
this.textLayout.draw(canvas);
canvas.restore();
}
}
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;
private int textY;
public BlockRelatedArticlesCell(Context context, WebpageAdapter webpageAdapter) {
super(context);
this.textX = AndroidUtilities.dp(18.0f);
this.textY = AndroidUtilities.dp(10.0f);
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();
}
@Override
protected void onMeasure(int i, int i2) {
int i3;
boolean z;
int i4;
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) {
if (ArticleViewer.this.selectedFontSize != 1) {
if (ArticleViewer.this.selectedFontSize != 3) {
if (ArticleViewer.this.selectedFontSize == 4) {
this.additionalHeight = AndroidUtilities.dp(4.0f);
}
} else {
this.additionalHeight = AndroidUtilities.dp(2.0f);
}
} else {
this.additionalHeight = -AndroidUtilities.dp(2.0f);
}
} else {
this.additionalHeight = -AndroidUtilities.dp(4.0f);
}
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);
this.imageView.setImage(ImageLocation.getForPhoto(closestPhotoSizeWithSize, photoWithId), "64_64", ImageLocation.getForPhoto(closestPhotoSizeWithSize != closestPhotoSizeWithSize2 ? closestPhotoSizeWithSize2 : null, 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 i5 = dp2;
int dp4 = AndroidUtilities.dp(18.0f);
if (tL_pageRelatedArticle.title != null) {
i3 = dp;
this.textLayout = ArticleViewer.this.createLayoutForText(this, tL_pageRelatedArticle.title, null, i5, 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 i6 = 4 - lineCount;
this.textOffset = this.textLayout.getHeight() + AndroidUtilities.dp(6.0f) + this.additionalHeight;
dp4 += this.textLayout.getHeight();
int i7 = 0;
while (true) {
if (i7 >= lineCount) {
z = false;
break;
} else {
if (this.textLayout.getLineLeft(i7) != 0.0f) {
z = true;
break;
}
i7++;
}
}
i4 = i6;
} 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(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(tL_pageRelatedArticle.published_date * 1000);
} else if (!TextUtils.isEmpty(tL_pageRelatedArticle.description)) {
str = tL_pageRelatedArticle.description;
} else {
str = tL_pageRelatedArticle.url;
}
String str2 = str;
ArticleViewer articleViewer = ArticleViewer.this;
DrawingText createLayoutForText = articleViewer.createLayoutForText(this, str2, null, i5, 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));
}
@Override
protected void onDraw(Canvas canvas) {
if (this.currentBlock == null) {
return;
}
if (this.drawImage) {
this.imageView.draw(canvas);
}
canvas.save();
canvas.translate(this.textX, AndroidUtilities.dp(10.0f));
DrawingText drawingText = this.textLayout;
if (drawingText != null) {
drawingText.draw(canvas);
}
if (this.textLayout2 != null) {
canvas.translate(0.0f, this.textOffset);
this.textLayout2.draw(canvas);
}
canvas.restore();
if (this.divider) {
canvas.drawLine(ArticleViewer.this.isRtl ? 0.0f : AndroidUtilities.dp(17.0f), getMeasuredHeight() - 1, getMeasuredWidth() - (ArticleViewer.this.isRtl ? AndroidUtilities.dp(17.0f) : 0), getMeasuredHeight() - 1, ArticleViewer.dividerPaint);
}
}
}
public class BlockHeaderCell extends View {
private TLRPC.TL_pageBlockHeader currentBlock;
private WebpageAdapter parentAdapter;
private DrawingText textLayout;
private int textX;
private int textY;
public BlockHeaderCell(Context context, WebpageAdapter webpageAdapter) {
super(context);
this.textX = AndroidUtilities.dp(18.0f);
this.textY = AndroidUtilities.dp(8.0f);
this.parentAdapter = webpageAdapter;
}
public void setBlock(TLRPC.TL_pageBlockHeader tL_pageBlockHeader) {
this.currentBlock = tL_pageBlockHeader;
requestLayout();
}
@Override
public boolean onTouchEvent(MotionEvent motionEvent) {
return ArticleViewer.this.checkLayoutForLinks(motionEvent, this, this.textLayout, this.textX, this.textY) || super.onTouchEvent(motionEvent);
}
@Override
protected 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(this, (CharSequence) null, tL_pageBlockHeader.text, size - AndroidUtilities.dp(36.0f), this.currentBlock, ArticleViewer.this.isRtl ? StaticLayoutEx.ALIGN_RIGHT() : Layout.Alignment.ALIGN_NORMAL, this.parentAdapter);
this.textLayout = createLayoutForText;
if (createLayoutForText != null) {
i3 = 0 + AndroidUtilities.dp(16.0f) + this.textLayout.getHeight();
}
} else {
i3 = 1;
}
setMeasuredDimension(size, i3);
}
@Override
protected void onDraw(Canvas canvas) {
if (this.currentBlock == null || this.textLayout == null) {
return;
}
canvas.save();
canvas.translate(this.textX, this.textY);
this.textLayout.draw(canvas);
canvas.restore();
}
@Override
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo accessibilityNodeInfo) {
super.onInitializeAccessibilityNodeInfo(accessibilityNodeInfo);
accessibilityNodeInfo.setEnabled(true);
if (this.textLayout == null) {
return;
}
accessibilityNodeInfo.setText(((Object) this.textLayout.getText()) + ", " + LocaleController.getString("AccDescrIVHeading", R.string.AccDescrIVHeading));
}
}
public class BlockDividerCell extends View {
private RectF rect;
public BlockDividerCell(Context context) {
super(context);
this.rect = new RectF();
}
@Override
protected void onMeasure(int i, int i2) {
setMeasuredDimension(View.MeasureSpec.getSize(i), AndroidUtilities.dp(18.0f));
}
@Override
protected void onDraw(Canvas canvas) {
this.rect.set(getMeasuredWidth() / 3, AndroidUtilities.dp(8.0f), r0 * 2, AndroidUtilities.dp(10.0f));
canvas.drawRoundRect(this.rect, AndroidUtilities.dp(1.0f), AndroidUtilities.dp(1.0f), ArticleViewer.dividerPaint);
}
}
public class BlockSubtitleCell extends View {
private TLRPC.TL_pageBlockSubtitle currentBlock;
private WebpageAdapter parentAdapter;
private DrawingText textLayout;
private int textX;
private int textY;
public BlockSubtitleCell(Context context, WebpageAdapter webpageAdapter) {
super(context);
this.textX = AndroidUtilities.dp(18.0f);
this.textY = AndroidUtilities.dp(8.0f);
this.parentAdapter = webpageAdapter;
}
public void setBlock(TLRPC.TL_pageBlockSubtitle tL_pageBlockSubtitle) {
this.currentBlock = tL_pageBlockSubtitle;
requestLayout();
}
@Override
public boolean onTouchEvent(MotionEvent motionEvent) {
return ArticleViewer.this.checkLayoutForLinks(motionEvent, this, this.textLayout, this.textX, this.textY) || super.onTouchEvent(motionEvent);
}
@Override
protected 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(this, (CharSequence) null, tL_pageBlockSubtitle.text, size - AndroidUtilities.dp(36.0f), this.currentBlock, ArticleViewer.this.isRtl ? StaticLayoutEx.ALIGN_RIGHT() : Layout.Alignment.ALIGN_NORMAL, this.parentAdapter);
this.textLayout = createLayoutForText;
if (createLayoutForText != null) {
i3 = 0 + AndroidUtilities.dp(16.0f) + this.textLayout.getHeight();
}
} else {
i3 = 1;
}
setMeasuredDimension(size, i3);
}
@Override
protected void onDraw(Canvas canvas) {
if (this.currentBlock == null || this.textLayout == null) {
return;
}
canvas.save();
canvas.translate(this.textX, this.textY);
this.textLayout.draw(canvas);
canvas.restore();
}
@Override
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo accessibilityNodeInfo) {
super.onInitializeAccessibilityNodeInfo(accessibilityNodeInfo);
accessibilityNodeInfo.setEnabled(true);
if (this.textLayout == null) {
return;
}
accessibilityNodeInfo.setText(((Object) this.textLayout.getText()) + ", " + LocaleController.getString("AccDescrIVHeading", R.string.AccDescrIVHeading));
}
}
public class BlockPullquoteCell extends View {
private TLRPC.TL_pageBlockPullquote currentBlock;
private WebpageAdapter parentAdapter;
private DrawingText textLayout;
private DrawingText textLayout2;
private int textX;
private int textY;
private int textY2;
public BlockPullquoteCell(Context context, WebpageAdapter webpageAdapter) {
super(context);
this.textX = AndroidUtilities.dp(18.0f);
this.textY = AndroidUtilities.dp(8.0f);
this.parentAdapter = webpageAdapter;
}
public void setBlock(TLRPC.TL_pageBlockPullquote tL_pageBlockPullquote) {
this.currentBlock = tL_pageBlockPullquote;
requestLayout();
}
@Override
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);
}
@Override
protected 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 = createLayoutForText != null ? 0 + AndroidUtilities.dp(8.0f) + this.textLayout.getHeight() : 0;
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);
}
@Override
protected void onDraw(Canvas canvas) {
if (this.currentBlock == null) {
return;
}
if (this.textLayout != null) {
canvas.save();
canvas.translate(this.textX, this.textY);
this.textLayout.draw(canvas);
canvas.restore();
}
if (this.textLayout2 != null) {
canvas.save();
canvas.translate(this.textX, this.textY2);
this.textLayout2.draw(canvas);
canvas.restore();
}
}
}
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;
private int textY2;
public BlockBlockquoteCell(Context context, WebpageAdapter webpageAdapter) {
super(context);
this.textY = AndroidUtilities.dp(8.0f);
this.parentAdapter = webpageAdapter;
}
public void setBlock(TLRPC.TL_pageBlockBlockquote tL_pageBlockBlockquote) {
this.currentBlock = tL_pageBlockBlockquote;
requestLayout();
}
@Override
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);
}
@Override
protected 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(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((this.currentBlock.level * 14) + 14);
} else {
this.textX = AndroidUtilities.dp(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);
}
@Override
protected void onDraw(Canvas canvas) {
if (this.currentBlock == null) {
return;
}
if (this.textLayout != null) {
canvas.save();
canvas.translate(this.textX, this.textY);
this.textLayout.draw(canvas);
canvas.restore();
}
if (this.textLayout2 != null) {
canvas.save();
canvas.translate(this.textX, this.textY2);
this.textLayout2.draw(canvas);
canvas.restore();
}
if (!ArticleViewer.this.isRtl) {
canvas.drawRect(AndroidUtilities.dp((this.currentBlock.level * 14) + 18), AndroidUtilities.dp(6.0f), AndroidUtilities.dp((this.currentBlock.level * 14) + 20), getMeasuredHeight() - AndroidUtilities.dp(6.0f), ArticleViewer.quoteLinePaint);
} else {
canvas.drawRect(getMeasuredWidth() - AndroidUtilities.dp(20.0f), AndroidUtilities.dp(6.0f), r0 + AndroidUtilities.dp(2.0f), getMeasuredHeight() - AndroidUtilities.dp(6.0f), ArticleViewer.quoteLinePaint);
}
if (this.currentBlock.level > 0) {
canvas.drawRect(AndroidUtilities.dp(18.0f), 0.0f, AndroidUtilities.dp(20.0f), getMeasuredHeight() - (this.currentBlock.bottom ? AndroidUtilities.dp(6.0f) : 0), ArticleViewer.quoteLinePaint);
}
}
}
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;
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
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.imageView = new ImageReceiver(this);
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)) {
return;
}
this.channelCell.setBlock(ArticleViewer.this.channelBlock);
this.channelCell.setVisibility(0);
}
public View getChannelCell() {
return this.channelCell;
}
@Override
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() + AndroidUtilities.dp(39.0f)) {
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;
}
if (motionEvent.getAction() == 0 && this.imageView.isInsideImage(x, y)) {
if (this.buttonState != -1) {
if (x >= this.buttonX && x <= r2 + AndroidUtilities.dp(48.0f)) {
if (y >= this.buttonY) {
}
}
}
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;
}
return 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);
}
@Override
protected void onMeasure(int i, int i2) {
int i3;
int i4;
TLRPC.TL_pageBlockPhoto tL_pageBlockPhoto;
int dp;
int i5;
int i6;
int i7;
int i8;
int i9;
int i10;
int i11;
int size = View.MeasureSpec.getSize(i);
int i12 = this.currentType;
boolean z = false;
int i13 = 1;
if (i12 == 1) {
size = ((View) getParent()).getMeasuredWidth();
i4 = ((View) getParent()).getMeasuredHeight();
} else if (i12 == 2) {
i4 = (int) Math.ceil(this.groupPosition.ph * 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 dp2 = AndroidUtilities.dp(48.0f);
if (this.currentType == 0 && this.currentBlock.level > 0) {
i6 = AndroidUtilities.dp(this.currentBlock.level * 14) + AndroidUtilities.dp(18.0f);
this.textX = i6;
i5 = i3 - (AndroidUtilities.dp(18.0f) + i6);
dp = i5;
} else {
this.textX = AndroidUtilities.dp(18.0f);
dp = i3 - AndroidUtilities.dp(36.0f);
i5 = i3;
i6 = 0;
}
TLRPC.Photo photo = this.currentPhoto;
if (photo == null || this.currentPhotoObject == null) {
i7 = i4;
} else {
TLRPC.PhotoSize closestPhotoSizeWithSize = FileLoader.getClosestPhotoSizeWithSize(photo.sizes, 40, true);
this.currentPhotoObjectThumb = closestPhotoSizeWithSize;
if (this.currentPhotoObject == closestPhotoSizeWithSize) {
this.currentPhotoObjectThumb = null;
}
int i14 = this.currentType;
if (i14 == 0) {
i4 = (int) ((i5 / this.currentPhotoObject.w) * this.currentPhotoObject.h);
if (!(this.parentBlock instanceof TLRPC.TL_pageBlockCover)) {
int max = (int) ((Math.max(ArticleViewer.this.listView[0].getMeasuredWidth(), ArticleViewer.this.listView[0].getMeasuredHeight()) - AndroidUtilities.dp(56.0f)) * 0.9f);
if (i4 > max) {
i5 = (int) ((max / this.currentPhotoObject.h) * this.currentPhotoObject.w);
i6 += ((i3 - i6) - i5) / 2;
i4 = max;
}
} else {
i4 = Math.min(i4, i5);
}
} else if (i14 == 2) {
if ((this.groupPosition.flags & 2) == 0) {
i5 -= AndroidUtilities.dp(2.0f);
}
int dp3 = (this.groupPosition.flags & 8) == 0 ? i4 - AndroidUtilities.dp(2.0f) : i4;
if (this.groupPosition.leftSpanOffset != 0) {
int ceil = (int) Math.ceil((this.groupPosition.leftSpanOffset * i3) / 1000.0f);
i5 -= ceil;
i6 += ceil;
}
int i15 = i6;
i8 = i4;
i4 = dp3;
i9 = i5;
i10 = i15;
this.imageView.setImageCoords(i10, (!this.isFirst || (i11 = this.currentType) == 1 || i11 == 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) (this.imageView.getImageX() + ((this.imageView.getImageWidth() - dp2) / 2.0f));
int imageY = (int) (this.imageView.getImageY() + ((this.imageView.getImageHeight() - dp2) / 2.0f));
this.buttonY = imageY;
RadialProgress2 radialProgress2 = this.radialProgress;
int i16 = this.buttonX;
radialProgress2.setProgressRect(i16, imageY, i16 + dp2, dp2 + imageY);
i7 = i8;
}
i9 = i5;
i10 = i6;
i8 = i4;
this.imageView.setImageCoords(i10, (!this.isFirst || (i11 = this.currentType) == 1 || i11 == 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) (this.imageView.getImageX() + ((this.imageView.getImageWidth() - dp2) / 2.0f));
int imageY2 = (int) (this.imageView.getImageY() + ((this.imageView.getImageHeight() - dp2) / 2.0f));
this.buttonY = imageY2;
RadialProgress2 radialProgress22 = this.radialProgress;
int i162 = this.buttonX;
radialProgress22.setProgressRect(i162, imageY2, i162 + dp2, dp2 + imageY2);
i7 = i8;
}
if (this.currentType == 0) {
DrawingText createLayoutForText = ArticleViewer.this.createLayoutForText(this, null, this.currentBlock.caption.text, dp, this.currentBlock, this.parentAdapter);
this.captionLayout = createLayoutForText;
if (createLayoutForText != null) {
int dp4 = AndroidUtilities.dp(4.0f) + this.captionLayout.getHeight();
this.creditOffset = dp4;
i7 += dp4 + AndroidUtilities.dp(4.0f);
}
DrawingText createLayoutForText2 = ArticleViewer.this.createLayoutForText(this, (CharSequence) null, this.currentBlock.caption.credit, dp, this.currentBlock, ArticleViewer.this.isRtl ? StaticLayoutEx.ALIGN_RIGHT() : Layout.Alignment.ALIGN_NORMAL, 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.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) {
i7 += AndroidUtilities.dp(8.0f);
}
i13 = i7;
}
this.channelCell.measure(i, i2);
this.channelCell.setTranslationY(this.imageView.getImageHeight() - AndroidUtilities.dp(39.0f));
setMeasuredDimension(i3, i13);
}
i3 = size;
tL_pageBlockPhoto = this.currentBlock;
if (tL_pageBlockPhoto != null) {
}
this.channelCell.measure(i, i2);
this.channelCell.setTranslationY(this.imageView.getImageHeight() - AndroidUtilities.dp(39.0f));
setMeasuredDimension(i3, i13);
}
@Override
protected void onDraw(Canvas canvas) {
if (this.currentBlock == null) {
return;
}
if (!this.imageView.hasBitmapImage() || this.imageView.getCurrentAlpha() != 1.0f) {
canvas.drawRect(this.imageView.getImageX(), this.imageView.getImageY(), this.imageView.getImageX2(), 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(this.textX, this.textY);
this.captionLayout.draw(canvas);
canvas.restore();
}
if (this.creditLayout != null) {
canvas.save();
canvas.translate(this.textX, this.textY + this.creditOffset);
this.creditLayout.draw(canvas);
canvas.restore();
}
if (this.currentBlock.level > 0) {
canvas.drawRect(AndroidUtilities.dp(18.0f), 0.0f, AndroidUtilities.dp(20.0f), 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();
return;
}
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);
return;
}
if (exists) {
DownloadController.getInstance(ArticleViewer.this.currentAccount).removeLoadingFileObserver(this);
this.buttonState = -1;
this.radialProgress.setIcon(getIconForCurrentState(), false, z);
invalidate();
return;
}
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();
}
@Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
this.imageView.onDetachedFromWindow();
DownloadController.getInstance(ArticleViewer.this.currentAccount).removeLoadingFileObserver(this);
}
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
this.imageView.onAttachedToWindow();
updateButtonState(false);
}
@Override
public void onFailedDownload(String str, boolean z) {
updateButtonState(false);
}
@Override
public void onSuccessDownload(String str) {
this.radialProgress.setProgress(1.0f, true);
updateButtonState(true);
}
@Override
public void onProgressDownload(String str, float f) {
this.radialProgress.setProgress(f, true);
if (this.buttonState != 1) {
updateButtonState(true);
}
}
@Override
public int getObserverTag() {
return this.TAG;
}
@Override
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());
}
}
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;
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.imageView = new ImageReceiver(this);
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();
}
@Override
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;
ArticleViewer.this.parentActivity.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;
}
return 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);
}
@Override
protected void onMeasure(int i, int i2) {
int i3;
int dp;
int i4;
int i5;
int i6;
int i7;
int max;
int size = View.MeasureSpec.getSize(i);
int i8 = this.currentType;
int i9 = 1;
if (i8 == 1) {
i3 = ((View) getParent()).getMeasuredWidth();
size = ((View) getParent()).getMeasuredHeight();
} else {
i3 = size;
if (i8 != 2) {
size = 0;
}
}
TLRPC.TL_pageBlockMap tL_pageBlockMap = this.currentBlock;
if (tL_pageBlockMap != null) {
if (this.currentType == 0 && tL_pageBlockMap.level > 0) {
i5 = AndroidUtilities.dp(this.currentBlock.level * 14) + AndroidUtilities.dp(18.0f);
this.textX = i5;
i4 = i3 - (AndroidUtilities.dp(18.0f) + i5);
dp = i4;
} else {
this.textX = AndroidUtilities.dp(18.0f);
dp = i3 - AndroidUtilities.dp(36.0f);
i4 = i3;
i5 = 0;
}
if (this.currentType != 0 || (size = (int) ((i4 / this.currentBlock.w) * this.currentBlock.h)) <= (max = (int) ((Math.max(ArticleViewer.this.listView[0].getMeasuredWidth(), ArticleViewer.this.listView[0].getMeasuredHeight()) - AndroidUtilities.dp(56.0f)) * 0.9f))) {
i6 = size;
} else {
i4 = (int) ((max / this.currentBlock.h) * this.currentBlock.w);
i5 += ((i3 - i5) - i4) / 2;
i6 = max;
}
this.imageView.setImageCoords(i5, (this.isFirst || (i7 = this.currentType) == 1 || i7 == 2 || this.currentBlock.level > 0) ? 0 : AndroidUtilities.dp(8.0f), i4, i6);
float f = i4;
float f2 = i6;
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(AndroidUtilities.density)));
int i10 = MessagesController.getInstance(ArticleViewer.this.currentAccount).mapProvider;
this.currentMapProvider = i10;
if (i10 == 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, dp, this.currentBlock, this.parentAdapter);
this.captionLayout = createLayoutForText;
if (createLayoutForText != null) {
int dp2 = AndroidUtilities.dp(4.0f) + this.captionLayout.getHeight();
this.creditOffset = dp2;
i6 += dp2 + AndroidUtilities.dp(4.0f);
}
DrawingText createLayoutForText2 = ArticleViewer.this.createLayoutForText(this, (CharSequence) null, this.currentBlock.caption.credit, dp, this.currentBlock, ArticleViewer.this.isRtl ? StaticLayoutEx.ALIGN_RIGHT() : Layout.Alignment.ALIGN_NORMAL, this.parentAdapter);
this.creditLayout = createLayoutForText2;
if (createLayoutForText2 != null) {
i6 += AndroidUtilities.dp(4.0f) + this.creditLayout.getHeight();
}
}
if (!this.isFirst && this.currentType == 0 && this.currentBlock.level <= 0) {
i6 += AndroidUtilities.dp(8.0f);
}
if (this.currentType != 2) {
i6 += AndroidUtilities.dp(8.0f);
}
i9 = i6;
}
setMeasuredDimension(i3, i9);
}
@Override
protected void onDraw(Canvas canvas) {
if (this.currentBlock == null) {
return;
}
this.imageView.draw(canvas);
if (this.currentMapProvider == 2 && this.imageView.hasNotThumb()) {
int intrinsicWidth = (int) (Theme.chat_redLocationIcon.getIntrinsicWidth() * 0.8f);
int intrinsicHeight = (int) (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(this.textX, this.textY);
this.captionLayout.draw(canvas);
canvas.restore();
}
if (this.creditLayout != null) {
canvas.save();
canvas.translate(this.textX, this.textY + this.creditOffset);
this.creditLayout.draw(canvas);
canvas.restore();
}
if (this.currentBlock.level > 0) {
canvas.drawRect(AndroidUtilities.dp(18.0f), 0.0f, AndroidUtilities.dp(20.0f), getMeasuredHeight() - (this.currentBlock.bottom ? AndroidUtilities.dp(6.0f) : 0), ArticleViewer.quoteLinePaint);
}
}
@Override
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());
}
}
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;
private int textX2;
private int textY;
public BlockChannelCell(Context context, WebpageAdapter webpageAdapter, int i) {
super(context);
this.textX = AndroidUtilities.dp(18.0f);
this.textY = AndroidUtilities.dp(11.0f);
this.parentAdapter = webpageAdapter;
setWillNotDraw(false);
this.backgroundPaint = new Paint();
this.currentType = i;
TextView textView = new TextView(context);
this.textView = textView;
textView.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() {
@Override
public final void onClick(View view) {
ArticleViewer.BlockChannelCell.this.lambda$new$0$ArticleViewer$BlockChannelCell(view);
}
});
ImageView imageView = new ImageView(context);
this.imageView = imageView;
imageView.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 void lambda$new$0$ArticleViewer$BlockChannelCell(View view) {
if (this.currentState != 0) {
return;
}
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(0, false);
} else {
setState(4, false);
}
}
requestLayout();
}
public void setState(int i, boolean z) {
AnimatorSet animatorSet = this.currentAnimation;
if (animatorSet != null) {
animatorSet.cancel();
}
this.currentState = i;
if (z) {
AnimatorSet animatorSet2 = new AnimatorSet();
this.currentAnimation = animatorSet2;
Animator[] animatorArr = new Animator[9];
TextView textView = this.textView;
Property property = View.ALPHA;
float[] fArr = new float[1];
fArr[0] = i == 0 ? 1.0f : 0.0f;
animatorArr[0] = ObjectAnimator.ofFloat(textView, (Property<TextView, Float>) property, fArr);
TextView textView2 = this.textView;
Property property2 = View.SCALE_X;
float[] fArr2 = new float[1];
fArr2[0] = i == 0 ? 1.0f : 0.1f;
animatorArr[1] = ObjectAnimator.ofFloat(textView2, (Property<TextView, Float>) property2, fArr2);
TextView textView3 = this.textView;
Property property3 = View.SCALE_Y;
float[] fArr3 = new float[1];
fArr3[0] = i == 0 ? 1.0f : 0.1f;
animatorArr[2] = ObjectAnimator.ofFloat(textView3, (Property<TextView, Float>) 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, (Property<ContextProgressView, Float>) 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, (Property<ContextProgressView, Float>) 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, (Property<ContextProgressView, Float>) property6, fArr6);
ImageView imageView = this.imageView;
Property property7 = View.ALPHA;
float[] fArr7 = new float[1];
fArr7[0] = i == 2 ? 1.0f : 0.0f;
animatorArr[6] = ObjectAnimator.ofFloat(imageView, (Property<ImageView, Float>) property7, fArr7);
ImageView imageView2 = this.imageView;
Property property8 = View.SCALE_X;
float[] fArr8 = new float[1];
fArr8[0] = i == 2 ? 1.0f : 0.1f;
animatorArr[7] = ObjectAnimator.ofFloat(imageView2, (Property<ImageView, Float>) property8, fArr8);
ImageView imageView3 = this.imageView;
Property property9 = View.SCALE_Y;
float[] fArr9 = new float[1];
fArr9[0] = i == 2 ? 1.0f : 0.1f;
animatorArr[8] = ObjectAnimator.ofFloat(imageView3, (Property<ImageView, Float>) 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);
this.imageView.setAlpha(i == 2 ? 1.0f : 0.0f);
this.imageView.setScaleX(i == 2 ? 1.0f : 0.1f);
this.imageView.setScaleY(i == 2 ? 1.0f : 0.1f);
}
@Override
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);
}
@Override
protected 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(this, tL_pageBlockChannel.channel.title, (TLRPC.RichText) null, (size - AndroidUtilities.dp(52.0f)) - this.buttonWidth, this.currentBlock, StaticLayoutEx.ALIGN_LEFT(), this.parentAdapter);
if (ArticleViewer.this.isRtl) {
this.textX2 = this.textX;
} else {
this.textX2 = (getMeasuredWidth() - this.textX) - this.buttonWidth;
}
}
}
@Override
protected 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 textView = this.textView;
int i5 = this.textX2;
textView.layout(i5, 0, textView.getMeasuredWidth() + i5, this.textView.getMeasuredHeight());
}
@Override
protected void onDraw(Canvas canvas) {
if (this.currentBlock == null) {
return;
}
canvas.drawRect(0.0f, 0.0f, getMeasuredWidth(), AndroidUtilities.dp(39.0f), this.backgroundPaint);
DrawingText drawingText = this.textLayout;
if (drawingText == null || drawingText.getLineCount() <= 0) {
return;
}
canvas.save();
if (ArticleViewer.this.isRtl) {
canvas.translate((getMeasuredWidth() - this.textLayout.getLineWidth(0)) - this.textX, this.textY);
} else {
canvas.translate(this.textX, this.textY);
}
this.textLayout.draw(canvas);
canvas.restore();
}
}
public class BlockAuthorDateCell extends View {
private TLRPC.TL_pageBlockAuthorDate currentBlock;
private WebpageAdapter parentAdapter;
private DrawingText textLayout;
private int textX;
private int textY;
public BlockAuthorDateCell(Context context, WebpageAdapter webpageAdapter) {
super(context);
this.textY = AndroidUtilities.dp(8.0f);
this.parentAdapter = webpageAdapter;
}
public void setBlock(TLRPC.TL_pageBlockAuthorDate tL_pageBlockAuthorDate) {
this.currentBlock = tL_pageBlockAuthorDate;
requestLayout();
}
@Override
public boolean onTouchEvent(MotionEvent motionEvent) {
return ArticleViewer.this.checkLayoutForLinks(motionEvent, this, this.textLayout, this.textX, this.textY) || super.onTouchEvent(motionEvent);
}
@Override
protected void onMeasure(int i, int i2) {
Spannable spannable;
CharSequence charSequence;
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 spannable2 = (Spannable) text;
metricAffectingSpanArr = (MetricAffectingSpan[]) spannable2.getSpans(0, text.length(), MetricAffectingSpan.class);
spannable = spannable2;
} else {
spannable = null;
}
if (this.currentBlock.published_date != 0 && !TextUtils.isEmpty(text)) {
charSequence = LocaleController.formatString("ArticleDateByAuthor", R.string.ArticleDateByAuthor, LocaleController.getInstance().chatFullDate.format(this.currentBlock.published_date * 1000), text);
} else if (!TextUtils.isEmpty(text)) {
charSequence = LocaleController.formatString("ArticleByAuthor", R.string.ArticleByAuthor, text);
} else {
charSequence = LocaleController.getInstance().chatFullDate.format(this.currentBlock.published_date * 1000);
}
if (metricAffectingSpanArr != null) {
try {
if (metricAffectingSpanArr.length > 0 && (indexOf = TextUtils.indexOf((CharSequence) charSequence, text)) != -1) {
charSequence = Spannable.Factory.getInstance().newSpannable(charSequence);
for (int i4 = 0; i4 < metricAffectingSpanArr.length; i4++) {
charSequence.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, charSequence, 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((size - this.textLayout.getLineWidth(0)) - AndroidUtilities.dp(16.0f));
} else {
this.textX = AndroidUtilities.dp(18.0f);
}
i3 = dp;
} else {
i3 = 0;
}
}
setMeasuredDimension(size, i3);
}
@Override
protected void onDraw(Canvas canvas) {
if (this.currentBlock == null || this.textLayout == null) {
return;
}
canvas.save();
canvas.translate(this.textX, this.textY);
this.textLayout.draw(canvas);
canvas.restore();
}
@Override
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo accessibilityNodeInfo) {
super.onInitializeAccessibilityNodeInfo(accessibilityNodeInfo);
accessibilityNodeInfo.setEnabled(true);
DrawingText drawingText = this.textLayout;
if (drawingText == null) {
return;
}
accessibilityNodeInfo.setText(drawingText.getText());
}
}
public class BlockTitleCell extends View {
private TLRPC.TL_pageBlockTitle currentBlock;
private WebpageAdapter parentAdapter;
private DrawingText textLayout;
private int textX;
private int textY;
public BlockTitleCell(Context context, WebpageAdapter webpageAdapter) {
super(context);
this.textX = AndroidUtilities.dp(18.0f);
this.parentAdapter = webpageAdapter;
}
public void setBlock(TLRPC.TL_pageBlockTitle tL_pageBlockTitle) {
this.currentBlock = tL_pageBlockTitle;
requestLayout();
}
@Override
public boolean onTouchEvent(MotionEvent motionEvent) {
return ArticleViewer.this.checkLayoutForLinks(motionEvent, this, this.textLayout, this.textX, this.textY) || super.onTouchEvent(motionEvent);
}
@Override
protected 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(this, (CharSequence) null, tL_pageBlockTitle.text, size - AndroidUtilities.dp(36.0f), this.currentBlock, ArticleViewer.this.isRtl ? StaticLayoutEx.ALIGN_RIGHT() : Layout.Alignment.ALIGN_NORMAL, this.parentAdapter);
this.textLayout = createLayoutForText;
i3 = createLayoutForText != null ? 0 + AndroidUtilities.dp(16.0f) + this.textLayout.getHeight() : 0;
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);
}
@Override
protected void onDraw(Canvas canvas) {
if (this.currentBlock == null || this.textLayout == null) {
return;
}
canvas.save();
canvas.translate(this.textX, this.textY);
this.textLayout.draw(canvas);
canvas.restore();
}
@Override
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo accessibilityNodeInfo) {
super.onInitializeAccessibilityNodeInfo(accessibilityNodeInfo);
accessibilityNodeInfo.setEnabled(true);
if (this.textLayout == null) {
return;
}
accessibilityNodeInfo.setText(((Object) this.textLayout.getText()) + ", " + LocaleController.getString("AccDescrIVTitle", R.string.AccDescrIVTitle));
}
}
public class BlockKickerCell extends View {
private TLRPC.TL_pageBlockKicker currentBlock;
private WebpageAdapter parentAdapter;
private DrawingText textLayout;
private int textX;
private int textY;
public BlockKickerCell(Context context, WebpageAdapter webpageAdapter) {
super(context);
this.textX = AndroidUtilities.dp(18.0f);
this.parentAdapter = webpageAdapter;
}
public void setBlock(TLRPC.TL_pageBlockKicker tL_pageBlockKicker) {
this.currentBlock = tL_pageBlockKicker;
requestLayout();
}
@Override
public boolean onTouchEvent(MotionEvent motionEvent) {
return ArticleViewer.this.checkLayoutForLinks(motionEvent, this, this.textLayout, this.textX, this.textY) || super.onTouchEvent(motionEvent);
}
@Override
protected 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(this, (CharSequence) null, tL_pageBlockKicker.text, size - AndroidUtilities.dp(36.0f), this.currentBlock, ArticleViewer.this.isRtl ? StaticLayoutEx.ALIGN_RIGHT() : Layout.Alignment.ALIGN_NORMAL, this.parentAdapter);
this.textLayout = createLayoutForText;
i3 = createLayoutForText != null ? 0 + AndroidUtilities.dp(16.0f) + this.textLayout.getHeight() : 0;
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);
}
@Override
protected void onDraw(Canvas canvas) {
if (this.currentBlock == null || this.textLayout == null) {
return;
}
canvas.save();
canvas.translate(this.textX, this.textY);
this.textLayout.draw(canvas);
canvas.restore();
}
}
public class BlockFooterCell extends View {
private TLRPC.TL_pageBlockFooter currentBlock;
private WebpageAdapter parentAdapter;
private DrawingText textLayout;
private int textX;
private int textY;
public BlockFooterCell(Context context, WebpageAdapter webpageAdapter) {
super(context);
this.textX = AndroidUtilities.dp(18.0f);
this.textY = AndroidUtilities.dp(8.0f);
this.parentAdapter = webpageAdapter;
}
public void setBlock(TLRPC.TL_pageBlockFooter tL_pageBlockFooter) {
this.currentBlock = tL_pageBlockFooter;
requestLayout();
}
@Override
public boolean onTouchEvent(MotionEvent motionEvent) {
return ArticleViewer.this.checkLayoutForLinks(motionEvent, this, this.textLayout, this.textX, this.textY) || super.onTouchEvent(motionEvent);
}
@Override
protected void onMeasure(int i, int i2) {
int dp;
int size = View.MeasureSpec.getSize(i);
TLRPC.TL_pageBlockFooter tL_pageBlockFooter = this.currentBlock;
int i3 = 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((this.currentBlock.level * 14) + 18);
}
DrawingText createLayoutForText = ArticleViewer.this.createLayoutForText(this, (CharSequence) null, this.currentBlock.text, (size - AndroidUtilities.dp(18.0f)) - this.textX, this.currentBlock, ArticleViewer.this.isRtl ? StaticLayoutEx.ALIGN_RIGHT() : Layout.Alignment.ALIGN_NORMAL, this.parentAdapter);
this.textLayout = createLayoutForText;
if (createLayoutForText != null) {
int height = createLayoutForText.getHeight();
if (this.currentBlock.level > 0) {
dp = AndroidUtilities.dp(8.0f);
} else {
dp = AndroidUtilities.dp(16.0f);
}
i3 = dp + height;
}
} else {
i3 = 1;
}
setMeasuredDimension(size, i3);
}
@Override
protected void onDraw(Canvas canvas) {
if (this.currentBlock == null) {
return;
}
if (this.textLayout != null) {
canvas.save();
canvas.translate(this.textX, this.textY);
this.textLayout.draw(canvas);
canvas.restore();
}
if (this.currentBlock.level > 0) {
canvas.drawRect(AndroidUtilities.dp(18.0f), 0.0f, AndroidUtilities.dp(20.0f), getMeasuredHeight() - (this.currentBlock.bottom ? AndroidUtilities.dp(6.0f) : 0), ArticleViewer.quoteLinePaint);
}
}
}
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;
HorizontalScrollView horizontalScrollView = new HorizontalScrollView(context) {
@Override
public boolean onInterceptTouchEvent(MotionEvent motionEvent) {
if (BlockPreformattedCell.this.textContainer.getMeasuredWidth() > getMeasuredWidth()) {
ArticleViewer.this.windowView.requestDisallowInterceptTouchEvent(true);
}
return super.onInterceptTouchEvent(motionEvent);
}
@Override
protected 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 = horizontalScrollView;
horizontalScrollView.setPadding(0, AndroidUtilities.dp(8.0f), 0, AndroidUtilities.dp(8.0f));
addView(this.scrollView, LayoutHelper.createFrame(-1, -2.0f));
this.textContainer = new View(context) {
@Override
protected 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(BlockPreformattedCell.this.textLayout.getLineWidth(i3)), i4);
i3++;
}
i3 = height;
}
} else {
i3 = 1;
}
setMeasuredDimension(i4 + AndroidUtilities.dp(32.0f), i3);
}
@Override
protected 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();
}
@Override
protected 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());
}
@Override
protected void onDraw(Canvas canvas) {
if (this.currentBlock == null) {
return;
}
canvas.drawRect(0.0f, AndroidUtilities.dp(8.0f), getMeasuredWidth(), getMeasuredHeight() - AndroidUtilities.dp(8.0f), ArticleViewer.preformattedBackgroundPaint);
}
}
public class BlockSubheaderCell extends View {
private TLRPC.TL_pageBlockSubheader currentBlock;
private WebpageAdapter parentAdapter;
private DrawingText textLayout;
private int textX;
private int textY;
public BlockSubheaderCell(Context context, WebpageAdapter webpageAdapter) {
super(context);
this.textX = AndroidUtilities.dp(18.0f);
this.textY = AndroidUtilities.dp(8.0f);
this.parentAdapter = webpageAdapter;
}
public void setBlock(TLRPC.TL_pageBlockSubheader tL_pageBlockSubheader) {
this.currentBlock = tL_pageBlockSubheader;
requestLayout();
}
@Override
public boolean onTouchEvent(MotionEvent motionEvent) {
return ArticleViewer.this.checkLayoutForLinks(motionEvent, this, this.textLayout, this.textX, this.textY) || super.onTouchEvent(motionEvent);
}
@Override
protected 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(this, (CharSequence) null, tL_pageBlockSubheader.text, size - AndroidUtilities.dp(36.0f), this.currentBlock, ArticleViewer.this.isRtl ? StaticLayoutEx.ALIGN_RIGHT() : Layout.Alignment.ALIGN_NORMAL, this.parentAdapter);
this.textLayout = createLayoutForText;
if (createLayoutForText != null) {
i3 = 0 + AndroidUtilities.dp(16.0f) + this.textLayout.getHeight();
}
} else {
i3 = 1;
}
setMeasuredDimension(size, i3);
}
@Override
protected void onDraw(Canvas canvas) {
if (this.currentBlock == null || this.textLayout == null) {
return;
}
canvas.save();
canvas.translate(this.textX, this.textY);
this.textLayout.draw(canvas);
canvas.restore();
}
@Override
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo accessibilityNodeInfo) {
super.onInitializeAccessibilityNodeInfo(accessibilityNodeInfo);
accessibilityNodeInfo.setEnabled(true);
if (this.textLayout == null) {
return;
}
accessibilityNodeInfo.setText(((Object) this.textLayout.getText()) + ", " + LocaleController.getString("AccDescrIVHeading", R.string.AccDescrIVHeading));
}
}
public class LinkMovementMethodMy extends LinkMovementMethod {
private LinkMovementMethodMy() {
}
@Override
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;
}
}
}
public class PhotoBackgroundDrawable extends ColorDrawable {
private Runnable drawRunnable;
public PhotoBackgroundDrawable(int i) {
super(i);
}
@Override
public void setAlpha(int i) {
if (ArticleViewer.this.parentActivity instanceof LaunchActivity) {
((LaunchActivity) ArticleViewer.this.parentActivity).drawerLayoutContainer.setAllowDrawContent((ArticleViewer.this.isPhotoVisible && i == 255) ? false : true);
}
super.setAlpha(i);
}
@Override
public void draw(Canvas canvas) {
Runnable runnable;
super.draw(canvas);
if (getAlpha() == 0 || (runnable = this.drawRunnable) == null) {
return;
}
runnable.run();
this.drawRunnable = null;
}
}
public class RadialProgressView {
private View parent;
private long lastUpdateTime = 0;
private float radOffset = 0.0f;
private float currentProgress = 0.0f;
private float animationProgressStart = 0.0f;
private long currentProgressTime = 0;
private float animatedProgressValue = 0.0f;
private RectF progressRect = new RectF();
private int backgroundState = -1;
private int size = AndroidUtilities.dp(64.0f);
private int previousBackgroundState = -2;
private float animatedAlphaValue = 1.0f;
private float alpha = 1.0f;
private float scale = 1.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(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 = f2 + (f3 * ArticleViewer.decelerateInterpolator.getInterpolation(((float) this.currentProgressTime) / 300.0f));
} else {
this.animatedProgressValue = f;
this.animationProgressStart = f;
this.currentProgressTime = 0L;
}
}
this.parent.invalidate();
}
if (this.animatedProgressValue < 1.0f || this.previousBackgroundState == -2) {
return;
}
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 = 0L;
}
public void setBackgroundState(int i, boolean z) {
int i2;
this.lastUpdateTime = System.currentTimeMillis();
if (z && (i2 = this.backgroundState) != i) {
this.previousBackgroundState = i2;
this.animatedAlphaValue = 1.0f;
} else {
this.previousBackgroundState = -2;
}
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) (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(containerViewWidth + dp, containerViewHeight + dp, (containerViewWidth + i2) - dp, (containerViewHeight + i2) - dp);
canvas.drawArc(this.progressRect, this.radOffset - 90.0f, Math.max(4.0f, this.animatedProgressValue * 360.0f), false, ArticleViewer.progressPaint);
updateAnimation();
}
}
}
public void onSharePressed() {
if (this.parentActivity == null || this.currentMedia == null) {
return;
}
try {
File mediaFile = getMediaFile(this.currentIndex);
if (mediaFile != null && mediaFile.exists()) {
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.jpgxbngtig.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);
return;
}
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());
} catch (Exception e) {
FileLog.e(e);
}
}
private void setScaleToFill() {
float bitmapWidth = this.centerImage.getBitmapWidth();
float containerViewWidth = getContainerViewWidth();
float bitmapHeight = this.centerImage.getBitmapHeight();
float containerViewHeight = getContainerViewHeight();
float min = Math.min(containerViewHeight / bitmapHeight, containerViewWidth / bitmapWidth);
float max = Math.max(containerViewWidth / ((int) (bitmapWidth * min)), containerViewHeight / ((int) (bitmapHeight * min)));
this.scale = max;
updateMinMax(max);
}
public void updateVideoPlayerTime() {
String format;
VideoPlayer videoPlayer = this.videoPlayer;
if (videoPlayer == null) {
format = String.format("%02d:%02d / %02d:%02d", 0, 0, 0, 0);
} else {
long currentPosition = videoPlayer.getCurrentPosition() / 1000;
long duration = this.videoPlayer.getDuration() / 1000;
format = (duration == C.TIME_UNSET || currentPosition == C.TIME_UNSET) ? String.format("%02d:%02d / %02d:%02d", 0, 0, 0, 0) : 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(), format)) {
return;
}
this.videoPlayerTime.setText(format);
}
private void preparePlayer(File file, boolean z) {
if (this.parentActivity == null) {
return;
}
releasePlayer();
if (this.videoTextureView == null) {
AspectRatioFrameLayout aspectRatioFrameLayout = new AspectRatioFrameLayout(this.parentActivity);
this.aspectRatioFrameLayout = aspectRatioFrameLayout;
aspectRatioFrameLayout.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 videoPlayer = new VideoPlayer();
this.videoPlayer = videoPlayer;
videoPlayer.setTextureView(this.videoTextureView);
this.videoPlayer.setDelegate(new VideoPlayer.VideoPlayerDelegate() {
@Override
public boolean onSurfaceDestroyed(SurfaceTexture surfaceTexture) {
return false;
}
@Override
public void onSurfaceTextureUpdated(SurfaceTexture surfaceTexture) {
}
@Override
public void onStateChanged(boolean z2, int i) {
if (ArticleViewer.this.videoPlayer == null) {
return;
}
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(0L);
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
public void onError(Exception exc) {
FileLog.e(exc);
}
@Override
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 : (i2 * f) / i, i3);
}
}
@Override
public void onRenderedFirstFrame() {
if (ArticleViewer.this.textureUploaded) {
return;
}
ArticleViewer.this.textureUploaded = true;
ArticleViewer.this.containerView.invalidate();
}
});
VideoPlayer videoPlayer2 = this.videoPlayer;
long j = 0;
if (videoPlayer2 != null) {
long duration = videoPlayer2.getDuration();
if (duration != C.TIME_UNSET) {
j = duration;
}
}
long j2 = j / 1000;
long j3 = j2 / 60;
long j4 = j2 % 60;
Math.ceil(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 videoPlayer = this.videoPlayer;
if (videoPlayer != null) {
videoPlayer.releasePlayer(true);
this.videoPlayer = null;
}
try {
this.parentActivity.getWindow().clearFlags(128);
} catch (Exception e) {
FileLog.e(e);
}
AspectRatioFrameLayout aspectRatioFrameLayout = this.aspectRatioFrameLayout;
if (aspectRatioFrameLayout != null) {
this.photoContainerView.removeView(aspectRatioFrameLayout);
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);
if (z2) {
ArrayList arrayList = new ArrayList();
ActionBar actionBar = this.actionBar;
Property property = View.ALPHA;
float[] fArr = new float[1];
fArr[0] = z ? 1.0f : 0.0f;
arrayList.add(ObjectAnimator.ofFloat(actionBar, (Property<ActionBar, Float>) property, fArr));
GroupedPhotosListView groupedPhotosListView = this.groupedPhotosListView;
Property property2 = View.ALPHA;
float[] fArr2 = new float[1];
fArr2[0] = z ? 1.0f : 0.0f;
arrayList.add(ObjectAnimator.ofFloat(groupedPhotosListView, (Property<GroupedPhotosListView, Float>) 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, (Property<FrameLayout, Float>) property3, fArr3));
if (this.captionTextView.getTag() != null) {
TextView textView = this.captionTextView;
Property property4 = View.ALPHA;
float[] fArr4 = new float[1];
fArr4[0] = z ? 1.0f : 0.0f;
arrayList.add(ObjectAnimator.ofFloat(textView, (Property<TextView, Float>) property4, fArr4));
}
AnimatorSet animatorSet = new AnimatorSet();
this.currentActionBarAnimation = animatorSet;
animatorSet.playTogether(arrayList);
if (!z) {
this.currentActionBarAnimation.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animator) {
if (ArticleViewer.this.currentActionBarAnimation == null || !ArticleViewer.this.currentActionBarAnimation.equals(animator)) {
return;
}
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) {
this.captionTextView.setAlpha(z ? 1.0f : 0.0f);
}
if (z) {
return;
}
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);
}
public 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;
}
public 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;
}
public 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);
}
public 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;
}
if (!(tLObject instanceof TLRPC.Document) || (closestPhotoSizeWithSize = FileLoader.getClosestPhotoSizeWithSize(((TLRPC.Document) tLObject).thumbs, 90)) == null) {
return null;
}
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)) {
return;
}
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);
}
}
public void setImageIndex(int i, boolean z) {
boolean z2;
boolean z3;
CharSequence charSequence;
boolean z4;
ImageReceiver.BitmapHolder bitmapHolder;
if (this.currentIndex == i) {
return;
}
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()) {
z2 = false;
z3 = false;
} else {
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;
z2 = pageBlock2 != null && pageBlock2 == pageBlock;
this.currentMedia = pageBlock;
z3 = isMediaVideo(this.currentIndex);
if (z3) {
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) {
@Override
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 (z3) {
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();
}
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 (!z2) {
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 = 0L;
this.imageMoveAnimation = null;
AspectRatioFrameLayout aspectRatioFrameLayout = this.aspectRatioFrameLayout;
if (aspectRatioFrameLayout != null) {
aspectRatioFrameLayout.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 || z3 || 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);
return;
}
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()) {
@Override
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;
if (i == 1) {
i2++;
} else if (i == 2) {
i2--;
}
File mediaFile = getMediaFile(i2);
boolean isMediaVideo = isMediaVideo(i2);
if (mediaFile == null || !mediaFile.exists()) {
if (isMediaVideo) {
if (!FileLoader.getInstance(this.currentAccount).isLoadingFile(this.currentFileNames[i])) {
this.radialProgressViews[i].setBackgroundState(2, false);
} else {
this.radialProgressViews[i].setBackgroundState(1, false);
}
} else {
this.radialProgressViews[i].setBackgroundState(0, z);
}
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) {
this.canZoom = (this.currentFileNames[0] == null || isMediaVideo || this.radialProgressViews[0].backgroundState == 0) ? false : true;
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);
return;
}
if (isMediaVideo(i)) {
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);
return;
}
imageReceiver.setImageBitmap(this.parentActivity.getResources().getDrawable(R.drawable.photoview_placeholder));
return;
}
AnimatedFileDrawable animatedFileDrawable = this.currentAnimation;
if (animatedFileDrawable != null) {
imageReceiver.setImageBitmap(animatedFileDrawable);
this.currentAnimation.setSecondParentView(this.photoContainerView);
return;
}
return;
}
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;
}
return this.photoAnimationInProgress != 0;
}
public boolean openPhoto(TLRPC.PageBlock pageBlock) {
final PlaceProviderObject placeForPhoto;
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(placeForPhoto.viewX + (drawRegion.left * placeForPhoto.scale));
this.animatingImageView.setTranslationY(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 = AndroidUtilities.displaySize.x / layoutParams.width;
float f2 = (AndroidUtilities.displaySize.y + AndroidUtilities.statusBarHeight) / layoutParams.height;
if (f > f2) {
f = f2;
}
float f3 = layoutParams.height * f;
float f4 = (AndroidUtilities.displaySize.x - (layoutParams.width * f)) / 2.0f;
if (Build.VERSION.SDK_INT >= 21 && (obj = this.lastInsets) != null) {
f4 += ((WindowInsets) obj).getSystemWindowInsetLeft();
}
float f5 = ((AndroidUtilities.displaySize.y + AndroidUtilities.statusBarHeight) - f3) / 2.0f;
int abs = placeForPhoto.imageReceiver.isAspectFit() ? 0 : (int) Math.abs(drawRegion.left - placeForPhoto.imageReceiver.getImageX());
int abs2 = (int) Math.abs(drawRegion.top - placeForPhoto.imageReceiver.getImageY());
placeForPhoto.parentView.getLocationInWindow(new int[2]);
int i = (int) ((r13[1] - (placeForPhoto.viewY + drawRegion.top)) + placeForPhoto.clipTopAddition);
if (i < 0) {
i = 0;
}
int height = (int) ((((placeForPhoto.viewY + drawRegion.top) + layoutParams.height) - (r13[1] + placeForPhoto.parentView.getHeight())) + placeForPhoto.clipBottomAddition);
if (height < 0) {
height = 0;
}
int max = Math.max(i, abs2);
int max2 = Math.max(height, abs2);
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 = abs;
this.animationValues[0][4] = placeForPhoto.scale * f6;
this.animationValues[0][5] = max * placeForPhoto.scale;
this.animationValues[0][6] = max2 * placeForPhoto.scale;
this.animationValues[0][7] = this.animatingImageView.getRadius();
this.animationValues[0][8] = abs2 * 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);
final AnimatorSet animatorSet = new AnimatorSet();
animatorSet.playTogether(ObjectAnimator.ofFloat(this.animatingImageView, "animationProgress", 0.0f, 1.0f), ObjectAnimator.ofInt(this.photoBackgroundDrawable, (Property<PhotoBackgroundDrawable, Integer>) AnimationProperties.COLOR_DRAWABLE_ALPHA, 0, 255), ObjectAnimator.ofFloat(this.actionBar, (Property<ActionBar, Float>) View.ALPHA, 0.0f, 1.0f), ObjectAnimator.ofFloat(this.bottomLayout, (Property<FrameLayout, Float>) View.ALPHA, 0.0f, 1.0f), ObjectAnimator.ofFloat(this.captionTextView, (Property<TextView, Float>) View.ALPHA, 0.0f, 1.0f), ObjectAnimator.ofFloat(this.groupedPhotosListView, (Property<GroupedPhotosListView, Float>) View.ALPHA, 0.0f, 1.0f));
this.photoAnimationEndRunnable = new Runnable() {
@Override
public final void run() {
ArticleViewer.this.lambda$openPhoto$37$ArticleViewer();
}
};
animatorSet.setDuration(200L);
animatorSet.addListener(new AnonymousClass23());
this.photoTransitionAnimationStartTime = System.currentTimeMillis();
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
ArticleViewer.this.lambda$openPhoto$38$ArticleViewer(animatorSet);
}
});
if (Build.VERSION.SDK_INT >= 18) {
this.photoContainerView.setLayerType(2, null);
}
this.photoBackgroundDrawable.drawRunnable = new Runnable() {
@Override
public final void run() {
ArticleViewer.this.lambda$openPhoto$39$ArticleViewer(placeForPhoto);
}
};
return true;
}
public void lambda$openPhoto$37$ArticleViewer() {
if (this.photoContainerView == null) {
return;
}
if (Build.VERSION.SDK_INT >= 18) {
this.photoContainerView.setLayerType(0, null);
}
this.photoAnimationInProgress = 0;
this.photoTransitionAnimationStartTime = 0L;
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 class AnonymousClass23 extends AnimatorListenerAdapter {
AnonymousClass23() {
}
@Override
public void onAnimationEnd(Animator animator) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
ArticleViewer.AnonymousClass23.this.lambda$onAnimationEnd$0$ArticleViewer$23();
}
});
}
public 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;
}
}
}
public 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 void lambda$openPhoto$39$ArticleViewer(PlaceProviderObject placeProviderObject) {
this.disableShowCheck = false;
placeProviderObject.imageReceiver.setVisible(false, true);
}
public void closePhoto(boolean z) {
RectF rectF;
Object obj;
if (this.parentActivity == null || !this.isPhotoVisible || checkPhotoAnimation()) {
return;
}
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 velocityTracker = this.velocityTracker;
if (velocityTracker != null) {
velocityTracker.recycle();
this.velocityTracker = null;
}
final 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 = AndroidUtilities.displaySize.x / layoutParams.width;
float f2 = (AndroidUtilities.displaySize.y + AndroidUtilities.statusBarHeight) / layoutParams.height;
if (f > f2) {
f = f2;
}
float f3 = layoutParams.width * this.scale * f;
float f4 = layoutParams.height * this.scale * f;
float f5 = (AndroidUtilities.displaySize.x - f3) / 2.0f;
if (Build.VERSION.SDK_INT >= 21 && (obj = this.lastInsets) != null) {
f5 += ((WindowInsets) obj).getSystemWindowInsetLeft();
}
this.animatingImageView.setTranslationX(f5 + this.translationX);
this.animatingImageView.setTranslationY((((AndroidUtilities.displaySize.y + AndroidUtilities.statusBarHeight) - f4) / 2.0f) + this.translationY);
this.animatingImageView.setScaleX(this.scale * f);
this.animatingImageView.setScaleY(this.scale * f);
if (placeForPhoto != null) {
placeForPhoto.imageReceiver.setVisible(false, true);
int abs = placeForPhoto.imageReceiver.isAspectFit() ? 0 : (int) Math.abs(rectF.left - placeForPhoto.imageReceiver.getImageX());
int abs2 = (int) Math.abs(rectF.top - placeForPhoto.imageReceiver.getImageY());
placeForPhoto.parentView.getLocationInWindow(new int[2]);
int i = (int) ((r15[1] - (placeForPhoto.viewY + rectF.top)) + placeForPhoto.clipTopAddition);
if (i < 0) {
i = 0;
}
int height = (int) ((((placeForPhoto.viewY + rectF.top) + (rectF.bottom - rectF.top)) - (r15[1] + placeForPhoto.parentView.getHeight())) + placeForPhoto.clipBottomAddition);
if (height < 0) {
height = 0;
}
int max = Math.max(i, abs2);
int max2 = Math.max(height, abs2);
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] = placeForPhoto.viewX + (rectF.left * placeForPhoto.scale);
this.animationValues[1][3] = placeForPhoto.viewY + (rectF.top * placeForPhoto.scale);
float f6 = abs;
this.animationValues[1][4] = placeForPhoto.scale * f6;
this.animationValues[1][5] = max * placeForPhoto.scale;
this.animationValues[1][6] = max2 * placeForPhoto.scale;
this.animationValues[1][7] = placeForPhoto.radius;
this.animationValues[1][8] = abs2 * placeForPhoto.scale;
this.animationValues[1][9] = f6 * placeForPhoto.scale;
animatorSet.playTogether(ObjectAnimator.ofFloat(this.animatingImageView, "animationProgress", 0.0f, 1.0f), ObjectAnimator.ofInt(this.photoBackgroundDrawable, (Property<PhotoBackgroundDrawable, Integer>) AnimationProperties.COLOR_DRAWABLE_ALPHA, 0), ObjectAnimator.ofFloat(this.actionBar, (Property<ActionBar, Float>) View.ALPHA, 0.0f), ObjectAnimator.ofFloat(this.bottomLayout, (Property<FrameLayout, Float>) View.ALPHA, 0.0f), ObjectAnimator.ofFloat(this.captionTextView, (Property<TextView, Float>) View.ALPHA, 0.0f), ObjectAnimator.ofFloat(this.groupedPhotosListView, (Property<GroupedPhotosListView, Float>) View.ALPHA, 0.0f));
} else {
int i2 = AndroidUtilities.displaySize.y + AndroidUtilities.statusBarHeight;
Animator[] animatorArr = new Animator[7];
animatorArr[0] = ObjectAnimator.ofInt(this.photoBackgroundDrawable, (Property<PhotoBackgroundDrawable, Integer>) AnimationProperties.COLOR_DRAWABLE_ALPHA, 0);
animatorArr[1] = ObjectAnimator.ofFloat(this.animatingImageView, (Property<ClippingImageView, Float>) View.ALPHA, 0.0f);
ClippingImageView clippingImageView = this.animatingImageView;
Property property = View.TRANSLATION_Y;
float[] fArr2 = new float[1];
if (this.translationY < 0.0f) {
i2 = -i2;
}
fArr2[0] = i2;
animatorArr[2] = ObjectAnimator.ofFloat(clippingImageView, (Property<ClippingImageView, Float>) property, fArr2);
animatorArr[3] = ObjectAnimator.ofFloat(this.actionBar, (Property<ActionBar, Float>) View.ALPHA, 0.0f);
animatorArr[4] = ObjectAnimator.ofFloat(this.bottomLayout, (Property<FrameLayout, Float>) View.ALPHA, 0.0f);
animatorArr[5] = ObjectAnimator.ofFloat(this.captionTextView, (Property<TextView, Float>) View.ALPHA, 0.0f);
animatorArr[6] = ObjectAnimator.ofFloat(this.groupedPhotosListView, (Property<GroupedPhotosListView, Float>) View.ALPHA, 0.0f);
animatorSet.playTogether(animatorArr);
}
this.photoAnimationEndRunnable = new Runnable() {
@Override
public final void run() {
ArticleViewer.this.lambda$closePhoto$40$ArticleViewer(placeForPhoto);
}
};
animatorSet.setDuration(200L);
animatorSet.addListener(new AnonymousClass24());
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 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);
}
public class AnonymousClass24 extends AnimatorListenerAdapter {
AnonymousClass24() {
}
@Override
public void onAnimationEnd(Animator animator) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
ArticleViewer.AnonymousClass24.this.lambda$onAnimationEnd$0$ArticleViewer$24();
}
});
}
public void lambda$onAnimationEnd$0$ArticleViewer$24() {
if (ArticleViewer.this.photoAnimationEndRunnable != null) {
ArticleViewer.this.photoAnimationEndRunnable.run();
ArticleViewer.this.photoAnimationEndRunnable = null;
}
}
}
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 = (Bitmap) null;
this.centerImage.setImageBitmap(bitmap);
this.leftImage.setImageBitmap(bitmap);
this.rightImage.setImageBitmap(bitmap);
this.photoContainerView.post(new Runnable() {
@Override
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 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) ((this.centerImage.getImageWidth() * f) - getContainerViewWidth())) / 2;
int imageHeight = ((int) ((this.centerImage.getImageHeight() * f) - getContainerViewHeight())) / 2;
if (imageWidth > 0) {
this.minX = -imageWidth;
this.maxX = imageWidth;
} else {
this.maxX = 0.0f;
this.minX = 0.0f;
}
if (imageHeight > 0) {
this.minY = -imageHeight;
this.maxY = imageHeight;
} else {
this.maxY = 0.0f;
this.minY = 0.0f;
}
}
public int getContainerViewWidth() {
return this.photoContainerView.getWidth();
}
public int getContainerViewHeight() {
return this.photoContainerView.getHeight();
}
public 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;
}
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(motionEvent.getX(1) - motionEvent.getX(0), 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 velocityTracker = this.velocityTracker;
if (velocityTracker != null) {
velocityTracker.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 velocityTracker2 = this.velocityTracker;
if (velocityTracker2 != null) {
velocityTracker2.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(motionEvent.getX(1) - motionEvent.getX(0), motionEvent.getY(1) - motionEvent.getY(0))) / this.pinchStartDistance) * this.pinchStartScale;
this.translationX = (this.pinchCenterX - (getContainerViewWidth() / 2)) - (((this.pinchCenterX - (getContainerViewWidth() / 2)) - this.pinchStartX) * (this.scale / this.pinchStartScale));
float containerViewHeight = this.pinchCenterY - (getContainerViewHeight() / 2);
float containerViewHeight2 = (this.pinchCenterY - (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 velocityTracker3 = this.velocityTracker;
if (velocityTracker3 != null) {
velocityTracker3.addMovement(motionEvent);
}
float abs = Math.abs(motionEvent.getX() - this.moveStartX);
float abs2 = Math.abs(motionEvent.getY() - this.dragY);
if (abs > AndroidUtilities.dp(3.0f) || abs2 > AndroidUtilities.dp(3.0f)) {
this.discardTap = true;
}
if (this.canDragDown && !this.draggingDown && this.scale == 1.0f && abs2 >= 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;
}
if (this.draggingDown) {
this.translationY = motionEvent.getY() - this.dragY;
this.photoContainerView.invalidate();
} else if (!this.invalidCoords && this.animationStartTime == 0) {
float x = this.moveStartX - motionEvent.getX();
float y2 = this.moveStartY - motionEvent.getY();
if (this.moving || ((this.scale == 1.0f && Math.abs(y2) + 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 {
this.invalidCoords = false;
this.moveStartX = motionEvent.getX();
this.moveStartY = motionEvent.getY();
}
}
} 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 - (getContainerViewWidth() / 2)) - (((this.pinchCenterX - (getContainerViewWidth() / 2)) - this.pinchStartX) * (3.0f / this.pinchStartScale));
float containerViewHeight3 = (this.pinchCenterY - (getContainerViewHeight() / 2)) - (((this.pinchCenterY - (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()) > 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 velocityTracker4 = this.velocityTracker;
if (velocityTracker4 != null && this.scale == 1.0f) {
velocityTracker4.computeCurrentVelocity(1000);
f = this.velocityTracker.getXVelocity();
}
if ((this.translationX < this.minX - (getContainerViewWidth() / 3) || f < (-AndroidUtilities.dp(650.0f))) && this.rightImage.hasImageSet()) {
goToNext();
return true;
}
if ((this.translationX > this.maxX + (getContainerViewWidth() / 3) || f > AndroidUtilities.dp(650.0f)) && this.leftImage.hasImageSet()) {
goToPrev();
return true;
}
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;
}
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 ? ((getContainerViewWidth() - this.centerImage.getImageWidth()) / 2) * this.scale : 0.0f;
this.switchImageAfterAnimation = 1;
animateTo(this.scale, ((this.minX - getContainerViewWidth()) - containerViewWidth) - (AndroidUtilities.dp(30.0f) / 2), this.translationY, false);
}
private void goToPrev() {
float containerViewWidth = this.scale != 1.0f ? ((getContainerViewWidth() - this.centerImage.getImageWidth()) / 2) * this.scale : 0.0f;
this.switchImageAfterAnimation = 2;
animateTo(this.scale, this.maxX + getContainerViewWidth() + containerViewWidth + (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) {
return;
}
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(i);
this.imageMoveAnimation.addListener(new AnimatorListenerAdapter() {
@Override
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;
}
public void drawContent(Canvas canvas) {
float f;
float f2;
float f3;
float f4;
float f5;
float f6;
float f7;
boolean z;
float f8;
float f9;
float f10;
float f11;
int i = this.photoAnimationInProgress;
if (i == 1) {
return;
}
if (!this.isPhotoVisible && i != 2) {
return;
}
if (this.imageMoveAnimation != null) {
if (!this.scroller.isFinished()) {
this.scroller.abortAnimation();
}
float f12 = this.scale;
float f13 = this.animateToScale;
float f14 = this.animationValue;
f = ((f13 - f12) * f14) + f12;
float f15 = this.translationX;
f3 = ((this.animateToX - f15) * f14) + f15;
float f16 = this.translationY;
f2 = f16 + ((this.animateToY - f16) * f14);
f4 = (f13 == 1.0f && f12 == 1.0f && f15 == 0.0f) ? f2 : -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 = 0L;
updateMinMax(f17);
this.zoomAnimation = false;
}
if (!this.scroller.isFinished() && this.scroller.computeScrollOffset()) {
if (this.scroller.getStartX() < this.maxX && this.scroller.getStartX() > this.minX) {
this.translationX = this.scroller.getCurrX();
}
if (this.scroller.getStartY() < this.maxY && this.scroller.getStartY() > this.minY) {
this.translationY = this.scroller.getCurrY();
}
this.photoContainerView.invalidate();
}
int i2 = this.switchImageAfterAnimation;
if (i2 != 0) {
if (i2 == 1) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
ArticleViewer.this.lambda$drawContent$42$ArticleViewer();
}
});
} else if (i2 == 2) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
ArticleViewer.this.lambda$drawContent$43$ArticleViewer();
}
});
}
this.switchImageAfterAnimation = 0;
}
f = this.scale;
f2 = this.translationY;
f3 = this.translationX;
f4 = !this.moving ? f2 : -1.0f;
}
if (this.photoAnimationInProgress != 2) {
if (this.scale == 1.0f && f4 != -1.0f && !this.zoomAnimation) {
float containerViewHeight = getContainerViewHeight() / 4.0f;
this.photoBackgroundDrawable.setAlpha((int) Math.max(127.0f, (1.0f - (Math.min(Math.abs(f4), containerViewHeight) / containerViewHeight)) * 255.0f));
} else {
this.photoBackgroundDrawable.setAlpha(255);
}
}
ImageReceiver imageReceiver = null;
if (this.scale >= 1.0f && !this.zoomAnimation && !this.zooming) {
if (f3 > this.maxX + AndroidUtilities.dp(5.0f)) {
imageReceiver = this.leftImage;
} else if (f3 < this.minX - 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 (f3 < f18) {
f10 = Math.min(1.0f, (f18 - f3) / canvas.getWidth());
f11 = (1.0f - f10) * 0.3f;
f9 = (-canvas.getWidth()) - (AndroidUtilities.dp(30.0f) / 2);
if (imageReceiver.hasBitmapImage()) {
canvas.save();
canvas.translate(getContainerViewWidth() / 2, getContainerViewHeight() / 2);
canvas.translate(canvas.getWidth() + (AndroidUtilities.dp(30.0f) / 2) + f9, 0.0f);
float f19 = 1.0f - f11;
canvas.scale(f19, f19);
int bitmapWidth = imageReceiver.getBitmapWidth();
float f20 = bitmapWidth;
float containerViewWidth = getContainerViewWidth() / f20;
float bitmapHeight = imageReceiver.getBitmapHeight();
float containerViewHeight2 = getContainerViewHeight() / bitmapHeight;
if (containerViewWidth > containerViewHeight2) {
containerViewWidth = containerViewHeight2;
}
int i3 = (int) (f20 * containerViewWidth);
int i4 = (int) (bitmapHeight * containerViewWidth);
imageReceiver.setAlpha(f10);
imageReceiver.setImageCoords((-i3) / 2, (-i4) / 2, i3, i4);
imageReceiver.draw(canvas);
canvas.restore();
}
this.groupedPhotosListView.setMoveProgress(-f10);
canvas.save();
canvas.translate(f9, f2 / f);
canvas.translate(((canvas.getWidth() * (this.scale + 1.0f)) + AndroidUtilities.dp(30.0f)) / 2.0f, (-f2) / f);
this.radialProgressViews[1].setScale(1.0f - f11);
this.radialProgressViews[1].setAlpha(f10);
this.radialProgressViews[1].onDraw(canvas);
canvas.restore();
}
}
f9 = f3;
f10 = 1.0f;
f11 = 0.0f;
if (imageReceiver.hasBitmapImage()) {
}
this.groupedPhotosListView.setMoveProgress(-f10);
canvas.save();
canvas.translate(f9, f2 / f);
canvas.translate(((canvas.getWidth() * (this.scale + 1.0f)) + AndroidUtilities.dp(30.0f)) / 2.0f, (-f2) / f);
this.radialProgressViews[1].setScale(1.0f - f11);
this.radialProgressViews[1].setAlpha(f10);
this.radialProgressViews[1].onDraw(canvas);
canvas.restore();
}
if (!this.zoomAnimation) {
float f21 = this.maxX;
if (f3 > f21) {
float min = Math.min(1.0f, (f3 - f21) / canvas.getWidth());
f7 = 0.3f * min;
f6 = 1.0f - min;
f5 = this.maxX;
AspectRatioFrameLayout aspectRatioFrameLayout = this.aspectRatioFrameLayout;
z = aspectRatioFrameLayout == null && aspectRatioFrameLayout.getVisibility() == 0;
if (this.centerImage.hasBitmapImage()) {
canvas.save();
canvas.translate(getContainerViewWidth() / 2, getContainerViewHeight() / 2);
canvas.translate(f5, f2);
float f22 = f - f7;
canvas.scale(f22, f22);
int bitmapWidth2 = this.centerImage.getBitmapWidth();
int bitmapHeight2 = this.centerImage.getBitmapHeight();
if (z && this.textureUploaded && Math.abs((bitmapWidth2 / bitmapHeight2) - (this.videoTextureView.getMeasuredWidth() / this.videoTextureView.getMeasuredHeight())) > 0.01f) {
bitmapWidth2 = this.videoTextureView.getMeasuredWidth();
bitmapHeight2 = this.videoTextureView.getMeasuredHeight();
}
float f23 = bitmapWidth2;
float containerViewWidth2 = getContainerViewWidth() / f23;
float f24 = bitmapHeight2;
float containerViewHeight3 = getContainerViewHeight() / f24;
if (containerViewWidth2 > containerViewHeight3) {
containerViewWidth2 = containerViewHeight3;
}
int i5 = (int) (f23 * containerViewWidth2);
int i6 = (int) (f24 * containerViewWidth2);
if (!z || !this.textureUploaded || !this.videoCrossfadeStarted || this.videoCrossfadeAlpha != 1.0f) {
this.centerImage.setAlpha(f6);
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((-i5) / 2, (-i6) / 2);
this.videoTextureView.setAlpha(this.videoCrossfadeAlpha * f6);
this.aspectRatioFrameLayout.draw(canvas);
if (this.videoCrossfadeStarted && this.videoCrossfadeAlpha < 1.0f) {
long currentTimeMillis = System.currentTimeMillis();
long j = currentTimeMillis - this.videoCrossfadeAlphaLastTime;
this.videoCrossfadeAlphaLastTime = currentTimeMillis;
this.videoCrossfadeAlpha += ((float) j) / 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, f2 / f);
this.radialProgressViews[0].setScale(1.0f - f7);
this.radialProgressViews[0].setAlpha(f6);
this.radialProgressViews[0].onDraw(canvas);
canvas.restore();
}
if (imageReceiver != this.leftImage) {
if (imageReceiver.hasBitmapImage()) {
canvas.save();
canvas.translate(getContainerViewWidth() / 2, getContainerViewHeight() / 2);
canvas.translate(((-((canvas.getWidth() * (this.scale + 1.0f)) + AndroidUtilities.dp(30.0f))) / 2.0f) + f3, 0.0f);
int bitmapWidth3 = imageReceiver.getBitmapWidth();
float f25 = bitmapWidth3;
float containerViewWidth3 = getContainerViewWidth() / f25;
float bitmapHeight3 = imageReceiver.getBitmapHeight();
float containerViewHeight4 = getContainerViewHeight() / bitmapHeight3;
if (containerViewWidth3 > containerViewHeight4) {
containerViewWidth3 = containerViewHeight4;
}
int i7 = (int) (f25 * containerViewWidth3);
int i8 = (int) (bitmapHeight3 * 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 - f6);
canvas.save();
canvas.translate(f3, f2 / f);
canvas.translate((-((canvas.getWidth() * (this.scale + f8)) + AndroidUtilities.dp(30.0f))) / 2.0f, (-f2) / f);
this.radialProgressViews[2].setScale(1.0f);
this.radialProgressViews[2].setAlpha(1.0f);
this.radialProgressViews[2].onDraw(canvas);
canvas.restore();
return;
}
return;
}
}
f5 = f3;
f6 = 1.0f;
f7 = 0.0f;
AspectRatioFrameLayout aspectRatioFrameLayout2 = this.aspectRatioFrameLayout;
if (aspectRatioFrameLayout2 == null) {
}
if (this.centerImage.hasBitmapImage()) {
}
if (!z) {
canvas.save();
canvas.translate(f5, f2 / f);
this.radialProgressViews[0].setScale(1.0f - f7);
this.radialProgressViews[0].setAlpha(f6);
this.radialProgressViews[0].onDraw(canvas);
canvas.restore();
}
if (imageReceiver != this.leftImage) {
}
}
public void lambda$drawContent$42$ArticleViewer() {
setImageIndex(this.currentIndex + 1, false);
}
public 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) {
return;
}
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) {
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);
}
}
}
@Override
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;
}
@Override
public boolean onSingleTapConfirmed(MotionEvent motionEvent) {
int i;
if (this.discardTap) {
return false;
}
AspectRatioFrameLayout aspectRatioFrameLayout = this.aspectRatioFrameLayout;
boolean z = aspectRatioFrameLayout != null && aspectRatioFrameLayout.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 >= (getContainerViewWidth() - AndroidUtilities.dp(100.0f)) / 2.0f && x <= (getContainerViewWidth() + AndroidUtilities.dp(100.0f)) / 2.0f && y >= (getContainerViewHeight() - AndroidUtilities.dp(100.0f)) / 2.0f && y <= (getContainerViewHeight() + AndroidUtilities.dp(100.0f)) / 2.0f) {
onActionClick(true);
checkProgress(0, true);
return true;
}
}
toggleActionBar(!this.isActionBarVisible, true);
return true;
}
@Override
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() - (getContainerViewWidth() / 2)) - (((motionEvent.getX() - (getContainerViewWidth() / 2)) - this.translationX) * (3.0f / this.scale));
float y = (motionEvent.getY() - (getContainerViewHeight() / 2)) - (((motionEvent.getY() - (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;
}
if (view instanceof BlockVideoCell) {
BlockVideoCell blockVideoCell = (BlockVideoCell) view;
if (blockVideoCell.currentBlock != pageBlock) {
return null;
}
view.getLocationInWindow(iArr);
return blockVideoCell.imageView;
}
if (view instanceof BlockCollageCell) {
ImageReceiver imageReceiverFromListView = getImageReceiverFromListView(((BlockCollageCell) view).innerListView, pageBlock, iArr);
if (imageReceiverFromListView != null) {
return imageReceiverFromListView;
}
return null;
}
if (view instanceof BlockSlideshowCell) {
ImageReceiver imageReceiverFromListView2 = getImageReceiverFromListView(((BlockSlideshowCell) view).innerListView, pageBlock, iArr);
if (imageReceiverFromListView2 != null) {
return imageReceiverFromListView2;
}
return null;
}
if (view instanceof BlockListItemCell) {
BlockListItemCell blockListItemCell = (BlockListItemCell) view;
if (blockListItemCell.blockLayout == null || (imageReceiverView2 = getImageReceiverView(blockListItemCell.blockLayout.itemView, pageBlock, iArr)) == null) {
return null;
}
return imageReceiverView2;
}
if (!(view instanceof BlockOrderedListItemCell)) {
return null;
}
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;
}
}