gt:         if (mediaMetadataRetriever == null) {
context: /*
   * This is the source code of Telegram for Android v. 5.x.x.
   * It is licensed under GNU GPL v. 2 or later.
   * You should have received a copy of the license in this archive (see LICENSE).
   *
   * Copyright Nikolai Kudashov, 2013-2018.
   */
  
  package org.telegram.ui.Components;
  
  import android.annotation.TargetApi;
  import android.content.Context;
  import android.graphics.Bitmap;
  import android.graphics.Canvas;
  import android.graphics.Paint;
  import android.graphics.Rect;
  import android.media.MediaMetadataRetriever;
  import android.os.AsyncTask;
  import android.view.MotionEvent;
  import android.view.View;
  
  import org.telegram.messenger.AndroidUtilities;
  import org.telegram.messenger.FileLog;
  
  import java.util.ArrayList;
  
  @TargetApi(10)
  public class VideoTimelineView extends View {
  
      private long videoLength;
      private float progressLeft;
      private float progressRight = 1;
      private Paint paint;
      private Paint paint2;
      private boolean pressedLeft;
      private boolean pressedRight;
      private float pressDx;
      private MediaMetadataRetriever mediaMetadataRetriever;
      private VideoTimelineViewDelegate delegate;
      private ArrayList<Bitmap> frames = new ArrayList<>();
      private AsyncTask<Integer, Integer, Bitmap> currentTask;
      private static final Object sync = new Object();
      private long frameTimeOffset;
      private int frameWidth;
      private int frameHeight;
      private int framesToLoad;
      private float maxProgressDiff = 1.0f;
      private float minProgressDiff = 0.0f;
      private boolean isRoundFrames;
      private Rect rect1;
      private Rect rect2;
  
      public interface VideoTimelineViewDelegate {
          void onLeftProgressChanged(float progress);
          void onRightProgressChanged(float progress);
          void didStartDragging();
          void didStopDragging();
      }
  
      public VideoTimelineView(Context context) {
          super(context);
          paint = new Paint(Paint.ANTI_ALIAS_FLAG);
          paint.setColor(0xffffffff);
          paint2 = new Paint();
          paint2.setColor(0x7f000000);
      }
  
      public float getLeftProgress() {
          return progressLeft;
      }
  
      public float getRightProgress() {
          return progressRight;
      }
  
      public void setMinProgressDiff(float value) {
          minProgressDiff = value;
      }
  
      public void setMaxProgressDiff(float value) {
          maxProgressDiff = value;
          if (progressRight - progressLeft > maxProgressDiff) {
              progressRight = progressLeft + maxProgressDiff;
              invalidate();
          }
      }
  
      public void setRoundFrames(boolean value) {
          isRoundFrames = value;
          if (isRoundFrames) {
              rect1 = new Rect(AndroidUtilities.dp(14), AndroidUtilities.dp(14), AndroidUtilities.dp(14 + 28), AndroidUtilities.dp(14 + 28));
              rect2 = new Rect();
          }
      }
  
      @Override
      public boolean onTouchEvent(MotionEvent event) {
          if (event == null) {
              return false;
          }
          float x = event.getX();
          float y = event.getY();
  
          int width = getMeasuredWidth() - AndroidUtilities.dp(32);
          int startX = (int) (width * progressLeft) + AndroidUtilities.dp(16);
          int endX = (int) (width * progressRight) + AndroidUtilities.dp(16);
  
          if (event.getAction() == MotionEvent.ACTION_DOWN) {
              getParent().requestDisallowInterceptTouchEvent(true);
              if (mediaMetadataRetriever == null) {
                  return false;
              }
              int additionWidth = AndroidUtilities.dp(12);
              if (startX - additionWidth <= x && x <= startX + additionWidth && y >= 0 && y <= getMeasuredHeight()) {
                  if (delegate != null) {
                      delegate.didStartDragging();
                  }
                  pressedLeft = true;
                  pressDx = (int) (x - startX);
                  invalidate();
                  return true;
              } else if (endX - additionWidth <= x && x <= endX + additionWidth && y >= 0 && y <= getMeasuredHeight()) {
                  if (delegate != null) {
                      delegate.didStartDragging();
                  }
                  pressedRight = true;
                  pressDx = (int) (x - endX);
                  invalidate();
                  return true;
              }
          } else if (event.getAction() == MotionEvent.ACTION_UP || event.getAction() == MotionEvent.ACTION_CANCEL) {
              if (pressedLeft) {
                  if (delegate != null) {
                      delegate.didStopDragging();
                  }
                  pressedLeft = false;
                  return true;
              } else if (pressedRight) {
                  if (delegate != null) {
                      delegate.didStopDragging();
                  }
                  pressedRight = false;
                  return true;
              }
          } else if (event.getAction() == MotionEvent.ACTION_MOVE) {
              if (pressedLeft) {
                  startX = (int) (x - pressDx);
                  if (startX < AndroidUtilities.dp(16)) {
                      startX = AndroidUtilities.dp(16);
                  } else if (startX > endX) {
                      startX = endX;
                  }
                  progressLeft = (float) (startX - AndroidUtilities.dp(16)) / (float) width;
                  if (progressRight - progressLeft > maxProgressDiff) {
                      progressRight = progressLeft + maxProgressDiff;
                  } else if (minProgressDiff != 0 && progressRight - progressLeft < minProgressDiff) {
                      progressLeft = progressRight - minProgressDiff;
                      if (progressLeft < 0) {
                          progressLeft = 0;
                      }
                  }
                  if (delegate != null) {
                      delegate.onLeftProgressChanged(progressLeft);
                  }
                  invalidate();
                  return true;
              } else if (pressedRight) {
                  endX = (int) (x - pressDx);
                  if (endX < startX) {
                      endX = startX;
                  } else if (endX > width + AndroidUtilities.dp(16)) {
                      endX = width + AndroidUtilities.dp(16);
                  }
                  progressRight = (float) (endX - AndroidUtilities.dp(16)) / (float) width;
                  if (progressRight - progressLeft > maxProgressDiff) {
                      progressLeft = progressRight - maxProgressDiff;
                  } else if (minProgressDiff != 0 && progressRight - progressLeft < minProgressDiff) {
                      progressRight = progressLeft + minProgressDiff;
                      if (progressRight > 1.0f) {
                          progressRight = 1.0f;
                      }
                  }
                  if (delegate != null) {
                      delegate.onRightProgressChanged(progressRight);
                  }
                  invalidate();
                  return true;
              }
          }
          return false;
      }
  
      public void setColor(int color) {
          paint.setColor(color);
      }
  
      public void setVideoPath(String path) {
          destroy();
          mediaMetadataRetriever = new MediaMetadataRetriever();
          progressLeft = 0.0f;
          progressRight = 1.0f;
          try {
              mediaMetadataRetriever.setDataSource(path);
              String duration = mediaMetadataRetriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION);
              videoLength = Long.parseLong(duration);
          } catch (Exception e) {
              FileLog.e(e);
          }
          invalidate();
      }
  
      public void setDelegate(VideoTimelineViewDelegate delegate) {
          this.delegate = delegate;
      }
  
      private void reloadFrames(int frameNum) {
  