NVRTimePlaybackNewFragment.java 源代码


package main.NVR.timeaxis;

import android.content.Context;
import android.content.Intent;
import android.content.res.Configuration;
import android.graphics.Bitmap;
import android.graphics.Point;
import android.graphics.drawable.ColorDrawable;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.support.v4.view.ViewPager;
import android.text.TextUtils;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListAdapter;
import android.widget.PopupWindow;
import android.widget.RadioButton;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import base.HiFragment;
import bean.MyCamera;
import butterknife.ButterKnife;
import com.bytedance.sdk.openadsdk.mediation.MediationConstant;
import com.dasu.blur.DBlur;
import com.dasu.blur.OnBlurListener;
import com.hichip.NVR.HiNVRDev;
import com.hichip.NVR.callback.INVRPlayStateCallback;
import com.hichip.NVR.callback.PlayLocalNVRFileCallback;
import com.hichip.NVR.content.HiChipNVRDefines;
import com.hichip.base.HiLog;
import com.hichip.callback.ICameraIOSessionCallback;
import com.hichip.callback.ICameraPlayStateCallback;
import com.hichip.campro.R;
import com.hichip.content.HiChipDefines;
import com.hichip.control.HiCamera;
import com.hichip.tools.Packet;
import com.meizu.cloud.pushsdk.constants.PushConstants;
import com.xiaomi.mipush.sdk.Constants;
import common.Constant;
import common.HiDataValue;
import common.MyPlaybackGLMonitor;
import custom.NoSlidingViewPager;
import java.io.File;
import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import main.MainActivity;
import main.NVR.View.TimeLineNVR;
import main.NVR.bean.NVRVideoList;
import main.NVR.bean.PlaybackNvrVo;
import main.NVR.timeaxis.NVRTimePlaybackNewFragment;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import service.DeleteNVRCacheFileService;
import timeaxis.bean.FilePlaybackModel;
import timeaxis.bean.MsyIsStop;
import timeaxis.bean.ResetSizeModel;
import timeaxis.calender.MsgCalenderDay;
import timeaxis.calender.MyLinearLayout;
import timeaxis.calender.MyPagerAdapter;
import timeaxis.calender.TitleGridAdapter;
import timeaxis.view.TimeLineNew;
import utils.FileSizeUtils;
import utils.HiLogcatUtil;
import utils.HiTools;
import utils.LiuHaiScreenTools;
import utils.MyToast;
import utils.OrientationWatchDog;
import utils.SharePreUtils;
import utils.SystemUtils;
import utils.TimeUtil;

public class NVRTimePlaybackNewFragment extends HiFragment implements ICameraIOSessionCallback, ICameraPlayStateCallback, INVRPlayStateCallback, PlayLocalNVRFileCallback, View.OnTouchListener, View.OnClickListener, OrientationWatchDog.OnOrientationListener {
    private static final int HANDLE_MESSAGE_FastFILE_LOADENDINFO = -2147483645;
    private static final int HANDLE_MESSAGE_PLAYLOCAL_STATE_ING = -1879048187;
    private static final int HANDLE_MESSAGE_PLAYLOCAL_STATE_STOP = -1879048186;
    private static final int HANDLE_MESSAGE_PLAYONLINE_DISLOADVIEW = 1879048194;
    private static final int HANDLE_MESSAGE_PLAYONLINE_LODING = -1879048159;
    private static final int HANDLE_MESSAGE_PLAYONLINE_OPENFAIL = -1879048160;
    private static final int HANDLE_MESSAGE_PLAYONLINE_OPENFILE = -1879048167;
    private static final int HANDLE_MESSAGE_PLAYONLINE_PLAYING = -1879048158;
    private static final int HANDLE_MESSAGE_PLAYONLINE_SHOWLOADVIEW = 1879048193;
    private static final int HANDLE_MESSAGE_PROGRESSBAR_RUN = -1879048186;
    private static final int HANDLE_MESSAGE_SEEKBAR_END = -1879048188;
    private static final int HANDLE_MESSAGE_SEEKBAR_RUN = -1879048189;
    private static final int HANDLE_MESSAGE_SEEKBAR_START = -1879048190;
    private static final int HANDLE_VIDEO_RUN = -1879048183;
    public static int mMonth;
    public static int mYear;
    private long FilePlayStartTime;
    private int PictureRealHeight;
    private int PictureRealWidth;
    private float action_down_x;
    private float action_down_y;
    public float bottom;
    ImageView bt_landdualswitch;
    private int currentPlayPosition;
    private long currentPlayVideoStartTime;
    boolean currentTypeIs2;
    private String download_path;
    private int dragTime;
    private String fileName;
    int fileType;
    private long firstVideoStartTime;
    public float height;
    private boolean isCalenderChangedMonth;
    private boolean isNeedShowProgress;
    private boolean isOtherDay;
    private boolean isQuit;
    ImageView iv_adaption;
    ImageView iv_full_screen;
    ImageView iv_left;
    ImageView iv_placeholder;
    ImageView iv_return;
    ImageView iv_right;
    ImageView iv_snapshot;
    ImageView iv_snapshot_land;
    private long lastClickTime;
    float lastX;
    float lastY;
    public float left;
    MyLinearLayout ll_bottom;
    LinearLayout ll_top;
    private boolean loadingViewIsShowing;
    private NVRTimeAxisActivity mAct;
    private int mHeight;
    private boolean mIsDataReceveEnd;
    ImageView mIvLoading;
    HiChipNVRDefines.PLATFORM_S_MONTHPLAYBACKFILE_REP mMonthfile;
    private MyCamera mMyCamera;
    private OrientationWatchDog mOrientationWatchDog;
    private PopupWindow mPopupWindow;
    private HiChipDefines.STimeDay mSaveSTimeDay;
    public MyPlaybackGLMonitor monitor;
    int moveX;
    int moveY;
    float move_x;
    float move_y;
    private PlaybackNvrVo msavepVo;
    TimeLineNVR myTimeLineView;
    private int nearVideoDay;
    private boolean noFileNeedJump;
    private MyPagerAdapter pagerAdapter;
    private long playingFileDevStartTime;
    private int playingFilePosition;
    private boolean preLoadingFile;
    private int preModle;
    RadioButton rb_alarm;
    RadioButton rb_all;
    private int recentHaveVideoDay;
    RelativeLayout rl_head;
    RelativeLayout rl_monitor;
    public LinearLayout root_lock_screen;
    private HiChipDefines.SD_FILEDAY sd_fileday;
    View shadowView;
    LinearLayout stc_calendar_layout;
    private NVRTimeAxisActivity timeAxisActivity;
    public boolean timePlayStart;
    private GridView title_gView;
    private boolean todayHasVideo;
    private TextView tvAdaption;
    private TextView tvFill;
    TextView tvSpeed;
    TextView tv_time;
    TextView tv_years_month;
    private boolean videoIsPause;
    private boolean videoIsPlaying;
    private PopupWindow videoSpeedPopupWindow;
    private int video_height;
    private int video_width;
    private View view;
    NoSlidingViewPager viewpager;
    public float width;
    int xlenOld;
    int ylenOld;
    private boolean isDrag = false;
    private int setpos = 0;
    private long oldTime = 0;
    private long savetime = 0;
    private long previousStartTime = 0;
    private long previousEndTime = 0;
    private long mergeStartTime = 0;
    private long mergeEndTime = 0;
    long mergeStartTime1 = 0;
    long mergeEndTime1 = 0;
    private List<Integer> alreadyGetVideoDay = new ArrayList();
    private List<PlaybackNvrVo> file_list = new ArrayList();
    private List<PlaybackNvrVo> file_list1 = new ArrayList();
    private List<Integer> allHaveVideoDayList = new ArrayList();
    private List<Integer> otherMonthAllHaveVideoDayList = new ArrayList();
    private List<NVRVideoList> videoLists = new ArrayList();
    private List<NVRVideoList> videoLists1 = new ArrayList();
    private List<PlaybackNvrVo> one_day_file_list = new ArrayList();
    private List<PlaybackNvrVo> curentDayVideo = new ArrayList();
    private List<NVRVideoList> videoLists2 = new ArrayList();
    private Calendar calStartDate = Calendar.getInstance();
    private int currPager = 999;
    private int perPager = 999;
    private int mSelectPosition = -1;
    private long mTimeInMicros = 0;
    private int mPictureSize = 0;
    private boolean isLeft = true;
    private boolean isFirstRevolveLand = false;
    private boolean isReadyPlay = false;
    private int isLarge = 0;
    public boolean mIsClickReturn = false;
    double nLenStart = 0.0d;
    private int mSpeed = 0;
    private boolean mIsEnd = false;
    private String loadingFile = "";
    private boolean fileisDowned = false;
    private int mdownLoadNextFileTime = 50000;
    private long subtime = 0;
    private boolean firstPlay = true;
    private boolean firstPlayDayVideo = true;
    private boolean isPlayEnd = false;
    private int chn = 0;
    String mstrdate = "";
    int mgetvideotype = 254;
    int StreamType = 0;
    private int mSavedragTime = 0;
    private boolean mIsCallStop = false;
    private boolean mIsVisibleToUser = true;
    private boolean isFirstIn = true;
    private boolean isCallStopDown = false;
    private boolean mIsPlayback = false;
    private boolean mIsResetSize = false;
    private boolean mBackToNoFile = false;
    private Handler lineHandler = new Handler() {
        @Override
        public void handleMessage(Message message) {
            if (message.what == -1879048183 && NVRTimePlaybackNewFragment.this.myTimeLineView.isCanPlay) {
                if (NVRTimePlaybackNewFragment.this.tv_time.getVisibility() == 0) {
                    NVRTimePlaybackNewFragment.this.tv_time.setVisibility(8);
                }
                if (!NVRTimePlaybackNewFragment.this.mIsVisibleToUser) {
                    if (NVRTimePlaybackNewFragment.this.mMyCamera != null) {
                        if (NVRTimePlaybackNewFragment.this.myTimeLineView != null) {
                            HiLog.e("tedG--....()....--" + NVRTimePlaybackNewFragment.this.mTimeInMicros + ";;;;");
                            NVRTimePlaybackNewFragment nVRTimePlaybackNewFragment = NVRTimePlaybackNewFragment.this;
                            nVRTimePlaybackNewFragment.mTimeInMicros = nVRTimePlaybackNewFragment.myTimeLineView.getCurrentValue();
                            HiLog.e("tedG--....()....--" + NVRTimePlaybackNewFragment.this.mTimeInMicros + ";;;;");
                        }
                        if (NVRTimePlaybackNewFragment.this.videoIsPause || !NVRTimePlaybackNewFragment.this.videoIsPlaying) {
                            return;
                        }
                        NVRTimePlaybackNewFragment.this.pausePlayVideo();
                        NVRTimePlaybackNewFragment.this.videoIsPause = true;
                        NVRTimePlaybackNewFragment.this.videoIsPlaying = false;
                        return;
                    }
                    return;
                }
                NVRTimePlaybackNewFragment.this.myTimeLineView.setValue(NVRTimePlaybackNewFragment.this.firstVideoStartTime + Long.parseLong(message.arg1 + "000000"));
                if (NVRTimePlaybackNewFragment.this.timePlayStart) {
                    return;
                }
                NVRTimePlaybackNewFragment.this.timePlayStart = true;
            }
        }
    };
    private Handler handler = new AnonymousClass12();
    private Handler mHandler_lockScreen = new Handler() {
        @Override
        public void handleMessage(Message message) {
            if (message.what == 0) {
                NVRTimePlaybackNewFragment.this.root_lock_screen.setVisibility(0);
                NVRTimePlaybackNewFragment.this.mHandler_lockScreen.sendEmptyMessageDelayed(1, 3000L);
            } else {
                NVRTimePlaybackNewFragment.this.root_lock_screen.setVisibility(8);
                NVRTimePlaybackNewFragment.this.mHandler_lockScreen.removeCallbacksAndMessages(null);
            }
        }
    };
    private Handler mhandlerPF = new AnonymousClass22();

    private byte[] longToByteArray_little(long j) {
        return new byte[]{(byte) j, (byte) (j >>> 8), (byte) (j >>> 16), (byte) (j >>> 24)};
    }

    @Override
    public void callbackPlayUTC(HiNVRDev hiNVRDev, int i, int i2) {
    }

    @Override
    public void callbackPlayUTC2(HiCamera hiCamera, int i, int i2) {
    }

    @Override
    public void callbackRecordState(HiNVRDev hiNVRDev, int i, int i2, int i3, int i4, String str) {
    }

    @Override
    public void callbackRecordState(HiCamera hiCamera, int i, int i2, int i3, String str) {
    }

    @Override
    public void callbackRecordStateDual(HiCamera hiCamera, int i, int i2, int i3, int i4, String str) {
    }

    @Override
    public void callbackState(HiNVRDev hiNVRDev, int i, int i2, int i3, int i4) {
    }

    @Override
    public void onAttach(Context context) {
        super.onAttach(context);
        HiLog.e("tedG--....onResume()....--");
        this.mAct = (NVRTimeAxisActivity) context;
    }

