Code Monkey home page Code Monkey logo

Comments (6)

raphaelbussa avatar raphaelbussa commented on May 24, 2024 1

I need some complete implementation.

from permissionutils.

raphaelbussa avatar raphaelbussa commented on May 24, 2024

In the sample it works, can you send me the complete implementation so that it can test the same situation?

from permissionutils.

ApofisXII avatar ApofisXII commented on May 24, 2024

Same issue!

from permissionutils.

Johnsonmaung avatar Johnsonmaung commented on May 24, 2024

Same problem in Fragment too...

from permissionutils.

Johnsonmaung avatar Johnsonmaung commented on May 24, 2024

`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.

raphaelbussa avatar raphaelbussa commented on May 24, 2024

Issue not found...

from permissionutils.

Related Issues (14)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.