CloudFilePlaybackDualFragment.java 源代码


package activity.cloud.timeaxis.fragment;

import activity.LocalFile.LocalFileActivity2;
import activity.cloud.OSSPlaybackDualLocalActivity;
import activity.cloud.OSSPlaybackDualLocalActivity_ThreeEyes;
import activity.cloud.OSSPlaybackLocalActivity;
import activity.cloud.OSSPlaybackSpliceLocalActivity;
import activity.cloud.OSSWallMountedPlaybackLocalActivity;
import activity.cloud.adapter.CloudMyFilePagerAdapter;
import activity.cloud.bean.CloudCalenderDay;
import activity.cloud.timeaxis.NewCloudPlaybackDualActivity;
import activity.cloud.view.CloudNoSlidingViewPager;
import activity.video.adapter.VideoInfoAdapter;
import android.animation.ObjectAnimator;
import android.content.Context;
import android.content.Intent;
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.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.PopupWindow;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import base.HiFragment;
import bean.MyCamera;
import bean.VideoInfo;
import butterknife.ButterKnife;
import butterknife.Unbinder;
import com.hichip.base.HiLog;
import com.hichip.callback.ICameraDownloadCallback;
import com.hichip.callback.ICameraIOSessionCallback;
import com.hichip.callback.PlayOSSFileCallback;
import com.hichip.campro.R;
import com.hichip.content.HiChipDefines;
import com.hichip.control.HiCamera;
import com.hichip.sdk.HiPlayOSSDualSDK;
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 custom.CircleProgressBar;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
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 java.util.Locale;
import org.apache.http.cookie.ClientCookie;
import org.greenrobot.eventbus.EventBus;
import service.DeleteCloudCacheFileService;
import timeaxis.calender.TitleGridAdapter;
import utils.FileSizeUtils;
import utils.HiLogcatUtil;
import utils.HiTools;
import utils.MyToast;
import utils.SharePreUtils;
import utils.SystemUtils;
import utils.TimeUtil;

public class CloudFilePlaybackDualFragment extends HiFragment implements View.OnClickListener, PlayOSSFileCallback, AdapterView.OnItemClickListener, ICameraDownloadCallback, ICameraIOSessionCallback {
    private static final int ECS_CALL_BACK = 1114;
    public static final String FILE_PATH = "file_path";
    private static final int HAVE_FILE_DAY_CALL_BACK = 1113;
    public static final int MY_PERMISSION_REQUEST_CODE = 10017;
    private static final int OSS_CALL_BACK = 1115;
    private static final int SINGLE_DAY_FILE_CALLBACK_END = 1112;
    private VideoInfoAdapter adapter;
    private CircleProgressBar circleProgressbar;
    private NewCloudPlaybackDualActivity cloudActivity;
    private byte[] cloudBuff;
    private int cloudBuffLength;
    private CloudMyFilePagerAdapter cloudPagerAdapter;
    private long currentMills;
    private boolean isDownloading;
    private boolean isVisibleToUser;
    private ImageView iv_arrow;
    ImageView iv_left;
    ImageView iv_right;
    ListView list_video_online;
    private View loadingView;
    private MyCamera mCamera;
    private OnWrongPswListener mOnWrongPswListener;
    private String mOssFileLocalPath;
    private String mOssFilePlayPath;
    private int moveCalendarCurrentPage;
    private String path;
    private TextView popup_tips_down;
    private PopupWindow progressPop;
    private boolean pswChanged;
    RelativeLayout rl_calendar;
    private View searchTimeView;
    LinearLayout stc_calendar_layout;
    private GridView title_gView;
    private TextView tv_cancel_downloading_video;
    private TextView tv_goto_downloading_video;
    TextView tv_nothing;
    private TextView tv_one;
    private TextView tv_sort;
    private TextView tv_two;
    TextView tv_years_month;
    private TextView txtSearchTime;
    private Unbinder unbinder;
    CloudNoSlidingViewPager viewpager;
    private int mCalendarCurrentPage = 999;
    private boolean mFirst = true;
    public boolean mIsDataReceiveEnd = false;
    private boolean mIsDescending = true;
    private List<VideoInfo> video_list = new ArrayList();
    private ArrayList<String> day_list = new ArrayList<>();
    private ArrayList<Integer> listDay = new ArrayList<>();
    private SimpleDateFormat sdf = new SimpleDateFormat(TimeUtil.FORMAT_DATE_TIME_FULL);
    private Handler fileHandler = new Handler() {
        @Override
        public void handleMessage(Message message) {
            int i = message.what;
            if (i == -1879048185) {
                CloudFilePlaybackDualFragment.this.handDownLoad(message);
                return;
            }
            if (i != CloudFilePlaybackDualFragment.SINGLE_DAY_FILE_CALLBACK_END) {
                return;
            }
            if (CloudFilePlaybackDualFragment.this.list_video_online != null && CloudFilePlaybackDualFragment.this.list_video_online.getFooterViewsCount() > 0) {
                CloudFilePlaybackDualFragment.this.list_video_online.removeFooterView(CloudFilePlaybackDualFragment.this.loadingView);
            }
            if (CloudFilePlaybackDualFragment.this.adapter != null) {
                CloudFilePlaybackDualFragment.this.adapter.notifyDataSetChanged();
            }
            CloudFilePlaybackDualFragment.this.firstReceive = 0;
            CloudFilePlaybackDualFragment.this.mIsDataReceiveEnd = true;
        }
    };
    private Handler ioHandler = new Handler() {
        @Override
        public void handleMessage(Message message) {
            if (message.what == -1879048191 && message.arg1 == 3) {
                Log.e("tedu", " cloud file receive WRONG_PASSWORD ");
                CloudFilePlaybackDualFragment.this.pswChanged = true;
            }
        }
    };
    private Handler mHandler = new Handler() {
        @Override
        public void handleMessage(Message message) {
            int i = message.what;
            switch (i) {
                case CloudFilePlaybackDualFragment.HAVE_FILE_DAY_CALL_BACK:
                    if (CloudFilePlaybackDualFragment.this.day_list.size() > 0) {
                        HiTools.sortList(CloudFilePlaybackDualFragment.this.day_list);
                        HiLogcatUtil.dTag(HiLogcatUtil.TAG_Google, "day_list: " + CloudFilePlaybackDualFragment.this.day_list.toString());
                        CloudFilePlaybackDualFragment.this.mCamera.mPlayDualOSS.GetOSSFileList((String) CloudFilePlaybackDualFragment.this.day_list.get(CloudFilePlaybackDualFragment.this.day_list.size() - 1), 1, 0);
                        String str = (String) CloudFilePlaybackDualFragment.this.day_list.get(CloudFilePlaybackDualFragment.this.day_list.size() - 1);
                        int parseInt = Integer.parseInt(str.substring(0, 4));
                        int parseInt2 = Integer.parseInt(str.substring(4, 6));
                        Calendar calendar = Calendar.getInstance();
                        calendar.set(1, parseInt);
                        calendar.set(2, parseInt2 - 1);
                        calendar.set(5, 1);
                        CloudFilePlaybackDualFragment cloudFilePlaybackDualFragment = CloudFilePlaybackDualFragment.this;
                        cloudFilePlaybackDualFragment.initCalenderViewPager(cloudFilePlaybackDualFragment.day_list, str, calendar, CloudFilePlaybackDualFragment.this.mCalendarCurrentPage);
                        StringBuilder sb = new StringBuilder(str);
                        sb.insert(6, Constants.ACCEPT_TIME_SEPARATOR_SERVER);
                        sb.insert(4, Constants.ACCEPT_TIME_SEPARATOR_SERVER);
                        CloudFilePlaybackDualFragment.this.txtSearchTime.setText(sb.toString());
                    }
                    CloudFilePlaybackDualFragment.this.firstReceive = 0;
                    return;
                case CloudFilePlaybackDualFragment.ECS_CALL_BACK:
                    if (message.arg1 == 0) {
                        return;
                    }
                    CloudFilePlaybackDualFragment.this.showEcsError(message.arg1, message.arg2);
                    return;
                case CloudFilePlaybackDualFragment.OSS_CALL_BACK:
                    if (message.arg1 != 0) {
                        CloudFilePlaybackDualFragment.this.showOssError(message.arg1, message.arg2);
                        return;
                    }
                    Log.i("==cloud", "OSS_CALL_BACK: SUCCESS");
                    if (CloudFilePlaybackDualFragment.this.mFirst) {
                        CloudFilePlaybackDualFragment.this.mCamera.mPlayDualOSS.GetOSSFileTime(1, 0);
                        CloudFilePlaybackDualFragment.this.mFirst = false;
                        return;
                    }
                    return;
                default:
                    switch (i) {
                        case 24832:
                            CloudFilePlaybackDualFragment.this.ShowError(1, message.what + "");
                            return;
                        case HiChipDefines.HI_P2P_GET_SNAP_AUTO_PARAM:
                            if (message.what == 24833) {
                                CloudFilePlaybackDualFragment cloudFilePlaybackDualFragment2 = CloudFilePlaybackDualFragment.this;
                                cloudFilePlaybackDualFragment2.ShowError(0, cloudFilePlaybackDualFragment2.getString(R.string.no_record_file));
                                return;
                            }
                            CloudFilePlaybackDualFragment.this.ShowError(1, message.what + "");
                            return;
                        case HiChipDefines.HI_P2P_SET_SNAP_AUTO_PARAM:
                        case HiChipDefines.HI_P2P_GET_SNAP_AUTO_SCHEDULE:
                        case HiChipDefines.HI_P2P_SET_SNAP_AUTO_SCHEDULE:
                            if (CloudFilePlaybackDualFragment.this.progressPop != null && CloudFilePlaybackDualFragment.this.progressPop.isShowing()) {
                                CloudFilePlaybackDualFragment.this.progressPop.dismiss();
                                CloudFilePlaybackDualFragment.this.deleteLoadingFile();
                            }
                            CloudFilePlaybackDualFragment.this.mIsDataReceiveEnd = true;
                            CloudFilePlaybackDualFragment.this.firstReceive = 0;
                            Toast.makeText(CloudFilePlaybackDualFragment.this.getContext(), HiTools.getErrorMsg(CloudFilePlaybackDualFragment.this.getContext(), CloudFilePlaybackDualFragment.toHex(message.what, 6), 0, 0), 1).show();
                            return;
                        default:
                            switch (i) {
                                case 25088:
                                    break;
                                case 25089:
                                    break;
                                case 25090:
                                case 25091:
                                case 25092:
                                    break;
                                default:
                                    switch (i) {
                                        case 25344:
                                            break;
                                        case 25345:
                                            break;
                                        case 25346:
                                        case 25347:
                                        case 25348:
                                            break;
                                        default:
                                            switch (i) {
                                                case 25600:
                                                    break;
                                                case 25601:
                                                    break;
                                                case 25602:
                                                case 25603:
                                                case 25604:
                                                    break;
                                                default:
                                                    switch (i) {
                                                        case 25856:
                                                            break;
                                                        case 25857:
                                                            break;
                                                        case 25858:
                                                        case 25859:
                                                        case 25860:
                                                            break;
                                                        default:
                                                            switch (i) {
                                                                case 26112:
                                                                    break;
                                                                case 26113:
                                                                    break;
                                                                case 26114:
                                                                case 26115:
                                                                case 26116:
                                                                    break;
                                                                default:
                                                                    return;
                                                            }
                                                    }
                                            }
                                    }
                            }
                    }
            }
        }
    };
    private int firstReceive = 0;

