Created
October 28, 2015 10:49
-
-
Save BukT0p/572e431288b698f25de0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.test.ui; | |
import android.Manifest; | |
import android.support.v4.app.Fragment; | |
import android.widget.Toast; | |
import com.test.R; | |
import org.androidannotations.annotations.Click; | |
import org.androidannotations.annotations.EFragment; | |
import permissions.dispatcher.DeniedPermission; | |
import permissions.dispatcher.NeedsPermission; | |
import permissions.dispatcher.RuntimePermissions; | |
import permissions.dispatcher.ShowsRationale; | |
@RuntimePermissions | |
@EFragment(R.layout.test_layout) | |
public class TestFragment extends Fragment { | |
private boolean storagePermissionGranted; | |
@Click(R.id.test_button) | |
void buttonClicked() { | |
checkStoragePermission(); | |
if (storagePermissionGranted) | |
Toast.makeText(getContext(), "Granted", Toast.LENGTH_LONG).show(); | |
} | |
@NeedsPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) | |
void checkStoragePermission() { | |
storagePermissionGranted = true; | |
} | |
// Option | |
@ShowsRationale(Manifest.permission.WRITE_EXTERNAL_STORAGE) | |
void showRationaleForStorage() { | |
Toast.makeText(getContext(), "Some Rationale", Toast.LENGTH_SHORT).show(); | |
} | |
// Option | |
@DeniedPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) | |
void showDeniedForStorage() { | |
Toast.makeText(getContext(), "Denied", Toast.LENGTH_LONG).show(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment