本文整理汇总了Java中pl.tajchert.nammu.PermissionCallback类的典型用法代码示例。如果您正苦于以下问题:Java PermissionCallback类的具体用法?Java PermissionCallback怎么用?Java PermissionCallback使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PermissionCallback类属于pl.tajchert.nammu包,在下文中一共展示了PermissionCallback类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: showChooserDialog
import pl.tajchert.nammu.PermissionCallback; //导入依赖的package包/类
public static void showChooserDialog(final BaseActivity activity, final Callback callback) {
PhotoHelper.callback = callback;
Nammu.askForPermission(activity, Manifest.permission.WRITE_EXTERNAL_STORAGE, new PermissionCallback() {
@Override
public void permissionGranted() {
Intent intent = CropImage.getPickImageChooserIntent(activity);
activity.startActivityForResult(intent, CropImage.PICK_IMAGE_CHOOSER_REQUEST_CODE);
}
@Override
public void permissionRefused() {
callOnFailure(Failure.PERMISSION_DENIED);
}
});
}
示例2: selectImage
import pl.tajchert.nammu.PermissionCallback; //导入依赖的package包/类
@DebugLog
@OnClick(R.id.backdrop)
void selectImage() {
int permissionCheck = ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE);
if (permissionCheck != PackageManager.PERMISSION_GRANTED) {
Nammu.askForPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE, new PermissionCallback() {
@DebugLog
@Override
public void permissionGranted() {
EasyImage.openGallery(NameActivity.this, 0);
//Nothing, this sample saves to Public gallery so it needs permission
}
@DebugLog
@Override
public void permissionRefused() {
// finish();
}
});
}
else {
EasyImage.openGallery(NameActivity.this, 0);
}
}
示例3: askPermission
import pl.tajchert.nammu.PermissionCallback; //导入依赖的package包/类
private void askPermission(String permissionName) {
if (!Nammu.checkPermission(permissionName)) {
if (Nammu.shouldShowRequestPermissionRationale(this, permissionName)) {
Toast.makeText(this, R.string.permission_tips, Toast.LENGTH_SHORT).show();
Nammu.askForPermission(MainActivity.this, permissionName, new PermissionCallback() {
@Override
public void permissionGranted() { }
@Override
public void permissionRefused() { }
});
} else {
Nammu.askForPermission(MainActivity.this, permissionName, new PermissionCallback() {
@Override
public void permissionGranted() { }
@Override
public void permissionRefused() { }
});
}
}
}
示例4: callNumber
import pl.tajchert.nammu.PermissionCallback; //导入依赖的package包/类
public static void callNumber(final Activity activity, String telNumber) {
String number = "tel:" + telNumber;
final Intent callIntent = new Intent(Intent.ACTION_CALL, Uri.parse(number));
PermissionHelper.verifyPermissions(
new String[]{Manifest.permission.CALL_PHONE},
new PermissionCallback() {
@Override
public void permissionGranted() {
activity.startActivity(callIntent);
}
@Override
public void permissionRefused() {
}
});
}
示例5: clickButtChangeSettings
import pl.tajchert.nammu.PermissionCallback; //导入依赖的package包/类
@OnClick(R.id.buttonSpecialChangeSettings) public void clickButtChangeSettings() {
if (Nammu.checkSpecialPermission(Manifest.permission.WRITE_SETTINGS)) {
Toast.makeText(this, "Access granted", Toast.LENGTH_SHORT).show();
} else {
Nammu.askForSpecialPermission(this, Manifest.permission.WRITE_SETTINGS,
new PermissionCallback() {
@Override public void permissionGranted() {
Toast.makeText(MainActivity.this, "Access granted", Toast.LENGTH_SHORT).show();
}
@Override public void permissionRefused() {
Log.d(TAG, "permissionRefused: ");
Toast.makeText(MainActivity.this, "Access refused", Toast.LENGTH_SHORT).show();
}
});
}
}
示例6: setLocationEnabled
import pl.tajchert.nammu.PermissionCallback; //导入依赖的package包/类
public static void setLocationEnabled(final Activity activity, final GoogleMap map) {
if (activity == null || map == null) {
return;
}
if (!setLocationIfPossible(activity, map)) {
Nammu.askForPermission(activity, LOCATION_PERMISSION, new PermissionCallback() {
@Override
public void permissionGranted() {
setLocationEnabled(activity, map);
}
@Override
public void permissionRefused() {
// Can't do anything here
}
});
}
}
示例7: loadHero
import pl.tajchert.nammu.PermissionCallback; //导入依赖的package包/类
public final void loadHero(final HeroFileInfo heroPath) {
Nammu.askForPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE, new PermissionCallback() {
@Override
public void permissionGranted() {
if (getHero() != null && preferences.getBoolean(DsaTabPreferenceActivity.KEY_AUTO_SAVE, true)) {
HeroSaveTask heroSaveTask = new HeroSaveTask(DsaTabActivity.this, getHero(),HeroExchange.getInstance());
heroSaveTask.execute();
}
setToolbarRefreshing(true);
Bundle args = new Bundle();
args.putSerializable(KEY_HERO_PATH, heroPath);
getLoaderManager().restartLoader(LOADER_HERO, args, new HeroLoaderCallback(DsaTabActivity.this));
}
@Override
public void permissionRefused() {
ViewUtils.snackbar(DsaTabActivity.this, "Keine Berechtigung um Helden auf SD-Karte zu speichern.");
}
});
}
示例8: verifyPermissions
import pl.tajchert.nammu.PermissionCallback; //导入依赖的package包/类
public static void verifyPermissions(String[] requiredPermissions, PermissionCallback permissionCallback){
for(String requiredPermission : requiredPermissions){
if(!Nammu.checkPermission(requiredPermission)){
permissionCallback.permissionRefused();
return;
}
}
permissionCallback.permissionGranted();
}
示例9: onCreate
import pl.tajchert.nammu.PermissionCallback; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
permissionHelper = PermissionHelper.getInstance(this);
Button requirePermissionButton = (Button) findViewById(R.id.require_permission_button);
TextView textView = (TextView) findViewById(R.id.text_view);
requirePermissionButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
permissionHelper.verifyPermission(new String[]{"dial this number"},
new String[]{Manifest.permission.CALL_PHONE}, new PermissionCallback() {
@Override
public void permissionGranted() {
Helpers.callNumber(MainActivity.this, "1234");
}
@Override
public void permissionRefused() {
}
});
}
});
}
示例10: pickPicture
import pl.tajchert.nammu.PermissionCallback; //导入依赖的package包/类
@OnClick(R.id.fab)
public void pickPicture(){
if(Util.isConnected(getContext(), true)) {
Util.askForPermissions(getActivity(), new PermissionCallback() {
@Override
public void permissionGranted() {
EasyImage.openChooserWithGallery(TranslateFragment.this, getString(R.string.select_an_image), REQUEST_PICK_PICTURE);
}
@Override
public void permissionRefused() {
}
});
}
}
示例11: askForPermissions
import pl.tajchert.nammu.PermissionCallback; //导入依赖的package包/类
public static void askForPermissions(final Activity activity, PermissionCallback callback){
List<String> missingPermissions = new ArrayList<>();
for(int i = 0; i < PERMISSIONS.length; i++){
if(!Nammu.checkPermission(PERMISSIONS[i])){
missingPermissions.add(PERMISSIONS[i]);
}
}
if(missingPermissions.isEmpty()){
callback.permissionGranted();
} else {
Nammu.askForPermission(activity, missingPermissions.toArray(new String[missingPermissions.size()]), callback);
}
}
示例12: refresh
import pl.tajchert.nammu.PermissionCallback; //导入依赖的package包/类
protected void refresh() {
if (getActivity()!=null) {
Nammu.askForPermission(getActivity(), Manifest.permission.WRITE_EXTERNAL_STORAGE, new PermissionCallback() {
@Override
public void permissionGranted() {
refresh(REMOTE_LOADER);
}
@Override
public void permissionRefused() {
ViewUtils.snackbar(getActivity(), "Keine Berechtigung um Helden auf SD-Karte zu speichern.");
}
});
}
}
示例13: setPermissionCallback
import pl.tajchert.nammu.PermissionCallback; //导入依赖的package包/类
protected void setPermissionCallback(PermissionCallback permissionCallback){
this.permissionCallback = permissionCallback;
}