    public interface OnWrongPswListener {
        void onWrongPsw();
    }

    @Override
    public void callbackDownloadSnapData(HiCamera hiCamera, int i, byte[] bArr, int i2, int i3) {
    }

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

    @Override
    public void callbackOSSOCloudReq(String str, int i, int i2, int i3, int i4, String str2) {
    }

    @Override
    public void callbackplayDuallocalExt(int i, int i2, int i3, int i4, long j, long j2, int i5, int i6, String str) {
    }

    @Override
    public void callbackplaylocal(int i, int i2, int i3, long j, int i4, int i5) {
    }

    @Override
    public void callbackplaylocalExt(int i, int i2, int i3, long j, long j2, int i4, int i5, String str) {
    }

    @Override
    public void receiveIOCtrlData(HiCamera hiCamera, int i, byte[] bArr, int i2) {
    }

    public static CloudFilePlaybackDualFragment newInstance(String str) {
        CloudFilePlaybackDualFragment cloudFilePlaybackDualFragment = new CloudFilePlaybackDualFragment();
        Bundle bundle = new Bundle();
        bundle.putSerializable("UID", str);
        cloudFilePlaybackDualFragment.setArguments(bundle);
        return cloudFilePlaybackDualFragment;
    }

    @Override
    public void onAttach(Context context) {
        super.onAttach(context);
        this.cloudActivity = (NewCloudPlaybackDualActivity) context;
    }

    @Override
    public void onCreate(Bundle bundle) {
        String string;
        super.onCreate(bundle);
        Log.i("==fragment", "file-onCreate: ");
        Bundle arguments = getArguments();
        if (arguments == null || (string = arguments.getString("UID")) == null) {
            return;
        }
        for (MyCamera myCamera : HiDataValue.CameraList) {
            if (string.equals(myCamera.getUid())) {
                this.mCamera = myCamera;
                return;
            }
        }
    }

