ЙЖ v1.1.1版本的 MD5 值为:8a99f876f523791304117b6ba699b758
以下内容为反编译后的 ArticleViewer.java 源代码,内容仅作参考
package im.wsnshelzvi.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.google.android.exoplayer2.C;
import com.google.android.exoplayer2.ui.AspectRatioFrameLayout;
import im.wsnshelzvi.messenger.AndroidUtilities;
import im.wsnshelzvi.messenger.ApplicationLoader;
import im.wsnshelzvi.messenger.DownloadController;
import im.wsnshelzvi.messenger.Emoji;
import im.wsnshelzvi.messenger.FileLoader;
import im.wsnshelzvi.messenger.FileLog;
import im.wsnshelzvi.messenger.ImageLoader;
import im.wsnshelzvi.messenger.ImageLocation;
import im.wsnshelzvi.messenger.ImageReceiver;
import im.wsnshelzvi.messenger.LocaleController;
import im.wsnshelzvi.messenger.MediaController;
import im.wsnshelzvi.messenger.MessageObject;
import im.wsnshelzvi.messenger.MessagesController;
import im.wsnshelzvi.messenger.MessagesStorage;
import im.wsnshelzvi.messenger.NotificationCenter;
import im.wsnshelzvi.messenger.R;
import im.wsnshelzvi.messenger.UserConfig;
import im.wsnshelzvi.messenger.Utilities;
import im.wsnshelzvi.messenger.WebFile;
import im.wsnshelzvi.messenger.browser.Browser;
import im.wsnshelzvi.tgnet.ConnectionsManager;
import im.wsnshelzvi.tgnet.RequestDelegate;
import im.wsnshelzvi.tgnet.TLObject;
import im.wsnshelzvi.tgnet.TLRPC;
import im.wsnshelzvi.ui.ArticleViewer;
import im.wsnshelzvi.ui.actionbar.ActionBar;
import im.wsnshelzvi.ui.actionbar.ActionBarMenu;
import im.wsnshelzvi.ui.actionbar.ActionBarMenuItem;
import im.wsnshelzvi.ui.actionbar.ActionBarPopupWindow;
import im.wsnshelzvi.ui.actionbar.AlertDialog;
import im.wsnshelzvi.ui.actionbar.BackDrawable;
import im.wsnshelzvi.ui.actionbar.BaseFragment;
import im.wsnshelzvi.ui.actionbar.BottomSheet;
import im.wsnshelzvi.ui.actionbar.SimpleTextView;
import im.wsnshelzvi.ui.actionbar.Theme;
import im.wsnshelzvi.ui.components.AlertsCreator;
import im.wsnshelzvi.ui.components.AnchorSpan;
import im.wsnshelzvi.ui.components.AnimatedArrowDrawable;
import im.wsnshelzvi.ui.components.AnimatedFileDrawable;
import im.wsnshelzvi.ui.components.AnimationProperties;
import im.wsnshelzvi.ui.components.AvatarDrawable;
import im.wsnshelzvi.ui.components.ClippingImageView;
import im.wsnshelzvi.ui.components.CombinedDrawable;
import im.wsnshelzvi.ui.components.ContextProgressView;
import im.wsnshelzvi.ui.components.GroupedPhotosListView;
import im.wsnshelzvi.ui.components.LayoutHelper;
import im.wsnshelzvi.ui.components.LineProgressView;
import im.wsnshelzvi.ui.components.LinkPath;
import im.wsnshelzvi.ui.components.RadialProgress2;
import im.wsnshelzvi.ui.components.RecyclerListView;
import im.wsnshelzvi.ui.components.Scroller;
import im.wsnshelzvi.ui.components.SeekBar;
import im.wsnshelzvi.ui.components.ShareAlert;
import im.wsnshelzvi.ui.components.StaticLayoutEx;
import im.wsnshelzvi.ui.components.TableLayout;
import im.wsnshelzvi.ui.components.TextPaintImageReceiverSpan;
import im.wsnshelzvi.ui.components.TextPaintMarkSpan;
import im.wsnshelzvi.ui.components.TextPaintSpan;
import im.wsnshelzvi.ui.components.TextPaintUrlSpan;
import im.wsnshelzvi.ui.components.TextPaintWebpageUrlSpan;
import im.wsnshelzvi.ui.components.TypefaceSpan;
import im.wsnshelzvi.ui.components.VideoPlayer;
import im.wsnshelzvi.ui.components.WebPlayerView;
import im.wsnshelzvi.ui.components.toast.ToastUtils;
import java.io.File;
import java.lang.reflect.Array;
import java.net.URLDecoder;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import org.json.JSONObject;
public class ArticleViewer implements NotificationCenter.NotificationCenterDelegate, GestureDetector.OnGestureListener, GestureDetector.OnDoubleTapListener {
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;
private static volatile ArticleViewer Instance = null;
public static final Property<WindowView, Float> ARTICLE_VIEWER_INNER_TRANSLATION_X = new AnimationProperties.FloatProperty<WindowView>("innerTranslationX") {
@Override
public void setValue(WindowView object, float value) {
object.setInnerTranslationX(value);
}
@Override
public Float get(WindowView object) {
return Float.valueOf(object.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()) {
float progress = ((float) ArticleViewer.this.videoPlayer.getCurrentPosition()) / ((float) ArticleViewer.this.videoPlayer.getDuration());
ArticleViewer.this.videoPlayerSeekbar.setProgress(progress);
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.TYPE, 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;
}
static int access$1104(ArticleViewer x0) {
int i = x0.pressCount + 1;
x0.pressCount = i;
return i;
}
static int access$13108(ArticleViewer x0) {
int i = x0.lastBlockNum;
x0.lastBlockNum = i + 1;
return i;
}
public static ArticleViewer getInstance() {
ArticleViewer localInstance = Instance;
if (localInstance == null) {
synchronized (ArticleViewer.class) {
localInstance = Instance;
if (localInstance == null) {
ArticleViewer articleViewer = new ArticleViewer();
localInstance = articleViewer;
Instance = articleViewer;
}
}
}
return localInstance;
}
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 line) {
return this.textLayout.getLineAscent(line);
}
public float getLineLeft(int line) {
return this.textLayout.getLineLeft(line);
}
public float getLineWidth(int line) {
return this.textLayout.getLineWidth(line);
}
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 event) {
float x = event.getX();
if (event.getAction() == 0) {
getParent().requestDisallowInterceptTouchEvent(true);
int a = 0;
while (true) {
if (a >= 5) {
break;
}
int i = this.sideSide;
int i2 = this.lineSize + (this.gapSize * 2);
int i3 = this.circleSize;
int cx = i + ((i2 + i3) * a) + (i3 / 2);
if (x > cx - AndroidUtilities.dp(15.0f) && x < AndroidUtilities.dp(15.0f) + cx) {
this.startMoving = a == ArticleViewer.this.selectedFontSize;
this.startX = x;
this.startMovingQuality = ArticleViewer.this.selectedFontSize;
} else {
a++;
}
}
} else if (event.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) {
int a2 = 0;
while (true) {
if (a2 >= 5) {
break;
}
int i4 = this.sideSide;
int i5 = this.lineSize;
int i6 = this.gapSize;
int i7 = this.circleSize;
int cx2 = i4 + (((i6 * 2) + i5 + i7) * a2) + (i7 / 2);
int diff = (i5 / 2) + (i7 / 2) + i6;
if (x > cx2 - diff && x < cx2 + diff) {
if (ArticleViewer.this.selectedFontSize != a2) {
ArticleViewer.this.selectedFontSize = a2;
ArticleViewer.this.updatePaintSize();
invalidate();
}
} else {
a2++;
}
}
}
} else if (event.getAction() == 1 || event.getAction() == 3) {
if (this.moving) {
if (ArticleViewer.this.selectedFontSize != this.startMovingQuality) {
ArticleViewer.this.updatePaintSize();
}
} else {
int a3 = 0;
while (true) {
if (a3 >= 5) {
break;
}
int i8 = this.sideSide;
int i9 = this.lineSize + (this.gapSize * 2);
int i10 = this.circleSize;
int cx3 = i8 + ((i9 + i10) * a3) + (i10 / 2);
if (x > cx3 - AndroidUtilities.dp(15.0f) && x < AndroidUtilities.dp(15.0f) + cx3) {
if (ArticleViewer.this.selectedFontSize != a3) {
ArticleViewer.this.selectedFontSize = a3;
ArticleViewer.this.updatePaintSize();
invalidate();
}
} else {
a3++;
}
}
}
this.startMoving = false;
this.moving = false;
}
return true;
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
View.MeasureSpec.getSize(widthMeasureSpec);
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 cy = getMeasuredHeight() / 2;
int a = 0;
while (a < 5) {
int i = this.sideSide;
int i2 = this.lineSize + (this.gapSize * 2);
int i3 = this.circleSize;
int cx = i + ((i2 + i3) * a) + (i3 / 2);
if (a <= ArticleViewer.this.selectedFontSize) {
this.paint.setColor(-15428119);
} else {
this.paint.setColor(-3355444);
}
canvas.drawCircle(cx, cy, a == ArticleViewer.this.selectedFontSize ? AndroidUtilities.dp(4.0f) : this.circleSize / 2, this.paint);
if (a != 0) {
int x = ((cx - (this.circleSize / 2)) - this.gapSize) - this.lineSize;
canvas.drawRect(x, cy - AndroidUtilities.dp(1.0f), this.lineSize + x, AndroidUtilities.dp(1.0f) + cy, this.paint);
}
a++;
}
}
}
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 widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(View.MeasureSpec.makeMeasureSpec(View.MeasureSpec.getSize(widthMeasureSpec), 1073741824), View.MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(48.0f), 1073741824));
}
public void setTextAndColor(String text, int color) {
this.textView.setText(text);
this.currentColor = color;
invalidate();
}
public void select(boolean value) {
if (this.selected == value) {
return;
}
this.selected = value;
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 widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(View.MeasureSpec.makeMeasureSpec(View.MeasureSpec.getSize(widthMeasureSpec), 1073741824), View.MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(48.0f), 1073741824));
}
public void select(boolean value) {
this.textView2.setTextColor(value ? -15428119 : -14606047);
}
public void setTextAndTypeface(String text, Typeface typeface) {
this.textView.setText(text);
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 event) {
ArticleViewer.this.processTouchEvent(event);
return true;
}
@Override
protected void onDraw(Canvas canvas) {
ArticleViewer.this.drawContent(canvas);
}
@Override
protected boolean drawChild(Canvas canvas, View child, long drawingTime) {
return child != ArticleViewer.this.aspectRatioFrameLayout && super.drawChild(canvas, child, drawingTime);
}
}
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 widthMeasureSpec, int heightMeasureSpec) {
int widthSize = View.MeasureSpec.getSize(widthMeasureSpec);
int heightSize = View.MeasureSpec.getSize(heightMeasureSpec);
if (ArticleViewer.this.lastInsets != null) {
setMeasuredDimension(widthSize, heightSize);
WindowInsets insets = (WindowInsets) ArticleViewer.this.lastInsets;
if (AndroidUtilities.incorrectDisplaySizeFix) {
if (heightSize > AndroidUtilities.displaySize.y) {
heightSize = AndroidUtilities.displaySize.y;
}
heightSize += AndroidUtilities.statusBarHeight;
}
int heightSize2 = heightSize - insets.getSystemWindowInsetBottom();
widthSize -= insets.getSystemWindowInsetRight() + insets.getSystemWindowInsetLeft();
if (insets.getSystemWindowInsetRight() != 0) {
this.bWidth = insets.getSystemWindowInsetRight();
this.bHeight = heightSize2;
} else if (insets.getSystemWindowInsetLeft() != 0) {
this.bWidth = insets.getSystemWindowInsetLeft();
this.bHeight = heightSize2;
} else {
this.bWidth = widthSize;
this.bHeight = insets.getSystemWindowInsetBottom();
}
heightSize = heightSize2 - insets.getSystemWindowInsetTop();
} else {
setMeasuredDimension(widthSize, heightSize);
}
ArticleViewer.this.containerView.measure(View.MeasureSpec.makeMeasureSpec(widthSize, 1073741824), View.MeasureSpec.makeMeasureSpec(heightSize, 1073741824));
ArticleViewer.this.photoContainerView.measure(View.MeasureSpec.makeMeasureSpec(widthSize, 1073741824), View.MeasureSpec.makeMeasureSpec(heightSize, 1073741824));
ArticleViewer.this.photoContainerBackground.measure(View.MeasureSpec.makeMeasureSpec(widthSize, 1073741824), View.MeasureSpec.makeMeasureSpec(heightSize, 1073741824));
ArticleViewer.this.fullscreenVideoContainer.measure(View.MeasureSpec.makeMeasureSpec(widthSize, 1073741824), View.MeasureSpec.makeMeasureSpec(heightSize, 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 changed, int left, int top, int right, int bottom) {
int x;
if (this.selfLayout) {
return;
}
int width = right - left;
if (ArticleViewer.this.anchorsOffsetMeasuredWidth != width) {
for (int i = 0; i < ArticleViewer.this.listView.length; i++) {
for (Map.Entry<String, Integer> entry : ArticleViewer.this.adapter[i].anchorsOffset.entrySet()) {
entry.setValue(-1);
}
}
ArticleViewer.this.anchorsOffsetMeasuredWidth = width;
}
int y = 0;
if (ArticleViewer.this.lastInsets != null) {
WindowInsets insets = (WindowInsets) ArticleViewer.this.lastInsets;
x = insets.getSystemWindowInsetLeft();
if (insets.getSystemWindowInsetRight() != 0) {
this.bX = width - this.bWidth;
this.bY = 0;
} else if (insets.getSystemWindowInsetLeft() != 0) {
this.bX = 0;
this.bY = 0;
} else {
this.bX = 0;
this.bY = (bottom - top) - this.bHeight;
}
if (Build.VERSION.SDK_INT >= 28) {
y = 0 + insets.getSystemWindowInsetTop();
}
} else {
x = 0;
}
ArticleViewer.this.containerView.layout(x, y, ArticleViewer.this.containerView.getMeasuredWidth() + x, ArticleViewer.this.containerView.getMeasuredHeight() + y);
ArticleViewer.this.photoContainerView.layout(x, y, ArticleViewer.this.photoContainerView.getMeasuredWidth() + x, ArticleViewer.this.photoContainerView.getMeasuredHeight() + y);
ArticleViewer.this.photoContainerBackground.layout(x, y, ArticleViewer.this.photoContainerBackground.getMeasuredWidth() + x, ArticleViewer.this.photoContainerBackground.getMeasuredHeight() + y);
ArticleViewer.this.fullscreenVideoContainer.layout(x, y, ArticleViewer.this.fullscreenVideoContainer.getMeasuredWidth() + x, ArticleViewer.this.fullscreenVideoContainer.getMeasuredHeight() + y);
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 disallowIntercept) {
handleTouchEvent(null);
super.requestDisallowInterceptTouchEvent(disallowIntercept);
}
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
return !ArticleViewer.this.collapsed && (handleTouchEvent(ev) || super.onInterceptTouchEvent(ev));
}
@Override
public boolean onTouchEvent(MotionEvent event) {
return !ArticleViewer.this.collapsed && (handleTouchEvent(event) || super.onTouchEvent(event));
}
public void setInnerTranslationX(float value) {
this.innerTranslationX = value;
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 child, long drawingTime) {
float opacity;
int width = getMeasuredWidth();
int translationX = (int) this.innerTranslationX;
int restoreCount = canvas.save();
canvas.clipRect(translationX, 0, width, getHeight());
boolean result = super.drawChild(canvas, child, drawingTime);
canvas.restoreToCount(restoreCount);
if (translationX != 0 && child == ArticleViewer.this.containerView) {
float opacity2 = Math.min(0.8f, (width - translationX) / width);
if (opacity2 >= 0.0f) {
opacity = opacity2;
} else {
opacity = 0.0f;
}
ArticleViewer.this.scrimPaint.setColor(((int) (153.0f * opacity)) << 24);
canvas.drawRect(0.0f, 0.0f, translationX, getHeight(), ArticleViewer.this.scrimPaint);
float alpha = Math.max(0.0f, Math.min((width - translationX) / AndroidUtilities.dp(20.0f), 1.0f));
ArticleViewer.this.layerShadowDrawable.setBounds(translationX - ArticleViewer.this.layerShadowDrawable.getIntrinsicWidth(), child.getTop(), translationX, child.getBottom());
ArticleViewer.this.layerShadowDrawable.setAlpha((int) (255.0f * alpha));
ArticleViewer.this.layerShadowDrawable.draw(canvas);
}
return result;
}
public float getInnerTranslationX() {
return this.innerTranslationX;
}
private void prepareForMoving(MotionEvent ev) {
this.maybeStartTracking = false;
this.startedTracking = true;
this.startedTrackingX = (int) ev.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 event) {
float distToMove;
if (ArticleViewer.this.isPhotoVisible || this.closeAnimationInProgress || ArticleViewer.this.fullscreenVideoContainer.getVisibility() == 0) {
return false;
}
if (event == null || event.getAction() != 0 || this.startedTracking || this.maybeStartTracking) {
if (event == null || event.getAction() != 2 || event.getPointerId(0) != this.startedTrackingPointerId) {
if (event != null && event.getPointerId(0) == this.startedTrackingPointerId && (event.getAction() == 3 || event.getAction() == 1 || event.getAction() == 6)) {
if (this.tracker == null) {
this.tracker = VelocityTracker.obtain();
}
this.tracker.computeCurrentVelocity(1000);
float velX = this.tracker.getXVelocity();
float velY = this.tracker.getYVelocity();
if (!this.startedTracking && velX >= 3500.0f && velX > Math.abs(velY)) {
prepareForMoving(event);
}
if (this.startedTracking) {
View movingView = this.movingPage ? ArticleViewer.this.listView[0] : ArticleViewer.this.containerView;
float x = movingView.getX();
final boolean backAnimation = x < ((float) movingView.getMeasuredWidth()) / 3.0f && (velX < 3500.0f || velX < velY);
AnimatorSet animatorSet = new AnimatorSet();
if (!backAnimation) {
distToMove = movingView.getMeasuredWidth() - x;
if (this.movingPage) {
animatorSet.playTogether(ObjectAnimator.ofFloat(ArticleViewer.this.listView[0], (Property<RecyclerListView, Float>) View.TRANSLATION_X, movingView.getMeasuredWidth()));
} else {
animatorSet.playTogether(ObjectAnimator.ofFloat(ArticleViewer.this.containerView, (Property<FrameLayout, Float>) View.TRANSLATION_X, movingView.getMeasuredWidth()), ObjectAnimator.ofFloat(this, ArticleViewer.ARTICLE_VIEWER_INNER_TRANSLATION_X, movingView.getMeasuredWidth()));
}
} else {
distToMove = x;
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 / movingView.getMeasuredWidth()) * distToMove), 50));
animatorSet.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animator) {
if (WindowView.this.movingPage) {
ArticleViewer.this.listView[0].setBackgroundDrawable(null);
if (!backAnimation) {
WebpageAdapter adapterToUpdate = ArticleViewer.this.adapter[1];
ArticleViewer.this.adapter[1] = ArticleViewer.this.adapter[0];
ArticleViewer.this.adapter[0] = adapterToUpdate;
RecyclerListView listToUpdate = ArticleViewer.this.listView[1];
ArticleViewer.this.listView[1] = ArticleViewer.this.listView[0];
ArticleViewer.this.listView[0] = listToUpdate;
LinearLayoutManager layoutManagerToUpdate = ArticleViewer.this.layoutManager[1];
ArticleViewer.this.layoutManager[1] = ArticleViewer.this.layoutManager[0];
ArticleViewer.this.layoutManager[0] = layoutManagerToUpdate;
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 (!backAnimation) {
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 velocityTracker = this.tracker;
if (velocityTracker != null) {
velocityTracker.recycle();
this.tracker = null;
}
} else if (event == null) {
this.maybeStartTracking = false;
this.startedTracking = false;
this.movingPage = false;
VelocityTracker velocityTracker2 = this.tracker;
if (velocityTracker2 != null) {
velocityTracker2.recycle();
this.tracker = null;
}
}
} else {
if (this.tracker == null) {
this.tracker = VelocityTracker.obtain();
}
int dx = Math.max(0, (int) (event.getX() - this.startedTrackingX));
int dy = Math.abs(((int) event.getY()) - this.startedTrackingY);
this.tracker.addMovement(event);
if (this.maybeStartTracking && !this.startedTracking && dx >= AndroidUtilities.getPixelsInCM(0.4f, true) && Math.abs(dx) / 3 > dy) {
prepareForMoving(event);
} else if (this.startedTracking) {
ArticleViewer.this.pressedLinkOwnerLayout = null;
ArticleViewer.this.pressedLinkOwnerView = null;
if (this.movingPage) {
ArticleViewer.this.listView[0].setTranslationX(dx);
} else {
ArticleViewer.this.containerView.setTranslationX(dx);
setInnerTranslationX(dx);
}
}
}
} else {
this.startedTrackingPointerId = event.getPointerId(0);
this.maybeStartTracking = true;
this.startedTrackingX = (int) event.getX();
this.startedTrackingY = (int) event.getY();
VelocityTracker velocityTracker3 = this.tracker;
if (velocityTracker3 != null) {
velocityTracker3.clear();
}
}
return this.startedTracking;
}
@Override
protected void dispatchDraw(Canvas canvas) {
int i;
int i2;
super.dispatchDraw(canvas);
if (this.bWidth != 0 && (i = this.bHeight) != 0) {
int i3 = this.bX;
if (i3 != 0 || (i2 = this.bY) != 0) {
canvas.drawRect(i3 - 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 (ArticleViewer.this.hasCutout && ArticleViewer.this.lastInsets != null) {
WindowInsets insets = (WindowInsets) ArticleViewer.this.lastInsets;
canvas.drawRect(this.innerTranslationX, 0.0f, getMeasuredWidth(), insets.getSystemWindowInsetBottom(), ArticleViewer.this.statusBarPaint);
}
}
@Override
public void setAlpha(float value) {
ArticleViewer.this.backgroundPaint.setAlpha((int) (value * 255.0f));
ArticleViewer.this.statusBarPaint.setAlpha((int) (255.0f * value));
this.alpha = value;
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) {
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) {
ArticleViewer.this.windowView.performHapticFeedback(0);
int[] location = new int[2];
ArticleViewer.this.pressedLinkOwnerView.getLocationInWindow(location);
int y = (location[1] + ArticleViewer.this.pressedLayoutY) - AndroidUtilities.dp(54.0f);
if (y < 0) {
y = 0;
}
ArticleViewer.this.pressedLinkOwnerView.invalidate();
ArticleViewer.this.drawBlockSelection = true;
ArticleViewer articleViewer2 = ArticleViewer.this;
articleViewer2.showPopup(articleViewer2.pressedLinkOwnerView, 48, 0, y);
ArticleViewer.this.listView[0].setLayoutFrozen(true);
ArticleViewer.this.listView[0].setLayoutFrozen(false);
}
}
}
}
private void createPaint(boolean update) {
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 (!update) {
return;
}
int color = getSelectedColor();
if (color == 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 (color == 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 (color == 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 urlFinal) {
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(urlFinal);
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.m1075lambda$showCopyPopup$0$imwsnshelzviuiArticleViewer(urlFinal, dialogInterface, i);
}
});
BottomSheet sheet = builder.create();
showDialog(sheet);
for (int a = 0; a < 2; a++) {
sheet.setItemColor(a, getTextColor(), getTextColor());
}
int a2 = getGrayTextColor();
sheet.setTitleColor(a2);
int i = this.selectedColor;
if (i == 0) {
sheet.setBackgroundColor(-1);
} else if (i == 1) {
sheet.setBackgroundColor(-659492);
} else if (i == 2) {
sheet.setBackgroundColor(-15461356);
}
}
public void m1075lambda$showCopyPopup$0$imwsnshelzviuiArticleViewer(String urlFinal, DialogInterface dialog, int which) {
String webPageUrl;
String anchor;
if (this.parentActivity == null) {
return;
}
if (which == 0) {
int index = urlFinal.lastIndexOf(35);
if (index != -1) {
if (!TextUtils.isEmpty(this.currentPage.cached_page.url)) {
webPageUrl = this.currentPage.cached_page.url.toLowerCase();
} else {
webPageUrl = this.currentPage.url.toLowerCase();
}
try {
anchor = URLDecoder.decode(urlFinal.substring(index + 1), "UTF-8");
} catch (Exception e) {
anchor = "";
}
if (urlFinal.toLowerCase().contains(webPageUrl)) {
if (TextUtils.isEmpty(anchor)) {
this.layoutManager[0].scrollToPositionWithOffset(0, 0);
checkScrollAnimated();
return;
} else {
scrollToAnchor(anchor);
return;
}
}
}
Browser.openUrl(this.parentActivity, urlFinal);
return;
}
if (which == 1) {
String url = urlFinal;
if (url.startsWith("mailto:")) {
url = url.substring(7);
} else if (url.startsWith("tel:")) {
url = url.substring(4);
}
AndroidUtilities.addToClipboard(url);
}
}
public void showPopup(View parent, int gravity, int x, int y) {
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 view, MotionEvent motionEvent) {
return ArticleViewer.this.m1077lambda$showPopup$1$imwsnshelzviuiArticleViewer(view, motionEvent);
}
});
this.popupLayout.setDispatchKeyEventListener(new ActionBarPopupWindow.OnDispatchKeyEventListener() {
@Override
public final void onDispatchKeyEvent(KeyEvent keyEvent) {
ArticleViewer.this.m1078lambda$showPopup$2$imwsnshelzviuiArticleViewer(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 view) {
ArticleViewer.this.m1079lambda$showPopup$3$imwsnshelzviuiArticleViewer(view);
}
});
this.popupLayout.addView(this.deleteView, LayoutHelper.createFrame(-2, 48.0f));
ActionBarPopupWindow actionBarPopupWindow2 = new ActionBarPopupWindow(this.popupLayout, -2, -2);
this.popupWindow = actionBarPopupWindow2;
actionBarPopupWindow2.setAnimationEnabled(false);
this.popupWindow.setAnimationStyle(R.style.PopupContextAnimation);
this.popupWindow.setOutsideTouchable(true);
this.popupWindow.setClippingEnabled(true);
this.popupWindow.setInputMethodMode(2);
this.popupWindow.setSoftInputMode(0);
this.popupWindow.getContentView().setFocusableInTouchMode(true);
this.popupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
@Override
public final void onDismiss() {
ArticleViewer.this.m1080lambda$showPopup$4$imwsnshelzviuiArticleViewer();
}
});
}
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(parent, gravity, x, y);
this.popupWindow.startAnimation();
}
public boolean m1077lambda$showPopup$1$imwsnshelzviuiArticleViewer(View v, MotionEvent event) {
ActionBarPopupWindow actionBarPopupWindow;
if (event.getActionMasked() == 0 && (actionBarPopupWindow = this.popupWindow) != null && actionBarPopupWindow.isShowing()) {
v.getHitRect(this.popupRect);
if (!this.popupRect.contains((int) event.getX(), (int) event.getY())) {
this.popupWindow.dismiss();
return false;
}
return false;
}
return false;
}
public void m1078lambda$showPopup$2$imwsnshelzviuiArticleViewer(KeyEvent keyEvent) {
ActionBarPopupWindow actionBarPopupWindow;
if (keyEvent.getKeyCode() == 4 && keyEvent.getRepeatCount() == 0 && (actionBarPopupWindow = this.popupWindow) != null && actionBarPopupWindow.isShowing()) {
this.popupWindow.dismiss();
}
}
public void m1079lambda$showPopup$3$imwsnshelzviuiArticleViewer(View v) {
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()) {
this.popupWindow.dismiss(true);
}
}
public void m1080lambda$showPopup$4$imwsnshelzviuiArticleViewer() {
View view = this.pressedLinkOwnerView;
if (view != null) {
this.pressedLinkOwnerLayout = null;
view.invalidate();
this.pressedLinkOwnerView = null;
}
}
private TLRPC.RichText getBlockCaption(TLRPC.PageBlock block, int type) {
if (type == 2) {
TLRPC.RichText text1 = getBlockCaption(block, 0);
if (text1 instanceof TLRPC.TL_textEmpty) {
text1 = null;
}
TLRPC.RichText text2 = getBlockCaption(block, 1);
if (text2 instanceof TLRPC.TL_textEmpty) {
text2 = null;
}
if (text1 != null && text2 == null) {
return text1;
}
if (text1 == null && text2 != null) {
return text2;
}
if (text1 == null || text2 == null) {
return null;
}
TLRPC.TL_textPlain text3 = new TLRPC.TL_textPlain();
text3.text = " ";
TLRPC.TL_textConcat textConcat = new TLRPC.TL_textConcat();
textConcat.texts.add(text1);
textConcat.texts.add(text3);
textConcat.texts.add(text2);
return textConcat;
}
if (block instanceof TLRPC.TL_pageBlockEmbedPost) {
TLRPC.TL_pageBlockEmbedPost blockEmbedPost = (TLRPC.TL_pageBlockEmbedPost) block;
if (type == 0) {
return blockEmbedPost.caption.text;
}
if (type == 1) {
return blockEmbedPost.caption.credit;
}
} else if (block instanceof TLRPC.TL_pageBlockSlideshow) {
TLRPC.TL_pageBlockSlideshow pageBlockSlideshow = (TLRPC.TL_pageBlockSlideshow) block;
if (type == 0) {
return pageBlockSlideshow.caption.text;
}
if (type == 1) {
return pageBlockSlideshow.caption.credit;
}
} else if (block instanceof TLRPC.TL_pageBlockPhoto) {
TLRPC.TL_pageBlockPhoto pageBlockPhoto = (TLRPC.TL_pageBlockPhoto) block;
if (type == 0) {
return pageBlockPhoto.caption.text;
}
if (type == 1) {
return pageBlockPhoto.caption.credit;
}
} else if (block instanceof TLRPC.TL_pageBlockCollage) {
TLRPC.TL_pageBlockCollage pageBlockCollage = (TLRPC.TL_pageBlockCollage) block;
if (type == 0) {
return pageBlockCollage.caption.text;
}
if (type == 1) {
return pageBlockCollage.caption.credit;
}
} else if (block instanceof TLRPC.TL_pageBlockEmbed) {
TLRPC.TL_pageBlockEmbed pageBlockEmbed = (TLRPC.TL_pageBlockEmbed) block;
if (type == 0) {
return pageBlockEmbed.caption.text;
}
if (type == 1) {
return pageBlockEmbed.caption.credit;
}
} else {
if (block instanceof TLRPC.TL_pageBlockBlockquote) {
TLRPC.TL_pageBlockBlockquote pageBlockBlockquote = (TLRPC.TL_pageBlockBlockquote) block;
return pageBlockBlockquote.caption;
}
if (block instanceof TLRPC.TL_pageBlockVideo) {
TLRPC.TL_pageBlockVideo pageBlockVideo = (TLRPC.TL_pageBlockVideo) block;
if (type == 0) {
return pageBlockVideo.caption.text;
}
if (type == 1) {
return pageBlockVideo.caption.credit;
}
} else {
if (block instanceof TLRPC.TL_pageBlockPullquote) {
TLRPC.TL_pageBlockPullquote pageBlockPullquote = (TLRPC.TL_pageBlockPullquote) block;
return pageBlockPullquote.caption;
}
if (block instanceof TLRPC.TL_pageBlockAudio) {
TLRPC.TL_pageBlockAudio pageBlockAudio = (TLRPC.TL_pageBlockAudio) block;
if (type == 0) {
return pageBlockAudio.caption.text;
}
if (type == 1) {
return pageBlockAudio.caption.credit;
}
} else {
if (block instanceof TLRPC.TL_pageBlockCover) {
TLRPC.TL_pageBlockCover pageBlockCover = (TLRPC.TL_pageBlockCover) block;
return getBlockCaption(pageBlockCover.cover, type);
}
if (block instanceof TLRPC.TL_pageBlockMap) {
TLRPC.TL_pageBlockMap pageBlockMap = (TLRPC.TL_pageBlockMap) block;
if (type == 0) {
return pageBlockMap.caption.text;
}
if (type == 1) {
return pageBlockMap.caption.credit;
}
}
}
}
}
return null;
}
private View getLastNonListCell(View view) {
if (view instanceof BlockListItemCell) {
BlockListItemCell cell = (BlockListItemCell) view;
if (cell.blockLayout != null) {
return getLastNonListCell(cell.blockLayout.itemView);
}
} else if (view instanceof BlockOrderedListItemCell) {
BlockOrderedListItemCell cell2 = (BlockOrderedListItemCell) view;
if (cell2.blockLayout != null) {
return getLastNonListCell(cell2.blockLayout.itemView);
}
}
return view;
}
public boolean isListItemBlock(TLRPC.PageBlock block) {
return (block instanceof TL_pageBlockListItem) || (block instanceof TL_pageBlockOrderedListItem);
}
public TLRPC.PageBlock getLastNonListPageBlock(TLRPC.PageBlock block) {
if (block instanceof TL_pageBlockListItem) {
TL_pageBlockListItem blockListItem = (TL_pageBlockListItem) block;
return blockListItem.blockItem != null ? getLastNonListPageBlock(blockListItem.blockItem) : blockListItem.blockItem;
}
if (block instanceof TL_pageBlockOrderedListItem) {
TL_pageBlockOrderedListItem blockListItem2 = (TL_pageBlockOrderedListItem) block;
return blockListItem2.blockItem != null ? getLastNonListPageBlock(blockListItem2.blockItem) : blockListItem2.blockItem;
}
return block;
}
private boolean openAllParentBlocks(TL_pageBlockDetailsChild child) {
TLRPC.PageBlock parentBlock = getLastNonListPageBlock(child.parent);
if (parentBlock instanceof TLRPC.TL_pageBlockDetails) {
TLRPC.TL_pageBlockDetails blockDetails = (TLRPC.TL_pageBlockDetails) parentBlock;
if (blockDetails.open) {
return false;
}
blockDetails.open = true;
return true;
}
if (!(parentBlock instanceof TL_pageBlockDetailsChild)) {
return false;
}
TL_pageBlockDetailsChild parent = (TL_pageBlockDetailsChild) parentBlock;
TLRPC.PageBlock parentBlock2 = getLastNonListPageBlock(parent.block);
boolean opened = false;
if (parentBlock2 instanceof TLRPC.TL_pageBlockDetails) {
TLRPC.TL_pageBlockDetails blockDetails2 = (TLRPC.TL_pageBlockDetails) parentBlock2;
if (!blockDetails2.open) {
blockDetails2.open = true;
opened = true;
}
}
return openAllParentBlocks(parent) || opened;
}
public TLRPC.PageBlock fixListBlock(TLRPC.PageBlock parentBlock, TLRPC.PageBlock childBlock) {
if (parentBlock instanceof TL_pageBlockListItem) {
TL_pageBlockListItem blockListItem = (TL_pageBlockListItem) parentBlock;
blockListItem.blockItem = childBlock;
return parentBlock;
}
if (parentBlock instanceof TL_pageBlockOrderedListItem) {
TL_pageBlockOrderedListItem blockListItem2 = (TL_pageBlockOrderedListItem) parentBlock;
blockListItem2.blockItem = childBlock;
return parentBlock;
}
return childBlock;
}
public TLRPC.PageBlock wrapInTableBlock(TLRPC.PageBlock parentBlock, TLRPC.PageBlock childBlock) {
if (parentBlock instanceof TL_pageBlockListItem) {
TL_pageBlockListItem parent = (TL_pageBlockListItem) parentBlock;
TL_pageBlockListItem item = new TL_pageBlockListItem();
item.parent = parent.parent;
item.blockItem = wrapInTableBlock(parent.blockItem, childBlock);
return item;
}
if (parentBlock instanceof TL_pageBlockOrderedListItem) {
TL_pageBlockOrderedListItem parent2 = (TL_pageBlockOrderedListItem) parentBlock;
TL_pageBlockOrderedListItem item2 = new TL_pageBlockOrderedListItem();
item2.parent = parent2.parent;
item2.blockItem = wrapInTableBlock(parent2.blockItem, childBlock);
return item2;
}
return childBlock;
}
private void updateInterfaceForCurrentPage(int order) {
int a;
int offset;
TLRPC.WebPage webPage = this.currentPage;
if (webPage != null && webPage.cached_page != null) {
this.isRtl = this.currentPage.cached_page.rtl;
this.channelBlock = null;
this.titleTextView.setText(this.currentPage.site_name == null ? "" : this.currentPage.site_name);
if (order != 0) {
WebpageAdapter[] webpageAdapterArr = this.adapter;
WebpageAdapter adapterToUpdate = webpageAdapterArr[1];
webpageAdapterArr[1] = webpageAdapterArr[0];
webpageAdapterArr[0] = adapterToUpdate;
RecyclerListView[] recyclerListViewArr = this.listView;
RecyclerListView listToUpdate = recyclerListViewArr[1];
recyclerListViewArr[1] = recyclerListViewArr[0];
recyclerListViewArr[0] = listToUpdate;
LinearLayoutManager[] linearLayoutManagerArr = this.layoutManager;
LinearLayoutManager layoutManagerToUpdate = linearLayoutManagerArr[1];
linearLayoutManagerArr[1] = linearLayoutManagerArr[0];
linearLayoutManagerArr[0] = layoutManagerToUpdate;
int index1 = this.containerView.indexOfChild(recyclerListViewArr[0]);
int index2 = this.containerView.indexOfChild(this.listView[1]);
if (order == 1) {
if (index1 < index2) {
this.containerView.removeView(this.listView[0]);
this.containerView.addView(this.listView[0], index2);
}
} else if (index2 < index1) {
this.containerView.removeView(this.listView[0]);
this.containerView.addView(this.listView[0], index1);
}
this.pageSwitchAnimation = new AnimatorSet();
this.listView[0].setVisibility(0);
final int index = order == 1 ? 0 : 1;
this.listView[index].setBackgroundColor(this.backgroundPaint.getColor());
this.listView[index].setLayerType(2, null);
if (order == 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 (order == -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 animation) {
ArticleViewer.this.listView[1].setVisibility(8);
ArticleViewer.this.listView[index].setBackgroundDrawable(null);
ArticleViewer.this.listView[index].setLayerType(0, null);
ArticleViewer.this.pageSwitchAnimation = null;
}
});
this.pageSwitchAnimation.start();
}
this.headerView.invalidate();
this.adapter[0].cleanup();
int count = this.currentPage.cached_page.blocks.size();
while (a < count) {
TLRPC.PageBlock block = this.currentPage.cached_page.blocks.get(a);
if (a != 0) {
a = (a == 1 && this.channelBlock != null) ? a + 1 : 0;
} else {
block.first = true;
if (block instanceof TLRPC.TL_pageBlockCover) {
TLRPC.TL_pageBlockCover pageBlockCover = (TLRPC.TL_pageBlockCover) block;
TLRPC.RichText caption = getBlockCaption(pageBlockCover, 0);
TLRPC.RichText credit = getBlockCaption(pageBlockCover, 1);
if (((caption != null && !(caption instanceof TLRPC.TL_textEmpty)) || (credit != null && !(credit instanceof TLRPC.TL_textEmpty))) && count > 1) {
TLRPC.PageBlock next = this.currentPage.cached_page.blocks.get(1);
if (next instanceof TLRPC.TL_pageBlockChannel) {
this.channelBlock = (TLRPC.TL_pageBlockChannel) next;
}
}
}
}
this.adapter[0].addBlock(block, 0, 0, a == count + (-1) ? a : 0);
}
this.adapter[0].notifyDataSetChanged();
if (this.pagesStack.size() == 1 || order == -1) {
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("articles", 0);
String key = "article" + this.currentPage.id;
int position = preferences.getInt(key, -1);
if (preferences.getBoolean(key + "r", true) == (AndroidUtilities.displaySize.x > AndroidUtilities.displaySize.y)) {
offset = preferences.getInt(key + "o", 0) - this.listView[0].getPaddingTop();
} else {
offset = AndroidUtilities.dp(10.0f);
}
if (position != -1) {
this.layoutManager[0].scrollToPositionWithOffset(position, offset);
}
} else {
this.layoutManager[0].scrollToPositionWithOffset(0, 0);
}
checkScrollAnimated();
}
}
private boolean addPageToStack(TLRPC.WebPage webPage, String anchor, int order) {
saveCurrentPagePosition();
this.currentPage = webPage;
this.pagesStack.add(webPage);
updateInterfaceForCurrentPage(order);
return scrollToAnchor(anchor);
}
private boolean scrollToAnchor(String anchor) {
if (TextUtils.isEmpty(anchor)) {
return false;
}
String anchor2 = anchor.toLowerCase();
Integer row = (Integer) this.adapter[0].anchors.get(anchor2);
if (row == null) {
return false;
}
TLRPC.TL_textAnchor textAnchor = (TLRPC.TL_textAnchor) this.adapter[0].anchorsParent.get(anchor2);
if (textAnchor != null) {
TLRPC.TL_pageBlockParagraph paragraph = new TLRPC.TL_pageBlockParagraph();
paragraph.text = textAnchor.text;
int type = this.adapter[0].getTypeForBlock(paragraph);
RecyclerView.ViewHolder holder = this.adapter[0].onCreateViewHolder(null, type);
this.adapter[0].bindBlockToHolder(type, holder, paragraph, 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(holder.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 (row.intValue() < 0 || row.intValue() >= this.adapter[0].blocks.size()) {
return false;
}
TLRPC.PageBlock originalBlock = (TLRPC.PageBlock) this.adapter[0].blocks.get(row.intValue());
TLRPC.PageBlock block = getLastNonListPageBlock(originalBlock);
if ((block instanceof TL_pageBlockDetailsChild) && openAllParentBlocks((TL_pageBlockDetailsChild) block)) {
this.adapter[0].updateRows();
this.adapter[0].notifyDataSetChanged();
}
int position = this.adapter[0].localBlocks.indexOf(originalBlock);
if (position != -1) {
row = Integer.valueOf(position);
}
Integer offset = (Integer) this.adapter[0].anchorsOffset.get(anchor2);
if (offset == null) {
offset = 0;
} else if (offset.intValue() == -1) {
int type2 = this.adapter[0].getTypeForBlock(originalBlock);
RecyclerView.ViewHolder holder2 = this.adapter[0].onCreateViewHolder(null, type2);
this.adapter[0].bindBlockToHolder(type2, holder2, originalBlock, 0, 0);
holder2.itemView.measure(View.MeasureSpec.makeMeasureSpec(this.listView[0].getMeasuredWidth(), 1073741824), View.MeasureSpec.makeMeasureSpec(0, 0));
Integer offset2 = (Integer) this.adapter[0].anchorsOffset.get(anchor2);
if (offset2.intValue() != -1) {
offset = offset2;
} else {
offset = 0;
}
}
this.layoutManager[0].scrollToPositionWithOffset(row.intValue(), (this.currentHeaderHeight - AndroidUtilities.dp(56.0f)) - offset.intValue());
return true;
}
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) {
TLRPC.TL_textUrl textUrl = (TLRPC.TL_textUrl) richText;
if (textUrl.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);
} else {
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);
}
if (richText instanceof TLRPC.TL_textPhone) {
return getLastRichText(((TLRPC.TL_textPhone) richText).text);
}
}
return richText;
}
public CharSequence getText(View parentView, TLRPC.RichText parentRichText, TLRPC.RichText richText, TLRPC.PageBlock parentBlock, int maxWidth) {
MetricAffectingSpan span;
MetricAffectingSpan span2;
if (richText == null) {
return null;
}
if (richText instanceof TLRPC.TL_textFixed) {
return getText(parentView, parentRichText, ((TLRPC.TL_textFixed) richText).text, parentBlock, maxWidth);
}
if (richText instanceof TLRPC.TL_textItalic) {
return getText(parentView, parentRichText, ((TLRPC.TL_textItalic) richText).text, parentBlock, maxWidth);
}
if (richText instanceof TLRPC.TL_textBold) {
return getText(parentView, parentRichText, ((TLRPC.TL_textBold) richText).text, parentBlock, maxWidth);
}
if (richText instanceof TLRPC.TL_textUnderline) {
return getText(parentView, parentRichText, ((TLRPC.TL_textUnderline) richText).text, parentBlock, maxWidth);
}
if (richText instanceof TLRPC.TL_textStrike) {
return getText(parentView, parentRichText, ((TLRPC.TL_textStrike) richText).text, parentBlock, maxWidth);
}
if (richText instanceof TLRPC.TL_textEmail) {
SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(getText(parentView, parentRichText, ((TLRPC.TL_textEmail) richText).text, parentBlock, maxWidth));
MetricAffectingSpan[] innerSpans = (MetricAffectingSpan[]) spannableStringBuilder.getSpans(0, spannableStringBuilder.length(), MetricAffectingSpan.class);
if (spannableStringBuilder.length() != 0) {
spannableStringBuilder.setSpan(new TextPaintUrlSpan((innerSpans == null || innerSpans.length == 0) ? getTextPaint(parentRichText, richText, parentBlock) : null, "mailto:" + getUrl(richText)), 0, spannableStringBuilder.length(), 33);
}
return spannableStringBuilder;
}
long j = 0;
if (richText instanceof TLRPC.TL_textUrl) {
TLRPC.TL_textUrl textUrl = (TLRPC.TL_textUrl) richText;
SpannableStringBuilder spannableStringBuilder2 = new SpannableStringBuilder(getText(parentView, parentRichText, ((TLRPC.TL_textUrl) richText).text, parentBlock, maxWidth));
MetricAffectingSpan[] innerSpans2 = (MetricAffectingSpan[]) spannableStringBuilder2.getSpans(0, spannableStringBuilder2.length(), MetricAffectingSpan.class);
TextPaint paint = (innerSpans2 == null || innerSpans2.length == 0) ? getTextPaint(parentRichText, richText, parentBlock) : null;
if (textUrl.webpage_id != 0) {
span2 = new TextPaintWebpageUrlSpan(paint, getUrl(richText));
} else {
span2 = new TextPaintUrlSpan(paint, getUrl(richText));
}
if (spannableStringBuilder2.length() != 0) {
spannableStringBuilder2.setSpan(span2, 0, spannableStringBuilder2.length(), 33);
}
return spannableStringBuilder2;
}
if (richText instanceof TLRPC.TL_textPlain) {
return ((TLRPC.TL_textPlain) richText).text;
}
if (richText instanceof TLRPC.TL_textAnchor) {
TLRPC.TL_textAnchor textAnchor = (TLRPC.TL_textAnchor) richText;
SpannableStringBuilder spannableStringBuilder3 = new SpannableStringBuilder(getText(parentView, parentRichText, textAnchor.text, parentBlock, maxWidth));
spannableStringBuilder3.setSpan(new AnchorSpan(textAnchor.name), 0, spannableStringBuilder3.length(), 17);
return spannableStringBuilder3;
}
if (richText instanceof TLRPC.TL_textEmpty) {
return "";
}
int i = 1;
if (richText instanceof TLRPC.TL_textConcat) {
SpannableStringBuilder spannableStringBuilder4 = new SpannableStringBuilder();
int count = richText.texts.size();
int a = 0;
while (a < count) {
TLRPC.RichText innerRichText = richText.texts.get(a);
TLRPC.RichText lastRichText = getLastRichText(innerRichText);
boolean extraSpace = maxWidth >= 0 && (innerRichText instanceof TLRPC.TL_textUrl) && ((TLRPC.TL_textUrl) innerRichText).webpage_id != j;
if (extraSpace && spannableStringBuilder4.length() != 0 && spannableStringBuilder4.charAt(spannableStringBuilder4.length() - i) != '\n') {
spannableStringBuilder4.append((CharSequence) " ");
}
int a2 = a;
int count2 = count;
CharSequence innerText = getText(parentView, parentRichText, innerRichText, parentBlock, maxWidth);
int flags = getTextFlags(lastRichText);
int startLength = spannableStringBuilder4.length();
spannableStringBuilder4.append(innerText);
if (flags != 0 && !(innerText instanceof SpannableStringBuilder)) {
if ((flags & 8) != 0 || (flags & 512) != 0) {
String url = getUrl(innerRichText);
if (url == null) {
url = getUrl(parentRichText);
}
if ((flags & 512) != 0) {
span = new TextPaintWebpageUrlSpan(getTextPaint(parentRichText, lastRichText, parentBlock), url);
} else {
span = new TextPaintUrlSpan(getTextPaint(parentRichText, lastRichText, parentBlock), url);
}
if (startLength != spannableStringBuilder4.length()) {
spannableStringBuilder4.setSpan(span, startLength, spannableStringBuilder4.length(), 33);
}
} else if (startLength != spannableStringBuilder4.length()) {
spannableStringBuilder4.setSpan(new TextPaintSpan(getTextPaint(parentRichText, lastRichText, parentBlock)), startLength, spannableStringBuilder4.length(), 33);
}
}
if (extraSpace && a2 != count2 - 1) {
spannableStringBuilder4.append((CharSequence) " ");
}
a = a2 + 1;
count = count2;
i = 1;
j = 0;
}
return spannableStringBuilder4;
}
if (richText instanceof TLRPC.TL_textSubscript) {
return getText(parentView, parentRichText, ((TLRPC.TL_textSubscript) richText).text, parentBlock, maxWidth);
}
if (richText instanceof TLRPC.TL_textSuperscript) {
return getText(parentView, parentRichText, ((TLRPC.TL_textSuperscript) richText).text, parentBlock, maxWidth);
}
if (richText instanceof TLRPC.TL_textMarked) {
SpannableStringBuilder spannableStringBuilder5 = new SpannableStringBuilder(getText(parentView, parentRichText, ((TLRPC.TL_textMarked) richText).text, parentBlock, maxWidth));
MetricAffectingSpan[] innerSpans3 = (MetricAffectingSpan[]) spannableStringBuilder5.getSpans(0, spannableStringBuilder5.length(), MetricAffectingSpan.class);
if (spannableStringBuilder5.length() != 0) {
spannableStringBuilder5.setSpan(new TextPaintMarkSpan((innerSpans3 == null || innerSpans3.length == 0) ? getTextPaint(parentRichText, richText, parentBlock) : null), 0, spannableStringBuilder5.length(), 33);
}
return spannableStringBuilder5;
}
if (richText instanceof TLRPC.TL_textPhone) {
SpannableStringBuilder spannableStringBuilder6 = new SpannableStringBuilder(getText(parentView, parentRichText, ((TLRPC.TL_textPhone) richText).text, parentBlock, maxWidth));
MetricAffectingSpan[] innerSpans4 = (MetricAffectingSpan[]) spannableStringBuilder6.getSpans(0, spannableStringBuilder6.length(), MetricAffectingSpan.class);
if (spannableStringBuilder6.length() != 0) {
spannableStringBuilder6.setSpan(new TextPaintUrlSpan((innerSpans4 == null || innerSpans4.length == 0) ? getTextPaint(parentRichText, richText, parentBlock) : null, "tel:" + getUrl(richText)), 0, spannableStringBuilder6.length(), 33);
}
return spannableStringBuilder6;
}
if (richText instanceof TLRPC.TL_textImage) {
TLRPC.TL_textImage textImage = (TLRPC.TL_textImage) richText;
TLRPC.Document document = getDocumentWithId(textImage.document_id);
if (document == null) {
return "";
}
SpannableStringBuilder spannableStringBuilder7 = new SpannableStringBuilder("*");
int w = AndroidUtilities.dp(textImage.w);
int h = AndroidUtilities.dp(textImage.h);
int maxWidth2 = Math.abs(maxWidth);
if (w > maxWidth2) {
float scale = maxWidth2 / w;
w = maxWidth2;
h = (int) (h * scale);
}
spannableStringBuilder7.setSpan(new TextPaintImageReceiverSpan(parentView, document, this.currentPage, w, h, false, this.selectedColor == 2), 0, spannableStringBuilder7.length(), 33);
return spannableStringBuilder7;
}
return "not supported " + richText;
}
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 stringBuilder = new StringBuilder();
int count = richText.texts.size();
for (int a = 0; a < count; a++) {
stringBuilder.append(getPlainText(richText.texts.get(a)));
}
return stringBuilder;
}
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);
}
boolean z = 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() {
switch (getSelectedColor()) {
case 0:
case 1:
return -14606047;
default:
return -6710887;
}
}
private int getInstantLinkBackgroundColor() {
switch (getSelectedColor()) {
case 0:
return -1707782;
case 1:
return -2498337;
default:
return -14536904;
}
}
private int getLinkTextColor() {
switch (getSelectedColor()) {
case 0:
return -15435321;
case 1:
return -13471296;
default:
return -10838585;
}
}
public int getGrayTextColor() {
switch (getSelectedColor()) {
case 0:
return -8156010;
case 1:
return -11711675;
default:
return -10066330;
}
}
private TextPaint getTextPaint(TLRPC.RichText parentRichText, TLRPC.RichText richText, TLRPC.PageBlock parentBlock) {
int additionalSize;
int flags = getTextFlags(richText);
SparseArray<TextPaint> currentMap = null;
int textSize = AndroidUtilities.dp(14.0f);
int textColor = SupportMenu.CATEGORY_MASK;
int additionalSize2 = this.selectedFontSize;
if (additionalSize2 == 0) {
additionalSize = -AndroidUtilities.dp(4.0f);
} else if (additionalSize2 == 1) {
additionalSize = -AndroidUtilities.dp(2.0f);
} else if (additionalSize2 == 3) {
additionalSize = AndroidUtilities.dp(2.0f);
} else if (additionalSize2 == 4) {
additionalSize = AndroidUtilities.dp(4.0f);
} else {
additionalSize = 0;
}
if (parentBlock instanceof TLRPC.TL_pageBlockPhoto) {
TLRPC.TL_pageBlockPhoto pageBlockPhoto = (TLRPC.TL_pageBlockPhoto) parentBlock;
if (pageBlockPhoto.caption.text == richText || pageBlockPhoto.caption.text == parentRichText) {
currentMap = photoCaptionTextPaints;
textSize = AndroidUtilities.dp(14.0f);
} else {
currentMap = photoCreditTextPaints;
textSize = AndroidUtilities.dp(12.0f);
}
textColor = getGrayTextColor();
} else if (parentBlock instanceof TLRPC.TL_pageBlockMap) {
TLRPC.TL_pageBlockMap pageBlockMap = (TLRPC.TL_pageBlockMap) parentBlock;
if (pageBlockMap.caption.text == richText || pageBlockMap.caption.text == parentRichText) {
currentMap = photoCaptionTextPaints;
textSize = AndroidUtilities.dp(14.0f);
} else {
currentMap = photoCreditTextPaints;
textSize = AndroidUtilities.dp(12.0f);
}
textColor = getGrayTextColor();
} else if (parentBlock instanceof TLRPC.TL_pageBlockTitle) {
currentMap = titleTextPaints;
textSize = AndroidUtilities.dp(24.0f);
textColor = getTextColor();
} else if (parentBlock instanceof TLRPC.TL_pageBlockKicker) {
currentMap = kickerTextPaints;
textSize = AndroidUtilities.dp(14.0f);
textColor = getTextColor();
} else if (parentBlock instanceof TLRPC.TL_pageBlockAuthorDate) {
currentMap = authorTextPaints;
textSize = AndroidUtilities.dp(14.0f);
textColor = getGrayTextColor();
} else if (parentBlock instanceof TLRPC.TL_pageBlockFooter) {
currentMap = footerTextPaints;
textSize = AndroidUtilities.dp(14.0f);
textColor = getGrayTextColor();
} else if (parentBlock instanceof TLRPC.TL_pageBlockSubtitle) {
currentMap = subtitleTextPaints;
textSize = AndroidUtilities.dp(21.0f);
textColor = getTextColor();
} else if (parentBlock instanceof TLRPC.TL_pageBlockHeader) {
currentMap = headerTextPaints;
textSize = AndroidUtilities.dp(21.0f);
textColor = getTextColor();
} else if (parentBlock instanceof TLRPC.TL_pageBlockSubheader) {
currentMap = subheaderTextPaints;
textSize = AndroidUtilities.dp(18.0f);
textColor = getTextColor();
} else if (parentBlock instanceof TLRPC.TL_pageBlockBlockquote) {
TLRPC.TL_pageBlockBlockquote pageBlockBlockquote = (TLRPC.TL_pageBlockBlockquote) parentBlock;
if (pageBlockBlockquote.text == parentRichText) {
currentMap = quoteTextPaints;
textSize = AndroidUtilities.dp(15.0f);
textColor = getTextColor();
} else if (pageBlockBlockquote.caption == parentRichText) {
currentMap = photoCaptionTextPaints;
textSize = AndroidUtilities.dp(14.0f);
textColor = getGrayTextColor();
}
} else if (parentBlock instanceof TLRPC.TL_pageBlockPullquote) {
TLRPC.TL_pageBlockPullquote pageBlockBlockquote2 = (TLRPC.TL_pageBlockPullquote) parentBlock;
if (pageBlockBlockquote2.text == parentRichText) {
currentMap = quoteTextPaints;
textSize = AndroidUtilities.dp(15.0f);
textColor = getTextColor();
} else if (pageBlockBlockquote2.caption == parentRichText) {
currentMap = photoCaptionTextPaints;
textSize = AndroidUtilities.dp(14.0f);
textColor = getGrayTextColor();
}
} else if (parentBlock instanceof TLRPC.TL_pageBlockPreformatted) {
currentMap = preformattedTextPaints;
textSize = AndroidUtilities.dp(14.0f);
textColor = getTextColor();
} else if (parentBlock instanceof TLRPC.TL_pageBlockParagraph) {
currentMap = paragraphTextPaints;
textSize = AndroidUtilities.dp(16.0f);
textColor = getTextColor();
} else if (isListItemBlock(parentBlock)) {
currentMap = listTextPaints;
textSize = AndroidUtilities.dp(16.0f);
textColor = getTextColor();
} else if (parentBlock instanceof TLRPC.TL_pageBlockEmbed) {
TLRPC.TL_pageBlockEmbed pageBlockEmbed = (TLRPC.TL_pageBlockEmbed) parentBlock;
if (pageBlockEmbed.caption.text == richText || pageBlockEmbed.caption.text == parentRichText) {
currentMap = photoCaptionTextPaints;
textSize = AndroidUtilities.dp(14.0f);
} else {
currentMap = photoCreditTextPaints;
textSize = AndroidUtilities.dp(12.0f);
}
textColor = getGrayTextColor();
} else if (parentBlock instanceof TLRPC.TL_pageBlockSlideshow) {
TLRPC.TL_pageBlockSlideshow pageBlockSlideshow = (TLRPC.TL_pageBlockSlideshow) parentBlock;
if (pageBlockSlideshow.caption.text == richText || pageBlockSlideshow.caption.text == parentRichText) {
currentMap = photoCaptionTextPaints;
textSize = AndroidUtilities.dp(14.0f);
} else {
currentMap = photoCreditTextPaints;
textSize = AndroidUtilities.dp(12.0f);
}
textColor = getGrayTextColor();
} else if (parentBlock instanceof TLRPC.TL_pageBlockCollage) {
TLRPC.TL_pageBlockCollage pageBlockCollage = (TLRPC.TL_pageBlockCollage) parentBlock;
if (pageBlockCollage.caption.text == richText || pageBlockCollage.caption.text == parentRichText) {
currentMap = photoCaptionTextPaints;
textSize = AndroidUtilities.dp(14.0f);
} else {
currentMap = photoCreditTextPaints;
textSize = AndroidUtilities.dp(12.0f);
}
textColor = getGrayTextColor();
} else if (parentBlock instanceof TLRPC.TL_pageBlockEmbedPost) {
TLRPC.TL_pageBlockEmbedPost pageBlockEmbedPost = (TLRPC.TL_pageBlockEmbedPost) parentBlock;
if (richText == pageBlockEmbedPost.caption.text) {
currentMap = photoCaptionTextPaints;
textSize = AndroidUtilities.dp(14.0f);
textColor = getGrayTextColor();
} else if (richText == pageBlockEmbedPost.caption.credit) {
currentMap = photoCreditTextPaints;
textSize = AndroidUtilities.dp(12.0f);
textColor = getGrayTextColor();
} else if (richText != null) {
currentMap = embedPostTextPaints;
textSize = AndroidUtilities.dp(14.0f);
textColor = getTextColor();
}
} else if (parentBlock instanceof TLRPC.TL_pageBlockVideo) {
TLRPC.TL_pageBlockVideo pageBlockVideo = (TLRPC.TL_pageBlockVideo) parentBlock;
if (richText == pageBlockVideo.caption.text) {
currentMap = mediaCaptionTextPaints;
textSize = AndroidUtilities.dp(14.0f);
textColor = getTextColor();
} else {
currentMap = mediaCreditTextPaints;
textSize = AndroidUtilities.dp(12.0f);
textColor = getTextColor();
}
} else if (parentBlock instanceof TLRPC.TL_pageBlockAudio) {
TLRPC.TL_pageBlockAudio pageBlockAudio = (TLRPC.TL_pageBlockAudio) parentBlock;
if (richText == pageBlockAudio.caption.text) {
currentMap = mediaCaptionTextPaints;
textSize = AndroidUtilities.dp(14.0f);
textColor = getTextColor();
} else {
currentMap = mediaCreditTextPaints;
textSize = AndroidUtilities.dp(12.0f);
textColor = getTextColor();
}
} else if (parentBlock instanceof TLRPC.TL_pageBlockRelatedArticles) {
currentMap = relatedArticleTextPaints;
textSize = AndroidUtilities.dp(15.0f);
textColor = getGrayTextColor();
} else if (parentBlock instanceof TLRPC.TL_pageBlockDetails) {
currentMap = detailsTextPaints;
textSize = AndroidUtilities.dp(15.0f);
textColor = getTextColor();
} else if (parentBlock instanceof TLRPC.TL_pageBlockTable) {
currentMap = tableTextPaints;
textSize = AndroidUtilities.dp(15.0f);
textColor = getTextColor();
}
if ((flags & 256) != 0 || (flags & 128) != 0) {
textSize -= AndroidUtilities.dp(4.0f);
}
if (currentMap == 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 paint = currentMap.get(flags);
if (paint == null) {
paint = new TextPaint(1);
if ((flags & 4) != 0) {
paint.setTypeface(AndroidUtilities.getTypeface("fonts/rmono.ttf"));
} else if (parentBlock instanceof TLRPC.TL_pageBlockRelatedArticles) {
paint.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
} else if (this.selectedFont == 1 || (parentBlock instanceof TLRPC.TL_pageBlockTitle) || (parentBlock instanceof TLRPC.TL_pageBlockKicker) || (parentBlock instanceof TLRPC.TL_pageBlockHeader) || (parentBlock instanceof TLRPC.TL_pageBlockSubtitle) || (parentBlock instanceof TLRPC.TL_pageBlockSubheader)) {
if ((flags & 1) != 0 && (flags & 2) != 0) {
paint.setTypeface(Typeface.create(C.SERIF_NAME, 3));
} else if ((flags & 1) != 0) {
paint.setTypeface(Typeface.create(C.SERIF_NAME, 1));
} else if ((flags & 2) != 0) {
paint.setTypeface(Typeface.create(C.SERIF_NAME, 2));
} else {
paint.setTypeface(Typeface.create(C.SERIF_NAME, 0));
}
} else if ((flags & 1) != 0 && (flags & 2) != 0) {
paint.setTypeface(AndroidUtilities.getTypeface("fonts/rmediumitalic.ttf"));
} else if ((flags & 1) != 0) {
paint.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
} else if ((flags & 2) != 0) {
paint.setTypeface(AndroidUtilities.getTypeface("fonts/ritalic.ttf"));
}
if ((flags & 32) != 0) {
paint.setFlags(paint.getFlags() | 16);
}
if ((flags & 16) != 0) {
paint.setFlags(paint.getFlags() | 8);
}
if ((flags & 8) != 0 || (flags & 512) != 0) {
paint.setFlags(paint.getFlags());
textColor = getLinkTextColor();
}
if ((flags & 256) != 0) {
paint.baselineShift -= AndroidUtilities.dp(6.0f);
} else if ((flags & 128) != 0) {
paint.baselineShift += AndroidUtilities.dp(2.0f);
}
paint.setColor(textColor);
currentMap.put(flags, paint);
}
paint.setTextSize(textSize + additionalSize);
return paint;
}
public DrawingText createLayoutForText(View parentView, CharSequence plainText, TLRPC.RichText richText, int width, TLRPC.PageBlock parentBlock, WebpageAdapter parentAdapter) {
return createLayoutForText(parentView, plainText, richText, width, 0, parentBlock, Layout.Alignment.ALIGN_NORMAL, 0, parentAdapter);
}
public DrawingText createLayoutForText(View parentView, CharSequence plainText, TLRPC.RichText richText, int width, TLRPC.PageBlock parentBlock, Layout.Alignment align, WebpageAdapter parentAdapter) {
return createLayoutForText(parentView, plainText, richText, width, 0, parentBlock, align, 0, parentAdapter);
}
private DrawingText createLayoutForText(View parentView, CharSequence plainText, TLRPC.RichText richText, int width, int textY, TLRPC.PageBlock parentBlock, WebpageAdapter parentAdapter) {
return createLayoutForText(parentView, plainText, richText, width, textY, parentBlock, Layout.Alignment.ALIGN_NORMAL, 0, parentAdapter);
}
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 i4;
CharSequence text;
int i5;
TextPaint textPaint;
StaticLayout staticLayout;
int i6;
CharSequence charSequence2;
int i7;
if (charSequence == null && (richText == null || (richText instanceof TLRPC.TL_textEmpty))) {
return null;
}
if (i >= 0) {
i4 = i;
} else {
i4 = AndroidUtilities.dp(10.0f);
}
int selectedColor = getSelectedColor();
if (charSequence != null) {
text = charSequence;
} else {
text = getText(view, richText, richText, pageBlock, i4);
}
if (TextUtils.isEmpty(text)) {
return null;
}
int i8 = this.selectedFontSize;
if (i8 == 0) {
i5 = -AndroidUtilities.dp(4.0f);
} else if (i8 == 1) {
i5 = -AndroidUtilities.dp(2.0f);
} else if (i8 == 3) {
i5 = AndroidUtilities.dp(2.0f);
} else if (i8 == 4) {
i5 = AndroidUtilities.dp(4.0f);
} else {
i5 = 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) + i5);
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) + i5);
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)) {
if (isListItemBlock(pageBlock) && charSequence != null) {
if (listTextPointerPaint == null) {
TextPaint textPaint5 = new TextPaint(1);
listTextPointerPaint = textPaint5;
textPaint5.setColor(getTextColor());
}
if (listTextNumPaint == null) {
TextPaint textPaint6 = new TextPaint(1);
listTextNumPaint = textPaint6;
textPaint6.setColor(getTextColor());
}
listTextPointerPaint.setTextSize(AndroidUtilities.dp(19.0f) + i5);
listTextNumPaint.setTextSize(AndroidUtilities.dp(16.0f) + i5);
if ((pageBlock instanceof TL_pageBlockListItem) && !((TL_pageBlockListItem) pageBlock).parent.pageBlockList.ordered) {
textPaint = listTextPointerPaint;
} else {
textPaint = listTextNumPaint;
}
} else {
textPaint = getTextPaint(richText, richText, pageBlock);
}
} else {
TL_pageBlockRelatedArticlesChild tL_pageBlockRelatedArticlesChild = (TL_pageBlockRelatedArticlesChild) pageBlock;
if (charSequence == tL_pageBlockRelatedArticlesChild.parent.articles.get(tL_pageBlockRelatedArticlesChild.num).title) {
if (relatedArticleHeaderPaint == null) {
TextPaint textPaint7 = new TextPaint(1);
relatedArticleHeaderPaint = textPaint7;
textPaint7.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
}
relatedArticleHeaderPaint.setColor(getTextColor());
relatedArticleHeaderPaint.setTextSize(AndroidUtilities.dp(15.0f) + i5);
textPaint = relatedArticleHeaderPaint;
} else {
if (relatedArticleTextPaint == null) {
relatedArticleTextPaint = new TextPaint(1);
}
relatedArticleTextPaint.setColor(getGrayTextColor());
relatedArticleTextPaint.setTextSize(AndroidUtilities.dp(14.0f) + i5);
textPaint = relatedArticleTextPaint;
}
}
if (i3 != 0) {
if (pageBlock instanceof TLRPC.TL_pageBlockPullquote) {
staticLayout = StaticLayoutEx.createStaticLayout(text, textPaint, i4, Layout.Alignment.ALIGN_CENTER, 1.0f, 0.0f, false, TextUtils.TruncateAt.END, i4, i3);
} else {
staticLayout = StaticLayoutEx.createStaticLayout(text, textPaint, i4, alignment, 1.0f, AndroidUtilities.dp(4.0f), false, TextUtils.TruncateAt.END, i4, i3);
}
} else {
if (text.charAt(text.length() - 1) == '\n') {
text = text.subSequence(0, text.length() - 1);
}
if (pageBlock instanceof TLRPC.TL_pageBlockPullquote) {
staticLayout = new StaticLayout(text, textPaint, i4, Layout.Alignment.ALIGN_CENTER, 1.0f, 0.0f, false);
} else {
staticLayout = new StaticLayout(text, textPaint, i4, alignment, 1.0f, AndroidUtilities.dp(4.0f), false);
}
}
if (staticLayout == null) {
return null;
}
CharSequence text2 = staticLayout.getText();
LinkPath linkPath = null;
linkPath = null;
linkPath = null;
linkPath = null;
LinkPath linkPath2 = null;
if (staticLayout != null && (text2 instanceof Spanned)) {
Spanned spanned = (Spanned) text2;
try {
AnchorSpan[] anchorSpanArr = (AnchorSpan[]) spanned.getSpans(0, spanned.length(), AnchorSpan.class);
int lineCount = staticLayout.getLineCount();
if (anchorSpanArr != null && anchorSpanArr.length > 0) {
int i9 = 0;
while (i9 < anchorSpanArr.length) {
if (lineCount > 1) {
charSequence2 = text;
i7 = i5;
webpageAdapter.anchorsOffset.put(anchorSpanArr[i9].getName(), Integer.valueOf(i2 + staticLayout.getLineTop(staticLayout.getLineForOffset(spanned.getSpanStart(anchorSpanArr[i9])))));
} else {
charSequence2 = text;
try {
i7 = i5;
try {
webpageAdapter.anchorsOffset.put(anchorSpanArr[i9].getName(), Integer.valueOf(i2));
} catch (Exception e) {
}
} catch (Exception e2) {
}
}
i9++;
i5 = i7;
text = charSequence2;
}
}
} catch (Exception e3) {
}
float f = 0.0f;
try {
TextPaintWebpageUrlSpan[] textPaintWebpageUrlSpanArr = (TextPaintWebpageUrlSpan[]) spanned.getSpans(0, spanned.length(), TextPaintWebpageUrlSpan.class);
if (textPaintWebpageUrlSpanArr != null && textPaintWebpageUrlSpanArr.length > 0) {
linkPath = new LinkPath(true);
linkPath.setAllowReset(false);
int i10 = 0;
while (i10 < textPaintWebpageUrlSpanArr.length) {
int spanStart = spanned.getSpanStart(textPaintWebpageUrlSpanArr[i10]);
int spanEnd = spanned.getSpanEnd(textPaintWebpageUrlSpanArr[i10]);
linkPath.setCurrentLayout(staticLayout, spanStart, f);
int i11 = textPaintWebpageUrlSpanArr[i10].getTextPaint() != null ? textPaintWebpageUrlSpanArr[i10].getTextPaint().baselineShift : 0;
if (i11 != 0) {
i6 = i11 + AndroidUtilities.dp(i11 > 0 ? 5.0f : -2.0f);
} else {
i6 = 0;
}
linkPath.setBaselineShift(i6);
staticLayout.getSelectionPath(spanStart, spanEnd, linkPath);
i10++;
f = 0.0f;
}
linkPath.setAllowReset(true);
}
} catch (Exception e4) {
}
try {
TextPaintMarkSpan[] textPaintMarkSpanArr = (TextPaintMarkSpan[]) spanned.getSpans(0, spanned.length(), TextPaintMarkSpan.class);
if (textPaintMarkSpanArr != null && textPaintMarkSpanArr.length > 0) {
LinkPath linkPath3 = new LinkPath(true);
int i12 = 0;
try {
linkPath3.setAllowReset(false);
int i13 = 0;
while (i13 < textPaintMarkSpanArr.length) {
int spanStart2 = spanned.getSpanStart(textPaintMarkSpanArr[i13]);
int spanEnd2 = spanned.getSpanEnd(textPaintMarkSpanArr[i13]);
linkPath3.setCurrentLayout(staticLayout, spanStart2, 0.0f);
int i14 = textPaintMarkSpanArr[i13].getTextPaint() != null ? textPaintMarkSpanArr[i13].getTextPaint().baselineShift : 0;
if (i14 != 0) {
i12 = i14 + AndroidUtilities.dp(i14 > 0 ? 5.0f : -2.0f);
}
linkPath3.setBaselineShift(i12);
staticLayout.getSelectionPath(spanStart2, spanEnd2, linkPath3);
i13++;
i12 = 0;
}
linkPath3.setAllowReset(true);
linkPath2 = linkPath3;
} catch (Exception e5) {
linkPath2 = linkPath3;
}
}
} catch (Exception e6) {
}
}
DrawingText drawingText = new DrawingText();
drawingText.textLayout = staticLayout;
drawingText.textPath = linkPath;
drawingText.markPath = linkPath2;
return drawingText;
}
public void drawLayoutLink(Canvas canvas, DrawingText layout) {
float width;
float x;
if (canvas == null || layout == null || this.pressedLinkOwnerLayout != layout) {
return;
}
if (this.pressedLink != null) {
canvas.drawPath(this.urlPath, urlPaint);
return;
}
if (this.drawBlockSelection && layout != null) {
if (layout.getLineCount() == 1) {
width = layout.getLineWidth(0);
x = layout.getLineLeft(0);
} else {
width = layout.getWidth();
x = 0.0f;
}
canvas.drawRect((-AndroidUtilities.dp(2.0f)) + x, 0.0f, x + width + AndroidUtilities.dp(2.0f), layout.getHeight(), urlPaint);
}
}
public boolean checkLayoutForLinks(MotionEvent event, View parentView, DrawingText drawingText, int layoutX, int layoutY) {
ActionBarPopupWindow actionBarPopupWindow;
String anchor;
String webPageUrl;
TextPaintUrlSpan[] link;
int end;
if (this.pageSwitchAnimation != null || parentView == null || drawingText == null) {
return false;
}
StaticLayout layout = drawingText.textLayout;
int x = (int) event.getX();
int y = (int) event.getY();
boolean removeLink = false;
if (event.getAction() == 0) {
int N = layout.getLineCount();
float width = 0.0f;
float left = 2.14748365E9f;
for (int a = 0; a < N; a++) {
width = Math.max(layout.getLineWidth(a), width);
left = Math.min(layout.getLineLeft(a), left);
}
if (x >= layoutX + left && x <= layoutX + left + width && y >= layoutY && y <= layout.getHeight() + layoutY) {
this.pressedLinkOwnerLayout = drawingText;
this.pressedLinkOwnerView = parentView;
this.pressedLayoutY = layoutY;
CharSequence text = layout.getText();
if (text instanceof Spannable) {
int checkX = x - layoutX;
int checkY = y - layoutY;
try {
int line = layout.getLineForVertical(checkY);
int off = layout.getOffsetForHorizontal(line, checkX);
float left2 = layout.getLineLeft(line);
if (left2 <= checkX && layout.getLineWidth(line) + left2 >= checkX) {
Spannable buffer = (Spannable) layout.getText();
TextPaintUrlSpan[] link2 = (TextPaintUrlSpan[]) buffer.getSpans(off, off, TextPaintUrlSpan.class);
if (link2 != null && link2.length > 0) {
TextPaintUrlSpan textPaintUrlSpan = link2[0];
this.pressedLink = textPaintUrlSpan;
int pressedStart = buffer.getSpanStart(textPaintUrlSpan);
int pressedEnd = buffer.getSpanEnd(this.pressedLink);
int pressedStart2 = pressedStart;
int pressedEnd2 = pressedEnd;
int pressedEnd3 = 1;
while (true) {
int x2 = x;
try {
if (pressedEnd3 >= link2.length) {
break;
}
TextPaintUrlSpan span = link2[pressedEnd3];
int start = buffer.getSpanStart(span);
int end2 = buffer.getSpanEnd(span);
Spannable buffer2 = buffer;
if (pressedStart2 <= start) {
link = link2;
end = end2;
if (end <= pressedEnd2) {
pressedEnd3++;
x = x2;
buffer = buffer2;
link2 = link;
}
} else {
link = link2;
end = end2;
}
this.pressedLink = span;
pressedStart2 = start;
pressedEnd2 = end;
pressedEnd3++;
x = x2;
buffer = buffer2;
link2 = link;
} catch (Exception e) {
e = e;
FileLog.e(e);
if (removeLink) {
}
if (event.getAction() == 0) {
}
if (event.getAction() != 0) {
cancelCheckLongPress();
}
if (!(parentView instanceof BlockDetailsCell)) {
}
}
}
try {
this.urlPath.setUseRoundRect(true);
this.urlPath.setCurrentLayout(layout, pressedStart2, 0.0f);
int shift = this.pressedLink.getTextPaint() != null ? this.pressedLink.getTextPaint().baselineShift : 0;
this.urlPath.setBaselineShift(shift != 0 ? AndroidUtilities.dp(shift > 0 ? 5.0f : -2.0f) + shift : 0);
layout.getSelectionPath(pressedStart2, pressedEnd2, this.urlPath);
parentView.invalidate();
} catch (Exception e2) {
FileLog.e(e2);
}
}
}
} catch (Exception e3) {
e = e3;
}
}
}
} else if (event.getAction() == 1) {
TextPaintUrlSpan textPaintUrlSpan2 = this.pressedLink;
if (textPaintUrlSpan2 != null) {
removeLink = true;
String url = textPaintUrlSpan2.getUrl();
if (url != null) {
BottomSheet bottomSheet = this.linkSheet;
if (bottomSheet != null) {
bottomSheet.dismiss();
this.linkSheet = null;
}
boolean isAnchor = false;
int index = url.lastIndexOf(35);
if (index != -1) {
if (!TextUtils.isEmpty(this.currentPage.cached_page.url)) {
webPageUrl = this.currentPage.cached_page.url.toLowerCase();
} else {
webPageUrl = this.currentPage.url.toLowerCase();
}
try {
anchor = URLDecoder.decode(url.substring(index + 1), "UTF-8");
} catch (Exception e4) {
anchor = "";
}
if (url.toLowerCase().contains(webPageUrl)) {
if (TextUtils.isEmpty(anchor)) {
this.layoutManager[0].scrollToPositionWithOffset(0, 0);
checkScrollAnimated();
} else {
scrollToAnchor(anchor);
}
isAnchor = true;
}
} else {
anchor = null;
}
if (!isAnchor) {
openWebpageUrl(this.pressedLink.getUrl(), anchor);
}
}
}
} else if (event.getAction() == 3 && ((actionBarPopupWindow = this.popupWindow) == null || !actionBarPopupWindow.isShowing())) {
removeLink = true;
}
if (removeLink) {
removePressedLink();
}
if (event.getAction() == 0) {
startCheckLongPress();
}
if (event.getAction() != 0 && event.getAction() != 2) {
cancelCheckLongPress();
}
return !(parentView instanceof BlockDetailsCell) ? this.pressedLink != null : this.pressedLinkOwnerLayout != null;
}
public void removePressedLink() {
if (this.pressedLink == null && this.pressedLinkOwnerView == null) {
return;
}
View parentView = this.pressedLinkOwnerView;
this.pressedLink = null;
this.pressedLinkOwnerLayout = null;
this.pressedLinkOwnerView = null;
if (parentView != null) {
parentView.invalidate();
}
}
public void openWebpageUrl(String url, final String anchor) {
if (this.openUrlReqId != 0) {
ConnectionsManager.getInstance(this.currentAccount).cancelRequest(this.openUrlReqId, false);
this.openUrlReqId = 0;
}
final int reqId = this.lastReqId + 1;
this.lastReqId = reqId;
closePhoto(false);
showProgressView(true, true);
final TLRPC.TL_messages_getWebPage req = new TLRPC.TL_messages_getWebPage();
req.url = url;
req.hash = 0;
this.openUrlReqId = ConnectionsManager.getInstance(this.currentAccount).sendRequest(req, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
ArticleViewer.this.m1061lambda$openWebpageUrl$6$imwsnshelzviuiArticleViewer(reqId, anchor, req, tLObject, tL_error);
}
});
}
public void m1061lambda$openWebpageUrl$6$imwsnshelzviuiArticleViewer(final int reqId, final String anchor, final TLRPC.TL_messages_getWebPage req, final TLObject response, TLRPC.TL_error error) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
ArticleViewer.this.m1060lambda$openWebpageUrl$5$imwsnshelzviuiArticleViewer(reqId, response, anchor, req);
}
});
}
public void m1060lambda$openWebpageUrl$5$imwsnshelzviuiArticleViewer(int reqId, TLObject response, String anchor, TLRPC.TL_messages_getWebPage req) {
if (this.openUrlReqId == 0 || reqId != this.lastReqId) {
return;
}
this.openUrlReqId = 0;
showProgressView(true, false);
if (this.isVisible) {
if ((response instanceof TLRPC.TL_webPage) && (((TLRPC.TL_webPage) response).cached_page instanceof TLRPC.TL_page)) {
addPageToStack((TLRPC.TL_webPage) response, anchor, 1);
} else {
Browser.openUrl(this.parentActivity, req.url);
}
}
}
public TLRPC.Photo getPhotoWithId(long id) {
TLRPC.WebPage webPage = this.currentPage;
if (webPage == null || webPage.cached_page == null) {
return null;
}
if (this.currentPage.photo != null && this.currentPage.photo.id == id) {
return this.currentPage.photo;
}
for (int a = 0; a < this.currentPage.cached_page.photos.size(); a++) {
TLRPC.Photo photo = this.currentPage.cached_page.photos.get(a);
if (photo.id == id) {
return photo;
}
}
return null;
}
public TLRPC.Document getDocumentWithId(long id) {
TLRPC.WebPage webPage = this.currentPage;
if (webPage == null || webPage.cached_page == null) {
return null;
}
if (this.currentPage.document != null && this.currentPage.document.id == id) {
return this.currentPage.document;
}
for (int a = 0; a < this.currentPage.cached_page.documents.size(); a++) {
TLRPC.Document document = this.currentPage.cached_page.documents.get(a);
if (document.id == id) {
return document;
}
}
return null;
}
@Override
public void didReceivedNotification(int id, int account, Object... args) {
BlockAudioCell cell;
MessageObject playing;
if (id == NotificationCenter.fileDidFailToLoad) {
String location = (String) args[0];
for (int a = 0; a < 3; a++) {
String str = this.currentFileNames[a];
if (str != null && str.equals(location)) {
this.radialProgressViews[a].setProgress(1.0f, true);
checkProgress(a, true);
return;
}
}
return;
}
if (id == NotificationCenter.fileDidLoad) {
String location2 = (String) args[0];
for (int a2 = 0; a2 < 3; a2++) {
String str2 = this.currentFileNames[a2];
if (str2 != null && str2.equals(location2)) {
this.radialProgressViews[a2].setProgress(1.0f, true);
checkProgress(a2, true);
if (a2 == 0 && isMediaVideo(this.currentIndex)) {
onActionClick(false);
return;
}
return;
}
}
return;
}
if (id == NotificationCenter.FileLoadProgressChanged) {
String location3 = (String) args[0];
for (int a3 = 0; a3 < 3; a3++) {
String str3 = this.currentFileNames[a3];
if (str3 != null && str3.equals(location3)) {
Float progress = (Float) args[1];
this.radialProgressViews[a3].setProgress(progress.floatValue(), true);
}
}
return;
}
if (id == NotificationCenter.emojiDidLoad) {
TextView textView = this.captionTextView;
if (textView != null) {
textView.invalidate();
return;
}
return;
}
if (id == NotificationCenter.needSetDayNightTheme) {
if (this.nightModeEnabled && this.selectedColor != 2 && this.adapter != null) {
updatePaintColors();
for (int i = 0; i < this.listView.length; i++) {
this.adapter[i].notifyDataSetChanged();
}
return;
}
return;
}
if (id == NotificationCenter.messagePlayingDidStart) {
if (this.listView != null) {
int i2 = 0;
while (true) {
RecyclerListView[] recyclerListViewArr = this.listView;
if (i2 < recyclerListViewArr.length) {
int count = recyclerListViewArr[i2].getChildCount();
for (int a4 = 0; a4 < count; a4++) {
View view = this.listView[i2].getChildAt(a4);
if (view instanceof BlockAudioCell) {
((BlockAudioCell) view).updateButtonState(true);
}
}
i2++;
} else {
return;
}
}
}
} else if (id == NotificationCenter.messagePlayingDidReset || id == NotificationCenter.messagePlayingPlayStateChanged) {
if (this.listView != null) {
int i3 = 0;
while (true) {
RecyclerListView[] recyclerListViewArr2 = this.listView;
if (i3 < recyclerListViewArr2.length) {
int count2 = recyclerListViewArr2[i3].getChildCount();
for (int a5 = 0; a5 < count2; a5++) {
View view2 = this.listView[i3].getChildAt(a5);
if (view2 instanceof BlockAudioCell) {
BlockAudioCell cell2 = (BlockAudioCell) view2;
MessageObject messageObject = cell2.getMessageObject();
if (messageObject != null) {
cell2.updateButtonState(true);
}
}
}
i3++;
} else {
return;
}
}
}
} else if (id == NotificationCenter.messagePlayingProgressDidChanged) {
Integer mid = (Integer) args[0];
if (this.listView != null) {
int i4 = 0;
while (true) {
RecyclerListView[] recyclerListViewArr3 = this.listView;
if (i4 < recyclerListViewArr3.length) {
int count3 = recyclerListViewArr3[i4].getChildCount();
int a6 = 0;
while (true) {
if (a6 < count3) {
View view3 = this.listView[i4].getChildAt(a6);
if (!(view3 instanceof BlockAudioCell) || (playing = (cell = (BlockAudioCell) view3).getMessageObject()) == null || playing.getId() != mid.intValue()) {
a6++;
} else {
MessageObject player = MediaController.getInstance().getPlayingMessageObject();
if (player != null) {
playing.audioProgress = player.audioProgress;
playing.audioProgressSec = player.audioProgressSec;
playing.audioPlayerDuration = player.audioPlayerDuration;
cell.updatePlayingMessageProgress();
}
}
}
}
i4++;
} else {
return;
}
}
}
}
}
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 typefaceNormal = this.selectedFont == 0 ? Typeface.DEFAULT : Typeface.SERIF;
Typeface typefaceItalic = this.selectedFont == 0 ? AndroidUtilities.getTypeface("fonts/ritalic.ttf") : Typeface.create(C.SERIF_NAME, 2);
Typeface typefaceBold = this.selectedFont == 0 ? AndroidUtilities.getTypeface("fonts/rmedium.ttf") : Typeface.create(C.SERIF_NAME, 1);
Typeface typefaceBoldItalic = this.selectedFont == 0 ? AndroidUtilities.getTypeface("fonts/rmediumitalic.ttf") : Typeface.create(C.SERIF_NAME, 3);
for (int a = 0; a < quoteTextPaints.size(); a++) {
updateFontEntry(quoteTextPaints.keyAt(a), quoteTextPaints.valueAt(a), typefaceNormal, typefaceBoldItalic, typefaceBold, typefaceItalic);
}
for (int a2 = 0; a2 < preformattedTextPaints.size(); a2++) {
updateFontEntry(preformattedTextPaints.keyAt(a2), preformattedTextPaints.valueAt(a2), typefaceNormal, typefaceBoldItalic, typefaceBold, typefaceItalic);
}
for (int a3 = 0; a3 < paragraphTextPaints.size(); a3++) {
updateFontEntry(paragraphTextPaints.keyAt(a3), paragraphTextPaints.valueAt(a3), typefaceNormal, typefaceBoldItalic, typefaceBold, typefaceItalic);
}
for (int a4 = 0; a4 < listTextPaints.size(); a4++) {
updateFontEntry(listTextPaints.keyAt(a4), listTextPaints.valueAt(a4), typefaceNormal, typefaceBoldItalic, typefaceBold, typefaceItalic);
}
for (int a5 = 0; a5 < embedPostTextPaints.size(); a5++) {
updateFontEntry(embedPostTextPaints.keyAt(a5), embedPostTextPaints.valueAt(a5), typefaceNormal, typefaceBoldItalic, typefaceBold, typefaceItalic);
}
for (int a6 = 0; a6 < mediaCaptionTextPaints.size(); a6++) {
updateFontEntry(mediaCaptionTextPaints.keyAt(a6), mediaCaptionTextPaints.valueAt(a6), typefaceNormal, typefaceBoldItalic, typefaceBold, typefaceItalic);
}
for (int a7 = 0; a7 < mediaCreditTextPaints.size(); a7++) {
updateFontEntry(mediaCreditTextPaints.keyAt(a7), mediaCreditTextPaints.valueAt(a7), typefaceNormal, typefaceBoldItalic, typefaceBold, typefaceItalic);
}
for (int a8 = 0; a8 < photoCaptionTextPaints.size(); a8++) {
updateFontEntry(photoCaptionTextPaints.keyAt(a8), photoCaptionTextPaints.valueAt(a8), typefaceNormal, typefaceBoldItalic, typefaceBold, typefaceItalic);
}
for (int a9 = 0; a9 < photoCreditTextPaints.size(); a9++) {
updateFontEntry(photoCreditTextPaints.keyAt(a9), photoCreditTextPaints.valueAt(a9), typefaceNormal, typefaceBoldItalic, typefaceBold, typefaceItalic);
}
for (int a10 = 0; a10 < authorTextPaints.size(); a10++) {
updateFontEntry(authorTextPaints.keyAt(a10), authorTextPaints.valueAt(a10), typefaceNormal, typefaceBoldItalic, typefaceBold, typefaceItalic);
}
for (int a11 = 0; a11 < footerTextPaints.size(); a11++) {
updateFontEntry(footerTextPaints.keyAt(a11), footerTextPaints.valueAt(a11), typefaceNormal, typefaceBoldItalic, typefaceBold, typefaceItalic);
}
for (int a12 = 0; a12 < embedPostCaptionTextPaints.size(); a12++) {
updateFontEntry(embedPostCaptionTextPaints.keyAt(a12), embedPostCaptionTextPaints.valueAt(a12), typefaceNormal, typefaceBoldItalic, typefaceBold, typefaceItalic);
}
for (int a13 = 0; a13 < relatedArticleTextPaints.size(); a13++) {
updateFontEntry(relatedArticleTextPaints.keyAt(a13), relatedArticleTextPaints.valueAt(a13), typefaceNormal, typefaceBoldItalic, typefaceBold, typefaceItalic);
}
for (int a14 = 0; a14 < detailsTextPaints.size(); a14++) {
updateFontEntry(detailsTextPaints.keyAt(a14), detailsTextPaints.valueAt(a14), typefaceNormal, typefaceBoldItalic, typefaceBold, typefaceItalic);
}
for (int a15 = 0; a15 < tableTextPaints.size(); a15++) {
updateFontEntry(tableTextPaints.keyAt(a15), tableTextPaints.valueAt(a15), typefaceNormal, typefaceBoldItalic, typefaceBold, typefaceItalic);
}
}
private void updateFontEntry(int flags, TextPaint paint, Typeface typefaceNormal, Typeface typefaceBoldItalic, Typeface typefaceBold, Typeface typefaceItalic) {
if ((flags & 1) != 0 && (flags & 2) != 0) {
paint.setTypeface(typefaceBoldItalic);
return;
}
if ((flags & 1) != 0) {
paint.setTypeface(typefaceBold);
} else if ((flags & 2) != 0) {
paint.setTypeface(typefaceItalic);
} else if ((flags & 4) == 0) {
paint.setTypeface(typefaceNormal);
}
}
public int getSelectedColor() {
int currentColor = this.selectedColor;
if (this.nightModeEnabled && currentColor != 2) {
if (Theme.selectedAutoNightType != 0) {
if (Theme.isCurrentThemeNight()) {
return 2;
}
return currentColor;
}
int hour = Calendar.getInstance().get(11);
if ((hour >= 22 && hour <= 24) || (hour >= 0 && hour <= 6)) {
return 2;
}
return currentColor;
}
return currentColor;
}
private void updatePaintColors() {
ApplicationLoader.applicationContext.getSharedPreferences("articles", 0).edit().putInt("font_color", this.selectedColor).commit();
int currentColor = getSelectedColor();
if (currentColor == 0) {
this.backgroundPaint.setColor(-1);
int i = 0;
while (true) {
RecyclerListView[] recyclerListViewArr = this.listView;
if (i >= recyclerListViewArr.length) {
break;
}
recyclerListViewArr[i].setGlowColor(-657673);
i++;
}
} else if (currentColor == 1) {
this.backgroundPaint.setColor(-659492);
int i2 = 0;
while (true) {
RecyclerListView[] recyclerListViewArr2 = this.listView;
if (i2 >= recyclerListViewArr2.length) {
break;
}
recyclerListViewArr2[i2].setGlowColor(-659492);
i2++;
}
} else if (currentColor == 2) {
this.backgroundPaint.setColor(-15461356);
int i3 = 0;
while (true) {
RecyclerListView[] recyclerListViewArr3 = this.listView;
if (i3 >= recyclerListViewArr3.length) {
break;
}
recyclerListViewArr3[i3].setGlowColor(-15461356);
i3++;
}
}
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 (currentColor == 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> map) {
for (int a = 0; a < map.size(); a++) {
int flags = map.keyAt(a);
TextPaint paint = map.valueAt(a);
if ((flags & 8) != 0 || (flags & 512) != 0) {
paint.setColor(getLinkTextColor());
} else {
paint.setColor(getTextColor());
}
}
}
public void setParentActivity(Activity activity, BaseFragment fragment) {
this.parentFragment = fragment;
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 child, long drawingTime) {
int clipLeft;
int clipRight;
float opacity;
if (ArticleViewer.this.windowView.movingPage) {
int width = getMeasuredWidth();
int translationX = (int) ArticleViewer.this.listView[0].getTranslationX();
if (child != ArticleViewer.this.listView[1]) {
if (child != ArticleViewer.this.listView[0]) {
clipLeft = 0;
clipRight = width;
} else {
clipLeft = translationX;
clipRight = width;
}
} else {
clipLeft = 0;
clipRight = translationX;
}
int restoreCount = canvas.save();
canvas.clipRect(clipLeft, 0, clipRight, getHeight());
boolean result = super.drawChild(canvas, child, drawingTime);
canvas.restoreToCount(restoreCount);
if (translationX != 0) {
if (child != ArticleViewer.this.listView[0]) {
if (child == ArticleViewer.this.listView[1]) {
float opacity2 = Math.min(0.8f, (width - translationX) / width);
if (opacity2 >= 0.0f) {
opacity = opacity2;
} else {
opacity = 0.0f;
}
ArticleViewer.this.scrimPaint.setColor(((int) (153.0f * opacity)) << 24);
canvas.drawRect(clipLeft, 0.0f, clipRight, getHeight(), ArticleViewer.this.scrimPaint);
}
} else {
float alpha = Math.max(0.0f, Math.min((width - translationX) / AndroidUtilities.dp(20.0f), 1.0f));
ArticleViewer.this.layerShadowDrawable.setBounds(translationX - ArticleViewer.this.layerShadowDrawable.getIntrinsicWidth(), child.getTop(), translationX, child.getBottom());
ArticleViewer.this.layerShadowDrawable.setAlpha((int) (255.0f * alpha));
ArticleViewer.this.layerShadowDrawable.draw(canvas);
}
}
return result;
}
return super.drawChild(canvas, child, drawingTime);
}
};
this.containerView = frameLayout;
this.windowView.addView(frameLayout, LayoutHelper.createFrame(-1, -1, 51));
this.containerView.setFitsSystemWindows(true);
this.containerView.setOnApplyWindowInsetsListener(new View.OnApplyWindowInsetsListener() {
@Override
public final WindowInsets onApplyWindowInsets(View view, WindowInsets windowInsets) {
return ArticleViewer.this.m1072lambda$setParentActivity$7$imwsnshelzviuiArticleViewer(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 changed, int left, int top, int right, int bottom) {
super.onLayout(changed, left, top, right, bottom);
int y = (bottom - top) - ArticleViewer.this.captionTextView.getMeasuredHeight();
int y2 = (bottom - top) - ArticleViewer.this.groupedPhotosListView.getMeasuredHeight();
if (ArticleViewer.this.bottomLayout.getVisibility() == 0) {
y -= ArticleViewer.this.bottomLayout.getMeasuredHeight();
y2 -= ArticleViewer.this.bottomLayout.getMeasuredHeight();
}
if (!ArticleViewer.this.groupedPhotosListView.currentPhotos.isEmpty()) {
y -= ArticleViewer.this.groupedPhotosListView.getMeasuredHeight();
}
ArticleViewer.this.captionTextView.layout(0, y, ArticleViewer.this.captionTextView.getMeasuredWidth(), ArticleViewer.this.captionTextView.getMeasuredHeight() + y);
ArticleViewer.this.captionTextViewNext.layout(0, y, ArticleViewer.this.captionTextViewNext.getMeasuredWidth(), ArticleViewer.this.captionTextViewNext.getMeasuredHeight() + y);
ArticleViewer.this.groupedPhotosListView.layout(0, y2, ArticleViewer.this.groupedPhotosListView.getMeasuredWidth(), ArticleViewer.this.groupedPhotosListView.getMeasuredHeight() + y2);
}
};
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 changed, int l, int t, int r, int b) {
super.onLayout(changed, l, t, r, b);
int count = getChildCount();
for (int a = 0; a < count; a++) {
View child = getChildAt(a);
if (child.getTag() instanceof Integer) {
Integer tag = (Integer) child.getTag();
if (tag.intValue() == 90) {
int bottom = child.getBottom();
if (bottom < getMeasuredHeight()) {
int height = getMeasuredHeight();
child.layout(0, height - child.getMeasuredHeight(), child.getMeasuredWidth(), height);
return;
}
} else {
continue;
}
}
}
}
@Override
public boolean onInterceptTouchEvent(MotionEvent e) {
if (ArticleViewer.this.pressedLinkOwnerLayout == null || ArticleViewer.this.pressedLink != null || ((ArticleViewer.this.popupWindow != null && ArticleViewer.this.popupWindow.isShowing()) || (e.getAction() != 1 && e.getAction() != 3))) {
if (ArticleViewer.this.pressedLinkOwnerLayout != null && ArticleViewer.this.pressedLink != null && e.getAction() == 1) {
ArticleViewer articleViewer = ArticleViewer.this;
articleViewer.checkLayoutForLinks(e, articleViewer.pressedLinkOwnerView, ArticleViewer.this.pressedLinkOwnerLayout, 0, 0);
}
} else {
ArticleViewer.this.pressedLink = null;
ArticleViewer.this.pressedLinkOwnerLayout = null;
ArticleViewer.this.pressedLinkOwnerView = null;
}
return super.onInterceptTouchEvent(e);
}
@Override
public boolean onTouchEvent(MotionEvent e) {
if (ArticleViewer.this.pressedLinkOwnerLayout != null && ArticleViewer.this.pressedLink == null && ((ArticleViewer.this.popupWindow == null || !ArticleViewer.this.popupWindow.isShowing()) && (e.getAction() == 1 || e.getAction() == 3))) {
ArticleViewer.this.pressedLink = null;
ArticleViewer.this.pressedLinkOwnerLayout = null;
ArticleViewer.this.pressedLinkOwnerView = null;
}
return super.onTouchEvent(e);
}
@Override
public void setTranslationX(float translationX) {
super.setTranslationX(translationX);
if (ArticleViewer.this.windowView.movingPage) {
ArticleViewer.this.containerView.invalidate();
float progress = translationX / getMeasuredWidth();
ArticleViewer.this.setCurrentHeaderHeight((int) (r1.windowView.startMovingHeaderHeight + ((AndroidUtilities.dp(56.0f) - ArticleViewer.this.windowView.startMovingHeaderHeight) * progress)));
}
}
};
((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.m1073lambda$setParentActivity$8$imwsnshelzviuiArticleViewer(view2, i3);
}
});
this.listView[i2].setOnItemClickListener(new RecyclerListView.OnItemClickListener() {
@Override
public final void onItemClick(View view2, int i3) {
ArticleViewer.this.m1063lambda$setParentActivity$11$imwsnshelzviuiArticleViewer(webpageAdapter, view2, i3);
}
});
this.listView[i2].setOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
if (recyclerView.getChildCount() != 0) {
ArticleViewer.this.headerView.invalidate();
ArticleViewer.this.checkScroll(dy);
}
}
});
i2++;
}
this.headerPaint.setColor(-16777216);
this.statusBarPaint.setColor(-16777216);
this.headerProgressPaint.setColor(-14408666);
FrameLayout frameLayout3 = new FrameLayout(activity) {
@Override
protected void onDraw(Canvas canvas) {
int width = getMeasuredWidth();
int height = getMeasuredHeight();
canvas.drawRect(0.0f, 0.0f, width, height, ArticleViewer.this.headerPaint);
if (ArticleViewer.this.layoutManager != null) {
int first = ArticleViewer.this.layoutManager[0].findFirstVisibleItemPosition();
int last = ArticleViewer.this.layoutManager[0].findLastVisibleItemPosition();
int count = ArticleViewer.this.layoutManager[0].getItemCount();
View view2 = last >= count + (-2) ? ArticleViewer.this.layoutManager[0].findViewByPosition(count - 2) : ArticleViewer.this.layoutManager[0].findViewByPosition(first);
if (view2 == null) {
return;
}
float itemProgress = width / (count - 1);
ArticleViewer.this.layoutManager[0].getChildCount();
float viewHeight = view2.getMeasuredHeight();
float viewProgress = last >= count + (-2) ? ((((count - 2) - first) * itemProgress) * (ArticleViewer.this.listView[0].getMeasuredHeight() - view2.getTop())) / viewHeight : (1.0f - ((Math.min(0, view2.getTop() - ArticleViewer.this.listView[0].getPaddingTop()) + viewHeight) / viewHeight)) * itemProgress;
float progress = (first * itemProgress) + viewProgress;
canvas.drawRect(0.0f, 0.0f, progress, height, 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.m1064lambda$setParentActivity$13$imwsnshelzviuiArticleViewer(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.m1065lambda$setParentActivity$14$imwsnshelzviuiArticleViewer();
}
};
LinearLayout settingsContainer = new LinearLayout(this.parentActivity);
settingsContainer.setPadding(0, AndroidUtilities.dp(4.0f), 0, AndroidUtilities.dp(4.0f));
settingsContainer.setOrientation(1);
int a = 0;
while (a < 3) {
this.colorCells[a] = new ColorCell(this.parentActivity);
switch (a) {
case 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[a].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.m1066lambda$setParentActivity$15$imwsnshelzviuiArticleViewer(view2);
}
});
this.colorCells[a].setTextAndColor(LocaleController.getString("ColorWhite", R.string.ColorWhite), -1);
this.colorCells[a].select(a != this.selectedColor);
this.colorCells[a].setTag(Integer.valueOf(a));
this.colorCells[a].setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view2) {
ArticleViewer.this.m1067lambda$setParentActivity$16$imwsnshelzviuiArticleViewer(view2);
}
});
settingsContainer.addView(this.colorCells[a], LayoutHelper.createLinear(-1, 50));
a++;
break;
case 1:
this.colorCells[a].setTextAndColor(LocaleController.getString("ColorSepia", R.string.ColorSepia), -1382967);
this.colorCells[a].select(a != this.selectedColor);
this.colorCells[a].setTag(Integer.valueOf(a));
this.colorCells[a].setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view2) {
ArticleViewer.this.m1067lambda$setParentActivity$16$imwsnshelzviuiArticleViewer(view2);
}
});
settingsContainer.addView(this.colorCells[a], LayoutHelper.createLinear(-1, 50));
a++;
break;
case 2:
this.colorCells[a].setTextAndColor(LocaleController.getString("ColorDark", R.string.ColorDark), -14474461);
this.colorCells[a].select(a != this.selectedColor);
this.colorCells[a].setTag(Integer.valueOf(a));
this.colorCells[a].setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view2) {
ArticleViewer.this.m1067lambda$setParentActivity$16$imwsnshelzviuiArticleViewer(view2);
}
});
settingsContainer.addView(this.colorCells[a], LayoutHelper.createLinear(-1, 50));
a++;
break;
default:
this.colorCells[a].select(a != this.selectedColor);
this.colorCells[a].setTag(Integer.valueOf(a));
this.colorCells[a].setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view2) {
ArticleViewer.this.m1067lambda$setParentActivity$16$imwsnshelzviuiArticleViewer(view2);
}
});
settingsContainer.addView(this.colorCells[a], LayoutHelper.createLinear(-1, 50));
a++;
break;
}
}
updateNightModeButton();
View divider = new View(this.parentActivity);
divider.setBackgroundColor(-2039584);
settingsContainer.addView(divider, LayoutHelper.createLinear(-1, 1, 15.0f, 4.0f, 15.0f, 4.0f));
divider.getLayoutParams().height = 1;
int a2 = 0;
while (a2 < 2) {
this.fontCells[a2] = new FontCell(this.parentActivity);
switch (a2) {
case 0:
this.fontCells[a2].setTextAndTypeface("Roboto", Typeface.DEFAULT);
this.fontCells[a2].select(a2 == this.selectedFont);
this.fontCells[a2].setTag(Integer.valueOf(a2));
this.fontCells[a2].setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view2) {
ArticleViewer.this.m1068lambda$setParentActivity$17$imwsnshelzviuiArticleViewer(view2);
}
});
settingsContainer.addView(this.fontCells[a2], LayoutHelper.createLinear(-1, 50));
a2++;
case 1:
this.fontCells[a2].setTextAndTypeface("Serif", Typeface.SERIF);
this.fontCells[a2].select(a2 == this.selectedFont);
this.fontCells[a2].setTag(Integer.valueOf(a2));
this.fontCells[a2].setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view2) {
ArticleViewer.this.m1068lambda$setParentActivity$17$imwsnshelzviuiArticleViewer(view2);
}
});
settingsContainer.addView(this.fontCells[a2], LayoutHelper.createLinear(-1, 50));
a2++;
break;
default:
this.fontCells[a2].select(a2 == this.selectedFont);
this.fontCells[a2].setTag(Integer.valueOf(a2));
this.fontCells[a2].setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view2) {
ArticleViewer.this.m1068lambda$setParentActivity$17$imwsnshelzviuiArticleViewer(view2);
}
});
settingsContainer.addView(this.fontCells[a2], LayoutHelper.createLinear(-1, 50));
a2++;
break;
}
}
View divider2 = new View(this.parentActivity);
divider2.setBackgroundColor(-2039584);
settingsContainer.addView(divider2, LayoutHelper.createLinear(-1, 1, 15.0f, 4.0f, 15.0f, 4.0f));
divider2.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));
settingsContainer.addView(textView, LayoutHelper.createLinear(-2, -2, (LocaleController.isRTL ? 5 : 3) | 48, 17, 12, 17, 0));
SizeChooseView sizeChooseView = new SizeChooseView(this.parentActivity);
settingsContainer.addView(sizeChooseView, 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(settingsContainer, 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 view2) {
ArticleViewer.this.m1069lambda$setParentActivity$18$imwsnshelzviuiArticleViewer(view2);
}
});
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;
this.windowLayoutParams.flags = -2147417848;
if (Build.VERSION.SDK_INT >= 28) {
this.windowLayoutParams.layoutInDisplayCutoutMode = 1;
}
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 i3) {
if (i3 == -1) {
ArticleViewer.this.closePhoto(true);
return;
}
if (i3 != 1) {
if (i3 == 2) {
ArticleViewer.this.onSharePressed();
return;
}
if (i3 == 3) {
try {
ArticleViewer articleViewer = ArticleViewer.this;
AndroidUtilities.openForView(articleViewer.getMedia(articleViewer.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("android.permission.WRITE_EXTERNAL_STORAGE") != 0) {
ArticleViewer.this.parentActivity.requestPermissions(new String[]{"android.permission.WRITE_EXTERNAL_STORAGE"}, 4);
return;
}
ArticleViewer articleViewer2 = ArticleViewer.this;
File mediaFile = articleViewer2.getMediaFile(articleViewer2.currentIndex);
if (mediaFile != null && mediaFile.exists()) {
String file = mediaFile.toString();
Activity activity2 = ArticleViewer.this.parentActivity;
ArticleViewer articleViewer3 = ArticleViewer.this;
MediaController.saveFile(file, activity2, articleViewer3.isMediaVideo(articleViewer3.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 f = articleViewer.getMediaFile(articleViewer.currentIndex);
return f != null && f.exists();
}
});
ActionBarMenu menu = this.actionBar.createMenu();
menu.addItem(2, R.drawable.share);
ActionBarMenuItem addItem = menu.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 getCurrentIndex() {
return ArticleViewer.this.currentIndex;
}
@Override
public int getCurrentAccount() {
return ArticleViewer.this.currentAccount;
}
@Override
public int getAvatarsDialogId() {
return 0;
}
@Override
public int getSlideshowMessageId() {
return 0;
}
@Override
public ArrayList<ImageLocation> getImagesArrLocations() {
return null;
}
@Override
public ArrayList<MessageObject> getImagesArr() {
return null;
}
@Override
public ArrayList<TLRPC.PageBlock> getPageBlockArr() {
return ArticleViewer.this.imagesArr;
}
@Override
public Object getParentObject() {
return ArticleViewer.this.currentPage;
}
@Override
public void setCurrentIndex(int index) {
ArticleViewer.this.currentIndex = -1;
if (ArticleViewer.this.currentThumb != null) {
ArticleViewer.this.currentThumb.release();
ArticleViewer.this.currentThumb = null;
}
ArticleViewer.this.setImageIndex(index, 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.m1070lambda$setParentActivity$19$imwsnshelzviuiArticleViewer(f);
}
});
FrameLayout frameLayout6 = new FrameLayout(activity) {
@Override
public boolean onTouchEvent(MotionEvent event) {
if (ArticleViewer.this.videoPlayerSeekbar.onTouch(event.getAction(), event.getX() - AndroidUtilities.dp(48.0f), event.getY())) {
getParent().requestDisallowInterceptTouchEvent(true);
invalidate();
return true;
}
return super.onTouchEvent(event);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
long duration;
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
if (ArticleViewer.this.videoPlayer != null) {
duration = ArticleViewer.this.videoPlayer.getDuration();
if (duration == C.TIME_UNSET) {
duration = 0;
}
} else {
duration = 0;
}
long duration2 = duration / 1000;
int size = (int) Math.ceil(ArticleViewer.this.videoPlayerTime.getPaint().measureText(String.format("%02d:%02d / %02d:%02d", Long.valueOf(duration2 / 60), Long.valueOf(duration2 % 60), Long.valueOf(duration2 / 60), Long.valueOf(duration2 % 60))));
ArticleViewer.this.videoPlayerSeekbar.setSize((getMeasuredWidth() - AndroidUtilities.dp(64.0f)) - size, getMeasuredHeight());
}
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
super.onLayout(changed, left, top, right, bottom);
float progress = 0.0f;
if (ArticleViewer.this.videoPlayer != null) {
progress = ((float) ArticleViewer.this.videoPlayer.getCurrentPosition()) / ((float) ArticleViewer.this.videoPlayer.getDuration());
}
ArticleViewer.this.videoPlayerSeekbar.setProgress(progress);
}
@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 view2) {
ArticleViewer.this.m1071lambda$setParentActivity$20$imwsnshelzviuiArticleViewer(view2);
}
});
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 m1072lambda$setParentActivity$7$imwsnshelzviuiArticleViewer(View v, WindowInsets insets) {
DisplayCutout cutout;
List<Rect> rects;
WindowInsets oldInsets = (WindowInsets) this.lastInsets;
this.lastInsets = insets;
if (oldInsets == null || !oldInsets.toString().equals(insets.toString())) {
this.windowView.requestLayout();
}
if (Build.VERSION.SDK_INT >= 28 && (cutout = this.parentActivity.getWindow().getDecorView().getRootWindowInsets().getDisplayCutout()) != null && (rects = cutout.getBoundingRects()) != null && !rects.isEmpty()) {
this.hasCutout = rects.get(0).height() != 0;
}
return insets.consumeSystemWindowInsets();
}
public boolean m1073lambda$setParentActivity$8$imwsnshelzviuiArticleViewer(View view, int position) {
if (view instanceof BlockRelatedArticlesCell) {
BlockRelatedArticlesCell cell = (BlockRelatedArticlesCell) view;
showCopyPopup(cell.currentBlock.parent.articles.get(cell.currentBlock.num).url);
return true;
}
return false;
}
public void m1063lambda$setParentActivity$11$imwsnshelzviuiArticleViewer(WebpageAdapter webpageAdapter, View view, int position) {
if (position == webpageAdapter.localBlocks.size() && this.currentPage != null) {
if (this.previewsReqId != 0) {
return;
}
TLObject object = MessagesController.getInstance(this.currentAccount).getUserOrChat("previews");
if (object instanceof TLRPC.TL_user) {
openPreviewsChat((TLRPC.User) object, this.currentPage.id);
return;
}
final int currentAccount = UserConfig.selectedAccount;
final long pageId = this.currentPage.id;
showProgressView(true, true);
TLRPC.TL_contacts_resolveUsername req = new TLRPC.TL_contacts_resolveUsername();
req.username = "previews";
this.previewsReqId = ConnectionsManager.getInstance(currentAccount).sendRequest(req, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
ArticleViewer.this.m1062lambda$setParentActivity$10$imwsnshelzviuiArticleViewer(currentAccount, pageId, tLObject, tL_error);
}
});
return;
}
if (position < 0 || position >= webpageAdapter.localBlocks.size()) {
return;
}
TLRPC.PageBlock pageBlock = (TLRPC.PageBlock) webpageAdapter.localBlocks.get(position);
TLRPC.PageBlock pageBlock2 = getLastNonListPageBlock(pageBlock);
if (pageBlock2 instanceof TL_pageBlockDetailsChild) {
TL_pageBlockDetailsChild detailsChild = (TL_pageBlockDetailsChild) pageBlock2;
pageBlock2 = detailsChild.block;
}
if (pageBlock2 instanceof TLRPC.TL_pageBlockChannel) {
TLRPC.TL_pageBlockChannel pageBlockChannel = (TLRPC.TL_pageBlockChannel) pageBlock2;
MessagesController.getInstance(this.currentAccount).openByUserName(pageBlockChannel.channel.username, this.parentFragment, 2);
close(false, true);
return;
}
if (pageBlock2 instanceof TL_pageBlockRelatedArticlesChild) {
TL_pageBlockRelatedArticlesChild pageBlockRelatedArticlesChild = (TL_pageBlockRelatedArticlesChild) pageBlock2;
openWebpageUrl(pageBlockRelatedArticlesChild.parent.articles.get(pageBlockRelatedArticlesChild.num).url, null);
return;
}
if (pageBlock2 instanceof TLRPC.TL_pageBlockDetails) {
View view2 = getLastNonListCell(view);
if (!(view2 instanceof BlockDetailsCell)) {
return;
}
this.pressedLinkOwnerLayout = null;
this.pressedLinkOwnerView = null;
int index = webpageAdapter.blocks.indexOf(pageBlock);
if (index < 0) {
return;
}
TLRPC.TL_pageBlockDetails pageBlockDetails = (TLRPC.TL_pageBlockDetails) pageBlock2;
pageBlockDetails.open = true ^ pageBlockDetails.open;
int oldCount = webpageAdapter.getItemCount();
webpageAdapter.updateRows();
int newCount = webpageAdapter.getItemCount();
int changeCount = Math.abs(newCount - oldCount);
BlockDetailsCell cell = (BlockDetailsCell) view2;
cell.arrow.setAnimationProgressAnimated(pageBlockDetails.open ? 0.0f : 1.0f);
cell.invalidate();
if (changeCount != 0) {
if (pageBlockDetails.open) {
webpageAdapter.notifyItemRangeInserted(position + 1, changeCount);
} else {
webpageAdapter.notifyItemRangeRemoved(position + 1, changeCount);
}
}
}
}
public void m1062lambda$setParentActivity$10$imwsnshelzviuiArticleViewer(final int currentAccount, final long pageId, final TLObject response, TLRPC.TL_error error) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
ArticleViewer.this.m1074lambda$setParentActivity$9$imwsnshelzviuiArticleViewer(response, currentAccount, pageId);
}
});
}
public void m1074lambda$setParentActivity$9$imwsnshelzviuiArticleViewer(TLObject response, int currentAccount, long pageId) {
if (this.previewsReqId == 0) {
return;
}
this.previewsReqId = 0;
showProgressView(true, false);
if (response != null) {
TLRPC.TL_contacts_resolvedPeer res = (TLRPC.TL_contacts_resolvedPeer) response;
MessagesController.getInstance(currentAccount).putUsers(res.users, false);
MessagesStorage.getInstance(currentAccount).putUsersAndChats(res.users, res.chats, false, true);
if (!res.users.isEmpty()) {
openPreviewsChat(res.users.get(0), pageId);
}
}
}
public static boolean lambda$setParentActivity$12(View v, MotionEvent event) {
return true;
}
public void m1064lambda$setParentActivity$13$imwsnshelzviuiArticleViewer(View v) {
close(true, true);
}
public void m1065lambda$setParentActivity$14$imwsnshelzviuiArticleViewer() {
float tick;
float progressLeft = 0.7f - this.lineProgressView.getCurrentProgress();
if (progressLeft > 0.0f) {
if (progressLeft < 0.25f) {
tick = 0.01f;
} else {
tick = 0.02f;
}
LineProgressView lineProgressView = this.lineProgressView;
lineProgressView.setProgress(lineProgressView.getCurrentProgress() + tick, true);
AndroidUtilities.runOnUIThread(this.lineProgressTickRunnable, 100L);
}
}
public void m1066lambda$setParentActivity$15$imwsnshelzviuiArticleViewer(View v) {
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 m1067lambda$setParentActivity$16$imwsnshelzviuiArticleViewer(View v) {
int num = ((Integer) v.getTag()).intValue();
this.selectedColor = num;
int a12 = 0;
while (a12 < 3) {
this.colorCells[a12].select(a12 == num);
a12++;
}
updateNightModeButton();
updatePaintColors();
for (int i = 0; i < this.listView.length; i++) {
this.adapter[i].notifyDataSetChanged();
}
}
public void m1068lambda$setParentActivity$17$imwsnshelzviuiArticleViewer(View v) {
int num = ((Integer) v.getTag()).intValue();
this.selectedFont = num;
int a1 = 0;
while (a1 < 2) {
this.fontCells[a1].select(a1 == num);
a1++;
}
updatePaintFonts();
for (int i = 0; i < this.listView.length; i++) {
this.adapter[i].notifyDataSetChanged();
}
}
public void m1069lambda$setParentActivity$18$imwsnshelzviuiArticleViewer(View v) {
if (this.currentPage == null || this.parentActivity == null) {
return;
}
showDialog(new ShareAlert(this.parentActivity, null, this.currentPage.url, false, this.currentPage.url, true));
}
public void m1070lambda$setParentActivity$19$imwsnshelzviuiArticleViewer(float progress) {
VideoPlayer videoPlayer = this.videoPlayer;
if (videoPlayer != null) {
videoPlayer.seekTo((int) (((float) videoPlayer.getDuration()) * progress));
}
}
public void m1071lambda$setParentActivity$20$imwsnshelzviuiArticleViewer(View v) {
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) {
return;
}
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 nightModeImageView = new ImageView(this.parentActivity);
nightModeImageView.setScaleType(ImageView.ScaleType.CENTER);
nightModeImageView.setImageResource(R.drawable.moon);
this.nightModeHintView.addView(nightModeImageView, 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 animation) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
ArticleViewer.AnonymousClass12.this.m1082lambda$onAnimationEnd$0$imwsnshelzviuiArticleViewer$12();
}
}, 3000L);
}
public void m1082lambda$onAnimationEnd$0$imwsnshelzviuiArticleViewer$12() {
AnimatorSet animatorSet1 = new AnimatorSet();
animatorSet1.playTogether(ObjectAnimator.ofFloat(ArticleViewer.this.nightModeHintView, (Property<FrameLayout, Float>) View.TRANSLATION_Y, AndroidUtilities.dp(100.0f)));
animatorSet1.setInterpolator(new DecelerateInterpolator(1.5f));
animatorSet1.setDuration(250L);
animatorSet1.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 fraction, Integer startValue, Integer endValue) {
return super.evaluate(fraction, startValue, endValue);
}
}
private void checkScrollAnimated() {
int maxHeight = AndroidUtilities.dp(56.0f);
if (this.currentHeaderHeight == maxHeight) {
return;
}
ValueAnimator va = ValueAnimator.ofObject(new IntEvaluator(), Integer.valueOf(this.currentHeaderHeight), Integer.valueOf(AndroidUtilities.dp(56.0f))).setDuration(180L);
va.setInterpolator(new DecelerateInterpolator());
va.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public final void onAnimationUpdate(ValueAnimator valueAnimator) {
ArticleViewer.this.m1041lambda$checkScrollAnimated$21$imwsnshelzviuiArticleViewer(valueAnimator);
}
});
va.start();
}
public void m1041lambda$checkScrollAnimated$21$imwsnshelzviuiArticleViewer(ValueAnimator animation) {
setCurrentHeaderHeight(((Integer) animation.getAnimatedValue()).intValue());
}
public void setCurrentHeaderHeight(int newHeight) {
int maxHeight = AndroidUtilities.dp(56.0f);
int minHeight = Math.max(AndroidUtilities.statusBarHeight, AndroidUtilities.dp(24.0f));
if (newHeight < minHeight) {
newHeight = minHeight;
} else if (newHeight > maxHeight) {
newHeight = maxHeight;
}
float heightDiff = maxHeight - minHeight;
this.currentHeaderHeight = newHeight;
float scale = (((newHeight - minHeight) / heightDiff) * 0.2f) + 0.8f;
float scale2 = (((newHeight - minHeight) / heightDiff) * 0.5f) + 0.5f;
this.backButton.setScaleX(scale);
this.backButton.setScaleY(scale);
this.backButton.setTranslationY((maxHeight - this.currentHeaderHeight) / 2);
this.shareContainer.setScaleX(scale);
this.shareContainer.setScaleY(scale);
this.settingsButton.setScaleX(scale);
this.settingsButton.setScaleY(scale);
this.titleTextView.setScaleX(scale);
this.titleTextView.setScaleY(scale);
this.lineProgressView.setScaleY(scale2);
this.shareContainer.setTranslationY((maxHeight - this.currentHeaderHeight) / 2);
this.settingsButton.setTranslationY((maxHeight - this.currentHeaderHeight) / 2);
this.titleTextView.setTranslationY((maxHeight - this.currentHeaderHeight) / 2);
this.headerView.setTranslationY(this.currentHeaderHeight - maxHeight);
int i = 0;
while (true) {
RecyclerListView[] recyclerListViewArr = this.listView;
if (i < recyclerListViewArr.length) {
recyclerListViewArr[i].setTopGlowOffset(this.currentHeaderHeight);
i++;
} else {
return;
}
}
}
public void checkScroll(int dy) {
setCurrentHeaderHeight(this.currentHeaderHeight - dy);
}
private void openPreviewsChat(TLRPC.User user, long wid) {
if (user == null || this.parentActivity == null) {
return;
}
Bundle args = new Bundle();
args.putInt("user_id", user.id);
args.putString("botUser", "webpage" + wid);
((LaunchActivity) this.parentActivity).presentFragment(new ChatActivity(args), false, true);
close(false, true);
}
public boolean open(MessageObject messageObject) {
return open(messageObject, null, null, true);
}
public boolean open(TLRPC.TL_webPage webpage, String url) {
return open(null, webpage, url, true);
}
private boolean open(final MessageObject messageObject, TLRPC.WebPage webPage, String str, boolean z) {
TLRPC.WebPage webPage2;
TLRPC.WebPage webPage3;
String str2;
int lastIndexOf;
Paint paint;
?? r0;
if (this.parentActivity != null) {
if (this.isVisible && !this.collapsed) {
return false;
}
if (messageObject == null && webPage == null) {
return false;
}
if (messageObject == null) {
webPage2 = webPage;
} else {
webPage2 = messageObject.messageOwner.media.webpage;
}
String str3 = null;
int i = -1;
if (messageObject != null) {
TLRPC.WebPage webPage4 = messageObject.messageOwner.media.webpage;
int i2 = 0;
?? r5 = str;
while (true) {
if (i2 >= messageObject.messageOwner.entities.size()) {
break;
}
TLRPC.MessageEntity messageEntity = messageObject.messageOwner.entities.get(i2);
if (messageEntity instanceof TLRPC.TL_messageEntityUrl) {
try {
r5 = messageObject.messageOwner.message.substring(messageEntity.offset, messageEntity.offset + messageEntity.length).toLowerCase();
if (!TextUtils.isEmpty(webPage4.cached_page.url)) {
r0 = webPage4.cached_page.url.toLowerCase();
} else {
r0 = webPage4.url.toLowerCase();
}
if (!r5.contains(r0) && !r0.contains(r5)) {
}
int lastIndexOf2 = r5.lastIndexOf(35);
if (lastIndexOf2 == i) {
break;
}
str3 = r5.substring(lastIndexOf2 + 1);
break;
} catch (Exception e) {
FileLog.e(e);
}
}
i2++;
r5 = r5;
}
webPage3 = webPage4;
str2 = str3;
} else if (str == null || (lastIndexOf = str.lastIndexOf(35)) == -1) {
webPage3 = webPage2;
str2 = null;
} else {
webPage3 = webPage2;
str2 = str.substring(lastIndexOf + 1);
}
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(webPage3, str2, 0);
if (!z) {
paint = null;
} else {
final String str4 = (addPageToStack || str2 == null) ? null : str2;
TLRPC.TL_messages_getWebPage tL_messages_getWebPage = new TLRPC.TL_messages_getWebPage();
tL_messages_getWebPage.url = webPage3.url;
if ((webPage3.cached_page instanceof TLRPC.TL_pagePart_layer82) || webPage3.cached_page.part) {
tL_messages_getWebPage.hash = 0;
} else {
tL_messages_getWebPage.hash = webPage3.hash;
}
final TLRPC.WebPage webPage5 = webPage3;
final int i3 = UserConfig.selectedAccount;
paint = null;
ConnectionsManager.getInstance(i3).sendRequest(tL_messages_getWebPage, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
ArticleViewer.this.m1054lambda$open$23$imwsnshelzviuiArticleViewer(webPage5, messageObject, str4, i3, tLObject, tL_error);
}
});
}
this.lastInsets = paint;
if (!this.isVisible) {
WindowManager windowManager = (WindowManager) this.parentActivity.getSystemService("window");
if (this.attachedToWindow) {
try {
windowManager.removeView(this.windowView);
} catch (Exception e2) {
}
}
try {
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 e3) {
FileLog.e(e3);
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.m1055lambda$open$24$imwsnshelzviuiArticleViewer();
}
};
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.m1056lambda$open$25$imwsnshelzviuiArticleViewer(animatorSet);
}
});
this.containerView.setLayerType(2, paint);
return true;
}
return false;
}
public void m1054lambda$open$23$imwsnshelzviuiArticleViewer(final TLRPC.WebPage webPageFinal, final MessageObject messageObject, final String anchorFinal, int currentAccount, TLObject response, TLRPC.TL_error error) {
if (response instanceof TLRPC.TL_webPage) {
final TLRPC.TL_webPage webPage = (TLRPC.TL_webPage) response;
if (webPage.cached_page == null) {
return;
}
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
ArticleViewer.this.m1053lambda$open$22$imwsnshelzviuiArticleViewer(webPageFinal, webPage, messageObject, anchorFinal);
}
});
LongSparseArray<TLRPC.WebPage> webpages = new LongSparseArray<>(1);
webpages.put(webPage.id, webPage);
MessagesStorage.getInstance(currentAccount).putWebPages(webpages);
}
}
public void m1053lambda$open$22$imwsnshelzviuiArticleViewer(TLRPC.WebPage webPageFinal, TLRPC.TL_webPage webPage, MessageObject messageObject, String anchorFinal) {
if (!this.pagesStack.isEmpty() && this.pagesStack.get(0) == webPageFinal && webPage.cached_page != null) {
if (messageObject != null) {
messageObject.messageOwner.media.webpage = webPage;
}
this.pagesStack.set(0, webPage);
if (this.pagesStack.size() == 1) {
this.currentPage = webPage;
ApplicationLoader.applicationContext.getSharedPreferences("articles", 0).edit().remove("article" + this.currentPage.id).commit();
updateInterfaceForCurrentPage(0);
if (anchorFinal != null) {
scrollToAnchor(anchorFinal);
}
}
}
}
public void m1055lambda$open$24$imwsnshelzviuiArticleViewer() {
if (this.containerView == null || this.windowView == null) {
return;
}
this.containerView.setLayerType(0, null);
this.animationInProgress = 0;
AndroidUtilities.hideKeyboard(this.parentActivity.getCurrentFocus());
}
public class AnonymousClass13 extends AnimatorListenerAdapter {
AnonymousClass13() {
}
@Override
public void onAnimationEnd(Animator animation) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
ArticleViewer.AnonymousClass13.this.m1083lambda$onAnimationEnd$0$imwsnshelzviuiArticleViewer$13();
}
});
}
public void m1083lambda$onAnimationEnd$0$imwsnshelzviuiArticleViewer$13() {
NotificationCenter.getInstance(ArticleViewer.this.currentAccount).setAnimationInProgress(false);
if (ArticleViewer.this.animationEndRunnable != null) {
ArticleViewer.this.animationEndRunnable.run();
ArticleViewer.this.animationEndRunnable = null;
}
}
}
public void m1056lambda$open$25$imwsnshelzviuiArticleViewer(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 useLine, final boolean show) {
if (useLine) {
AndroidUtilities.cancelRunOnUIThread(this.lineProgressTickRunnable);
if (show) {
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 (show) {
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 animation) {
if (ArticleViewer.this.progressViewAnimation != null && ArticleViewer.this.progressViewAnimation.equals(animation)) {
if (!show) {
ArticleViewer.this.progressView.setVisibility(4);
} else {
ArticleViewer.this.shareButton.setVisibility(4);
}
}
}
@Override
public void onAnimationCancel(Animator animation) {
if (ArticleViewer.this.progressViewAnimation != null && ArticleViewer.this.progressViewAnimation.equals(animation)) {
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 {
Dialog dialog = this.visibleDialog;
if (dialog != null) {
dialog.dismiss();
this.visibleDialog = null;
}
} catch (Exception e) {
FileLog.e(e);
}
AnimatorSet animatorSet = new AnimatorSet();
animatorSet.playTogether(ObjectAnimator.ofFloat(this.containerView, (Property<FrameLayout, Float>) View.TRANSLATION_X, this.containerView.getMeasuredWidth() - AndroidUtilities.dp(56.0f)), ObjectAnimator.ofFloat(this.containerView, (Property<FrameLayout, Float>) View.TRANSLATION_Y, ActionBar.getCurrentActionBarHeight() + AndroidUtilities.statusBarHeight), ObjectAnimator.ofFloat(this.windowView, (Property<WindowView, Float>) View.ALPHA, 0.0f), ObjectAnimator.ofFloat(this.listView[0], (Property<RecyclerListView, Float>) View.ALPHA, 0.0f), ObjectAnimator.ofFloat(this.listView[0], (Property<RecyclerListView, Float>) View.TRANSLATION_Y, -AndroidUtilities.dp(56.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 = true;
this.animationInProgress = 2;
this.animationEndRunnable = new Runnable() {
@Override
public final void run() {
ArticleViewer.this.m1044lambda$collapse$26$imwsnshelzviuiArticleViewer();
}
};
animatorSet.setInterpolator(new DecelerateInterpolator());
animatorSet.setDuration(250L);
animatorSet.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
if (ArticleViewer.this.animationEndRunnable != null) {
ArticleViewer.this.animationEndRunnable.run();
ArticleViewer.this.animationEndRunnable = null;
}
}
});
this.transitionAnimationStartTime = System.currentTimeMillis();
this.containerView.setLayerType(2, null);
this.backDrawable.setRotation(1.0f, true);
animatorSet.start();
}
public void m1044lambda$collapse$26$imwsnshelzviuiArticleViewer() {
if (this.containerView == null) {
return;
}
this.containerView.setLayerType(0, null);
this.animationInProgress = 0;
WindowManager wm = (WindowManager) this.parentActivity.getSystemService("window");
wm.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.m1081lambda$uncollapse$27$imwsnshelzviuiArticleViewer();
}
};
animatorSet.setDuration(250L);
animatorSet.setInterpolator(new DecelerateInterpolator());
animatorSet.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
if (ArticleViewer.this.animationEndRunnable != null) {
ArticleViewer.this.animationEndRunnable.run();
ArticleViewer.this.animationEndRunnable = null;
}
}
});
this.transitionAnimationStartTime = System.currentTimeMillis();
this.containerView.setLayerType(2, null);
this.backDrawable.setRotation(0.0f, true);
animatorSet.start();
}
public void m1081lambda$uncollapse$27$imwsnshelzviuiArticleViewer() {
if (this.containerView == null) {
return;
}
this.containerView.setLayerType(0, null);
this.animationInProgress = 0;
}
public void saveCurrentPagePosition() {
int offset;
if (this.currentPage == null) {
return;
}
int position = this.layoutManager[0].findFirstVisibleItemPosition();
if (position != -1) {
View view = this.layoutManager[0].findViewByPosition(position);
if (view != null) {
offset = view.getTop();
} else {
offset = 0;
}
SharedPreferences.Editor editor = ApplicationLoader.applicationContext.getSharedPreferences("articles", 0).edit();
String key = "article" + this.currentPage.id;
editor.putInt(key, position).putInt(key + "o", offset).putBoolean(key + "r", AndroidUtilities.displaySize.x > AndroidUtilities.displaySize.y).commit();
}
}
public void close(boolean byBackPress, boolean force) {
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 (!force) {
return;
}
}
if (this.isPhotoVisible) {
closePhoto(!force);
if (!force) {
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 (byBackPress && !force && 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 {
Dialog dialog = this.visibleDialog;
if (dialog != null) {
dialog.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.m1042lambda$close$28$imwsnshelzviuiArticleViewer();
}
};
animatorSet.setDuration(150L);
animatorSet.setInterpolator(this.interpolator);
animatorSet.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
if (ArticleViewer.this.animationEndRunnable != null) {
ArticleViewer.this.animationEndRunnable.run();
ArticleViewer.this.animationEndRunnable = null;
}
}
});
this.transitionAnimationStartTime = System.currentTimeMillis();
this.containerView.setLayerType(2, null);
animatorSet.start();
}
public void m1042lambda$close$28$imwsnshelzviuiArticleViewer() {
if (this.containerView == null) {
return;
}
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 a = 0; a < this.createdWebViews.size(); a++) {
BlockEmbedCell cell = this.createdWebViews.get(a);
cell.destroyWebView(false);
}
this.containerView.post(new Runnable() {
@Override
public final void run() {
ArticleViewer.this.m1051lambda$onClosed$29$imwsnshelzviuiArticleViewer();
}
});
}
public void m1051lambda$onClosed$29$imwsnshelzviuiArticleViewer() {
try {
if (this.windowView.getParent() != null) {
WindowManager wm = (WindowManager) this.parentActivity.getSystemService("window");
wm.removeView(this.windowView);
}
} catch (Exception e) {
FileLog.e(e);
}
}
public void loadChannel(final BlockChannelCell cell, final WebpageAdapter adapter, TLRPC.Chat channel) {
if (this.loadingChannel || TextUtils.isEmpty(channel.username)) {
return;
}
this.loadingChannel = true;
TLRPC.TL_contacts_resolveUsername req = new TLRPC.TL_contacts_resolveUsername();
req.username = channel.username;
final int currentAccount = UserConfig.selectedAccount;
ConnectionsManager.getInstance(currentAccount).sendRequest(req, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
ArticleViewer.this.m1050lambda$loadChannel$31$imwsnshelzviuiArticleViewer(adapter, currentAccount, cell, tLObject, tL_error);
}
});
}
public void m1050lambda$loadChannel$31$imwsnshelzviuiArticleViewer(final WebpageAdapter adapter, final int currentAccount, final BlockChannelCell cell, final TLObject response, final TLRPC.TL_error error) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
ArticleViewer.this.m1049lambda$loadChannel$30$imwsnshelzviuiArticleViewer(adapter, error, response, currentAccount, cell);
}
});
}
public void m1049lambda$loadChannel$30$imwsnshelzviuiArticleViewer(WebpageAdapter adapter, TLRPC.TL_error error, TLObject response, int currentAccount, BlockChannelCell cell) {
this.loadingChannel = false;
if (this.parentFragment == null || adapter.blocks.isEmpty()) {
return;
}
if (error == null) {
TLRPC.TL_contacts_resolvedPeer res = (TLRPC.TL_contacts_resolvedPeer) response;
if (!res.chats.isEmpty()) {
MessagesController.getInstance(currentAccount).putUsers(res.users, false);
MessagesController.getInstance(currentAccount).putChats(res.chats, false);
MessagesStorage.getInstance(currentAccount).putUsersAndChats(res.users, res.chats, false, true);
TLRPC.Chat chat = res.chats.get(0);
this.loadedChannel = chat;
if (chat.left && !this.loadedChannel.kicked) {
cell.setState(0, false);
return;
} else {
cell.setState(4, false);
return;
}
}
cell.setState(4, false);
return;
}
cell.setState(4, false);
}
public void joinChannel(final BlockChannelCell cell, final TLRPC.Chat channel) {
final TLRPC.TL_channels_joinChannel req = new TLRPC.TL_channels_joinChannel();
req.channel = MessagesController.getInputChannel(channel);
final int currentAccount = UserConfig.selectedAccount;
ConnectionsManager.getInstance(currentAccount).sendRequest(req, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
ArticleViewer.this.m1048lambda$joinChannel$35$imwsnshelzviuiArticleViewer(cell, currentAccount, req, channel, tLObject, tL_error);
}
});
}
public void m1048lambda$joinChannel$35$imwsnshelzviuiArticleViewer(final BlockChannelCell cell, final int currentAccount, final TLRPC.TL_channels_joinChannel req, final TLRPC.Chat channel, TLObject response, final TLRPC.TL_error error) {
if (error != null) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
ArticleViewer.this.m1047lambda$joinChannel$32$imwsnshelzviuiArticleViewer(cell, currentAccount, error, req);
}
});
return;
}
boolean hasJoinMessage = false;
TLRPC.Updates updates = (TLRPC.Updates) response;
int a = 0;
while (true) {
if (a >= updates.updates.size()) {
break;
}
TLRPC.Update update = updates.updates.get(a);
if (!(update instanceof TLRPC.TL_updateNewChannelMessage) || !(((TLRPC.TL_updateNewChannelMessage) update).message.action instanceof TLRPC.TL_messageActionChatAddUser)) {
a++;
} else {
hasJoinMessage = true;
break;
}
}
MessagesController.getInstance(currentAccount).processUpdates(updates, false);
if (!hasJoinMessage) {
MessagesController.getInstance(currentAccount).generateJoinMessage(channel.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(currentAccount).loadFullChat(channel.id, 0, true);
}
}, 1000L);
MessagesStorage.getInstance(currentAccount).updateDialogsWithDeletedMessages(new ArrayList<>(), null, true, channel.id);
}
public void m1047lambda$joinChannel$32$imwsnshelzviuiArticleViewer(BlockChannelCell cell, int currentAccount, TLRPC.TL_error error, TLRPC.TL_channels_joinChannel req) {
cell.setState(0, false);
AlertsCreator.processError(currentAccount, error, this.parentFragment, req, 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 wm = (WindowManager) this.parentActivity.getSystemService("window");
wm.removeViewImmediate(this.windowView);
}
this.windowView = null;
} catch (Exception e) {
FileLog.e(e);
}
for (int a = 0; a < this.createdWebViews.size(); a++) {
BlockEmbedCell cell = this.createdWebViews.get(a);
cell.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 {
Dialog dialog2 = this.visibleDialog;
if (dialog2 != null) {
dialog2.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.m1076lambda$showDialog$36$imwsnshelzviuiArticleViewer(dialogInterface);
}
});
dialog.show();
} catch (Exception e2) {
FileLog.e(e2);
}
}
public void m1076lambda$showDialog$36$imwsnshelzviuiArticleViewer(DialogInterface dialog1) {
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 ctx) {
this.context = ctx;
}
private void setRichTextParents(TLRPC.RichText parentRichText, TLRPC.RichText richText) {
if (richText == null) {
return;
}
richText.parentRichText = parentRichText;
if (richText instanceof TLRPC.TL_textFixed) {
setRichTextParents(richText, ((TLRPC.TL_textFixed) richText).text);
return;
}
if (richText instanceof TLRPC.TL_textItalic) {
setRichTextParents(richText, ((TLRPC.TL_textItalic) richText).text);
return;
}
if (richText instanceof TLRPC.TL_textBold) {
setRichTextParents(richText, ((TLRPC.TL_textBold) richText).text);
return;
}
if (richText instanceof TLRPC.TL_textUnderline) {
setRichTextParents(richText, ((TLRPC.TL_textUnderline) richText).text);
return;
}
if (richText instanceof TLRPC.TL_textStrike) {
setRichTextParents(richText, ((TLRPC.TL_textStrike) richText).text);
return;
}
if (richText instanceof TLRPC.TL_textEmail) {
setRichTextParents(richText, ((TLRPC.TL_textEmail) richText).text);
return;
}
if (richText instanceof TLRPC.TL_textPhone) {
setRichTextParents(richText, ((TLRPC.TL_textPhone) richText).text);
return;
}
if (richText instanceof TLRPC.TL_textUrl) {
setRichTextParents(richText, ((TLRPC.TL_textUrl) richText).text);
return;
}
if (richText instanceof TLRPC.TL_textConcat) {
int count = richText.texts.size();
for (int a = 0; a < count; a++) {
setRichTextParents(richText, richText.texts.get(a));
}
return;
}
if (richText instanceof TLRPC.TL_textSubscript) {
setRichTextParents(richText, ((TLRPC.TL_textSubscript) richText).text);
return;
}
if (richText instanceof TLRPC.TL_textSuperscript) {
setRichTextParents(richText, ((TLRPC.TL_textSuperscript) richText).text);
return;
}
if (richText instanceof TLRPC.TL_textMarked) {
setRichTextParents(richText, ((TLRPC.TL_textMarked) richText).text);
return;
}
if (richText instanceof TLRPC.TL_textAnchor) {
TLRPC.TL_textAnchor textAnchor = (TLRPC.TL_textAnchor) richText;
setRichTextParents(richText, textAnchor.text);
String name = textAnchor.name.toLowerCase();
this.anchors.put(name, Integer.valueOf(this.blocks.size()));
if (textAnchor.text instanceof TLRPC.TL_textPlain) {
TLRPC.TL_textPlain textPlain = (TLRPC.TL_textPlain) textAnchor.text;
if (!TextUtils.isEmpty(textPlain.text)) {
this.anchorsParent.put(name, textAnchor);
}
} else if (!(textAnchor.text instanceof TLRPC.TL_textEmpty)) {
this.anchorsParent.put(name, textAnchor);
}
this.anchorsOffset.put(name, -1);
}
}
private void setRichTextParents(TLRPC.PageBlock block) {
if (block instanceof TLRPC.TL_pageBlockEmbedPost) {
TLRPC.TL_pageBlockEmbedPost blockEmbedPost = (TLRPC.TL_pageBlockEmbedPost) block;
setRichTextParents(null, blockEmbedPost.caption.text);
setRichTextParents(null, blockEmbedPost.caption.credit);
return;
}
if (block instanceof TLRPC.TL_pageBlockParagraph) {
TLRPC.TL_pageBlockParagraph pageBlockParagraph = (TLRPC.TL_pageBlockParagraph) block;
setRichTextParents(null, pageBlockParagraph.text);
return;
}
if (block instanceof TLRPC.TL_pageBlockKicker) {
TLRPC.TL_pageBlockKicker pageBlockKicker = (TLRPC.TL_pageBlockKicker) block;
setRichTextParents(null, pageBlockKicker.text);
return;
}
if (block instanceof TLRPC.TL_pageBlockFooter) {
TLRPC.TL_pageBlockFooter pageBlockFooter = (TLRPC.TL_pageBlockFooter) block;
setRichTextParents(null, pageBlockFooter.text);
return;
}
if (block instanceof TLRPC.TL_pageBlockHeader) {
TLRPC.TL_pageBlockHeader pageBlockHeader = (TLRPC.TL_pageBlockHeader) block;
setRichTextParents(null, pageBlockHeader.text);
return;
}
if (block instanceof TLRPC.TL_pageBlockPreformatted) {
TLRPC.TL_pageBlockPreformatted pageBlockPreformatted = (TLRPC.TL_pageBlockPreformatted) block;
setRichTextParents(null, pageBlockPreformatted.text);
return;
}
if (block instanceof TLRPC.TL_pageBlockSubheader) {
TLRPC.TL_pageBlockSubheader pageBlockTitle = (TLRPC.TL_pageBlockSubheader) block;
setRichTextParents(null, pageBlockTitle.text);
return;
}
if (block instanceof TLRPC.TL_pageBlockSlideshow) {
TLRPC.TL_pageBlockSlideshow pageBlockSlideshow = (TLRPC.TL_pageBlockSlideshow) block;
setRichTextParents(null, pageBlockSlideshow.caption.text);
setRichTextParents(null, pageBlockSlideshow.caption.credit);
int size = pageBlockSlideshow.items.size();
for (int a = 0; a < size; a++) {
setRichTextParents(pageBlockSlideshow.items.get(a));
}
return;
}
if (block instanceof TLRPC.TL_pageBlockPhoto) {
TLRPC.TL_pageBlockPhoto pageBlockPhoto = (TLRPC.TL_pageBlockPhoto) block;
setRichTextParents(null, pageBlockPhoto.caption.text);
setRichTextParents(null, pageBlockPhoto.caption.credit);
return;
}
if (block instanceof TL_pageBlockListItem) {
TL_pageBlockListItem pageBlockListItem = (TL_pageBlockListItem) block;
if (pageBlockListItem.textItem != null) {
setRichTextParents(null, pageBlockListItem.textItem);
return;
} else {
if (pageBlockListItem.blockItem != null) {
setRichTextParents(pageBlockListItem.blockItem);
return;
}
return;
}
}
if (block instanceof TL_pageBlockOrderedListItem) {
TL_pageBlockOrderedListItem pageBlockOrderedListItem = (TL_pageBlockOrderedListItem) block;
if (pageBlockOrderedListItem.textItem != null) {
setRichTextParents(null, pageBlockOrderedListItem.textItem);
return;
} else {
if (pageBlockOrderedListItem.blockItem != null) {
setRichTextParents(pageBlockOrderedListItem.blockItem);
return;
}
return;
}
}
if (block instanceof TLRPC.TL_pageBlockCollage) {
TLRPC.TL_pageBlockCollage pageBlockCollage = (TLRPC.TL_pageBlockCollage) block;
setRichTextParents(null, pageBlockCollage.caption.text);
setRichTextParents(null, pageBlockCollage.caption.credit);
int size2 = pageBlockCollage.items.size();
for (int a2 = 0; a2 < size2; a2++) {
setRichTextParents(pageBlockCollage.items.get(a2));
}
return;
}
if (block instanceof TLRPC.TL_pageBlockEmbed) {
TLRPC.TL_pageBlockEmbed pageBlockEmbed = (TLRPC.TL_pageBlockEmbed) block;
setRichTextParents(null, pageBlockEmbed.caption.text);
setRichTextParents(null, pageBlockEmbed.caption.credit);
return;
}
if (block instanceof TLRPC.TL_pageBlockSubtitle) {
TLRPC.TL_pageBlockSubtitle pageBlockSubtitle = (TLRPC.TL_pageBlockSubtitle) block;
setRichTextParents(null, pageBlockSubtitle.text);
return;
}
if (block instanceof TLRPC.TL_pageBlockBlockquote) {
TLRPC.TL_pageBlockBlockquote pageBlockBlockquote = (TLRPC.TL_pageBlockBlockquote) block;
setRichTextParents(null, pageBlockBlockquote.text);
setRichTextParents(null, pageBlockBlockquote.caption);
return;
}
if (block instanceof TLRPC.TL_pageBlockDetails) {
TLRPC.TL_pageBlockDetails pageBlockDetails = (TLRPC.TL_pageBlockDetails) block;
setRichTextParents(null, pageBlockDetails.title);
int size3 = pageBlockDetails.blocks.size();
for (int a3 = 0; a3 < size3; a3++) {
setRichTextParents(pageBlockDetails.blocks.get(a3));
}
return;
}
if (block instanceof TLRPC.TL_pageBlockVideo) {
TLRPC.TL_pageBlockVideo pageBlockVideo = (TLRPC.TL_pageBlockVideo) block;
setRichTextParents(null, pageBlockVideo.caption.text);
setRichTextParents(null, pageBlockVideo.caption.credit);
return;
}
if (block instanceof TLRPC.TL_pageBlockPullquote) {
TLRPC.TL_pageBlockPullquote pageBlockPullquote = (TLRPC.TL_pageBlockPullquote) block;
setRichTextParents(null, pageBlockPullquote.text);
setRichTextParents(null, pageBlockPullquote.caption);
return;
}
if (block instanceof TLRPC.TL_pageBlockAudio) {
TLRPC.TL_pageBlockAudio pageBlockAudio = (TLRPC.TL_pageBlockAudio) block;
setRichTextParents(null, pageBlockAudio.caption.text);
setRichTextParents(null, pageBlockAudio.caption.credit);
return;
}
if (block instanceof TLRPC.TL_pageBlockTable) {
TLRPC.TL_pageBlockTable pageBlockTable = (TLRPC.TL_pageBlockTable) block;
setRichTextParents(null, pageBlockTable.title);
int size4 = pageBlockTable.rows.size();
for (int a4 = 0; a4 < size4; a4++) {
TLRPC.TL_pageTableRow row = pageBlockTable.rows.get(a4);
int size22 = row.cells.size();
for (int b = 0; b < size22; b++) {
TLRPC.TL_pageTableCell cell = row.cells.get(b);
setRichTextParents(null, cell.text);
}
}
return;
}
if (block instanceof TLRPC.TL_pageBlockTitle) {
TLRPC.TL_pageBlockTitle pageBlockTitle2 = (TLRPC.TL_pageBlockTitle) block;
setRichTextParents(null, pageBlockTitle2.text);
return;
}
if (block instanceof TLRPC.TL_pageBlockCover) {
TLRPC.TL_pageBlockCover pageBlockCover = (TLRPC.TL_pageBlockCover) block;
setRichTextParents(pageBlockCover.cover);
return;
}
if (block instanceof TLRPC.TL_pageBlockAuthorDate) {
TLRPC.TL_pageBlockAuthorDate pageBlockAuthorDate = (TLRPC.TL_pageBlockAuthorDate) block;
setRichTextParents(null, pageBlockAuthorDate.author);
} else if (block instanceof TLRPC.TL_pageBlockMap) {
TLRPC.TL_pageBlockMap pageBlockMap = (TLRPC.TL_pageBlockMap) block;
setRichTextParents(null, pageBlockMap.caption.text);
setRichTextParents(null, pageBlockMap.caption.credit);
} else if (block instanceof TLRPC.TL_pageBlockRelatedArticles) {
TLRPC.TL_pageBlockRelatedArticles pageBlockRelatedArticles = (TLRPC.TL_pageBlockRelatedArticles) block;
setRichTextParents(null, pageBlockRelatedArticles.title);
}
}
public void addBlock(TLRPC.PageBlock block, int level, int listLevel, int position) {
TLRPC.PageBlock block2;
TLRPC.TL_pageBlockOrderedList pageBlockOrderedList;
int size;
String str;
TLRPC.PageBlock finalBlock;
TLRPC.TL_pageListOrderedItemBlocks pageListOrderedItemBlocks;
TLRPC.TL_pageBlockList pageBlockList;
String str2;
TLRPC.PageBlock finalBlock2;
TLRPC.TL_pageListItemBlocks pageListItemBlocks;
int size2;
TLRPC.PageBlock block3 = block;
if (block3 instanceof TL_pageBlockDetailsChild) {
TL_pageBlockDetailsChild blockDetailsChild = (TL_pageBlockDetailsChild) block3;
block3 = blockDetailsChild.block;
}
if (!(block3 instanceof TLRPC.TL_pageBlockList) && !(block3 instanceof TLRPC.TL_pageBlockOrderedList)) {
setRichTextParents(block3);
addAllMediaFromBlock(block3);
}
TLRPC.PageBlock block4 = ArticleViewer.this.getLastNonListPageBlock(block3);
if (block4 instanceof TLRPC.TL_pageBlockUnsupported) {
return;
}
if (block4 instanceof TLRPC.TL_pageBlockAnchor) {
this.anchors.put(((TLRPC.TL_pageBlockAnchor) block4).name.toLowerCase(), Integer.valueOf(this.blocks.size()));
return;
}
if (!(block4 instanceof TLRPC.TL_pageBlockList) && !(block4 instanceof TLRPC.TL_pageBlockOrderedList)) {
this.blocks.add(block);
}
if (block4 instanceof TLRPC.TL_pageBlockAudio) {
TLRPC.TL_pageBlockAudio blockAudio = (TLRPC.TL_pageBlockAudio) block4;
TLRPC.TL_message message = new TLRPC.TL_message();
message.out = true;
int i = -Long.valueOf(blockAudio.audio_id).hashCode();
block4.mid = i;
message.id = i;
message.to_id = new TLRPC.TL_peerUser();
TLRPC.Peer peer = message.to_id;
int clientUserId = UserConfig.getInstance(ArticleViewer.this.currentAccount).getClientUserId();
message.from_id = clientUserId;
peer.user_id = clientUserId;
message.date = (int) (System.currentTimeMillis() / 1000);
message.message = "";
message.media = new TLRPC.TL_messageMediaDocument();
message.media.webpage = ArticleViewer.this.currentPage;
message.media.flags |= 3;
message.media.document = ArticleViewer.this.getDocumentWithId(blockAudio.audio_id);
message.flags |= 768;
MessageObject messageObject = new MessageObject(UserConfig.selectedAccount, message, false);
this.audioMessages.add(messageObject);
this.audioBlocks.put(blockAudio, messageObject);
return;
}
AnonymousClass1 anonymousClass1 = null;
if (block4 instanceof TLRPC.TL_pageBlockEmbedPost) {
TLRPC.TL_pageBlockEmbedPost pageBlockEmbedPost = (TLRPC.TL_pageBlockEmbedPost) block4;
if (!pageBlockEmbedPost.blocks.isEmpty()) {
block4.level = -1;
for (int b = 0; b < pageBlockEmbedPost.blocks.size(); b++) {
TLRPC.PageBlock innerBlock = pageBlockEmbedPost.blocks.get(b);
if (!(innerBlock instanceof TLRPC.TL_pageBlockUnsupported)) {
if (innerBlock instanceof TLRPC.TL_pageBlockAnchor) {
TLRPC.TL_pageBlockAnchor pageBlockAnchor = (TLRPC.TL_pageBlockAnchor) innerBlock;
this.anchors.put(pageBlockAnchor.name.toLowerCase(), Integer.valueOf(this.blocks.size()));
} else {
innerBlock.level = 1;
if (b == pageBlockEmbedPost.blocks.size() - 1) {
innerBlock.bottom = true;
}
this.blocks.add(innerBlock);
addAllMediaFromBlock(innerBlock);
}
}
}
if (!TextUtils.isEmpty(ArticleViewer.getPlainText(pageBlockEmbedPost.caption.text)) || !TextUtils.isEmpty(ArticleViewer.getPlainText(pageBlockEmbedPost.caption.credit))) {
TL_pageBlockEmbedPostCaption pageBlockEmbedPostCaption = new TL_pageBlockEmbedPostCaption();
pageBlockEmbedPostCaption.parent = pageBlockEmbedPost;
pageBlockEmbedPostCaption.caption = pageBlockEmbedPost.caption;
this.blocks.add(pageBlockEmbedPostCaption);
}
}
return;
}
if (block4 instanceof TLRPC.TL_pageBlockRelatedArticles) {
TLRPC.TL_pageBlockRelatedArticles pageBlockRelatedArticles = (TLRPC.TL_pageBlockRelatedArticles) block4;
TL_pageBlockRelatedArticlesShadow shadow = new TL_pageBlockRelatedArticlesShadow();
shadow.parent = pageBlockRelatedArticles;
ArrayList<TLRPC.PageBlock> arrayList = this.blocks;
arrayList.add(arrayList.size() - 1, shadow);
int size3 = pageBlockRelatedArticles.articles.size();
for (int b2 = 0; b2 < size3; b2++) {
TL_pageBlockRelatedArticlesChild child = new TL_pageBlockRelatedArticlesChild();
child.parent = pageBlockRelatedArticles;
child.num = b2;
this.blocks.add(child);
}
if (position == 0) {
TL_pageBlockRelatedArticlesShadow shadow2 = new TL_pageBlockRelatedArticlesShadow();
shadow2.parent = pageBlockRelatedArticles;
this.blocks.add(shadow2);
}
return;
}
if (block4 instanceof TLRPC.TL_pageBlockDetails) {
TLRPC.TL_pageBlockDetails pageBlockDetails = (TLRPC.TL_pageBlockDetails) block4;
int size4 = pageBlockDetails.blocks.size();
for (int b3 = 0; b3 < size4; b3++) {
TL_pageBlockDetailsChild child2 = new TL_pageBlockDetailsChild();
child2.parent = block;
child2.block = pageBlockDetails.blocks.get(b3);
addBlock(ArticleViewer.this.wrapInTableBlock(block, child2), level + 1, listLevel, position);
}
return;
}
String str3 = " ";
if (block4 instanceof TLRPC.TL_pageBlockList) {
TLRPC.TL_pageBlockList pageBlockList2 = (TLRPC.TL_pageBlockList) block4;
TL_pageBlockListParent pageBlockListParent = new TL_pageBlockListParent();
pageBlockListParent.pageBlockList = pageBlockList2;
pageBlockListParent.level = listLevel;
int b4 = 0;
int size5 = pageBlockList2.items.size();
while (b4 < size5) {
TLRPC.PageListItem item = pageBlockList2.items.get(b4);
int size6 = size5;
TL_pageBlockListItem pageBlockListItem = new TL_pageBlockListItem();
pageBlockListItem.index = b4;
pageBlockListItem.parent = pageBlockListParent;
if (pageBlockList2.ordered) {
if (ArticleViewer.this.isRtl) {
pageBlockListItem.num = String.format(".%d", Integer.valueOf(b4 + 1));
} else {
pageBlockListItem.num = String.format("%d.", Integer.valueOf(b4 + 1));
}
} else {
pageBlockListItem.num = "•";
}
pageBlockListParent.items.add(pageBlockListItem);
if (item instanceof TLRPC.TL_pageListItemText) {
pageBlockListItem.textItem = ((TLRPC.TL_pageListItemText) item).text;
pageBlockList = pageBlockList2;
} else if (!(item instanceof TLRPC.TL_pageListItemBlocks)) {
pageBlockList = pageBlockList2;
} else {
TLRPC.TL_pageListItemBlocks pageListItemBlocks2 = (TLRPC.TL_pageListItemBlocks) item;
if (!pageListItemBlocks2.blocks.isEmpty()) {
pageBlockList = pageBlockList2;
pageBlockListItem.blockItem = pageListItemBlocks2.blocks.get(0);
} else {
pageBlockList = pageBlockList2;
TLRPC.TL_pageListItemText text = new TLRPC.TL_pageListItemText();
TLRPC.TL_textPlain textPlain = new TLRPC.TL_textPlain();
textPlain.text = str3;
text.text = textPlain;
item = text;
}
}
if (block instanceof TL_pageBlockDetailsChild) {
TL_pageBlockDetailsChild pageBlockDetailsChild = (TL_pageBlockDetailsChild) block;
str2 = str3;
TL_pageBlockDetailsChild child3 = new TL_pageBlockDetailsChild();
child3.parent = pageBlockDetailsChild.parent;
child3.block = pageBlockListItem;
addBlock(child3, level, listLevel + 1, position);
} else {
str2 = str3;
if (b4 == 0) {
finalBlock2 = ArticleViewer.this.fixListBlock(block, pageBlockListItem);
} else {
finalBlock2 = pageBlockListItem;
}
addBlock(finalBlock2, level, listLevel + 1, position);
}
if (item instanceof TLRPC.TL_pageListItemBlocks) {
TLRPC.TL_pageListItemBlocks pageListItemBlocks3 = (TLRPC.TL_pageListItemBlocks) item;
int c = 1;
int size22 = pageListItemBlocks3.blocks.size();
while (c < size22) {
TLRPC.PageListItem item2 = item;
pageBlockListItem = new TL_pageBlockListItem();
pageBlockListItem.blockItem = pageListItemBlocks3.blocks.get(c);
pageBlockListItem.parent = pageBlockListParent;
if (block instanceof TL_pageBlockDetailsChild) {
TL_pageBlockDetailsChild pageBlockDetailsChild2 = (TL_pageBlockDetailsChild) block;
pageListItemBlocks = pageListItemBlocks3;
size2 = size22;
TL_pageBlockDetailsChild child4 = new TL_pageBlockDetailsChild();
child4.parent = pageBlockDetailsChild2.parent;
child4.block = pageBlockListItem;
addBlock(child4, level, listLevel + 1, position);
} else {
pageListItemBlocks = pageListItemBlocks3;
size2 = size22;
addBlock(pageBlockListItem, level, listLevel + 1, position);
}
pageBlockListParent.items.add(pageBlockListItem);
c++;
item = item2;
pageListItemBlocks3 = pageListItemBlocks;
size22 = size2;
}
}
b4++;
size5 = size6;
pageBlockList2 = pageBlockList;
str3 = str2;
anonymousClass1 = null;
}
return;
}
String str4 = " ";
if (block4 instanceof TLRPC.TL_pageBlockOrderedList) {
TLRPC.TL_pageBlockOrderedList pageBlockOrderedList2 = (TLRPC.TL_pageBlockOrderedList) block4;
TL_pageBlockOrderedListParent pageBlockOrderedListParent = new TL_pageBlockOrderedListParent();
pageBlockOrderedListParent.pageBlockOrderedList = pageBlockOrderedList2;
pageBlockOrderedListParent.level = listLevel;
int b5 = 0;
int size7 = pageBlockOrderedList2.items.size();
while (b5 < size7) {
TLRPC.PageListOrderedItem item3 = pageBlockOrderedList2.items.get(b5);
TL_pageBlockOrderedListItem pageBlockOrderedListItem = new TL_pageBlockOrderedListItem();
pageBlockOrderedListItem.index = b5;
pageBlockOrderedListItem.parent = pageBlockOrderedListParent;
pageBlockOrderedListParent.items.add(pageBlockOrderedListItem);
if (item3 instanceof TLRPC.TL_pageListOrderedItemText) {
TLRPC.TL_pageListOrderedItemText pageListOrderedItemText = (TLRPC.TL_pageListOrderedItemText) item3;
block2 = block4;
pageBlockOrderedListItem.textItem = pageListOrderedItemText.text;
if (TextUtils.isEmpty(pageListOrderedItemText.num)) {
if (ArticleViewer.this.isRtl) {
pageBlockOrderedListItem.num = String.format(".%d", Integer.valueOf(b5 + 1));
pageBlockOrderedList = pageBlockOrderedList2;
} else {
pageBlockOrderedListItem.num = String.format("%d.", Integer.valueOf(b5 + 1));
pageBlockOrderedList = pageBlockOrderedList2;
}
} else if (ArticleViewer.this.isRtl) {
pageBlockOrderedListItem.num = "." + pageListOrderedItemText.num;
pageBlockOrderedList = pageBlockOrderedList2;
} else {
pageBlockOrderedList = pageBlockOrderedList2;
pageBlockOrderedListItem.num = pageListOrderedItemText.num + ".";
}
size = size7;
str = str4;
} else {
block2 = block4;
pageBlockOrderedList = pageBlockOrderedList2;
if (!(item3 instanceof TLRPC.TL_pageListOrderedItemBlocks)) {
size = size7;
str = str4;
} else {
TLRPC.TL_pageListOrderedItemBlocks pageListOrderedItemBlocks2 = (TLRPC.TL_pageListOrderedItemBlocks) item3;
if (!pageListOrderedItemBlocks2.blocks.isEmpty()) {
pageBlockOrderedListItem.blockItem = pageListOrderedItemBlocks2.blocks.get(0);
size = size7;
str = str4;
} else {
TLRPC.TL_pageListOrderedItemText text2 = new TLRPC.TL_pageListOrderedItemText();
TLRPC.TL_textPlain textPlain2 = new TLRPC.TL_textPlain();
size = size7;
str = str4;
textPlain2.text = str;
text2.text = textPlain2;
item3 = text2;
}
if (TextUtils.isEmpty(pageListOrderedItemBlocks2.num)) {
if (ArticleViewer.this.isRtl) {
pageBlockOrderedListItem.num = String.format(".%d", Integer.valueOf(b5 + 1));
} else {
pageBlockOrderedListItem.num = String.format("%d.", Integer.valueOf(b5 + 1));
}
} else if (ArticleViewer.this.isRtl) {
pageBlockOrderedListItem.num = "." + pageListOrderedItemBlocks2.num;
} else {
pageBlockOrderedListItem.num = pageListOrderedItemBlocks2.num + ".";
}
}
}
if (block instanceof TL_pageBlockDetailsChild) {
TL_pageBlockDetailsChild pageBlockDetailsChild3 = (TL_pageBlockDetailsChild) block;
TL_pageBlockDetailsChild child5 = new TL_pageBlockDetailsChild();
child5.parent = pageBlockDetailsChild3.parent;
child5.block = pageBlockOrderedListItem;
addBlock(child5, level, listLevel + 1, position);
} else {
if (b5 == 0) {
finalBlock = ArticleViewer.this.fixListBlock(block, pageBlockOrderedListItem);
} else {
finalBlock = pageBlockOrderedListItem;
}
addBlock(finalBlock, level, listLevel + 1, position);
}
if (item3 instanceof TLRPC.TL_pageListOrderedItemBlocks) {
TLRPC.TL_pageListOrderedItemBlocks pageListOrderedItemBlocks3 = (TLRPC.TL_pageListOrderedItemBlocks) item3;
int c2 = 1;
int size23 = pageListOrderedItemBlocks3.blocks.size();
while (c2 < size23) {
String str5 = str;
TLRPC.PageListOrderedItem item4 = item3;
TL_pageBlockOrderedListItem pageBlockOrderedListItem2 = new TL_pageBlockOrderedListItem();
pageBlockOrderedListItem2.blockItem = pageListOrderedItemBlocks3.blocks.get(c2);
pageBlockOrderedListItem2.parent = pageBlockOrderedListParent;
if (block instanceof TL_pageBlockDetailsChild) {
TL_pageBlockDetailsChild pageBlockDetailsChild4 = (TL_pageBlockDetailsChild) block;
pageListOrderedItemBlocks = pageListOrderedItemBlocks3;
TL_pageBlockDetailsChild child6 = new TL_pageBlockDetailsChild();
child6.parent = pageBlockDetailsChild4.parent;
child6.block = pageBlockOrderedListItem2;
addBlock(child6, level, listLevel + 1, position);
} else {
pageListOrderedItemBlocks = pageListOrderedItemBlocks3;
addBlock(pageBlockOrderedListItem2, level, listLevel + 1, position);
}
pageBlockOrderedListParent.items.add(pageBlockOrderedListItem2);
c2++;
pageListOrderedItemBlocks3 = pageListOrderedItemBlocks;
str = str5;
item3 = item4;
}
}
String str6 = str;
b5++;
block4 = block2;
pageBlockOrderedList2 = pageBlockOrderedList;
size7 = size;
str4 = str6;
}
}
}
private void addAllMediaFromBlock(TLRPC.PageBlock block) {
if (!(block instanceof TLRPC.TL_pageBlockPhoto)) {
if ((block instanceof TLRPC.TL_pageBlockVideo) && ArticleViewer.this.isVideoBlock(block)) {
TLRPC.TL_pageBlockVideo pageBlockVideo = (TLRPC.TL_pageBlockVideo) block;
TLRPC.Document document = ArticleViewer.this.getDocumentWithId(pageBlockVideo.video_id);
if (document != null) {
pageBlockVideo.thumb = FileLoader.getClosestPhotoSizeWithSize(document.thumbs, 56, true);
pageBlockVideo.thumbObject = document;
this.photoBlocks.add(block);
return;
}
return;
}
if (block instanceof TLRPC.TL_pageBlockSlideshow) {
TLRPC.TL_pageBlockSlideshow slideshow = (TLRPC.TL_pageBlockSlideshow) block;
int count = slideshow.items.size();
for (int a = 0; a < count; a++) {
TLRPC.PageBlock innerBlock = slideshow.items.get(a);
innerBlock.groupId = ArticleViewer.this.lastBlockNum;
addAllMediaFromBlock(innerBlock);
}
ArticleViewer.access$13108(ArticleViewer.this);
return;
}
if (block instanceof TLRPC.TL_pageBlockCollage) {
TLRPC.TL_pageBlockCollage collage = (TLRPC.TL_pageBlockCollage) block;
int count2 = collage.items.size();
for (int a2 = 0; a2 < count2; a2++) {
TLRPC.PageBlock innerBlock2 = collage.items.get(a2);
innerBlock2.groupId = ArticleViewer.this.lastBlockNum;
addAllMediaFromBlock(innerBlock2);
}
ArticleViewer.access$13108(ArticleViewer.this);
return;
}
if (block instanceof TLRPC.TL_pageBlockCover) {
TLRPC.TL_pageBlockCover pageBlockCover = (TLRPC.TL_pageBlockCover) block;
addAllMediaFromBlock(pageBlockCover.cover);
return;
}
return;
}
TLRPC.TL_pageBlockPhoto pageBlockPhoto = (TLRPC.TL_pageBlockPhoto) block;
TLRPC.Photo photo = ArticleViewer.this.getPhotoWithId(pageBlockPhoto.photo_id);
if (photo != null) {
pageBlockPhoto.thumb = FileLoader.getClosestPhotoSizeWithSize(photo.sizes, 56, true);
pageBlockPhoto.thumbObject = photo;
this.photoBlocks.add(block);
}
}
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view;
switch (viewType) {
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:
view = 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:
view = 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:
view = 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:
view = 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;
case 90:
FrameLayout frameLayout = new FrameLayout(this.context) {
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, View.MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(44.0f), 1073741824));
}
};
frameLayout.setTag(90);
TextView textView = new TextView(this.context);
frameLayout.addView(textView, LayoutHelper.createFrame(-1.0f, 34.0f, 51, 0.0f, 10.0f, 0.0f, 0.0f));
textView.setText(LocaleController.getString("PreviewFeedback", R.string.PreviewFeedback));
textView.setTextSize(1, 12.0f);
textView.setGravity(17);
view = frameLayout;
break;
default:
TextView textView2 = new TextView(this.context);
textView2.setBackgroundColor(SupportMenu.CATEGORY_MASK);
textView2.setTextColor(-16777216);
textView2.setTextSize(1, 20.0f);
view = textView2;
break;
}
view.setLayoutParams(new RecyclerView.LayoutParams(-1, -2));
view.setFocusable(true);
return new RecyclerListView.Holder(view);
}
@Override
public boolean isEnabled(RecyclerView.ViewHolder holder) {
int type = holder.getItemViewType();
if (type == 23 || type == 24) {
return true;
}
return false;
}
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
if (position < this.localBlocks.size()) {
TLRPC.PageBlock block = this.localBlocks.get(position);
bindBlockToHolder(holder.getItemViewType(), holder, block, position, this.localBlocks.size());
return;
}
if (holder.getItemViewType() == 90) {
TextView textView = (TextView) ((ViewGroup) holder.itemView).getChildAt(0);
int color = ArticleViewer.this.getSelectedColor();
if (color == 0) {
textView.setTextColor(-8879475);
textView.setBackgroundColor(-1183760);
} else if (color == 1) {
textView.setTextColor(ArticleViewer.this.getGrayTextColor());
textView.setBackgroundColor(-1712440);
} else if (color == 2) {
textView.setTextColor(ArticleViewer.this.getGrayTextColor());
textView.setBackgroundColor(-15000805);
}
}
}
public void bindBlockToHolder(int type, RecyclerView.ViewHolder holder, TLRPC.PageBlock block, int position, int total) {
if (block instanceof TLRPC.TL_pageBlockCover) {
block = ((TLRPC.TL_pageBlockCover) block).cover;
} else if (block instanceof TL_pageBlockDetailsChild) {
TL_pageBlockDetailsChild pageBlockDetailsChild = (TL_pageBlockDetailsChild) block;
block = pageBlockDetailsChild.block;
}
switch (type) {
case 0:
BlockParagraphCell cell = (BlockParagraphCell) holder.itemView;
cell.setBlock((TLRPC.TL_pageBlockParagraph) block);
return;
case 1:
BlockHeaderCell cell2 = (BlockHeaderCell) holder.itemView;
cell2.setBlock((TLRPC.TL_pageBlockHeader) block);
return;
case 2:
return;
case 3:
BlockEmbedCell cell3 = (BlockEmbedCell) holder.itemView;
cell3.setBlock((TLRPC.TL_pageBlockEmbed) block);
return;
case 4:
BlockSubtitleCell cell4 = (BlockSubtitleCell) holder.itemView;
cell4.setBlock((TLRPC.TL_pageBlockSubtitle) block);
return;
case 5:
BlockVideoCell cell5 = (BlockVideoCell) holder.itemView;
cell5.setBlock((TLRPC.TL_pageBlockVideo) block, position == 0, position == total + (-1));
cell5.setParentBlock(block);
return;
case 6:
BlockPullquoteCell cell6 = (BlockPullquoteCell) holder.itemView;
cell6.setBlock((TLRPC.TL_pageBlockPullquote) block);
return;
case 7:
BlockBlockquoteCell cell7 = (BlockBlockquoteCell) holder.itemView;
cell7.setBlock((TLRPC.TL_pageBlockBlockquote) block);
return;
case 8:
BlockSlideshowCell cell8 = (BlockSlideshowCell) holder.itemView;
cell8.setBlock((TLRPC.TL_pageBlockSlideshow) block);
return;
case 9:
BlockPhotoCell cell9 = (BlockPhotoCell) holder.itemView;
cell9.setBlock((TLRPC.TL_pageBlockPhoto) block, position == 0, position == total + (-1));
cell9.setParentBlock(block);
return;
case 10:
BlockAuthorDateCell cell10 = (BlockAuthorDateCell) holder.itemView;
cell10.setBlock((TLRPC.TL_pageBlockAuthorDate) block);
return;
case 11:
BlockTitleCell cell11 = (BlockTitleCell) holder.itemView;
cell11.setBlock((TLRPC.TL_pageBlockTitle) block);
return;
case 12:
BlockListItemCell cell12 = (BlockListItemCell) holder.itemView;
cell12.setBlock((TL_pageBlockListItem) block);
return;
case 13:
BlockFooterCell cell13 = (BlockFooterCell) holder.itemView;
cell13.setBlock((TLRPC.TL_pageBlockFooter) block);
return;
case 14:
BlockPreformattedCell cell14 = (BlockPreformattedCell) holder.itemView;
cell14.setBlock((TLRPC.TL_pageBlockPreformatted) block);
return;
case 15:
BlockSubheaderCell cell15 = (BlockSubheaderCell) holder.itemView;
cell15.setBlock((TLRPC.TL_pageBlockSubheader) block);
return;
case 16:
BlockEmbedPostCell cell16 = (BlockEmbedPostCell) holder.itemView;
cell16.setBlock((TLRPC.TL_pageBlockEmbedPost) block);
return;
case 17:
BlockCollageCell cell17 = (BlockCollageCell) holder.itemView;
cell17.setBlock((TLRPC.TL_pageBlockCollage) block);
return;
case 18:
BlockChannelCell cell18 = (BlockChannelCell) holder.itemView;
cell18.setBlock((TLRPC.TL_pageBlockChannel) block);
return;
case 19:
BlockAudioCell cell19 = (BlockAudioCell) holder.itemView;
cell19.setBlock((TLRPC.TL_pageBlockAudio) block, position == 0, position == total + (-1));
return;
case 20:
BlockKickerCell cell20 = (BlockKickerCell) holder.itemView;
cell20.setBlock((TLRPC.TL_pageBlockKicker) block);
return;
case 21:
BlockOrderedListItemCell cell21 = (BlockOrderedListItemCell) holder.itemView;
cell21.setBlock((TL_pageBlockOrderedListItem) block);
return;
case 22:
BlockMapCell cell22 = (BlockMapCell) holder.itemView;
cell22.setBlock((TLRPC.TL_pageBlockMap) block, position == 0, position == total + (-1));
return;
case 23:
BlockRelatedArticlesCell cell23 = (BlockRelatedArticlesCell) holder.itemView;
cell23.setBlock((TL_pageBlockRelatedArticlesChild) block);
return;
case 24:
BlockDetailsCell cell24 = (BlockDetailsCell) holder.itemView;
cell24.setBlock((TLRPC.TL_pageBlockDetails) block);
return;
case 25:
BlockTableCell cell25 = (BlockTableCell) holder.itemView;
cell25.setBlock((TLRPC.TL_pageBlockTable) block);
return;
case 26:
BlockRelatedArticlesHeaderCell cell26 = (BlockRelatedArticlesHeaderCell) holder.itemView;
cell26.setBlock((TLRPC.TL_pageBlockRelatedArticles) block);
return;
case 27:
return;
case 100:
TextView textView = (TextView) holder.itemView;
textView.setText("unsupported block " + block);
return;
default:
return;
}
}
public int getTypeForBlock(TLRPC.PageBlock block) {
if (block instanceof TLRPC.TL_pageBlockParagraph) {
return 0;
}
if (block instanceof TLRPC.TL_pageBlockHeader) {
return 1;
}
if (block instanceof TLRPC.TL_pageBlockDivider) {
return 2;
}
if (block instanceof TLRPC.TL_pageBlockEmbed) {
return 3;
}
if (block instanceof TLRPC.TL_pageBlockSubtitle) {
return 4;
}
if (block instanceof TLRPC.TL_pageBlockVideo) {
return 5;
}
if (block instanceof TLRPC.TL_pageBlockPullquote) {
return 6;
}
if (block instanceof TLRPC.TL_pageBlockBlockquote) {
return 7;
}
if (block instanceof TLRPC.TL_pageBlockSlideshow) {
return 8;
}
if (block instanceof TLRPC.TL_pageBlockPhoto) {
return 9;
}
if (block instanceof TLRPC.TL_pageBlockAuthorDate) {
return 10;
}
if (block instanceof TLRPC.TL_pageBlockTitle) {
return 11;
}
if (block instanceof TL_pageBlockListItem) {
return 12;
}
if (block instanceof TLRPC.TL_pageBlockFooter) {
return 13;
}
if (block instanceof TLRPC.TL_pageBlockPreformatted) {
return 14;
}
if (block instanceof TLRPC.TL_pageBlockSubheader) {
return 15;
}
if (block instanceof TLRPC.TL_pageBlockEmbedPost) {
return 16;
}
if (block instanceof TLRPC.TL_pageBlockCollage) {
return 17;
}
if (block instanceof TLRPC.TL_pageBlockChannel) {
return 18;
}
if (block instanceof TLRPC.TL_pageBlockAudio) {
return 19;
}
if (block instanceof TLRPC.TL_pageBlockKicker) {
return 20;
}
if (block instanceof TL_pageBlockOrderedListItem) {
return 21;
}
if (block instanceof TLRPC.TL_pageBlockMap) {
return 22;
}
if (block instanceof TL_pageBlockRelatedArticlesChild) {
return 23;
}
if (block instanceof TLRPC.TL_pageBlockDetails) {
return 24;
}
if (block instanceof TLRPC.TL_pageBlockTable) {
return 25;
}
if (block instanceof TLRPC.TL_pageBlockRelatedArticles) {
return 26;
}
if (block instanceof TL_pageBlockDetailsBottom) {
return 27;
}
if (block instanceof TL_pageBlockRelatedArticlesShadow) {
return 28;
}
if (block instanceof TL_pageBlockDetailsChild) {
TL_pageBlockDetailsChild pageBlockDetailsChild = (TL_pageBlockDetailsChild) block;
return getTypeForBlock(pageBlockDetailsChild.block);
}
if (block instanceof TLRPC.TL_pageBlockCover) {
TLRPC.TL_pageBlockCover pageBlockCover = (TLRPC.TL_pageBlockCover) block;
return getTypeForBlock(pageBlockCover.cover);
}
return 100;
}
@Override
public int getItemViewType(int position) {
if (position == this.localBlocks.size()) {
return 90;
}
return getTypeForBlock(this.localBlocks.get(position));
}
public TLRPC.PageBlock getItem(int position) {
return this.localBlocks.get(position);
}
@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 child) {
TLRPC.PageBlock parentBlock = ArticleViewer.this.getLastNonListPageBlock(child.parent);
if (parentBlock instanceof TLRPC.TL_pageBlockDetails) {
return ((TLRPC.TL_pageBlockDetails) parentBlock).open;
}
if (!(parentBlock instanceof TL_pageBlockDetailsChild)) {
return false;
}
TL_pageBlockDetailsChild parent = (TL_pageBlockDetailsChild) parentBlock;
TLRPC.PageBlock parentBlock2 = ArticleViewer.this.getLastNonListPageBlock(parent.block);
if (!(parentBlock2 instanceof TLRPC.TL_pageBlockDetails) || ((TLRPC.TL_pageBlockDetails) parentBlock2).open) {
return isBlockOpened(parent);
}
return false;
}
public void updateRows() {
int a;
this.localBlocks.clear();
int size = this.blocks.size();
while (a < size) {
TLRPC.PageBlock originalBlock = this.blocks.get(a);
TLRPC.PageBlock block = ArticleViewer.this.getLastNonListPageBlock(originalBlock);
if (block instanceof TL_pageBlockDetailsChild) {
TL_pageBlockDetailsChild pageBlockDetailsChild = (TL_pageBlockDetailsChild) block;
a = isBlockOpened(pageBlockDetailsChild) ? 0 : a + 1;
}
this.localBlocks.add(originalBlock);
}
}
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 position) {
updateRows();
super.notifyItemChanged(position);
}
@Override
public void notifyItemChanged(int position, Object payload) {
updateRows();
super.notifyItemChanged(position, payload);
}
@Override
public void notifyItemRangeChanged(int positionStart, int itemCount) {
updateRows();
super.notifyItemRangeChanged(positionStart, itemCount);
}
@Override
public void notifyItemRangeChanged(int positionStart, int itemCount, Object payload) {
updateRows();
super.notifyItemRangeChanged(positionStart, itemCount, payload);
}
@Override
public void notifyItemInserted(int position) {
updateRows();
super.notifyItemInserted(position);
}
@Override
public void notifyItemMoved(int fromPosition, int toPosition) {
updateRows();
super.notifyItemMoved(fromPosition, toPosition);
}
@Override
public void notifyItemRangeInserted(int positionStart, int itemCount) {
updateRows();
super.notifyItemRangeInserted(positionStart, itemCount);
}
@Override
public void notifyItemRemoved(int position) {
updateRows();
super.notifyItemRemoved(position);
}
@Override
public void notifyItemRangeRemoved(int positionStart, int itemCount) {
updateRows();
super.notifyItemRangeRemoved(positionStart, itemCount);
}
}
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;
public BlockVideoCell(Context context, WebpageAdapter adapter, int type) {
super(context);
this.parentAdapter = adapter;
setWillNotDraw(false);
ImageReceiver imageReceiver = new ImageReceiver(this);
this.imageView = imageReceiver;
imageReceiver.setNeedsQualityThumb(true);
this.imageView.setShouldGenerateQualityThumb(true);
this.currentType = type;
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 block, boolean first, boolean last) {
this.currentBlock = block;
this.parentBlock = null;
this.cancelLoading = false;
TLRPC.Document documentWithId = ArticleViewer.this.getDocumentWithId(block.video_id);
this.currentDocument = documentWithId;
this.isGif = MessageObject.isGifDocument(documentWithId);
this.isFirst = first;
this.isLast = last;
this.channelCell.setVisibility(4);
updateButtonState(false);
requestLayout();
}
public void setParentBlock(TLRPC.PageBlock block) {
this.parentBlock = block;
if (ArticleViewer.this.channelBlock != null && (this.parentBlock instanceof TLRPC.TL_pageBlockCover)) {
this.channelCell.setBlock(ArticleViewer.this.channelBlock);
this.channelCell.setVisibility(0);
}
}
public View getChannelCell() {
return this.channelCell;
}
@Override
public boolean onTouchEvent(MotionEvent event) {
float x = event.getX();
float y = event.getY();
if (this.channelCell.getVisibility() == 0 && y > this.channelCell.getTranslationY() && y < this.channelCell.getTranslationY() + AndroidUtilities.dp(39.0f)) {
if (ArticleViewer.this.channelBlock != null && event.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 (event.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 (event.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 (event.getAction() == 3) {
this.photoPressed = false;
}
return this.photoPressed || this.buttonPressed != 0 || ArticleViewer.this.checkLayoutForLinks(event, this, this.captionLayout, this.textX, this.textY) || ArticleViewer.this.checkLayoutForLinks(event, this, this.creditLayout, this.textX, this.textY + this.creditOffset) || super.onTouchEvent(event);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int width;
int height;
int photoX;
int textWidth;
boolean z;
int height2;
int i;
int width2 = View.MeasureSpec.getSize(widthMeasureSpec);
int height3 = 0;
int i2 = this.currentType;
if (i2 == 1) {
int width3 = ((View) getParent()).getMeasuredWidth();
height3 = ((View) getParent()).getMeasuredHeight();
width = width3;
} else if (i2 != 2) {
width = width2;
} else {
height3 = (int) Math.ceil(this.groupPosition.ph * Math.max(AndroidUtilities.displaySize.x, AndroidUtilities.displaySize.y) * 0.5f);
width = width2;
}
TLRPC.TL_pageBlockVideo tL_pageBlockVideo = this.currentBlock;
if (tL_pageBlockVideo != null) {
int photoWidth = width;
int photoHeight = height3;
if (this.currentType == 0 && tL_pageBlockVideo.level > 0) {
int dp = AndroidUtilities.dp(this.currentBlock.level * 14) + AndroidUtilities.dp(18.0f);
photoX = dp;
this.textX = dp;
photoWidth -= AndroidUtilities.dp(18.0f) + photoX;
textWidth = photoWidth;
} else {
photoX = 0;
this.textX = AndroidUtilities.dp(18.0f);
textWidth = width - AndroidUtilities.dp(36.0f);
}
if (this.currentDocument == null) {
height = height3;
} else {
int size = AndroidUtilities.dp(48.0f);
TLRPC.PhotoSize thumb = FileLoader.getClosestPhotoSizeWithSize(this.currentDocument.thumbs, 48);
int i3 = this.currentType;
if (i3 == 0) {
boolean found = false;
int a = 0;
int count = this.currentDocument.attributes.size();
while (true) {
if (a >= count) {
break;
}
TLRPC.DocumentAttribute attribute = this.currentDocument.attributes.get(a);
if (!(attribute instanceof TLRPC.TL_documentAttributeVideo)) {
a++;
} else {
float scale = photoWidth / attribute.w;
height3 = (int) (attribute.h * scale);
found = true;
break;
}
}
float w = thumb != null ? thumb.w : 100.0f;
float h = thumb != null ? thumb.h : 100.0f;
if (!found) {
float scale2 = photoWidth / w;
height3 = (int) (scale2 * h);
}
if (!(this.parentBlock instanceof TLRPC.TL_pageBlockCover)) {
int maxHeight = (int) ((Math.max(ArticleViewer.this.listView[0].getMeasuredWidth(), ArticleViewer.this.listView[0].getMeasuredHeight()) - AndroidUtilities.dp(56.0f)) * 0.9f);
if (height3 > maxHeight) {
height3 = maxHeight;
float scale3 = height3 / h;
photoWidth = (int) (scale3 * w);
photoX += ((width - photoX) - photoWidth) / 2;
}
} else {
height3 = Math.min(height3, photoWidth);
}
if (height3 == 0) {
height3 = AndroidUtilities.dp(100.0f);
} else if (height3 < size) {
height3 = size;
}
photoHeight = height3;
} else if (i3 == 2) {
if ((this.groupPosition.flags & 2) == 0) {
photoWidth -= AndroidUtilities.dp(2.0f);
}
if ((this.groupPosition.flags & 8) == 0) {
photoHeight -= AndroidUtilities.dp(2.0f);
}
}
this.imageView.setQualityThumbDocument(this.currentDocument);
this.imageView.setImageCoords(photoX, (this.isFirst || (i = this.currentType) == 1 || i == 2 || this.currentBlock.level > 0) ? 0 : AndroidUtilities.dp(8.0f), photoWidth, photoHeight);
if (this.isGif) {
this.autoDownload = DownloadController.getInstance(ArticleViewer.this.currentAccount).canDownloadMedia(4, this.currentDocument.size);
File path = FileLoader.getPathToAttach(this.currentDocument, true);
if (!this.autoDownload && !path.exists()) {
this.imageView.setStrippedLocation(ImageLocation.getForDocument(this.currentDocument));
this.imageView.setImage(null, null, null, null, ImageLocation.getForDocument(thumb, this.currentDocument), "80_80_b", null, this.currentDocument.size, null, ArticleViewer.this.currentPage, 1);
} else {
this.imageView.setStrippedLocation(null);
this.imageView.setImage(ImageLocation.getForDocument(this.currentDocument), null, null, null, ImageLocation.getForDocument(thumb, 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(thumb, this.currentDocument), "80_80_b", 0, null, ArticleViewer.this.currentPage, 1);
}
this.imageView.setAspectFit(true);
this.buttonX = (int) (this.imageView.getImageX() + ((this.imageView.getImageWidth() - size) / 2.0f));
int imageY = (int) (this.imageView.getImageY() + ((this.imageView.getImageHeight() - size) / 2.0f));
this.buttonY = imageY;
RadialProgress2 radialProgress2 = this.radialProgress;
int i4 = this.buttonX;
radialProgress2.setProgressRect(i4, imageY, i4 + size, imageY + size);
height = height3;
}
if (this.currentType == 0) {
DrawingText createLayoutForText = ArticleViewer.this.createLayoutForText(this, null, this.currentBlock.caption.text, textWidth, this.currentBlock, this.parentAdapter);
this.captionLayout = createLayoutForText;
if (createLayoutForText != null) {
int dp2 = AndroidUtilities.dp(4.0f) + this.captionLayout.getHeight();
this.creditOffset = dp2;
height2 = height + dp2 + AndroidUtilities.dp(4.0f);
} else {
height2 = height;
}
DrawingText createLayoutForText2 = ArticleViewer.this.createLayoutForText(this, (CharSequence) null, this.currentBlock.caption.credit, textWidth, this.currentBlock, ArticleViewer.this.isRtl ? StaticLayoutEx.ALIGN_RIGHT() : Layout.Alignment.ALIGN_NORMAL, this.parentAdapter);
this.creditLayout = createLayoutForText2;
if (createLayoutForText2 != null) {
height = height2 + AndroidUtilities.dp(4.0f) + this.creditLayout.getHeight();
} else {
height = height2;
}
}
if (!this.isFirst && this.currentType == 0 && this.currentBlock.level <= 0) {
height += AndroidUtilities.dp(8.0f);
}
if (this.parentBlock instanceof TLRPC.TL_pageBlockCover) {
z = true;
if (this.parentAdapter.blocks.size() > 1) {
}
}
z = false;
boolean nextIsChannel = z;
if (this.currentType != 2 && !nextIsChannel) {
height += AndroidUtilities.dp(8.0f);
}
} else {
height = 1;
}
this.channelCell.measure(widthMeasureSpec, heightMeasureSpec);
this.channelCell.setTranslationY(this.imageView.getImageHeight() - AndroidUtilities.dp(39.0f));
setMeasuredDimension(width, height);
}
@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;
}
if (i == 3) {
return 0;
}
return 4;
}
public void updateButtonState(boolean animated) {
String fileName = FileLoader.getAttachFileName(this.currentDocument);
File path = FileLoader.getPathToAttach(this.currentDocument, true);
boolean fileExists = path.exists();
if (TextUtils.isEmpty(fileName)) {
this.radialProgress.setIcon(4, false, false);
return;
}
if (fileExists) {
DownloadController.getInstance(ArticleViewer.this.currentAccount).removeLoadingFileObserver(this);
if (!this.isGif) {
this.buttonState = 3;
} else {
this.buttonState = -1;
}
this.radialProgress.setIcon(getIconForCurrentState(), false, animated);
invalidate();
return;
}
DownloadController.getInstance(ArticleViewer.this.currentAccount).addLoadingFileObserver(fileName, null, this);
float setProgress = 0.0f;
boolean progressVisible = false;
if (!FileLoader.getInstance(ArticleViewer.this.currentAccount).isLoadingFile(fileName)) {
if (!this.cancelLoading && this.autoDownload && this.isGif) {
progressVisible = true;
this.buttonState = 1;
} else {
this.buttonState = 0;
}
} else {
progressVisible = true;
this.buttonState = 1;
Float progress = ImageLoader.getInstance().getFileProgress(fileName);
setProgress = progress != null ? progress.floatValue() : 0.0f;
}
this.radialProgress.setIcon(getIconForCurrentState(), progressVisible, animated);
this.radialProgress.setProgress(setProgress, false);
invalidate();
}
private void didPressedButton(boolean animated) {
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 {
TLRPC.PhotoSize thumb = FileLoader.getClosestPhotoSizeWithSize(this.currentDocument.thumbs, 40);
this.imageView.setImage(ImageLocation.getForDocument(this.currentDocument), null, ImageLocation.getForDocument(thumb, this.currentDocument), "80_80_b", this.currentDocument.size, null, ArticleViewer.this.currentPage, 1);
}
this.buttonState = 1;
this.radialProgress.setIcon(getIconForCurrentState(), true, animated);
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, animated);
invalidate();
return;
}
if (i == 2) {
this.imageView.setAllowStartAnimation(true);
this.imageView.startAnimation();
this.buttonState = -1;
this.radialProgress.setIcon(getIconForCurrentState(), false, animated);
return;
}
if (i == 3) {
ArticleViewer.this.openPhoto(this.currentBlock);
}
}
@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 fileName, boolean canceled) {
updateButtonState(false);
}
@Override
public void onSuccessDownload(String fileName) {
this.radialProgress.setProgress(1.0f, true);
if (this.isGif) {
this.buttonState = 2;
didPressedButton(true);
} else {
updateButtonState(true);
}
}
@Override
public void onProgressUpload(String fileName, float progress, boolean isEncrypted) {
}
@Override
public void onProgressDownload(String fileName, float progress) {
this.radialProgress.setProgress(progress, true);
if (this.buttonState != 1) {
updateButtonState(true);
}
}
@Override
public int getObserverTag() {
return this.TAG;
}
@Override
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
super.onInitializeAccessibilityNodeInfo(info);
info.setEnabled(true);
StringBuilder sb = new StringBuilder(LocaleController.getString("AttachVideo", R.string.AttachVideo));
if (this.captionLayout != null) {
sb.append(", ");
sb.append(this.captionLayout.getText());
}
info.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;
public BlockAudioCell(Context context, WebpageAdapter adapter) {
super(context);
this.textY = AndroidUtilities.dp(54.0f);
this.parentAdapter = adapter;
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.m1086lambda$new$0$imwsnshelzviuiArticleViewer$BlockAudioCell(f);
}
});
}
public void m1086lambda$new$0$imwsnshelzviuiArticleViewer$BlockAudioCell(float progress) {
MessageObject messageObject = this.currentMessageObject;
if (messageObject == null) {
return;
}
messageObject.audioProgress = progress;
MediaController.getInstance().seekToProgress(this.currentMessageObject, progress);
}
public void setBlock(TLRPC.TL_pageBlockAudio block, boolean first, boolean last) {
this.currentBlock = block;
MessageObject messageObject = (MessageObject) this.parentAdapter.audioBlocks.get(this.currentBlock);
this.currentMessageObject = messageObject;
this.currentDocument = messageObject.getDocument();
this.isFirst = first;
this.isLast = last;
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 event) {
float x = event.getX();
float y = event.getY();
boolean result = this.seekBar.onTouch(event.getAction(), event.getX() - this.seekBarX, event.getY() - this.seekBarY);
if (result) {
if (event.getAction() == 0) {
getParent().requestDisallowInterceptTouchEvent(true);
}
invalidate();
return true;
}
if (event.getAction() != 0) {
if (event.getAction() == 1) {
if (this.buttonPressed == 1) {
this.buttonPressed = 0;
playSoundEffect(0);
didPressedButton(true);
invalidate();
}
} else if (event.getAction() == 3) {
this.buttonPressed = 0;
}
} else if (this.buttonState != -1) {
if (x >= this.buttonX && x <= r4 + AndroidUtilities.dp(48.0f)) {
if (y >= this.buttonY) {
}
}
}
return this.buttonPressed != 0 || ArticleViewer.this.checkLayoutForLinks(event, this, this.captionLayout, this.textX, this.textY) || ArticleViewer.this.checkLayoutForLinks(event, this, this.creditLayout, this.textX, this.textY + this.creditOffset) || super.onTouchEvent(event);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int height;
SpannableStringBuilder stringBuilder;
int width = View.MeasureSpec.getSize(widthMeasureSpec);
int height2 = AndroidUtilities.dp(54.0f);
TLRPC.TL_pageBlockAudio tL_pageBlockAudio = this.currentBlock;
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 textWidth = (width - this.textX) - AndroidUtilities.dp(18.0f);
int size = AndroidUtilities.dp(44.0f);
this.buttonX = AndroidUtilities.dp(16.0f);
int dp = AndroidUtilities.dp(5.0f);
this.buttonY = dp;
RadialProgress2 radialProgress2 = this.radialProgress;
int i = this.buttonX;
radialProgress2.setProgressRect(i, dp, i + size, dp + size);
DrawingText createLayoutForText = ArticleViewer.this.createLayoutForText(this, null, this.currentBlock.caption.text, textWidth, this.currentBlock, this.parentAdapter);
this.captionLayout = createLayoutForText;
if (createLayoutForText != null) {
int dp2 = AndroidUtilities.dp(4.0f) + this.captionLayout.getHeight();
this.creditOffset = dp2;
height = height2 + dp2 + AndroidUtilities.dp(4.0f);
} else {
height = height2;
}
DrawingText createLayoutForText2 = ArticleViewer.this.createLayoutForText(this, (CharSequence) null, this.currentBlock.caption.credit, textWidth, this.currentBlock, ArticleViewer.this.isRtl ? StaticLayoutEx.ALIGN_RIGHT() : Layout.Alignment.ALIGN_NORMAL, this.parentAdapter);
this.creditLayout = createLayoutForText2;
if (createLayoutForText2 != null) {
height += AndroidUtilities.dp(4.0f) + this.creditLayout.getHeight();
}
if (!this.isFirst && this.currentBlock.level <= 0) {
height += AndroidUtilities.dp(8.0f);
}
String author = this.currentMessageObject.getMusicAuthor(false);
String title = this.currentMessageObject.getMusicTitle(false);
int dp3 = this.buttonX + AndroidUtilities.dp(50.0f) + size;
this.seekBarX = dp3;
int w = (width - dp3) - AndroidUtilities.dp(18.0f);
if (TextUtils.isEmpty(title) && TextUtils.isEmpty(author)) {
this.titleLayout = null;
this.seekBarY = this.buttonY + ((size - AndroidUtilities.dp(30.0f)) / 2);
} else {
if (!TextUtils.isEmpty(title) && !TextUtils.isEmpty(author)) {
stringBuilder = new SpannableStringBuilder(String.format("%s - %s", author, title));
} else if (!TextUtils.isEmpty(title)) {
stringBuilder = new SpannableStringBuilder(title);
} else {
stringBuilder = new SpannableStringBuilder(author);
}
if (!TextUtils.isEmpty(author)) {
TypefaceSpan span = new TypefaceSpan(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
stringBuilder.setSpan(span, 0, author.length(), 18);
}
CharSequence stringFinal = TextUtils.ellipsize(stringBuilder, Theme.chat_audioTitlePaint, w, TextUtils.TruncateAt.END);
this.titleLayout = new StaticLayout(stringFinal, ArticleViewer.audioTimePaint, w, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
this.seekBarY = this.buttonY + ((size - AndroidUtilities.dp(30.0f)) / 2) + AndroidUtilities.dp(11.0f);
}
this.seekBar.setSize(w, AndroidUtilities.dp(30.0f));
} else {
height = 1;
}
setMeasuredDimension(width, height);
updatePlayingMessageProgress();
}
@Override
protected void onDraw(Canvas canvas) {
if (this.currentBlock != null) {
this.radialProgress.setColors(ArticleViewer.this.getTextColor(), ArticleViewer.this.getTextColor(), ArticleViewer.this.getTextColor(), ArticleViewer.this.getTextColor());
this.radialProgress.draw(canvas);
canvas.save();
canvas.translate(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;
}
if (i == 3) {
return 3;
}
return 0;
}
public void updatePlayingMessageProgress() {
if (this.currentDocument == null || this.currentMessageObject == null) {
return;
}
if (!this.seekBar.isDragging()) {
this.seekBar.setProgress(this.currentMessageObject.audioProgress);
}
int duration = 0;
if (MediaController.getInstance().isPlayingMessage(this.currentMessageObject)) {
duration = this.currentMessageObject.audioProgressSec;
} else {
int a = 0;
while (true) {
if (a >= this.currentDocument.attributes.size()) {
break;
}
TLRPC.DocumentAttribute attribute = this.currentDocument.attributes.get(a);
if (!(attribute instanceof TLRPC.TL_documentAttributeAudio)) {
a++;
} else {
duration = attribute.duration;
break;
}
}
}
String timeString = String.format("%d:%02d", Integer.valueOf(duration / 60), Integer.valueOf(duration % 60));
String str = this.lastTimeString;
if (str == null || (str != null && !str.equals(timeString))) {
this.lastTimeString = timeString;
ArticleViewer.audioTimePaint.setTextSize(AndroidUtilities.dp(16.0f));
int timeWidth = (int) Math.ceil(ArticleViewer.audioTimePaint.measureText(timeString));
this.durationLayout = new StaticLayout(timeString, ArticleViewer.audioTimePaint, timeWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
}
ArticleViewer.audioTimePaint.setColor(ArticleViewer.this.getTextColor());
invalidate();
}
public void updateButtonState(boolean animated) {
String fileName = FileLoader.getAttachFileName(this.currentDocument);
File path = FileLoader.getPathToAttach(this.currentDocument, true);
boolean fileExists = path.exists();
if (TextUtils.isEmpty(fileName)) {
this.radialProgress.setIcon(4, false, false);
return;
}
if (fileExists) {
DownloadController.getInstance(ArticleViewer.this.currentAccount).removeLoadingFileObserver(this);
boolean playing = MediaController.getInstance().isPlayingMessage(this.currentMessageObject);
if (!playing || (playing && MediaController.getInstance().isMessagePaused())) {
this.buttonState = 0;
} else {
this.buttonState = 1;
}
this.radialProgress.setIcon(getIconForCurrentState(), false, animated);
} else {
DownloadController.getInstance(ArticleViewer.this.currentAccount).addLoadingFileObserver(fileName, null, this);
if (!FileLoader.getInstance(ArticleViewer.this.currentAccount).isLoadingFile(fileName)) {
this.buttonState = 2;
this.radialProgress.setProgress(0.0f, animated);
this.radialProgress.setIcon(getIconForCurrentState(), false, animated);
} else {
this.buttonState = 3;
Float progress = ImageLoader.getInstance().getFileProgress(fileName);
if (progress != null) {
this.radialProgress.setProgress(progress.floatValue(), animated);
} else {
this.radialProgress.setProgress(0.0f, animated);
}
this.radialProgress.setIcon(getIconForCurrentState(), true, animated);
}
}
updatePlayingMessageProgress();
}
private void didPressedButton(boolean animated) {
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, animated);
invalidate();
return;
}
return;
}
if (i == 1) {
boolean result = MediaController.getInstance().m321lambda$startAudioAgain$5$imwsnshelzvimessengerMediaController(this.currentMessageObject);
if (result) {
this.buttonState = 0;
this.radialProgress.setIcon(getIconForCurrentState(), false, animated);
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, animated);
invalidate();
return;
}
if (i == 3) {
FileLoader.getInstance(ArticleViewer.this.currentAccount).cancelLoadFile(this.currentDocument);
this.buttonState = 2;
this.radialProgress.setIcon(getIconForCurrentState(), false, animated);
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 fileName, boolean canceled) {
updateButtonState(true);
}
@Override
public void onSuccessDownload(String fileName) {
this.radialProgress.setProgress(1.0f, true);
updateButtonState(true);
}
@Override
public void onProgressUpload(String fileName, float progress, boolean isEncrypted) {
}
@Override
public void onProgressDownload(String fileName, float progress) {
this.radialProgress.setProgress(progress, 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 adapter) {
super(context);
this.parentAdapter = adapter;
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 block) {
this.currentBlock = block;
requestLayout();
}
@Override
public boolean onTouchEvent(MotionEvent event) {
return ArticleViewer.this.checkLayoutForLinks(event, this, this.captionLayout, this.textX, this.textY) || ArticleViewer.this.checkLayoutForLinks(event, this, this.creditLayout, this.textX, this.textY + this.creditOffset) || super.onTouchEvent(event);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int height;
int width = View.MeasureSpec.getSize(widthMeasureSpec);
TLRPC.TL_pageBlockEmbedPost tL_pageBlockEmbedPost = this.currentBlock;
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 photo = ArticleViewer.this.getPhotoWithId(this.currentBlock.author_photo_id);
boolean z2 = photo instanceof TLRPC.TL_photo;
this.avatarVisible = z2;
if (z2) {
this.avatarDrawable.setInfo(0, this.currentBlock.author, null);
TLRPC.PhotoSize image = FileLoader.getClosestPhotoSizeWithSize(photo.sizes, AndroidUtilities.dp(40.0f), true);
this.avatarImageView.setImage(ImageLocation.getForPhoto(image, photo), "40_40", this.avatarDrawable, 0, (String) null, ArticleViewer.this.currentPage, 1);
}
}
this.nameLayout = ArticleViewer.this.createLayoutForText(this, this.currentBlock.author, null, width - 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, width - AndroidUtilities.dp((this.avatarVisible ? 54 : 0) + 50), this.currentBlock, this.parentAdapter);
} else {
this.dateLayout = null;
}
height = AndroidUtilities.dp(56.0f);
if (this.currentBlock.blocks.isEmpty()) {
int textWidth = width - AndroidUtilities.dp(50.0f);
DrawingText createLayoutForText = ArticleViewer.this.createLayoutForText(this, null, this.currentBlock.caption.text, textWidth, this.currentBlock, this.parentAdapter);
this.captionLayout = createLayoutForText;
if (createLayoutForText != null) {
int dp = AndroidUtilities.dp(4.0f) + this.captionLayout.getHeight();
this.creditOffset = dp;
height += dp + AndroidUtilities.dp(4.0f);
}
DrawingText createLayoutForText2 = ArticleViewer.this.createLayoutForText(this, (CharSequence) null, this.currentBlock.caption.credit, textWidth, this.currentBlock, ArticleViewer.this.isRtl ? StaticLayoutEx.ALIGN_RIGHT() : Layout.Alignment.ALIGN_NORMAL, this.parentAdapter);
this.creditLayout = createLayoutForText2;
if (createLayoutForText2 != null) {
height += AndroidUtilities.dp(4.0f) + this.creditLayout.getHeight();
}
this.textX = AndroidUtilities.dp(32.0f);
this.textY = AndroidUtilities.dp(56.0f);
} else {
this.captionLayout = null;
this.creditLayout = null;
}
} else {
int textWidth2 = width - AndroidUtilities.dp(50.0f);
DrawingText createLayoutForText3 = ArticleViewer.this.createLayoutForText(this, null, this.currentBlock.caption.text, textWidth2, this.currentBlock, this.parentAdapter);
this.captionLayout = createLayoutForText3;
if (createLayoutForText3 != null) {
int dp2 = AndroidUtilities.dp(4.0f) + this.captionLayout.getHeight();
this.creditOffset = dp2;
int height2 = 0 + dp2 + AndroidUtilities.dp(4.0f);
height = height2;
} else {
height = 0;
}
DrawingText createLayoutForText4 = ArticleViewer.this.createLayoutForText(this, (CharSequence) null, this.currentBlock.caption.credit, textWidth2, this.currentBlock, ArticleViewer.this.isRtl ? StaticLayoutEx.ALIGN_RIGHT() : Layout.Alignment.ALIGN_NORMAL, this.parentAdapter);
this.creditLayout = createLayoutForText4;
if (createLayoutForText4 != null) {
height += AndroidUtilities.dp(4.0f) + this.creditLayout.getHeight();
}
this.textX = AndroidUtilities.dp(18.0f);
this.textY = AndroidUtilities.dp(4.0f);
}
this.lineHeight = height;
} else {
height = 1;
}
setMeasuredDimension(width, height);
}
@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 adapter) {
super(context);
this.parentAdapter = adapter;
}
public void setBlock(TLRPC.TL_pageBlockParagraph block) {
this.currentBlock = block;
requestLayout();
}
@Override
public boolean onTouchEvent(MotionEvent event) {
return ArticleViewer.this.checkLayoutForLinks(event, this, this.textLayout, this.textX, this.textY) || super.onTouchEvent(event);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int width = View.MeasureSpec.getSize(widthMeasureSpec);
int height = 0;
TLRPC.TL_pageBlockParagraph tL_pageBlockParagraph = this.currentBlock;
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, (width - 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 height2 = createLayoutForText.getHeight();
if (this.currentBlock.level > 0) {
height = height2 + AndroidUtilities.dp(8.0f);
} else {
height = height2 + AndroidUtilities.dp(16.0f);
}
}
} else {
height = 1;
}
setMeasuredDimension(width, height);
}
@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 info) {
super.onInitializeAccessibilityNodeInfo(info);
info.setEnabled(true);
DrawingText drawingText = this.textLayout;
if (drawingText == null) {
return;
}
info.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 eventName, final String eventData) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
ArticleViewer.BlockEmbedCell.WebviewProxy.this.m1089xb7275d36(eventName, eventData);
}
});
}
public void m1089xb7275d36(String eventName, String eventData) {
if ("resize_frame".equals(eventName)) {
try {
JSONObject object = new JSONObject(eventData);
BlockEmbedCell.this.exactWebViewHeight = Utilities.parseInt(object.getString("height")).intValue();
BlockEmbedCell.this.requestLayout();
} catch (Throwable th) {
}
}
}
}
public class TouchyWebView extends WebView {
public TouchyWebView(Context context) {
super(context);
setFocusable(false);
}
@Override
public boolean onTouchEvent(MotionEvent event) {
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(event);
}
}
public BlockEmbedCell(Context context, WebpageAdapter adapter) {
super(context);
this.parentAdapter = adapter;
setWillNotDraw(false);
WebPlayerView webPlayerView = new WebPlayerView(context, false, false, new WebPlayerView.WebPlayerViewDelegate() {
@Override
public void onInitFailed() {
BlockEmbedCell.this.webView.setVisibility(0);
BlockEmbedCell.this.videoView.setVisibility(4);
BlockEmbedCell.this.videoView.loadVideo(null, null, null, null, false);
HashMap<String, String> args = new HashMap<>();
args.put("Referer", "http://youtube.com");
BlockEmbedCell.this.webView.loadUrl(BlockEmbedCell.this.currentBlock.url, args);
}
@Override
public void onVideoSizeChanged(float aspectRatio, int rotation) {
ArticleViewer.this.fullscreenAspectRatioView.setAspectRatio(aspectRatio, rotation);
}
@Override
public void onInlineSurfaceTextureReady() {
}
@Override
public TextureView onSwitchToFullscreen(View controlsView, boolean fullscreen, float aspectRatio, int rotation, boolean byButton) {
if (fullscreen) {
ArticleViewer.this.fullscreenAspectRatioView.addView(ArticleViewer.this.fullscreenTextureView, LayoutHelper.createFrame(-1, -1.0f));
ArticleViewer.this.fullscreenAspectRatioView.setVisibility(0);
ArticleViewer.this.fullscreenAspectRatioView.setAspectRatio(aspectRatio, rotation);
ArticleViewer.this.fullscreenedVideo = BlockEmbedCell.this.videoView;
ArticleViewer.this.fullscreenVideoContainer.addView(controlsView, 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 prepareToSwitchInlineMode(boolean inline, Runnable switchInlineModeRunnable, float aspectRatio, boolean animated) {
}
@Override
public TextureView onSwitchInlineMode(View controlsView, boolean inline, float aspectRatio, int rotation, boolean animated) {
return null;
}
@Override
public void onSharePressed() {
if (ArticleViewer.this.parentActivity != null) {
ArticleViewer.this.showDialog(new ShareAlert(ArticleViewer.this.parentActivity, null, BlockEmbedCell.this.currentBlock.url, false, BlockEmbedCell.this.currentBlock.url, true));
}
}
@Override
public void onPlayStateChanged(WebPlayerView playerView, boolean playing) {
if (playing) {
if (ArticleViewer.this.currentPlayingVideo != null && ArticleViewer.this.currentPlayingVideo != playerView) {
ArticleViewer.this.currentPlayingVideo.pause();
}
ArticleViewer.this.currentPlayingVideo = playerView;
try {
ArticleViewer.this.parentActivity.getWindow().addFlags(128);
return;
} catch (Exception e) {
FileLog.e(e);
return;
}
}
if (ArticleViewer.this.currentPlayingVideo == playerView) {
ArticleViewer.this.currentPlayingVideo = null;
}
try {
ArticleViewer.this.parentActivity.getWindow().clearFlags(128);
} catch (Exception e2) {
FileLog.e(e2);
}
}
@Override
public boolean checkInlinePermissions() {
return false;
}
@Override
public ViewGroup getTextureViewContainer() {
return null;
}
});
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);
this.webView.getSettings().setMediaPlaybackRequiresUserGesture(false);
this.webView.addJavascriptInterface(new WebviewProxy(), "WebviewProxy");
this.webView.getSettings().setMixedContentMode(0);
CookieManager cookieManager = CookieManager.getInstance();
cookieManager.setAcceptThirdPartyCookies(this.webView, true);
this.webView.setWebChromeClient(new AnonymousClass2(ArticleViewer.this));
this.webView.setWebViewClient(new WebViewClient() {
@Override
public void onLoadResource(WebView view, String url) {
super.onLoadResource(view, url);
}
@Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
}
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if (BlockEmbedCell.this.wasUserInteraction) {
Browser.openUrl(ArticleViewer.this.parentActivity, url);
return true;
}
return false;
}
});
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 requestedOrientation, WebChromeClient.CustomViewCallback callback) {
onShowCustomView(view, callback);
}
@Override
public void onShowCustomView(View view, WebChromeClient.CustomViewCallback callback) {
if (ArticleViewer.this.customView == null) {
ArticleViewer.this.customView = view;
ArticleViewer.this.customViewCallback = callback;
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
ArticleViewer.BlockEmbedCell.AnonymousClass2.this.m1088xc3c74983();
}
}, 100L);
return;
}
callback.onCustomViewHidden();
}
public void m1088xc3c74983() {
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) {
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 completely) {
try {
this.webView.stopLoading();
this.webView.loadUrl("about:blank");
if (completely) {
this.webView.destroy();
}
this.currentBlock = null;
} catch (Exception e) {
FileLog.e(e);
}
this.videoView.destroy();
}
public void setBlock(TLRPC.TL_pageBlockEmbed block) {
TLRPC.TL_pageBlockEmbed previousBlock = this.currentBlock;
this.currentBlock = block;
if (previousBlock != block) {
this.wasUserInteraction = false;
if (!block.allow_scrolling) {
this.webView.setVerticalScrollBarEnabled(false);
this.webView.setHorizontalScrollBarEnabled(false);
} else {
this.webView.setVerticalScrollBarEnabled(true);
this.webView.setHorizontalScrollBarEnabled(true);
}
this.exactWebViewHeight = 0;
try {
this.webView.loadUrl("about:blank");
} catch (Exception e) {
FileLog.e(e);
}
try {
if (this.currentBlock.html == null) {
TLRPC.Photo thumb = this.currentBlock.poster_photo_id != 0 ? ArticleViewer.this.getPhotoWithId(this.currentBlock.poster_photo_id) : null;
boolean handled = this.videoView.loadVideo(block.url, thumb, ArticleViewer.this.currentPage, null, false);
if (!handled) {
this.webView.setVisibility(0);
this.videoView.setVisibility(4);
this.videoView.loadVideo(null, null, null, null, false);
HashMap<String, String> args = new HashMap<>();
args.put("Referer", "http://youtube.com");
this.webView.loadUrl(this.currentBlock.url, args);
} else {
this.webView.setVisibility(4);
this.videoView.setVisibility(0);
this.webView.stopLoading();
this.webView.loadUrl("about:blank");
}
} else {
this.webView.loadDataWithBaseURL("https://m12345.com/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) {
this.currentBlock = null;
}
}
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
}
@Override
public boolean onTouchEvent(MotionEvent event) {
return ArticleViewer.this.checkLayoutForLinks(event, this, this.captionLayout, this.textX, this.textY) || ArticleViewer.this.checkLayoutForLinks(event, this, this.creditLayout, this.textX, this.textY + this.creditOffset) || super.onTouchEvent(event);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int height;
int listWidth;
int textWidth;
float scale;
int height2;
int height3;
int height4;
int width = View.MeasureSpec.getSize(widthMeasureSpec);
TLRPC.TL_pageBlockEmbed tL_pageBlockEmbed = this.currentBlock;
if (tL_pageBlockEmbed != null) {
if (tL_pageBlockEmbed.level <= 0) {
this.listX = 0;
this.textX = AndroidUtilities.dp(18.0f);
int textWidth2 = width - AndroidUtilities.dp(36.0f);
if (!this.currentBlock.full_width) {
int listWidth2 = width - AndroidUtilities.dp(36.0f);
this.listX += AndroidUtilities.dp(18.0f);
listWidth = listWidth2;
textWidth = textWidth2;
} else {
listWidth = width;
textWidth = textWidth2;
}
} else {
int dp = AndroidUtilities.dp(this.currentBlock.level * 14) + AndroidUtilities.dp(18.0f);
this.listX = dp;
this.textX = dp;
int listWidth3 = width - (dp + AndroidUtilities.dp(18.0f));
textWidth = listWidth3;
listWidth = listWidth3;
}
if (this.currentBlock.w == 0) {
scale = 1.0f;
} else {
float scale2 = width;
scale = scale2 / this.currentBlock.w;
}
int i = this.exactWebViewHeight;
if (i != 0) {
height2 = AndroidUtilities.dp(i);
} else {
height2 = (int) ((this.currentBlock.w == 0 ? AndroidUtilities.dp(this.currentBlock.h) : this.currentBlock.h) * scale);
}
if (height2 != 0) {
height3 = height2;
} else {
int height5 = AndroidUtilities.dp(10.0f);
height3 = height5;
}
this.webView.measure(View.MeasureSpec.makeMeasureSpec(listWidth, 1073741824), View.MeasureSpec.makeMeasureSpec(height3, 1073741824));
if (this.videoView.getParent() == this) {
this.videoView.measure(View.MeasureSpec.makeMeasureSpec(listWidth, 1073741824), View.MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(10.0f) + height3, 1073741824));
}
DrawingText createLayoutForText = ArticleViewer.this.createLayoutForText(this, null, this.currentBlock.caption.text, textWidth, this.currentBlock, this.parentAdapter);
this.captionLayout = createLayoutForText;
if (createLayoutForText != null) {
this.textY = AndroidUtilities.dp(8.0f) + height3;
int dp2 = AndroidUtilities.dp(4.0f) + this.captionLayout.getHeight();
this.creditOffset = dp2;
height4 = height3 + dp2 + AndroidUtilities.dp(4.0f);
} else {
height4 = height3;
}
DrawingText createLayoutForText2 = ArticleViewer.this.createLayoutForText(this, (CharSequence) null, this.currentBlock.caption.credit, textWidth, this.currentBlock, ArticleViewer.this.isRtl ? StaticLayoutEx.ALIGN_RIGHT() : Layout.Alignment.ALIGN_NORMAL, this.parentAdapter);
this.creditLayout = createLayoutForText2;
if (createLayoutForText2 != null) {
height4 += AndroidUtilities.dp(4.0f) + this.creditLayout.getHeight();
}
height = height4 + AndroidUtilities.dp(5.0f);
if (this.currentBlock.level > 0 && !this.currentBlock.bottom) {
height += AndroidUtilities.dp(8.0f);
} else if (this.currentBlock.level == 0 && this.captionLayout != null) {
height += AndroidUtilities.dp(8.0f);
}
} else {
height = 1;
}
setMeasuredDimension(width, height);
}
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
TouchyWebView touchyWebView = this.webView;
int i = this.listX;
touchyWebView.layout(i, 0, touchyWebView.getMeasuredWidth() + i, this.webView.getMeasuredHeight());
if (this.videoView.getParent() == this) {
WebPlayerView webPlayerView = this.videoView;
int i2 = this.listX;
webPlayerView.layout(i2, 0, webPlayerView.getMeasuredWidth() + i2, 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 adapter) {
super(context);
this.parentAdapter = adapter;
HorizontalScrollView horizontalScrollView = new HorizontalScrollView(context) {
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
if (BlockTableCell.this.tableLayout.getMeasuredWidth() > getMeasuredWidth() - AndroidUtilities.dp(36.0f)) {
ArticleViewer.this.windowView.requestDisallowInterceptTouchEvent(true);
}
return super.onInterceptTouchEvent(ev);
}
@Override
protected void onScrollChanged(int l, int t, int oldl, int oldt) {
super.onScrollChanged(l, t, oldl, oldt);
if (ArticleViewer.this.pressedLinkOwnerLayout != null) {
ArticleViewer.this.pressedLinkOwnerLayout = null;
ArticleViewer.this.pressedLinkOwnerView = null;
}
}
@Override
protected boolean overScrollBy(int deltaX, int deltaY, int scrollX, int scrollY, int scrollRangeX, int scrollRangeY, int maxOverScrollX, int maxOverScrollY, boolean isTouchEvent) {
ArticleViewer.this.removePressedLink();
return super.overScrollBy(deltaX, deltaY, scrollX, scrollY, scrollRangeX, scrollRangeY, maxOverScrollX, maxOverScrollY, isTouchEvent);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
BlockTableCell.this.tableLayout.measure(View.MeasureSpec.makeMeasureSpec((View.MeasureSpec.getSize(widthMeasureSpec) - getPaddingLeft()) - getPaddingRight(), 0), heightMeasureSpec);
setMeasuredDimension(View.MeasureSpec.getSize(widthMeasureSpec), 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 cell, int maxWidth) {
Layout.Alignment alignment;
if (cell == null) {
return null;
}
if (cell.align_right) {
alignment = Layout.Alignment.ALIGN_OPPOSITE;
} else if (cell.align_center) {
alignment = Layout.Alignment.ALIGN_CENTER;
} else {
alignment = Layout.Alignment.ALIGN_NORMAL;
}
return ArticleViewer.this.createLayoutForText(this, null, cell.text, maxWidth, 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 block) {
this.currentBlock = block;
int color = ArticleViewer.this.getSelectedColor();
if (color == 0) {
AndroidUtilities.setScrollViewEdgeEffectColor(this.scrollView, -657673);
} else if (color == 1) {
AndroidUtilities.setScrollViewEdgeEffectColor(this.scrollView, -659492);
} else if (color == 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);
int maxCols = 0;
if (!this.currentBlock.rows.isEmpty()) {
TLRPC.TL_pageTableRow row = this.currentBlock.rows.get(0);
int size2 = row.cells.size();
for (int c = 0; c < size2; c++) {
TLRPC.TL_pageTableCell cell = row.cells.get(c);
maxCols += cell.colspan != 0 ? cell.colspan : 1;
}
}
int size = this.currentBlock.rows.size();
for (int r = 0; r < size; r++) {
TLRPC.TL_pageTableRow row2 = this.currentBlock.rows.get(r);
int cols = 0;
int size22 = row2.cells.size();
for (int c2 = 0; c2 < size22; c2++) {
TLRPC.TL_pageTableCell cell2 = row2.cells.get(c2);
int colspan = cell2.colspan != 0 ? cell2.colspan : 1;
int rowspan = cell2.rowspan != 0 ? cell2.rowspan : 1;
if (cell2.text != null) {
this.tableLayout.addChild(cell2, cols, r, colspan);
} else {
this.tableLayout.addChild(cols, r, colspan, rowspan);
}
cols += colspan;
}
}
this.tableLayout.setColumnCount(maxCols);
this.firstLayout = true;
requestLayout();
}
@Override
public boolean onTouchEvent(MotionEvent event) {
int N = this.tableLayout.getChildCount();
for (int i = 0; i < N; i++) {
TableLayout.Child c = this.tableLayout.getChildAt(i);
if (ArticleViewer.this.checkLayoutForLinks(event, this, c.textLayout, (this.scrollView.getPaddingLeft() - this.scrollView.getScrollX()) + this.listX + c.getTextX(), this.listY + c.getTextY())) {
return true;
}
}
return ArticleViewer.this.checkLayoutForLinks(event, this, this.titleLayout, this.textX, this.textY) || super.onTouchEvent(event);
}
@Override
public void invalidate() {
super.invalidate();
this.tableLayout.invalidate();
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int height;
int textWidth;
this.inLayout = true;
int width = View.MeasureSpec.getSize(widthMeasureSpec);
int height2 = 0;
TLRPC.TL_pageBlockTable tL_pageBlockTable = this.currentBlock;
if (tL_pageBlockTable != null) {
if (tL_pageBlockTable.level > 0) {
int dp = AndroidUtilities.dp(this.currentBlock.level * 14);
this.listX = dp;
int dp2 = dp + AndroidUtilities.dp(18.0f);
this.textX = dp2;
textWidth = width - dp2;
} else {
this.listX = 0;
this.textX = AndroidUtilities.dp(18.0f);
textWidth = width - AndroidUtilities.dp(36.0f);
}
DrawingText createLayoutForText = ArticleViewer.this.createLayoutForText(this, null, this.currentBlock.title, textWidth, 0, this.currentBlock, Layout.Alignment.ALIGN_CENTER, 0, this.parentAdapter);
this.titleLayout = createLayoutForText;
if (createLayoutForText == null) {
this.listY = AndroidUtilities.dp(8.0f);
} else {
this.textY = 0;
height2 = 0 + createLayoutForText.getHeight() + AndroidUtilities.dp(8.0f);
this.listY = height2;
}
this.scrollView.measure(View.MeasureSpec.makeMeasureSpec(width - this.listX, 1073741824), View.MeasureSpec.makeMeasureSpec(0, 0));
height = height2 + this.scrollView.getMeasuredHeight() + AndroidUtilities.dp(8.0f);
if (this.currentBlock.level > 0 && !this.currentBlock.bottom) {
height += AndroidUtilities.dp(8.0f);
}
} else {
height = 1;
}
setMeasuredDimension(width, height);
this.inLayout = false;
}
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
HorizontalScrollView horizontalScrollView = this.scrollView;
int i = this.listX;
horizontalScrollView.layout(i, this.listY, horizontalScrollView.getMeasuredWidth() + i, 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 i1, int i2, float f1, float f2) {
this.lineCounts = new int[]{i1, i2};
this.heights = new float[]{f1, f2};
}
public MessageGroupedLayoutAttempt(int i1, int i2, int i3, float f1, float f2, float f3) {
this.lineCounts = new int[]{i1, i2, i3};
this.heights = new float[]{f1, f2, f3};
}
public MessageGroupedLayoutAttempt(int i1, int i2, int i3, int i4, float f1, float f2, float f3, float f4) {
this.lineCounts = new int[]{i1, i2, i3, i4};
this.heights = new float[]{f1, f2, f3, f4};
}
}
private float multiHeight(float[] array, int start, int end) {
float sum = 0.0f;
for (int a = start; a < end; a++) {
sum += array[a];
}
int a2 = this.maxSizeWidth;
return a2 / sum;
}
public void calculate() {
float averageAspectRatio;
float maxAspectRatio;
int paddingsWidth;
int count;
int a;
int count2;
int thirdLine;
int minHeight;
int count3;
float maxSizeHeight;
int minWidth;
int minWidth2;
int minWidth3;
float maxAspectRatio2;
int paddingsWidth2;
int paddingsWidth3;
int paddingsWidth4;
float averageAspectRatio2;
float averageAspectRatio3;
float maxAspectRatio3;
int paddingsWidth5;
int paddingsWidth6;
int minWidth4;
int minWidth5;
TLRPC.PhotoSize photoSize;
MessageObject.GroupedMessagePosition position;
this.posArray.clear();
this.positions.clear();
int count4 = BlockCollageCell.this.currentBlock.items.size();
if (count4 <= 1) {
return;
}
float minWidth6 = 814.0f;
StringBuilder proportions = new StringBuilder();
float averageAspectRatio4 = 1.0f;
this.hasSibling = false;
int a2 = 0;
boolean forceCalc = false;
while (a2 < count4) {
TLObject object = BlockCollageCell.this.currentBlock.items.get(a2);
if (!(object instanceof TLRPC.TL_pageBlockPhoto)) {
if (object instanceof TLRPC.TL_pageBlockVideo) {
TLRPC.TL_pageBlockVideo pageBlockVideo = (TLRPC.TL_pageBlockVideo) object;
TLRPC.Document document = ArticleViewer.this.getDocumentWithId(pageBlockVideo.video_id);
if (document != null) {
photoSize = FileLoader.getClosestPhotoSizeWithSize(document.thumbs, 90);
position = new MessageObject.GroupedMessagePosition();
position.last = a2 != count4 + (-1);
position.aspectRatio = photoSize != null ? 1.0f : photoSize.w / photoSize.h;
if (position.aspectRatio <= 1.2f) {
}
averageAspectRatio4 += position.aspectRatio;
if (position.aspectRatio > 2.0f) {
}
this.positions.put(object, position);
this.posArray.add(position);
}
}
a2++;
} else {
TLRPC.TL_pageBlockPhoto pageBlockPhoto = (TLRPC.TL_pageBlockPhoto) object;
TLRPC.Photo photo = ArticleViewer.this.getPhotoWithId(pageBlockPhoto.photo_id);
if (photo == null) {
a2++;
} else {
photoSize = FileLoader.getClosestPhotoSizeWithSize(photo.sizes, AndroidUtilities.getPhotoSize());
position = new MessageObject.GroupedMessagePosition();
position.last = a2 != count4 + (-1);
position.aspectRatio = photoSize != null ? 1.0f : photoSize.w / photoSize.h;
if (position.aspectRatio <= 1.2f) {
proportions.append("w");
} else if (position.aspectRatio < 0.8f) {
proportions.append("n");
} else {
proportions.append("q");
}
averageAspectRatio4 += position.aspectRatio;
if (position.aspectRatio > 2.0f) {
forceCalc = true;
}
this.positions.put(object, position);
this.posArray.add(position);
a2++;
}
}
}
int minHeight2 = AndroidUtilities.dp(120.0f);
int minWidth7 = (int) (AndroidUtilities.dp(120.0f) / (Math.min(AndroidUtilities.displaySize.x, AndroidUtilities.displaySize.y) / this.maxSizeWidth));
float dp = AndroidUtilities.dp(40.0f);
float min = Math.min(AndroidUtilities.displaySize.x, AndroidUtilities.displaySize.y);
int i = this.maxSizeWidth;
int paddingsWidth7 = (int) (dp / (min / i));
float maxAspectRatio4 = i / 814.0f;
float averageAspectRatio5 = averageAspectRatio4 / count4;
if (!forceCalc) {
if (count4 == 2 || count4 == 3 || count4 == 4) {
if (count4 == 2) {
MessageObject.GroupedMessagePosition position1 = this.posArray.get(0);
MessageObject.GroupedMessagePosition position2 = this.posArray.get(1);
String pString = proportions.toString();
if (pString.equals("ww")) {
paddingsWidth6 = paddingsWidth7;
minWidth4 = minWidth7;
if (averageAspectRatio5 > maxAspectRatio4 * 1.4d && position1.aspectRatio - position2.aspectRatio < 0.2d) {
float height = Math.round(Math.min(this.maxSizeWidth / position1.aspectRatio, Math.min(this.maxSizeWidth / position2.aspectRatio, 814.0f / 2.0f))) / 814.0f;
position1.set(0, 0, 0, 0, this.maxSizeWidth, height, 7);
position2.set(0, 0, 1, 1, this.maxSizeWidth, height, 11);
minWidth5 = minWidth4;
count = count4;
}
} else {
paddingsWidth6 = paddingsWidth7;
minWidth4 = minWidth7;
}
if (pString.equals("ww")) {
minWidth5 = minWidth4;
} else if (pString.equals("qq")) {
minWidth5 = minWidth4;
} else {
int secondWidth = (int) Math.max(this.maxSizeWidth * 0.4f, Math.round((r1 / position1.aspectRatio) / ((1.0f / position1.aspectRatio) + (1.0f / position2.aspectRatio))));
int firstWidth = this.maxSizeWidth - secondWidth;
minWidth5 = minWidth4;
if (firstWidth < minWidth5) {
int diff = minWidth5 - firstWidth;
firstWidth = minWidth5;
secondWidth -= diff;
}
float height2 = Math.min(814.0f, Math.round(Math.min(firstWidth / position1.aspectRatio, secondWidth / position2.aspectRatio))) / 814.0f;
position1.set(0, 0, 0, 0, firstWidth, height2, 13);
position2.set(1, 1, 0, 0, secondWidth, height2, 14);
count = count4;
}
int width = this.maxSizeWidth / 2;
float height3 = Math.round(Math.min(width / position1.aspectRatio, Math.min(width / position2.aspectRatio, 814.0f))) / 814.0f;
position1.set(0, 0, 0, 0, width, height3, 13);
position2.set(1, 1, 0, 0, width, height3, 14);
count = count4;
} else if (count4 == 3) {
MessageObject.GroupedMessagePosition position12 = this.posArray.get(0);
MessageObject.GroupedMessagePosition position22 = this.posArray.get(1);
MessageObject.GroupedMessagePosition position3 = this.posArray.get(2);
if (proportions.charAt(0) == 'n') {
float thirdHeight = Math.min(814.0f * 0.5f, Math.round((position22.aspectRatio * this.maxSizeWidth) / (position3.aspectRatio + position22.aspectRatio)));
float secondHeight = 814.0f - thirdHeight;
maxAspectRatio3 = maxAspectRatio4;
int rightWidth = (int) Math.max(minWidth7, Math.min(this.maxSizeWidth * 0.5f, Math.round(Math.min(position3.aspectRatio * thirdHeight, position22.aspectRatio * secondHeight))));
paddingsWidth5 = paddingsWidth7;
int leftWidth = Math.round(Math.min((position12.aspectRatio * 814.0f) + paddingsWidth5, this.maxSizeWidth - rightWidth));
position12.set(0, 0, 0, 1, leftWidth, 1.0f, 13);
position22.set(1, 1, 0, 0, rightWidth, secondHeight / 814.0f, 6);
position3.set(0, 1, 1, 1, rightWidth, thirdHeight / 814.0f, 10);
position3.spanSize = this.maxSizeWidth;
position12.siblingHeights = new float[]{thirdHeight / 814.0f, secondHeight / 814.0f};
position22.spanSize = this.maxSizeWidth - leftWidth;
position3.leftSpanOffset = leftWidth;
this.hasSibling = true;
} else {
maxAspectRatio3 = maxAspectRatio4;
paddingsWidth5 = paddingsWidth7;
float firstHeight = Math.round(Math.min(this.maxSizeWidth / position12.aspectRatio, 0.66f * 814.0f)) / 814.0f;
position12.set(0, 1, 0, 0, this.maxSizeWidth, firstHeight, 7);
int width2 = this.maxSizeWidth / 2;
float secondHeight2 = Math.min(814.0f - firstHeight, Math.round(Math.min(width2 / position22.aspectRatio, width2 / position3.aspectRatio))) / 814.0f;
position22.set(0, 0, 1, 1, width2, secondHeight2, 9);
position3.set(1, 1, 1, 1, width2, secondHeight2, 10);
}
count = count4;
} else if (count4 == 4) {
MessageObject.GroupedMessagePosition position13 = this.posArray.get(0);
MessageObject.GroupedMessagePosition position23 = this.posArray.get(1);
MessageObject.GroupedMessagePosition position32 = this.posArray.get(2);
MessageObject.GroupedMessagePosition position4 = this.posArray.get(3);
if (proportions.charAt(0) == 'w') {
float h0 = Math.round(Math.min(this.maxSizeWidth / position13.aspectRatio, 0.66f * 814.0f)) / 814.0f;
position13.set(0, 2, 0, 0, this.maxSizeWidth, h0, 7);
float h = Math.round(this.maxSizeWidth / ((position23.aspectRatio + position32.aspectRatio) + position4.aspectRatio));
int w0 = (int) Math.max(minWidth7, Math.min(this.maxSizeWidth * 0.4f, position23.aspectRatio * h));
int w2 = (int) Math.max(Math.max(minWidth7, this.maxSizeWidth * 0.33f), position4.aspectRatio * h);
int w1 = (this.maxSizeWidth - w0) - w2;
averageAspectRatio3 = averageAspectRatio5;
float averageAspectRatio6 = 814.0f - h0;
float h2 = Math.min(averageAspectRatio6, h) / 814.0f;
position23.set(0, 0, 1, 1, w0, h2, 9);
position32.set(1, 1, 1, 1, w1, h2, 8);
position4.set(2, 2, 1, 1, w2, h2, 10);
} else {
averageAspectRatio3 = averageAspectRatio5;
int w = Math.max(minWidth7, Math.round(814.0f / (((1.0f / position23.aspectRatio) + (1.0f / position32.aspectRatio)) + (1.0f / this.posArray.get(3).aspectRatio))));
float h02 = Math.min(0.33f, Math.max(minHeight2, w / position23.aspectRatio) / 814.0f);
float h1 = Math.min(0.33f, Math.max(minHeight2, w / position32.aspectRatio) / 814.0f);
float h22 = (1.0f - h02) - h1;
int w02 = Math.round(Math.min((position13.aspectRatio * 814.0f) + paddingsWidth7, this.maxSizeWidth - w));
position13.set(0, 0, 0, 2, w02, h02 + h1 + h22, 13);
position23.set(1, 1, 0, 0, w, h02, 6);
position32.set(0, 1, 1, 1, w, h1, 2);
position32.spanSize = this.maxSizeWidth;
position4.set(0, 1, 2, 2, w, h22, 10);
position4.spanSize = this.maxSizeWidth;
position23.spanSize = this.maxSizeWidth - w02;
position32.leftSpanOffset = w02;
position4.leftSpanOffset = w02;
position13.siblingHeights = new float[]{h02, h1, h22};
this.hasSibling = true;
}
count = count4;
} else {
count = count4;
}
a = 0;
while (true) {
count2 = count;
if (a >= count2) {
MessageObject.GroupedMessagePosition pos = this.posArray.get(a);
if ((pos.flags & 1) != 0) {
pos.edge = true;
}
a++;
count = count2;
} else {
return;
}
}
} else {
averageAspectRatio = averageAspectRatio5;
maxAspectRatio = maxAspectRatio4;
paddingsWidth = paddingsWidth7;
}
} else {
averageAspectRatio = averageAspectRatio5;
maxAspectRatio = maxAspectRatio4;
paddingsWidth = paddingsWidth7;
}
float[] croppedRatios = new float[this.posArray.size()];
for (int a3 = 0; a3 < count4; a3++) {
if (averageAspectRatio > 1.1f) {
croppedRatios[a3] = Math.max(1.0f, this.posArray.get(a3).aspectRatio);
} else {
croppedRatios[a3] = Math.min(1.0f, this.posArray.get(a3).aspectRatio);
}
croppedRatios[a3] = Math.max(0.66667f, Math.min(1.7f, croppedRatios[a3]));
}
ArrayList<MessageGroupedLayoutAttempt> attempts = new ArrayList<>();
int firstLine = 1;
while (firstLine < croppedRatios.length) {
int secondLine = croppedRatios.length - firstLine;
if (firstLine <= 3) {
if (secondLine <= 3) {
float averageAspectRatio7 = multiHeight(croppedRatios, 0, firstLine);
paddingsWidth4 = paddingsWidth;
averageAspectRatio2 = averageAspectRatio;
attempts.add(new MessageGroupedLayoutAttempt(firstLine, secondLine, averageAspectRatio7, multiHeight(croppedRatios, firstLine, croppedRatios.length)));
} else {
paddingsWidth4 = paddingsWidth;
averageAspectRatio2 = averageAspectRatio;
}
} else {
paddingsWidth4 = paddingsWidth;
averageAspectRatio2 = averageAspectRatio;
}
firstLine++;
averageAspectRatio = averageAspectRatio2;
paddingsWidth = paddingsWidth4;
}
int secondLine2 = paddingsWidth;
float averageAspectRatio8 = averageAspectRatio;
int firstLine2 = 1;
while (firstLine2 < croppedRatios.length - 1) {
int secondLine3 = 1;
while (secondLine3 < croppedRatios.length - firstLine2) {
int thirdLine2 = (croppedRatios.length - firstLine2) - secondLine3;
if (firstLine2 <= 3) {
if (secondLine3 <= (averageAspectRatio8 < 0.85f ? 4 : 3)) {
if (thirdLine2 > 3) {
minWidth3 = minWidth7;
maxAspectRatio2 = maxAspectRatio;
paddingsWidth2 = secondLine2;
paddingsWidth3 = secondLine3;
} else {
minWidth3 = minWidth7;
maxAspectRatio2 = maxAspectRatio;
paddingsWidth2 = secondLine2;
paddingsWidth3 = secondLine3;
attempts.add(new MessageGroupedLayoutAttempt(firstLine2, secondLine3, thirdLine2, multiHeight(croppedRatios, 0, firstLine2), multiHeight(croppedRatios, firstLine2, firstLine2 + secondLine3), multiHeight(croppedRatios, firstLine2 + secondLine3, croppedRatios.length)));
}
secondLine3 = paddingsWidth3 + 1;
maxAspectRatio = maxAspectRatio2;
secondLine2 = paddingsWidth2;
minWidth7 = minWidth3;
}
}
minWidth3 = minWidth7;
maxAspectRatio2 = maxAspectRatio;
paddingsWidth2 = secondLine2;
paddingsWidth3 = secondLine3;
secondLine3 = paddingsWidth3 + 1;
maxAspectRatio = maxAspectRatio2;
secondLine2 = paddingsWidth2;
minWidth7 = minWidth3;
}
firstLine2++;
secondLine2 = secondLine2;
}
int secondLine4 = minWidth7;
int firstLine3 = 1;
while (firstLine3 < croppedRatios.length - 2) {
int secondLine5 = 1;
while (secondLine5 < croppedRatios.length - firstLine3) {
int thirdLine3 = 1;
while (thirdLine3 < (croppedRatios.length - firstLine3) - secondLine5) {
int fourthLine = ((croppedRatios.length - firstLine3) - secondLine5) - thirdLine3;
if (firstLine3 > 3 || secondLine5 > 3 || thirdLine3 > 3) {
thirdLine = thirdLine3;
minHeight = minHeight2;
count3 = count4;
maxSizeHeight = minWidth6;
minWidth = secondLine4;
minWidth2 = secondLine5;
} else if (fourthLine > 3) {
thirdLine = thirdLine3;
minHeight = minHeight2;
count3 = count4;
maxSizeHeight = minWidth6;
minWidth = secondLine4;
minWidth2 = secondLine5;
} else {
float multiHeight = multiHeight(croppedRatios, 0, firstLine3);
float maxSizeHeight2 = multiHeight(croppedRatios, firstLine3, firstLine3 + secondLine5);
count3 = count4;
thirdLine = thirdLine3;
maxSizeHeight = minWidth6;
minWidth = secondLine4;
minWidth2 = secondLine5;
minHeight = minHeight2;
attempts.add(new MessageGroupedLayoutAttempt(firstLine3, secondLine5, thirdLine3, fourthLine, multiHeight, maxSizeHeight2, multiHeight(croppedRatios, firstLine3 + secondLine5, firstLine3 + secondLine5 + thirdLine3), multiHeight(croppedRatios, firstLine3 + secondLine5 + thirdLine3, croppedRatios.length)));
}
thirdLine3 = thirdLine + 1;
minHeight2 = minHeight;
secondLine5 = minWidth2;
count4 = count3;
secondLine4 = minWidth;
minWidth6 = maxSizeHeight;
}
float maxSizeHeight3 = minWidth6;
int minWidth8 = secondLine4;
int minWidth9 = secondLine5;
secondLine5 = minWidth9 + 1;
secondLine4 = minWidth8;
minWidth6 = maxSizeHeight3;
}
float maxSizeHeight4 = minWidth6;
int minWidth10 = secondLine4;
firstLine3++;
secondLine4 = minWidth10;
minWidth6 = maxSizeHeight4;
}
count = count4;
float maxSizeHeight5 = minWidth6;
int minWidth11 = secondLine4;
MessageGroupedLayoutAttempt optimal = null;
float optimalDiff = 0.0f;
float maxHeight = (this.maxSizeWidth / 3) * 4;
for (int a4 = 0; a4 < attempts.size(); a4++) {
MessageGroupedLayoutAttempt attempt = attempts.get(a4);
float height4 = 0.0f;
float minLineHeight = Float.MAX_VALUE;
for (int b = 0; b < attempt.heights.length; b++) {
height4 += attempt.heights[b];
if (attempt.heights[b] < minLineHeight) {
minLineHeight = attempt.heights[b];
}
}
float diff2 = Math.abs(height4 - maxHeight);
if (attempt.lineCounts.length > 1) {
if (attempt.lineCounts[0] <= attempt.lineCounts[1]) {
if (attempt.lineCounts.length > 2) {
if (attempt.lineCounts[1] > attempt.lineCounts[2]) {
}
}
if (attempt.lineCounts.length > 3) {
}
}
diff2 *= 1.2f;
}
if (minLineHeight < minWidth11) {
diff2 *= 1.5f;
}
if (optimal == null || diff2 < optimalDiff) {
optimal = attempt;
optimalDiff = diff2;
}
}
if (optimal == null) {
return;
}
int index = 0;
float y = 0.0f;
int i2 = 0;
while (i2 < optimal.lineCounts.length) {
int c = optimal.lineCounts[i2];
float lineHeight = optimal.heights[i2];
int spanLeft = this.maxSizeWidth;
MessageObject.GroupedMessagePosition posToFix = null;
int k = 0;
while (k < c) {
float ratio = croppedRatios[index];
float optimalDiff2 = optimalDiff;
float optimalDiff3 = ratio * lineHeight;
int width3 = (int) optimalDiff3;
int spanLeft2 = spanLeft - width3;
float maxHeight2 = maxHeight;
MessageObject.GroupedMessagePosition pos2 = this.posArray.get(index);
int flags = 0;
if (i2 == 0) {
flags = 0 | 4;
}
if (i2 == optimal.lineCounts.length - 1) {
flags |= 8;
}
if (k == 0) {
flags |= 1;
}
if (k == c - 1) {
flags |= 2;
posToFix = pos2;
}
pos2.set(k, k, i2, i2, width3, lineHeight / maxSizeHeight5, flags);
index++;
k++;
optimalDiff = optimalDiff2;
maxHeight = maxHeight2;
spanLeft = spanLeft2;
}
posToFix.pw += spanLeft;
posToFix.spanSize += spanLeft;
y += lineHeight;
i2++;
optimalDiff = optimalDiff;
}
a = 0;
while (true) {
count2 = count;
if (a >= count2) {
}
a++;
count = count2;
}
}
}
public BlockCollageCell(Context context, WebpageAdapter adapter) {
super(context);
this.group = new GroupedMessages();
this.parentAdapter = adapter;
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 outRect, View view, RecyclerView parent, RecyclerView.State state) {
MessageObject.GroupedMessagePosition position;
outRect.bottom = 0;
if (!(view instanceof BlockPhotoCell)) {
if (view instanceof BlockVideoCell) {
position = BlockCollageCell.this.group.positions.get(((BlockVideoCell) view).currentBlock);
} else {
position = null;
}
} else {
position = BlockCollageCell.this.group.positions.get(((BlockPhotoCell) view).currentBlock);
}
if (position != null && position.siblingHeights != null) {
float maxHeight = Math.max(AndroidUtilities.displaySize.x, AndroidUtilities.displaySize.y) * 0.5f;
int h = 0;
for (int a = 0; a < position.siblingHeights.length; a++) {
h += (int) Math.ceil(position.siblingHeights[a] * maxHeight);
}
int a2 = position.maxY;
int h2 = h + ((a2 - position.minY) * AndroidUtilities.dp2(11.0f));
int count = BlockCollageCell.this.group.posArray.size();
int a3 = 0;
while (true) {
if (a3 >= count) {
break;
}
MessageObject.GroupedMessagePosition pos = BlockCollageCell.this.group.posArray.get(a3);
if (pos.minY != position.minY || ((pos.minX == position.minX && pos.maxX == position.maxX && pos.minY == position.minY && pos.maxY == position.maxY) || pos.minY != position.minY)) {
a3++;
} else {
h2 -= ((int) Math.ceil(pos.ph * maxHeight)) - AndroidUtilities.dp(4.0f);
break;
}
}
int a4 = -h2;
outRect.bottom = a4;
}
}
});
GridLayoutManagerFixed gridLayoutManagerFixed = new GridLayoutManagerFixed(context, 1000, 1, true) {
@Override
public boolean supportsPredictiveItemAnimations() {
return false;
}
@Override
public boolean shouldLayoutChildFromOpositeSide(View child) {
return false;
}
@Override
protected boolean hasSiblingChild(int position) {
TLObject message = BlockCollageCell.this.currentBlock.items.get((BlockCollageCell.this.currentBlock.items.size() - position) - 1);
MessageObject.GroupedMessagePosition pos = BlockCollageCell.this.group.positions.get(message);
if (pos.minX == pos.maxX || pos.minY != pos.maxY || pos.minY == 0) {
return false;
}
int count = BlockCollageCell.this.group.posArray.size();
for (int a = 0; a < count; a++) {
MessageObject.GroupedMessagePosition p = BlockCollageCell.this.group.posArray.get(a);
if (p != pos && p.minY <= pos.minY && p.maxY >= pos.minY) {
return true;
}
}
return false;
}
};
this.gridLayoutManager = gridLayoutManagerFixed;
gridLayoutManagerFixed.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
@Override
public int getSpanSize(int position) {
TLObject message = BlockCollageCell.this.currentBlock.items.get((BlockCollageCell.this.currentBlock.items.size() - position) - 1);
return BlockCollageCell.this.group.positions.get(message).spanSize;
}
});
this.innerListView.setLayoutManager(this.gridLayoutManager);
RecyclerListView recyclerListView2 = this.innerListView;
RecyclerView.Adapter adapter2 = new RecyclerView.Adapter() {
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view;
switch (viewType) {
case 0:
view = new BlockPhotoCell(BlockCollageCell.this.getContext(), BlockCollageCell.this.parentAdapter, 2);
break;
default:
view = new BlockVideoCell(BlockCollageCell.this.getContext(), BlockCollageCell.this.parentAdapter, 2);
break;
}
return new RecyclerListView.Holder(view);
}
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
TLRPC.PageBlock pageBlock = BlockCollageCell.this.currentBlock.items.get((BlockCollageCell.this.currentBlock.items.size() - position) - 1);
switch (holder.getItemViewType()) {
case 0:
BlockPhotoCell cell = (BlockPhotoCell) holder.itemView;
cell.groupPosition = BlockCollageCell.this.group.positions.get(pageBlock);
cell.setBlock((TLRPC.TL_pageBlockPhoto) pageBlock, true, true);
return;
default:
BlockVideoCell cell2 = (BlockVideoCell) holder.itemView;
cell2.groupPosition = BlockCollageCell.this.group.positions.get(pageBlock);
cell2.setBlock((TLRPC.TL_pageBlockVideo) pageBlock, true, true);
return;
}
}
@Override
public int getItemCount() {
if (BlockCollageCell.this.currentBlock != null) {
return BlockCollageCell.this.currentBlock.items.size();
}
return 0;
}
@Override
public int getItemViewType(int position) {
TLRPC.PageBlock block = BlockCollageCell.this.currentBlock.items.get((BlockCollageCell.this.currentBlock.items.size() - position) - 1);
return block instanceof TLRPC.TL_pageBlockPhoto ? 0 : 1;
}
};
this.innerAdapter = adapter2;
recyclerListView2.setAdapter(adapter2);
addView(this.innerListView, LayoutHelper.createFrame(-1, -2.0f));
setWillNotDraw(false);
}
public void setBlock(TLRPC.TL_pageBlockCollage block) {
if (this.currentBlock != block) {
this.currentBlock = block;
this.group.calculate();
}
this.innerAdapter.notifyDataSetChanged();
int color = ArticleViewer.this.getSelectedColor();
if (color == 0) {
this.innerListView.setGlowColor(-657673);
} else if (color == 1) {
this.innerListView.setGlowColor(-659492);
} else if (color == 2) {
this.innerListView.setGlowColor(-15461356);
}
requestLayout();
}
@Override
public boolean onTouchEvent(MotionEvent event) {
return ArticleViewer.this.checkLayoutForLinks(event, this, this.captionLayout, this.textX, this.textY) || ArticleViewer.this.checkLayoutForLinks(event, this, this.creditLayout, this.textX, this.textY + this.creditOffset) || super.onTouchEvent(event);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int height;
int textWidth;
int listWidth;
int height2;
this.inLayout = true;
int width = View.MeasureSpec.getSize(widthMeasureSpec);
TLRPC.TL_pageBlockCollage tL_pageBlockCollage = this.currentBlock;
if (tL_pageBlockCollage != null) {
if (tL_pageBlockCollage.level > 0) {
int dp = AndroidUtilities.dp(this.currentBlock.level * 14) + AndroidUtilities.dp(18.0f);
this.listX = dp;
this.textX = dp;
int listWidth2 = width - (dp + AndroidUtilities.dp(18.0f));
textWidth = listWidth2;
listWidth = listWidth2;
} else {
this.listX = 0;
this.textX = AndroidUtilities.dp(18.0f);
textWidth = width - AndroidUtilities.dp(36.0f);
listWidth = width;
}
this.innerListView.measure(View.MeasureSpec.makeMeasureSpec(listWidth, 1073741824), View.MeasureSpec.makeMeasureSpec(0, 0));
int height3 = this.innerListView.getMeasuredHeight();
DrawingText createLayoutForText = ArticleViewer.this.createLayoutForText(this, null, this.currentBlock.caption.text, textWidth, this.currentBlock, this.parentAdapter);
this.captionLayout = createLayoutForText;
if (createLayoutForText != null) {
this.textY = AndroidUtilities.dp(8.0f) + height3;
int dp2 = AndroidUtilities.dp(4.0f) + this.captionLayout.getHeight();
this.creditOffset = dp2;
height2 = height3 + dp2 + AndroidUtilities.dp(4.0f);
} else {
height2 = height3;
}
DrawingText createLayoutForText2 = ArticleViewer.this.createLayoutForText(this, (CharSequence) null, this.currentBlock.caption.credit, textWidth, this.currentBlock, ArticleViewer.this.isRtl ? StaticLayoutEx.ALIGN_RIGHT() : Layout.Alignment.ALIGN_NORMAL, this.parentAdapter);
this.creditLayout = createLayoutForText2;
if (createLayoutForText2 != null) {
height2 += AndroidUtilities.dp(4.0f) + this.creditLayout.getHeight();
}
height = height2 + AndroidUtilities.dp(16.0f);
if (this.currentBlock.level > 0 && !this.currentBlock.bottom) {
height += AndroidUtilities.dp(8.0f);
}
} else {
height = 1;
}
setMeasuredDimension(width, height);
this.inLayout = false;
}
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
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 adapter) {
super(context);
this.textX = AndroidUtilities.dp(18.0f);
this.parentAdapter = adapter;
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 ev) {
return super.onTouchEvent(ev);
}
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
ArticleViewer.this.windowView.requestDisallowInterceptTouchEvent(true);
return super.onInterceptTouchEvent(ev);
}
};
this.innerListView = viewPager;
viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
float width = BlockSlideshowCell.this.innerListView.getMeasuredWidth();
if (width == 0.0f) {
return;
}
BlockSlideshowCell.this.pageOffset = (((position * width) + positionOffsetPixels) - (r1.currentPage * width)) / width;
BlockSlideshowCell.this.dotsContainer.invalidate();
}
@Override
public void onPageSelected(int position) {
BlockSlideshowCell.this.currentPage = position;
BlockSlideshowCell.this.dotsContainer.invalidate();
}
@Override
public void onPageScrollStateChanged(int state) {
}
});
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 BlockSlideshowCell.this.currentBlock.items.size();
}
return 0;
}
@Override
public boolean isViewFromObject(View view, Object object) {
return ((ObjectContainer) object).view == view;
}
@Override
public int getItemPosition(Object object) {
ObjectContainer objectContainer = (ObjectContainer) object;
if (BlockSlideshowCell.this.currentBlock.items.contains(objectContainer.block)) {
return -1;
}
return -2;
}
@Override
public Object instantiateItem(ViewGroup container, int position) {
View view;
TLRPC.PageBlock block = BlockSlideshowCell.this.currentBlock.items.get(position);
if (block instanceof TLRPC.TL_pageBlockPhoto) {
view = new BlockPhotoCell(BlockSlideshowCell.this.getContext(), BlockSlideshowCell.this.parentAdapter, 1);
((BlockPhotoCell) view).setBlock((TLRPC.TL_pageBlockPhoto) block, true, true);
} else {
view = new BlockVideoCell(BlockSlideshowCell.this.getContext(), BlockSlideshowCell.this.parentAdapter, 1);
((BlockVideoCell) view).setBlock((TLRPC.TL_pageBlockVideo) block, true, true);
}
container.addView(view);
ObjectContainer objectContainer = new ObjectContainer();
objectContainer.view = view;
objectContainer.block = block;
return objectContainer;
}
@Override
public void destroyItem(ViewGroup container, int position, Object object) {
container.removeView(((ObjectContainer) object).view);
}
@Override
public void unregisterDataSetObserver(DataSetObserver observer) {
if (observer != null) {
super.unregisterDataSetObserver(observer);
}
}
};
this.innerAdapter = pagerAdapter;
viewPager2.setAdapter(pagerAdapter);
int color = ArticleViewer.this.getSelectedColor();
if (color == 0) {
AndroidUtilities.setViewPagerEdgeEffectColor(this.innerListView, -657673);
} else if (color == 1) {
AndroidUtilities.setViewPagerEdgeEffectColor(this.innerListView, -659492);
} else if (color == 2) {
AndroidUtilities.setViewPagerEdgeEffectColor(this.innerListView, -15461356);
}
addView(this.innerListView);
View view = new View(context) {
@Override
protected void onDraw(Canvas canvas) {
int xOffset;
if (BlockSlideshowCell.this.currentBlock != null) {
int count = BlockSlideshowCell.this.innerAdapter.getCount();
int totalWidth = (AndroidUtilities.dp(7.0f) * count) + ((count - 1) * AndroidUtilities.dp(6.0f)) + AndroidUtilities.dp(4.0f);
if (totalWidth < getMeasuredWidth()) {
xOffset = (getMeasuredWidth() - totalWidth) / 2;
} else {
xOffset = AndroidUtilities.dp(4.0f);
int size = AndroidUtilities.dp(13.0f);
int halfCount = ((getMeasuredWidth() - AndroidUtilities.dp(8.0f)) / 2) / size;
if (BlockSlideshowCell.this.currentPage != (count - halfCount) - 1 || BlockSlideshowCell.this.pageOffset >= 0.0f) {
if (BlockSlideshowCell.this.currentPage < (count - halfCount) - 1) {
if (BlockSlideshowCell.this.currentPage > halfCount) {
xOffset -= ((int) (BlockSlideshowCell.this.pageOffset * size)) + ((BlockSlideshowCell.this.currentPage - halfCount) * size);
} else if (BlockSlideshowCell.this.currentPage == halfCount && BlockSlideshowCell.this.pageOffset > 0.0f) {
xOffset -= (int) (BlockSlideshowCell.this.pageOffset * size);
}
} else {
xOffset -= ((count - (halfCount * 2)) - 1) * size;
}
} else {
xOffset -= ((int) (BlockSlideshowCell.this.pageOffset * size)) + (((count - (halfCount * 2)) - 1) * size);
}
}
int a = 0;
while (a < BlockSlideshowCell.this.currentBlock.items.size()) {
int cx = AndroidUtilities.dp(4.0f) + xOffset + (AndroidUtilities.dp(13.0f) * a);
Drawable drawable = BlockSlideshowCell.this.currentPage == a ? ArticleViewer.this.slideDotBigDrawable : ArticleViewer.this.slideDotDrawable;
drawable.setBounds(cx - AndroidUtilities.dp(5.0f), 0, AndroidUtilities.dp(5.0f) + cx, AndroidUtilities.dp(10.0f));
drawable.draw(canvas);
a++;
}
}
}
};
this.dotsContainer = view;
addView(view);
setWillNotDraw(false);
}
public void setBlock(TLRPC.TL_pageBlockSlideshow block) {
this.currentBlock = block;
this.innerAdapter.notifyDataSetChanged();
this.innerListView.setCurrentItem(0, false);
this.innerListView.forceLayout();
requestLayout();
}
@Override
public boolean onTouchEvent(MotionEvent event) {
return ArticleViewer.this.checkLayoutForLinks(event, this, this.captionLayout, this.textX, this.textY) || ArticleViewer.this.checkLayoutForLinks(event, this, this.creditLayout, this.textX, this.textY + this.creditOffset) || super.onTouchEvent(event);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int height;
int height2;
int width = View.MeasureSpec.getSize(widthMeasureSpec);
if (this.currentBlock != null) {
int height3 = AndroidUtilities.dp(310.0f);
this.innerListView.measure(View.MeasureSpec.makeMeasureSpec(width, 1073741824), View.MeasureSpec.makeMeasureSpec(height3, 1073741824));
this.currentBlock.items.size();
this.dotsContainer.measure(View.MeasureSpec.makeMeasureSpec(width, 1073741824), View.MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(10.0f), 1073741824));
int textWidth = width - AndroidUtilities.dp(36.0f);
this.textY = AndroidUtilities.dp(16.0f) + height3;
DrawingText createLayoutForText = ArticleViewer.this.createLayoutForText(this, null, this.currentBlock.caption.text, textWidth, this.currentBlock, this.parentAdapter);
this.captionLayout = createLayoutForText;
if (createLayoutForText != null) {
int dp = AndroidUtilities.dp(4.0f) + this.captionLayout.getHeight();
this.creditOffset = dp;
height2 = height3 + dp + AndroidUtilities.dp(4.0f);
} else {
height2 = height3;
}
DrawingText createLayoutForText2 = ArticleViewer.this.createLayoutForText(this, (CharSequence) null, this.currentBlock.caption.credit, textWidth, this.currentBlock, ArticleViewer.this.isRtl ? StaticLayoutEx.ALIGN_RIGHT() : Layout.Alignment.ALIGN_NORMAL, this.parentAdapter);
this.creditLayout = createLayoutForText2;
if (createLayoutForText2 != null) {
height2 += AndroidUtilities.dp(4.0f) + this.creditLayout.getHeight();
}
height = height2 + AndroidUtilities.dp(16.0f);
} else {
height = 1;
}
setMeasuredDimension(width, height);
}
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
this.innerListView.layout(0, AndroidUtilities.dp(8.0f), this.innerListView.getMeasuredWidth(), AndroidUtilities.dp(8.0f) + this.innerListView.getMeasuredHeight());
int y = this.innerListView.getBottom() - AndroidUtilities.dp(23.0f);
View view = this.dotsContainer;
view.layout(0, y, view.getMeasuredWidth(), this.dotsContainer.getMeasuredHeight() + y);
}
@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 adapter) {
super(context);
this.parentAdapter = adapter;
setWillNotDraw(false);
}
public void setBlock(TL_pageBlockListItem block) {
if (this.currentBlock != block) {
this.currentBlock = block;
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 event) {
if (ArticleViewer.this.checkLayoutForLinks(event, this, this.textLayout, this.textX, this.textY)) {
return true;
}
return super.onTouchEvent(event);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int maxWidth;
int width = View.MeasureSpec.getSize(widthMeasureSpec);
int height = 0;
TL_pageBlockListItem tL_pageBlockListItem = this.currentBlock;
if (tL_pageBlockListItem != null) {
this.textLayout = null;
this.textY = (tL_pageBlockListItem.index == 0 && this.currentBlock.parent.level == 0) ? AndroidUtilities.dp(10.0f) : 0;
this.numOffsetY = 0;
if (this.currentBlock.parent.lastMaxNumCalcWidth != width || this.currentBlock.parent.lastFontSize != ArticleViewer.this.selectedFontSize) {
this.currentBlock.parent.lastMaxNumCalcWidth = width;
this.currentBlock.parent.lastFontSize = ArticleViewer.this.selectedFontSize;
this.currentBlock.parent.maxNumWidth = 0;
int size = this.currentBlock.parent.items.size();
for (int a = 0; a < size; a++) {
TL_pageBlockListItem item = (TL_pageBlockListItem) this.currentBlock.parent.items.get(a);
if (item.num != null) {
item.numLayout = ArticleViewer.this.createLayoutForText(this, item.num, null, width - AndroidUtilities.dp(54.0f), this.currentBlock, this.parentAdapter);
this.currentBlock.parent.maxNumWidth = Math.max(this.currentBlock.parent.maxNumWidth, (int) Math.ceil(item.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(18.0f);
} else {
this.textX = AndroidUtilities.dp(24.0f) + this.currentBlock.parent.maxNumWidth + (this.currentBlock.parent.level * AndroidUtilities.dp(12.0f));
}
int maxWidth2 = (width - AndroidUtilities.dp(18.0f)) - this.textX;
if (ArticleViewer.this.isRtl) {
maxWidth = maxWidth2 - ((AndroidUtilities.dp(6.0f) + this.currentBlock.parent.maxNumWidth) + (this.currentBlock.parent.level * AndroidUtilities.dp(12.0f)));
} else {
maxWidth = maxWidth2;
}
if (this.currentBlock.textItem != null) {
DrawingText createLayoutForText = ArticleViewer.this.createLayoutForText(this, (CharSequence) null, this.currentBlock.textItem, maxWidth, 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) {
int ascent = this.textLayout.getLineAscent(0);
this.numOffsetY = (this.currentBlock.numLayout.getLineAscent(0) + AndroidUtilities.dp(2.5f)) - ascent;
}
height = 0 + this.textLayout.getHeight() + AndroidUtilities.dp(8.0f);
}
} 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);
}
maxWidth += AndroidUtilities.dp(18.0f);
height = 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);
}
maxWidth += AndroidUtilities.dp(18.0f);
} else if (ArticleViewer.this.isListItemBlock(this.currentBlock.blockItem)) {
this.blockX = 0;
this.blockY = 0;
this.textY = 0;
if (this.currentBlock.index == 0 && this.currentBlock.parent.level == 0) {
height = 0 - AndroidUtilities.dp(10.0f);
}
maxWidth = width;
height -= AndroidUtilities.dp(8.0f);
} else if (this.blockLayout.itemView instanceof BlockTableCell) {
this.blockX -= AndroidUtilities.dp(18.0f);
maxWidth += AndroidUtilities.dp(36.0f);
}
this.blockLayout.itemView.measure(View.MeasureSpec.makeMeasureSpec(maxWidth, 1073741824), View.MeasureSpec.makeMeasureSpec(0, 0));
if ((this.blockLayout.itemView instanceof BlockParagraphCell) && this.currentBlock.numLayout != null && this.currentBlock.numLayout.getLineCount() > 0) {
BlockParagraphCell paragraphCell = (BlockParagraphCell) this.blockLayout.itemView;
if (paragraphCell.textLayout != null && paragraphCell.textLayout.getLineCount() > 0) {
int ascent2 = paragraphCell.textLayout.getLineAscent(0);
this.numOffsetY = (this.currentBlock.numLayout.getLineAscent(0) + AndroidUtilities.dp(2.5f)) - ascent2;
}
}
if (this.currentBlock.blockItem instanceof TLRPC.TL_pageBlockDetails) {
this.verticalAlign = true;
this.blockY = 0;
if (this.currentBlock.index == 0 && this.currentBlock.parent.level == 0) {
height -= AndroidUtilities.dp(10.0f);
}
height -= AndroidUtilities.dp(8.0f);
} else if (this.blockLayout.itemView instanceof BlockOrderedListItemCell) {
this.verticalAlign = ((BlockOrderedListItemCell) this.blockLayout.itemView).verticalAlign;
} else if (this.blockLayout.itemView instanceof BlockListItemCell) {
this.verticalAlign = ((BlockListItemCell) this.blockLayout.itemView).verticalAlign;
}
if (this.verticalAlign && this.currentBlock.numLayout != null) {
this.textY = ((this.blockLayout.itemView.getMeasuredHeight() - this.currentBlock.numLayout.getHeight()) / 2) - AndroidUtilities.dp(4.0f);
this.drawDot = false;
}
height += this.blockLayout.itemView.getMeasuredHeight();
}
height += AndroidUtilities.dp(8.0f);
}
if (this.currentBlock.parent.items.get(this.currentBlock.parent.items.size() - 1) == this.currentBlock) {
height += AndroidUtilities.dp(8.0f);
}
if (this.currentBlock.index == 0 && this.currentBlock.parent.level == 0) {
height += AndroidUtilities.dp(10.0f);
}
} else {
height = 1;
}
setMeasuredDimension(width, height);
}
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
RecyclerView.ViewHolder viewHolder = this.blockLayout;
if (viewHolder != null) {
View view = viewHolder.itemView;
int i = this.blockX;
view.layout(i, this.blockY, this.blockLayout.itemView.getMeasuredWidth() + i, this.blockY + this.blockLayout.itemView.getMeasuredHeight());
}
}
@Override
protected void onDraw(Canvas canvas) {
if (this.currentBlock == null) {
return;
}
int width = getMeasuredWidth();
if (this.currentBlock.numLayout != null) {
canvas.save();
if (ArticleViewer.this.isRtl) {
canvas.translate(((width - 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 info) {
super.onInitializeAccessibilityNodeInfo(info);
info.setEnabled(true);
DrawingText drawingText = this.textLayout;
if (drawingText == null) {
return;
}
info.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 adapter) {
super(context);
this.parentAdapter = adapter;
setWillNotDraw(false);
}
public void setBlock(TL_pageBlockOrderedListItem block) {
if (this.currentBlock != block) {
this.currentBlock = block;
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 event) {
if (ArticleViewer.this.checkLayoutForLinks(event, this, this.textLayout, this.textX, this.textY)) {
return true;
}
return super.onTouchEvent(event);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int maxWidth;
int width = View.MeasureSpec.getSize(widthMeasureSpec);
int height = 0;
TL_pageBlockOrderedListItem tL_pageBlockOrderedListItem = this.currentBlock;
if (tL_pageBlockOrderedListItem != null) {
this.textLayout = null;
this.textY = (tL_pageBlockOrderedListItem.index == 0 && this.currentBlock.parent.level == 0) ? AndroidUtilities.dp(10.0f) : 0;
this.numOffsetY = 0;
if (this.currentBlock.parent.lastMaxNumCalcWidth != width || this.currentBlock.parent.lastFontSize != ArticleViewer.this.selectedFontSize) {
this.currentBlock.parent.lastMaxNumCalcWidth = width;
this.currentBlock.parent.lastFontSize = ArticleViewer.this.selectedFontSize;
this.currentBlock.parent.maxNumWidth = 0;
int size = this.currentBlock.parent.items.size();
for (int a = 0; a < size; a++) {
TL_pageBlockOrderedListItem item = (TL_pageBlockOrderedListItem) this.currentBlock.parent.items.get(a);
if (item.num != null) {
item.numLayout = ArticleViewer.this.createLayoutForText(this, item.num, null, width - AndroidUtilities.dp(54.0f), this.currentBlock, this.parentAdapter);
this.currentBlock.parent.maxNumWidth = Math.max(this.currentBlock.parent.maxNumWidth, (int) Math.ceil(item.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(18.0f);
} else {
this.textX = AndroidUtilities.dp(24.0f) + this.currentBlock.parent.maxNumWidth + (this.currentBlock.parent.level * AndroidUtilities.dp(20.0f));
}
this.verticalAlign = false;
int maxWidth2 = (width - AndroidUtilities.dp(18.0f)) - this.textX;
if (ArticleViewer.this.isRtl) {
maxWidth = maxWidth2 - ((AndroidUtilities.dp(6.0f) + this.currentBlock.parent.maxNumWidth) + (this.currentBlock.parent.level * AndroidUtilities.dp(20.0f)));
} else {
maxWidth = maxWidth2;
}
if (this.currentBlock.textItem != null) {
DrawingText createLayoutForText = ArticleViewer.this.createLayoutForText(this, (CharSequence) null, this.currentBlock.textItem, maxWidth, 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) {
int ascent = this.textLayout.getLineAscent(0);
this.numOffsetY = this.currentBlock.numLayout.getLineAscent(0) - ascent;
}
height = 0 + this.textLayout.getHeight() + AndroidUtilities.dp(8.0f);
}
} 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);
}
maxWidth += AndroidUtilities.dp(18.0f);
height = 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);
}
maxWidth += AndroidUtilities.dp(18.0f);
} else if (ArticleViewer.this.isListItemBlock(this.currentBlock.blockItem)) {
this.blockX = 0;
this.blockY = 0;
this.textY = 0;
maxWidth = width;
height = 0 - AndroidUtilities.dp(8.0f);
} else if (this.blockLayout.itemView instanceof BlockTableCell) {
this.blockX -= AndroidUtilities.dp(18.0f);
maxWidth += AndroidUtilities.dp(36.0f);
}
this.blockLayout.itemView.measure(View.MeasureSpec.makeMeasureSpec(maxWidth, 1073741824), View.MeasureSpec.makeMeasureSpec(0, 0));
if ((this.blockLayout.itemView instanceof BlockParagraphCell) && this.currentBlock.numLayout != null && this.currentBlock.numLayout.getLineCount() > 0) {
BlockParagraphCell paragraphCell = (BlockParagraphCell) this.blockLayout.itemView;
if (paragraphCell.textLayout != null && paragraphCell.textLayout.getLineCount() > 0) {
int ascent2 = paragraphCell.textLayout.getLineAscent(0);
this.numOffsetY = this.currentBlock.numLayout.getLineAscent(0) - ascent2;
}
}
if (this.currentBlock.blockItem instanceof TLRPC.TL_pageBlockDetails) {
this.verticalAlign = true;
this.blockY = 0;
height -= 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;
}
height += this.blockLayout.itemView.getMeasuredHeight();
}
height += AndroidUtilities.dp(8.0f);
}
if (this.currentBlock.parent.items.get(this.currentBlock.parent.items.size() - 1) == this.currentBlock) {
height += AndroidUtilities.dp(8.0f);
}
if (this.currentBlock.index == 0 && this.currentBlock.parent.level == 0) {
height += AndroidUtilities.dp(10.0f);
}
} else {
height = 1;
}
setMeasuredDimension(width, height);
}
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
RecyclerView.ViewHolder viewHolder = this.blockLayout;
if (viewHolder != null) {
View view = viewHolder.itemView;
int i = this.blockX;
view.layout(i, this.blockY, this.blockLayout.itemView.getMeasuredWidth() + i, this.blockY + this.blockLayout.itemView.getMeasuredHeight());
}
}
@Override
protected void onDraw(Canvas canvas) {
if (this.currentBlock == null) {
return;
}
int width = getMeasuredWidth();
if (this.currentBlock.numLayout != null) {
canvas.save();
if (ArticleViewer.this.isRtl) {
canvas.translate(((width - 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 info) {
super.onInitializeAccessibilityNodeInfo(info);
info.setEnabled(true);
DrawingText drawingText = this.textLayout;
if (drawingText == null) {
return;
}
info.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;
public BlockDetailsCell(Context context, WebpageAdapter adapter) {
super(context);
this.textX = AndroidUtilities.dp(50.0f);
this.textY = AndroidUtilities.dp(11.0f) + 1;
this.parentAdapter = adapter;
this.arrow = new AnimatedArrowDrawable(ArticleViewer.this.getGrayTextColor(), true);
}
@Override
public void invalidateDrawable(Drawable drawable) {
invalidate();
}
@Override
public void scheduleDrawable(Drawable drawable, Runnable runnable, long l) {
}
@Override
public void unscheduleDrawable(Drawable drawable, Runnable runnable) {
}
public void setBlock(TLRPC.TL_pageBlockDetails block) {
this.currentBlock = block;
this.arrow.setAnimationProgress(block.open ? 0.0f : 1.0f);
this.arrow.setCallback(this);
requestLayout();
}
@Override
public boolean onTouchEvent(MotionEvent event) {
return ArticleViewer.this.checkLayoutForLinks(event, this, this.textLayout, this.textX, this.textY) || super.onTouchEvent(event);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int width = View.MeasureSpec.getSize(widthMeasureSpec);
int h = 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, width - AndroidUtilities.dp(52.0f), this.currentBlock, ArticleViewer.this.isRtl ? StaticLayoutEx.ALIGN_RIGHT() : Layout.Alignment.ALIGN_NORMAL, this.parentAdapter);
this.textLayout = createLayoutForText;
if (createLayoutForText != null) {
h = Math.max(h, AndroidUtilities.dp(21.0f) + this.textLayout.getHeight());
this.textY = ((this.textLayout.getHeight() + AndroidUtilities.dp(21.0f)) - this.textLayout.getHeight()) / 2;
}
}
setMeasuredDimension(width, h + 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();
}
int y = getMeasuredHeight() - 1;
canvas.drawLine(0.0f, y, getMeasuredWidth(), y, 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 widthMeasureSpec, int heightMeasureSpec) {
setMeasuredDimension(View.MeasureSpec.getSize(widthMeasureSpec), 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);
Drawable drawable = Theme.getThemedDrawable(context, R.drawable.greydivider_bottom, -16777216);
CombinedDrawable combinedDrawable = new CombinedDrawable(new ColorDrawable(-986896), drawable);
this.shadowDrawable = combinedDrawable;
combinedDrawable.setFullsize(true);
setBackgroundDrawable(this.shadowDrawable);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
setMeasuredDimension(View.MeasureSpec.getSize(widthMeasureSpec), AndroidUtilities.dp(12.0f));
int color = ArticleViewer.this.getSelectedColor();
if (color == 0) {
Theme.setCombinedDrawableColor(this.shadowDrawable, -986896, false);
} else if (color == 1) {
Theme.setCombinedDrawableColor(this.shadowDrawable, -1712440, false);
} else if (color == 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 adapter) {
super(context);
this.textX = AndroidUtilities.dp(18.0f);
this.parentAdapter = adapter;
}
public void setBlock(TLRPC.TL_pageBlockRelatedArticles block) {
this.currentBlock = block;
requestLayout();
}
@Override
public boolean onTouchEvent(MotionEvent event) {
return ArticleViewer.this.checkLayoutForLinks(event, this, this.textLayout, this.textX, this.textY) || super.onTouchEvent(event);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int width = View.MeasureSpec.getSize(widthMeasureSpec);
TLRPC.TL_pageBlockRelatedArticles tL_pageBlockRelatedArticles = this.currentBlock;
if (tL_pageBlockRelatedArticles != null) {
DrawingText createLayoutForText = ArticleViewer.this.createLayoutForText(this, null, tL_pageBlockRelatedArticles.title, width - 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(width, AndroidUtilities.dp(38.0f));
} else {
setMeasuredDimension(width, 1);
}
}
@Override
protected void onDraw(Canvas canvas) {
if (this.currentBlock != null && this.textLayout != null) {
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 adapter) {
super(context);
this.textX = AndroidUtilities.dp(18.0f);
this.textY = AndroidUtilities.dp(10.0f);
this.parentAdapter = adapter;
ImageReceiver imageReceiver = new ImageReceiver(this);
this.imageView = imageReceiver;
imageReceiver.setRoundRadius(AndroidUtilities.dp(6.0f));
}
public void setBlock(TL_pageBlockRelatedArticlesChild block) {
this.currentBlock = block;
requestLayout();
}
@Override
protected void onMeasure(int i, int i2) {
int i3;
int i4;
boolean z;
int i5;
int i6;
String str;
int i7;
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);
if (closestPhotoSizeWithSize == closestPhotoSizeWithSize2) {
closestPhotoSizeWithSize2 = null;
}
this.imageView.setImage(ImageLocation.getForPhoto(closestPhotoSizeWithSize, photoWithId), "64_64", ImageLocation.getForPhoto(closestPhotoSizeWithSize2, 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) {
i3 = dp2;
} else {
int dp3 = AndroidUtilities.dp(44.0f);
this.imageView.setImageCoords((size - dp3) - AndroidUtilities.dp(8.0f), AndroidUtilities.dp(8.0f), dp3, dp3);
i3 = dp2 - (this.imageView.getImageWidth() + AndroidUtilities.dp(6.0f));
}
int dp4 = AndroidUtilities.dp(18.0f);
boolean z2 = false;
if (tL_pageRelatedArticle.title != null) {
i4 = dp;
this.textLayout = ArticleViewer.this.createLayoutForText(this, tL_pageRelatedArticle.title, null, i3, this.textY, this.currentBlock, Layout.Alignment.ALIGN_NORMAL, 3, this.parentAdapter);
} else {
i4 = dp;
}
DrawingText drawingText = this.textLayout;
if (drawingText != null) {
int lineCount = drawingText.getLineCount();
int i8 = 4 - lineCount;
this.textOffset = this.textLayout.getHeight() + AndroidUtilities.dp(6.0f) + this.additionalHeight;
int height = dp4 + this.textLayout.getHeight();
int i9 = 0;
while (true) {
if (i9 >= lineCount) {
break;
}
if (this.textLayout.getLineLeft(i9) == 0.0f) {
i9++;
} else {
z2 = true;
break;
}
}
z = z2;
i5 = height;
i6 = i8;
} else {
this.textOffset = 0;
z = false;
i5 = dp4;
i6 = 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;
}
ArticleViewer articleViewer = ArticleViewer.this;
DrawingText createLayoutForText = articleViewer.createLayoutForText(this, str, null, i3, this.textY + this.textOffset, this.currentBlock, (articleViewer.isRtl || z) ? StaticLayoutEx.ALIGN_RIGHT() : Layout.Alignment.ALIGN_NORMAL, i6, this.parentAdapter);
this.textLayout2 = createLayoutForText;
if (createLayoutForText == null) {
i7 = i5;
} else {
int height2 = i5 + createLayoutForText.getHeight();
if (this.textLayout != null) {
i7 = height2 + AndroidUtilities.dp(6.0f) + this.additionalHeight;
} else {
i7 = height2;
}
}
setMeasuredDimension(size, (this.divider ? 1 : 0) + Math.max(i4, i7));
}
@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 adapter) {
super(context);
this.textX = AndroidUtilities.dp(18.0f);
this.textY = AndroidUtilities.dp(8.0f);
this.parentAdapter = adapter;
}
public void setBlock(TLRPC.TL_pageBlockHeader block) {
this.currentBlock = block;
requestLayout();
}
@Override
public boolean onTouchEvent(MotionEvent event) {
return ArticleViewer.this.checkLayoutForLinks(event, this, this.textLayout, this.textX, this.textY) || super.onTouchEvent(event);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int width = View.MeasureSpec.getSize(widthMeasureSpec);
int height = 0;
TLRPC.TL_pageBlockHeader tL_pageBlockHeader = this.currentBlock;
if (tL_pageBlockHeader != null) {
DrawingText createLayoutForText = ArticleViewer.this.createLayoutForText(this, (CharSequence) null, tL_pageBlockHeader.text, width - AndroidUtilities.dp(36.0f), this.currentBlock, ArticleViewer.this.isRtl ? StaticLayoutEx.ALIGN_RIGHT() : Layout.Alignment.ALIGN_NORMAL, this.parentAdapter);
this.textLayout = createLayoutForText;
if (createLayoutForText != null) {
height = 0 + AndroidUtilities.dp(16.0f) + this.textLayout.getHeight();
}
} else {
height = 1;
}
setMeasuredDimension(width, height);
}
@Override
protected void onDraw(Canvas canvas) {
if (this.currentBlock != null && this.textLayout != null) {
canvas.save();
canvas.translate(this.textX, this.textY);
this.textLayout.draw(canvas);
canvas.restore();
}
}
@Override
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
super.onInitializeAccessibilityNodeInfo(info);
info.setEnabled(true);
if (this.textLayout == null) {
return;
}
info.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 widthMeasureSpec, int heightMeasureSpec) {
setMeasuredDimension(View.MeasureSpec.getSize(widthMeasureSpec), AndroidUtilities.dp(18.0f));
}
@Override
protected void onDraw(Canvas canvas) {
int width = getMeasuredWidth() / 3;
this.rect.set(width, AndroidUtilities.dp(8.0f), width * 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 adapter) {
super(context);
this.textX = AndroidUtilities.dp(18.0f);
this.textY = AndroidUtilities.dp(8.0f);
this.parentAdapter = adapter;
}
public void setBlock(TLRPC.TL_pageBlockSubtitle block) {
this.currentBlock = block;
requestLayout();
}
@Override
public boolean onTouchEvent(MotionEvent event) {
return ArticleViewer.this.checkLayoutForLinks(event, this, this.textLayout, this.textX, this.textY) || super.onTouchEvent(event);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int width = View.MeasureSpec.getSize(widthMeasureSpec);
int height = 0;
TLRPC.TL_pageBlockSubtitle tL_pageBlockSubtitle = this.currentBlock;
if (tL_pageBlockSubtitle != null) {
DrawingText createLayoutForText = ArticleViewer.this.createLayoutForText(this, (CharSequence) null, tL_pageBlockSubtitle.text, width - AndroidUtilities.dp(36.0f), this.currentBlock, ArticleViewer.this.isRtl ? StaticLayoutEx.ALIGN_RIGHT() : Layout.Alignment.ALIGN_NORMAL, this.parentAdapter);
this.textLayout = createLayoutForText;
if (createLayoutForText != null) {
height = 0 + AndroidUtilities.dp(16.0f) + this.textLayout.getHeight();
}
} else {
height = 1;
}
setMeasuredDimension(width, height);
}
@Override
protected void onDraw(Canvas canvas) {
if (this.currentBlock != null && this.textLayout != null) {
canvas.save();
canvas.translate(this.textX, this.textY);
this.textLayout.draw(canvas);
canvas.restore();
}
}
@Override
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
super.onInitializeAccessibilityNodeInfo(info);
info.setEnabled(true);
if (this.textLayout == null) {
return;
}
info.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 adapter) {
super(context);
this.textX = AndroidUtilities.dp(18.0f);
this.textY = AndroidUtilities.dp(8.0f);
this.parentAdapter = adapter;
}
public void setBlock(TLRPC.TL_pageBlockPullquote block) {
this.currentBlock = block;
requestLayout();
}
@Override
public boolean onTouchEvent(MotionEvent event) {
return ArticleViewer.this.checkLayoutForLinks(event, this, this.textLayout, this.textX, this.textY) || ArticleViewer.this.checkLayoutForLinks(event, this, this.textLayout2, this.textX, this.textY2) || super.onTouchEvent(event);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int height;
int width = View.MeasureSpec.getSize(widthMeasureSpec);
TLRPC.TL_pageBlockPullquote tL_pageBlockPullquote = this.currentBlock;
if (tL_pageBlockPullquote != null) {
DrawingText createLayoutForText = ArticleViewer.this.createLayoutForText(this, null, tL_pageBlockPullquote.text, width - AndroidUtilities.dp(36.0f), this.currentBlock, this.parentAdapter);
this.textLayout = createLayoutForText;
height = createLayoutForText != null ? 0 + AndroidUtilities.dp(8.0f) + this.textLayout.getHeight() : 0;
DrawingText createLayoutForText2 = ArticleViewer.this.createLayoutForText(this, null, this.currentBlock.caption, width - AndroidUtilities.dp(36.0f), this.currentBlock, this.parentAdapter);
this.textLayout2 = createLayoutForText2;
if (createLayoutForText2 != null) {
this.textY2 = AndroidUtilities.dp(2.0f) + height;
height += AndroidUtilities.dp(8.0f) + this.textLayout2.getHeight();
}
if (height != 0) {
height += AndroidUtilities.dp(8.0f);
}
} else {
height = 1;
}
setMeasuredDimension(width, height);
}
@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 adapter) {
super(context);
this.textY = AndroidUtilities.dp(8.0f);
this.parentAdapter = adapter;
}
public void setBlock(TLRPC.TL_pageBlockBlockquote block) {
this.currentBlock = block;
requestLayout();
}
@Override
public boolean onTouchEvent(MotionEvent event) {
return ArticleViewer.this.checkLayoutForLinks(event, this, this.textLayout, this.textX, this.textY) || ArticleViewer.this.checkLayoutForLinks(event, this, this.textLayout2, this.textX, this.textY2) || super.onTouchEvent(event);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int height;
int width = View.MeasureSpec.getSize(widthMeasureSpec);
if (this.currentBlock != null) {
int textWidth = width - AndroidUtilities.dp(50.0f);
if (this.currentBlock.level > 0) {
textWidth -= AndroidUtilities.dp(this.currentBlock.level * 14);
}
DrawingText createLayoutForText = ArticleViewer.this.createLayoutForText(this, null, this.currentBlock.text, textWidth, this.currentBlock, this.parentAdapter);
this.textLayout = createLayoutForText;
height = 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, textWidth, this.currentBlock, this.parentAdapter);
this.textLayout2 = createLayoutForText2;
if (createLayoutForText2 != null) {
this.textY2 = AndroidUtilities.dp(8.0f) + height;
height += AndroidUtilities.dp(8.0f) + this.textLayout2.getHeight();
}
if (height != 0) {
height += AndroidUtilities.dp(8.0f);
}
} else {
height = 1;
}
setMeasuredDimension(width, height);
}
@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 {
int x = getMeasuredWidth() - AndroidUtilities.dp(20.0f);
canvas.drawRect(x, AndroidUtilities.dp(6.0f), AndroidUtilities.dp(2.0f) + x, 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;
public BlockPhotoCell(Context context, WebpageAdapter adapter, int type) {
super(context);
this.parentAdapter = adapter;
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 = type;
}
public void setBlock(TLRPC.TL_pageBlockPhoto block, boolean first, boolean last) {
this.parentBlock = null;
this.currentBlock = block;
this.isFirst = first;
this.isLast = last;
this.channelCell.setVisibility(4);
if (!TextUtils.isEmpty(this.currentBlock.url)) {
this.linkDrawable = getResources().getDrawable(R.drawable.instant_link);
}
TLRPC.TL_pageBlockPhoto tL_pageBlockPhoto = this.currentBlock;
if (tL_pageBlockPhoto != null) {
TLRPC.Photo photo = ArticleViewer.this.getPhotoWithId(tL_pageBlockPhoto.photo_id);
if (photo != null) {
this.currentPhotoObject = FileLoader.getClosestPhotoSizeWithSize(photo.sizes, AndroidUtilities.getPhotoSize());
} else {
this.currentPhotoObject = null;
}
} else {
this.currentPhotoObject = null;
}
updateButtonState(false);
requestLayout();
}
public void setParentBlock(TLRPC.PageBlock block) {
this.parentBlock = block;
if (ArticleViewer.this.channelBlock != null && (this.parentBlock instanceof TLRPC.TL_pageBlockCover)) {
this.channelCell.setBlock(ArticleViewer.this.channelBlock);
this.channelCell.setVisibility(0);
}
}
public View getChannelCell() {
return this.channelCell;
}
@Override
public boolean onTouchEvent(MotionEvent event) {
float x = event.getX();
float y = event.getY();
if (this.channelCell.getVisibility() == 0 && y > this.channelCell.getTranslationY() && y < this.channelCell.getTranslationY() + AndroidUtilities.dp(39.0f)) {
if (ArticleViewer.this.channelBlock != null && event.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 (event.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 (event.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 (event.getAction() == 3) {
this.photoPressed = false;
this.buttonPressed = 0;
}
return this.photoPressed || this.buttonPressed != 0 || ArticleViewer.this.checkLayoutForLinks(event, this, this.captionLayout, this.textX, this.textY) || ArticleViewer.this.checkLayoutForLinks(event, this, this.creditLayout, this.textX, this.textY + this.creditOffset) || super.onTouchEvent(event);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int width;
int height;
int photoX;
int textWidth;
int height2;
int i;
int width2 = View.MeasureSpec.getSize(widthMeasureSpec);
int height3 = 0;
int i2 = this.currentType;
if (i2 == 1) {
int width3 = ((View) getParent()).getMeasuredWidth();
height3 = ((View) getParent()).getMeasuredHeight();
width = width3;
} else if (i2 != 2) {
width = width2;
} else {
height3 = (int) Math.ceil(this.groupPosition.ph * Math.max(AndroidUtilities.displaySize.x, AndroidUtilities.displaySize.y) * 0.5f);
width = width2;
}
TLRPC.TL_pageBlockPhoto tL_pageBlockPhoto = this.currentBlock;
if (tL_pageBlockPhoto != null) {
this.currentPhoto = ArticleViewer.this.getPhotoWithId(tL_pageBlockPhoto.photo_id);
int size = AndroidUtilities.dp(48.0f);
int photoWidth = width;
int photoHeight = height3;
if (this.currentType == 0 && this.currentBlock.level > 0) {
int dp = AndroidUtilities.dp(this.currentBlock.level * 14) + AndroidUtilities.dp(18.0f);
photoX = dp;
this.textX = dp;
photoWidth -= AndroidUtilities.dp(18.0f) + photoX;
textWidth = photoWidth;
} else {
photoX = 0;
this.textX = AndroidUtilities.dp(18.0f);
textWidth = width - AndroidUtilities.dp(36.0f);
}
TLRPC.Photo photo = this.currentPhoto;
if (photo == null || this.currentPhotoObject == null) {
height = height3;
} else {
TLRPC.PhotoSize closestPhotoSizeWithSize = FileLoader.getClosestPhotoSizeWithSize(photo.sizes, 40, true);
this.currentPhotoObjectThumb = closestPhotoSizeWithSize;
if (this.currentPhotoObject == closestPhotoSizeWithSize) {
this.currentPhotoObjectThumb = null;
}
int i3 = this.currentType;
if (i3 == 0) {
float scale = photoWidth / r4.w;
height3 = (int) (this.currentPhotoObject.h * scale);
if (!(this.parentBlock instanceof TLRPC.TL_pageBlockCover)) {
int maxHeight = (int) ((Math.max(ArticleViewer.this.listView[0].getMeasuredWidth(), ArticleViewer.this.listView[0].getMeasuredHeight()) - AndroidUtilities.dp(56.0f)) * 0.9f);
if (height3 > maxHeight) {
height3 = maxHeight;
float scale2 = height3 / this.currentPhotoObject.h;
photoWidth = (int) (this.currentPhotoObject.w * scale2);
photoX += ((width - photoX) - photoWidth) / 2;
}
} else {
height3 = Math.min(height3, photoWidth);
}
photoHeight = height3;
} else if (i3 == 2) {
if ((this.groupPosition.flags & 2) == 0) {
photoWidth -= AndroidUtilities.dp(2.0f);
}
if ((this.groupPosition.flags & 8) == 0) {
photoHeight -= AndroidUtilities.dp(2.0f);
}
if (this.groupPosition.leftSpanOffset != 0) {
int offset = (int) Math.ceil((this.groupPosition.leftSpanOffset * width) / 1000.0f);
photoWidth -= offset;
photoX += offset;
}
}
this.imageView.setImageCoords(photoX, (this.isFirst || (i = this.currentType) == 1 || i == 2 || this.currentBlock.level > 0) ? 0 : AndroidUtilities.dp(8.0f), photoWidth, photoHeight);
if (this.currentType == 0) {
this.currentFilter = null;
} else {
this.currentFilter = String.format(Locale.US, "%d_%d", Integer.valueOf(photoWidth), Integer.valueOf(photoHeight));
}
this.currentThumbFilter = "80_80_b";
this.autoDownload = (DownloadController.getInstance(ArticleViewer.this.currentAccount).getCurrentDownloadMask() & 1) != 0;
File path = FileLoader.getPathToAttach(this.currentPhotoObject, true);
if (!this.autoDownload && !path.exists()) {
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);
} else {
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() - size) / 2.0f));
int imageY = (int) (this.imageView.getImageY() + ((this.imageView.getImageHeight() - size) / 2.0f));
this.buttonY = imageY;
RadialProgress2 radialProgress2 = this.radialProgress;
int i4 = this.buttonX;
radialProgress2.setProgressRect(i4, imageY, i4 + size, imageY + size);
height = height3;
}
if (this.currentType == 0) {
DrawingText createLayoutForText = ArticleViewer.this.createLayoutForText(this, null, this.currentBlock.caption.text, textWidth, this.currentBlock, this.parentAdapter);
this.captionLayout = createLayoutForText;
if (createLayoutForText != null) {
int dp2 = AndroidUtilities.dp(4.0f) + this.captionLayout.getHeight();
this.creditOffset = dp2;
height2 = height + dp2 + AndroidUtilities.dp(4.0f);
} else {
height2 = height;
}
DrawingText createLayoutForText2 = ArticleViewer.this.createLayoutForText(this, (CharSequence) null, this.currentBlock.caption.credit, textWidth, this.currentBlock, ArticleViewer.this.isRtl ? StaticLayoutEx.ALIGN_RIGHT() : Layout.Alignment.ALIGN_NORMAL, this.parentAdapter);
this.creditLayout = createLayoutForText2;
if (createLayoutForText2 != null) {
height = height2 + AndroidUtilities.dp(4.0f) + this.creditLayout.getHeight();
} else {
height = height2;
}
}
if (!this.isFirst && this.currentType == 0 && this.currentBlock.level <= 0) {
height += AndroidUtilities.dp(8.0f);
}
boolean nextIsChannel = (this.parentBlock instanceof TLRPC.TL_pageBlockCover) && this.parentAdapter.blocks != null && this.parentAdapter.blocks.size() > 1 && (this.parentAdapter.blocks.get(1) instanceof TLRPC.TL_pageBlockChannel);
if (this.currentType != 2 && !nextIsChannel) {
height += AndroidUtilities.dp(8.0f);
}
} else {
height = 1;
}
this.channelCell.measure(widthMeasureSpec, heightMeasureSpec);
this.channelCell.setTranslationY(this.imageView.getImageHeight() - AndroidUtilities.dp(39.0f));
setMeasuredDimension(width, height);
}
@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 x = getMeasuredWidth() - AndroidUtilities.dp(35.0f);
int y = this.imageView.getImageY() + AndroidUtilities.dp(11.0f);
this.linkDrawable.setBounds(x, y, AndroidUtilities.dp(24.0f) + x, AndroidUtilities.dp(24.0f) + y);
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;
}
if (i == 1) {
return 3;
}
return 4;
}
private void didPressedButton(boolean animated) {
int i = this.buttonState;
if (i == 0) {
this.cancelLoading = false;
this.radialProgress.setProgress(0.0f, animated);
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, animated);
invalidate();
return;
}
if (i == 1) {
this.cancelLoading = true;
this.imageView.cancelLoadImage();
this.buttonState = 0;
this.radialProgress.setIcon(getIconForCurrentState(), false, animated);
invalidate();
}
}
public void updateButtonState(boolean animated) {
String fileName = FileLoader.getAttachFileName(this.currentPhotoObject);
File path = FileLoader.getPathToAttach(this.currentPhotoObject, true);
boolean fileExists = path.exists();
if (TextUtils.isEmpty(fileName)) {
this.radialProgress.setIcon(4, false, false);
return;
}
if (fileExists) {
DownloadController.getInstance(ArticleViewer.this.currentAccount).removeLoadingFileObserver(this);
this.buttonState = -1;
this.radialProgress.setIcon(getIconForCurrentState(), false, animated);
invalidate();
return;
}
DownloadController.getInstance(ArticleViewer.this.currentAccount).addLoadingFileObserver(fileName, null, this);
float setProgress = 0.0f;
if (this.autoDownload || FileLoader.getInstance(ArticleViewer.this.currentAccount).isLoadingFile(fileName)) {
this.buttonState = 1;
Float progress = ImageLoader.getInstance().getFileProgress(fileName);
setProgress = progress != null ? progress.floatValue() : 0.0f;
} else {
this.buttonState = 0;
}
this.radialProgress.setIcon(getIconForCurrentState(), true, animated);
this.radialProgress.setProgress(setProgress, 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 fileName, boolean canceled) {
updateButtonState(false);
}
@Override
public void onSuccessDownload(String fileName) {
this.radialProgress.setProgress(1.0f, true);
updateButtonState(true);
}
@Override
public void onProgressUpload(String fileName, float progress, boolean isEncrypted) {
}
@Override
public void onProgressDownload(String fileName, float progress) {
this.radialProgress.setProgress(progress, true);
if (this.buttonState != 1) {
updateButtonState(true);
}
}
@Override
public int getObserverTag() {
return this.TAG;
}
@Override
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
super.onInitializeAccessibilityNodeInfo(info);
info.setEnabled(true);
StringBuilder sb = new StringBuilder(LocaleController.getString("AttachPhoto", R.string.AttachPhoto));
if (this.captionLayout != null) {
sb.append(", ");
sb.append(this.captionLayout.getText());
}
info.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 adapter, int type) {
super(context);
this.parentAdapter = adapter;
setWillNotDraw(false);
this.imageView = new ImageReceiver(this);
this.currentType = type;
}
public void setBlock(TLRPC.TL_pageBlockMap block, boolean first, boolean last) {
this.currentBlock = block;
this.isFirst = first;
this.isLast = last;
requestLayout();
}
@Override
public boolean onTouchEvent(MotionEvent event) {
float x = event.getX();
float y = event.getY();
if (event.getAction() == 0 && this.imageView.isInsideImage(x, y)) {
this.photoPressed = true;
} else if (event.getAction() == 1 && this.photoPressed) {
this.photoPressed = false;
try {
double lat = this.currentBlock.geo.lat;
double lon = this.currentBlock.geo._long;
ArticleViewer.this.parentActivity.startActivity(new Intent("android.intent.action.VIEW", Uri.parse("geo:" + lat + "," + lon + "?q=" + lat + "," + lon)));
} catch (Exception e) {
FileLog.e(e);
}
} else if (event.getAction() == 3) {
this.photoPressed = false;
}
return this.photoPressed || ArticleViewer.this.checkLayoutForLinks(event, this, this.captionLayout, this.textX, this.textY) || ArticleViewer.this.checkLayoutForLinks(event, this, this.creditLayout, this.textX, this.textY + this.creditOffset) || super.onTouchEvent(event);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int width;
int height;
int photoX;
int textWidth;
int photoWidth;
int photoX2;
int height2;
int i;
int width2 = View.MeasureSpec.getSize(widthMeasureSpec);
int height3 = 0;
int i2 = this.currentType;
if (i2 == 1) {
int width3 = ((View) getParent()).getMeasuredWidth();
height3 = ((View) getParent()).getMeasuredHeight();
width = width3;
} else if (i2 != 2) {
width = width2;
} else {
height3 = width2;
width = width2;
}
TLRPC.TL_pageBlockMap tL_pageBlockMap = this.currentBlock;
if (tL_pageBlockMap != null) {
int photoWidth2 = width;
if (this.currentType == 0 && tL_pageBlockMap.level > 0) {
int dp = AndroidUtilities.dp(this.currentBlock.level * 14) + AndroidUtilities.dp(18.0f);
photoX = dp;
this.textX = dp;
photoWidth2 -= AndroidUtilities.dp(18.0f) + photoX;
textWidth = photoWidth2;
} else {
photoX = 0;
this.textX = AndroidUtilities.dp(18.0f);
textWidth = width - AndroidUtilities.dp(36.0f);
}
if (this.currentType == 0) {
float scale = photoWidth2 / this.currentBlock.w;
int height4 = (int) (this.currentBlock.h * scale);
int maxHeight = (int) ((Math.max(ArticleViewer.this.listView[0].getMeasuredWidth(), ArticleViewer.this.listView[0].getMeasuredHeight()) - AndroidUtilities.dp(56.0f)) * 0.9f);
if (height4 > maxHeight) {
float scale2 = maxHeight / this.currentBlock.h;
int photoWidth3 = (int) (this.currentBlock.w * scale2);
height = maxHeight;
photoWidth = photoWidth3;
photoX2 = photoX + (((width - photoX) - photoWidth3) / 2);
} else {
height = height4;
photoWidth = photoWidth2;
photoX2 = photoX;
}
} else {
height = height3;
photoWidth = photoWidth2;
photoX2 = photoX;
}
this.imageView.setImageCoords(photoX2, (this.isFirst || (i = this.currentType) == 1 || i == 2 || this.currentBlock.level > 0) ? 0 : AndroidUtilities.dp(8.0f), photoWidth, height);
String currentUrl = AndroidUtilities.formapMapUrl(ArticleViewer.this.currentAccount, this.currentBlock.geo.lat, this.currentBlock.geo._long, (int) (photoWidth / AndroidUtilities.density), (int) (height / AndroidUtilities.density), true, 15);
WebFile currentWebFile = WebFile.createWithGeoPoint(this.currentBlock.geo, (int) (photoWidth / AndroidUtilities.density), (int) (height / AndroidUtilities.density), 15, Math.min(2, (int) Math.ceil(AndroidUtilities.density)));
int i3 = MessagesController.getInstance(ArticleViewer.this.currentAccount).mapProvider;
this.currentMapProvider = i3;
if (i3 == 2) {
if (currentWebFile != null) {
this.imageView.setImage(ImageLocation.getForWebFile(currentWebFile), null, Theme.chat_locationDrawable[0], null, ArticleViewer.this.currentPage, 0);
}
} else if (currentUrl != null) {
this.imageView.setImage(currentUrl, null, Theme.chat_locationDrawable[0], null, 0);
}
if (this.currentType == 0) {
DrawingText createLayoutForText = ArticleViewer.this.createLayoutForText(this, null, this.currentBlock.caption.text, textWidth, this.currentBlock, this.parentAdapter);
this.captionLayout = createLayoutForText;
if (createLayoutForText != null) {
int dp2 = AndroidUtilities.dp(4.0f) + this.captionLayout.getHeight();
this.creditOffset = dp2;
height2 = height + dp2 + AndroidUtilities.dp(4.0f);
} else {
height2 = height;
}
DrawingText createLayoutForText2 = ArticleViewer.this.createLayoutForText(this, (CharSequence) null, this.currentBlock.caption.credit, textWidth, this.currentBlock, ArticleViewer.this.isRtl ? StaticLayoutEx.ALIGN_RIGHT() : Layout.Alignment.ALIGN_NORMAL, this.parentAdapter);
this.creditLayout = createLayoutForText2;
if (createLayoutForText2 != null) {
height = height2 + AndroidUtilities.dp(4.0f) + this.creditLayout.getHeight();
} else {
height = height2;
}
}
if (!this.isFirst && this.currentType == 0 && this.currentBlock.level <= 0) {
height += AndroidUtilities.dp(8.0f);
}
if (this.currentType != 2) {
height += AndroidUtilities.dp(8.0f);
}
} else {
height = 1;
}
setMeasuredDimension(width, height);
}
@Override
protected void onDraw(Canvas canvas) {
if (this.currentBlock == null) {
return;
}
this.imageView.draw(canvas);
if (this.currentMapProvider == 2 && this.imageView.hasNotThumb()) {
int w = (int) (Theme.chat_redLocationIcon.getIntrinsicWidth() * 0.8f);
int h = (int) (Theme.chat_redLocationIcon.getIntrinsicHeight() * 0.8f);
int x = this.imageView.getImageX() + ((this.imageView.getImageWidth() - w) / 2);
int y = this.imageView.getImageY() + ((this.imageView.getImageHeight() / 2) - h);
Theme.chat_redLocationIcon.setAlpha((int) (this.imageView.getCurrentAlpha() * 255.0f));
Theme.chat_redLocationIcon.setBounds(x, y, x + w, y + h);
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 info) {
super.onInitializeAccessibilityNodeInfo(info);
info.setEnabled(true);
StringBuilder sb = new StringBuilder(LocaleController.getString("Map", R.string.Map));
if (this.captionLayout != null) {
sb.append(", ");
sb.append(this.captionLayout.getText());
}
info.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 adapter, int type) {
super(context);
this.textX = AndroidUtilities.dp(18.0f);
this.textY = AndroidUtilities.dp(11.0f);
this.parentAdapter = adapter;
setWillNotDraw(false);
this.backgroundPaint = new Paint();
this.currentType = type;
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.m1087lambda$new$0$imwsnshelzviuiArticleViewer$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 m1087lambda$new$0$imwsnshelzviuiArticleViewer$BlockChannelCell(View v) {
if (this.currentState != 0) {
return;
}
setState(1, true);
ArticleViewer articleViewer = ArticleViewer.this;
articleViewer.joinChannel(this, articleViewer.loadedChannel);
}
public void setBlock(TLRPC.TL_pageBlockChannel block) {
this.currentBlock = block;
int color = ArticleViewer.this.getSelectedColor();
if (this.currentType == 0) {
this.textView.setTextColor(-14840360);
if (color == 0) {
this.backgroundPaint.setColor(-526345);
} else if (color == 1) {
this.backgroundPaint.setColor(-1712440);
} else if (color == 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 channel = MessagesController.getInstance(ArticleViewer.this.currentAccount).getChat(Integer.valueOf(block.channel.id));
if (channel == null || channel.min) {
ArticleViewer.this.loadChannel(this, this.parentAdapter, block.channel);
setState(1, false);
} else {
ArticleViewer.this.loadedChannel = channel;
if (!channel.left || channel.kicked) {
setState(4, false);
} else {
setState(0, false);
}
}
requestLayout();
}
public void setState(int state, boolean animated) {
AnimatorSet animatorSet = this.currentAnimation;
if (animatorSet != null) {
animatorSet.cancel();
}
this.currentState = state;
if (animated) {
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] = state == 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] = state == 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] = state == 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] = state == 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] = state == 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] = state == 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] = state == 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] = state == 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] = state == 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(state == 0 ? 1.0f : 0.0f);
this.textView.setScaleX(state == 0 ? 1.0f : 0.1f);
this.textView.setScaleY(state == 0 ? 1.0f : 0.1f);
this.progressView.setAlpha(state == 1 ? 1.0f : 0.0f);
this.progressView.setScaleX(state == 1 ? 1.0f : 0.1f);
this.progressView.setScaleY(state == 1 ? 1.0f : 0.1f);
this.imageView.setAlpha(state == 2 ? 1.0f : 0.0f);
this.imageView.setScaleX(state == 2 ? 1.0f : 0.1f);
this.imageView.setScaleY(state == 2 ? 1.0f : 0.1f);
}
@Override
public boolean onTouchEvent(MotionEvent event) {
if (this.currentType != 0) {
return super.onTouchEvent(event);
}
return ArticleViewer.this.checkLayoutForLinks(event, this, this.textLayout, this.textX, this.textY) || super.onTouchEvent(event);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int width = View.MeasureSpec.getSize(widthMeasureSpec);
setMeasuredDimension(width, AndroidUtilities.dp(48.0f));
this.textView.measure(View.MeasureSpec.makeMeasureSpec(View.MeasureSpec.getSize(widthMeasureSpec), 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, (width - 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 changed, int left, int top, int right, int bottom) {
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 i = this.textX2;
textView.layout(i, 0, textView.getMeasuredWidth() + i, 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) {
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 adapter) {
super(context);
this.textY = AndroidUtilities.dp(8.0f);
this.parentAdapter = adapter;
}
public void setBlock(TLRPC.TL_pageBlockAuthorDate block) {
this.currentBlock = block;
requestLayout();
}
@Override
public boolean onTouchEvent(MotionEvent event) {
return ArticleViewer.this.checkLayoutForLinks(event, this, this.textLayout, this.textX, this.textY) || super.onTouchEvent(event);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
Spannable spannableAuthor;
MetricAffectingSpan[] spans;
CharSequence text;
CharSequence text2;
int idx;
int width = View.MeasureSpec.getSize(widthMeasureSpec);
int height = 0;
TLRPC.TL_pageBlockAuthorDate tL_pageBlockAuthorDate = this.currentBlock;
if (tL_pageBlockAuthorDate != null) {
CharSequence author = ArticleViewer.this.getText(this, tL_pageBlockAuthorDate.author, this.currentBlock.author, this.currentBlock, width);
if (author instanceof Spannable) {
Spannable spannableAuthor2 = (Spannable) author;
spannableAuthor = spannableAuthor2;
spans = (MetricAffectingSpan[]) spannableAuthor2.getSpans(0, author.length(), MetricAffectingSpan.class);
} else {
spannableAuthor = null;
spans = null;
}
if (this.currentBlock.published_date != 0 && !TextUtils.isEmpty(author)) {
text = LocaleController.formatString("ArticleDateByAuthor", R.string.ArticleDateByAuthor, LocaleController.getInstance().chatFullDate.format(this.currentBlock.published_date * 1000), author);
} else if (TextUtils.isEmpty(author)) {
text = LocaleController.getInstance().chatFullDate.format(this.currentBlock.published_date * 1000);
} else {
text = LocaleController.formatString("ArticleByAuthor", R.string.ArticleByAuthor, author);
}
if (spans != null) {
try {
if (spans.length > 0 && (idx = TextUtils.indexOf(text, author)) != -1) {
Spannable spannable = Spannable.Factory.getInstance().newSpannable(text);
text = spannable;
for (int a = 0; a < spans.length; a++) {
spannable.setSpan(spans[a], spannableAuthor.getSpanStart(spans[a]) + idx, spannableAuthor.getSpanEnd(spans[a]) + idx, 33);
}
}
} catch (Exception e) {
FileLog.e(e);
text2 = text;
}
}
text2 = text;
DrawingText createLayoutForText = ArticleViewer.this.createLayoutForText(this, text2, null, width - AndroidUtilities.dp(36.0f), this.currentBlock, this.parentAdapter);
this.textLayout = createLayoutForText;
if (createLayoutForText != null) {
height = 0 + AndroidUtilities.dp(16.0f) + this.textLayout.getHeight();
if (ArticleViewer.this.isRtl) {
this.textX = (int) Math.floor((width - this.textLayout.getLineWidth(0)) - AndroidUtilities.dp(16.0f));
} else {
this.textX = AndroidUtilities.dp(18.0f);
}
}
} else {
height = 1;
}
setMeasuredDimension(width, height);
}
@Override
protected void onDraw(Canvas canvas) {
if (this.currentBlock != null && this.textLayout != null) {
canvas.save();
canvas.translate(this.textX, this.textY);
this.textLayout.draw(canvas);
canvas.restore();
}
}
@Override
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
super.onInitializeAccessibilityNodeInfo(info);
info.setEnabled(true);
DrawingText drawingText = this.textLayout;
if (drawingText == null) {
return;
}
info.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 adapter) {
super(context);
this.textX = AndroidUtilities.dp(18.0f);
this.parentAdapter = adapter;
}
public void setBlock(TLRPC.TL_pageBlockTitle block) {
this.currentBlock = block;
requestLayout();
}
@Override
public boolean onTouchEvent(MotionEvent event) {
return ArticleViewer.this.checkLayoutForLinks(event, this, this.textLayout, this.textX, this.textY) || super.onTouchEvent(event);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int height;
int width = View.MeasureSpec.getSize(widthMeasureSpec);
TLRPC.TL_pageBlockTitle tL_pageBlockTitle = this.currentBlock;
if (tL_pageBlockTitle != null) {
DrawingText createLayoutForText = ArticleViewer.this.createLayoutForText(this, (CharSequence) null, tL_pageBlockTitle.text, width - AndroidUtilities.dp(36.0f), this.currentBlock, ArticleViewer.this.isRtl ? StaticLayoutEx.ALIGN_RIGHT() : Layout.Alignment.ALIGN_NORMAL, this.parentAdapter);
this.textLayout = createLayoutForText;
height = createLayoutForText != null ? 0 + AndroidUtilities.dp(16.0f) + this.textLayout.getHeight() : 0;
if (this.currentBlock.first) {
height += AndroidUtilities.dp(8.0f);
this.textY = AndroidUtilities.dp(16.0f);
} else {
this.textY = AndroidUtilities.dp(8.0f);
}
} else {
height = 1;
}
setMeasuredDimension(width, height);
}
@Override
protected void onDraw(Canvas canvas) {
if (this.currentBlock != null && this.textLayout != null) {
canvas.save();
canvas.translate(this.textX, this.textY);
this.textLayout.draw(canvas);
canvas.restore();
}
}
@Override
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
super.onInitializeAccessibilityNodeInfo(info);
info.setEnabled(true);
if (this.textLayout == null) {
return;
}
info.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 adapter) {
super(context);
this.textX = AndroidUtilities.dp(18.0f);
this.parentAdapter = adapter;
}
public void setBlock(TLRPC.TL_pageBlockKicker block) {
this.currentBlock = block;
requestLayout();
}
@Override
public boolean onTouchEvent(MotionEvent event) {
return ArticleViewer.this.checkLayoutForLinks(event, this, this.textLayout, this.textX, this.textY) || super.onTouchEvent(event);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int height;
int width = View.MeasureSpec.getSize(widthMeasureSpec);
TLRPC.TL_pageBlockKicker tL_pageBlockKicker = this.currentBlock;
if (tL_pageBlockKicker != null) {
DrawingText createLayoutForText = ArticleViewer.this.createLayoutForText(this, (CharSequence) null, tL_pageBlockKicker.text, width - AndroidUtilities.dp(36.0f), this.currentBlock, ArticleViewer.this.isRtl ? StaticLayoutEx.ALIGN_RIGHT() : Layout.Alignment.ALIGN_NORMAL, this.parentAdapter);
this.textLayout = createLayoutForText;
height = createLayoutForText != null ? 0 + AndroidUtilities.dp(16.0f) + this.textLayout.getHeight() : 0;
if (this.currentBlock.first) {
height += AndroidUtilities.dp(8.0f);
this.textY = AndroidUtilities.dp(16.0f);
} else {
this.textY = AndroidUtilities.dp(8.0f);
}
} else {
height = 1;
}
setMeasuredDimension(width, height);
}
@Override
protected void onDraw(Canvas canvas) {
if (this.currentBlock != null && this.textLayout != null) {
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 adapter) {
super(context);
this.textX = AndroidUtilities.dp(18.0f);
this.textY = AndroidUtilities.dp(8.0f);
this.parentAdapter = adapter;
}
public void setBlock(TLRPC.TL_pageBlockFooter block) {
this.currentBlock = block;
requestLayout();
}
@Override
public boolean onTouchEvent(MotionEvent event) {
return ArticleViewer.this.checkLayoutForLinks(event, this, this.textLayout, this.textX, this.textY) || super.onTouchEvent(event);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int width = View.MeasureSpec.getSize(widthMeasureSpec);
int height = 0;
TLRPC.TL_pageBlockFooter tL_pageBlockFooter = this.currentBlock;
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, (width - 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 height2 = createLayoutForText.getHeight();
if (this.currentBlock.level > 0) {
height = height2 + AndroidUtilities.dp(8.0f);
} else {
height = height2 + AndroidUtilities.dp(16.0f);
}
}
} else {
height = 1;
}
setMeasuredDimension(width, height);
}
@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 adapter) {
super(context);
this.parentAdapter = adapter;
HorizontalScrollView horizontalScrollView = new HorizontalScrollView(context) {
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
if (BlockPreformattedCell.this.textContainer.getMeasuredWidth() > getMeasuredWidth()) {
ArticleViewer.this.windowView.requestDisallowInterceptTouchEvent(true);
}
return super.onInterceptTouchEvent(ev);
}
@Override
protected void onScrollChanged(int l, int t, int oldl, int oldt) {
super.onScrollChanged(l, t, oldl, oldt);
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 widthMeasureSpec, int heightMeasureSpec) {
int height = 0;
int width = 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) {
height = 0 + BlockPreformattedCell.this.textLayout.getHeight();
int count = BlockPreformattedCell.this.textLayout.getLineCount();
for (int a = 0; a < count; a++) {
width = Math.max((int) Math.ceil(BlockPreformattedCell.this.textLayout.getLineWidth(a)), width);
}
}
} else {
height = 1;
}
setMeasuredDimension(AndroidUtilities.dp(32.0f) + width, height);
}
@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 block) {
this.currentBlock = block;
this.scrollView.setScrollX(0);
this.textContainer.requestLayout();
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int width = View.MeasureSpec.getSize(widthMeasureSpec);
this.scrollView.measure(View.MeasureSpec.makeMeasureSpec(width, 1073741824), View.MeasureSpec.makeMeasureSpec(0, 0));
setMeasuredDimension(width, 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 adapter) {
super(context);
this.textX = AndroidUtilities.dp(18.0f);
this.textY = AndroidUtilities.dp(8.0f);
this.parentAdapter = adapter;
}
public void setBlock(TLRPC.TL_pageBlockSubheader block) {
this.currentBlock = block;
requestLayout();
}
@Override
public boolean onTouchEvent(MotionEvent event) {
return ArticleViewer.this.checkLayoutForLinks(event, this, this.textLayout, this.textX, this.textY) || super.onTouchEvent(event);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int width = View.MeasureSpec.getSize(widthMeasureSpec);
int height = 0;
TLRPC.TL_pageBlockSubheader tL_pageBlockSubheader = this.currentBlock;
if (tL_pageBlockSubheader != null) {
DrawingText createLayoutForText = ArticleViewer.this.createLayoutForText(this, (CharSequence) null, tL_pageBlockSubheader.text, width - AndroidUtilities.dp(36.0f), this.currentBlock, ArticleViewer.this.isRtl ? StaticLayoutEx.ALIGN_RIGHT() : Layout.Alignment.ALIGN_NORMAL, this.parentAdapter);
this.textLayout = createLayoutForText;
if (createLayoutForText != null) {
height = 0 + AndroidUtilities.dp(16.0f) + this.textLayout.getHeight();
}
} else {
height = 1;
}
setMeasuredDimension(width, height);
}
@Override
protected void onDraw(Canvas canvas) {
if (this.currentBlock != null && this.textLayout != null) {
canvas.save();
canvas.translate(this.textX, this.textY);
this.textLayout.draw(canvas);
canvas.restore();
}
}
@Override
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
super.onInitializeAccessibilityNodeInfo(info);
info.setEnabled(true);
if (this.textLayout == null) {
return;
}
info.setText(((Object) this.textLayout.getText()) + ", " + LocaleController.getString("AccDescrIVHeading", R.string.AccDescrIVHeading));
}
}
public class LinkMovementMethodMy extends LinkMovementMethod {
private LinkMovementMethodMy() {
}
@Override
public boolean onTouchEvent(TextView widget, Spannable buffer, MotionEvent event) {
try {
boolean result = super.onTouchEvent(widget, buffer, event);
if (event.getAction() == 1 || event.getAction() == 3) {
Selection.removeSelection(buffer);
}
return result;
} catch (Exception e) {
FileLog.e(e);
return false;
}
}
}
public class PhotoBackgroundDrawable extends ColorDrawable {
private Runnable drawRunnable;
public PhotoBackgroundDrawable(int color) {
super(color);
}
@Override
public void setAlpha(int alpha) {
if (ArticleViewer.this.parentActivity instanceof LaunchActivity) {
((LaunchActivity) ArticleViewer.this.parentActivity).drawerLayoutContainer.setAllowDrawContent((ArticleViewer.this.isPhotoVisible && alpha == 255) ? false : true);
}
super.setAlpha(alpha);
}
@Override
public void draw(Canvas canvas) {
Runnable runnable;
super.draw(canvas);
if (getAlpha() != 0 && (runnable = this.drawRunnable) != null) {
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 parentView) {
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 = parentView;
}
private void updateAnimation() {
long newTime = System.currentTimeMillis();
long dt = newTime - this.lastUpdateTime;
this.lastUpdateTime = newTime;
if (this.animatedProgressValue != 1.0f) {
this.radOffset += ((float) (360 * dt)) / 3000.0f;
float f = this.currentProgress;
float f2 = this.animationProgressStart;
float progressDiff = f - f2;
if (progressDiff > 0.0f) {
long j = this.currentProgressTime + dt;
this.currentProgressTime = j;
if (j < 300) {
this.animatedProgressValue = f2 + (ArticleViewer.decelerateInterpolator.getInterpolation(((float) this.currentProgressTime) / 300.0f) * progressDiff);
} else {
this.animatedProgressValue = f;
this.animationProgressStart = f;
this.currentProgressTime = 0L;
}
}
this.parent.invalidate();
}
if (this.animatedProgressValue >= 1.0f && this.previousBackgroundState != -2) {
float f3 = this.animatedAlphaValue - (((float) dt) / 200.0f);
this.animatedAlphaValue = f3;
if (f3 <= 0.0f) {
this.animatedAlphaValue = 0.0f;
this.previousBackgroundState = -2;
}
this.parent.invalidate();
}
}
public void setProgress(float value, boolean animated) {
if (!animated) {
this.animatedProgressValue = value;
this.animationProgressStart = value;
} else {
this.animationProgressStart = this.animatedProgressValue;
}
this.currentProgress = value;
this.currentProgressTime = 0L;
}
public void setBackgroundState(int state, boolean animated) {
int i;
this.lastUpdateTime = System.currentTimeMillis();
if (animated && (i = this.backgroundState) != state) {
this.previousBackgroundState = i;
this.animatedAlphaValue = 1.0f;
} else {
this.previousBackgroundState = -2;
}
this.backgroundState = state;
this.parent.invalidate();
}
public void setAlpha(float value) {
this.alpha = value;
}
public void setScale(float value) {
this.scale = value;
}
public void onDraw(Canvas canvas) {
int i;
Drawable drawable;
Drawable drawable2;
int sizeScaled = (int) (this.size * this.scale);
int x = (ArticleViewer.this.getContainerViewWidth() - sizeScaled) / 2;
int y = (ArticleViewer.this.getContainerViewHeight() - sizeScaled) / 2;
int i2 = this.previousBackgroundState;
if (i2 >= 0 && i2 < 4 && (drawable2 = ArticleViewer.progressDrawables[this.previousBackgroundState]) != null) {
drawable2.setAlpha((int) (this.animatedAlphaValue * 255.0f * this.alpha));
drawable2.setBounds(x, y, x + sizeScaled, y + sizeScaled);
drawable2.draw(canvas);
}
int i3 = this.backgroundState;
if (i3 >= 0 && i3 < 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(x, y, x + sizeScaled, y + sizeScaled);
drawable.draw(canvas);
}
int i4 = this.backgroundState;
if (i4 == 0 || i4 == 1 || (i = this.previousBackgroundState) == 0 || i == 1) {
int diff = 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(x + diff, y + diff, (x + sizeScaled) - diff, (y + sizeScaled) - diff);
canvas.drawArc(this.progressRect, (-90.0f) + this.radOffset, 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 f = getMediaFile(this.currentIndex);
if (f != null && f.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.wsnshelzvi.messenger.provider", f));
intent.setFlags(1);
} catch (Exception e) {
intent.putExtra("android.intent.extra.STREAM", Uri.fromFile(f));
}
} else {
intent.putExtra("android.intent.extra.STREAM", Uri.fromFile(f));
}
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 e2) {
FileLog.e(e2);
}
}
private void setScaleToFill() {
float bitmapWidth = this.centerImage.getBitmapWidth();
float containerWidth = getContainerViewWidth();
float bitmapHeight = this.centerImage.getBitmapHeight();
float containerHeight = getContainerViewHeight();
float scaleFit = Math.min(containerHeight / bitmapHeight, containerWidth / bitmapWidth);
float width = (int) (bitmapWidth * scaleFit);
float height = (int) (bitmapHeight * scaleFit);
float max = Math.max(containerWidth / width, containerHeight / height);
this.scale = max;
updateMinMax(max);
}
public void updateVideoPlayerTime() {
String newText;
VideoPlayer videoPlayer = this.videoPlayer;
if (videoPlayer == null) {
newText = String.format("%02d:%02d / %02d:%02d", 0, 0, 0, 0);
} else {
long current = videoPlayer.getCurrentPosition() / 1000;
long total = this.videoPlayer.getDuration() / 1000;
if (total != C.TIME_UNSET && current != C.TIME_UNSET) {
newText = String.format("%02d:%02d / %02d:%02d", Long.valueOf(current / 60), Long.valueOf(current % 60), Long.valueOf(total / 60), Long.valueOf(total % 60));
} else {
newText = String.format("%02d:%02d / %02d:%02d", 0, 0, 0, 0);
}
}
if (!TextUtils.equals(this.videoPlayerTime.getText(), newText)) {
this.videoPlayerTime.setText(newText);
}
}
private void preparePlayer(File file, boolean playWhenReady) {
long duration;
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 void onStateChanged(boolean playWhenReady2, int playbackState) {
if (ArticleViewer.this.videoPlayer == null) {
return;
}
if (playbackState == 4 || playbackState == 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 (playbackState == 3 && ArticleViewer.this.aspectRatioFrameLayout.getVisibility() != 0) {
ArticleViewer.this.aspectRatioFrameLayout.setVisibility(0);
}
if (!ArticleViewer.this.videoPlayer.isPlaying() || playbackState == 4) {
if (ArticleViewer.this.isPlaying) {
ArticleViewer.this.isPlaying = false;
ArticleViewer.this.videoPlayButton.setImageResource(R.drawable.inline_video_play);
AndroidUtilities.cancelRunOnUIThread(ArticleViewer.this.updateProgressRunnable);
if (playbackState == 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 e) {
FileLog.e(e);
}
@Override
public void onVideoSizeChanged(int width, int height, int unappliedRotationDegrees, float pixelWidthHeightRatio) {
if (ArticleViewer.this.aspectRatioFrameLayout != null) {
if (unappliedRotationDegrees == 90 || unappliedRotationDegrees == 270) {
width = height;
height = width;
}
ArticleViewer.this.aspectRatioFrameLayout.setAspectRatio(height == 0 ? 1.0f : (width * pixelWidthHeightRatio) / height, unappliedRotationDegrees);
}
}
@Override
public void onRenderedFirstFrame() {
if (!ArticleViewer.this.textureUploaded) {
ArticleViewer.this.textureUploaded = true;
ArticleViewer.this.containerView.invalidate();
}
}
@Override
public boolean onSurfaceDestroyed(SurfaceTexture surfaceTexture) {
return false;
}
@Override
public void onSurfaceTextureUpdated(SurfaceTexture surfaceTexture) {
}
});
VideoPlayer videoPlayer2 = this.videoPlayer;
if (videoPlayer2 != null) {
duration = videoPlayer2.getDuration();
if (duration == C.TIME_UNSET) {
duration = 0;
}
} else {
duration = 0;
}
long duration2 = duration / 1000;
Math.ceil(this.videoPlayerTime.getPaint().measureText(String.format("%02d:%02d / %02d:%02d", Long.valueOf(duration2 / 60), Long.valueOf(duration2 % 60), Long.valueOf(duration2 / 60), Long.valueOf(duration2 % 60))));
}
this.videoPlayer.preparePlayer(Uri.fromFile(file), "other");
this.bottomLayout.setVisibility(0);
this.videoPlayer.setPlayWhenReady(playWhenReady);
}
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 show, boolean animated) {
if (show) {
this.actionBar.setVisibility(0);
if (this.videoPlayer != null) {
this.bottomLayout.setVisibility(0);
}
if (this.captionTextView.getTag() != null) {
this.captionTextView.setVisibility(0);
}
}
this.isActionBarVisible = show;
this.actionBar.setEnabled(show);
this.bottomLayout.setEnabled(show);
if (animated) {
ArrayList<Animator> arrayList = new ArrayList<>();
ActionBar actionBar = this.actionBar;
Property property = View.ALPHA;
float[] fArr = new float[1];
fArr[0] = show ? 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] = show ? 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] = show ? 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] = show ? 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 (!show) {
this.currentActionBarAnimation.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
if (ArticleViewer.this.currentActionBarAnimation != null && ArticleViewer.this.currentActionBarAnimation.equals(animation)) {
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(show ? 1.0f : 0.0f);
this.bottomLayout.setAlpha(show ? 1.0f : 0.0f);
if (this.captionTextView.getTag() != null) {
this.captionTextView.setAlpha(show ? 1.0f : 0.0f);
}
if (!show) {
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 index) {
TLObject media = getMedia(index);
if (media instanceof TLRPC.Photo) {
media = FileLoader.getClosestPhotoSizeWithSize(((TLRPC.Photo) media).sizes, AndroidUtilities.getPhotoSize());
}
return FileLoader.getAttachFileName(media);
}
public TLObject getMedia(int index) {
if (this.imagesArr.isEmpty() || index >= this.imagesArr.size() || index < 0) {
return null;
}
TLRPC.PageBlock block = this.imagesArr.get(index);
if (block instanceof TLRPC.TL_pageBlockPhoto) {
return getPhotoWithId(((TLRPC.TL_pageBlockPhoto) block).photo_id);
}
if (block instanceof TLRPC.TL_pageBlockVideo) {
return getDocumentWithId(((TLRPC.TL_pageBlockVideo) block).video_id);
}
return null;
}
public File getMediaFile(int index) {
TLRPC.Document document;
TLRPC.PhotoSize sizeFull;
if (this.imagesArr.isEmpty() || index >= this.imagesArr.size() || index < 0) {
return null;
}
TLRPC.PageBlock block = this.imagesArr.get(index);
if (block instanceof TLRPC.TL_pageBlockPhoto) {
TLRPC.Photo photo = getPhotoWithId(((TLRPC.TL_pageBlockPhoto) block).photo_id);
if (photo != null && (sizeFull = FileLoader.getClosestPhotoSizeWithSize(photo.sizes, AndroidUtilities.getPhotoSize())) != null) {
return FileLoader.getPathToAttach(sizeFull, true);
}
} else if ((block instanceof TLRPC.TL_pageBlockVideo) && (document = getDocumentWithId(((TLRPC.TL_pageBlockVideo) block).video_id)) != null) {
return FileLoader.getPathToAttach(document, true);
}
return null;
}
public boolean isVideoBlock(TLRPC.PageBlock block) {
TLRPC.Document document;
if ((block instanceof TLRPC.TL_pageBlockVideo) && (document = getDocumentWithId(((TLRPC.TL_pageBlockVideo) block).video_id)) != null) {
return MessageObject.isVideoDocument(document);
}
return false;
}
public boolean isMediaVideo(int index) {
return !this.imagesArr.isEmpty() && index < this.imagesArr.size() && index >= 0 && isVideoBlock(this.imagesArr.get(index));
}
private String getMediaMime(int index) {
if (index >= this.imagesArr.size() || index < 0) {
return "image/jpeg";
}
TLRPC.PageBlock block = this.imagesArr.get(index);
if (block instanceof TLRPC.TL_pageBlockVideo) {
TLRPC.TL_pageBlockVideo pageBlockVideo = (TLRPC.TL_pageBlockVideo) block;
TLRPC.Document document = getDocumentWithId(pageBlockVideo.video_id);
if (document != null) {
return document.mime_type;
}
}
return "image/jpeg";
}
private TLRPC.PhotoSize getFileLocation(TLObject media, int[] size) {
if (media instanceof TLRPC.Photo) {
TLRPC.Photo photo = (TLRPC.Photo) media;
TLRPC.PhotoSize sizeFull = FileLoader.getClosestPhotoSizeWithSize(photo.sizes, AndroidUtilities.getPhotoSize());
if (sizeFull != null) {
size[0] = sizeFull.size;
if (size[0] == 0) {
size[0] = -1;
}
return sizeFull;
}
size[0] = -1;
return null;
}
if (media instanceof TLRPC.Document) {
TLRPC.Document document = (TLRPC.Document) media;
TLRPC.PhotoSize thumb = FileLoader.getClosestPhotoSizeWithSize(document.thumbs, 90);
if (thumb != null) {
size[0] = thumb.size;
if (size[0] == 0) {
size[0] = -1;
}
return thumb;
}
return null;
}
return null;
}
private void onPhotoShow(int index, PlaceProviderObject object) {
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 = object != null ? object.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 a = 0; a < 3; a++) {
RadialProgressView radialProgressView = this.radialProgressViews[a];
if (radialProgressView != null) {
radialProgressView.setBackgroundState(-1, false);
}
}
setImageIndex(index, true);
if (this.currentMedia != null && isMediaVideo(this.currentIndex)) {
onActionClick(false);
}
}
private void setImages() {
if (this.photoAnimationInProgress == 0) {
setIndexToImage(this.centerImage, this.currentIndex);
setIndexToImage(this.rightImage, this.currentIndex + 1);
setIndexToImage(this.leftImage, this.currentIndex - 1);
}
}
public void setImageIndex(int index, boolean init) {
CharSequence captionToSet;
boolean setAsIs;
boolean setAsIs2;
ImageReceiver.BitmapHolder bitmapHolder;
if (this.currentIndex == index) {
return;
}
if (!init && (bitmapHolder = this.currentThumb) != null) {
bitmapHolder.release();
this.currentThumb = null;
}
this.currentFileNames[0] = getFileName(index);
this.currentFileNames[1] = getFileName(index + 1);
this.currentFileNames[2] = getFileName(index - 1);
int prevIndex = this.currentIndex;
this.currentIndex = index;
boolean isVideo = false;
boolean sameImage = false;
if (!this.imagesArr.isEmpty()) {
int i = this.currentIndex;
if (i >= 0 && i < this.imagesArr.size()) {
TLRPC.PageBlock newMedia = this.imagesArr.get(this.currentIndex);
TLRPC.PageBlock pageBlock = this.currentMedia;
boolean sameImage2 = pageBlock != null && pageBlock == newMedia;
this.currentMedia = newMedia;
boolean isVideo2 = isMediaVideo(this.currentIndex);
if (isVideo2) {
this.menuItem.showSubItem(3);
}
if (newMedia instanceof TLRPC.TL_pageBlockPhoto) {
String url = ((TLRPC.TL_pageBlockPhoto) newMedia).url;
if (!TextUtils.isEmpty(url)) {
SpannableStringBuilder stringBuilder = new SpannableStringBuilder(url);
stringBuilder.setSpan(new URLSpan(url) {
@Override
public void onClick(View widget) {
ArticleViewer.this.openWebpageUrl(getURL(), null);
}
}, 0, url.length(), 34);
captionToSet = stringBuilder;
setAsIs = true;
if (captionToSet != null) {
TLRPC.RichText caption = getBlockCaption(this.currentMedia, 2);
setAsIs2 = setAsIs;
captionToSet = getText(null, caption, caption, this.currentMedia, -AndroidUtilities.dp(100.0f));
} else {
setAsIs2 = setAsIs;
}
setCurrentCaption(captionToSet, setAsIs2);
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) {
if (isVideo2) {
this.actionBar.setTitle(LocaleController.getString("AttachVideo", R.string.AttachVideo));
} else {
this.actionBar.setTitle(LocaleController.getString("AttachPhoto", R.string.AttachPhoto));
}
} else {
this.actionBar.setTitle(LocaleController.formatString("Of", R.string.Of, Integer.valueOf(this.currentIndex + 1), Integer.valueOf(this.imagesArr.size())));
}
this.menuItem.showSubItem(1);
}
this.groupedPhotosListView.fillList();
sameImage = sameImage2;
isVideo = isVideo2;
}
}
captionToSet = null;
setAsIs = false;
if (captionToSet != null) {
}
setCurrentCaption(captionToSet, setAsIs2);
if (this.currentAnimation == null) {
}
this.groupedPhotosListView.fillList();
sameImage = sameImage2;
isVideo = isVideo2;
} else {
closePhoto(false);
return;
}
}
int count = this.listView[0].getChildCount();
int a = 0;
while (true) {
if (a >= count) {
break;
}
View child = this.listView[0].getChildAt(a);
if (child instanceof BlockSlideshowCell) {
BlockSlideshowCell cell = (BlockSlideshowCell) child;
int idx = cell.currentBlock.items.indexOf(this.currentMedia);
if (idx != -1) {
cell.innerListView.setCurrentItem(idx, false);
break;
}
}
a++;
}
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 (!sameImage) {
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 || isVideo || this.radialProgressViews[0].backgroundState == 0) ? false : true;
updateMinMax(this.scale);
}
if (prevIndex == -1) {
setImages();
for (int a2 = 0; a2 < 3; a2++) {
checkProgress(a2, false);
}
return;
}
checkProgress(0, false);
int i2 = this.currentIndex;
if (prevIndex > i2) {
ImageReceiver temp = this.rightImage;
this.rightImage = this.centerImage;
this.centerImage = this.leftImage;
this.leftImage = temp;
RadialProgressView[] radialProgressViewArr = this.radialProgressViews;
RadialProgressView tempProgress = radialProgressViewArr[0];
radialProgressViewArr[0] = radialProgressViewArr[2];
radialProgressViewArr[2] = tempProgress;
setIndexToImage(temp, i2 - 1);
checkProgress(1, false);
checkProgress(2, false);
return;
}
if (prevIndex < i2) {
ImageReceiver temp2 = this.leftImage;
this.leftImage = this.centerImage;
this.centerImage = this.rightImage;
this.rightImage = temp2;
RadialProgressView[] radialProgressViewArr2 = this.radialProgressViews;
RadialProgressView tempProgress2 = radialProgressViewArr2[0];
radialProgressViewArr2[0] = radialProgressViewArr2[1];
radialProgressViewArr2[1] = tempProgress2;
setIndexToImage(temp2, i2 + 1);
checkProgress(1, false);
checkProgress(2, false);
}
}
private void setCurrentCaption(CharSequence caption, boolean setAsIs) {
CharSequence result;
if (!TextUtils.isEmpty(caption)) {
Theme.createChatResources(null, true);
if (setAsIs) {
result = caption;
} else if (caption instanceof Spannable) {
Spannable spannable = (Spannable) caption;
TextPaintUrlSpan[] spans = (TextPaintUrlSpan[]) spannable.getSpans(0, caption.length(), TextPaintUrlSpan.class);
SpannableStringBuilder builder = new SpannableStringBuilder(caption.toString());
if (spans != null && spans.length > 0) {
for (int a = 0; a < spans.length; a++) {
builder.setSpan(new URLSpan(spans[a].getUrl()) {
@Override
public void onClick(View widget) {
ArticleViewer.this.openWebpageUrl(getURL(), null);
}
}, spannable.getSpanStart(spans[a]), spannable.getSpanEnd(spans[a]), 33);
}
}
result = builder;
} else {
result = new SpannableStringBuilder(caption.toString());
}
CharSequence str = Emoji.replaceEmoji(result, this.captionTextView.getPaint().getFontMetricsInt(), AndroidUtilities.dp(20.0f), false);
this.captionTextView.setTag(str);
this.captionTextView.setText(str);
this.captionTextView.setVisibility(0);
return;
}
this.captionTextView.setTag(null);
this.captionTextView.setVisibility(8);
}
private void checkProgress(int a, boolean animated) {
if (this.currentFileNames[a] != null) {
int index = this.currentIndex;
if (a == 1) {
index++;
} else if (a == 2) {
index--;
}
File f = getMediaFile(index);
boolean isVideo = isMediaVideo(index);
if (f != null && f.exists()) {
if (isVideo) {
this.radialProgressViews[a].setBackgroundState(3, animated);
} else {
this.radialProgressViews[a].setBackgroundState(-1, animated);
}
} else {
if (!isVideo) {
this.radialProgressViews[a].setBackgroundState(0, animated);
} else if (!FileLoader.getInstance(this.currentAccount).isLoadingFile(this.currentFileNames[a])) {
this.radialProgressViews[a].setBackgroundState(2, false);
} else {
this.radialProgressViews[a].setBackgroundState(1, false);
}
Float progress = ImageLoader.getInstance().getFileProgress(this.currentFileNames[a]);
if (progress == null) {
progress = Float.valueOf(0.0f);
}
this.radialProgressViews[a].setProgress(progress.floatValue(), false);
}
if (a == 0) {
this.canZoom = (this.currentFileNames[0] == null || isVideo || this.radialProgressViews[0].backgroundState == 0) ? false : true;
return;
}
return;
}
this.radialProgressViews[a].setBackgroundState(-1, animated);
}
private void setIndexToImage(ImageReceiver imageReceiver, int index) {
ImageReceiver.BitmapHolder placeHolder;
ImageReceiver.BitmapHolder placeHolder2;
imageReceiver.setOrientation(0, false);
int[] size = new int[1];
TLObject media = getMedia(index);
TLRPC.PhotoSize fileLocation = getFileLocation(media, size);
if (fileLocation != null) {
if (!(media instanceof TLRPC.Photo)) {
if (isMediaVideo(index)) {
if (fileLocation.location instanceof TLRPC.TL_fileLocationUnavailable) {
imageReceiver.setImageBitmap(this.parentActivity.getResources().getDrawable(R.drawable.photoview_placeholder));
return;
}
if (this.currentThumb != null && imageReceiver == this.centerImage) {
ImageReceiver.BitmapHolder placeHolder3 = this.currentThumb;
placeHolder = placeHolder3;
} else {
placeHolder = null;
}
imageReceiver.setImage(null, null, ImageLocation.getForDocument(fileLocation, (TLRPC.Document) media), "b", placeHolder != null ? new BitmapDrawable(placeHolder.bitmap) : null, 0, null, this.currentPage, 1);
return;
}
AnimatedFileDrawable animatedFileDrawable = this.currentAnimation;
if (animatedFileDrawable != null) {
imageReceiver.setImageBitmap(animatedFileDrawable);
this.currentAnimation.setSecondParentView(this.photoContainerView);
return;
}
return;
}
TLRPC.Photo photo = (TLRPC.Photo) media;
if (this.currentThumb != null && imageReceiver == this.centerImage) {
ImageReceiver.BitmapHolder placeHolder4 = this.currentThumb;
placeHolder2 = placeHolder4;
} else {
placeHolder2 = null;
}
if (size[0] == 0) {
size[0] = -1;
}
TLRPC.PhotoSize thumbLocation = FileLoader.getClosestPhotoSizeWithSize(photo.sizes, 80);
imageReceiver.setImage(ImageLocation.getForPhoto(fileLocation, photo), null, ImageLocation.getForPhoto(thumbLocation, photo), "b", placeHolder2 != null ? new BitmapDrawable(placeHolder2.bitmap) : null, size[0], null, this.currentPage, 1);
return;
}
if (size[0] != 0) {
imageReceiver.setImageBitmap(this.parentActivity.getResources().getDrawable(R.drawable.photoview_placeholder));
} else {
imageReceiver.setImageBitmap((Bitmap) null);
}
}
public boolean isShowingImage(TLRPC.PageBlock object) {
return this.isPhotoVisible && !this.disableShowCheck && object != null && this.currentMedia == object;
}
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 block) {
final PlaceProviderObject object;
int clipHorizontal;
if (this.pageSwitchAnimation != null || this.parentActivity == null || this.isPhotoVisible || checkPhotoAnimation() || block == null || (object = getPlaceForPhoto(block)) == 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 (block != null) {
this.currentAnimation = object.imageReceiver.getAnimation();
}
int index = this.adapter[0].photoBlocks.indexOf(block);
this.imagesArr.clear();
if (!(block instanceof TLRPC.TL_pageBlockVideo) || isVideoBlock(block)) {
this.imagesArr.addAll(this.adapter[0].photoBlocks);
} else {
this.imagesArr.add(block);
index = 0;
}
onPhotoShow(index, object);
RectF drawRegion = object.imageReceiver.getDrawRegion();
int orientation = object.imageReceiver.getOrientation();
int animatedOrientation = object.imageReceiver.getAnimatedOrientation();
if (animatedOrientation != 0) {
orientation = animatedOrientation;
}
this.animatingImageView.setVisibility(0);
this.animatingImageView.setRadius(object.radius);
this.animatingImageView.setOrientation(orientation);
this.animatingImageView.setNeedRadius(object.radius != 0);
this.animatingImageView.setImageBitmap(object.thumb);
this.animatingImageView.setAlpha(1.0f);
this.animatingImageView.setPivotX(0.0f);
this.animatingImageView.setPivotY(0.0f);
this.animatingImageView.setScaleX(object.scale);
this.animatingImageView.setScaleY(object.scale);
this.animatingImageView.setTranslationX(object.viewX + (drawRegion.left * object.scale));
this.animatingImageView.setTranslationY(object.viewY + (drawRegion.top * object.scale));
ViewGroup.LayoutParams layoutParams = this.animatingImageView.getLayoutParams();
layoutParams.width = (int) drawRegion.width();
layoutParams.height = (int) drawRegion.height();
this.animatingImageView.setLayoutParams(layoutParams);
float scaleX = AndroidUtilities.displaySize.x / layoutParams.width;
float scaleY = (AndroidUtilities.displaySize.y + AndroidUtilities.statusBarHeight) / layoutParams.height;
float scale = scaleX > scaleY ? scaleY : scaleX;
float width = layoutParams.width * scale;
float height = layoutParams.height * scale;
float xPos = (AndroidUtilities.displaySize.x - width) / 2.0f;
if (this.lastInsets != null) {
xPos += ((WindowInsets) r3).getSystemWindowInsetLeft();
}
float yPos = ((AndroidUtilities.displaySize.y + AndroidUtilities.statusBarHeight) - height) / 2.0f;
if (object.imageReceiver.isAspectFit()) {
clipHorizontal = 0;
} else {
clipHorizontal = (int) Math.abs(drawRegion.left - object.imageReceiver.getImageX());
}
int clipVertical = (int) Math.abs(drawRegion.top - object.imageReceiver.getImageY());
int[] coords2 = new int[2];
object.parentView.getLocationInWindow(coords2);
int clipTop = (int) ((coords2[1] - (object.viewY + drawRegion.top)) + object.clipTopAddition);
if (clipTop < 0) {
clipTop = 0;
}
int clipBottom = (int) ((((object.viewY + drawRegion.top) + layoutParams.height) - (coords2[1] + object.parentView.getHeight())) + object.clipBottomAddition);
if (clipBottom < 0) {
clipBottom = 0;
}
int clipTop2 = Math.max(clipTop, clipVertical);
int clipBottom2 = Math.max(clipBottom, clipVertical);
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();
this.animationValues[0][4] = clipHorizontal * object.scale;
this.animationValues[0][5] = clipTop2 * object.scale;
this.animationValues[0][6] = clipBottom2 * object.scale;
this.animationValues[0][7] = this.animatingImageView.getRadius();
this.animationValues[0][8] = clipVertical * object.scale;
this.animationValues[0][9] = clipHorizontal * object.scale;
float[] fArr = this.animationValues[1];
fArr[0] = scale;
fArr[1] = scale;
fArr[2] = xPos;
fArr[3] = yPos;
fArr[4] = 0.0f;
fArr[5] = 0.0f;
fArr[6] = 0.0f;
fArr[7] = 0.0f;
fArr[8] = 0.0f;
fArr[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.m1057lambda$openPhoto$37$imwsnshelzviuiArticleViewer();
}
};
animatorSet.setDuration(200L);
animatorSet.addListener(new AnonymousClass23());
this.photoTransitionAnimationStartTime = System.currentTimeMillis();
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
ArticleViewer.this.m1058lambda$openPhoto$38$imwsnshelzviuiArticleViewer(animatorSet);
}
});
this.photoContainerView.setLayerType(2, null);
this.photoBackgroundDrawable.drawRunnable = new Runnable() {
@Override
public final void run() {
ArticleViewer.this.m1059lambda$openPhoto$39$imwsnshelzviuiArticleViewer(object);
}
};
return true;
}
public void m1057lambda$openPhoto$37$imwsnshelzviuiArticleViewer() {
if (this.photoContainerView == null) {
return;
}
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 animation) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
ArticleViewer.AnonymousClass23.this.m1084lambda$onAnimationEnd$0$imwsnshelzviuiArticleViewer$23();
}
});
}
public void m1084lambda$onAnimationEnd$0$imwsnshelzviuiArticleViewer$23() {
NotificationCenter.getInstance(ArticleViewer.this.currentAccount).setAnimationInProgress(false);
if (ArticleViewer.this.photoAnimationEndRunnable != null) {
ArticleViewer.this.photoAnimationEndRunnable.run();
ArticleViewer.this.photoAnimationEndRunnable = null;
}
}
}
public void m1058lambda$openPhoto$38$imwsnshelzviuiArticleViewer(AnimatorSet animatorSet) {
NotificationCenter.getInstance(this.currentAccount).setAllowedNotificationsDutingAnimation(new int[]{NotificationCenter.dialogsNeedReload, NotificationCenter.closeChats});
NotificationCenter.getInstance(this.currentAccount).setAnimationInProgress(true);
animatorSet.start();
}
public void m1059lambda$openPhoto$39$imwsnshelzviuiArticleViewer(PlaceProviderObject object) {
this.disableShowCheck = false;
object.imageReceiver.setVisible(false, true);
}
public void closePhoto(boolean animated) {
int clipHorizontal;
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 object = getPlaceForPhoto(this.currentMedia);
if (animated) {
this.photoAnimationInProgress = 1;
this.animatingImageView.setVisibility(0);
this.photoContainerView.invalidate();
AnimatorSet animatorSet = new AnimatorSet();
ViewGroup.LayoutParams layoutParams = this.animatingImageView.getLayoutParams();
RectF drawRegion = null;
int orientation = this.centerImage.getOrientation();
int animatedOrientation = 0;
if (object != null && object.imageReceiver != null) {
animatedOrientation = object.imageReceiver.getAnimatedOrientation();
}
if (animatedOrientation != 0) {
orientation = animatedOrientation;
}
this.animatingImageView.setOrientation(orientation);
if (object == null) {
this.animatingImageView.setNeedRadius(false);
layoutParams.width = this.centerImage.getImageWidth();
layoutParams.height = this.centerImage.getImageHeight();
this.animatingImageView.setImageBitmap(this.centerImage.getBitmapSafe());
} else {
this.animatingImageView.setNeedRadius(object.radius != 0);
drawRegion = object.imageReceiver.getDrawRegion();
layoutParams.width = (int) drawRegion.width();
layoutParams.height = (int) drawRegion.height();
this.animatingImageView.setImageBitmap(object.thumb);
}
this.animatingImageView.setLayoutParams(layoutParams);
float scaleX = AndroidUtilities.displaySize.x / layoutParams.width;
float scaleY = (AndroidUtilities.displaySize.y + AndroidUtilities.statusBarHeight) / layoutParams.height;
float scale2 = scaleX > scaleY ? scaleY : scaleX;
float width = layoutParams.width * this.scale * scale2;
float height = layoutParams.height * this.scale * scale2;
float xPos = (AndroidUtilities.displaySize.x - width) / 2.0f;
if (this.lastInsets != null) {
xPos += ((WindowInsets) r4).getSystemWindowInsetLeft();
}
float yPos = ((AndroidUtilities.displaySize.y + AndroidUtilities.statusBarHeight) - height) / 2.0f;
this.animatingImageView.setTranslationX(this.translationX + xPos);
this.animatingImageView.setTranslationY(this.translationY + yPos);
this.animatingImageView.setScaleX(this.scale * scale2);
this.animatingImageView.setScaleY(this.scale * scale2);
if (object != null) {
object.imageReceiver.setVisible(false, true);
if (object.imageReceiver.isAspectFit()) {
clipHorizontal = 0;
} else {
clipHorizontal = (int) Math.abs(drawRegion.left - object.imageReceiver.getImageX());
}
int clipVertical = (int) Math.abs(drawRegion.top - object.imageReceiver.getImageY());
int[] coords2 = new int[2];
object.parentView.getLocationInWindow(coords2);
int clipTop = (int) ((coords2[1] - (object.viewY + drawRegion.top)) + object.clipTopAddition);
if (clipTop < 0) {
clipTop = 0;
}
int clipBottom = (int) ((((object.viewY + drawRegion.top) + (drawRegion.bottom - drawRegion.top)) - (coords2[1] + object.parentView.getHeight())) + object.clipBottomAddition);
if (clipBottom < 0) {
clipBottom = 0;
}
int clipTop2 = Math.max(clipTop, clipVertical);
int clipBottom2 = Math.max(clipBottom, clipVertical);
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;
float[] fArr2 = fArr[0];
fArr2[4] = 0.0f;
fArr2[5] = 0.0f;
fArr2[6] = 0.0f;
fArr2[7] = 0.0f;
fArr2[8] = 0.0f;
fArr2[9] = 0.0f;
fArr[1][0] = object.scale;
this.animationValues[1][1] = object.scale;
this.animationValues[1][2] = object.viewX + (drawRegion.left * object.scale);
this.animationValues[1][3] = object.viewY + (drawRegion.top * object.scale);
this.animationValues[1][4] = clipHorizontal * object.scale;
this.animationValues[1][5] = clipTop2 * object.scale;
this.animationValues[1][6] = clipBottom2 * object.scale;
this.animationValues[1][7] = object.radius;
this.animationValues[1][8] = clipVertical * object.scale;
this.animationValues[1][9] = clipHorizontal * object.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 h = 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[] fArr3 = new float[1];
fArr3[0] = this.translationY >= 0.0f ? h : -h;
animatorArr[2] = ObjectAnimator.ofFloat(clippingImageView, (Property<ClippingImageView, Float>) property, fArr3);
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.m1043lambda$closePhoto$40$imwsnshelzviuiArticleViewer(object);
}
};
animatorSet.setDuration(200L);
animatorSet.addListener(new AnonymousClass24());
this.photoTransitionAnimationStartTime = System.currentTimeMillis();
this.photoContainerView.setLayerType(2, null);
animatorSet.start();
} else {
this.photoContainerView.setVisibility(4);
this.photoContainerBackground.setVisibility(4);
this.photoAnimationInProgress = 0;
onPhotoClosed(object);
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 m1043lambda$closePhoto$40$imwsnshelzviuiArticleViewer(PlaceProviderObject object) {
this.photoContainerView.setLayerType(0, null);
this.photoContainerView.setVisibility(4);
this.photoContainerBackground.setVisibility(4);
this.photoAnimationInProgress = 0;
onPhotoClosed(object);
}
public class AnonymousClass24 extends AnimatorListenerAdapter {
AnonymousClass24() {
}
@Override
public void onAnimationEnd(Animator animation) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
ArticleViewer.AnonymousClass24.this.m1085lambda$onAnimationEnd$0$imwsnshelzviuiArticleViewer$24();
}
});
}
public void m1085lambda$onAnimationEnd$0$imwsnshelzviuiArticleViewer$24() {
if (ArticleViewer.this.photoAnimationEndRunnable != null) {
ArticleViewer.this.photoAnimationEndRunnable.run();
ArticleViewer.this.photoAnimationEndRunnable = null;
}
}
}
private void onPhotoClosed(PlaceProviderObject object) {
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 a = 0; a < 3; a++) {
RadialProgressView radialProgressView = this.radialProgressViews[a];
if (radialProgressView != null) {
radialProgressView.setBackgroundState(-1, false);
}
}
this.centerImage.setImageBitmap((Bitmap) null);
this.leftImage.setImageBitmap((Bitmap) null);
this.rightImage.setImageBitmap((Bitmap) null);
this.photoContainerView.post(new Runnable() {
@Override
public final void run() {
ArticleViewer.this.m1052lambda$onPhotoClosed$41$imwsnshelzviuiArticleViewer();
}
});
this.disableShowCheck = false;
if (object != null) {
object.imageReceiver.setVisible(true, true);
}
this.groupedPhotosListView.clear();
}
public void m1052lambda$onPhotoClosed$41$imwsnshelzviuiArticleViewer() {
this.animatingImageView.setImageBitmap(null);
}
public void onPause() {
if (this.currentAnimation != null) {
closePhoto(false);
}
}
private void updateMinMax(float scale) {
int maxW = ((int) ((this.centerImage.getImageWidth() * scale) - getContainerViewWidth())) / 2;
int maxH = ((int) ((this.centerImage.getImageHeight() * scale) - getContainerViewHeight())) / 2;
if (maxW > 0) {
this.minX = -maxW;
this.maxX = maxW;
} else {
this.maxX = 0.0f;
this.minX = 0.0f;
}
if (maxH > 0) {
this.minY = -maxH;
this.maxY = maxH;
} 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 ev) {
if (this.photoAnimationInProgress != 0 || this.animationStartTime != 0) {
return false;
}
if (ev.getPointerCount() == 1 && this.gestureDetector.onTouchEvent(ev) && this.doubleTap) {
this.doubleTap = false;
this.moving = false;
this.zooming = false;
checkMinMax(false);
return true;
}
if (ev.getActionMasked() == 0 || ev.getActionMasked() == 5) {
this.discardTap = false;
if (!this.scroller.isFinished()) {
this.scroller.abortAnimation();
}
if (!this.draggingDown && !this.changingPage) {
if (this.canZoom && ev.getPointerCount() == 2) {
this.pinchStartDistance = (float) Math.hypot(ev.getX(1) - ev.getX(0), ev.getY(1) - ev.getY(0));
this.pinchStartScale = this.scale;
this.pinchCenterX = (ev.getX(0) + ev.getX(1)) / 2.0f;
this.pinchCenterY = (ev.getY(0) + ev.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 (ev.getPointerCount() == 1) {
this.moveStartX = ev.getX();
float y = ev.getY();
this.moveStartY = y;
this.dragY = y;
this.draggingDown = false;
this.canDragDown = true;
VelocityTracker velocityTracker2 = this.velocityTracker;
if (velocityTracker2 != null) {
velocityTracker2.clear();
}
}
}
} else if (ev.getActionMasked() == 2) {
if (this.canZoom && ev.getPointerCount() == 2 && !this.draggingDown && this.zooming && !this.changingPage) {
this.discardTap = true;
this.scale = (((float) Math.hypot(ev.getX(1) - ev.getX(0), ev.getY(1) - ev.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 f = this.scale;
this.translationY = containerViewHeight - (containerViewHeight2 * (f / this.pinchStartScale));
updateMinMax(f);
this.photoContainerView.invalidate();
} else if (ev.getPointerCount() == 1) {
VelocityTracker velocityTracker3 = this.velocityTracker;
if (velocityTracker3 != null) {
velocityTracker3.addMovement(ev);
}
float dx = Math.abs(ev.getX() - this.moveStartX);
float dy = Math.abs(ev.getY() - this.dragY);
if (dx > AndroidUtilities.dp(3.0f) || dy > AndroidUtilities.dp(3.0f)) {
this.discardTap = true;
}
if (this.canDragDown && !this.draggingDown && this.scale == 1.0f && dy >= AndroidUtilities.dp(30.0f) && dy / 2.0f > dx) {
this.draggingDown = true;
this.moving = false;
this.dragY = ev.getY();
if (this.isActionBarVisible) {
toggleActionBar(false, true);
}
return true;
}
if (this.draggingDown) {
this.translationY = ev.getY() - this.dragY;
this.photoContainerView.invalidate();
} else if (!this.invalidCoords && this.animationStartTime == 0) {
float moveDx = this.moveStartX - ev.getX();
float moveDy = this.moveStartY - ev.getY();
if (this.moving || ((this.scale == 1.0f && Math.abs(moveDy) + AndroidUtilities.dp(12.0f) < Math.abs(moveDx)) || this.scale != 1.0f)) {
if (!this.moving) {
moveDx = 0.0f;
moveDy = 0.0f;
this.moving = true;
this.canDragDown = false;
}
this.moveStartX = ev.getX();
this.moveStartY = ev.getY();
updateMinMax(this.scale);
if ((this.translationX < this.minX && !this.rightImage.hasImageSet()) || (this.translationX > this.maxX && !this.leftImage.hasImageSet())) {
moveDx /= 3.0f;
}
float f2 = this.maxY;
if (f2 == 0.0f) {
float f3 = this.minY;
if (f3 == 0.0f) {
float f4 = this.translationY;
if (f4 - moveDy < f3) {
this.translationY = f3;
moveDy = 0.0f;
} else if (f4 - moveDy > f2) {
this.translationY = f2;
moveDy = 0.0f;
}
this.translationX -= moveDx;
if (this.scale != 1.0f) {
this.translationY -= moveDy;
}
this.photoContainerView.invalidate();
}
}
float f5 = this.translationY;
if (f5 < this.minY || f5 > f2) {
moveDy /= 3.0f;
}
this.translationX -= moveDx;
if (this.scale != 1.0f) {
}
this.photoContainerView.invalidate();
}
} else {
this.invalidCoords = false;
this.moveStartX = ev.getX();
this.moveStartY = ev.getY();
}
}
} else if (ev.getActionMasked() == 3 || ev.getActionMasked() == 1 || ev.getActionMasked() == 6) {
if (this.zooming) {
this.invalidCoords = true;
float f6 = this.scale;
if (f6 < 1.0f) {
updateMinMax(1.0f);
animateTo(1.0f, 0.0f, 0.0f, true);
} else if (f6 > 3.0f) {
float atx = (this.pinchCenterX - (getContainerViewWidth() / 2)) - (((this.pinchCenterX - (getContainerViewWidth() / 2)) - this.pinchStartX) * (3.0f / this.pinchStartScale));
float aty = (this.pinchCenterY - (getContainerViewHeight() / 2)) - (((this.pinchCenterY - (getContainerViewHeight() / 2)) - this.pinchStartY) * (3.0f / this.pinchStartScale));
updateMinMax(3.0f);
if (atx < this.minX) {
atx = this.minX;
} else if (atx > this.maxX) {
atx = this.maxX;
}
if (aty < this.minY) {
aty = this.minY;
} else if (aty > this.maxY) {
aty = this.maxY;
}
animateTo(3.0f, atx, aty, true);
} else {
checkMinMax(true);
}
this.zooming = false;
} else if (this.draggingDown) {
if (Math.abs(this.dragY - ev.getY()) > getContainerViewHeight() / 6.0f) {
closePhoto(true);
} else {
animateTo(1.0f, 0.0f, 0.0f, false);
}
this.draggingDown = false;
} else if (this.moving) {
float moveToX = this.translationX;
float moveToY = this.translationY;
updateMinMax(this.scale);
this.moving = false;
this.canDragDown = true;
float velocity = 0.0f;
VelocityTracker velocityTracker4 = this.velocityTracker;
if (velocityTracker4 != null && this.scale == 1.0f) {
velocityTracker4.computeCurrentVelocity(1000);
velocity = this.velocityTracker.getXVelocity();
}
if ((this.translationX < this.minX - (getContainerViewWidth() / 3) || velocity < (-AndroidUtilities.dp(650.0f))) && this.rightImage.hasImageSet()) {
goToNext();
return true;
}
if ((this.translationX > this.maxX + (getContainerViewWidth() / 3) || velocity > AndroidUtilities.dp(650.0f)) && this.leftImage.hasImageSet()) {
goToPrev();
return true;
}
float f7 = this.translationX;
if (f7 < this.minX) {
moveToX = this.minX;
} else if (f7 > this.maxX) {
moveToX = this.maxX;
}
float f8 = this.translationY;
if (f8 < this.minY) {
moveToY = this.minY;
} else if (f8 > this.maxY) {
moveToY = this.maxY;
}
animateTo(this.scale, moveToX, moveToY, false);
}
}
return false;
}
private void checkMinMax(boolean zoom) {
float moveToX = this.translationX;
float moveToY = this.translationY;
updateMinMax(this.scale);
float f = this.translationX;
if (f < this.minX) {
moveToX = this.minX;
} else if (f > this.maxX) {
moveToX = this.maxX;
}
float f2 = this.translationY;
if (f2 < this.minY) {
moveToY = this.minY;
} else if (f2 > this.maxY) {
moveToY = this.maxY;
}
animateTo(this.scale, moveToX, moveToY, zoom);
}
private void goToNext() {
float extra = 0.0f;
if (this.scale != 1.0f) {
extra = ((getContainerViewWidth() - this.centerImage.getImageWidth()) / 2) * this.scale;
}
this.switchImageAfterAnimation = 1;
animateTo(this.scale, ((this.minX - getContainerViewWidth()) - extra) - (AndroidUtilities.dp(30.0f) / 2), this.translationY, false);
}
private void goToPrev() {
float extra = 0.0f;
if (this.scale != 1.0f) {
extra = ((getContainerViewWidth() - this.centerImage.getImageWidth()) / 2) * this.scale;
}
this.switchImageAfterAnimation = 2;
animateTo(this.scale, this.maxX + getContainerViewWidth() + extra + (AndroidUtilities.dp(30.0f) / 2), this.translationY, false);
}
private void animateTo(float newScale, float newTx, float newTy, boolean isZoom) {
animateTo(newScale, newTx, newTy, isZoom, ItemTouchHelper.Callback.DEFAULT_SWIPE_ANIMATION_DURATION);
}
private void animateTo(float newScale, float newTx, float newTy, boolean isZoom, int duration) {
if (this.scale == newScale && this.translationX == newTx && this.translationY == newTy) {
return;
}
this.zoomAnimation = isZoom;
this.animateToScale = newScale;
this.animateToX = newTx;
this.animateToY = newTy;
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(duration);
this.imageMoveAnimation.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
ArticleViewer.this.imageMoveAnimation = null;
ArticleViewer.this.photoContainerView.invalidate();
}
});
this.imageMoveAnimation.start();
}
public void setAnimationValue(float value) {
this.animationValue = value;
this.photoContainerView.invalidate();
}
public float getAnimationValue() {
return this.animationValue;
}
public void drawContent(Canvas canvas) {
float currentScale;
float currentTranslationY;
float currentTranslationX;
float alpha;
int i = this.photoAnimationInProgress;
if (i != 1) {
if (!this.isPhotoVisible && i != 2) {
return;
}
float aty = -1.0f;
if (this.imageMoveAnimation != null) {
if (!this.scroller.isFinished()) {
this.scroller.abortAnimation();
}
float f = this.scale;
float f2 = this.animateToScale;
float f3 = this.animationValue;
float ts = ((f2 - f) * f3) + f;
float f4 = this.translationX;
float tx = ((this.animateToX - f4) * f3) + f4;
float f5 = this.translationY;
float ty = f5 + ((this.animateToY - f5) * f3);
if (f2 == 1.0f && f == 1.0f && f4 == 0.0f) {
aty = ty;
}
currentScale = ts;
currentTranslationY = ty;
currentTranslationX = tx;
this.photoContainerView.invalidate();
} else {
if (this.animationStartTime != 0) {
this.translationX = this.animateToX;
this.translationY = this.animateToY;
float f6 = this.animateToScale;
this.scale = f6;
this.animationStartTime = 0L;
updateMinMax(f6);
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.m1045lambda$drawContent$42$imwsnshelzviuiArticleViewer();
}
});
} else if (i2 == 2) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
ArticleViewer.this.m1046lambda$drawContent$43$imwsnshelzviuiArticleViewer();
}
});
}
this.switchImageAfterAnimation = 0;
}
currentScale = this.scale;
currentTranslationY = this.translationY;
currentTranslationX = this.translationX;
if (!this.moving) {
aty = this.translationY;
}
}
if (this.photoAnimationInProgress != 2) {
if (this.scale == 1.0f && aty != -1.0f && !this.zoomAnimation) {
float maxValue = getContainerViewHeight() / 4.0f;
this.photoBackgroundDrawable.setAlpha((int) Math.max(127.0f, (1.0f - (Math.min(Math.abs(aty), maxValue) / maxValue)) * 255.0f));
} else {
this.photoBackgroundDrawable.setAlpha(255);
}
}
ImageReceiver sideImage = null;
if (this.scale >= 1.0f && !this.zoomAnimation && !this.zooming) {
if (currentTranslationX > this.maxX + AndroidUtilities.dp(5.0f)) {
sideImage = this.leftImage;
} else if (currentTranslationX < this.minX - AndroidUtilities.dp(5.0f)) {
sideImage = this.rightImage;
} else {
this.groupedPhotosListView.setMoveProgress(0.0f);
}
}
this.changingPage = sideImage != null;
if (sideImage == this.rightImage) {
float tranlateX = currentTranslationX;
float scaleDiff = 0.0f;
if (!this.zoomAnimation) {
float f7 = this.minX;
if (tranlateX < f7) {
float alpha2 = Math.min(1.0f, (f7 - tranlateX) / canvas.getWidth());
scaleDiff = (1.0f - alpha2) * 0.3f;
tranlateX = (-canvas.getWidth()) - (AndroidUtilities.dp(30.0f) / 2);
alpha = alpha2;
if (!sideImage.hasBitmapImage()) {
canvas.save();
canvas.translate(getContainerViewWidth() / 2, getContainerViewHeight() / 2);
canvas.translate(canvas.getWidth() + (AndroidUtilities.dp(30.0f) / 2) + tranlateX, 0.0f);
canvas.scale(1.0f - scaleDiff, 1.0f - scaleDiff);
int bitmapWidth = sideImage.getBitmapWidth();
int bitmapHeight = sideImage.getBitmapHeight();
float scaleX = getContainerViewWidth() / bitmapWidth;
float scaleY = getContainerViewHeight() / bitmapHeight;
float scale = scaleX > scaleY ? scaleY : scaleX;
int width = (int) (bitmapWidth * scale);
int height = (int) (bitmapHeight * scale);
sideImage.setAlpha(alpha);
sideImage.setImageCoords((-width) / 2, (-height) / 2, width, height);
sideImage.draw(canvas);
canvas.restore();
}
this.groupedPhotosListView.setMoveProgress(-alpha);
canvas.save();
canvas.translate(tranlateX, currentTranslationY / currentScale);
canvas.translate(((canvas.getWidth() * (this.scale + 1.0f)) + AndroidUtilities.dp(30.0f)) / 2.0f, (-currentTranslationY) / currentScale);
this.radialProgressViews[1].setScale(1.0f - scaleDiff);
this.radialProgressViews[1].setAlpha(alpha);
this.radialProgressViews[1].onDraw(canvas);
canvas.restore();
}
}
alpha = 1.0f;
if (!sideImage.hasBitmapImage()) {
}
this.groupedPhotosListView.setMoveProgress(-alpha);
canvas.save();
canvas.translate(tranlateX, currentTranslationY / currentScale);
canvas.translate(((canvas.getWidth() * (this.scale + 1.0f)) + AndroidUtilities.dp(30.0f)) / 2.0f, (-currentTranslationY) / currentScale);
this.radialProgressViews[1].setScale(1.0f - scaleDiff);
this.radialProgressViews[1].setAlpha(alpha);
this.radialProgressViews[1].onDraw(canvas);
canvas.restore();
}
float translateX = currentTranslationX;
float scaleDiff2 = 0.0f;
float alpha3 = 1.0f;
if (!this.zoomAnimation) {
float f8 = this.maxX;
if (translateX > f8) {
float alpha4 = Math.min(1.0f, (translateX - f8) / canvas.getWidth());
scaleDiff2 = alpha4 * 0.3f;
alpha3 = 1.0f - alpha4;
translateX = this.maxX;
}
}
AspectRatioFrameLayout aspectRatioFrameLayout = this.aspectRatioFrameLayout;
boolean drawTextureView = aspectRatioFrameLayout != null && aspectRatioFrameLayout.getVisibility() == 0;
if (this.centerImage.hasBitmapImage()) {
canvas.save();
canvas.translate(getContainerViewWidth() / 2, getContainerViewHeight() / 2);
canvas.translate(translateX, currentTranslationY);
canvas.scale(currentScale - scaleDiff2, currentScale - scaleDiff2);
int bitmapWidth2 = this.centerImage.getBitmapWidth();
int bitmapHeight2 = this.centerImage.getBitmapHeight();
if (drawTextureView && this.textureUploaded) {
float scale1 = bitmapWidth2 / bitmapHeight2;
float scale2 = this.videoTextureView.getMeasuredWidth() / this.videoTextureView.getMeasuredHeight();
if (Math.abs(scale1 - scale2) > 0.01f) {
bitmapWidth2 = this.videoTextureView.getMeasuredWidth();
bitmapHeight2 = this.videoTextureView.getMeasuredHeight();
}
}
float scaleX2 = getContainerViewWidth() / bitmapWidth2;
float scaleY2 = getContainerViewHeight() / bitmapHeight2;
float scale3 = scaleX2 > scaleY2 ? scaleY2 : scaleX2;
int width2 = (int) (bitmapWidth2 * scale3);
int height2 = (int) (bitmapHeight2 * scale3);
if (drawTextureView && this.textureUploaded && this.videoCrossfadeStarted && this.videoCrossfadeAlpha == 1.0f) {
if (drawTextureView) {
if (!this.videoCrossfadeStarted && this.textureUploaded) {
this.videoCrossfadeStarted = true;
this.videoCrossfadeAlpha = 0.0f;
this.videoCrossfadeAlphaLastTime = System.currentTimeMillis();
}
canvas.translate((-width2) / 2, (-height2) / 2);
this.videoTextureView.setAlpha(this.videoCrossfadeAlpha * alpha3);
this.aspectRatioFrameLayout.draw(canvas);
if (this.videoCrossfadeStarted && this.videoCrossfadeAlpha < 1.0f) {
long newUpdateTime = System.currentTimeMillis();
long dt = newUpdateTime - this.videoCrossfadeAlphaLastTime;
this.videoCrossfadeAlphaLastTime = newUpdateTime;
this.videoCrossfadeAlpha += ((float) dt) / 300.0f;
this.photoContainerView.invalidate();
if (this.videoCrossfadeAlpha > 1.0f) {
this.videoCrossfadeAlpha = 1.0f;
}
}
}
canvas.restore();
}
this.centerImage.setAlpha(alpha3);
this.centerImage.setImageCoords((-width2) / 2, (-height2) / 2, width2, height2);
this.centerImage.draw(canvas);
if (drawTextureView) {
}
canvas.restore();
}
if (!drawTextureView && this.bottomLayout.getVisibility() != 0) {
canvas.save();
canvas.translate(translateX, currentTranslationY / currentScale);
this.radialProgressViews[0].setScale(1.0f - scaleDiff2);
this.radialProgressViews[0].setAlpha(alpha3);
this.radialProgressViews[0].onDraw(canvas);
canvas.restore();
}
if (sideImage == this.leftImage) {
if (sideImage.hasBitmapImage()) {
canvas.save();
canvas.translate(getContainerViewWidth() / 2, getContainerViewHeight() / 2);
canvas.translate(((-((canvas.getWidth() * (this.scale + 1.0f)) + AndroidUtilities.dp(30.0f))) / 2.0f) + currentTranslationX, 0.0f);
int bitmapWidth3 = sideImage.getBitmapWidth();
int bitmapHeight3 = sideImage.getBitmapHeight();
float scaleX3 = getContainerViewWidth() / bitmapWidth3;
float scaleY3 = getContainerViewHeight() / bitmapHeight3;
float scale4 = scaleX3 > scaleY3 ? scaleY3 : scaleX3;
int width3 = (int) (bitmapWidth3 * scale4);
int height3 = (int) (bitmapHeight3 * scale4);
sideImage.setAlpha(1.0f);
sideImage.setImageCoords((-width3) / 2, (-height3) / 2, width3, height3);
sideImage.draw(canvas);
canvas.restore();
}
this.groupedPhotosListView.setMoveProgress(1.0f - alpha3);
canvas.save();
canvas.translate(currentTranslationX, currentTranslationY / currentScale);
canvas.translate((-((canvas.getWidth() * (this.scale + 1.0f)) + AndroidUtilities.dp(30.0f))) / 2.0f, (-currentTranslationY) / currentScale);
this.radialProgressViews[2].setScale(1.0f);
this.radialProgressViews[2].setAlpha(1.0f);
this.radialProgressViews[2].onDraw(canvas);
canvas.restore();
}
}
}
public void m1045lambda$drawContent$42$imwsnshelzviuiArticleViewer() {
setImageIndex(this.currentIndex + 1, false);
}
public void m1046lambda$drawContent$43$imwsnshelzviuiArticleViewer() {
setImageIndex(this.currentIndex - 1, false);
}
private void onActionClick(boolean download) {
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 && (file = getMediaFile(this.currentIndex)) != null && !file.exists()) {
file = null;
}
if (file == null) {
if (download) {
if (!FileLoader.getInstance(this.currentAccount).isLoadingFile(this.currentFileNames[0])) {
FileLoader.getInstance(this.currentAccount).loadFile(document, this.currentPage, 1, 1);
return;
} else {
FileLoader.getInstance(this.currentAccount).cancelLoadFile(document);
return;
}
}
return;
}
preparePlayer(file, true);
}
@Override
public boolean onDown(MotionEvent e) {
return false;
}
@Override
public void onShowPress(MotionEvent e) {
}
@Override
public boolean onSingleTapUp(MotionEvent e) {
return false;
}
@Override
public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
return false;
}
@Override
public void onLongPress(MotionEvent e) {
}
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
if (this.scale != 1.0f) {
this.scroller.abortAnimation();
this.scroller.fling(Math.round(this.translationX), Math.round(this.translationY), Math.round(velocityX), Math.round(velocityY), (int) this.minX, (int) this.maxX, (int) this.minY, (int) this.maxY);
this.photoContainerView.postInvalidate();
return false;
}
return false;
}
@Override
public boolean onSingleTapConfirmed(MotionEvent e) {
int state;
if (this.discardTap) {
return false;
}
AspectRatioFrameLayout aspectRatioFrameLayout = this.aspectRatioFrameLayout;
boolean drawTextureView = aspectRatioFrameLayout != null && aspectRatioFrameLayout.getVisibility() == 0;
RadialProgressView radialProgressView = this.radialProgressViews[0];
if (radialProgressView != null && this.photoContainerView != null && !drawTextureView && (state = radialProgressView.backgroundState) > 0 && state <= 3) {
float x = e.getX();
float y = e.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 e) {
if (this.canZoom) {
float f = this.scale;
if ((f == 1.0f && (this.translationY != 0.0f || this.translationX != 0.0f)) || this.animationStartTime != 0 || this.photoAnimationInProgress != 0) {
return false;
}
if (f == 1.0f) {
float atx = (e.getX() - (getContainerViewWidth() / 2)) - (((e.getX() - (getContainerViewWidth() / 2)) - this.translationX) * (3.0f / this.scale));
float aty = (e.getY() - (getContainerViewHeight() / 2)) - (((e.getY() - (getContainerViewHeight() / 2)) - this.translationY) * (3.0f / this.scale));
updateMinMax(3.0f);
if (atx < this.minX) {
atx = this.minX;
} else if (atx > this.maxX) {
atx = this.maxX;
}
if (aty < this.minY) {
aty = this.minY;
} else if (aty > this.maxY) {
aty = this.maxY;
}
animateTo(3.0f, atx, aty, true);
} else {
animateTo(1.0f, 0.0f, 0.0f, true);
}
this.doubleTap = true;
return true;
}
return false;
}
@Override
public boolean onDoubleTapEvent(MotionEvent e) {
return false;
}
private ImageReceiver getImageReceiverView(View view, TLRPC.PageBlock pageBlock, int[] coords) {
ImageReceiver imageReceiver;
ImageReceiver imageReceiver2;
if (view instanceof BlockPhotoCell) {
BlockPhotoCell cell = (BlockPhotoCell) view;
if (cell.currentBlock == pageBlock) {
view.getLocationInWindow(coords);
return cell.imageView;
}
return null;
}
if (view instanceof BlockVideoCell) {
BlockVideoCell cell2 = (BlockVideoCell) view;
if (cell2.currentBlock == pageBlock) {
view.getLocationInWindow(coords);
return cell2.imageView;
}
return null;
}
if (view instanceof BlockCollageCell) {
ImageReceiver imageReceiver3 = getImageReceiverFromListView(((BlockCollageCell) view).innerListView, pageBlock, coords);
if (imageReceiver3 != null) {
return imageReceiver3;
}
return null;
}
if (view instanceof BlockSlideshowCell) {
ImageReceiver imageReceiver4 = getImageReceiverFromListView(((BlockSlideshowCell) view).innerListView, pageBlock, coords);
if (imageReceiver4 != null) {
return imageReceiver4;
}
return null;
}
if (view instanceof BlockListItemCell) {
BlockListItemCell blockListItemCell = (BlockListItemCell) view;
if (blockListItemCell.blockLayout != null && (imageReceiver2 = getImageReceiverView(blockListItemCell.blockLayout.itemView, pageBlock, coords)) != null) {
return imageReceiver2;
}
return null;
}
if (view instanceof BlockOrderedListItemCell) {
BlockOrderedListItemCell blockOrderedListItemCell = (BlockOrderedListItemCell) view;
if (blockOrderedListItemCell.blockLayout != null && (imageReceiver = getImageReceiverView(blockOrderedListItemCell.blockLayout.itemView, pageBlock, coords)) != null) {
return imageReceiver;
}
return null;
}
return null;
}
private ImageReceiver getImageReceiverFromListView(ViewGroup listView, TLRPC.PageBlock pageBlock, int[] coords) {
int count = listView.getChildCount();
for (int a = 0; a < count; a++) {
ImageReceiver imageReceiver = getImageReceiverView(listView.getChildAt(a), pageBlock, coords);
if (imageReceiver != null) {
return imageReceiver;
}
}
return null;
}
private PlaceProviderObject getPlaceForPhoto(TLRPC.PageBlock pageBlock) {
ImageReceiver imageReceiver = getImageReceiverFromListView(this.listView[0], pageBlock, this.coords);
if (imageReceiver == null) {
return null;
}
PlaceProviderObject object = new PlaceProviderObject();
object.viewX = this.coords[0];
object.viewY = this.coords[1];
object.parentView = this.listView[0];
object.imageReceiver = imageReceiver;
object.thumb = imageReceiver.getBitmapSafe();
object.radius = imageReceiver.getRoundRadius();
object.clipTopAddition = this.currentHeaderHeight;
return object;
}
}