    @Override
    public void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        HiLog.e("tedG--....onResume()....--");
        EventBus.getDefault().register(this);
    }

    @Override
    public View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
        HiLog.e("tedG--....onResume()....--");
        this.view = layoutInflater.inflate(R.layout.fragment_nvrtime_playback, (ViewGroup) null);
        getActivity().getWindow().addFlags(128);
        ButterKnife.bind(this, this.view);
        getIntentData();
        initViewAndData();
        initViewPager();
        setListeners();
        initOrientationWatchdog();
        initPBFast(this.mMyCamera);
        searchmonvideo();
        return this.view;
    }

    private void checkPBFastCacheSize() {
        if (getActivity() != null && Double.valueOf(FileSizeUtils.getFileOrFilesSize(HiDataValue.getPathCameraVideoOnLineNVR(getActivity()), 3)).compareTo(Double.valueOf(HiDataValue.DelCacheMax)) > 0) {
            Intent intent = new Intent(getActivity(), (Class<?>) DeleteNVRCacheFileService.class);
            intent.putExtra("PBFast", true);
            intent.putExtra("PBFastuid", this.mMyCamera.getUid());
            getActivity().startService(intent);
        }
    }

    private void setListeners() {
        this.iv_adaption.setOnClickListener(this);
        this.iv_full_screen.setOnClickListener(this);
        this.iv_left.setOnClickListener(this);
        this.iv_right.setOnClickListener(this);
        this.monitor.setOnClickListener(this);
        this.monitor.setOnTouchListener(this);
        this.iv_return.setOnClickListener(this);
        this.shadowView.setOnClickListener(this);
        this.root_lock_screen.setOnClickListener(this);
        this.tvSpeed.setOnClickListener(this);
        this.viewpager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
            @Override
            public void onPageScrollStateChanged(int i) {
            }

            @Override
            public void onPageScrolled(int i, float f, int i2) {
            }

            @Override
            public void onPageSelected(int i) {
                NVRTimePlaybackNewFragment.this.calStartDate.add(2, i - NVRTimePlaybackNewFragment.this.perPager);
                NVRTimePlaybackNewFragment.this.calStartDate.set(5, 1);
                NVRTimePlaybackNewFragment nVRTimePlaybackNewFragment = NVRTimePlaybackNewFragment.this;
                nVRTimePlaybackNewFragment.perPager = nVRTimePlaybackNewFragment.currPager = i;
                NVRTimePlaybackNewFragment.this.tv_years_month.setText(NVRTimePlaybackNewFragment.this.calStartDate.get(1) + Constants.ACCEPT_TIME_SEPARATOR_SERVER + (NVRTimePlaybackNewFragment.this.calStartDate.get(2) + 1));
                if (NVRTimePlaybackNewFragment.this.calStartDate.get(1) != NVRTimePlaybackNewFragment.mYear || NVRTimePlaybackNewFragment.this.calStartDate.get(2) + 1 != NVRTimePlaybackNewFragment.mMonth) {
                    NVRTimePlaybackNewFragment.this.isCalenderChangedMonth = true;
                    NVRTimePlaybackNewFragment.this.otherMonthAllHaveVideoDayList.clear();
                    NVRTimePlaybackNewFragment.this.viewpager.setScanScroll(false);
                    NVRTimePlaybackNewFragment.this.mMyCamera.sendIOCtrl(HiChipDefines.HI_P2P_GET_RECORD_ALLDAY, HiChipDefines.SD_YEARMONTH.parseContent(NVRTimePlaybackNewFragment.this.calStartDate.get(1), NVRTimePlaybackNewFragment.this.calStartDate.get(2) + 1));
                    return;
                }
                HiLog.e("MsgCalenderDay:");
                EventBus.getDefault().post(new MsgCalenderDay(NVRTimePlaybackNewFragment.this.allHaveVideoDayList, NVRTimePlaybackNewFragment.this.alreadyGetVideoDay, NVRTimePlaybackNewFragment.this.mSelectPosition, NVRTimePlaybackNewFragment.this.currPager));
            }
        });
        this.rb_all.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                NVRTimePlaybackNewFragment.this.onClick(view);
            }
        });
        this.rb_alarm.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                NVRTimePlaybackNewFragment.this.onClick(view);
            }
        });
        this.bt_landdualswitch.setVisibility(8);
        this.tvSpeed.setVisibility(0);
    }

    protected void reset() {
        Handler handler = this.lineHandler;
        if (handler != null) {
            handler.removeMessages(-1879048183);
        }
        Handler handler2 = this.handler;
        if (handler2 != null) {
            handler2.removeMessages(0);
        }
        Handler handler3 = this.handler;
        if (handler3 != null) {
            handler3.removeMessages(1);
        }
        Handler handler4 = this.handler;
        if (handler4 != null) {
            handler4.removeMessages(2);
        }
        Handler handler5 = this.handler;
        if (handler5 != null) {
            handler5.removeMessages(HiDataValue.HANDLE_MESSAGE_SESSION_STATE);
        }
        Handler handler6 = this.handler;
        if (handler6 != null) {
            handler6.removeMessages(-1879048189);
        }
        this.firstVideoStartTime = 0L;
        this.currentPlayPosition = 0;
        this.currentPlayVideoStartTime = 0L;
        List<PlaybackNvrVo> list = this.one_day_file_list;
        if (list != null) {
            list.clear();
        }
        List<NVRVideoList> list2 = this.videoLists;
        if (list2 != null) {
            list2.clear();
        }
        List<NVRVideoList> list3 = this.videoLists1;
        if (list3 != null) {
            list3.clear();
        }
        List<NVRVideoList> list4 = this.videoLists2;
        if (list4 != null) {
            list4.clear();
        }
        List<PlaybackNvrVo> list5 = this.file_list;
        if (list5 != null) {
            list5.clear();
        }
        List<PlaybackNvrVo> list6 = this.file_list1;
        if (list6 != null) {
            list6.clear();
        }
        List<PlaybackNvrVo> list7 = this.curentDayVideo;
        if (list7 != null) {
            list7.clear();
        }
        List<Integer> list8 = this.alreadyGetVideoDay;
        if (list8 != null) {
            list8.clear();
        }
        List<Integer> list9 = this.allHaveVideoDayList;
        if (list9 != null) {
            list9.clear();
        }
        this.isDrag = false;
        this.isNeedShowProgress = false;
        this.nearVideoDay = 0;
        this.setpos = 0;
        this.videoIsPlaying = false;
        this.todayHasVideo = false;
        this.isOtherDay = false;
        this.videoIsPause = false;
        this.mergeStartTime = 0L;
        this.mergeEndTime = 0L;
        this.mergeStartTime1 = 0L;
        this.mergeEndTime1 = 0L;
        this.previousStartTime = 0L;
        this.previousEndTime = 0L;
        this.preModle = 0;
        this.recentHaveVideoDay = 0;
        TimeLineNVR timeLineNVR = this.myTimeLineView;
        if (timeLineNVR != null) {
            timeLineNVR.resetData();
        }
        this.mSelectPosition = -1;
        this.mIsDataReceveEnd = false;
    }

    private void initViewAndData() {
        this.chn = this.mAct.chn;
        this.myTimeLineView.setView(this.iv_full_screen);
        this.viewpager.setScanScroll(true);
        this.monitor.setCamera(this.mMyCamera);
        this.monitor.setVisibility(0);
        this.mMyCamera.setLiveShowMonitor(this.monitor);
        DisplayMetrics displayMetrics = new DisplayMetrics();
        this.mAct.getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
        this.mHeight = HiTools.dip2px(getContext(), 250.0f);
        this.rl_monitor.setLayoutParams(new LinearLayout.LayoutParams(-1, this.mHeight));
        this.iv_placeholder.setLayoutParams(new RelativeLayout.LayoutParams(-1, this.mHeight));
        if (this.mMyCamera.snapshot != null) {
            DBlur.source(this.mAct, this.mMyCamera.snapshot).mode(1).radius(24).animAlpha().build().doBlur(new OnBlurListener() {
                @Override
                public void onBlurFailed() {
                }

                @Override
                public void onBlurSuccess(Bitmap bitmap) {
                    NVRTimePlaybackNewFragment.this.iv_placeholder.setImageBitmap(bitmap);
                }
            });
        }
        setListenerTimeView();
        String[] stringArray = getResources().getStringArray(R.array.event_type);
        this.rb_all.setText(stringArray[0]);
        this.rb_alarm.setText(stringArray[2]);
        this.rb_all.setEnabled(false);
        this.rb_alarm.setEnabled(false);
        getActivity().getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
        this.monitor.screen_height = displayMetrics.heightPixels;
        this.monitor.screen_width = displayMetrics.widthPixels;
        initMatrix(this.monitor.screen_width, this.monitor.screen_height);
        this.monitor.setState(0);
        MyPlaybackGLMonitor myPlaybackGLMonitor = this.monitor;
        myPlaybackGLMonitor.setMatrix(myPlaybackGLMonitor.left, this.monitor.bottom, this.monitor.width, this.monitor.height);
        resetMonitorSize(false, 10000.0d);
    }

    private void initViewPager() {
        MyPagerAdapter myPagerAdapter = new MyPagerAdapter(this.mAct, false);
        this.pagerAdapter = myPagerAdapter;
        this.viewpager.setAdapter(myPagerAdapter);
        this.viewpager.setCurrentItem(999);
        setTitleGirdView();
        this.stc_calendar_layout.addView(this.title_gView, new LinearLayout.LayoutParams(-1, -2));
        this.pagerAdapter.setOnItemClickListenerPostion(new MyPagerAdapter.OnItemClickListenerPostion() {
            @Override
            public void onItemPostion(int i) {
                boolean z;
                boolean z2;
                if (HiTools.isCustomFastClick(1000)) {
                    return;
                }
                NVRTimePlaybackNewFragment.this.calStartDate.set(5, 1);
                int i2 = NVRTimePlaybackNewFragment.this.calStartDate.get(7) - 1;
                int i3 = NVRTimePlaybackNewFragment.this.calStartDate.get(2) + 1;
                int i4 = (i - i2) + 1;
                if (i4 == NVRTimePlaybackNewFragment.this.nearVideoDay && i3 == NVRTimePlaybackNewFragment.mMonth) {
                    return;
                }
                int i5 = NVRTimePlaybackNewFragment.this.calStartDate.get(2) + 1;
                NVRTimePlaybackNewFragment.this.myTimeLineView.handler.removeMessages(1);
                NVRTimePlaybackNewFragment.this.myTimeLineView.handler.removeMessages(0);
                if (i5 == NVRTimePlaybackNewFragment.mMonth) {
                    Iterator it = NVRTimePlaybackNewFragment.this.allHaveVideoDayList.iterator();
                    while (true) {
                        if (it.hasNext()) {
                            if (((Integer) it.next()).intValue() == i4) {
                                z2 = true;
                                break;
                            }
                        } else {
                            z2 = false;
                            break;
                        }
                    }
                    if (z2) {
                        NVRTimePlaybackNewFragment.this.nearVideoDay = i4;
                        HiLog.e("MsgCalenderDay::" + NVRTimePlaybackNewFragment.this.nearVideoDay + Constants.COLON_SEPARATOR + NVRTimePlaybackNewFragment.this.mSelectPosition);
                        NVRTimePlaybackNewFragment nVRTimePlaybackNewFragment = NVRTimePlaybackNewFragment.this;
                        nVRTimePlaybackNewFragment.mSelectPosition = nVRTimePlaybackNewFragment.nearVideoDay;
                        if (NVRTimePlaybackNewFragment.this.mMyCamera != null && NVRTimePlaybackNewFragment.this.mMyCamera.mhiNvrdev != null) {
                            if (NVRTimePlaybackNewFragment.this.mAct.isDownloading || NVRTimePlaybackNewFragment.this.mAct.isCallDownload) {
                                Packet.longToByteArray4_Little(NVRTimePlaybackNewFragment.this.msavepVo.getU32StartPts(NVRTimePlaybackNewFragment.this.StreamType));
                                Packet.longToByteArray4_Little(NVRTimePlaybackNewFragment.this.msavepVo.getU32StopPts(NVRTimePlaybackNewFragment.this.StreamType));
                            }
                            NVRTimePlaybackNewFragment.this.mMyCamera.mhiNvrdev.StopPlayLocal();
                            NVRTimePlaybackNewFragment.this.isCallStopDown = true;
                            NVRTimePlaybackNewFragment.this.mAct.isDownloading = false;
                            NVRTimePlaybackNewFragment.this.mAct.isCallDownload = false;
                        }
                        HiTools.getMyGrandpaStackTrace();
                        EventBus.getDefault().post(new MsgCalenderDay(NVRTimePlaybackNewFragment.this.allHaveVideoDayList, NVRTimePlaybackNewFragment.this.alreadyGetVideoDay, NVRTimePlaybackNewFragment.this.mSelectPosition, NVRTimePlaybackNewFragment.this.currPager));
                        if (!NVRTimePlaybackNewFragment.this.alreadyGetVideoDay.contains(Integer.valueOf(NVRTimePlaybackNewFragment.this.nearVideoDay))) {
                            NVRTimePlaybackNewFragment.this.videoIsPlaying = false;
                            NVRTimePlaybackNewFragment.this.myTimeLineView.isCanPlay = false;
                            NVRTimePlaybackNewFragment.this.one_day_file_list.clear();
                            NVRTimePlaybackNewFragment.this.file_list.clear();
                            NVRTimePlaybackNewFragment.this.file_list1.clear();
                            NVRTimePlaybackNewFragment.this.isOtherDay = true;
                            NVRTimePlaybackNewFragment.this.videoIsPause = false;
                            NVRTimePlaybackNewFragment nVRTimePlaybackNewFragment2 = NVRTimePlaybackNewFragment.this;
                            nVRTimePlaybackNewFragment2.removeVideoList(nVRTimePlaybackNewFragment2.nearVideoDay);
                            NVRTimePlaybackNewFragment.this.showLoadingView();
                            if (NVRTimePlaybackNewFragment.this.mAct.isDownloading || NVRTimePlaybackNewFragment.this.mAct.isCallDownload) {
                                Packet.longToByteArray4_Little(NVRTimePlaybackNewFragment.this.msavepVo.getU32StartPts(NVRTimePlaybackNewFragment.this.StreamType));
                                Packet.longToByteArray4_Little(NVRTimePlaybackNewFragment.this.msavepVo.getU32StopPts(NVRTimePlaybackNewFragment.this.StreamType));
                            }
                            NVRTimePlaybackNewFragment.this.mMyCamera.mhiNvrdev.StopPlayLocal();
                            NVRTimePlaybackNewFragment.this.isCallStopDown = true;
                            NVRTimePlaybackNewFragment.this.mAct.isDownloading = false;
                            NVRTimePlaybackNewFragment.this.mAct.isCallDownload = false;
                            HiLogcatUtil.i("tedu", "--onDayItemClick--sendIOCtrl(HiChipDefines.HI_P2P_GET_RECORD_ALLFILE_ONEDAY:" + NVRTimePlaybackNewFragment.this.nearVideoDay);
                            NVRTimePlaybackNewFragment.this.mMyCamera.sendIOCtrl(HiChipDefines.HI_P2P_GET_RECORD_ALLFILE_ONEDAY, HiChipDefines.RECORD_ALLFILE.parseContent(0, NVRTimePlaybackNewFragment.mYear, NVRTimePlaybackNewFragment.mMonth, NVRTimePlaybackNewFragment.this.nearVideoDay, NVRTimePlaybackNewFragment.this.getFileType()));
                            NVRTimePlaybackNewFragment.this.alreadyGetVideoDay.add(Integer.valueOf(NVRTimePlaybackNewFragment.this.nearVideoDay));
                            return;
                        }
                        if (NVRTimePlaybackNewFragment.this.mAct.isDownloading || NVRTimePlaybackNewFragment.this.mAct.isCallDownload) {
                            Packet.longToByteArray4_Little(NVRTimePlaybackNewFragment.this.msavepVo.getU32StartPts(NVRTimePlaybackNewFragment.this.StreamType));
                            Packet.longToByteArray4_Little(NVRTimePlaybackNewFragment.this.msavepVo.getU32StopPts(NVRTimePlaybackNewFragment.this.StreamType));
                        }
                        NVRTimePlaybackNewFragment.this.mMyCamera.mhiNvrdev.StopPlayLocal();
                        NVRTimePlaybackNewFragment.this.isCallStopDown = true;
                        NVRTimePlaybackNewFragment.this.mAct.isDownloading = false;
                        NVRTimePlaybackNewFragment.this.mAct.isCallDownload = false;
                        NVRTimePlaybackNewFragment.this.videoIsPlaying = false;
                        NVRTimePlaybackNewFragment.this.myTimeLineView.isCanPlay = false;
                        NVRTimePlaybackNewFragment.this.one_day_file_list.clear();
                        NVRTimePlaybackNewFragment nVRTimePlaybackNewFragment3 = NVRTimePlaybackNewFragment.this;
                        nVRTimePlaybackNewFragment3.removeVideoList(nVRTimePlaybackNewFragment3.nearVideoDay);
                        NVRTimePlaybackNewFragment.this.videoIsPause = false;
                        NVRTimePlaybackNewFragment.this.showLoadingView();
                        if (NVRTimePlaybackNewFragment.this.mAct.isDownloading || NVRTimePlaybackNewFragment.this.mAct.isCallDownload) {
                            Packet.longToByteArray4_Little(NVRTimePlaybackNewFragment.this.msavepVo.getU32StartPts(NVRTimePlaybackNewFragment.this.StreamType));
                            Packet.longToByteArray4_Little(NVRTimePlaybackNewFragment.this.msavepVo.getU32StopPts(NVRTimePlaybackNewFragment.this.StreamType));
                        }
                        NVRTimePlaybackNewFragment.this.mMyCamera.mhiNvrdev.StopPlayLocal();
                        NVRTimePlaybackNewFragment.this.isCallStopDown = true;
                        NVRTimePlaybackNewFragment.this.mAct.isDownloading = false;
                        NVRTimePlaybackNewFragment.this.mAct.isCallDownload = false;
                        HiLogcatUtil.i("tedu", "--onDayItemClick--sendIOCtrl(HiChipDefines.HI_P2P_GET_RECORD_ALLFILE_ONEDAY:" + NVRTimePlaybackNewFragment.this.nearVideoDay);
                        NVRTimePlaybackNewFragment.this.mMyCamera.sendIOCtrl(HiChipDefines.HI_P2P_GET_RECORD_ALLFILE_ONEDAY, HiChipDefines.RECORD_ALLFILE.parseContent(0, NVRTimePlaybackNewFragment.mYear, NVRTimePlaybackNewFragment.mMonth, NVRTimePlaybackNewFragment.this.nearVideoDay, NVRTimePlaybackNewFragment.this.getFileType()));
                        return;
                    }
                    return;
                }
                Iterator it2 = NVRTimePlaybackNewFragment.this.otherMonthAllHaveVideoDayList.iterator();
                while (true) {
                    if (it2.hasNext()) {
                        if (((Integer) it2.next()).intValue() == i4) {
                            z = true;
                            break;
                        }
                    } else {
                        z = false;
                        break;
                    }
                }
                if (z) {
                    NVRTimePlaybackNewFragment.this.showLoadingView();
                    if (NVRTimePlaybackNewFragment.this.mAct.isDownloading || NVRTimePlaybackNewFragment.this.mAct.isCallDownload) {
                        Packet.longToByteArray4_Little(NVRTimePlaybackNewFragment.this.msavepVo.getU32StartPts(NVRTimePlaybackNewFragment.this.StreamType));
                        Packet.longToByteArray4_Little(NVRTimePlaybackNewFragment.this.msavepVo.getU32StopPts(NVRTimePlaybackNewFragment.this.StreamType));
                    }
                    NVRTimePlaybackNewFragment.this.mMyCamera.mhiNvrdev.StopPlayLocal();
                    NVRTimePlaybackNewFragment.this.isCallStopDown = true;
                    NVRTimePlaybackNewFragment.this.mAct.isDownloading = false;
                    NVRTimePlaybackNewFragment.this.mAct.isCallDownload = false;
                    NVRTimePlaybackNewFragment.this.reset();
                    NVRTimePlaybackNewFragment.this.nearVideoDay = i4;
                    NVRTimePlaybackNewFragment nVRTimePlaybackNewFragment4 = NVRTimePlaybackNewFragment.this;
                    nVRTimePlaybackNewFragment4.mSelectPosition = nVRTimePlaybackNewFragment4.nearVideoDay;
                    NVRTimePlaybackNewFragment.this.allHaveVideoDayList.addAll(NVRTimePlaybackNewFragment.this.otherMonthAllHaveVideoDayList);
                    for (int i6 = 0; i6 < NVRTimePlaybackNewFragment.this.allHaveVideoDayList.size(); i6++) {
                        NVRTimePlaybackNewFragment.this.myTimeLineView.date[((Integer) NVRTimePlaybackNewFragment.this.allHaveVideoDayList.get(i6)).intValue() - 1] = 1;
                    }
                    NVRTimePlaybackNewFragment.mYear = NVRTimePlaybackNewFragment.this.calStartDate.get(1);
                    NVRTimePlaybackNewFragment.mMonth = NVRTimePlaybackNewFragment.this.calStartDate.get(2) + 1;
                    if (NVRTimePlaybackNewFragment.this.mAct.isDownloading || NVRTimePlaybackNewFragment.this.mAct.isCallDownload) {
                        Packet.longToByteArray4_Little(NVRTimePlaybackNewFragment.this.msavepVo.getU32StartPts(NVRTimePlaybackNewFragment.this.StreamType));
                        Packet.longToByteArray4_Little(NVRTimePlaybackNewFragment.this.msavepVo.getU32StopPts(NVRTimePlaybackNewFragment.this.StreamType));
                    }
                    NVRTimePlaybackNewFragment.this.mMyCamera.mhiNvrdev.StopPlayLocal();
                    NVRTimePlaybackNewFragment.this.isCallStopDown = true;
                    NVRTimePlaybackNewFragment.this.mAct.isDownloading = false;
                    NVRTimePlaybackNewFragment.this.mAct.isCallDownload = false;
                    HiLogcatUtil.i("tedu", "--pagerAdapter.setOnItemClick--:" + NVRTimePlaybackNewFragment.this.nearVideoDay);
                    NVRTimePlaybackNewFragment.this.mMyCamera.sendIOCtrl(HiChipDefines.HI_P2P_GET_RECORD_ALLFILE_ONEDAY, HiChipDefines.RECORD_ALLFILE.parseContent(0, NVRTimePlaybackNewFragment.mYear, NVRTimePlaybackNewFragment.mMonth, NVRTimePlaybackNewFragment.this.nearVideoDay, NVRTimePlaybackNewFragment.this.getFileType()));
                    NVRTimePlaybackNewFragment.this.alreadyGetVideoDay.add(Integer.valueOf(NVRTimePlaybackNewFragment.this.nearVideoDay));
                    if (NVRTimePlaybackNewFragment.this.allHaveVideoDayList == null || NVRTimePlaybackNewFragment.this.allHaveVideoDayList.size() <= 0) {
                        return;
                    }
                    NVRTimePlaybackNewFragment nVRTimePlaybackNewFragment5 = NVRTimePlaybackNewFragment.this;
                    nVRTimePlaybackNewFragment5.recentHaveVideoDay = ((Integer) nVRTimePlaybackNewFragment5.allHaveVideoDayList.get(NVRTimePlaybackNewFragment.this.allHaveVideoDayList.size() - 1)).intValue();
                }
            }
        });
    }

    private void initPBFast(MyCamera myCamera) {
        if (myCamera.mhiNvrdev == null) {
            myCamera.mhiNvrdev = new HiNVRDev();
            myCamera.mhiNvrdev.SetHiCameraObj(myCamera);
            boolean z = SharePreUtils.getBoolean(HiDataValue.CACHE, getActivity(), Constant.DEV_IsVivoMedia, false);
            if (SystemUtils.isVIVOMobile(getActivity()) && Build.VERSION.SDK_INT > 29 && !z) {
                myCamera.mhiNvrdev.SetDecodeViVoVideoType(0);
            } else {
                myCamera.mhiNvrdev.SetDecodeViVoVideoType(1);
            }
        }
        if (myCamera.mhiNvrdev != null) {
            myCamera.mhiNvrdev.SetHiCameraObj(myCamera);
            myCamera.mhiNvrdev.registerPlayNVRStateListener(this);
            myCamera.mhiNvrdev.registerPlayBackNVRStateListener(this);
            myCamera.mhiNvrdev.setLiveShowMonitor(this.monitor);
        }
    }

    public byte getFileType() {
        return this.currentTypeIs2 ? (byte) 2 : (byte) 0;
    }

    private void setTitleGirdView() {
        this.title_gView = setGirdView();
        this.title_gView.setLayoutParams(new LinearLayout.LayoutParams(-1, -2));
        this.title_gView.setVerticalSpacing(1);
        this.title_gView.setHorizontalSpacing(1);
        this.title_gView.setAdapter((ListAdapter) new TitleGridAdapter(this.mAct));
    }

    private GridView setGirdView() {
        LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(-1, -2);
        GridView gridView = new GridView(this.mAct);
        gridView.setLayoutParams(layoutParams);
        gridView.setNumColumns(7);
        gridView.setGravity(16);
        gridView.setVerticalSpacing(1);
        gridView.setHorizontalSpacing(1);
        gridView.setBackgroundColor(0);
        gridView.setSelector(new ColorDrawable(0));
        return gridView;
    }

    private void getIntentData() {
        String string = getArguments().getString(HiDataValue.EXTRAS_KEY_UID);
        if (!TextUtils.isEmpty(string)) {
            Iterator<MyCamera> it = HiDataValue.CameraList.iterator();
            while (true) {
                if (!it.hasNext()) {
                    break;
                }
                MyCamera next = it.next();
                if (string.equals(next.getUid())) {
                    this.mMyCamera = next;
                    break;
                }
            }
        }
        MyCamera myCamera = this.mMyCamera;
        if (myCamera != null) {
            myCamera.registerIOSessionListener(this);
            this.mMyCamera.registerPlayStateListener(this);
        }
    }

    private void searchmonvideo() {
        Calendar calendar = Calendar.getInstance();
        mYear = calendar.get(1);
        mMonth = calendar.get(2) + 1;
        setYearMonth(calendar.getTimeInMillis() * 1000);
        HiLogcatUtil.e("-11-sendIOCtrl(HiChipNVRDefines.HI_NVR_P2P_PLATFORM_GET_MONTHPLAYBACKFILE---mYear-:" + mYear + "-mMonth-:" + mMonth);
        if (mMonth < 10) {
            this.mstrdate = "" + mYear + PushConstants.PUSH_TYPE_NOTIFY + mMonth;
        } else {
            this.mstrdate = "" + mYear + mMonth;
        }
        this.mMyCamera.sendIOCtrl(HiChipNVRDefines.HI_NVR_P2P_PLATFORM_GET_MONTHPLAYBACKFILE, HiChipNVRDefines.PLATFORM_S_MONTHPLAYBACKFILE_REQ.parseContent(this.chn, this.mstrdate.getBytes()));
    }

    public class AnonymousClass4 implements TimeLineNew.PlaybackViewListener {
        AnonymousClass4() {
        }

        @Override
        public void onValueChanged(String str, long j, boolean z) {
            if (z && NVRTimePlaybackNewFragment.this.isNeedShowProgress) {
                NVRTimePlaybackNewFragment.this.tv_time.setVisibility(0);
                NVRTimePlaybackNewFragment.this.timePlayStart = false;
            }
            NVRTimePlaybackNewFragment.this.tv_time.setText(str);
            if (str.contains("23:59:59")) {
                NVRTimePlaybackNewFragment.this.myTimeLineView.isCanPlay = false;
            }
        }

        @Override
        public void onVideoStart(String str, long j, int i) {
            int i2;
            int i3;
            String str2 = str;
            long j2 = j;
            String format = HiDataValue.sdf.format(new Date(j2 / 1000));
            HiLogcatUtil.e("tedu--时间轴控件  onVideoStart--:" + format + "-timeInMillis-:" + str2 + ":::" + str.length() + "\n>>type=" + i + ">>timeInMicros=" + j2 + "::" + NVRTimePlaybackNewFragment.this.nearVideoDay + "::" + NVRTimePlaybackNewFragment.this.getDay(j2));
            if (!TextUtils.isEmpty(format) && format.length() > 10 && format.indexOf("00:00:00") != -1) {
                j2 += 1000000;
            }
            if (!TextUtils.isEmpty(str) && str.length() >= 8 && str2.indexOf("00:00:00") != -1) {
                str2 = str2.replace("00:00:00", "00:00:01");
            }
            HiLogcatUtil.e("tedu--时间轴控件  onVideoStart--:" + format + "-timeInMillis-:" + str2 + "\n>>type=" + i + ">>timeInMicros=" + j2 + "::" + NVRTimePlaybackNewFragment.this.nearVideoDay + "::" + NVRTimePlaybackNewFragment.this.getDay(j2));
            if (i == 0 && "00:00:01".equals(str2)) {
                return;
            }
            NVRTimePlaybackNewFragment.this.tv_time.setVisibility(8);
            NVRTimePlaybackNewFragment.this.handler.postDelayed(new Runnable() {
                @Override
                public final void run() {
                    NVRTimePlaybackNewFragment.AnonymousClass4.this.lambda$onVideoStart$0$NVRTimePlaybackNewFragment$4();
                }
            }, 500L);
            if (NVRTimePlaybackNewFragment.this.getDay(j2) != -1) {
                NVRTimePlaybackNewFragment nVRTimePlaybackNewFragment = NVRTimePlaybackNewFragment.this;
                nVRTimePlaybackNewFragment.nearVideoDay = nVRTimePlaybackNewFragment.getDay(j2);
            }
            if (!NVRTimePlaybackNewFragment.this.isDrag) {
                if (NVRTimePlaybackNewFragment.this.mhandlerPF != null) {
                    NVRTimePlaybackNewFragment.this.mhandlerPF.sendEmptyMessage(NVRTimePlaybackNewFragment.HANDLE_MESSAGE_PLAYONLINE_SHOWLOADVIEW);
                }
                NVRTimePlaybackNewFragment.this.myTimeLineView.isCanPlay = true;
                NVRTimePlaybackNewFragment.this.isPlayEnd = false;
                if (NVRTimePlaybackNewFragment.this.one_day_file_list.size() > 0) {
                    PlaybackNvrVo playbackNvrVo = (PlaybackNvrVo) NVRTimePlaybackNewFragment.this.one_day_file_list.get(0);
                    NVRTimePlaybackNewFragment.this.setpos = 0;
                    NVRTimePlaybackNewFragment.this.oldTime = 0L;
                    NVRTimePlaybackNewFragment.this.firstVideoStartTime = playbackNvrVo.getStartTime();
                    NVRTimePlaybackNewFragment.this.currentPlayVideoStartTime = playbackNvrVo.getStartTime();
                    HiLogcatUtil.e("currentPlayPosition:" + NVRTimePlaybackNewFragment.this.currentPlayPosition + ":::" + NVRTimePlaybackNewFragment.this.firstVideoStartTime);
                    byte[] bArr = new byte[8];
                    System.arraycopy(playbackNvrVo.getTest(), 0, bArr, 0, 8);
                    NVRTimePlaybackNewFragment.this.startPlayBack(playbackNvrVo, bArr, playbackNvrVo.getStartTime() / 1000, playbackNvrVo.getEndTime() / 1000, 0L, 0, 0, playbackNvrVo.getFlag());
                    NVRTimePlaybackNewFragment.this.isDrag = true;
                    NVRTimePlaybackNewFragment.this.isNeedShowProgress = true;
                    return;
                }
                return;
            }
            if (NVRTimePlaybackNewFragment.this.mBackToNoFile) {
                int findVideoFile = NVRTimePlaybackNewFragment.this.findVideoFile(j2, i);
                if (findVideoFile == -1) {
                    NVRTimePlaybackNewFragment.this.myTimeLineView.listener.onNoneVideo(str2, j2);
                    return;
                }
                if (NVRTimePlaybackNewFragment.this.myTimeLineView.isScroll()) {
                    return;
                }
                final PlaybackNvrVo playbackNvrVo2 = (PlaybackNvrVo) NVRTimePlaybackNewFragment.this.curentDayVideo.get(findVideoFile);
                NVRTimePlaybackNewFragment.this.oldTime = 0L;
                NVRTimePlaybackNewFragment.this.firstVideoStartTime = j2;
                NVRTimePlaybackNewFragment.this.setpos = 1;
                HiLogcatUtil.e("currentPlayPosition:" + NVRTimePlaybackNewFragment.this.currentPlayPosition + "::" + findVideoFile + Constants.COLON_SEPARATOR + NVRTimePlaybackNewFragment.this.firstVideoStartTime);
                if (NVRTimePlaybackNewFragment.this.currentPlayPosition != findVideoFile) {
                    if (NVRTimePlaybackNewFragment.this.mAct.isDownloading || NVRTimePlaybackNewFragment.this.mAct.isCallDownload) {
                        Packet.longToByteArray4_Little(NVRTimePlaybackNewFragment.this.msavepVo.getU32StartPts(NVRTimePlaybackNewFragment.this.StreamType));
                        Packet.longToByteArray4_Little(NVRTimePlaybackNewFragment.this.msavepVo.getU32StopPts(NVRTimePlaybackNewFragment.this.StreamType));
                    }
                    NVRTimePlaybackNewFragment.this.mMyCamera.mhiNvrdev.StopPlayLocal();
                    NVRTimePlaybackNewFragment.this.isCallStopDown = true;
                    i2 = 0;
                    NVRTimePlaybackNewFragment.this.mAct.isDownloading = false;
                    NVRTimePlaybackNewFragment.this.mAct.isCallDownload = false;
                    i3 = 1000;
                } else {
                    i2 = 0;
                    i3 = 0;
                }
                NVRTimePlaybackNewFragment.this.currentPlayPosition = findVideoFile;
                final byte[] bArr2 = new byte[8];
                System.arraycopy(playbackNvrVo2.getTest(), i2, bArr2, i2, 8);
                long startTime = playbackNvrVo2.getStartTime() / 1000;
                long endTime = playbackNvrVo2.getEndTime() / 1000;
                byte flag = playbackNvrVo2.getFlag();
                if (NVRTimePlaybackNewFragment.this.isQuit) {
                    return;
                }
                if (NVRTimePlaybackNewFragment.this.mhandlerPF != null) {
                    NVRTimePlaybackNewFragment.this.mhandlerPF.sendEmptyMessage(NVRTimePlaybackNewFragment.HANDLE_MESSAGE_PLAYONLINE_SHOWLOADVIEW);
                }
                NVRTimePlaybackNewFragment.this.mBackToNoFile = false;
                HiLogcatUtil.e("test222  " + NVRTimePlaybackNewFragment.this.curentDayVideo.size() + "---" + findVideoFile + "::" + ((int) flag));
                NVRTimePlaybackNewFragment.this.mhandlerPF.postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        NVRTimePlaybackNewFragment nVRTimePlaybackNewFragment2 = NVRTimePlaybackNewFragment.this;
                        PlaybackNvrVo playbackNvrVo3 = playbackNvrVo2;
                        nVRTimePlaybackNewFragment2.HiDoPlayFast(playbackNvrVo3, bArr2, 0L, 0, playbackNvrVo3.getFlag());
                    }
                }, (long) i3);
                NVRTimePlaybackNewFragment.this.myTimeLineView.moveToValue(playbackNvrVo2.getStartTime());
                NVRTimePlaybackNewFragment.this.videoIsPause = false;
                NVRTimePlaybackNewFragment.this.videoIsPlaying = true;
                return;
            }
            NVRTimePlaybackNewFragment.this.handPlayStart(str2, j2, i);
        }

        public void lambda$onVideoStart$0$NVRTimePlaybackNewFragment$4() {
            NVRTimePlaybackNewFragment.this.iv_full_screen.setEnabled(true);
        }

        @Override
        public void onNoneVideo(String str, long j) {
            int i;
            int i2;
            HiLogcatUtil.e("tedu--时间轴控件  onNoneVideo--:");
            NVRTimePlaybackNewFragment.this.dismissLoadingView();
            if (NVRTimePlaybackNewFragment.this.videoIsPlaying && NVRTimePlaybackNewFragment.this.one_day_file_list.size() > 0) {
                NVRTimePlaybackNewFragment.this.tv_time.postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        NVRTimePlaybackNewFragment.this.iv_placeholder.setVisibility(0);
                        NVRTimePlaybackNewFragment.this.iv_placeholder.setLayoutParams(new RelativeLayout.LayoutParams(-1, NVRTimePlaybackNewFragment.this.mHeight));
                        if (NVRTimePlaybackNewFragment.this.mAct != null && !NVRTimePlaybackNewFragment.this.mAct.isFinishing()) {
                            Toast.makeText(NVRTimePlaybackNewFragment.this.mAct, NVRTimePlaybackNewFragment.this.getString(R.string.current_not_video), 1).show();
                        }
                        if (NVRTimePlaybackNewFragment.this.videoIsPause || !NVRTimePlaybackNewFragment.this.videoIsPlaying) {
                            return;
                        }
                        NVRTimePlaybackNewFragment.this.pausePlayVideo();
                        NVRTimePlaybackNewFragment.this.videoIsPlaying = false;
                        NVRTimePlaybackNewFragment.this.videoIsPause = true;
                    }
                }, 500L);
            } else if (NVRTimePlaybackNewFragment.this.iv_placeholder.getVisibility() == 0) {
                if (NVRTimePlaybackNewFragment.this.curentDayVideo.size() > 0) {
                    i = NVRTimePlaybackNewFragment.this.myTimeLineView.getCurrentValue() / 1000000 > ((PlaybackNvrVo) NVRTimePlaybackNewFragment.this.curentDayVideo.get(NVRTimePlaybackNewFragment.this.curentDayVideo.size() - 1)).getEndTime() / 1000000 ? NVRTimePlaybackNewFragment.this.curentDayVideo.size() - 1 : -1;
                    if (NVRTimePlaybackNewFragment.this.myTimeLineView.getCurrentValue() / 1000000 < ((PlaybackNvrVo) NVRTimePlaybackNewFragment.this.curentDayVideo.get(0)).getStartTime() / 1000000) {
                        i = 0;
                    }
                } else {
                    i = -1;
                }
                if (i != -1) {
                    final PlaybackNvrVo playbackNvrVo = (PlaybackNvrVo) NVRTimePlaybackNewFragment.this.curentDayVideo.get(i);
                    if (NVRTimePlaybackNewFragment.this.mBackToNoFile) {
                        NVRTimePlaybackNewFragment.this.oldTime = 0L;
                        NVRTimePlaybackNewFragment.this.firstVideoStartTime = j;
                        NVRTimePlaybackNewFragment.this.setpos = 1;
                        HiLogcatUtil.e("currentPlayPosition:" + NVRTimePlaybackNewFragment.this.currentPlayPosition + "::" + i + Constants.COLON_SEPARATOR + NVRTimePlaybackNewFragment.this.firstVideoStartTime);
                        if (NVRTimePlaybackNewFragment.this.currentPlayPosition != i) {
                            if (NVRTimePlaybackNewFragment.this.mAct.isDownloading || NVRTimePlaybackNewFragment.this.mAct.isCallDownload) {
                                Packet.longToByteArray4_Little(NVRTimePlaybackNewFragment.this.msavepVo.getU32StartPts(NVRTimePlaybackNewFragment.this.StreamType));
                                Packet.longToByteArray4_Little(NVRTimePlaybackNewFragment.this.msavepVo.getU32StopPts(NVRTimePlaybackNewFragment.this.StreamType));
                            }
                            NVRTimePlaybackNewFragment.this.mMyCamera.mhiNvrdev.StopPlayLocal();
                            NVRTimePlaybackNewFragment.this.isCallStopDown = true;
                            NVRTimePlaybackNewFragment.this.mAct.isDownloading = false;
                            NVRTimePlaybackNewFragment.this.mAct.isCallDownload = false;
                            i2 = 1000;
                        } else {
                            i2 = 0;
                        }
                        NVRTimePlaybackNewFragment.this.currentPlayPosition = i;
                        final byte[] bArr = new byte[8];
                        System.arraycopy(playbackNvrVo.getTest(), 0, bArr, 0, 8);
                        long startTime = playbackNvrVo.getStartTime() / 1000;
                        long endTime = playbackNvrVo.getEndTime() / 1000;
                        playbackNvrVo.getFlag();
                        if (NVRTimePlaybackNewFragment.this.isQuit) {
                            return;
                        }
                        if (NVRTimePlaybackNewFragment.this.mhandlerPF != null) {
                            NVRTimePlaybackNewFragment.this.mhandlerPF.sendEmptyMessage(NVRTimePlaybackNewFragment.HANDLE_MESSAGE_PLAYONLINE_SHOWLOADVIEW);
                        }
                        NVRTimePlaybackNewFragment.this.mBackToNoFile = false;
                        NVRTimePlaybackNewFragment.this.mhandlerPF.postDelayed(new Runnable() {
                            @Override
                            public void run() {
                                NVRTimePlaybackNewFragment nVRTimePlaybackNewFragment = NVRTimePlaybackNewFragment.this;
                                PlaybackNvrVo playbackNvrVo2 = playbackNvrVo;
                                nVRTimePlaybackNewFragment.HiDoPlayFast(playbackNvrVo2, bArr, 0L, 0, playbackNvrVo2.getFlag());
                            }
                        }, i2);
                        NVRTimePlaybackNewFragment.this.myTimeLineView.moveToValue(playbackNvrVo.getStartTime());
                    } else {
                        NVRTimePlaybackNewFragment.this.myTimeLineView.moveToValue(playbackNvrVo.getStartTime());
                    }
                }
            }
            if (NVRTimePlaybackNewFragment.this.videoIsPause && !NVRTimePlaybackNewFragment.this.videoIsPlaying && NVRTimePlaybackNewFragment.this.iv_placeholder.getVisibility() != 0) {
                NVRTimePlaybackNewFragment.this.iv_placeholder.setVisibility(0);
                NVRTimePlaybackNewFragment.this.iv_placeholder.setLayoutParams(new RelativeLayout.LayoutParams(-1, NVRTimePlaybackNewFragment.this.mHeight));
            }
            NVRTimePlaybackNewFragment.this.timePlayStart = true;
        }

        @Override
        public void onChangedScaleMode() {
            if (NVRTimePlaybackNewFragment.this.myTimeLineView.getScaleMode() == 120 || NVRTimePlaybackNewFragment.this.myTimeLineView.getScaleMode() == 600) {
                if (NVRTimePlaybackNewFragment.this.preModle != NVRTimePlaybackNewFragment.this.myTimeLineView.getScaleMode()) {
                    NVRTimePlaybackNewFragment.this.myTimeLineView.setVideos(NVRTimePlaybackNewFragment.this.file_list, false, 0L);
                    NVRTimePlaybackNewFragment nVRTimePlaybackNewFragment = NVRTimePlaybackNewFragment.this;
                    nVRTimePlaybackNewFragment.preModle = nVRTimePlaybackNewFragment.myTimeLineView.getScaleMode();
                    return;
                }
                return;
            }
            if (NVRTimePlaybackNewFragment.this.preModle != NVRTimePlaybackNewFragment.this.myTimeLineView.getScaleMode()) {
                NVRTimePlaybackNewFragment.this.myTimeLineView.setVideos(NVRTimePlaybackNewFragment.this.file_list1, false, 0L);
                NVRTimePlaybackNewFragment nVRTimePlaybackNewFragment2 = NVRTimePlaybackNewFragment.this;
                nVRTimePlaybackNewFragment2.preModle = nVRTimePlaybackNewFragment2.myTimeLineView.getScaleMode();
            }
        }
    }

    private void setListenerTimeView() {
        this.myTimeLineView.setOnPlaybackViewListener(new AnonymousClass4());
    }

    public void handPlayStart(String str, long j, int i) {
        int i2;
        int findVideoFile = findVideoFile(j, i);
        if (findVideoFile == -1) {
            this.myTimeLineView.listener.onNoneVideo(str, j);
            return;
        }
        if (this.myTimeLineView.isScroll()) {
            return;
        }
        final PlaybackNvrVo playbackNvrVo = this.curentDayVideo.get(findVideoFile);
        if (this.noFileNeedJump) {
            this.myTimeLineView.moveToValue(playbackNvrVo.getStartTime());
            return;
        }
        this.oldTime = 0L;
        this.firstVideoStartTime = j;
        Handler handler = this.mhandlerPF;
        if (handler != null) {
            handler.sendEmptyMessage(HANDLE_MESSAGE_PLAYONLINE_SHOWLOADVIEW);
        }
        this.setpos = 1;
        HiLogcatUtil.e("currentPlayPosition:" + this.currentPlayPosition + "::" + findVideoFile + Constants.COLON_SEPARATOR + this.firstVideoStartTime);
        if (this.currentPlayPosition != findVideoFile) {
            if (this.mAct.isDownloading || this.mAct.isCallDownload) {
                Packet.longToByteArray4_Little(this.msavepVo.getU32StartPts(this.StreamType));
                Packet.longToByteArray4_Little(this.msavepVo.getU32StopPts(this.StreamType));
            }
            this.mMyCamera.mhiNvrdev.StopPlayLocal();
            this.isCallStopDown = true;
            this.mAct.isDownloading = false;
            this.mAct.isCallDownload = false;
            i2 = 1000;
        } else {
            i2 = 0;
        }
        this.currentPlayPosition = findVideoFile;
        HiLogcatUtil.e("currentPlayPosition:" + this.currentPlayPosition + "::" + findVideoFile + "::" + this.mAct.isDownloading + Constants.COLON_SEPARATOR + this.mAct.isCallDownload);
        final byte[] bArr = new byte[8];
        System.arraycopy(playbackNvrVo.getTest(), 0, bArr, 0, 8);
        final int startTime = (int) ((j - playbackNvrVo.getStartTime()) / 1000000);
        if (this.videoIsPlaying || this.videoIsPause) {
            this.iv_placeholder.setVisibility(4);
            HiLogcatUtil.e("getMyGrandpaStackTrace" + playbackNvrVo.getStartTime() + Constants.COLON_SEPARATOR + playbackNvrVo.getEndTime() + Constants.COLON_SEPARATOR + j + Constants.COLON_SEPARATOR + ((j - playbackNvrVo.getStartTime()) / 1000) + Constants.COLON_SEPARATOR + findVideoFile + Constants.COLON_SEPARATOR + ((int) playbackNvrVo.getFlag()));
            this.mhandlerPF.postDelayed(new Runnable() {
                @Override
                public void run() {
                    NVRTimePlaybackNewFragment nVRTimePlaybackNewFragment = NVRTimePlaybackNewFragment.this;
                    PlaybackNvrVo playbackNvrVo2 = playbackNvrVo;
                    nVRTimePlaybackNewFragment.HiDoPlayFast(playbackNvrVo2, bArr, startTime, 1, playbackNvrVo2.getFlag());
                }
            }, (long) i2);
        } else {
            this.iv_placeholder.setVisibility(4);
            HiLogcatUtil.e("getMyGrandpaStackTrace" + playbackNvrVo.getStartTime() + Constants.COLON_SEPARATOR + playbackNvrVo.getEndTime() + Constants.COLON_SEPARATOR + j + Constants.COLON_SEPARATOR + ((j - playbackNvrVo.getStartTime()) / 1000) + Constants.COLON_SEPARATOR + findVideoFile + Constants.COLON_SEPARATOR + ((int) playbackNvrVo.getFlag()));
            this.mhandlerPF.postDelayed(new Runnable() {
                @Override
                public void run() {
                    NVRTimePlaybackNewFragment nVRTimePlaybackNewFragment = NVRTimePlaybackNewFragment.this;
                    PlaybackNvrVo playbackNvrVo2 = playbackNvrVo;
                    nVRTimePlaybackNewFragment.HiDoPlayFast(playbackNvrVo2, bArr, 0L, 0, playbackNvrVo2.getFlag());
                }
            }, (long) i2);
        }
        this.videoIsPause = false;
        this.videoIsPlaying = true;
        this.mSpeed = 0;
        this.tvSpeed.setText("X 1");
    }

    private void setYearMonth(long j) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTimeInMillis(j / 1000);
        if (isAdded()) {
            this.tv_years_month.setText(calendar.get(1) + Constants.ACCEPT_TIME_SEPARATOR_SERVER + (calendar.get(2) + 1));
        }
    }

    public void pausePlayVideo() {
        HiTools.getMyGrandpaStackTrace();
    }

    protected int findVideoFile(long j, int i) {
        HiTools.getMyGrandpaStackTrace();
        HiLog.e("tedG--....()...." + j + ";;;;" + i);
        this.curentDayVideo.clear();
        if (!this.alreadyGetVideoDay.contains(Integer.valueOf(this.nearVideoDay))) {
            HiLog.e("tedG--....()....--");
            return -1;
        }
        int i2 = 0;
        while (true) {
            if (i2 >= this.videoLists.size()) {
                break;
            }
            if (this.nearVideoDay == this.videoLists.get(i2).getDay_of_month()) {
                this.curentDayVideo.addAll(this.videoLists.get(i2).getTodayVideos());
                break;
            }
            i2++;
        }
        HiLog.e("tedG--....()...." + j + ";;;;" + i + "::" + this.curentDayVideo.size());
        if (this.curentDayVideo.size() == 0) {
            return -1;
        }
        int size = this.curentDayVideo.size() - 1;
        int i3 = 0;
        while (i3 <= size) {
            int i4 = (i3 + size) / 2;
            long j2 = j / 1000000;
            if (this.curentDayVideo.get(i4).getStartTime() / 1000000 <= j2 && this.curentDayVideo.get(i4).getEndTime() / 1000000 >= j2) {
                this.noFileNeedJump = false;
                return i4;
            }
            if (this.curentDayVideo.get(i4).getEndTime() / 1000000 <= j2) {
                i3 = i4 + 1;
            } else if (this.curentDayVideo.get(i4).getStartTime() / 1000000 > j2) {
                size = i4 - 1;
            }
        }
        int i5 = (i3 + size) / 2;
        HiLog.e("tedG--....()....--" + size + "::" + i3 + ":::" + this.curentDayVideo.size());
        if (size < 0 || i3 > this.curentDayVideo.size() - 1) {
            HiLog.e("tedG--....()....--");
            return -1;
        }
        if (i == 1) {
            this.noFileNeedJump = true;
            return i5 + 1;
        }
        if (i == 0) {
            this.noFileNeedJump = true;
            return i5;
        }
        if (i == -1) {
            this.noFileNeedJump = false;
            return size;
        }
        HiLog.e("tedG--....()....--");
        return -1;
    }

    public void startPlayBack(final PlaybackNvrVo playbackNvrVo, final byte[] bArr, long j, long j2, final long j3, int i, final int i2, final byte b) {
        HiTools.getMyGrandpaStackTrace();
        new Thread() {
            @Override
            public void run() {
                super.run();
                if (NVRTimePlaybackNewFragment.this.curentDayVideo.size() == 0) {
                    if (NVRTimePlaybackNewFragment.this.isQuit) {
                        return;
                    }
                    NVRTimePlaybackNewFragment.this.HiDoPlayFast(playbackNvrVo, bArr, j3, i2, b);
                } else {
                    if (NVRTimePlaybackNewFragment.this.isQuit) {
                        return;
                    }
                    if (!NVRTimePlaybackNewFragment.this.isPlayEnd || !NVRTimePlaybackNewFragment.this.mIsPlayback) {
                        NVRTimePlaybackNewFragment.this.HiDoPlayFast(playbackNvrVo, bArr, j3, i2, b);
                        return;
                    }
                    NVRTimePlaybackNewFragment.this.isPlayEnd = false;
                    NVRTimePlaybackNewFragment.this.mIsPlayback = false;
                    NVRTimePlaybackNewFragment.this.HiDoPlayFast(playbackNvrVo, bArr, j3, i2, b);
                }
            }
        }.start();
    }

    private void Hi_fileexists(byte[] bArr) {
        this.fileName = splitFileName(new HiChipDefines.STimeDay(bArr, 0).toString());
        String str = this.download_path + this.fileName + ".nvrh26x";
        HiLog.e("filepath:" + str);
        if (new File(str).exists()) {
            this.fileisDowned = true;
        }
    }

    private String splitFileName(String str) {
        long j;
        try {
            j = new SimpleDateFormat(TimeUtil.FORMAT_DATE_TIME_FULL).parse(str).getTime();
        } catch (ParseException e) {
            e.printStackTrace();
            j = 0;
        }
        return new SimpleDateFormat(TimeUtil.FORMAT_DATE_TIME_NEW2).format(Long.valueOf(j));
    }

    public void HiDoPlayFast(final PlaybackNvrVo playbackNvrVo, byte[] bArr, long j, int i, byte b) {
        Handler handler;
        HiTools.getMyGrandpaStackTrace();
        MyCamera myCamera = this.mMyCamera;
        if (myCamera == null || myCamera.mhiNvrdev == null) {
            return;
        }
        this.mMyCamera.mhiNvrdev.PlayLocal_Resume();
        if (HiTools.isSDCardValid()) {
            File file = new File(HiDataValue.getPathNVROnLineRecord(this.mMyCamera.getUid(), this.chn, this.mstrdate, getActivity()));
            if (!file.exists()) {
                file.mkdirs();
            }
            Handler handler2 = this.mhandlerPF;
            if (handler2 != null) {
                handler2.sendEmptyMessage(HANDLE_MESSAGE_PLAYONLINE_SHOWLOADVIEW);
            }
            bArr[7] = 4;
            getFirstTime(bArr);
            this.download_path = file.getAbsolutePath() + "/";
            this.fileName = splitFileName(new HiChipDefines.STimeDay(bArr, 0).toString());
            this.fileName += "_" + this.StreamType;
            String str = this.download_path + this.fileName + ".nvrh26x";
            HiLog.e("filepath:" + str + "::" + j + "::" + this.mAct.isDownloading + Constants.COLON_SEPARATOR + this.mAct.isCallDownload);
            if (j > 0) {
                this.mSavedragTime = (int) j;
            }
            if (new File(str).exists()) {
                this.fileisDowned = true;
                int StartPlayLocalTime = this.mMyCamera.mhiNvrdev.StartPlayLocalTime(str, ((int) j) * 1000);
                if (StartPlayLocalTime == 0 || StartPlayLocalTime == -10000 || (handler = this.mhandlerPF) == null) {
                    return;
                }
                handler.sendEmptyMessage(HANDLE_MESSAGE_PLAYONLINE_OPENFAIL);
                return;
            }
            this.fileisDowned = false;
            final String str2 = this.download_path + this.fileName + ".rec";
            File file2 = new File(str2);
            HiLog.e("filepath:" + str2);
            if (!file2.exists()) {
                HiLog.e("filepath:" + str2);
                try {
                    if (!file2.createNewFile()) {
                        return;
                    }
                } catch (IOException e) {
                    e.printStackTrace();
                }
                this.mAct.isDownloading = false;
                this.mAct.isCallDownload = false;
                checkPBFastCacheSize();
                new Thread() {
                    @Override
                    public void run() {
                        super.run();
                        NVRTimePlaybackNewFragment.this.isCallStopDown = false;
                        NVRTimePlaybackNewFragment.this.mAct.isCallDownload = true;
                        NVRTimePlaybackNewFragment.this.msavepVo = playbackNvrVo;
                        Packet.longToByteArray4_Little(playbackNvrVo.getU32StartPts(NVRTimePlaybackNewFragment.this.StreamType));
                        Packet.longToByteArray4_Little(playbackNvrVo.getU32StopPts(NVRTimePlaybackNewFragment.this.StreamType));
                        NVRTimePlaybackNewFragment.this.mMyCamera.mhiNvrdev.setPlaybackLocalPath(playbackNvrVo.getU16Width(NVRTimePlaybackNewFragment.this.StreamType), playbackNvrVo.getU16Height(NVRTimePlaybackNewFragment.this.StreamType), playbackNvrVo.getU8StreamCode(NVRTimePlaybackNewFragment.this.StreamType), playbackNvrVo.getU8AFormat(), str2);
                    }
                }.start();
                return;
            }
            HiLog.e("mAct.isCallDownloadfilepath:" + str2 + "::" + this.mAct.isDownloading + Constants.COLON_SEPARATOR + this.mAct.isCallDownload);
            if (this.mAct.isDownloading) {
                return;
            }
            this.mSaveSTimeDay = new HiChipDefines.STimeDay(bArr, 0);
            checkPBFastCacheSize();
            new Thread() {
                @Override
                public void run() {
                    super.run();
                    NVRTimePlaybackNewFragment.this.isCallStopDown = false;
                    NVRTimePlaybackNewFragment.this.mAct.isCallDownload = true;
                    String str3 = NVRTimePlaybackNewFragment.this.download_path + NVRTimePlaybackNewFragment.this.fileName + ".rec";
                    NVRTimePlaybackNewFragment.this.msavepVo = playbackNvrVo;
                    Packet.longToByteArray4_Little(playbackNvrVo.getU32StartPts(NVRTimePlaybackNewFragment.this.StreamType));
                    Packet.longToByteArray4_Little(playbackNvrVo.getU32StopPts(NVRTimePlaybackNewFragment.this.StreamType));
                    NVRTimePlaybackNewFragment.this.mMyCamera.mhiNvrdev.setPlaybackLocalPath(playbackNvrVo.getU16Width(NVRTimePlaybackNewFragment.this.StreamType), playbackNvrVo.getU16Height(NVRTimePlaybackNewFragment.this.StreamType), playbackNvrVo.getU8StreamCode(NVRTimePlaybackNewFragment.this.StreamType), playbackNvrVo.getU8AFormat(), str3);
                }
            }.start();
        }
    }

    private void getFirstTime(byte[] bArr) {
        long timeInMillis2 = new HiChipDefines.STimeDay(bArr, 0).getTimeInMillis2() / 1000;
        if (this.currentPlayVideoStartTime / 1000000 != timeInMillis2) {
            if (this.setpos == 0 || this.isOtherDay) {
                this.firstVideoStartTime = timeInMillis2 * 1000000;
                int findVideoFile = findVideoFile(1000 * timeInMillis2, -1);
                this.currentPlayPosition = findVideoFile;
                HiLogcatUtil.e("currentPlayPosition:" + this.currentPlayPosition + "::" + findVideoFile + "::" + timeInMillis2 + ":::" + this.myTimeLineView.getCurrentValue() + Constants.COLON_SEPARATOR + this.firstVideoStartTime);
            }
            this.oldTime = 0L;
        }
        this.setpos = 0;
        this.isOtherDay = false;
        this.currentPlayVideoStartTime = timeInMillis2 * 1000000;
    }

    protected void removeVideoList(int i) {
        this.mIsDataReceveEnd = false;
        this.firstVideoStartTime = 0L;
        this.currentPlayPosition = 0;
        this.currentPlayVideoStartTime = 0L;
        this.one_day_file_list.clear();
        this.file_list.clear();
        this.file_list1.clear();
        this.curentDayVideo.clear();
        this.videoLists.clear();
        this.videoLists1.clear();
        this.videoLists2.clear();
    }

    protected void switchVideoList(int i, int i2) {
        this.file_list.clear();
        this.file_list1.clear();
        findThreeDayFile(this.file_list, i, this.videoLists1);
        findThreeDayFile(this.file_list1, i, this.videoLists2);
        this.curentDayVideo.clear();
        if (this.alreadyGetVideoDay.contains(Integer.valueOf(this.nearVideoDay))) {
            int i3 = 0;
            while (true) {
                if (i3 >= this.videoLists.size()) {
                    break;
                }
                if (this.nearVideoDay == this.videoLists.get(i3).getDay_of_month()) {
                    this.curentDayVideo.addAll(this.videoLists.get(i3).getTodayVideos());
                    break;
                }
                i3++;
            }
        }
        if (this.myTimeLineView.getScaleMode() != 120) {
            if (this.curentDayVideo.size() > 0) {
                this.isNeedShowProgress = true;
                this.myTimeLineView.setVideos(this.file_list1, true, this.curentDayVideo.get(0).getStartTime());
                return;
            }
            pausePlayVideo();
            this.videoIsPause = true;
            this.videoIsPlaying = false;
            this.isNeedShowProgress = false;
            this.iv_placeholder.setVisibility(0);
            this.iv_placeholder.setLayoutParams(new RelativeLayout.LayoutParams(-1, this.mHeight));
            HiLogcatUtil.e("showcurrent_day_novideo");
            MyToast.showToast(this.mAct, getString(R.string.current_day_novideo));
            Calendar calendar = Calendar.getInstance();
            calendar.set(1, mYear);
            calendar.set(2, mMonth - 1);
            calendar.set(5, i);
            calendar.set(11, 0);
            calendar.set(12, 0);
            calendar.set(13, 1);
            this.myTimeLineView.setVideos(new ArrayList(), false, calendar.getTimeInMillis() * 1000);
            return;
        }
        if (this.curentDayVideo.size() > 0) {
            this.isNeedShowProgress = true;
            this.myTimeLineView.setVideos(this.file_list, true, this.curentDayVideo.get(0).getStartTime());
            return;
        }
        pausePlayVideo();
        this.videoIsPause = true;
        this.videoIsPlaying = false;
        this.isNeedShowProgress = false;
        this.iv_placeholder.setVisibility(0);
        this.iv_placeholder.setLayoutParams(new RelativeLayout.LayoutParams(-1, this.mHeight));
        HiLogcatUtil.e("showcurrent_day_novideo");
        MyToast.showToast(this.mAct, getString(R.string.current_day_novideo));
        Calendar calendar2 = Calendar.getInstance();
        calendar2.set(1, mYear);
        calendar2.set(2, mMonth - 1);
        calendar2.set(5, i);
        calendar2.set(11, 0);
        calendar2.set(12, 0);
        calendar2.set(13, 1);
        this.myTimeLineView.setVideos(new ArrayList(), false, calendar2.getTimeInMillis() * 1000);
    }

    private void findThreeDayFile(List<PlaybackNvrVo> list, int i, List<NVRVideoList> list2) {
        for (int i2 = 0; i2 < this.allHaveVideoDayList.size(); i2++) {
            if (i == this.allHaveVideoDayList.get(i2).intValue()) {
                getDayVideos(i, list2, list);
                return;
            }
        }
    }

    private void getDayVideos(int i, List<NVRVideoList> list, List<PlaybackNvrVo> list2) {
        for (int i2 = 0; i2 < list.size(); i2++) {
            if (i == list.get(i2).getDay_of_month()) {
                list2.addAll(list.get(i2).getTodayVideos());
                return;
            }
        }
    }

    public int getDay(long j) {
        if (j == 0) {
            return -1;
        }
        Calendar calendar = Calendar.getInstance();
        calendar.setTimeInMillis(j / 1000);
        return calendar.get(5);
    }

    @Override
    public void onResume() {
        super.onResume();
        HiLog.e("tedG--....onResume()....--");
        MyCamera myCamera = this.mMyCamera;
        if (myCamera != null) {
            myCamera.registerIOSessionListener(this);
            this.mMyCamera.registerPlayStateListener(this);
            if (this.mMyCamera.mhiNvrdev != null) {
                this.mMyCamera.mhiNvrdev.setLiveShowMonitor(this.monitor);
            }
            int i = SharePreUtils.getInt(HiDataValue.CACHE, getActivity(), "pictureSize" + HiDataValue.userAccount + this.mMyCamera.getUid());
            this.mPictureSize = i;
            if (i == -1) {
                this.mPictureSize = 0;
            }
        }
        if (this.videoIsPause && !this.videoIsPlaying && this.mIsVisibleToUser) {
            HiLog.i("tedG--....onResume()    我去暂停了....--" + this.mTimeInMicros);
            if (findVideoFile(this.mTimeInMicros, -1) == -1) {
                return;
            }
            HiLog.i("tedG--....onResume()    我去暂停了....--");
            pausePlayVideo();
            this.videoIsPause = false;
            this.videoIsPlaying = true;
        }
        NVRTimeAxisActivity nVRTimeAxisActivity = this.mAct;
        if (nVRTimeAxisActivity instanceof NVRTimeAxisActivity) {
            this.timeAxisActivity = nVRTimeAxisActivity;
        }
        if (getResources().getConfiguration().orientation == 1) {
            TimeLineNVR timeLineNVR = this.myTimeLineView;
            if (timeLineNVR != null && !timeLineNVR.isCanPlay && !this.videoIsPlaying && this.videoIsPause) {
                this.iv_placeholder.setVisibility(0);
                this.iv_placeholder.setLayoutParams(new RelativeLayout.LayoutParams(-1, this.mHeight));
            }
        } else {
            handLandscape(this.mPictureSize);
        }
        this.monitor.setVisibility(0);
    }

    @Override
    public void onPause() {
        super.onPause();
        HiLog.e("tedG--....onResume()    我去暂停了....--" + this.mTimeInMicros);
        if (this.mMyCamera != null) {
            if (this.myTimeLineView != null) {
                HiLog.e("tedG--....()....--" + this.mTimeInMicros + ";;;;");
                this.mTimeInMicros = this.myTimeLineView.getCurrentValue();
                HiLog.e("tedG--....()....--" + this.mTimeInMicros + ";;;;");
            }
            if (this.mAct.isDownloading || this.mAct.isCallDownload) {
                Packet.longToByteArray4_Little(this.msavepVo.getU32StartPts(this.StreamType));
                Packet.longToByteArray4_Little(this.msavepVo.getU32StopPts(this.StreamType));
            }
            if (this.mMyCamera.mhiNvrdev != null) {
                this.mMyCamera.mhiNvrdev.unregisterPlayNVRStateListener(this);
                this.mMyCamera.mhiNvrdev.unregisterPlayBackNVRStateListener(this);
                this.mMyCamera.mhiNvrdev.StopPlayLocal();
                this.isCallStopDown = true;
                this.mAct.isDownloading = false;
                this.mAct.isCallDownload = false;
            }
            Handler handler = this.mhandlerPF;
            if (handler != null) {
                handler.removeCallbacksAndMessages(null);
            }
            Handler handler2 = this.handler;
            if (handler2 != null) {
                handler2.removeCallbacksAndMessages(null);
            }
            this.mMyCamera.unregisterIOSessionListener(this);
            this.mMyCamera.unregisterPlayStateListener(this);
            if (!this.videoIsPause && this.videoIsPlaying) {
                pausePlayVideo();
                this.videoIsPlaying = false;
                this.videoIsPause = true;
            }
            MyPlaybackGLMonitor myPlaybackGLMonitor = this.monitor;
            if (myPlaybackGLMonitor != null) {
                myPlaybackGLMonitor.FreeMonitor();
            }
        }
        if (getResources().getConfiguration().orientation == 2 && getActivity() != null) {
            getActivity().setRequestedOrientation(1);
        }
        HiLog.e("tedG--....onResume()    我去暂停了....--" + this.mTimeInMicros);
    }

    @Subscribe(threadMode = ThreadMode.MAIN)
    public void getIsStop(MsyIsStop msyIsStop) {
        boolean ismIsStop = msyIsStop.ismIsStop();
        this.mIsCallStop = ismIsStop;
        if (ismIsStop) {
            this.videoIsPause = false;
            this.videoIsPlaying = false;
        }
    }

    @Subscribe(threadMode = ThreadMode.MAIN)
    public void getIsPlay(FilePlaybackModel filePlaybackModel) {
        this.mIsPlayback = filePlaybackModel.ismIsPlay();
    }

    @Subscribe(threadMode = ThreadMode.MAIN)
    public void getIsResetSize(ResetSizeModel resetSizeModel) {
        this.mIsResetSize = resetSizeModel.ismIsResetSize();
    }

    @Override
    public void setUserVisibleHint(boolean z) {
        super.setUserVisibleHint(z);
        HiLog.e("tedG--....onResume()....--");
        if (z) {
            this.mIsVisibleToUser = true;
            HiChipDefines.SD_FILEDAY sd_fileday = this.sd_fileday;
            if (sd_fileday != null && sd_fileday.num > 1) {
                this.timePlayStart = false;
            }
            if (this.myTimeLineView != null) {
                if (this.isFirstIn) {
                    this.timePlayStart = false;
                    this.isFirstIn = false;
                    this.mIsCallStop = false;
                    searchmonvideo();
                    return;
                }
                HiLog.e("test111mIsCallStop: " + this.mIsCallStop);
                if (this.mIsCallStop) {
                    this.videoIsPause = false;
                    this.videoIsPlaying = true;
                    MyPlaybackGLMonitor myPlaybackGLMonitor = this.monitor;
                    if (myPlaybackGLMonitor != null) {
                        myPlaybackGLMonitor.setmIsFullScreen(0);
                        this.mHeight = HiTools.dip2px(getContext(), 250.0f);
                        resetMonitorSize(false, 10000.0d);
                    }
                    hand0And1();
                    this.mIsCallStop = false;
                    return;
                }
                if (this.mIsResetSize) {
                    this.mIsResetSize = false;
                    MyPlaybackGLMonitor myPlaybackGLMonitor2 = this.monitor;
                    if (myPlaybackGLMonitor2 != null) {
                        myPlaybackGLMonitor2.setmIsFullScreen(0);
                        this.mHeight = HiTools.dip2px(getContext(), 250.0f);
                        resetMonitorSize(false, 10000.0d);
                    }
                }
                if (this.isPlayEnd) {
                    this.timePlayStart = true;
                    return;
                }
                if (!this.videoIsPause || this.videoIsPlaying) {
                    return;
                }
                HiLog.e("tedG--....()....--" + this.mTimeInMicros + ";;;;");
                int findVideoFile = findVideoFile(this.mTimeInMicros, -1);
                if (findVideoFile == -1) {
                    this.timePlayStart = true;
                    return;
                }
                pausePlayVideo();
                this.videoIsPause = false;
                this.videoIsPlaying = true;
                try {
                    HiLog.e("tedG--....()....--" + this.mTimeInMicros + ";;;;");
                    if (findVideoFile == this.curentDayVideo.size() - 1 && Math.abs((this.mTimeInMicros - this.curentDayVideo.get(findVideoFile).getEndTime()) / 1000000) < 3) {
                        this.timePlayStart = true;
                    }
                    HiLog.e("tedG--....()....--" + this.mTimeInMicros + ";;;;");
                    return;
                } catch (Exception e) {
                    e.printStackTrace();
                    return;
                }
            }
            return;
        }
        this.mIsVisibleToUser = false;
        if (this.mMyCamera != null) {
            if (this.myTimeLineView != null) {
                HiLog.e("tedG--....()....--" + this.mTimeInMicros + ";;;;");
                this.mTimeInMicros = this.myTimeLineView.getCurrentValue();
                HiLog.e("tedG--....()....--" + this.mTimeInMicros + ";;;;");
            }
            if (!this.videoIsPlaying || this.videoIsPause) {
                return;
            }
            pausePlayVideo();
            this.videoIsPause = true;
            this.videoIsPlaying = false;
        }
    }

    private void hand0And1() {
        int i;
        if (this.isPlayEnd) {
            this.timePlayStart = true;
            return;
        }
        long j = this.mTimeInMicros;
        int findVideoFile = findVideoFile(j, -1);
        if (findVideoFile == -1) {
            this.myTimeLineView.listener.onNoneVideo("", j);
            this.mBackToNoFile = true;
            return;
        }
        if (this.myTimeLineView.isScroll()) {
            return;
        }
        final PlaybackNvrVo playbackNvrVo = this.curentDayVideo.get(findVideoFile);
        this.oldTime = 0L;
        this.firstVideoStartTime = j;
        this.setpos = 1;
        HiLogcatUtil.e("currentPlayPosition:" + this.currentPlayPosition + "::" + findVideoFile + Constants.COLON_SEPARATOR + this.firstVideoStartTime);
        if (this.currentPlayPosition != findVideoFile) {
            if (this.mAct.isDownloading || this.mAct.isCallDownload) {
                Packet.longToByteArray4_Little(this.msavepVo.getU32StartPts(this.StreamType));
                Packet.longToByteArray4_Little(this.msavepVo.getU32StopPts(this.StreamType));
            }
            this.mMyCamera.mhiNvrdev.StopPlayLocal();
            this.isCallStopDown = true;
            this.mAct.isDownloading = false;
            this.mAct.isCallDownload = false;
            i = 1000;
        } else {
            i = 0;
        }
        this.currentPlayPosition = findVideoFile;
        final byte[] bArr = new byte[8];
        System.arraycopy(playbackNvrVo.getTest(), 0, bArr, 0, 8);
        long startTime = playbackNvrVo.getStartTime() / 1000;
        long endTime = playbackNvrVo.getEndTime() / 1000;
        final int startTime2 = (int) ((j - playbackNvrVo.getStartTime()) / 1000);
        playbackNvrVo.getFlag();
        HiTools.getMyGrandpaStackTrace();
        showLoadingView();
        if (this.isQuit) {
            return;
        }
        this.mhandlerPF.postDelayed(new Runnable() {
            @Override
            public void run() {
                NVRTimePlaybackNewFragment nVRTimePlaybackNewFragment = NVRTimePlaybackNewFragment.this;
                PlaybackNvrVo playbackNvrVo2 = playbackNvrVo;
                nVRTimePlaybackNewFragment.HiDoPlayFast(playbackNvrVo2, bArr, startTime2 / 1000, 1, playbackNvrVo2.getFlag());
            }
        }, i);
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        HiLog.e("tedG--....onResume()....--");
        MyPlaybackGLMonitor myPlaybackGLMonitor = this.monitor;
        if (myPlaybackGLMonitor != null) {
            myPlaybackGLMonitor.FreeMonitor();
        }
        Handler handler = this.lineHandler;
        if (handler != null) {
            handler.removeMessages(-1879048183);
        }
        if (this.mHandler_lockScreen != null) {
            this.root_lock_screen.setVisibility(8);
            this.mHandler_lockScreen.removeCallbacksAndMessages(null);
        }
        if (this.mMyCamera != null) {
            this.isQuit = true;
        }
        stopWatchOrientation();
        EventBus.getDefault().unregister(this);
    }

    public class AnonymousClass12 extends Handler {
        AnonymousClass12() {
        }

        @Override
        public void handleMessage(Message message) {
            int i = message.what;
            if (i == -1879048191) {
                int i2 = message.arg1;
                if ((i2 == 0 || i2 == 5) && NVRTimePlaybackNewFragment.this.mIsVisibleToUser) {
                    HiLogcatUtil.e("tedu", "--CAMERA_CONNECTION_STATE_DISCONNECTED--");
                    NVRTimePlaybackNewFragment.this.dismissLoadingView();
                    MyToast.showToast(NVRTimePlaybackNewFragment.this.mAct, NVRTimePlaybackNewFragment.this.getString(R.string.disconnect));
                    HiLogcatUtil.e("#############################  mMyCamera.stopPlaybackNew ###################### ");
                    if (NVRTimePlaybackNewFragment.this.mAct.isDownloading || NVRTimePlaybackNewFragment.this.mAct.isCallDownload) {
                        Packet.longToByteArray4_Little(NVRTimePlaybackNewFragment.this.msavepVo.getU32StartPts(NVRTimePlaybackNewFragment.this.StreamType));
                        Packet.longToByteArray4_Little(NVRTimePlaybackNewFragment.this.msavepVo.getU32StopPts(NVRTimePlaybackNewFragment.this.StreamType));
                    }
                    NVRTimePlaybackNewFragment.this.mMyCamera.mhiNvrdev.StopPlayLocal();
                    NVRTimePlaybackNewFragment.this.isCallStopDown = true;
                    NVRTimePlaybackNewFragment.this.mAct.isDownloading = false;
                    NVRTimePlaybackNewFragment.this.mAct.isCallDownload = false;
                    NVRTimePlaybackNewFragment.this.mAct.finish();
                    return;
                }
                return;
            }
            if (i == -1879048189) {
                if (message.arg2 == 0) {
                    NVRTimePlaybackNewFragment.this.handIOCTRLSuccess(message);
                    return;
                }
                NVRTimePlaybackNewFragment.this.dismissLoadingView();
                MyToast.showToast(NVRTimePlaybackNewFragment.this.mAct, NVRTimePlaybackNewFragment.this.getString(R.string.get_data_fail));
                if (message.arg1 != 16779) {
                    return;
                }
                NVRTimePlaybackNewFragment.this.mAct.iv_return.setEnabled(true);
                return;
            }
            if (i == -6) {
                HiLogcatUtil.e("################# timeline PLAY_ONLINESTATE_ERROR ##############  ");
                if (NVRTimePlaybackNewFragment.this.getActivity() != null) {
                    Toast.makeText(NVRTimePlaybackNewFragment.this.getActivity(), NVRTimePlaybackNewFragment.this.getString(R.string.play_4k_sd_error), 1).show();
                }
                if (NVRTimePlaybackNewFragment.this.mAct.isDownloading || NVRTimePlaybackNewFragment.this.mAct.isCallDownload) {
                    Packet.longToByteArray4_Little(NVRTimePlaybackNewFragment.this.msavepVo.getU32StartPts(NVRTimePlaybackNewFragment.this.StreamType));
                    Packet.longToByteArray4_Little(NVRTimePlaybackNewFragment.this.msavepVo.getU32StopPts(NVRTimePlaybackNewFragment.this.StreamType));
                }
                NVRTimePlaybackNewFragment.this.mMyCamera.mhiNvrdev.StopPlayLocal();
                NVRTimePlaybackNewFragment.this.isCallStopDown = true;
                NVRTimePlaybackNewFragment.this.mAct.isDownloading = false;
                NVRTimePlaybackNewFragment.this.mAct.isCallDownload = false;
                NVRTimePlaybackNewFragment.this.mMyCamera.setReconnectTimes(10);
                NVRTimePlaybackNewFragment.this.startActivity(new Intent(NVRTimePlaybackNewFragment.this.mAct, (Class<?>) MainActivity.class));
                return;
            }
            if (i == 0) {
                NVRTimePlaybackNewFragment.this.isReadyPlay = true;
                NVRTimePlaybackNewFragment.this.mIsEnd = false;
                HiLogcatUtil.e("tedu", "-播放开始-PLAY_STATE_START--");
                NVRTimePlaybackNewFragment.this.handler.postDelayed(new Runnable() {
                    @Override
                    public final void run() {
                        NVRTimePlaybackNewFragment.AnonymousClass12.this.lambda$handleMessage$0$NVRTimePlaybackNewFragment$12();
                    }
                }, 100L);
                NVRTimePlaybackNewFragment.this.myTimeLineView.isCanPlay = true;
                NVRTimePlaybackNewFragment.this.isPlayEnd = false;
                NVRTimePlaybackNewFragment.this.videoIsPlaying = true;
                NVRTimePlaybackNewFragment.this.iv_placeholder.setVisibility(8);
                if (NVRTimePlaybackNewFragment.this.getResources().getConfiguration().orientation == 1) {
                    NVRTimePlaybackNewFragment.this.iv_full_screen.setVisibility(0);
                }
                NVRTimePlaybackNewFragment.this.dismissLoadingView();
                NVRTimePlaybackNewFragment.this.startWatchOrientation();
                NVRTimePlaybackNewFragment.this.rb_all.setEnabled(true);
                NVRTimePlaybackNewFragment.this.rb_alarm.setEnabled(true);
                return;
            }
            if (i != 1) {
                if (i != 2) {
                    return;
                }
                HiLogcatUtil.e("tedu", "--PLAY_STATE_POS--");
                NVRTimePlaybackNewFragment.this.myTimeLineView.isCanPlay = true;
                NVRTimePlaybackNewFragment.this.dismissLoadingView();
                return;
            }
            HiLogcatUtil.e("tedu", "--PLAY_STATE_EDN--");
            NVRTimePlaybackNewFragment.this.mIsEnd = true;
            NVRTimePlaybackNewFragment.this.isPlayEnd = true;
            MyToast.showToast(NVRTimePlaybackNewFragment.this.mAct, NVRTimePlaybackNewFragment.this.getString(R.string.tips_stop_video));
            NVRTimePlaybackNewFragment.this.myTimeLineView.isCanPlay = false;
            if (!NVRTimePlaybackNewFragment.this.videoIsPause && NVRTimePlaybackNewFragment.this.videoIsPlaying) {
                NVRTimePlaybackNewFragment.this.pausePlayVideo();
                NVRTimePlaybackNewFragment.this.videoIsPause = true;
                NVRTimePlaybackNewFragment.this.videoIsPlaying = false;
            }
            NVRTimePlaybackNewFragment.this.shadowView.setVisibility(8);
            NVRTimePlaybackNewFragment.this.rb_all.setEnabled(true);
            NVRTimePlaybackNewFragment.this.rb_alarm.setEnabled(true);
        }

        public void lambda$handleMessage$0$NVRTimePlaybackNewFragment$12() {
            NVRTimePlaybackNewFragment.this.shadowView.setVisibility(8);
        }
    }

    public void handIOCTRLSuccess(Message message) {
        ?? r8;
        boolean z;
        long j;
        boolean z2;
        String str;
        int i;
        int i2;
        boolean z3;
        byte[] bArr;
        byte[] bArr2;
        String str2;
        byte[] bArr3;
        String str3;
        int i3;
        int i4;
        char c;
        byte[] byteArray = message.getData().getByteArray("data");
        int i5 = message.arg1;
        String str4 = "::";
        int i6 = 0;
        int i7 = 1;
        if (i5 == 1174405123) {
            long timeInMillis2 = new HiChipDefines.Record_FILE_INFO(byteArray).sStartTime.getTimeInMillis2() / 1000;
            if (this.currentPlayVideoStartTime / 1000000 != timeInMillis2) {
                if (this.setpos == 0 || this.isOtherDay) {
                    this.firstVideoStartTime = timeInMillis2 * 1000000;
                    int findVideoFile = findVideoFile(timeInMillis2 * 1000, -1);
                    z = false;
                    HiLogcatUtil.e("currentPlayPosition:" + this.currentPlayPosition + "::" + findVideoFile + Constants.COLON_SEPARATOR + this.firstVideoStartTime);
                    this.currentPlayPosition = findVideoFile;
                    j = 0;
                } else {
                    j = 0;
                    z = false;
                }
                this.oldTime = j;
                r8 = z;
            } else {
                r8 = 0;
            }
            this.setpos = r8;
            this.isOtherDay = r8;
            this.currentPlayVideoStartTime = timeInMillis2 * 1000000;
            return;
        }
        String str5 = "MsgCalenderDay:";
        switch (i5) {
            case HiChipNVRDefines.HI_NVR_P2P_PLATFORM_GET_PLAYBACKFILE:
                HiChipNVRDefines.PLATFORM_S_PLAYBACKFILE_LIST_REP platform_s_playbackfile_list_rep = new HiChipNVRDefines.PLATFORM_S_PLAYBACKFILE_LIST_REP(byteArray);
                HiLogcatUtil.e(this.mMyCamera.getUid() + "HI_NVR_P2P_PLATFORM_GET_PLAYBACKFILE" + platform_s_playbackfile_list_rep.total + "::" + platform_s_playbackfile_list_rep.index + "::" + platform_s_playbackfile_list_rep.endflag + "::" + platform_s_playbackfile_list_rep.count + "::" + byteArray.length);
                int i8 = 120;
                if (platform_s_playbackfile_list_rep.endflag == 2) {
                    byte[] bArr4 = new byte[8];
                    byte[] bArr5 = new byte[8];
                    byte[] bArr6 = new byte[120];
                    int i9 = 0;
                    while (i9 < platform_s_playbackfile_list_rep.count) {
                        int i10 = (i9 * 120) + 12;
                        if (byteArray.length >= i10 + 120) {
                            System.arraycopy(byteArray, i10, bArr6, i6, i8);
                            HiChipNVRDefines.PLATFORM_S_PLAYBACKFILE platform_s_playbackfile = new HiChipNVRDefines.PLATFORM_S_PLAYBACKFILE(bArr6);
                            String[] strArr = new String[i7];
                            StringBuilder sb = new StringBuilder();
                            sb.append(this.mMyCamera.getUid());
                            sb.append("PLATFORM_GET_PLAYBACKFILE:");
                            sb.append(platform_s_playbackfile.eAlarmType);
                            sb.append(str4);
                            sb.append(platform_s_playbackfile.u32StartTime);
                            sb.append(str4);
                            sb.append(platform_s_playbackfile.u32StopTime);
                            sb.append(str4);
                            sb.append(Packet.getString(platform_s_playbackfile.sFilePath));
                            sb.append(":u16Width:");
                            sb.append(platform_s_playbackfile.u16Width[i6]);
                            sb.append(str4);
                            sb.append(platform_s_playbackfile.u16Width[i7]);
                            sb.append(":u16Height:");
                            sb.append(platform_s_playbackfile.u16Height[i6]);
                            sb.append(str4);
                            sb.append(platform_s_playbackfile.u16Height[i7]);
                            sb.append(":u32StartPts:");
                            byte[] bArr7 = bArr6;
                            sb.append(platform_s_playbackfile.u32StartPts[i6]);
                            sb.append(str4);
                            sb.append(platform_s_playbackfile.u32StartPts[1]);
                            sb.append(":u32StopPts:");
                            sb.append(platform_s_playbackfile.u32StopPts[i6]);
                            sb.append(str4);
                            sb.append(platform_s_playbackfile.u32StopPts[1]);
                            sb.append(str4);
                            sb.append(platform_s_playbackfile.u8AFormat);
                            sb.append(":u8StreamCode:");
                            sb.append((int) platform_s_playbackfile.u8StreamCode[i6]);
                            sb.append(str4);
                            sb.append((int) platform_s_playbackfile.u8StreamCode[1]);
                            strArr[i6] = sb.toString();
                            HiLogcatUtil.e(strArr);
                            higetSTimeDay(bArr4, bArr5, Packet.getString(platform_s_playbackfile.sFilePath));
                            HiChipDefines.STimeDay sTimeDay = new HiChipDefines.STimeDay(bArr4, i6);
                            HiChipDefines.STimeDay sTimeDay2 = new HiChipDefines.STimeDay(bArr5, i6);
                            long timeInMillis = sTimeDay2.getTimeInMillis() - sTimeDay.getTimeInMillis();
                            if (timeInMillis > 2000000 || timeInMillis <= 0) {
                                bArr = bArr4;
                                bArr2 = bArr5;
                                str2 = str4;
                                str3 = str5;
                                bArr3 = bArr7;
                            } else {
                                str2 = str4;
                                str3 = str5;
                                byte[] bArr8 = bArr4;
                                byte[] bArr9 = bArr5;
                                PlaybackNvrVo playbackNvrVo = new PlaybackNvrVo(sTimeDay.getTimeInMillis2() * 1000, sTimeDay2.getTimeInMillis2() * 1000, sTimeDay.parseContent(), platform_s_playbackfile.u16Width, platform_s_playbackfile.u16Height, platform_s_playbackfile.u32StartPts, platform_s_playbackfile.u32StopPts, platform_s_playbackfile.u8AFormat, platform_s_playbackfile.u8StreamCode, Packet.getString(platform_s_playbackfile.sFilePath), this.fileType, (byte) this.mgetvideotype);
                                this.one_day_file_list.add(playbackNvrVo);
                                handFileList(this.fileType, playbackNvrVo);
                                PlaybackNvrVo playbackNvrVo2 = new PlaybackNvrVo(sTimeDay.getTimeInMillis2() * 1000, sTimeDay2.getTimeInMillis2() * 1000, sTimeDay.parseContent(), platform_s_playbackfile.u16Width, platform_s_playbackfile.u16Height, platform_s_playbackfile.u32StartPts, platform_s_playbackfile.u32StopPts, platform_s_playbackfile.u8AFormat, platform_s_playbackfile.u8StreamCode, Packet.getString(platform_s_playbackfile.sFilePath), this.fileType, (byte) this.mgetvideotype);
                                playbackNvrVo2.setEventType(this.fileType);
                                if (i9 == platform_s_playbackfile_list_rep.count - 1) {
                                    playbackNvrVo2.getEndTA().setTimeInMillis(sTimeDay2.getTimeInMillis2());
                                    this.file_list1.add(playbackNvrVo2);
                                    bArr3 = bArr7;
                                    bArr2 = bArr9;
                                    i3 = 1;
                                    bArr = bArr8;
                                    i9 += i3;
                                    bArr5 = bArr2;
                                    bArr6 = bArr3;
                                    str4 = str2;
                                    str5 = str3;
                                    i6 = 0;
                                    i8 = 120;
                                    i7 = i3;
                                    bArr4 = bArr;
                                } else {
                                    int i11 = i9 + 1;
                                    byte[] bArr10 = bArr7;
                                    System.arraycopy(byteArray, (i11 * 120) + 12, bArr10, 0, 120);
                                    byte[] bArr11 = bArr8;
                                    bArr2 = bArr9;
                                    higetSTimeDay(bArr11, bArr2, Packet.getString(new HiChipNVRDefines.PLATFORM_S_PLAYBACKFILE(bArr10).sFilePath));
                                    new HiChipDefines.STimeDay(bArr11, 0);
                                    new HiChipDefines.STimeDay(bArr2, 0);
                                    if (playbackNvrVo2.getEventType() != this.mgetvideotype) {
                                        playbackNvrVo2.getEndTA().setTimeInMillis(sTimeDay2.getTimeInMillis2());
                                        this.file_list1.add(playbackNvrVo2);
                                        bArr3 = bArr10;
                                        bArr = bArr11;
                                    } else {
                                        int i12 = i11;
                                        while (true) {
                                            if (i12 < platform_s_playbackfile_list_rep.count) {
                                                i4 = 0;
                                                System.arraycopy(byteArray, (i12 * 120) + 12, bArr10, 0, 120);
                                                HiChipNVRDefines.PLATFORM_S_PLAYBACKFILE platform_s_playbackfile2 = new HiChipNVRDefines.PLATFORM_S_PLAYBACKFILE(bArr10);
                                                higetSTimeDay(bArr11, bArr2, Packet.getString(platform_s_playbackfile2.sFilePath));
                                                HiChipDefines.STimeDay sTimeDay3 = new HiChipDefines.STimeDay(bArr11, 0);
                                                new HiChipDefines.STimeDay(bArr2, 0);
                                                if (sTimeDay3.getTimeInMillis2() - sTimeDay2.getTimeInMillis2() <= 60000) {
                                                    higetSTimeDay(bArr11, bArr2, Packet.getString(platform_s_playbackfile2.sFilePath));
                                                    new HiChipDefines.STimeDay(bArr11, 0);
                                                    sTimeDay2 = new HiChipDefines.STimeDay(bArr2, 0);
                                                    i9 = i12;
                                                    i12++;
                                                }
                                            }
                                            i4 = 0;
                                        }
                                        while (i11 <= i9) {
                                            System.arraycopy(byteArray, (i11 * 120) + 12, bArr10, i4, 120);
                                            HiChipNVRDefines.PLATFORM_S_PLAYBACKFILE platform_s_playbackfile3 = new HiChipNVRDefines.PLATFORM_S_PLAYBACKFILE(bArr10);
                                            higetSTimeDay(bArr11, bArr2, Packet.getString(platform_s_playbackfile3.sFilePath));
                                            HiChipDefines.STimeDay sTimeDay4 = new HiChipDefines.STimeDay(bArr11, i4);
                                            PlaybackNvrVo playbackNvrVo3 = new PlaybackNvrVo(sTimeDay4.getTimeInMillis2() * 1000, new HiChipDefines.STimeDay(bArr2, i4).getTimeInMillis2() * 1000, sTimeDay4.parseContent(), platform_s_playbackfile3.u16Width, platform_s_playbackfile3.u16Height, platform_s_playbackfile3.u32StartPts, platform_s_playbackfile3.u32StopPts, platform_s_playbackfile3.u8AFormat, platform_s_playbackfile3.u8StreamCode, Packet.getString(platform_s_playbackfile3.sFilePath), this.fileType, (byte) this.mgetvideotype);
                                            handFileList(this.mgetvideotype, playbackNvrVo3);
                                            this.one_day_file_list.add(playbackNvrVo3);
                                            i11++;
                                            bArr10 = bArr10;
                                            i9 = i9;
                                            bArr11 = bArr11;
                                            i4 = 0;
                                        }
                                        bArr3 = bArr10;
                                        bArr = bArr11;
                                        playbackNvrVo2.getEndTA().setTimeInMillis(sTimeDay2.getTimeInMillis2());
                                        this.file_list1.add(playbackNvrVo2);
                                    }
                                }
                            }
                        } else {
                            bArr = bArr4;
                            bArr2 = bArr5;
                            str2 = str4;
                            bArr3 = bArr6;
                            str3 = str5;
                        }
                        i3 = 1;
                        i9 += i3;
                        bArr5 = bArr2;
                        bArr6 = bArr3;
                        str4 = str2;
                        str5 = str3;
                        i6 = 0;
                        i8 = 120;
                        i7 = i3;
                        bArr4 = bArr;
                    }
                    z2 = i7;
                    str = str5;
                } else {
                    z2 = 1;
                    str = "MsgCalenderDay:";
                    int i13 = platform_s_playbackfile_list_rep.endflag;
                }
                if (platform_s_playbackfile_list_rep.endflag == 3) {
                    this.mIsDataReceveEnd = z2;
                    dismissLoadingView();
                    this.mAct.iv_return.setEnabled(z2);
                    this.previousStartTime = 0L;
                    this.previousEndTime = 0L;
                    this.mergeStartTime = 0L;
                    this.mergeEndTime = 0L;
                    this.mergeStartTime1 = 0L;
                    this.mergeEndTime1 = 0L;
                    if (this.one_day_file_list.size() > 0) {
                        ArrayList arrayList = new ArrayList();
                        arrayList.addAll(this.one_day_file_list);
                        this.videoLists.add(new NVRVideoList(this.nearVideoDay, arrayList));
                        ArrayList arrayList2 = new ArrayList();
                        arrayList2.addAll(this.file_list);
                        this.videoLists1.add(new NVRVideoList(this.nearVideoDay, arrayList2));
                        ArrayList arrayList3 = new ArrayList();
                        arrayList3.addAll(this.file_list1);
                        this.videoLists2.add(new NVRVideoList(this.nearVideoDay, arrayList3));
                        long startTime = this.one_day_file_list.get(0).getStartTime();
                        if (this.calStartDate.get(1) != mYear || this.calStartDate.get(2) + 1 != mMonth) {
                            z3 = true;
                            jumpCurrentYM(mYear, this.calStartDate.get(1), mMonth, this.calStartDate.get(2) + 1);
                        } else {
                            HiLog.e(str);
                            EventBus.getDefault().post(new MsgCalenderDay(this.allHaveVideoDayList, this.alreadyGetVideoDay, this.mSelectPosition, this.currPager));
                            z3 = true;
                        }
                        this.isNeedShowProgress = z3;
                        if (this.myTimeLineView.getScaleMode() != 120) {
                            this.myTimeLineView.setVideos(this.file_list1, z3, startTime);
                            return;
                        } else {
                            this.myTimeLineView.setVideos(this.file_list, z3, startTime);
                            return;
                        }
                    }
                    this.rb_all.setEnabled(true);
                    this.rb_alarm.setEnabled(true);
                    this.iv_placeholder.setVisibility(0);
                    this.iv_placeholder.setLayoutParams(new RelativeLayout.LayoutParams(-1, this.mHeight));
                    HiLogcatUtil.e(this.currentTypeIs2 + "showcurrent_day_novideo");
                    if (this.currentTypeIs2) {
                        MyToast.showToast(this.mAct, getString(R.string.time_no_alarm));
                    } else {
                        MyToast.showToast(this.mAct, getString(R.string.current_day_novideo));
                    }
                    this.shadowView.setVisibility(8);
                    this.timePlayStart = true;
                    if (this.calStartDate.get(1) != mYear || this.calStartDate.get(2) + 1 != mMonth) {
                        i = 1;
                        i2 = 2;
                        jumpCurrentYM(mYear, this.calStartDate.get(1), mMonth, this.calStartDate.get(2) + 1);
                    } else {
                        HiLog.e(str);
                        EventBus.getDefault().post(new MsgCalenderDay(this.allHaveVideoDayList, this.alreadyGetVideoDay, this.mSelectPosition, this.currPager));
                        i = 1;
                        i2 = 2;
                    }
                    Calendar calendar = Calendar.getInstance();
                    calendar.set(i, mYear);
                    calendar.set(i2, mMonth + i);
                    calendar.set(5, this.nearVideoDay);
                    calendar.set(11, 0);
                    calendar.set(12, 0);
                    calendar.set(13, i);
                    this.isNeedShowProgress = false;
                    this.myTimeLineView.setVideos(new ArrayList(), false, calendar.getTimeInMillis() * 1000);
                    return;
                }
                return;
            case HiChipNVRDefines.HI_NVR_P2P_PLATFORM_PLAYBACKFILE:
                this.mMyCamera.mhiNvrdev.stopPlaybackThread();
                this.mMyCamera.mhiNvrdev.startPlaybackThread();
                return;
            case HiChipNVRDefines.HI_NVR_P2P_PLATFORM_GET_MONTHPLAYBACKFILE:
                this.mMonthfile = new HiChipNVRDefines.PLATFORM_S_MONTHPLAYBACKFILE_REP(byteArray);
                HiLogcatUtil.e(this.mMyCamera.getUid() + "HI_NVR_P2P_PLATFORM_GET_MONTHPLAYBACKFILE" + this.mMonthfile.szDay + Packet.getString(this.mMonthfile.szDay));
                int i14 = 0;
                while (true) {
                    if (i14 >= 32) {
                        c = 0;
                    } else if (this.mMonthfile.szDay[i14] == 1) {
                        c = 1;
                    } else {
                        i14++;
                    }
                }
                this.viewpager.setScanScroll(true);
                if (this.isCalenderChangedMonth) {
                    if (c < 1) {
                        dismissLoadingView();
                        HiLog.e("MsgCalenderDay:");
                        EventBus.getDefault().post(new MsgCalenderDay(new ArrayList(), new ArrayList(), -1, this.currPager));
                        return;
                    }
                    for (int i15 = 30; i15 > -1; i15--) {
                        if (this.mMonthfile.szDay[i15] == 1) {
                            this.otherMonthAllHaveVideoDayList.add(Integer.valueOf(i15 + 1));
                        }
                    }
                    Collections.reverse(this.otherMonthAllHaveVideoDayList);
                    HiLog.e("MsgCalenderDay:");
                    EventBus.getDefault().post(new MsgCalenderDay(this.otherMonthAllHaveVideoDayList, new ArrayList(), -1, this.currPager));
                    return;
                }
                if (c < 1) {
                    dismissLoadingView();
                    this.iv_placeholder.setLayoutParams(new RelativeLayout.LayoutParams(-1, this.mHeight));
                    this.iv_placeholder.setVisibility(0);
                    HiLog.e("MsgCalenderDay:");
                    EventBus.getDefault().post(new MsgCalenderDay(this.allHaveVideoDayList, this.alreadyGetVideoDay, this.mSelectPosition, this.currPager));
                    MyToast.showToast(this.mAct, getString(R.string.current_moth_novideo));
                    this.timePlayStart = true;
                    this.mIsDataReceveEnd = true;
                    this.iv_full_screen.setVisibility(8);
                    this.iv_snapshot.setVisibility(8);
                    return;
                }
                this.iv_placeholder.setVisibility(4);
                int i16 = Calendar.getInstance().get(5);
                boolean z4 = true;
                for (int i17 = i16 - 1; i17 > -1; i17--) {
                    HiLogcatUtil.e("--mDay--:" + i16 + "::" + i17 + "::" + ((int) this.mMonthfile.szDay[i17]));
                    if (this.mMonthfile.szDay[i17] == 1 && z4) {
                        this.one_day_file_list.clear();
                        this.file_list.clear();
                        this.file_list1.clear();
                        HiLogcatUtil.e("--sendIOCtrl(HiChipDefines.HI_NVR_P2P_PLATFORM_GET_PLAYBACKFILE  2222--:");
                        this.mAct.iv_return.setEnabled(false);
                        HiLogcatUtil.e("--我去请求当天录像文件了  返回键禁掉--");
                        this.mIsDataReceveEnd = false;
                        String str6 = this.mstrdate;
                        if (i17 < 10) {
                            this.mstrdate = str6 + PushConstants.PUSH_TYPE_NOTIFY + i17;
                        } else {
                            this.mstrdate = str6 + i17;
                        }
                        int i18 = i17 + 1;
                        String str7 = i18 < 10 ? str6 + PushConstants.PUSH_TYPE_NOTIFY + i18 : str6 + i18;
                        this.mstrdate = str7;
                        this.mMyCamera.sendIOCtrl(HiChipNVRDefines.HI_NVR_P2P_PLATFORM_GET_PLAYBACKFILE, HiChipNVRDefines.PLATFORM_S_PLAYBACKFILE_LIST_REQ.parseContent(this.chn, this.mgetvideotype, str7.getBytes()));
                        this.alreadyGetVideoDay.add(Integer.valueOf(i18));
                        this.nearVideoDay = i18;
                        this.recentHaveVideoDay = i18;
                        if (i18 == i16) {
                            this.todayHasVideo = true;
                        } else {
                            this.todayHasVideo = false;
                        }
                        z4 = false;
                    }
                    if (this.mMonthfile.szDay[i17] == 1) {
                        this.myTimeLineView.date[i17] = 1;
                        this.allHaveVideoDayList.add(Integer.valueOf(i17 + 1));
                    }
                }
                Collections.reverse(this.allHaveVideoDayList);
                Iterator<Integer> it = this.allHaveVideoDayList.iterator();
                while (it.hasNext()) {
                    HiLogcatUtil.e("--当月有录像的天数--:" + it.next().intValue());
                }
                HiLog.e("MsgCalenderDay:");
                EventBus.getDefault().post(new MsgCalenderDay(this.allHaveVideoDayList, this.alreadyGetVideoDay, this.mSelectPosition, this.currPager));
                HiLog.e("-11-被观察者发出通知---allHaveVideoDayList-:" + this.allHaveVideoDayList.size() + "-alreadyGetVideoDay-:" + this.alreadyGetVideoDay.size() + "-mSelectPosition-:" + this.mSelectPosition + "-currPager-:" + this.currPager);
                return;
            default:
                return;
        }
    }

    private void higetSTimeDay(byte[] bArr, byte[] bArr2, String str) {
        if (this.mstrdate.length() < 8) {
            return;
        }
        byte[] bArr3 = new byte[8];
        int parseInt = Integer.parseInt(this.mstrdate.substring(0, 4));
        int parseInt2 = Integer.parseInt(this.mstrdate.substring(4, 6));
        int parseInt3 = Integer.parseInt(this.mstrdate.substring(6, 8));
        String[] split = str.split("/");
        if (split.length < 1) {
            return;
        }
        String str2 = split[split.length - 1];
        int parseInt4 = Integer.parseInt(str2.substring(0, 2));
        int parseInt5 = Integer.parseInt(str2.substring(2, 4));
        int parseInt6 = Integer.parseInt(str2.substring(4, 6));
        int parseInt7 = Integer.parseInt(str2.substring(7, 9));
        int parseInt8 = Integer.parseInt(str2.substring(9, 11));
        int parseInt9 = Integer.parseInt(str2.substring(11, 13));
        HiLogcatUtil.e("" + parseInt + "::" + parseInt2 + "::" + parseInt3 + "::" + parseInt4 + "::" + parseInt5 + "::" + parseInt6 + "::" + parseInt7 + "::" + parseInt8 + "::" + parseInt9);
        System.arraycopy(Packet.shortToByteArray_Little((short) parseInt), 0, bArr3, 0, 2);
        bArr3[2] = (byte) parseInt2;
        bArr3[3] = (byte) parseInt3;
        bArr3[4] = (byte) parseInt4;
        bArr3[5] = (byte) parseInt5;
        bArr3[6] = (byte) parseInt6;
        System.arraycopy(bArr3, 0, bArr, 0, 8);
        bArr3[4] = (byte) parseInt7;
        bArr3[5] = (byte) parseInt8;
        bArr3[6] = (byte) parseInt9;
        System.arraycopy(bArr3, 0, bArr2, 0, 8);
    }

    private void jumpCurrentYM(int i, int i2, int i3, int i4) {
        int i5 = 0;
        if (i > i2) {
            int i6 = ((i - i2) * 12) + 0;
            i5 = i3 >= i4 ? i6 + (i3 - i4) : i6 + (12 - i4);
        } else if (i == i2) {
            i5 = i3 >= i4 ? i3 - i4 : -(i4 - i3);
        }
        NoSlidingViewPager noSlidingViewPager = this.viewpager;
        if (noSlidingViewPager != null) {
            noSlidingViewPager.setCurrentItem(this.currPager + i5);
        }
    }

    private void handFileList(int i, PlaybackNvrVo playbackNvrVo) {
        if (this.file_list.size() <= 0) {
            playbackNvrVo.setEventType(i);
            this.file_list.add(playbackNvrVo);
            return;
        }
        PlaybackNvrVo playbackNvrVo2 = this.file_list.get(r0.size() - 1);
        int eventType = playbackNvrVo2.getEventType();
        if (i == 2 && eventType == 2 && playbackNvrVo.getStartTime() - playbackNvrVo2.getEndTime() <= 1000000) {
            playbackNvrVo2.getEndTA().setTimeInMillis(playbackNvrVo.getEndTime() / 1000);
            return;
        }
        if (i != 2 && eventType != 2 && playbackNvrVo.getStartTime() - playbackNvrVo2.getEndTime() <= 1000000) {
            playbackNvrVo2.getEndTA().setTimeInMillis(playbackNvrVo.getEndTime() / 1000);
        } else {
            playbackNvrVo.setEventType(i);
            this.file_list.add(playbackNvrVo);
        }
    }

    private void HiclickSpeed(TextView textView, boolean z) {
        int dip2px;
        View inflate = getLayoutInflater().inflate(R.layout.popview_videospeed, (ViewGroup) null, false);
        this.videoSpeedPopupWindow = new PopupWindow(inflate);
        this.videoSpeedPopupWindow.setBackgroundDrawable(new ColorDrawable(0));
        this.videoSpeedPopupWindow.setOutsideTouchable(true);
        this.videoSpeedPopupWindow.setFocusable(false);
        this.videoSpeedPopupWindow.setWidth(-2);
        this.videoSpeedPopupWindow.setHeight(-2);
        int[] iArr = new int[2];
        textView.getLocationOnScreen(iArr);
        int dip2px2 = HiTools.dip2px(getActivity(), 150.0f);
        if (z) {
            dip2px = !this.isLeft ? 0 : LiuHaiScreenTools.getNotchHeight(getActivity()) - HiTools.dip2px(getActivity(), 5.0f);
        } else {
            dip2px = HiTools.dip2px(getActivity(), 15.0f);
        }
        this.videoSpeedPopupWindow.showAtLocation(textView, 0, iArr[0] - dip2px, iArr[1] - dip2px2);
        final TextView textView2 = (TextView) inflate.findViewById(R.id.speed_16);
        final TextView textView3 = (TextView) inflate.findViewById(R.id.speed_8);
        final TextView textView4 = (TextView) inflate.findViewById(R.id.speed_4);
        final TextView textView5 = (TextView) inflate.findViewById(R.id.speed_0);
        this.mMyCamera.getVideoQuality();
        int i = this.mSpeed;
        if (i == 0) {
            textView2.setSelected(false);
            textView3.setSelected(false);
            textView4.setSelected(false);
            textView5.setSelected(true);
        } else if (i == 4) {
            textView2.setSelected(false);
            textView3.setSelected(false);
            textView4.setSelected(true);
            textView5.setSelected(false);
        } else if (i == 8) {
            textView2.setSelected(false);
            textView3.setSelected(true);
            textView4.setSelected(false);
            textView5.setSelected(false);
        } else if (i == 16) {
            textView2.setSelected(true);
            textView3.setSelected(false);
            textView4.setSelected(false);
            textView5.setSelected(false);
        }
        textView2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                NVRTimePlaybackNewFragment.this.mSpeed = 16;
                NVRTimePlaybackNewFragment.this.ResetPlayFastSpeed();
                textView2.setSelected(true);
                textView3.setSelected(false);
                textView4.setSelected(false);
                textView5.setSelected(false);
                NVRTimePlaybackNewFragment.this.videoSpeedPopupWindow.dismiss();
            }
        });
        textView3.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                NVRTimePlaybackNewFragment.this.mSpeed = 8;
                NVRTimePlaybackNewFragment.this.ResetPlayFastSpeed();
                textView2.setSelected(false);
                textView3.setSelected(true);
                textView4.setSelected(false);
                textView5.setSelected(false);
                NVRTimePlaybackNewFragment.this.videoSpeedPopupWindow.dismiss();
            }
        });
        textView4.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                NVRTimePlaybackNewFragment.this.mSpeed = 4;
                NVRTimePlaybackNewFragment.this.ResetPlayFastSpeed();
                textView2.setSelected(false);
                textView3.setSelected(false);
                textView4.setSelected(true);
                textView5.setSelected(false);
                NVRTimePlaybackNewFragment.this.videoSpeedPopupWindow.dismiss();
            }
        });
        textView5.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                NVRTimePlaybackNewFragment.this.mSpeed = 0;
                NVRTimePlaybackNewFragment.this.ResetPlayFastSpeed();
                textView2.setSelected(false);
                textView3.setSelected(false);
                textView4.setSelected(false);
                textView5.setSelected(true);
                NVRTimePlaybackNewFragment.this.videoSpeedPopupWindow.dismiss();
            }
        });
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.iv_adaption:
                handPictureSize();
                return;
            case R.id.iv_full_screen:
                this.mIsClickReturn = false;
                if (getResources().getConfiguration().orientation == 1) {
                    this.mAct.setRequestedOrientation(0);
                } else if (getResources().getConfiguration().orientation == 2) {
                    this.mAct.setRequestedOrientation(1);
                }
                this.monitor.setVisibility(4);
                return;
            case R.id.iv_left:
                if (HiTools.isCustomFastClick(500)) {
                    return;
                }
                showPreMonth();
                return;
            case R.id.iv_return:
                if (getResources().getConfiguration().orientation == 1) {
                    return;
                }
                this.mIsClickReturn = true;
                releaseLockScreen();
                this.mAct.setRequestedOrientation(1);
                return;
            case R.id.iv_right:
                if (HiTools.isCustomFastClick(500)) {
                    return;
                }
                showNextMonth();
                return;
            case R.id.iv_speed:
                handFast();
                return;
            case R.id.monitor_1dual:
                if (getResources().getConfiguration().orientation == 2) {
                    LinearLayout linearLayout = this.ll_top;
                    linearLayout.setVisibility(linearLayout.getVisibility() != 0 ? 0 : 8);
                    return;
                }
                return;
            case R.id.rb_alarm:
                if (this.mIsDataReceveEnd && !this.currentTypeIs2) {
                    this.currentTypeIs2 = true;
                    this.rb_alarm.setChecked(true);
                    this.rb_all.setChecked(false);
                    this.rb_all.setEnabled(false);
                    this.rb_alarm.setEnabled(false);
                    resetRequestData();
                    showLoadingView();
                    HiLogcatUtil.e("tedu", "-rb_alarm-");
                    if (this.mAct.isDownloading || this.mAct.isCallDownload) {
                        Packet.longToByteArray4_Little(this.msavepVo.getU32StartPts(this.StreamType));
                        Packet.longToByteArray4_Little(this.msavepVo.getU32StopPts(this.StreamType));
                    }
                    this.mMyCamera.mhiNvrdev.StopPlayLocal();
                    this.isCallStopDown = true;
                    this.mAct.isDownloading = false;
                    this.mAct.isCallDownload = false;
                    this.mMyCamera.sendIOCtrl(HiChipDefines.HI_P2P_GET_RECORD_ALLFILE_ONEDAY, HiChipDefines.RECORD_ALLFILE.parseContent(0, mYear, mMonth, this.nearVideoDay, getFileType()));
                    return;
                }
                return;
            case R.id.rb_all:
                if (this.mIsDataReceveEnd && this.currentTypeIs2) {
                    this.currentTypeIs2 = false;
                    this.rb_alarm.setChecked(false);
                    this.rb_all.setChecked(true);
                    this.rb_all.setEnabled(false);
                    this.rb_alarm.setEnabled(false);
                    resetRequestData();
                    showLoadingView();
                    HiLogcatUtil.e("tedu", "-rb_all-");
                    if (this.mAct.isDownloading || this.mAct.isCallDownload) {
                        Packet.longToByteArray4_Little(this.msavepVo.getU32StartPts(this.StreamType));
                        Packet.longToByteArray4_Little(this.msavepVo.getU32StopPts(this.StreamType));
                    }
                    this.mMyCamera.mhiNvrdev.StopPlayLocal();
                    this.isCallStopDown = true;
                    this.mAct.isDownloading = false;
                    this.mAct.isCallDownload = false;
                    this.mMyCamera.sendIOCtrl(HiChipDefines.HI_P2P_GET_RECORD_ALLFILE_ONEDAY, HiChipDefines.RECORD_ALLFILE.parseContent(0, mYear, mMonth, this.nearVideoDay, getFileType()));
                    return;
                }
                return;
            case R.id.root_lock_screen:
                OrientationWatchDog orientationWatchDog = this.mOrientationWatchDog;
                if (orientationWatchDog != null) {
                    orientationWatchDog.setLockScreen(true);
                }
                this.root_lock_screen.setVisibility(8);
                this.mHandler_lockScreen.removeCallbacksAndMessages(null);
                return;
            case R.id.tv_speed:
                HiclickSpeed(this.tvSpeed, false);
                return;
            default:
                return;
        }
    }

    private void handPictureSize() {
        View inflate = View.inflate(getActivity(), R.layout.pup_landscape_adaption, null);
        this.mPopupWindow = new PopupWindow(inflate);
        this.mPopupWindow.setBackgroundDrawable(new ColorDrawable(0));
        this.mPopupWindow.setOutsideTouchable(true);
        this.mPopupWindow.setHeight(-1);
        this.mPopupWindow.setWidth(HiTools.dip2px(getActivity(), 250.0f));
        this.mPopupWindow.setAnimationStyle(R.style.AnimTopRight);
        this.mPopupWindow.showAtLocation(inflate, 17, getActivity().getWindowManager().getDefaultDisplay().getWidth(), 0);
        this.tvFill = (TextView) inflate.findViewById(R.id.tv_fill);
        this.tvAdaption = (TextView) inflate.findViewById(R.id.tv_adaption);
        int i = this.mPictureSize;
        if (i == 0) {
            this.tvFill.setSelected(true);
            this.tvAdaption.setSelected(false);
        } else if (i == 1) {
            this.tvFill.setSelected(false);
            this.tvAdaption.setSelected(true);
        }
        this.tvFill.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                NVRTimePlaybackNewFragment.this.tvFill.setSelected(true);
                NVRTimePlaybackNewFragment.this.tvAdaption.setSelected(false);
                if (NVRTimePlaybackNewFragment.this.mMyCamera != null) {
                    SharePreUtils.putInt(HiDataValue.CACHE, NVRTimePlaybackNewFragment.this.getActivity(), "pictureSize" + HiDataValue.userAccount + NVRTimePlaybackNewFragment.this.mMyCamera.getUid(), 0);
                }
                NVRTimePlaybackNewFragment.this.mPictureSize = 0;
                NVRTimePlaybackNewFragment nVRTimePlaybackNewFragment = NVRTimePlaybackNewFragment.this;
                nVRTimePlaybackNewFragment.handLandscape(nVRTimePlaybackNewFragment.mPictureSize);
            }
        });
        this.tvAdaption.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                NVRTimePlaybackNewFragment.this.tvFill.setSelected(false);
                NVRTimePlaybackNewFragment.this.tvAdaption.setSelected(true);
                if (NVRTimePlaybackNewFragment.this.mMyCamera != null) {
                    SharePreUtils.putInt(HiDataValue.CACHE, NVRTimePlaybackNewFragment.this.getActivity(), "pictureSize" + HiDataValue.userAccount + NVRTimePlaybackNewFragment.this.mMyCamera.getUid(), 1);
                }
                NVRTimePlaybackNewFragment.this.mPictureSize = 1;
                NVRTimePlaybackNewFragment nVRTimePlaybackNewFragment = NVRTimePlaybackNewFragment.this;
                nVRTimePlaybackNewFragment.handLandscape(nVRTimePlaybackNewFragment.mPictureSize);
            }
        });
    }

    private void resetRequestData() {
        this.mIsDataReceveEnd = false;
        this.firstVideoStartTime = 0L;
        this.currentPlayPosition = 0;
        this.currentPlayVideoStartTime = 0L;
        this.videoIsPlaying = false;
        this.videoIsPause = false;
        this.myTimeLineView.isCanPlay = false;
        this.one_day_file_list.clear();
        this.file_list.clear();
        this.file_list1.clear();
        this.videoLists.clear();
        this.videoLists1.clear();
        this.videoLists2.clear();
        this.isDrag = false;
        this.curentDayVideo.clear();
    }

    @Override
    public void onConfigurationChanged(Configuration configuration) {
        super.onConfigurationChanged(configuration);
        NVRTimeAxisActivity nVRTimeAxisActivity = this.mAct;
        if (nVRTimeAxisActivity instanceof NVRTimeAxisActivity) {
            this.timeAxisActivity = nVRTimeAxisActivity;
        }
        if (getResources().getConfiguration().orientation == 1) {
            setDefaultFull_Portrait();
            handPortrait();
            TimeLineNVR timeLineNVR = this.myTimeLineView;
            if (timeLineNVR != null && !timeLineNVR.isCanPlay && !this.videoIsPlaying && this.videoIsPause) {
                this.iv_placeholder.setVisibility(0);
                this.iv_placeholder.setLayoutParams(new RelativeLayout.LayoutParams(-1, this.mHeight));
            }
        } else {
            handLandscape(this.mPictureSize);
        }
        this.monitor.setVisibility(0);
    }

    private void handPortrait() {
        if (getActivity() == null || this.monitor == null) {
            return;
        }
        PopupWindow popupWindow = this.mPopupWindow;
        if (popupWindow != null && popupWindow.isShowing()) {
            this.mPopupWindow.dismiss();
        }
        showBottomUIMenu(getActivity());
        this.monitor.setmIsFullScreen(0);
        this.mAct.getWindow().clearFlags(1024);
        this.timeAxisActivity.ll_title.setVisibility(0);
        this.timeAxisActivity.rl_head.setVisibility(0);
        this.myTimeLineView.setVisibility(0);
        this.ll_bottom.setVisibility(0);
        this.ll_top.setVisibility(8);
        this.iv_full_screen.setVisibility(0);
        this.rl_monitor.setLayoutParams(new LinearLayout.LayoutParams(-1, this.mHeight));
        RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(-1, this.mHeight);
        this.iv_placeholder.setLayoutParams(layoutParams);
        DisplayMetrics displayMetrics = new DisplayMetrics();
        getActivity().getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
        this.monitor.screen_height = displayMetrics.heightPixels;
        this.monitor.screen_width = displayMetrics.widthPixels;
        initMatrix(this.monitor.screen_width, this.monitor.screen_height);
        this.monitor.setLayoutParams(layoutParams);
        this.monitor.setState(0);
        MyPlaybackGLMonitor myPlaybackGLMonitor = this.monitor;
        myPlaybackGLMonitor.setMatrix(myPlaybackGLMonitor.left, this.monitor.bottom, this.monitor.width, this.monitor.height);
        resetMonitorSize(false, 10000.0d);
    }

    public void handLandscape(int i) {
        RelativeLayout.LayoutParams layoutParams;
        LinearLayout.LayoutParams layoutParams2;
        if (getActivity() == null || this.monitor == null) {
            return;
        }
        boolean hideBottomUIMenu = hideBottomUIMenu(getActivity());
        this.monitor.setmIsFullScreen(1);
        this.mAct.getWindow().setFlags(1024, 1024);
        this.timeAxisActivity.ll_title.setVisibility(8);
        this.timeAxisActivity.rl_head.setVisibility(8);
        this.myTimeLineView.setVisibility(8);
        this.ll_bottom.setVisibility(8);
        this.ll_top.setVisibility(0);
        this.iv_full_screen.setVisibility(4);
        DisplayMetrics displayMetrics = new DisplayMetrics();
        getActivity().getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
        MyPlaybackGLMonitor myPlaybackGLMonitor = this.monitor;
        int i2 = displayMetrics.heightPixels;
        myPlaybackGLMonitor.screen_height = i2;
        this.PictureRealHeight = i2;
        MyPlaybackGLMonitor myPlaybackGLMonitor2 = this.monitor;
        int i3 = displayMetrics.widthPixels;
        myPlaybackGLMonitor2.screen_width = i3;
        this.PictureRealWidth = i3;
        HiLog.e(this.PictureRealWidth + "::" + this.PictureRealHeight + "::" + this.video_width + "::" + this.video_height + "::" + i + "::" + this.monitor.left + "::" + this.monitor.bottom + "::" + this.monitor.width + "::" + this.monitor.height + "::" + this.monitor.screen_width + "::" + this.monitor.screen_height);
        if (HiTools.isAllScreenDevice(getActivity())) {
            layoutParams = new RelativeLayout.LayoutParams(-1, -1);
            layoutParams2 = new LinearLayout.LayoutParams(-1, -1);
            if (hideBottomUIMenu) {
                MyPlaybackGLMonitor myPlaybackGLMonitor3 = this.monitor;
                int navigationBarHeight = displayMetrics.widthPixels + HiTools.getNavigationBarHeight(getActivity());
                myPlaybackGLMonitor3.screen_width = navigationBarHeight;
                this.PictureRealWidth = navigationBarHeight;
            }
        } else {
            layoutParams = new RelativeLayout.LayoutParams(this.mAct.getWindowManager().getDefaultDisplay().getWidth(), this.mAct.getWindowManager().getDefaultDisplay().getHeight());
            layoutParams2 = new LinearLayout.LayoutParams(this.mAct.getWindowManager().getDefaultDisplay().getWidth(), this.mAct.getWindowManager().getDefaultDisplay().getHeight());
        }
        if (i == 1) {
            int Getwh = HiTools.Getwh(this.PictureRealWidth, this.PictureRealHeight, this.video_width, this.video_height);
            if (Getwh == 2) {
                this.monitor.screen_height = HiTools.getVideoshowh(this.PictureRealWidth, this.PictureRealHeight, this.video_width, this.video_height);
                layoutParams.setMargins(0, (this.PictureRealHeight - this.monitor.screen_height) / 2, 0, (this.PictureRealHeight - this.monitor.screen_height) / 2);
            } else if (Getwh == 3) {
                this.monitor.screen_width = HiTools.getVideoshoww(this.PictureRealWidth, this.PictureRealHeight, this.video_width, this.video_height);
                layoutParams.setMargins((this.PictureRealWidth - this.monitor.screen_width) / 2, 0, (this.PictureRealWidth - this.monitor.screen_width) / 2, 0);
            } else {
                layoutParams.setMargins(0, 0, 0, 0);
            }
        }
        this.monitor.setLayoutParams(layoutParams);
        this.rl_monitor.setLayoutParams(layoutParams2);
        initMatrix(this.monitor.screen_width, this.monitor.screen_height);
        this.monitor.setState(0);
        MyPlaybackGLMonitor myPlaybackGLMonitor4 = this.monitor;
        myPlaybackGLMonitor4.setMatrix(myPlaybackGLMonitor4.left, this.monitor.bottom, this.monitor.width, this.monitor.height);
        HiLog.e(this.PictureRealWidth + "::" + this.PictureRealHeight + "::" + this.video_width + "::" + this.video_height + "::" + i + "::" + this.monitor.left + "::" + this.monitor.bottom + "::" + this.monitor.width + "::" + this.monitor.height + "::" + this.monitor.screen_width + "::" + this.monitor.screen_height);
    }

    public void handLandscapeForNextFile(int i) {
        RelativeLayout.LayoutParams layoutParams;
        LinearLayout.LayoutParams layoutParams2;
        if (getActivity() == null || this.monitor == null) {
            return;
        }
        boolean hideBottomUIMenu = hideBottomUIMenu(getActivity());
        this.monitor.setmIsFullScreen(1);
        this.mAct.getWindow().setFlags(1024, 1024);
        this.timeAxisActivity.ll_title.setVisibility(8);
        this.timeAxisActivity.rl_head.setVisibility(8);
        this.myTimeLineView.setVisibility(8);
        this.ll_bottom.setVisibility(8);
        this.ll_top.setVisibility(0);
        this.iv_full_screen.setVisibility(4);
        this.rl_head.requestLayout();
        DisplayMetrics displayMetrics = new DisplayMetrics();
        getActivity().getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
        MyPlaybackGLMonitor myPlaybackGLMonitor = this.monitor;
        int i2 = displayMetrics.heightPixels;
        myPlaybackGLMonitor.screen_height = i2;
        this.PictureRealHeight = i2;
        MyPlaybackGLMonitor myPlaybackGLMonitor2 = this.monitor;
        int i3 = displayMetrics.widthPixels;
        myPlaybackGLMonitor2.screen_width = i3;
        this.PictureRealWidth = i3;
        HiLog.e(this.PictureRealWidth + "::" + this.PictureRealHeight + "::" + this.video_width + "::" + this.video_height + "::" + i + "::" + this.monitor.left + "::" + this.monitor.bottom + "::" + this.monitor.width + "::" + this.monitor.height + "::" + this.monitor.screen_width + "::" + this.monitor.screen_height);
        if (HiTools.isAllScreenDevice(getActivity())) {
            layoutParams = new RelativeLayout.LayoutParams(-1, -1);
            layoutParams2 = new LinearLayout.LayoutParams(-1, -1);
            if (hideBottomUIMenu) {
                MyPlaybackGLMonitor myPlaybackGLMonitor3 = this.monitor;
                int navigationBarHeight = displayMetrics.widthPixels + HiTools.getNavigationBarHeight(getActivity());
                myPlaybackGLMonitor3.screen_width = navigationBarHeight;
                this.PictureRealWidth = navigationBarHeight;
            }
        } else {
            layoutParams = new RelativeLayout.LayoutParams(this.mAct.getWindowManager().getDefaultDisplay().getWidth(), this.mAct.getWindowManager().getDefaultDisplay().getHeight());
            layoutParams2 = new LinearLayout.LayoutParams(this.mAct.getWindowManager().getDefaultDisplay().getWidth(), this.mAct.getWindowManager().getDefaultDisplay().getHeight());
        }
        if (i == 1) {
            int Getwh = HiTools.Getwh(this.PictureRealWidth, this.PictureRealHeight, this.video_width, this.video_height);
            if (Getwh == 2) {
                this.monitor.screen_height = HiTools.getVideoshowh(this.PictureRealWidth, this.PictureRealHeight, this.video_width, this.video_height);
                layoutParams.setMargins(0, (this.PictureRealHeight - this.monitor.screen_height) / 2, 0, (this.PictureRealHeight - this.monitor.screen_height) / 2);
            } else if (Getwh == 3) {
                this.monitor.screen_width = HiTools.getVideoshoww(this.PictureRealWidth, this.PictureRealHeight, this.video_width, this.video_height);
                layoutParams.setMargins((this.PictureRealWidth - this.monitor.screen_width) / 2, 0, (this.PictureRealWidth - this.monitor.screen_width) / 2, 0);
            } else {
                layoutParams.setMargins(0, 0, 0, 0);
            }
        }
        this.monitor.setLayoutParams(layoutParams);
        this.rl_monitor.setLayoutParams(layoutParams2);
        initMatrix(this.monitor.screen_width, this.monitor.screen_height);
        this.monitor.setState(0);
        MyPlaybackGLMonitor myPlaybackGLMonitor4 = this.monitor;
        myPlaybackGLMonitor4.setMatrix(myPlaybackGLMonitor4.left, this.monitor.bottom, this.monitor.width, this.monitor.height);
        HiLog.e(this.PictureRealWidth + "::" + this.PictureRealHeight + "::" + this.video_width + "::" + this.video_height + "::" + i + "::" + this.monitor.left + "::" + this.monitor.bottom + "::" + this.monitor.width + "::" + this.monitor.height + "::" + this.monitor.screen_width + "::" + this.monitor.screen_height);
    }

    private void showPreMonth() {
        NoSlidingViewPager noSlidingViewPager = this.viewpager;
        int i = this.currPager - 1;
        this.currPager = i;
        noSlidingViewPager.setCurrentItem(i, true);
    }

    private void showNextMonth() {
        int i = this.currPager;
        if (i >= 999) {
            return;
        }
        NoSlidingViewPager noSlidingViewPager = this.viewpager;
        int i2 = i + 1;
        this.currPager = i2;
        noSlidingViewPager.setCurrentItem(i2, true);
    }

    public void showLoadingView() {
        if (this.loadingViewIsShowing) {
            return;
        }
        this.loadingViewIsShowing = true;
        Animation loadAnimation = AnimationUtils.loadAnimation(getContext(), R.anim.rotate);
        this.mIvLoading.setVisibility(0);
        this.mIvLoading.startAnimation(loadAnimation);
        this.shadowView.setVisibility(0);
    }

    public void dismissLoadingView() {
        if (this.loadingViewIsShowing) {
            this.loadingViewIsShowing = false;
            this.mIvLoading.clearAnimation();
            this.mIvLoading.setVisibility(8);
            this.shadowView.setVisibility(8);
        }
    }

    @Override
    public boolean onTouch(View view, MotionEvent motionEvent) {
        if (view.getId() == R.id.monitor_1dual) {
            int pointerCount = motionEvent.getPointerCount();
            if ((motionEvent.getAction() & 255) == 5 && 2 == pointerCount) {
                this.monitor.setTouchMove(2);
                for (int i = 0; i < pointerCount; i++) {
                    new Point((int) motionEvent.getX(i), (int) motionEvent.getY(i));
                }
                this.xlenOld = Math.abs(((int) motionEvent.getX(0)) - ((int) motionEvent.getX(1)));
                int abs = Math.abs(((int) motionEvent.getY(0)) - ((int) motionEvent.getY(1)));
                this.ylenOld = abs;
                int i2 = this.xlenOld;
                this.nLenStart = Math.sqrt((i2 * i2) + (abs * abs));
            } else {
                if ((motionEvent.getAction() & 255) == 2 && 2 == pointerCount) {
                    this.monitor.setTouchMove(2);
                    for (int i3 = 0; i3 < pointerCount; i3++) {
                        new Point((int) motionEvent.getX(i3), (int) motionEvent.getY(i3));
                    }
                    int abs2 = Math.abs(((int) motionEvent.getX(0)) - ((int) motionEvent.getX(1)));
                    int abs3 = Math.abs(((int) motionEvent.getY(0)) - ((int) motionEvent.getY(1)));
                    int abs4 = Math.abs(abs2 - this.xlenOld);
                    int abs5 = Math.abs(abs3 - this.ylenOld);
                    double d = abs2;
                    double d2 = abs3;
                    double sqrt = Math.sqrt((d * d) + (d2 * d2));
                    if (abs4 < 20 && abs5 < 20) {
                        return false;
                    }
                    if (sqrt > this.nLenStart) {
                        resetMonitorSize(true, sqrt);
                    } else {
                        resetMonitorSize(false, sqrt);
                    }
                    this.xlenOld = abs2;
                    this.ylenOld = abs3;
                    this.nLenStart = sqrt;
                    return true;
                }
                if (pointerCount == 1) {
                    int action = motionEvent.getAction();
                    if (action == 0) {
                        this.monitor.setTouchMove(0);
                    } else if (action == 2 && this.monitor.getTouchMove() == 0 && (Math.abs(this.move_x - this.action_down_x) > 40.0f || Math.abs(this.move_y - this.action_down_y) > 40.0f)) {
                        this.monitor.setTouchMove(1);
                    }
                }
            }
        }
        return false;
    }

    public void resetMonitorSize(boolean z, double d) {
        this.isLarge = z ? 1 : 2;
        if (this.monitor.getmIsFullScreen() == 0) {
            this.monitor.screen_height = this.mHeight;
        }
        if (this.monitor.height == 0 && this.monitor.width == 0) {
            initMatrix(this.monitor.screen_width, this.monitor.screen_height);
        }
        this.moveX = (int) (d / 2.0d);
        this.moveY = (int) (((d * this.monitor.screen_height) / this.monitor.screen_width) / 2.0d);
        if (z) {
            if (this.monitor.width <= this.monitor.screen_width * 2 && this.monitor.height <= this.monitor.screen_height * 2) {
                this.monitor.left -= this.moveX / 2;
                this.monitor.bottom -= this.moveY / 2;
                this.monitor.width += this.moveX;
                this.monitor.height += this.moveY;
            }
        } else {
            this.monitor.left += this.moveX / 2;
            this.monitor.bottom += this.moveY / 2;
            this.monitor.width -= this.moveX;
            this.monitor.height -= this.moveY;
            if (this.monitor.bottom + this.monitor.height < this.monitor.screen_height) {
                MyPlaybackGLMonitor myPlaybackGLMonitor = this.monitor;
                myPlaybackGLMonitor.bottom = myPlaybackGLMonitor.screen_height - this.monitor.height;
            }
            if (this.monitor.left + this.monitor.width < this.monitor.screen_width) {
                MyPlaybackGLMonitor myPlaybackGLMonitor2 = this.monitor;
                myPlaybackGLMonitor2.left = myPlaybackGLMonitor2.screen_width - this.monitor.width;
            }
        }
        if (this.monitor.left > 0 || this.monitor.width < this.monitor.screen_width || this.monitor.height < this.monitor.screen_height || this.monitor.bottom > 0) {
            initMatrix(this.monitor.screen_width, this.monitor.screen_height);
        }
        if (this.monitor.width > this.monitor.screen_width) {
            this.monitor.setState(1);
        } else {
            this.monitor.setState(0);
        }
        MyPlaybackGLMonitor myPlaybackGLMonitor3 = this.monitor;
        myPlaybackGLMonitor3.setMatrix(myPlaybackGLMonitor3.left, this.monitor.bottom, this.monitor.width, this.monitor.height);
        if (getResources().getConfiguration().orientation == 1) {
            this.isLarge = 0;
        }
    }

    private void initMatrix(int i, int i2) {
        this.monitor.left = 0;
        this.monitor.bottom = 0;
        this.monitor.width = i;
        this.monitor.height = i2;
    }

    private void setDefaultFull_Portrait() {
        PopupWindow popupWindow = this.mPopupWindow;
        if (popupWindow != null) {
            popupWindow.dismiss();
        }
        if (this.monitor != null) {
            RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(this.monitor.getLayoutParams());
            this.monitor.screen_width = this.PictureRealWidth;
            this.monitor.screen_height = this.PictureRealHeight;
            layoutParams.setMargins(0, 0, 0, 0);
            this.monitor.setLayoutParams(layoutParams);
            HiLogcatUtil.e("" + this.monitor.screen_width + "::" + this.monitor.screen_height + "::" + HiTools.isAllScreenDevice(getActivity()));
            initMatrix(this.monitor.screen_width, this.monitor.screen_height);
            this.monitor.setState(0);
            MyPlaybackGLMonitor myPlaybackGLMonitor = this.monitor;
            myPlaybackGLMonitor.setMatrix(myPlaybackGLMonitor.left, this.monitor.bottom, this.monitor.width, this.monitor.height);
        }
    }

    public void startWatchOrientation() {
        OrientationWatchDog orientationWatchDog;
        if (this.iv_full_screen.getVisibility() != 0 || this.iv_placeholder.getVisibility() == 0 || !this.myTimeLineView.isCanPlay || (orientationWatchDog = this.mOrientationWatchDog) == null) {
            return;
        }
        orientationWatchDog.startWatch();
    }

    public void stopWatchOrientation() {
        OrientationWatchDog orientationWatchDog = this.mOrientationWatchDog;
        if (orientationWatchDog != null) {
            orientationWatchDog.stopWatch();
        }
    }

    public void releaseLockScreen() {
        OrientationWatchDog orientationWatchDog = this.mOrientationWatchDog;
        if (orientationWatchDog != null) {
            orientationWatchDog.setLockScreen(false);
        }
        this.isFirstRevolveLand = false;
        this.root_lock_screen.setVisibility(8);
        this.mHandler_lockScreen.removeCallbacksAndMessages(null);
    }

    private void initOrientationWatchdog() {
        OrientationWatchDog orientationWatchDog = new OrientationWatchDog(getActivity());
        this.mOrientationWatchDog = orientationWatchDog;
        orientationWatchDog.setOnOrientationListener(this);
    }

    @Override
    public void changedScreenDirection(int i) {
        if (this.isReadyPlay && this.iv_placeholder.getVisibility() != 0) {
            if (i == 90) {
                if (this.myTimeLineView.isCanPlay) {
                    HiLogcatUtil.e("wry---", "---" + this.mOrientationWatchDog.getLastOrientation());
                    if (this.mOrientationWatchDog.getLastOrientation() == 270 && !this.mIsClickReturn) {
                        new Handler().postDelayed(new Runnable() {
                            @Override
                            public void run() {
                                if (NVRTimePlaybackNewFragment.this.isLarge != 1) {
                                    if (NVRTimePlaybackNewFragment.this.isLarge == 2) {
                                        NVRTimePlaybackNewFragment nVRTimePlaybackNewFragment = NVRTimePlaybackNewFragment.this;
                                        nVRTimePlaybackNewFragment.resetMonitorSize(false, nVRTimePlaybackNewFragment.nLenStart);
                                        return;
                                    }
                                    return;
                                }
                                NVRTimePlaybackNewFragment nVRTimePlaybackNewFragment2 = NVRTimePlaybackNewFragment.this;
                                nVRTimePlaybackNewFragment2.resetMonitorSize(true, nVRTimePlaybackNewFragment2.nLenStart);
                            }
                        }, 200L);
                    }
                    if (!this.mIsClickReturn) {
                        getActivity().setRequestedOrientation(8);
                    }
                    if (!this.isFirstRevolveLand) {
                        this.isFirstRevolveLand = true;
                    }
                    if (this.mIsClickReturn) {
                        return;
                    }
                    if (this.root_lock_screen.getVisibility() == 0) {
                        this.mHandler_lockScreen.removeCallbacksAndMessages(null);
                        this.mHandler_lockScreen.sendEmptyMessageDelayed(1, 3000L);
                        return;
                    } else {
                        this.mHandler_lockScreen.removeCallbacksAndMessages(null);
                        this.mHandler_lockScreen.sendEmptyMessageDelayed(0, 3000L);
                        return;
                    }
                }
                return;
            }
            if (i == 270) {
                if (this.myTimeLineView.isCanPlay) {
                    HiLogcatUtil.e("wry---", "===" + this.mOrientationWatchDog.getLastOrientation());
                    if (this.mOrientationWatchDog.getLastOrientation() == 90 && !this.mIsClickReturn) {
                        new Handler().postDelayed(new Runnable() {
                            @Override
                            public void run() {
                                if (NVRTimePlaybackNewFragment.this.isLarge != 1) {
                                    if (NVRTimePlaybackNewFragment.this.isLarge == 2) {
                                        NVRTimePlaybackNewFragment nVRTimePlaybackNewFragment = NVRTimePlaybackNewFragment.this;
                                        nVRTimePlaybackNewFragment.resetMonitorSize(false, nVRTimePlaybackNewFragment.nLenStart);
                                        return;
                                    }
                                    return;
                                }
                                NVRTimePlaybackNewFragment nVRTimePlaybackNewFragment2 = NVRTimePlaybackNewFragment.this;
                                nVRTimePlaybackNewFragment2.resetMonitorSize(true, nVRTimePlaybackNewFragment2.nLenStart);
                            }
                        }, 200L);
                    }
                    if (!this.mIsClickReturn) {
                        getActivity().setRequestedOrientation(0);
                    }
                    if (this.isFirstRevolveLand && !this.mIsClickReturn) {
                        if (this.root_lock_screen.getVisibility() == 0) {
                            this.mHandler_lockScreen.removeCallbacksAndMessages(null);
                            this.mHandler_lockScreen.sendEmptyMessageDelayed(1, 3000L);
                            return;
                        } else {
                            this.mHandler_lockScreen.removeCallbacksAndMessages(null);
                            this.mHandler_lockScreen.sendEmptyMessageDelayed(0, 3000L);
                            return;
                        }
                    }
                    return;
                }
                return;
            }
            this.mIsClickReturn = false;
            this.isFirstRevolveLand = false;
            getActivity().setRequestedOrientation(1);
            this.root_lock_screen.setVisibility(8);
            this.mHandler_lockScreen.removeCallbacksAndMessages(null);
        }
    }

    public class AnonymousClass22 extends Handler {
        AnonymousClass22() {
        }

        @Override
        public void handleMessage(Message message) {
            int StartPlayLocalTime;
            int StartPlayLocalTime2;
            int i = message.arg2;
            int i2 = message.arg1;
            String string = message.getData().getString("data");
            if (NVRTimePlaybackNewFragment.this.loadingFile == null || TextUtils.isEmpty(NVRTimePlaybackNewFragment.this.loadingFile) || (!TextUtils.isEmpty(string) && !NVRTimePlaybackNewFragment.this.loadingFile.equals(string))) {
                NVRTimePlaybackNewFragment.this.loadingFile = string;
            }
            switch (message.what) {
                case NVRTimePlaybackNewFragment.HANDLE_MESSAGE_SEEKBAR_START:
                    NVRTimePlaybackNewFragment.this.isReadyPlay = true;
                    NVRTimePlaybackNewFragment.this.mIsEnd = false;
                    NVRTimePlaybackNewFragment.this.isPlayEnd = false;
                    NVRTimePlaybackNewFragment.this.videoIsPause = false;
                    NVRTimePlaybackNewFragment.this.videoIsPlaying = true;
                    HiLogcatUtil.e("tedu", "-播放开始-PLAY_STATE_START--");
                    NVRTimePlaybackNewFragment.this.handler.postDelayed(new Runnable() {
                        @Override
                        public final void run() {
                            NVRTimePlaybackNewFragment.AnonymousClass22.this.lambda$handleMessage$0$NVRTimePlaybackNewFragment$22();
                        }
                    }, 100L);
                    NVRTimePlaybackNewFragment.this.myTimeLineView.isCanPlay = true;
                    NVRTimePlaybackNewFragment.this.videoIsPlaying = true;
                    NVRTimePlaybackNewFragment.this.iv_placeholder.setVisibility(8);
                    if (NVRTimePlaybackNewFragment.this.getResources().getConfiguration().orientation == 1) {
                        NVRTimePlaybackNewFragment.this.iv_full_screen.setVisibility(0);
                    }
                    NVRTimePlaybackNewFragment.this.dismissLoadingView();
                    if (NVRTimePlaybackNewFragment.this.video_width != message.arg1 || NVRTimePlaybackNewFragment.this.video_height != message.arg2) {
                        NVRTimePlaybackNewFragment.this.video_width = message.arg1;
                        NVRTimePlaybackNewFragment.this.video_height = message.arg2;
                        if (NVRTimePlaybackNewFragment.this.getResources().getConfiguration().orientation == 2) {
                            NVRTimePlaybackNewFragment nVRTimePlaybackNewFragment = NVRTimePlaybackNewFragment.this;
                            nVRTimePlaybackNewFragment.handLandscapeForNextFile(nVRTimePlaybackNewFragment.mPictureSize);
                        }
                    }
                    NVRTimePlaybackNewFragment.this.startWatchOrientation();
                    NVRTimePlaybackNewFragment.this.rb_all.setEnabled(true);
                    NVRTimePlaybackNewFragment.this.rb_alarm.setEnabled(true);
                    NVRTimePlaybackNewFragment.this.ResetPlayFastSpeed();
                    return;
                case NVRTimePlaybackNewFragment.HANDLE_MESSAGE_SEEKBAR_END:
                    HiLogcatUtil.e("tedu", "--HANDLE_MESSAGE_SEEKBAR_END--" + NVRTimePlaybackNewFragment.this.mAct.isDownloading + "::" + NVRTimePlaybackNewFragment.this.mAct.isCallDownload + ":::" + NVRTimePlaybackNewFragment.this.loadingFile);
                    NVRTimePlaybackNewFragment.this.mMyCamera.mhiNvrdev.StopPlayLocal();
                    if (!NVRTimePlaybackNewFragment.this.mAct.isCallDownload) {
                        NVRTimePlaybackNewFragment nVRTimePlaybackNewFragment2 = NVRTimePlaybackNewFragment.this;
                        nVRTimePlaybackNewFragment2.mTimeInMicros = nVRTimePlaybackNewFragment2.myTimeLineView.getCurrentValue();
                        HiLog.e("tedG--....()....--" + NVRTimePlaybackNewFragment.this.mTimeInMicros + ";;;;");
                        long j = NVRTimePlaybackNewFragment.this.mTimeInMicros;
                        int findVideoFile = NVRTimePlaybackNewFragment.this.findVideoFile(j, -1);
                        if (findVideoFile == -1) {
                            NVRTimePlaybackNewFragment.this.myTimeLineView.listener.onNoneVideo("", j);
                            NVRTimePlaybackNewFragment.this.mBackToNoFile = true;
                            return;
                        }
                        if (NVRTimePlaybackNewFragment.this.myTimeLineView.isScroll()) {
                            return;
                        }
                        int i3 = findVideoFile + 1;
                        if (i3 < NVRTimePlaybackNewFragment.this.curentDayVideo.size()) {
                            PlaybackNvrVo playbackNvrVo = (PlaybackNvrVo) NVRTimePlaybackNewFragment.this.curentDayVideo.get(i3);
                            HiLogcatUtil.e("currentPlayPosition:" + NVRTimePlaybackNewFragment.this.currentPlayPosition + "::" + findVideoFile + "::" + playbackNvrVo.getStartTime() + "::" + playbackNvrVo.getEndTime());
                            NVRTimePlaybackNewFragment.this.currentPlayPosition = findVideoFile;
                            byte[] bArr = new byte[8];
                            System.arraycopy(playbackNvrVo.getTest(), 0, bArr, 0, 8);
                            NVRTimePlaybackNewFragment.this.HiDoPlayFast(playbackNvrVo, bArr, 0L, 0, playbackNvrVo.getFlag());
                        } else {
                            MyToast.showToast(NVRTimePlaybackNewFragment.this.mAct, NVRTimePlaybackNewFragment.this.getString(R.string.tips_stop_video));
                            NVRTimePlaybackNewFragment.this.myTimeLineView.isCanPlay = false;
                            if (!NVRTimePlaybackNewFragment.this.videoIsPause && NVRTimePlaybackNewFragment.this.videoIsPlaying) {
                                NVRTimePlaybackNewFragment.this.pausePlayVideo();
                                NVRTimePlaybackNewFragment.this.videoIsPause = true;
                                NVRTimePlaybackNewFragment.this.videoIsPlaying = false;
                            }
                            NVRTimePlaybackNewFragment.this.shadowView.setVisibility(8);
                        }
                    } else {
                        NVRTimePlaybackNewFragment nVRTimePlaybackNewFragment3 = NVRTimePlaybackNewFragment.this;
                        nVRTimePlaybackNewFragment3.firstVideoStartTime = nVRTimePlaybackNewFragment3.myTimeLineView.getCurrentValue();
                        File file = new File(NVRTimePlaybackNewFragment.this.loadingFile.replace(".rec", ".nvrh26x"));
                        HiLog.e("filepath:" + NVRTimePlaybackNewFragment.this.loadingFile);
                        if (NVRTimePlaybackNewFragment.this.mAct.isDownloading || file.exists()) {
                            if (!TextUtils.isEmpty(NVRTimePlaybackNewFragment.this.loadingFile) && (StartPlayLocalTime = NVRTimePlaybackNewFragment.this.mMyCamera.mhiNvrdev.StartPlayLocalTime(NVRTimePlaybackNewFragment.this.loadingFile, 0)) != 0 && StartPlayLocalTime != -10000 && NVRTimePlaybackNewFragment.this.mhandlerPF != null) {
                                NVRTimePlaybackNewFragment.this.mhandlerPF.sendEmptyMessage(NVRTimePlaybackNewFragment.HANDLE_MESSAGE_PLAYONLINE_OPENFAIL);
                            }
                        } else if (NVRTimePlaybackNewFragment.this.mhandlerPF != null) {
                            NVRTimePlaybackNewFragment.this.mhandlerPF.sendEmptyMessage(NVRTimePlaybackNewFragment.HANDLE_MESSAGE_PLAYONLINE_OPENFILE);
                        }
                    }
                    NVRTimePlaybackNewFragment.this.myTimeLineView.isCanPlay = false;
                    NVRTimePlaybackNewFragment.this.isPlayEnd = true;
                    NVRTimePlaybackNewFragment.this.shadowView.setVisibility(8);
                    NVRTimePlaybackNewFragment.this.rb_all.setEnabled(true);
                    NVRTimePlaybackNewFragment.this.rb_alarm.setEnabled(true);
                    return;
                case -1879048187:
                    NVRTimePlaybackNewFragment.this.dismissLoadingView();
                    return;
                case HiDataValue.HANDLE_MESSAGE_SCAN_CHECK:
                    NVRTimePlaybackNewFragment.this.myTimeLineView.isCanPlay = false;
                    NVRTimePlaybackNewFragment.this.isPlayEnd = true;
                    if (!NVRTimePlaybackNewFragment.this.videoIsPause && NVRTimePlaybackNewFragment.this.videoIsPlaying) {
                        NVRTimePlaybackNewFragment.this.pausePlayVideo();
                        NVRTimePlaybackNewFragment.this.videoIsPause = true;
                        NVRTimePlaybackNewFragment.this.videoIsPlaying = false;
                    }
                    NVRTimePlaybackNewFragment.this.shadowView.setVisibility(8);
                    NVRTimePlaybackNewFragment.this.rb_all.setEnabled(true);
                    NVRTimePlaybackNewFragment.this.rb_alarm.setEnabled(true);
                    return;
                case NVRTimePlaybackNewFragment.HANDLE_MESSAGE_PLAYONLINE_OPENFILE:
                    File file2 = new File(NVRTimePlaybackNewFragment.this.loadingFile.replace(".rec", ".nvrh26x"));
                    HiLog.e("filepath:" + NVRTimePlaybackNewFragment.this.loadingFile);
                    if (NVRTimePlaybackNewFragment.this.mAct.isDownloading || file2.exists()) {
                        if (TextUtils.isEmpty(NVRTimePlaybackNewFragment.this.loadingFile) || (StartPlayLocalTime2 = NVRTimePlaybackNewFragment.this.mMyCamera.mhiNvrdev.StartPlayLocalTime(NVRTimePlaybackNewFragment.this.loadingFile, 0)) == 0 || StartPlayLocalTime2 == -10000 || NVRTimePlaybackNewFragment.this.mhandlerPF == null) {
                            return;
                        }
                        NVRTimePlaybackNewFragment.this.mhandlerPF.sendEmptyMessage(NVRTimePlaybackNewFragment.HANDLE_MESSAGE_PLAYONLINE_OPENFAIL);
                        return;
                    }
                    if (NVRTimePlaybackNewFragment.this.mhandlerPF != null) {
                        NVRTimePlaybackNewFragment.this.mhandlerPF.sendEmptyMessageDelayed(NVRTimePlaybackNewFragment.HANDLE_MESSAGE_PLAYONLINE_OPENFILE, 1000L);
                        return;
                    }
                    return;
                case NVRTimePlaybackNewFragment.HANDLE_MESSAGE_PLAYONLINE_OPENFAIL:
                    HiTools.getMyGrandpaStackTrace();
                    MyToast.showToast(NVRTimePlaybackNewFragment.this.getActivity(), NVRTimePlaybackNewFragment.this.getString(R.string.tips_open_video_fail));
                    NVRTimePlaybackNewFragment.this.mhandlerPF.postDelayed(new Runnable() {
                        @Override
                        public void run() {
                            NVRTimePlaybackNewFragment.this.getActivity().finish();
                        }
                    }, 1000L);
                    return;
                case -1:
                    HiLogcatUtil.e("################# timeline PLAY_ONLINESTATE_ERROR ##############  ");
                    if (NVRTimePlaybackNewFragment.this.getActivity() != null) {
                        Toast.makeText(NVRTimePlaybackNewFragment.this.getActivity(), NVRTimePlaybackNewFragment.this.getString(R.string.play_4k_sd_error), 1).show();
                    }
                    NVRTimePlaybackNewFragment.this.mMyCamera.setReconnectTimes(10);
                    NVRTimePlaybackNewFragment.this.startActivity(new Intent(NVRTimePlaybackNewFragment.this.mAct, (Class<?>) MainActivity.class));
                    return;
                case 10:
                    HiLogcatUtil.e(string + ":mSavedragTime:" + NVRTimePlaybackNewFragment.this.mSavedragTime);
                    int unused = NVRTimePlaybackNewFragment.this.mSavedragTime;
                    NVRTimePlaybackNewFragment.this.mSavedragTime = 0;
                    return;
                case 23:
                    int StartPlayLocalTime3 = NVRTimePlaybackNewFragment.this.mMyCamera.mhiNvrdev.StartPlayLocalTime(NVRTimePlaybackNewFragment.this.download_path + NVRTimePlaybackNewFragment.this.fileName + ".rec", 0);
                    if (StartPlayLocalTime3 == 0 || StartPlayLocalTime3 == -10000) {
                        return;
                    }
                    NVRTimePlaybackNewFragment.this.mhandlerPF.sendEmptyMessage(NVRTimePlaybackNewFragment.HANDLE_MESSAGE_PLAYONLINE_OPENFAIL);
                    return;
                case 24:
                    NVRTimePlaybackNewFragment.this.mAct.isDownloading = false;
                    NVRTimePlaybackNewFragment.this.mAct.isCallDownload = false;
                    HiLog.e("PlayLocalNVRFileCallback.DOWNLOAD_STATE_END");
                    return;
                case 27:
                    NVRTimePlaybackNewFragment.this.mAct.isDownloading = false;
                    NVRTimePlaybackNewFragment.this.mAct.isCallDownload = false;
                    if (NVRTimePlaybackNewFragment.this.mMyCamera != null && NVRTimePlaybackNewFragment.this.mMyCamera.mhiNvrdev != null) {
                        NVRTimePlaybackNewFragment.this.mMyCamera.mhiNvrdev.SetHiCameraLoadFin();
                    }
                    HiLog.e("PlayLocalNVRFileCallback.DOWNLOAD_STATE_FINISH" + string);
                    if (new File(string).exists()) {
                        String replace = string.replace(".rec", ".nvrh26x");
                        HiLogcatUtil.e(string + ":" + replace + Constants.COLON_SEPARATOR);
                        NVRTimePlaybackNewFragment.this.renameFile(string, replace);
                        return;
                    }
                    return;
                case 1101:
                    MyToast.showToast(NVRTimePlaybackNewFragment.this.getActivity(), NVRTimePlaybackNewFragment.this.getString(R.string.data_parsing_error));
                    NVRTimePlaybackNewFragment.this.handler.postDelayed(new Runnable() {
                        @Override
                        public void run() {
                            NVRTimePlaybackNewFragment.this.getActivity().finish();
                        }
                    }, 1000L);
                    return;
                case NVRTimePlaybackNewFragment.HANDLE_MESSAGE_PLAYONLINE_SHOWLOADVIEW:
                    NVRTimePlaybackNewFragment.this.showLoadingView();
                    return;
                default:
                    return;
            }
        }

        public void lambda$handleMessage$0$NVRTimePlaybackNewFragment$22() {
            NVRTimePlaybackNewFragment.this.shadowView.setVisibility(8);
        }
    }

    private void preLoadFile(final PlaybackNvrVo playbackNvrVo, byte[] bArr) {
        if (HiTools.isSDCardExist()) {
            File file = new File(HiDataValue.getPathNVROnLineRecord(this.mMyCamera.getUid(), this.chn, this.mstrdate, getActivity()));
            if (!file.exists()) {
                Log.d("==cloudPlay", "CameraVideoFastDownLoadCache: " + file.mkdirs());
            }
            this.download_path = file.getAbsolutePath() + "/";
            this.fileName = splitFileName(new HiChipDefines.STimeDay(bArr, 0).toString());
            this.fileName += "_" + this.StreamType;
            String str = this.download_path + this.fileName + ".nvrh26x";
            HiLog.e("filepath:" + str);
            if (new File(str).exists()) {
                this.fileisDowned = true;
                HiLog.e("==cloudPlay执行预加载,下一个文件,本地已经存在");
                return;
            }
            MyCamera myCamera = this.mMyCamera;
            if (myCamera == null || myCamera.mhiNvrdev == null) {
                return;
            }
            this.fileisDowned = false;
            String str2 = this.download_path + this.fileName + ".rec";
            File file2 = new File(str2);
            if (!file2.exists()) {
                try {
                    if (!file2.createNewFile()) {
                        return;
                    }
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            HiLog.e("filepath:" + str2);
            checkPBFastCacheSize();
            new Thread() {
                @Override
                public void run() {
                    super.run();
                    NVRTimePlaybackNewFragment.this.isCallStopDown = false;
                    NVRTimePlaybackNewFragment.this.mMyCamera.mhiNvrdev.PlayLocal_Resume();
                    NVRTimePlaybackNewFragment.this.mAct.isCallDownload = true;
                    String str3 = NVRTimePlaybackNewFragment.this.download_path + NVRTimePlaybackNewFragment.this.fileName + ".rec";
                    NVRTimePlaybackNewFragment.this.msavepVo = playbackNvrVo;
                    Packet.longToByteArray4_Little(playbackNvrVo.getU32StartPts(NVRTimePlaybackNewFragment.this.StreamType));
                    Packet.longToByteArray4_Little(playbackNvrVo.getU32StopPts(NVRTimePlaybackNewFragment.this.StreamType));
                    NVRTimePlaybackNewFragment.this.mMyCamera.mhiNvrdev.setPlaybackLocalPath(playbackNvrVo.getU16Width(NVRTimePlaybackNewFragment.this.StreamType), playbackNvrVo.getU16Height(NVRTimePlaybackNewFragment.this.StreamType), playbackNvrVo.getU8StreamCode(NVRTimePlaybackNewFragment.this.StreamType), playbackNvrVo.getU8AFormat(), str3);
                }
            }.start();
        }
    }

    public void renameFile(String str, String str2) {
        if (TextUtils.isEmpty(str) || TextUtils.isEmpty(str2)) {
            return;
        }
        new File(str).renameTo(new File(str2));
    }

    private void handFast() {
        if (this.mIsEnd) {
            return;
        }
        int i = this.mSpeed;
        if (i == 0) {
            this.mSpeed = 2;
            this.tvSpeed.setText("X 2");
            this.mMyCamera.mhiNvrdev.PlayLocal_Speed(2, 5);
            this.mMyCamera.mhiNvrdev.SetHiCameraTimeSpeedPlay(true);
            this.mdownLoadNextFileTime = 10000;
            return;
        }
        if (i == 2) {
            this.mSpeed = 4;
            this.tvSpeed.setText("X 4");
            this.mMyCamera.mhiNvrdev.PlayLocal_Speed(4, 0);
            this.mMyCamera.mhiNvrdev.SetHiCameraTimeSpeedPlay(true);
            this.mdownLoadNextFileTime = 20000;
            return;
        }
        if (i == 4) {
            this.mSpeed = 8;
            this.tvSpeed.setText("X 8");
            this.mMyCamera.mhiNvrdev.PlayLocal_Speed(8, 0);
            this.mMyCamera.mhiNvrdev.SetHiCameraTimeSpeedPlay(true);
            this.mdownLoadNextFileTime = 40000;
            return;
        }
        if (i == 8) {
            this.mSpeed = 16;
            this.tvSpeed.setText("X 16");
            this.mMyCamera.mhiNvrdev.PlayLocal_Speed(16, 0);
            this.mMyCamera.mhiNvrdev.SetHiCameraTimeSpeedPlay(true);
            this.mdownLoadNextFileTime = MediationConstant.ErrorCode.ADN_INIT_FAIL;
            return;
        }
        if (i != 16) {
            return;
        }
        this.mSpeed = 0;
        this.tvSpeed.setText("X 1");
        this.mMyCamera.mhiNvrdev.PlayLocal_Speed(0, 0);
        this.mMyCamera.mhiNvrdev.SetHiCameraTimeSpeedPlay(false);
        this.mdownLoadNextFileTime = 5000;
    }

    public void ResetPlayFastSpeed() {
        int i = this.mSpeed;
        if (i == 0) {
            this.mSpeed = 0;
            this.tvSpeed.setText("X 1");
            this.mMyCamera.mhiNvrdev.PlayLocal_Speed(0, 0);
            this.mMyCamera.mhiNvrdev.SetHiCameraTimeSpeedPlay(false);
            this.mdownLoadNextFileTime = 5000;
            return;
        }
        if (i == 2) {
            this.mMyCamera.mhiNvrdev.PlayLocal_Speed(2, 5);
            this.mMyCamera.mhiNvrdev.SetHiCameraTimeSpeedPlay(true);
            this.mSpeed = 2;
            this.tvSpeed.setText("X 2");
            this.mdownLoadNextFileTime = 10000;
            return;
        }
        if (i == 4) {
            this.mMyCamera.mhiNvrdev.PlayLocal_Speed(4, 0);
            this.mMyCamera.mhiNvrdev.SetHiCameraTimeSpeedPlay(true);
            this.mSpeed = 4;
            this.tvSpeed.setText("X 4");
            this.mdownLoadNextFileTime = 20000;
            return;
        }
        if (i == 8) {
            this.mMyCamera.mhiNvrdev.PlayLocal_Speed(8, 0);
            this.mMyCamera.mhiNvrdev.SetHiCameraTimeSpeedPlay(true);
            this.mSpeed = 8;
            this.tvSpeed.setText("X 8");
            this.mdownLoadNextFileTime = 40000;
            return;
        }
        if (i != 16) {
            return;
        }
        this.mMyCamera.mhiNvrdev.PlayLocal_Speed(16, 0);
        this.mMyCamera.mhiNvrdev.SetHiCameraTimeSpeedPlay(true);
        this.mSpeed = 16;
        this.tvSpeed.setText("X 16");
        this.mdownLoadNextFileTime = MediationConstant.ErrorCode.ADN_INIT_FAIL;
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        MyPlaybackGLMonitor myPlaybackGLMonitor = this.monitor;
        if (myPlaybackGLMonitor != null) {
            myPlaybackGLMonitor.FreeMonitor();
        }
    }

    @Override
    public void receiveIOCtrlData(HiCamera hiCamera, int i, byte[] bArr, int i2) {
        Bundle bundle = new Bundle();
        bundle.putByteArray("data", bArr);
        Message obtainMessage = this.handler.obtainMessage();
        obtainMessage.what = -1879048189;
        obtainMessage.obj = hiCamera;
        obtainMessage.arg1 = i;
        obtainMessage.arg2 = i2;
        obtainMessage.setData(bundle);
        this.handler.sendMessage(obtainMessage);
    }

    @Override
    public void receiveSessionState(HiCamera hiCamera, int i) {
        Message obtainMessage = this.handler.obtainMessage();
        obtainMessage.what = HiDataValue.HANDLE_MESSAGE_SESSION_STATE;
        obtainMessage.arg1 = i;
        obtainMessage.obj = hiCamera;
        this.handler.sendMessage(obtainMessage);
    }

    @Override
    public void callbackStateDual(HiCamera hiCamera, int i, int i2, int i3, int i4) {
        if (HiTools.mDualvalue == 0 || HiTools.mDualvalue == 1) {
            if (i == 2) {
                return;
            }
        } else if (HiTools.mDualvalue == 2 && i == 1) {
            return;
        }
        if (this.mMyCamera != hiCamera) {
            return;
        }
        Message obtainMessage = this.handler.obtainMessage();
        obtainMessage.what = i2;
        obtainMessage.arg1 = i3;
        obtainMessage.arg2 = i4;
        this.handler.sendMessage(obtainMessage);
    }

    @Override
    public void callbackState(HiCamera hiCamera, int i, int i2, int i3) {
        if (this.mMyCamera != hiCamera) {
            return;
        }
        Message obtainMessage = this.handler.obtainMessage();
        obtainMessage.what = i;
        obtainMessage.arg1 = i2;
        obtainMessage.arg2 = i3;
        this.handler.sendMessage(obtainMessage);
    }

    @Override
    public void callbackPlayUTC(HiCamera hiCamera, int i) {
        if (this.mMyCamera != hiCamera) {
            return;
        }
        if (this.oldTime == 0) {
            this.oldTime = i;
        }
        long j = i;
        long j2 = j - this.oldTime;
        long j3 = 60;
        if (j2 < 0) {
            this.oldTime = j;
            j2 = 60;
        }
        if (this.savetime == 0) {
            this.savetime = j;
        }
        if (j - this.savetime > 1000) {
            this.oldTime = j;
        } else {
            j3 = j2;
        }
        this.savetime = j;
        Message obtainMessage = this.handler.obtainMessage();
        obtainMessage.what = -1879048183;
        obtainMessage.arg1 = (int) (j3 / 1000);
        this.lineHandler.sendMessage(obtainMessage);
    }

    @Override
    public void callbackplaylocal(HiCamera hiCamera, int i, int i2, int i3, long j, int i4, int i5) {
        long j2;
        int i6 = i3;
        HiLog.e(hiCamera.getUid() + Constants.COLON_SEPARATOR + i + Constants.COLON_SEPARATOR + i2 + Constants.COLON_SEPARATOR + i6 + Constants.COLON_SEPARATOR + j + Constants.COLON_SEPARATOR + i4 + Constants.COLON_SEPARATOR + i5);
        if (i6 == 0) {
            i6 = 30;
        }
        if (j != 0) {
            if (this.oldTime == 0) {
                this.oldTime = j;
                this.subtime = 0L;
            }
            long j3 = this.oldTime;
            if (j > j3) {
                long j4 = j - j3;
                if (j4 < 0) {
                    this.oldTime = j;
                    j4 = 60;
                }
                if (this.savetime == 0) {
                    this.savetime = j;
                }
                if (j - this.savetime > 9000) {
                    this.oldTime = j;
                    j2 = 60;
                } else {
                    j2 = j4;
                }
                this.savetime = j;
                Message obtainMessage = this.handler.obtainMessage();
                obtainMessage.what = -1879048183;
                obtainMessage.arg1 = (int) (j2 / 1000);
                this.lineHandler.sendMessage(obtainMessage);
            }
            if (this.subtime == 0) {
                this.subtime = this.oldTime + (i6 * 1000);
            }
            HiLog.e(this.firstVideoStartTime + "tedG" + this.myTimeLineView.getCurrentValue() + "---" + this.mTimeInMicros + ";;;;" + ((this.oldTime + (i6 * 1000)) - j) + "::" + this.subtime + "::" + (this.subtime - j) + "::" + this.mAct.isDownloading + "::" + this.mAct.isCallDownload + "::" + this.preLoadingFile + "::" + this.mdownLoadNextFileTime);
            if (!this.mAct.isDownloading && !this.mAct.isCallDownload && !this.preLoadingFile && this.subtime - j <= this.mdownLoadNextFileTime) {
                HiLog.e("tedG--....()....--" + this.mTimeInMicros + ";;;;");
                this.preLoadingFile = true;
                this.mTimeInMicros = this.myTimeLineView.getCurrentValue();
                HiLog.e("tedG--....()....--" + this.mTimeInMicros + ";;;;");
                long j5 = this.mTimeInMicros;
                int findVideoFile = findVideoFile(j5, -1);
                if (findVideoFile == -1) {
                    this.myTimeLineView.listener.onNoneVideo("", j5);
                    this.mBackToNoFile = true;
                    return;
                }
                if (this.myTimeLineView.isScroll()) {
                    return;
                }
                int i7 = findVideoFile + 1;
                if (i7 < this.curentDayVideo.size()) {
                    PlaybackNvrVo playbackNvrVo = this.curentDayVideo.get(i7);
                    HiLogcatUtil.e("currentPlayPosition:" + this.currentPlayPosition + "::" + findVideoFile);
                    this.currentPlayPosition = findVideoFile;
                    byte[] bArr = new byte[8];
                    playbackNvrVo.getStartTime();
                    System.arraycopy(playbackNvrVo.getTest(), 0, bArr, 0, 8);
                    preLoadFile(playbackNvrVo, bArr);
                }
            }
        }
        Message obtain = Message.obtain();
        if (i5 == 31) {
            obtain.what = HANDLE_MESSAGE_PLAYONLINE_LODING;
        } else if (i5 != 32) {
            switch (i5) {
                case -1:
                case 5:
                    this.mhandlerPF.sendEmptyMessage(1101);
                    break;
                case 0:
                    this.preLoadingFile = false;
                    this.oldTime = 0L;
                    this.mhandlerPF.sendEmptyMessage(10);
                    break;
                case 1:
                    this.isReadyPlay = true;
                    obtain.what = HANDLE_MESSAGE_SEEKBAR_START;
                    obtain.arg1 = i;
                    obtain.arg2 = i2;
                    break;
                case 2:
                    obtain.what = -1879048187;
                    break;
                case 3:
                    this.mhandlerPF.sendEmptyMessage(HANDLE_MESSAGE_SEEKBAR_END);
                    break;
                case 4:
                    this.mhandlerPF.sendEmptyMessage(HiDataValue.HANDLE_MESSAGE_SCAN_CHECK);
                    break;
            }
        } else {
            obtain.what = HANDLE_MESSAGE_PLAYONLINE_PLAYING;
        }
        this.mhandlerPF.sendMessage(obtain);
    }

    @Override
    public void callbackplaylocalExt(HiCamera hiCamera, int i, int i2, int i3, long j, int i4, int i5, String str) {
        HiLog.e(hiCamera.getUid() + Constants.COLON_SEPARATOR + i + Constants.COLON_SEPARATOR + i2 + Constants.COLON_SEPARATOR + i3 + Constants.COLON_SEPARATOR + j + Constants.COLON_SEPARATOR + i4 + Constants.COLON_SEPARATOR + i5 + Constants.COLON_SEPARATOR + str);
        if (!this.mAct.isDownloading && !this.isCallStopDown) {
            if (i5 == 21) {
                this.mAct.isDownloading = true;
            }
            HiLogcatUtil.e(this.mAct.isDownloading + Constants.COLON_SEPARATOR + i5 + Constants.COLON_SEPARATOR + 21);
        }
        Bundle bundle = new Bundle();
        bundle.putString("data", str);
        Message obtainMessage = this.handler.obtainMessage();
        obtainMessage.what = i5;
        obtainMessage.setData(bundle);
        this.mhandlerPF.sendMessage(obtainMessage);
    }
}