https://github.com/florent37/androidmvpresenter
https://github.com/florent37/androidmvpresenter
Last synced: 8 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/florent37/androidmvpresenter
- Owner: florent37
- License: apache-2.0
- Created: 2017-10-09T12:21:46.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-01-07T14:18:38.000Z (about 8 years ago)
- Last Synced: 2025-05-12T22:55:13.814Z (8 months ago)
- Language: Java
- Size: 140 KB
- Stars: 6
- Watchers: 2
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# AndroidMVPresenter
# Download
[  ](https://bintray.com/florent37/maven/androidmvpresenter/_latestVersion)
```java
dependencies {
compile 'com.github.florent37:androidmvpresenter:1.0.1'
}
```
# Presenter
```java
public class MainPresenter extends AbstractPresenter {
private final AuthRepo authRepo;
public MainPresenter(final AuthRepo authRepo) {
super();
this.authRepo = authRepo;
super.setupRetry(
3,
new Function>() {
@Override
public Observable> apply(Throwable throwable) throws Exception {
if(throwable instanceof AuthentificationException && ((AuthentificationException) throwable).statusCode == 401){
return authRepo.authentificate().toObservable();
} else if(throwable instanceof IOException) {
return Observable.timer(3, TimeUnit.SECONDS); //wait 3 seconds before continue
}
return Observable.error(throwable);
}
});
}
@Override
protected void start() {
onView(new AbstractPresenter.ViewCallback() {
@Override
public void onView(View view) {
view.sayHello();
}
});
}
//example of Auth Error
private class AuthentificationException extends Throwable {
private int statusCode;
}
public interface View extends AbstractPresenter.View {
void sayHello();
}
}
```