Comments (6)
I need some complete implementation.
from permissionutils.
In the sample it works, can you send me the complete implementation so that it can test the same situation?
from permissionutils.
Same issue!
from permissionutils.
Same problem in Fragment too...
from permissionutils.
`public class FragmentNearby extends BaseFragment
implements NearbyMVPView, FullCallback, OnMapReadyCallback {
/*
0 - Retry
1 - No Data
*/ int error_type = 0;
//@Bind(R.id.map) GoogleMap googleMap;
@Bind(R.id.llContent) LinearLayout llContent;
@Bind(R.id.progress) ProgressBar progressBar;
@Bind(R.id.linearMessage) LinearLayout linearMessage;
@Bind(R.id.imgMessage) ImageView imgMessage;
@Bind(R.id.tvMessage) TextView tvMessage;
@Bind(R.id.btnMessage) Button btnMessage;
View rootView;
GoogleMap googleMap;
NearByPresenter presenter;
public static FragmentNearby newInstance() {
FragmentNearby fragment = new FragmentNearby();
return fragment;
}
@OverRide public Context getContext() {
return getActivity();
}
@OverRide public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
presenter = new NearByPresenter();
presenter.attachView(this);
}
@OverRide public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
//Recycle for map Fragment
if (rootView != null) {
ViewGroup parent = (ViewGroup) rootView.getParent();
if (parent != null) parent.removeView(rootView);
}
try {
rootView = inflater.inflate(R.layout.fragment_nearby, container, false);
ButterKnife.bind(this, rootView);
SupportMapFragment mapFragment =
(SupportMapFragment) getChildFragmentManager().findFragmentById(map);
mapFragment.getMapAsync(this);
} catch (InflateException e) {
/* map is already there, just return view as it is */
}
return rootView;
}
@OverRide public void onDestroy() {
presenter.detachView();
super.onDestroy();
}
@OverRide public void onDestroyView() {
super.onDestroyView();
ButterKnife.unbind(this);
}
@OverRide public void onMapReady(GoogleMap googleMap) {
this.googleMap = googleMap;
presenter.getNearByLocation();
}
@OnClick(R.id.btnMessage) void ActionClick() {
if (error_type == 0) {
PermissionManager.with(getActivity())
.key(9001)
.permission(PermissionEnum.ACCESS_FINE_LOCATION)
.askAgain(false)
.askAgainCallback(new AskAgainCallback() {
@OverRide public void showRequestPermission(UserResponse response) {
showDialog(response);
}
})
.callback(this)
.ask();
} else if (error_type == 1) {
//go to home
presenter.getNearByLocation();
}
}
@OverRide public void showMessage(int message) {
error_type = message;
if (message == 0) {
tvMessage.setText("Need permission!");
btnMessage.setText("Grant");
} else if (message == 1) {
tvMessage.setText("No product in cart.");
btnMessage.setText("Go Shopping");
}
llContent.setVisibility(View.GONE);
progressBar.setVisibility(View.GONE);
linearMessage.setVisibility(View.VISIBLE);
}
@OverRide public void showProgress() {
llContent.setVisibility(View.GONE);
progressBar.setVisibility(View.VISIBLE);
linearMessage.setVisibility(View.GONE);
}
@OverRide public void showContent() {
try {
//GeoJsonLayer layer = new GeoJsonLayer(googleMap, new JSONObject(geo));
GeoJsonLayer layer = new GeoJsonLayer(googleMap, R.raw.geo, getActivity());
layer.addLayerToMap();
/LatLng yangon = new LatLng(16.8661, 96.1951);
googleMap.moveCamera(CameraUpdateFactory.newLatLng(yangon));/
//CameraPosition cameraPosition = new CameraPosition.Builder().target(yangon).zoom(14).build();
//googleMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
/LatLngBounds bound =
new LatLngBounds(new LatLng(96.135751, 16.778411), new LatLng(96.172158, 16.769463));/
//googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(layer.getBoundingBox().getCenter(), 12));
googleMap.moveCamera(CameraUpdateFactory.newLatLngBounds(layer.getBoundingBox(), 0));
layer.setOnFeatureClickListener(new GeoJsonLayer.GeoJsonOnFeatureClickListener() {
@OverRide public void onFeatureClick(GeoJsonFeature feature) {
Toast.makeText(getActivity(), "Feature clicked: " + feature.getProperty("name"),
Toast.LENGTH_SHORT).show();
}
});
//layer.clearLayer();
} catch (IOException e) {
e.printStackTrace();
} catch (JSONException e) {
e.printStackTrace();
}
llContent.setVisibility(View.VISIBLE);
progressBar.setVisibility(View.GONE);
linearMessage.setVisibility(View.GONE);
}
@OverRide public void result(ArrayList permissionsGranted,
ArrayList permissionsDenied,
ArrayList permissionsDeniedForever,
ArrayList permissionsAsked) {
LogUtils.e("Hey!");
for (PermissionEnum permissionEnum : permissionsGranted) {
if (permissionEnum.equals(PermissionEnum.ACCESS_FINE_LOCATION)) {
LogUtils.e("granted!");
}
}
for (PermissionEnum permissionEnum : permissionsDenied) {
if (permissionEnum.equals(PermissionEnum.ACCESS_FINE_LOCATION)) {
LogUtils.e("denied!");
}
}
for (PermissionEnum permissionEnum : permissionsDeniedForever) {
if (permissionEnum.equals(PermissionEnum.ACCESS_FINE_LOCATION)) {
LogUtils.e("denied for ever!");
}
}
for (PermissionEnum permissionEnum : permissionsAsked) {
if (permissionEnum.equals(PermissionEnum.ACCESS_FINE_LOCATION)) {
LogUtils.e("asked!");
}
}
}
@OverRide public void onRequestPermissionsResult(int requestCode, @nonnull String[] permissions,
@nonnull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
PermissionManager.handleResult(requestCode, permissions, grantResults);
}
private void showDialog(final AskAgainCallback.UserResponse response) {
new AlertDialog.Builder(getActivity()).setTitle("Permission needed")
.setMessage("This app realy need to use this permission, you wont to authorize it?")
.setPositiveButton("OK", new DialogInterface.OnClickListener() {
@OverRide public void onClick(DialogInterface dialogInterface, int i) {
response.result(true);
}
})
.setNegativeButton("NOT NOW", new DialogInterface.OnClickListener() {
@OverRide public void onClick(DialogInterface dialogInterface, int i) {
response.result(false);
}
})
.setCancelable(false)
.show();
}
}
``
from permissionutils.
Issue not found...
from permissionutils.
Related Issues (14)
- Support library 26.0.2 HOT 2
- Can reqeust only one set of permissions at a time
- permissionGranted is always false if deniedForever and then enabled from settings
- Dialog for permission not shown HOT 5
- When fragment deny permissions automatic finish current fragment
- PermissionUtls.isGranted() is not correct when you forbid permission in system settings HOT 1
- Read me error
- Missing Permissions in Enum List HOT 1
- fragment? HOT 5
- can init the request using Fragment(in support library) HOT 3
- direct call to result() when starting from GooglePlay (just after install) HOT 1
- How to Proceed HOT 2
- Leak in PermissionManager instance HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from permissionutils.