forked from sockeqwe/mosby
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
mvp module support retaining activities with retaining presenters
- Loading branch information
Showing
37 changed files
with
435 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
mvp/src/main/java/com/hannesdorfmann/mosby/mvp/delegate/ActivityMvpDelegateCallback.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* | ||
* Copyright 2015 Hannes Dorfmann. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
|
||
package com.hannesdorfmann.mosby.mvp.delegate; | ||
|
||
import android.support.v4.app.FragmentActivity; | ||
import com.hannesdorfmann.mosby.mvp.MvpPresenter; | ||
import com.hannesdorfmann.mosby.mvp.MvpView; | ||
|
||
/** | ||
* The MvpDelegate callback that will be called from {@link | ||
* ActivityMvpDelegate}. This interface must be implemented by all | ||
* Activities that you want to support mosby's mvp. | ||
* | ||
* @author Hannes Dorfmann | ||
* @see BaseMvpDelegateCallback | ||
* @since 2.0.0 | ||
*/ | ||
public interface ActivityMvpDelegateCallback<V extends MvpView, P extends MvpPresenter<V>> | ||
extends BaseMvpDelegateCallback<V, P> { | ||
|
||
/** | ||
* Return any Object holding the desired state to propagate to the next activity instance. Please | ||
* note that mosby internals like the presenter are already saved internally and you don't have | ||
* to take them into account. You can retrieve this value later with {@link | ||
* ActivityMvpDelegate#getNonMosbyLastCustomNonConfigurationInstance()}. | ||
* | ||
* <p> | ||
* This mechanism works pretty the same way as {@link FragmentActivity#onRetainCustomNonConfigurationInstance()} | ||
* and {@link #getNonMosbyLastCustomNonConfigurationInstance()} | ||
* </p> | ||
* | ||
* @return Object holding state. | ||
*/ | ||
Object onRetainNonMosbyCustomNonConfigurationInstance(); | ||
|
||
/** | ||
* @return Return the value previously returned from {@link FragmentActivity#onRetainCustomNonConfigurationInstance()}. | ||
*/ | ||
Object getLastCustomNonConfigurationInstance(); | ||
|
||
/** | ||
* This method should invoke {@link | ||
* ActivityMvpDelegate#getNonMosbyLastCustomNonConfigurationInstance()}. | ||
* | ||
* <p> | ||
* This method is not really a "callback" method (will not invoked from delegate somehow). | ||
* However, it's part of this interface to ensure that no custom implementation will miss this | ||
* method since this method is the counterpart to {@link #onRetainNonMosbyCustomNonConfigurationInstance()} | ||
* </p> | ||
*/ | ||
Object getNonMosbyLastCustomNonConfigurationInstance(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
...main/java/com/hannesdorfmann/mosby/mvp/delegate/ActivityMvpNonConfigurationInstances.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* Copyright 2015 Hannes Dorfmann. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
|
||
package com.hannesdorfmann.mosby.mvp.delegate; | ||
|
||
import com.hannesdorfmann.mosby.mvp.MvpPresenter; | ||
import com.hannesdorfmann.mosby.mvp.MvpView; | ||
|
||
/** | ||
* This kind of class is used in Activities to save the presenter in retaining activities | ||
* | ||
* @author Hannes Dorfmann | ||
* @since 2.0.0 | ||
*/ | ||
class ActivityMvpNonConfigurationInstances<V extends MvpView, P extends MvpPresenter<V>> { | ||
|
||
/** | ||
* The reference to the presenter | ||
*/ | ||
P presenter; | ||
|
||
/** | ||
* The reference to the custom non configuration. | ||
*/ | ||
Object nonMosbyCustomConfigurationInstance; | ||
|
||
/** | ||
* Constructor | ||
* | ||
* @param presenter The retaining presenter | ||
* @param nonMosbyCustomConfigurationInstance the other custom object | ||
*/ | ||
ActivityMvpNonConfigurationInstances(P presenter, Object nonMosbyCustomConfigurationInstance) { | ||
this.presenter = presenter; | ||
this.nonMosbyCustomConfigurationInstance = nonMosbyCustomConfigurationInstance; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.