Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @TargetApi(23)
- public boolean checkLocationPermission() {
- boolean granted = false;
- if (getContext().checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
- requestPermissions(new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, REQUEST_CODE_LOCATION);
- Toast.makeText(getContext(), R.string.check_permission_location_information, Toast.LENGTH_SHORT).show();
- if (getContext().checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
- granted = true;
- }
- } else {
- granted = true;
- }
- return granted;
- }
- @OnClick(R.id.btn_refresh_events)
- public void onRefreshClick() {
- boolean isPermissionGranted = checkLocationPermission();
- if (isPermissionGranted) {
- refreshingEvents.setVisibility(View.GONE);
- mPresenter.refresh();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement