An open API service indexing awesome lists of open source software.

https://github.com/florent37/androidmvpresenter


https://github.com/florent37/androidmvpresenter

Last synced: 8 months ago
JSON representation

Awesome Lists containing this project

README

          

# AndroidMVPresenter


Android app on Google Play

# Download

Buy Me a Coffee at ko-fi.com

[ ![Download](https://api.bintray.com/packages/florent37/maven/androidmvpresenter/images/download.svg) ](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();
}
}
```