use of com.iknow.android.features.select.loader.VideoCursorLoader in project Android-Video-Trimmer by iknow4.
the class VideoSelectActivity method initUI.
@SuppressLint("CheckResult")
@Override
public void initUI() {
mVideoLoadManager = new VideoLoadManager();
mVideoLoadManager.setLoader(new VideoCursorLoader());
mBinding = DataBindingUtil.setContentView(this, R.layout.activity_video_select);
mCameraSurfaceViewLy = findViewById(R.id.layout_surface_view);
mBinding.mBtnBack.setOnClickListener(this);
RxPermissions rxPermissions = new RxPermissions(this);
rxPermissions.request(Manifest.permission.READ_EXTERNAL_STORAGE).subscribe(granted -> {
if (granted) {
// Always true pre-M
mVideoLoadManager.load(this, new SimpleCallback() {
@Override
public void success(Object obj) {
if (mVideoSelectAdapter == null) {
mVideoSelectAdapter = new VideoSelectAdapter(VideoSelectActivity.this, (Cursor) obj);
} else {
mVideoSelectAdapter.swapCursor((Cursor) obj);
}
if (mBinding.videoGridview.getAdapter() == null) {
mBinding.videoGridview.setAdapter(mVideoSelectAdapter);
}
mVideoSelectAdapter.notifyDataSetChanged();
}
});
} else {
finish();
}
});
if (rxPermissions.isGranted(Manifest.permission.CAMERA)) {
initCameraPreview();
} else {
mBinding.cameraPreviewLy.setVisibility(View.GONE);
mBinding.openCameraPermissionLy.setVisibility(View.VISIBLE);
mBinding.mOpenCameraPermission.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
rxPermissions.request(Manifest.permission.CAMERA).subscribe(granted -> {
if (granted) {
initCameraPreview();
}
});
}
});
}
}
Aggregations