    @Override
    public View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
        View inflate = layoutInflater.inflate(R.layout.fragment_cloud_file_playback, viewGroup, false);
        this.unbinder = ButterKnife.bind(this, inflate);
        initView(inflate);
        return inflate;
    }

    public void registerListener() {
        MyCamera myCamera = this.mCamera;
        if (myCamera != null) {
            myCamera.registerIOSessionListener(this);
            this.mCamera.registerDownloadListener(this);
            if (this.mCamera.mPlayDualOSS != null) {
                this.mCamera.mPlayDualOSS.registerPlayOSSStateListener(this);
            }
        }
    }

    public void unregisterListener() {
        MyCamera myCamera = this.mCamera;
        if (myCamera != null) {
            myCamera.unregisterDownloadListener(this);
            if (this.mCamera.mPlayDualOSS != null) {
                this.mCamera.mPlayDualOSS.unregisterPlayOSSStateListener(this);
            }
        }
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        Log.i("==fragment", "file-onDestroy: ");
        this.isDownloading = false;
        Handler handler = this.mHandler;
        if (handler != null) {
            handler.removeCallbacksAndMessages(null);
        }
        Handler handler2 = this.fileHandler;
        if (handler2 != null) {
            handler2.removeCallbacksAndMessages(null);
        }
        Handler handler3 = this.ioHandler;
        if (handler3 != null) {
            handler3.removeCallbacksAndMessages(null);
        }
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        this.unbinder.unbind();
        EventBus.getDefault().unregister(this);
        unregisterListener();
        MyCamera myCamera = this.mCamera;
        if (myCamera != null) {
            myCamera.unregisterIOSessionListener(this);
        }
    }

    private void initView(View view) {
        View findViewById = view.findViewById(R.id.search_layout);
        this.searchTimeView = findViewById;
        this.txtSearchTime = (TextView) findViewById.findViewById(R.id.txtSearchTimeDuration);
        this.tv_sort = (TextView) this.searchTimeView.findViewById(R.id.tv_sort);
        this.iv_arrow = (ImageView) this.searchTimeView.findViewById(R.id.iv_arrow);
        this.searchTimeView.findViewById(R.id.ll_sort).setOnClickListener(this);
        this.loadingView = getLayoutInflater().inflate(R.layout.loading_events, (ViewGroup) null);
    }

    @Override
    public void onActivityCreated(Bundle bundle) {
        super.onActivityCreated(bundle);
        Log.i("==fragment", "file-onActivityCreated: ");
        registerListener();
        checkOssCacheSize();
        initOSS();
    }

    @Override
    public void onStart() {
        super.onStart();
    }

    @Override
    public void onResume() {
        super.onResume();
        if (this.isVisibleToUser) {
            registerListener();
        }
    }

    @Override
    public void onPause() {
        PopupWindow popupWindow;
        super.onPause();
        unregisterListener();
        if (this.isDownloading && (popupWindow = this.progressPop) != null && popupWindow.isShowing()) {
            this.progressPop.dismiss();
            deleteLoadingFile();
        }
    }

    @Override
    public void onStop() {
        super.onStop();
    }

    @Override
    public void onDetach() {
        super.onDetach();
    }

    @Override
    public void setUserVisibleHint(boolean z) {
        super.setUserVisibleHint(z);
        this.isVisibleToUser = z;
        if (z) {
            NewCloudPlaybackDualActivity newCloudPlaybackDualActivity = this.cloudActivity;
            if (newCloudPlaybackDualActivity != null && newCloudPlaybackDualActivity.loading != null && this.cloudActivity.loading.getVisibility() == 0) {
                this.cloudActivity.loading.setVisibility(8);
            }
            registerListener();
            return;
        }
        unregisterListener();
    }

    private void checkOssCacheSize() {
        if (getActivity() != null && Double.valueOf(FileSizeUtils.getFileOrFilesSize(HiDataValue.getPathCameraVideoOSSDownLoadcache(getActivity()), 3)).compareTo(Double.valueOf(HiDataValue.DelCacheMax)) > 0) {
            getActivity().startService(new Intent(getActivity(), (Class<?>) DeleteCloudCacheFileService.class));
        }
    }

    private void initOSS() {
        MyCamera myCamera;
        if (getContext() == null || (myCamera = this.mCamera) == null) {
            return;
        }
        if (myCamera.mPlayDualOSS == null) {
            this.mCamera.mPlayDualOSS = new HiPlayOSSDualSDK();
            boolean z = SharePreUtils.getBoolean(HiDataValue.CACHE, getActivity(), Constant.DEV_IsVivoMedia, false);
            if (SystemUtils.isVIVOMobile(getActivity()) && Build.VERSION.SDK_INT > 29 && !z) {
                this.mCamera.mPlayDualOSS.SetDecodeViVoVideoType(0);
            } else {
                this.mCamera.mPlayDualOSS.SetDecodeViVoVideoType(1);
            }
            this.mCamera.mPlayDualOSS.registerPlayOSSStateListener(this);
        } else {
            this.mCamera.mPlayDualOSS.registerPlayOSSStateListener(this);
        }
        if (this.mCamera.mPlayDualOSS.GetOSSisInfo()) {
            Log.i("==cloud", "GetOSSisInfo: SUCCESS");
            this.mCamera.mPlayDualOSS.GetOSSFileTime(1, 0);
        } else {
            this.mCamera.mPlayDualOSS.SetContext(getContext(), this.mCamera.getUid());
            this.mCamera.mPlayDualOSS.GetOSSInfoOCloud(this.mCamera.getUsername(), this.mCamera.getPassword(), this.mCamera.getEcsIp(), this.mCamera.getEcsPort(), 1, 0);
        }
        VideoInfoAdapter videoInfoAdapter = new VideoInfoAdapter(getActivity(), this.video_list, this.mCamera);
        this.adapter = videoInfoAdapter;
        videoInfoAdapter.SetListType(true);
        this.list_video_online.addFooterView(this.loadingView);
        this.list_video_online.setAdapter((ListAdapter) this.adapter);
        this.list_video_online.setOnItemClickListener(this);
    }

    @Override
    public void onClick(View view) {
        if (view.getId() != R.id.ll_sort) {
            return;
        }
        if (this.mIsDataReceiveEnd) {
            this.tv_sort.setText(getString(this.mIsDescending ? R.string.asce : R.string.desc));
            this.iv_arrow.animate().rotation(this.mIsDescending ? 180.0f : 0.0f).setDuration(400L).start();
            Collections.reverse(this.video_list);
            this.adapter.setClickItemPosition(-10);
            this.adapter.notifyDataSetChanged();
            this.mIsDescending = !this.mIsDescending;
            return;
        }
        MyToast.showToast(getContext(), getString(R.string.data_get_wait));
    }

    @Override
    public void onItemClick(AdapterView<?> adapterView, View view, int i, long j) {
        OnWrongPswListener onWrongPswListener;
        if (this.mCamera != null && (onWrongPswListener = this.mOnWrongPswListener) != null && this.pswChanged) {
            onWrongPswListener.onWrongPsw();
            if (this.mCamera.mPlayDualOSS != null) {
                this.mCamera.mPlayDualOSS = null;
                return;
            }
            return;
        }
        if (System.currentTimeMillis() - this.currentMills < 500) {
            return;
        }
        this.currentMills = System.currentTimeMillis();
        if (i >= 0) {
            this.adapter.setClickItemPosition(i);
        }
        if (HiTools.isCustomFastClick(1000)) {
            return;
        }
        popupMethod(i, view);
    }

    private void popupMethod(int i, View view) {
        final int headerViewsCount;
        if (getActivity() != null && (headerViewsCount = i - this.list_video_online.getHeaderViewsCount()) >= 0) {
            View inflate = View.inflate(getActivity(), R.layout.popview_video_online, null);
            final PopupWindow popupWindow = new PopupWindow();
            popupWindow.setContentView(inflate);
            popupWindow.setWidth(-1);
            popupWindow.setHeight(-1);
            popupWindow.showAtLocation(inflate, 17, 0, 0);
            TextView textView = (TextView) view.findViewById(R.id.txt_time);
            TextView textView2 = (TextView) inflate.findViewById(R.id.pup_vo_item_tv_state);
            TextView textView3 = (TextView) inflate.findViewById(R.id.pup_vo_item_tv_time);
            textView2.setText(this.txtSearchTime.getText());
            textView3.setText(textView.getText());
            ((TextView) inflate.findViewById(R.id.tv_play_video_online)).setOnClickListener(new View.OnClickListener() {
                @Override
                public final void onClick(View view2) {
                    CloudFilePlaybackDualFragment.this.lambda$popupMethod$1$CloudFilePlaybackDualFragment(popupWindow, headerViewsCount, view2);
                }
            });
            ((TextView) inflate.findViewById(R.id.tv_downlinad_video_online)).setOnClickListener(new View.OnClickListener() {
                @Override
                public final void onClick(View view2) {
                    CloudFilePlaybackDualFragment.this.lambda$popupMethod$2$CloudFilePlaybackDualFragment(popupWindow, headerViewsCount, view2);
                }
            });
            ((TextView) inflate.findViewById(R.id.tv_downlinad_video_cancel)).setOnClickListener(new View.OnClickListener() {
                @Override
                public final void onClick(View view2) {
                    popupWindow.dismiss();
                }
            });
            this.adapter.notifyDataSetChanged();
        }
    }

    public void lambda$popupMethod$1$CloudFilePlaybackDualFragment(PopupWindow popupWindow, final int i, View view) {
        popupWindow.dismiss();
        this.list_video_online.postDelayed(new Runnable() {
            @Override
            public final void run() {
                CloudFilePlaybackDualFragment.this.lambda$popupMethod$0$CloudFilePlaybackDualFragment(i);
            }
        }, 100L);
    }

    public void lambda$popupMethod$2$CloudFilePlaybackDualFragment(PopupWindow popupWindow, int i, View view) {
        popupWindow.dismiss();
        if (HiTools.HiPermission(getActivity(), getActivity(), 1, 10017)) {
            return;
        }
        downloadRecording(i);
    }

    public void lambda$popupMethod$0$CloudFilePlaybackDualFragment(int i) {
        if (this.mCamera == null || getActivity() == null) {
            return;
        }
        VideoInfo videoInfo = this.video_list.get(i);
        Bundle bundle = new Bundle();
        bundle.putString(HiDataValue.EXTRAS_KEY_UID, this.mCamera.getUid());
        bundle.putString("file_path", videoInfo.filename);
        bundle.putString(HiDataValue.EXTRAS_KEY_UID, this.mCamera.getUid());
        bundle.putInt("filesize", videoInfo.fileLen);
        bundle.putBoolean("needShowSnapshotButton", true);
        bundle.putInt("iv_fastforward", 1);
        Intent intent = new Intent();
        if (this.mCamera.isWallMounted) {
            intent.setClass(getActivity(), OSSWallMountedPlaybackLocalActivity.class);
            bundle.putString("start_time", getStartTime(videoInfo.start_time));
        } else if (this.mCamera.isFishEye()) {
            intent.setClass(getActivity(), OSSPlaybackLocalActivity.class);
            bundle.putString("start_time", videoInfo.start_time);
        } else {
            if (this.mCamera.getdevDual()) {
                if (this.mCamera.getIs_ThreeEyes()) {
                    intent.setClass(getActivity(), OSSPlaybackDualLocalActivity_ThreeEyes.class);
                } else {
                    intent.setClass(getActivity(), OSSPlaybackDualLocalActivity.class);
                }
            } else if (!this.mCamera.getdevSplice()) {
                intent.setClass(getActivity(), OSSPlaybackLocalActivity.class);
            } else {
                intent.setClass(getActivity(), OSSPlaybackSpliceLocalActivity.class);
            }
            bundle.putString("start_time", videoInfo.start_time);
        }
        intent.putExtras(bundle);
        startActivity(intent);
    }

    private String getStartTime(String str) {
        try {
            return this.sdf.format(new SimpleDateFormat(TimeUtil.FORMAT_STRING).parse(str.split("_")[0].replace(Constants.ACCEPT_TIME_SEPARATOR_SERVER, "")));
        } catch (ParseException e) {
            e.printStackTrace();
            return str;
        }
    }

    private void downloadRecording(int i) {
        if (getContext() == null) {
            return;
        }
        VideoInfo videoInfo = this.video_list.get(i);
        String filename = videoInfo.getFilename();
        int fileLen = videoInfo.getFileLen();
        if (HiTools.isSDCardExist()) {
            File file = new File(HiDataValue.getPathCameraVideoOSSDownLoadcache(getContext()));
            if (!file.exists()) {
                Log.e("==cloud", "createPathCameraVideoOSSDownLoadCache: " + file.mkdirs());
            }
            File file2 = new File(HiDataValue.getPathCameraVideoOnLineDownLoad(this.mCamera.getUid(), getContext()));
            if (!file2.exists()) {
                Log.e("==cloud", "createPathCameraVideoOnLineDownLoad: " + file2.mkdirs());
            }
            String[] split = filename.split("/");
            String str = file.getAbsoluteFile() + "/" + this.mCamera.getUid().replace(Constants.ACCEPT_TIME_SEPARATOR_SERVER, "");
            String str2 = split[1] + Constants.ACCEPT_TIME_SEPARATOR_SERVER + split[3];
            String str3 = file.getAbsoluteFile() + "/" + this.mCamera.getUid().replace(Constants.ACCEPT_TIME_SEPARATOR_SERVER, "") + str2;
            this.mOssFilePlayPath = str3;
            boolean endsWith = str3.endsWith(".rec");
            if (endsWith) {
                this.mOssFilePlayPath = this.mOssFilePlayPath.replace(HiDataValue.OSSFILEEn, HiDataValue.OSSFILEEnd);
                this.mOssFileLocalPath = file2.getAbsoluteFile() + "/" + videoInfo.getRecType() + str2.replace(HiDataValue.OSSFILEEn, HiDataValue.OSSFILEEnd);
            } else {
                this.mOssFilePlayPath = this.mOssFilePlayPath.replace(HiDataValue.OSSFILEEn_HX, HiDataValue.OSSFILEEnd);
                this.mOssFileLocalPath = file2.getAbsoluteFile() + "/" + videoInfo.getRecType() + str2.replace(HiDataValue.OSSFILEEn_HX, HiDataValue.OSSFILEEnd);
            }
            if (new File(this.mOssFilePlayPath).exists()) {
                copyFile(this.mOssFilePlayPath, this.mOssFileLocalPath);
                showPopPupProgress();
                CircleProgressBar circleProgressBar = this.circleProgressbar;
                if (circleProgressBar != null) {
                    circleProgressBar.setProgress(100);
                }
                this.isDownloading = false;
                TextView textView = this.tv_cancel_downloading_video;
                if (textView != null) {
                    textView.setText(R.string.continue_down);
                }
                TextView textView2 = this.tv_goto_downloading_video;
                if (textView2 != null) {
                    textView2.setVisibility(0);
                }
                TextView textView3 = this.popup_tips_down;
                if (textView3 != null) {
                    textView3.setText(getString(R.string.download_done));
                }
                CircleProgressBar circleProgressBar2 = this.circleProgressbar;
                if (circleProgressBar2 != null) {
                    circleProgressBar2.setVisibility(8);
                }
                TextView textView4 = this.tv_one;
                if (textView4 != null) {
                    textView4.setVisibility(0);
                }
                TextView textView5 = this.tv_two;
                if (textView5 != null) {
                    textView5.setVisibility(0);
                }
                ObjectAnimator ofFloat = ObjectAnimator.ofFloat(this.tv_one, "Alpha", 0.0f, 1.0f);
                ofFloat.setDuration(300L);
                ofFloat.start();
                ObjectAnimator ofFloat2 = ObjectAnimator.ofFloat(this.tv_two, "Alpha", 0.0f, 1.0f);
                ofFloat2.setDuration(300L);
                ofFloat2.start();
                return;
            }
            if (endsWith) {
                this.mOssFilePlayPath = this.mOssFilePlayPath.replaceAll(HiDataValue.OSSFILEEnd, HiDataValue.OSSFILEEn);
            } else {
                this.mOssFilePlayPath = this.mOssFilePlayPath.replaceAll(HiDataValue.OSSFILEEnd, HiDataValue.OSSFILEEn_HX);
            }
            MyCamera myCamera = this.mCamera;
            if (myCamera == null || myCamera.mPlayDualOSS == null) {
                return;
            }
            this.mCamera.mPlayDualOSS.OSSPlayDown(filename, str, str2, fileLen, 1);
        }
    }

    private void showPopPupProgress() {
        if (getActivity() == null) {
            return;
        }
        View inflate = View.inflate(getActivity(), R.layout.pup_loading_video, null);
        this.progressPop = new PopupWindow(inflate);
        this.progressPop.setBackgroundDrawable(new ColorDrawable(0));
        this.progressPop.setFocusable(true);
        this.progressPop.setWidth(-1);
        this.progressPop.setHeight(-1);
        this.circleProgressbar = (CircleProgressBar) inflate.findViewById(R.id.circleprogressbar);
        this.popup_tips_down = (TextView) inflate.findViewById(R.id.popu_tips_down);
        this.tv_one = (TextView) inflate.findViewById(R.id.tv_one);
        this.tv_two = (TextView) inflate.findViewById(R.id.tv_two);
        this.progressPop.showAtLocation(inflate, 17, 0, 0);
        this.progressPop.setOnDismissListener(new PopupWindow.OnDismissListener() {
            @Override
            public final void onDismiss() {
                CloudFilePlaybackDualFragment.this.lambda$showPopPupProgress$4$CloudFilePlaybackDualFragment();
            }
        });
        TextView textView = (TextView) inflate.findViewById(R.id.tv_cancel_downloading_video);
        this.tv_cancel_downloading_video = textView;
        textView.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                CloudFilePlaybackDualFragment.this.lambda$showPopPupProgress$5$CloudFilePlaybackDualFragment(view);
            }
        });
        TextView textView2 = (TextView) inflate.findViewById(R.id.tv_goto_downloading_video);
        this.tv_goto_downloading_video = textView2;
        textView2.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                CloudFilePlaybackDualFragment.this.lambda$showPopPupProgress$6$CloudFilePlaybackDualFragment(view);
            }
        });
    }

    public void lambda$showPopPupProgress$4$CloudFilePlaybackDualFragment() {
        this.isDownloading = false;
        MyCamera myCamera = this.mCamera;
        if (myCamera == null || myCamera.mPlayDualOSS == null) {
            return;
        }
        this.mCamera.mPlayDualOSS.StopDownOSS();
        this.mCamera.mPlayDualOSS.StopPlayLocal();
    }

    public void lambda$showPopPupProgress$5$CloudFilePlaybackDualFragment(View view) {
        if (getString(R.string.continue_down).equals(this.tv_cancel_downloading_video.getText().toString().trim())) {
            this.progressPop.dismiss();
        } else {
            this.progressPop.dismiss();
            deleteLoadingFile();
        }
    }

    public void lambda$showPopPupProgress$6$CloudFilePlaybackDualFragment(View view) {
        this.progressPop.dismiss();
        Intent intent = new Intent(getContext(), (Class<?>) LocalFileActivity2.class);
        intent.putExtra(HiDataValue.EXTRAS_KEY_UID, this.mCamera.getUid());
        startActivity(intent);
    }

    public void deleteLoadingFile() {
        Log.i("==cloud", "deleteLoadingFile: " + new File(this.mOssFilePlayPath).delete());
    }

    public boolean copyFile(String str, String str2) {
        try {
            File file = new File(str);
            if (!file.exists()) {
                Log.e("--Method--", "copyFile:  oldFile not exist.");
                return false;
            }
            if (!file.isFile()) {
                Log.e("--Method--", "copyFile:  oldFile not file.");
                return false;
            }
            if (!file.canRead()) {
                Log.e("--Method--", "copyFile:  oldFile cannot read.");
                return false;
            }
            FileInputStream fileInputStream = new FileInputStream(str);
            FileOutputStream fileOutputStream = new FileOutputStream(str2);
            byte[] bArr = new byte[4096];
            while (true) {
                int read = fileInputStream.read(bArr);
                if (-1 != read) {
                    fileOutputStream.write(bArr, 0, read);
                } else {
                    fileInputStream.close();
                    fileOutputStream.flush();
                    fileOutputStream.close();
                    return true;
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
    }

    public void clickChooseData() {
        if (!this.mIsDataReceiveEnd) {
            MyToast.showToast(getActivity(), getString(R.string.data_get_wait));
            return;
        }
        if (this.rl_calendar.getVisibility() == 8) {
            if (this.cloudPagerAdapter != null) {
                this.cloudPagerAdapter.setSelectedDate(this.txtSearchTime.getText().toString().replace(Constants.ACCEPT_TIME_SEPARATOR_SERVER, ""));
            }
            this.rl_calendar.setVisibility(0);
            return;
        }
        this.rl_calendar.setVisibility(8);
    }

    private long getMills(String str) {
        Date date;
        try {
            date = new SimpleDateFormat(TimeUtil.FORMAT_STRING, Locale.getDefault()).parse(str);
        } catch (ParseException e) {
            e.printStackTrace();
            date = null;
        }
        if (date != null) {
            return date.getTime();
        }
        return 0L;
    }

    public void handDownLoad(Message message) {
        float f;
        Bundle data = message.getData();
        int i = message.arg1;
        if (i == 0) {
            showPopPupProgress();
            this.isDownloading = true;
            this.path = data.getString(ClientCookie.PATH_ATTR);
            return;
        }
        if (i == 1) {
            if (this.isDownloading) {
                long j = data.getLong("total");
                if (j == 0) {
                    f = (float) ((data.getLong("curSize") * 100) / 1048576);
                } else {
                    f = (float) ((data.getLong("curSize") * 100) / j);
                }
                if (f >= 100.0f) {
                    f = 99.0f;
                }
                int i2 = (int) f;
                CircleProgressBar circleProgressBar = this.circleProgressbar;
                if (circleProgressBar != null) {
                    circleProgressBar.setProgress(i2);
                    return;
                }
                return;
            }
            return;
        }
        if (i != 2) {
            if (i != 3) {
                return;
            }
            MyToast.showToast(getContext(), getString(R.string.tips_wifi_connect_failed));
            return;
        }
        MyCamera myCamera = this.mCamera;
        if (myCamera != null && myCamera.mPlayDualOSS != null) {
            this.mCamera.mPlayDualOSS.StopDownOSS();
            this.mCamera.mPlayDualOSS.StopPlayLocal();
        }
        String str = this.mOssFilePlayPath;
        if (str != null && this.mOssFileLocalPath != null) {
            if (str.endsWith(".rec")) {
                this.mOssFilePlayPath = this.mOssFilePlayPath.replace(".rec", ".ch26x");
            }
            if (this.mOssFilePlayPath.endsWith(".hx")) {
                this.mOssFilePlayPath = this.mOssFilePlayPath.replace(".hx", ".ch26x");
            }
            copyFile(this.mOssFilePlayPath, this.mOssFileLocalPath);
        }
        CircleProgressBar circleProgressBar2 = this.circleProgressbar;
        if (circleProgressBar2 != null) {
            circleProgressBar2.setProgress(100);
        }
        this.isDownloading = false;
        TextView textView = this.tv_cancel_downloading_video;
        if (textView != null) {
            textView.setText(R.string.continue_down);
        }
        TextView textView2 = this.tv_goto_downloading_video;
        if (textView2 != null) {
            textView2.setVisibility(0);
        }
        TextView textView3 = this.popup_tips_down;
        if (textView3 != null) {
            textView3.setText(getString(R.string.download_done));
        }
        CircleProgressBar circleProgressBar3 = this.circleProgressbar;
        if (circleProgressBar3 != null) {
            circleProgressBar3.setVisibility(8);
        }
        TextView textView4 = this.tv_one;
        if (textView4 != null) {
            textView4.setVisibility(0);
        }
        TextView textView5 = this.tv_two;
        if (textView5 != null) {
            textView5.setVisibility(0);
        }
        ObjectAnimator ofFloat = ObjectAnimator.ofFloat(this.tv_one, "Alpha", 0.0f, 1.0f);
        ofFloat.setDuration(300L);
        ofFloat.start();
        ObjectAnimator ofFloat2 = ObjectAnimator.ofFloat(this.tv_two, "Alpha", 0.0f, 1.0f);
        ofFloat2.setDuration(300L);
        ofFloat2.start();
    }

    private void showLocalError(String str) {
        PopupWindow popupWindow = this.progressPop;
        if (popupWindow != null && popupWindow.isShowing()) {
            this.progressPop.dismiss();
            deleteLoadingFile();
        }
        this.mIsDataReceiveEnd = true;
        this.firstReceive = 0;
        Toast.makeText(getContext(), HiTools.getErrorMsg(getContext(), str, 0, 0), 1).show();
    }

    public void ShowError(int i, String str) {
        this.mIsDataReceiveEnd = true;
        PopupWindow popupWindow = this.progressPop;
        if (popupWindow != null && popupWindow.isShowing()) {
            this.progressPop.dismiss();
        }
        this.firstReceive = 0;
        this.list_video_online.setVisibility(8);
        this.searchTimeView.setVisibility(8);
        this.tv_nothing.setVisibility(0);
        if (i == 1) {
            try {
                str = HiTools.getErrorMsg(getContext(), toHex(Integer.parseInt(str), 6), 0, 0);
            } catch (Exception unused) {
                str = "-10001";
            }
        }
        this.tv_nothing.setText(str);
    }

    public static String toHex(int i, int i2) {
        return splicingZero(Integer.toHexString(i), i2);
    }

    public static String splicingZero(String str, int i) {
        int length = str.length();
        StringBuilder sb = new StringBuilder(str);
        for (int i2 = 0; i2 < i - length; i2++) {
            sb.insert(0, PushConstants.PUSH_TYPE_NOTIFY);
        }
        return sb.toString();
    }

    public void showEcsError(int i, int i2) {
        MyCamera myCamera = this.mCamera;
        if (myCamera != null && myCamera.mPlayDualOSS != null) {
            this.mCamera.mPlayDualOSS = null;
        }
        this.firstReceive = 0;
        this.mIsDataReceiveEnd = true;
        String errorMsg = HiTools.getErrorMsg(getContext(), "ECS", i, i2);
        this.list_video_online.setVisibility(8);
        this.searchTimeView.setVisibility(8);
        this.tv_nothing.setVisibility(0);
        this.tv_nothing.setText(errorMsg);
    }

    public void showOssError(int i, int i2) {
        MyCamera myCamera = this.mCamera;
        if (myCamera != null && myCamera.mPlayDualOSS != null) {
            this.mCamera.mPlayDualOSS = null;
        }
        this.firstReceive = 0;
        this.mIsDataReceiveEnd = true;
        String errorMsg = HiTools.getErrorMsg(getContext(), "OSS", i, i2);
        this.list_video_online.setVisibility(8);
        this.searchTimeView.setVisibility(8);
        this.tv_nothing.setVisibility(0);
        this.tv_nothing.setText(errorMsg);
    }

    @Override
    public void callbackOSSReq(String str, int i, int i2, int i3, String str2) {
        Log.i("==cloud", "callbackOSSReq: " + str + " type: " + i + " ret: " + i2 + " status: " + i3);
        Message obtain = Message.obtain();
        if (i == 1) {
            obtain.what = ECS_CALL_BACK;
        } else if (i == 2) {
            obtain.what = OSS_CALL_BACK;
        } else {
            obtain.what = i;
        }
        obtain.obj = str;
        obtain.arg1 = i2;
        obtain.arg2 = i3;
        this.mHandler.sendMessage(obtain);
    }

    @Override
    public void callbackOSSData(int i, byte[] bArr, int i2, int i3, int i4, int i5, int i6, int i7, String str) {
        if (i == 24837) {
            getHaveFileDay(bArr, i2, i7);
        } else {
            if (i != 25093) {
                return;
            }
            initSingleFile(i7, bArr, i2);
        }
    }

    @Override
    public void CallBackOSSDownLoad(int i, int i2, int i3, String str) {
        Bundle bundle = new Bundle();
        bundle.putLong("total", i3);
        bundle.putLong("curSize", i2);
        bundle.putString(ClientCookie.PATH_ATTR, this.path);
        Message obtainMessage = this.fileHandler.obtainMessage();
        obtainMessage.what = HiDataValue.HANDLE_MESSAGE_DOWNLOAD_STATE;
        obtainMessage.arg1 = i;
        obtainMessage.setData(bundle);
        this.fileHandler.sendMessage(obtainMessage);
    }

    @Override
    public void CallBackOSSDownLoadExt(int i, long j, long j2, String str) {
        HiLog.e(j + ":::::" + j2 + ":::" + i);
        if (i == 24831) {
            if (this.firstReceive != 1) {
                this.cloudBuffLength = 0;
                this.firstReceive = 1;
                this.cloudBuff = null;
                this.cloudBuff = new byte[(int) j2];
                return;
            }
            return;
        }
        if (i == 25087 && this.firstReceive != 1) {
            this.cloudBuffLength = 0;
            this.firstReceive = 1;
            this.cloudBuff = null;
            this.cloudBuff = new byte[(int) j2];
        }
    }

    private void getHaveFileDay(byte[] bArr, int i, int i2) {
        Message obtain = Message.obtain();
        if (i2 == 1) {
            System.arraycopy(bArr, 0, this.cloudBuff, this.cloudBuffLength, i);
            this.cloudBuffLength += i;
            return;
        }
        if (i2 == 2) {
            int i3 = this.cloudBuffLength / 12;
            HiLog.e("" + this.cloudBuffLength + ":::::" + i3);
            byte[] bArr2 = new byte[12];
            byte[] bArr3 = new byte[8];
            if (i3 > 0) {
                for (int i4 = 0; i4 < i3; i4++) {
                    System.arraycopy(this.cloudBuff, i4 * 12, bArr2, 0, 12);
                    System.arraycopy(bArr2, 0, bArr3, 0, 8);
                    this.day_list.add(new String(bArr3));
                }
            }
            obtain.what = HAVE_FILE_DAY_CALL_BACK;
            this.mHandler.sendMessage(obtain);
        }
    }

    private void initSingleFile(int i, byte[] bArr, int i2) {
        if (this.fileHandler == null) {
            return;
        }
        if (i == 1) {
            System.arraycopy(bArr, 0, this.cloudBuff, this.cloudBuffLength, i2);
            this.cloudBuffLength += i2;
        }
        if (i == 2) {
            int i3 = 148;
            int i4 = this.cloudBuffLength / 148;
            HiLog.e("" + this.cloudBuffLength + ":::::" + i4);
            byte[] bArr2 = new byte[148];
            int i5 = 128;
            byte[] bArr3 = new byte[128];
            if (i4 > 0) {
                int i6 = 0;
                while (i6 < i4) {
                    System.arraycopy(this.cloudBuff, i6 * 148, bArr2, 0, i3);
                    System.arraycopy(bArr2, 0, bArr3, 0, i5);
                    int byteArrayToInt_Little = Packet.byteArrayToInt_Little(bArr2, i5);
                    int byteArrayToInt_Little2 = Packet.byteArrayToInt_Little(bArr2, 132);
                    int byteArrayToInt_Little3 = Packet.byteArrayToInt_Little(bArr2, 136);
                    int byteArrayToInt_Little4 = Packet.byteArrayToInt_Little(bArr2, 140);
                    VideoInfo videoInfo = new VideoInfo(0);
                    videoInfo.setRecType(byteArrayToInt_Little2);
                    videoInfo.setFilename(new String(bArr3).trim());
                    String[] split = videoInfo.getFilename().split("/");
                    if (split.length >= 4) {
                        videoInfo.setStart_time(split[1] + Constants.ACCEPT_TIME_SEPARATOR_SERVER + split[3]);
                        videoInfo.setTimeLength(Integer.toString((byteArrayToInt_Little4 - byteArrayToInt_Little3) / 1000));
                        videoInfo.setFileLen(byteArrayToInt_Little);
                        videoInfo.setTime((long) byteArrayToInt_Little3);
                        String[] split2 = split[3].split("_");
                        if (split2.length >= 2) {
                            videoInfo.setEndTime(getMills(split[1] + split2[0]));
                            videoInfo.setStartTime(getMills(split[1] + split2[1]));
                        }
                        this.video_list.add(videoInfo);
                    }
                    i6++;
                    i3 = 148;
                    i5 = 128;
                }
                Collections.reverse(this.video_list);
                Message obtainMessage = this.fileHandler.obtainMessage();
                obtainMessage.what = SINGLE_DAY_FILE_CALLBACK_END;
                this.fileHandler.sendMessage(obtainMessage);
            }
        }
    }

    public void setOnWrongPswListener(OnWrongPswListener onWrongPswListener) {
        this.mOnWrongPswListener = onWrongPswListener;
    }

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

    public void initCalenderViewPager(List<String> list, String str, final Calendar calendar, int i) {
        this.moveCalendarCurrentPage = i;
        int parseInt = Integer.parseInt(str.substring(0, 4));
        int parseInt2 = Integer.parseInt(str.substring(4, 6));
        this.tv_years_month.setText(parseInt + Constants.ACCEPT_TIME_SEPARATOR_SERVER + parseInt2);
        this.viewpager.setScanScroll(true);
        this.listDay.addAll(getDaysByTimeStamp(list, parseInt, parseInt2));
        CloudMyFilePagerAdapter cloudMyFilePagerAdapter = new CloudMyFilePagerAdapter(getActivity(), this.listDay, str, calendar, i);
        this.cloudPagerAdapter = cloudMyFilePagerAdapter;
        this.viewpager.setAdapter(cloudMyFilePagerAdapter);
        this.viewpager.setCurrentItem(this.moveCalendarCurrentPage);
        setTitleGirdView();
        this.stc_calendar_layout.addView(this.title_gView, new LinearLayout.LayoutParams(-1, -2));
        this.cloudPagerAdapter.setOnGridItemClickListener(new CloudMyFilePagerAdapter.OnGridItemClickListener() {
            @Override
            public final void onDayItemClick(int i2) {
                CloudFilePlaybackDualFragment.this.lambda$initCalenderViewPager$8$CloudFilePlaybackDualFragment(calendar, i2);
            }
        });
        setListeners(this.listDay, calendar);
    }

    public void lambda$initCalenderViewPager$8$CloudFilePlaybackDualFragment(Calendar calendar, int i) {
        if (HiTools.isCustomFastClick(500)) {
            return;
        }
        calendar.set(5, 1);
        int i2 = (i - (calendar.get(7) - 1)) + 1;
        int i3 = calendar.get(2) + 1;
        int i4 = calendar.get(1);
        final StringBuilder sb = new StringBuilder();
        sb.append(i4);
        sb.append(Constants.ACCEPT_TIME_SEPARATOR_SERVER);
        if (i3 < 10) {
            sb.append(0);
            sb.append(i3);
        } else {
            sb.append(i3);
        }
        sb.append(Constants.ACCEPT_TIME_SEPARATOR_SERVER);
        if (i2 < 10) {
            sb.append(0);
            sb.append(i2);
        } else {
            sb.append(i2);
        }
        if (isContainDays(this.listDay, i2)) {
            this.rl_calendar.setVisibility(8);
            EventBus.getDefault().post(new CloudCalenderDay(this.listDay, i4, i3, this.moveCalendarCurrentPage, sb.toString().replace(Constants.ACCEPT_TIME_SEPARATOR_SERVER, "")));
            this.mIsDescending = true;
            this.mCalendarCurrentPage = this.moveCalendarCurrentPage;
            this.tv_sort.setText(getString(R.string.desc));
            this.iv_arrow.animate().rotation(0.0f).setDuration(0L).start();
            this.video_list.clear();
            this.adapter.setClickItemPosition(-10);
            this.adapter.notifyDataSetChanged();
            this.mIsDataReceiveEnd = false;
            this.tv_sort.postDelayed(new Runnable() {
                @Override
                public final void run() {
                    CloudFilePlaybackDualFragment.this.lambda$initCalenderViewPager$7$CloudFilePlaybackDualFragment(sb);
                }
            }, 500L);
            this.txtSearchTime.setText(sb.toString());
        }
    }

    public void lambda$initCalenderViewPager$7$CloudFilePlaybackDualFragment(StringBuilder sb) {
        MyCamera myCamera = this.mCamera;
        if (myCamera != null && myCamera.mPlayDualOSS != null) {
            this.mCamera.mPlayDualOSS.GetOSSFileList(sb.toString().replace(Constants.ACCEPT_TIME_SEPARATOR_SERVER, ""), 1, 0);
        }
        this.list_video_online.setVisibility(0);
        this.searchTimeView.setVisibility(0);
        this.tv_nothing.setVisibility(8);
        if (this.list_video_online.getFooterViewsCount() == 0) {
            this.list_video_online.addFooterView(this.loadingView);
        }
    }

    private void setTitleGirdView() {
        if (getActivity() == null) {
            return;
        }
        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(getActivity()));
    }

    private boolean isContainDays(List<Integer> list, int i) {
        Iterator<Integer> it = list.iterator();
        while (it.hasNext()) {
            if (it.next().intValue() == i) {
                return true;
            }
        }
        return false;
    }

    public List<Integer> getDaysByTimeStamp(List<String> list, int i, int i2) {
        ArrayList arrayList = new ArrayList();
        StringBuffer stringBuffer = new StringBuffer();
        stringBuffer.append(i);
        if (i2 < 10) {
            stringBuffer.append(0);
        }
        stringBuffer.append(i2);
        for (String str : list) {
            if (str.startsWith(stringBuffer.toString())) {
                arrayList.add(Integer.valueOf(str.replace(stringBuffer, "")));
            }
        }
        return arrayList;
    }

    private GridView setGirdView() {
        LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(-1, -2);
        GridView gridView = new GridView(getActivity());
        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 setListeners(final List<Integer> list, final Calendar calendar) {
        this.iv_left.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                CloudFilePlaybackDualFragment.this.lambda$setListeners$9$CloudFilePlaybackDualFragment(view);
            }
        });
        this.iv_right.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                CloudFilePlaybackDualFragment.this.lambda$setListeners$10$CloudFilePlaybackDualFragment(view);
            }
        });
        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) {
                calendar.add(2, i - CloudFilePlaybackDualFragment.this.moveCalendarCurrentPage);
                calendar.set(5, 1);
                CloudFilePlaybackDualFragment.this.moveCalendarCurrentPage = i;
                CloudFilePlaybackDualFragment.this.tv_years_month.setText(calendar.get(1) + Constants.ACCEPT_TIME_SEPARATOR_SERVER + (calendar.get(2) + 1));
                list.clear();
                List list2 = list;
                CloudFilePlaybackDualFragment cloudFilePlaybackDualFragment = CloudFilePlaybackDualFragment.this;
                list2.addAll(cloudFilePlaybackDualFragment.getDaysByTimeStamp(cloudFilePlaybackDualFragment.day_list, calendar.get(1), calendar.get(2) + 1));
                EventBus.getDefault().post(new CloudCalenderDay(list, calendar.get(1), calendar.get(2) + 1, CloudFilePlaybackDualFragment.this.moveCalendarCurrentPage, CloudFilePlaybackDualFragment.this.txtSearchTime.getText().toString().replace(Constants.ACCEPT_TIME_SEPARATOR_SERVER, "")));
            }
        });
    }

    public void lambda$setListeners$9$CloudFilePlaybackDualFragment(View view) {
        showPreMonth(this.moveCalendarCurrentPage);
    }

    public void lambda$setListeners$10$CloudFilePlaybackDualFragment(View view) {
        showNextMonth(this.moveCalendarCurrentPage);
    }

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

    private void showNextMonth(int i) {
        this.viewpager.setCurrentItem(i + 1, true);
    }

    @Override
    public void onRequestPermissionsResult(int i, String[] strArr, int[] iArr) {
        super.onRequestPermissionsResult(i, strArr, iArr);
        boolean z = true;
        HiLogcatUtil.e("" + i);
        int length = strArr.length;
        for (int i2 = 0; i2 < length; i2++) {
            HiLogcatUtil.e(strArr.length + Constants.COLON_SEPARATOR + strArr[i2]);
        }
        for (int i3 : iArr) {
            HiLogcatUtil.e(iArr.length + Constants.COLON_SEPARATOR + i3);
        }
        if (i == 10017) {
            int length2 = iArr.length;
            int i4 = 0;
            while (true) {
                if (i4 >= length2) {
                    break;
                }
                if (iArr[i4] != 0) {
                    z = false;
                    break;
                }
                i4++;
            }
            if (z) {
                return;
            }
            HiTools.Hi_GoToSetting(strArr, getActivity(), getActivity());
        }
    }
}