Skip to content

Commit

Permalink
Merge branch 'release/1.4.5'
Browse files Browse the repository at this point in the history
  • Loading branch information
senneco committed Jan 16, 2017
2 parents 11ba2f0 + 026e425 commit 090bdcd
Show file tree
Hide file tree
Showing 39 changed files with 650 additions and 632 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,36 +76,36 @@ Base modules integration:
```groovy
dependencies {
...
compile 'com.arello-mobile:moxy:1.4.4'
provided 'com.arello-mobile:moxy-compiler:1.4.4'
compile 'com.arello-mobile:moxy:1.4.5'
provided 'com.arello-mobile:moxy-compiler:1.4.5'
}
```
If you want to see generated code, use `apt` instead of `provided` dependency type:
```groovy
dependencies {
...
apt 'com.arello-mobile:moxy-compiler:1.4.4'
apt 'com.arello-mobile:moxy-compiler:1.4.5'
}
```
Note: if you use gradle plugin verion 2.2.2 and above, so you can use `annotationProcessor` instead of `apt`:
```groovy
dependencies {
...
annotationProcessor 'com.arello-mobile:moxy-compiler:1.4.4'
annotationProcessor 'com.arello-mobile:moxy-compiler:1.4.5'
}
```
For additional base view classes `MvpActivity` and `MvpFragment` add this:
```groovy
dependencies {
...
compile 'com.arello-mobile:moxy-android:1.4.4'
compile 'com.arello-mobile:moxy-android:1.4.5'
}
```
If you are planing to use AppCompat, then you can use `MvpAppCompatActivity` and `MvpAppCompatFragment`. Then add this:
```groovy
dependencies {
...
compile 'com.arello-mobile:moxy-app-compat:1.4.4'
compile 'com.arello-mobile:moxy-app-compat:1.4.5'
compile 'com.android.support:appcompat-v7:$support_version'
}
```
Expand All @@ -114,7 +114,7 @@ If you are using kotlin, use `kapt` instead of `provided`/`apt` dependency type
```groovy
dependencies {
...
kapt 'com.arello-mobile:moxy-compiler:1.4.4'
kapt 'com.arello-mobile:moxy-compiler:1.4.5'
}
kapt {
generateStubs = true
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ allprojects {
}

ext {
targetVersionCode = 37
targetVersionName = "1.4.4"
targetVersionCode = 38
targetVersionName = "1.4.5"
}

task clean(type: Delete) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ protected void onCreate(Bundle savedInstanceState) {
getMvpDelegate().onCreate(savedInstanceState);
}

@Override
protected void onStart() {
super.onStart();

getMvpDelegate().onAttach();
}

@Override
protected void onResume() {
super.onResume();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@ public void onCreate(Bundle savedInstanceState) {
getMvpDelegate().onCreate(savedInstanceState);
}

@Override
public void onStart() {
super.onStart();

mIsStateSaved = false;

getMvpDelegate().onAttach();
}

public void onResume() {
super.onResume();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ public void onCreate(Bundle savedInstanceState) {
throw new RuntimeException("Stub!");
}

public void onStart() {
throw new RuntimeException("Stub!");
}

public void onResume() {
throw new RuntimeException("Stub!");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ protected void onCreate(Bundle savedInstanceState) {
getMvpDelegate().onCreate(savedInstanceState);
}

@Override
protected void onStart() {
super.onStart();

getMvpDelegate().onAttach();
}

@Override
protected void onResume() {
super.onResume();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@ public void onCreate(Bundle savedInstanceState) {
getMvpDelegate().onCreate(savedInstanceState);
}

@Override
public void onStart() {
super.onStart();

mIsStateSaved = false;

getMvpDelegate().onAttach();
}

public void onResume() {
super.onResume();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ public void onCreate(Bundle savedInstanceState) {
throw new RuntimeException("Stub!");
}

public void onStart() {
throw new RuntimeException("Stub!");
}

public void onResume() {
throw new RuntimeException("Stub!");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ protected void onCreate(Bundle savedInstanceState) {
throw new RuntimeException("Stub!");
}

protected void onStart() {
throw new RuntimeException("Stub!");
}

protected void onResume() {
throw new RuntimeException("Stub!");
}
Expand Down
4 changes: 4 additions & 0 deletions moxy/src/main/java/com/arellomobile/mvp/MvpDelegate.java
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@ public void onAttach() {
*/
public void onDetach() {
for (MvpPresenter<? super Delegated> presenter : mPresenters) {
if (!mIsAttached && !presenter.getAttachedViews().contains(mDelegated)) {
continue;
}

presenter.detachView(mDelegated);
}

Expand Down
6 changes: 3 additions & 3 deletions sample-github/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ dependencies {
testCompile "org.hamcrest:hamcrest-all:1.3"
testCompile "org.robolectric:robolectric:3.1-rc1"

compile 'com.arello-mobile:moxy:1.4.4'
compile 'com.arello-mobile:moxy-app-compat:1.4.4'
annotationProcessor 'com.arello-mobile:moxy-compiler:1.4.4'
compile 'com.arello-mobile:moxy:1.4.5'
compile 'com.arello-mobile:moxy-app-compat:1.4.5'
annotationProcessor 'com.arello-mobile:moxy-compiler:1.4.5'
}
4 changes: 2 additions & 2 deletions sample-github/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest package="com.arellomobile.mvp.sample.github"
xmlns:android="http://schemas.android.com/apk/res/android">
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.arellomobile.mvp.sample.github">

<uses-permission android:name="android.permission.INTERNET" />

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.arellomobile.mvp.sample.github.common;

import rx.Observable;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

/**
* Date: 11.01.2017
* Time: 16:39
*
* @author Yuri Shmakov
*/

public class Utils {
public static <T> Observable.Transformer<T, T> applySchedulers() {
return observable -> observable.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ public class HomePresenter extends MvpPresenter<HomeView> {
public void onRepositorySelection(int position, Repository repository) {
getViewState().showDetailsContainer();

getViewState().setSelection(position);

getViewState().showDetails(position, repository);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@

import java.util.List;

import com.arellomobile.mvp.InjectViewState;
import com.arellomobile.mvp.sample.github.app.GithubApi;
import com.arellomobile.mvp.sample.github.app.GithubApp;
import com.arellomobile.mvp.sample.github.common.Utils;
import com.arellomobile.mvp.sample.github.mvp.GithubService;
import com.arellomobile.mvp.sample.github.mvp.models.Repository;
import com.arellomobile.mvp.sample.github.mvp.views.RepositoriesView;
import com.arellomobile.mvp.InjectViewState;

import javax.inject.Inject;

import rx.Observable;
import rx.Subscription;
import rx.android.schedulers.AndroidSchedulers;

/**
* Date: 22.01.2016
Expand Down Expand Up @@ -54,14 +54,14 @@ private void loadData(int page, boolean isPageLoading, boolean isRefreshing) {
}
mIsInLoading = true;

getViewState().hideError();
getViewState().onStartLoading();

showProgress(isPageLoading, isRefreshing);

final Observable<List<Repository>> observable = mGithubService.getUserRepos("JakeWharton", page, GithubApi.PAGE_SIZE);

Subscription subscription = observable.observeOn(AndroidSchedulers.mainThread())
Subscription subscription = observable
.compose(Utils.applySchedulers())
.subscribe(repositories -> {
onLoadingFinish(isPageLoading, isRefreshing);
onLoadingSuccess(isPageLoading, repositories);
Expand Down Expand Up @@ -117,7 +117,7 @@ private void hideProgress(boolean isPageLoading, boolean isRefreshing) {
}
}

public void closeError() {
public void onErrorCancel() {
getViewState().hideError();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,8 @@
import java.util.List;
import java.util.concurrent.TimeUnit;

import com.arellomobile.mvp.sample.github.app.GithubApp;
import com.arellomobile.mvp.sample.github.mvp.views.RepositoryLikesView;
import com.arellomobile.mvp.InjectViewState;
import com.squareup.otto.Bus;

import javax.inject.Inject;
import com.arellomobile.mvp.sample.github.mvp.views.RepositoryLikesView;

import rx.Observable;
import rx.Subscription;
Expand All @@ -26,18 +22,9 @@
public class RepositoryLikesPresenter extends BasePresenter<RepositoryLikesView> {
public static final String TAG = "RepositoryLikesPresenter";

@Inject
Bus mBus;

private List<Integer> mInProgress = new ArrayList<>();
private List<Integer> mLikedIds = new ArrayList<>();

public RepositoryLikesPresenter() {
GithubApp.getAppComponent().inject(this);

mBus.register(this);
}

public void toggleLike(int id) {
if (mInProgress.contains(id)) {
return;
Expand Down Expand Up @@ -91,10 +78,4 @@ private void onFail(int id) {
mInProgress.remove(Integer.valueOf(id));
getViewState().updateLikes(mInProgress, mLikedIds);
}

@Override
public void onDestroy() {
super.onDestroy();
mBus.unregister(this);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,22 @@
*/
@InjectViewState
public class RepositoryPresenter extends MvpPresenter<RepositoryView> {
private boolean mIsInitialized = false;

private Repository mRepository;
private List<Integer> mInProgress;
private List<Integer> mLikedIds;

public RepositoryPresenter() {
public RepositoryPresenter(Repository repository) {
super();
}

public void setRepository(Repository repository) {
if (mIsInitialized) {
return;
}
mIsInitialized = true;

mRepository = repository;
}

@Override
protected void onFirstViewAttach() {
super.onFirstViewAttach();

getViewState().showRepository(repository);
getViewState().showRepository(mRepository);

updateLikes(mInProgress, mLikedIds);
}
Expand Down
Loading

0 comments on commit 090bdcd

Please sign in to comment.