use of com.tbruyelle.rxpermissions3.RxPermissions in project RxMVP by Yumore.
the class ManageFragment method onClick.
@Override
public void onClick(View view) {
RxPermissions permissions = new RxPermissions(getFragment());
if (view.getId() == R.id.btn_package) {
permissions.setLogging(true);
permissions.request(Manifest.permission.READ_PHONE_STATE).subscribe(granted -> {
if (granted) {
startActivity(new Intent(getActivity(), PackageActivity.class));
} else {
Toast.makeText(getActivity(), "没有权限将无法获取单个app的流量信息", Toast.LENGTH_SHORT).show();
}
});
} else if (view.getId() == R.id.btn_antivirus) {
startActivity(new Intent(getActivity(), AntivirusActivity.class));
} else if (view.getId() == R.id.btn_toast) {
startActivity(new Intent(getActivity(), ToastActivity.class));
} else if (view.getId() == R.id.btn_setting) {
Uri packageUri = Uri.parse(String.format("package:%s", BuildConfig.APPLICATION_ID));
Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS, packageUri);
startActivity(intent);
} else if (view.getId() == R.id.btn_setting2) {
gotoRomSettings();
} else if (view.getId() == R.id.kotlin_coroutines) {
startActivity(new Intent(getActivity(), FileActivity.class));
}
}
use of com.tbruyelle.rxpermissions3.RxPermissions 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();
}
});
}
});
}
}
use of com.tbruyelle.rxpermissions3.RxPermissions in project AndroidQuick by ddnosh.
the class PermissionFragment method rxPermissionsCheck.
private void rxPermissionsCheck() {
rxPermissions = new RxPermissions(this);
rxPermissions.request(Manifest.permission.CAMERA).subscribe(granted -> {
if (granted) {
// Always true pre-M
ToastUtil.showToast("授权成功!");
} else {
ToastUtil.showToast("授权失败!");
}
});
}
use of com.tbruyelle.rxpermissions3.RxPermissions in project BigImageViewer by Piasy.
the class LongImageActivity method saveImage.
@SuppressWarnings("MissingPermission")
private void saveImage() {
disposePermissionRequest();
mPermissionRequest = new RxPermissions(this).request(Manifest.permission.WRITE_EXTERNAL_STORAGE).subscribe(new Consumer<Boolean>() {
@Override
public void accept(Boolean granted) throws Exception {
if (granted) {
mBigImageView.saveImageIntoGallery();
}
}
}, new Consumer<Throwable>() {
@Override
public void accept(Throwable throwable) throws Exception {
throwable.printStackTrace();
}
});
}
use of com.tbruyelle.rxpermissions3.RxPermissions in project RxPermissions by tbruyelle.
the class MainActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
RxPermissions rxPermissions = new RxPermissions(this);
rxPermissions.setLogging(true);
setContentView(R.layout.act_main);
surfaceView = (SurfaceView) findViewById(R.id.surfaceView);
RxJavaInterop.toV2Observable(RxView.clicks(findViewById(R.id.enableCamera)).map(new Func1<Void, Object>() {
@Override
public Object call(final Void aVoid) {
return new Object();
}
})).compose(rxPermissions.ensureEach(permission.CAMERA)).subscribe(new Consumer<Permission>() {
@Override
public void accept(Permission permission) {
Log.i(TAG, "Permission result " + permission);
if (permission.granted) {
releaseCamera();
camera = Camera.open(0);
try {
camera.setPreviewDisplay(surfaceView.getHolder());
camera.startPreview();
} catch (IOException e) {
Log.e(TAG, "Error while trying to display the camera preview", e);
}
} else if (permission.shouldShowRequestPermissionRationale) {
// Denied permission without ask never again
Toast.makeText(MainActivity.this, "Denied permission without ask never again", Toast.LENGTH_SHORT).show();
} else {
// Denied permission with ask never again
// Need to go to the settings
Toast.makeText(MainActivity.this, "Permission denied, can't enable the camera", Toast.LENGTH_SHORT).show();
}
}
}, new Consumer<Throwable>() {
@Override
public void accept(Throwable t) {
Log.e(TAG, "onError", t);
}
}, new Action() {
@Override
public void run() {
Log.i(TAG, "OnComplete");
}
});
}
Aggregations