Comments (4)
Awesome idea!
I would personally prefer a more semantic or granular API, such as
public void someMethod() {
Dexter.forPermissions(Manifest.permission.CAMERA, Manifest.permission.READ_CONTACTS)
.doOnGranted(someListener)
.doOnDenied(errorListener)
.doWhenRationaleShouldBeShown(someListener)
.onSameThread()
.check();
}
It's just my personal and maleable opinion. But the idea of a fluent API is great.
from dexter.
I can see why you'd separate the doWhenRationaleShouldBeShown
callback but I can't think of any use case where you wouldn't handle at least the two basic responses, doOnGranted
and doOnDenied
. Anyways, you can always create a composite listener with a generic onDenied
listener and specific onGranted
implementations, actually, you can do the same with the rationale callback as well.
In this case, I'd rather keep a single interface than splitting it into three for three reasons: it's easier to implement, it's easier to understand (IMHO) and we can move towards simpler interfaces whenever we want keeping it backwards compatible (but not the other way around!).
from dexter.
Yep you're right, it doesn't make much sense implementing only one of the two callbacks. I was thinking more on lambda support. Two methods with one functional interface can use lambdas, but one method with a two method interface can't.
But of course, at the current state of Android, lambda support should not be a priority for an API design :p
Maybe a middle solution would be a RxJava-like listener supporting both forms, one interface with two methods and two interfaces with one method.
Anyway, just that you have thought about it is good enough for me. The real advantage here is the fluent API \o/
from dexter.
@Serchinastico do you have a branch to implement this one? Could be great to publish the 3.0.0 version with my last PR #73 and this one.
from dexter.
Related Issues (20)
- onPermissionDenied is called even when the permission was already granted HOT 2
- MultiPermissionsListener not called when reguest permissions from onPermissionGranted HOT 4
- Check if a permission CHANGED in MultiplePermissionsReport? HOT 1
- Activity re-created after denying permission HOT 3
- Haven't supported Manifest.permission.MANAGE_EXTERNAL_STORAGE yet (Android 11) HOT 3
- Listener not working properly on Configuration Change HOT 8
- Desugring error HOT 4
- I am having trouble with implementing Dexter to get location using google map. Please help me.
- Duplicate Permission in report HOT 5
- Dexter doesn't notify when the app goes in background with permission dialog open and when returning doing tap in the app icon, the permission dialog is close. HOT 1
- OnPermissionDenied called even when permissions are granted on Android 10
- java.lang.IllegalArgumentException ERROR IN device API 23 HOT 1
- ------
- Screen rotation while showing Rationale dialog invalidates PermissionListener HOT 13
- .
- (1). cannot resolve withContext method. (2). cannot resolve permission Symbol HOT 1
- Proguard rules are affecting the whole project HOT 1
- ACTIVITY_RECOGNITION Permission HOT 1
- API 30 Android 11: Requesting background location permission
- Android 11 dismissible permission dialogs HOT 2
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 dexter.