This repository has been archived by the owner on Mar 1, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Created TriadActionBarActivity, using TriadManager
- Loading branch information
Showing
12 changed files
with
301 additions
and
87 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,11 @@ | ||
isRelease = false | ||
isRelease = false | ||
|
||
group=com.nhaarman | ||
|
||
POM_DESCRIPTION=A Model-View-Presenter library for Android | ||
POM_URL=https://github.com/nhaarman/Triad | ||
POM_SCM_URL=https://github.com/nhaarman/Triad | ||
POM_SCM_CONNECTION=scm:git@github.com:nhaarman/Triad.git | ||
POM_SCM_DEV_CONNECTION=scm:git@github.com:nhaarman/Triad.git | ||
POM_DEVELOPER_ID=nhaarman | ||
POM_DEVELOPER_NAME=Niek Haarman |
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
include ':triad' | ||
include ':triad-appcompat-v7' | ||
include ':triad-tests' | ||
|
||
include ':triad-sample:business' | ||
|
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,28 @@ | ||
apply plugin: 'com.android.library' | ||
|
||
android { | ||
testOptions { | ||
unitTests.returnDefaultValues = true | ||
} | ||
} | ||
|
||
|
||
apply from: rootProject.projectDir.absolutePath + '/gradle/compile.gradle'; | ||
apply from: rootProject.projectDir.absolutePath + '/gradle/publishing.gradle' | ||
apply from: rootProject.projectDir.absolutePath + '/gradle/bintray.gradle' | ||
apply from: rootProject.projectDir.absolutePath + '/gradle/artifactory.gradle' | ||
|
||
dependencies { | ||
compile project(':triad') | ||
|
||
/* AppCompat v7 */ | ||
compile 'com.android.support:appcompat-v7:22.0.0' | ||
|
||
/* Annotations library */ | ||
provided 'org.jetbrains:annotations:13.0' | ||
|
||
/* Tests */ | ||
testCompile 'junit:junit:4.12' | ||
testCompile 'org.hamcrest:hamcrest-core:1.3' | ||
testCompile 'org.mockito:mockito-core:1.9.5' | ||
} |
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,3 @@ | ||
POM_NAME=Triad AppCompat v7 | ||
POM_ARTIFACT_ID=triad-appcompat-v7 | ||
POM_PACKAGING=aar |
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,6 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest package="com.nhaarman.triad_appcompat_v7"> | ||
|
||
<application /> | ||
|
||
</manifest> |
80 changes: 80 additions & 0 deletions
80
triad-appcompat-v7/src/main/java/com/nhaarman/triad/TriadActionBarActivity.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,80 @@ | ||
package com.nhaarman.triad; | ||
|
||
import android.app.Activity; | ||
import android.os.Bundle; | ||
import android.support.v7.app.ActionBarActivity; | ||
import com.nhaarman.triad.presenter.Presenter; | ||
import com.nhaarman.triad.screen.Screen; | ||
import flow.Flow; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
/** | ||
* An {@link Activity} which is the root of an application that uses Triad. | ||
* | ||
* @param <M> The {@code main component} to use for {@link Presenter} creation. | ||
*/ | ||
public abstract class TriadActionBarActivity<M> extends ActionBarActivity { | ||
|
||
@NotNull | ||
private final TriadManager<M> mTriadManager; | ||
|
||
public TriadActionBarActivity() { | ||
mTriadManager = new TriadManager<>(this); | ||
} | ||
|
||
@Override | ||
protected void onCreate(final Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
|
||
mTriadManager.onCreate(createInitialScreen(), createMainComponent()); | ||
} | ||
|
||
/** | ||
* Creates the main component which is used to retrieve dependencies from that are needed to create {@link Presenter}s. | ||
* | ||
* @return The created main component. | ||
*/ | ||
@NotNull | ||
protected abstract M createMainComponent(); | ||
|
||
/** | ||
* Creates the {@link Screen} that is to be shown when the application starts. | ||
* | ||
* @return The created {@link Screen}. | ||
*/ | ||
@NotNull | ||
protected abstract Screen<?, ?, M> createInitialScreen(); | ||
|
||
@Override | ||
protected void onStart() { | ||
super.onStart(); | ||
mTriadManager.onStart(); | ||
} | ||
|
||
@Override | ||
protected void onPostCreate(final Bundle savedInstanceState) { | ||
super.onPostCreate(savedInstanceState); | ||
mTriadManager.onPostCreate(); | ||
} | ||
|
||
@Override | ||
protected void onStop() { | ||
super.onStop(); | ||
mTriadManager.onStop(); | ||
} | ||
|
||
@Override | ||
public void onBackPressed() { | ||
if (!mTriadManager.onBackPressed()) { | ||
super.onBackPressed(); | ||
} | ||
} | ||
|
||
/** | ||
* Returns the {@link Flow} instance to be used to navigate between {@link Screen}s. | ||
*/ | ||
@NotNull | ||
protected Flow getFlow() { | ||
return mTriadManager.getFlow(); | ||
} | ||
} |
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.