Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
Konstantin Tskhovrebov committed Sep 27, 2018
2 parents 98b1ff2 + de961bc commit 301f3f3
Show file tree
Hide file tree
Showing 63 changed files with 1,063 additions and 1,750 deletions.
67 changes: 22 additions & 45 deletions README.md
Expand Up @@ -22,8 +22,11 @@ It was designed to be used with the MVP pattern (try [Moxy](https://github.com/A
+ suitable for Unit Testing

## Additional features
+ easy screen result subscription
+ opening several screens inside single call (for example: deeplink)
+ implementation of parallel navigation (Instagram like)
+ predefined navigator ready for Single-Activity apps
+ predefined navigator ready for setup transition animation

**See the sample application**

## How to add
Expand Down Expand Up @@ -64,7 +67,7 @@ public class SampleApplication extends MvpApplication {
```

## How it works?
![](https://habrastorage.org/files/4df/45d/973/4df45d9733fc4ee0a2f0be933de475b1.png)
<img src="https://github.com/terrakok/Cicerone/raw/develop/media/CiceroneDiagram.png" alt="drawing" width="800"/>

Presenter calls navigation method of Router.

Expand All @@ -81,14 +84,14 @@ public class SamplePresenter extends Presenter<SampleView> {
}

public void onForwardCommandClick() {
router.navigateTo("Some screen");
router.navigateTo(new SomeScreen());
}
}
```

Router converts the navigation call to the set of Commands and sends them to CommandBuffer.
Router converts the navigation call to the set of Commands and sends them to CommandBuffer.

CommandBuffer checks whether there are _"active"_ Navigator:
CommandBuffer checks whether there are _"active"_ Navigator:
- If yes, it passes the commands to the Navigator. Navigator will process them to achive the desired transition.
- If no, then CommandBuffer saves the commands in a queue, and will apply them as soon as new _"active"_ Navigator will appear.

Expand Down Expand Up @@ -122,62 +125,36 @@ protected void onPause() {

private Navigator navigator = new Navigator() {
@Override
public void applyCommand(Command command) {
//implement commands logic
public void applyCommands(Command[] commands) {
//implement commands logic (apply command batch to navigation container)
}
};
```

## Navigation commands
This commands set will fulfill the needs of the most applications. But if you need something special - just add it!
+ Forward - Opens new screen
![](https://habrastorage.org/files/862/77e/b20/86277eb20b574dae8307ac4f64b0f090.png)
![](https://github.com/terrakok/Cicerone/raw/develop/media/forward_img.png)
+ Back - Rolls back the last transition
![](https://habrastorage.org/files/059/b63/2d3/059b632d3a7c4515a534b9e5e881c8f0.png)
![](https://github.com/terrakok/Cicerone/raw/develop/media/back_img.png)
+ BackTo - Rolls back to the needed screen in the screens chain
![](https://habrastorage.org/files/a45/4f4/c34/a454f4c340764632ad0669014ad5550d.png)
![](https://github.com/terrakok/Cicerone/raw/develop/media/backTo_img.png)
+ Replace - Replaces the current screen
![](https://habrastorage.org/files/4ae/95c/fee/4ae95cfee4c04f038ad17d358ab08d07.png)
+ SystemMessage - Shows system message (Alert, Toast, Snack, etc.)
![](https://habrastorage.org/files/6e7/1a6/4ed/6e71a64edec04079bf33faa7ab39606f.png)
![](https://github.com/terrakok/Cicerone/raw/develop/media/replace_img.png)

## Predefined navigators
The library provides predefined navigators for _Fragments_ to use inside _Activity_.
To use, just provide it with the container and _FragmentManager_ and override few simple methods.
The library provides predefined navigators for _Fragments_ and _Activity_.
To use, just provide it with the container and _FragmentManager_.
```java
private Navigator navigator = new SupportAppNavigator(this, R.id.container) {
@Override
protected Intent createActivityIntent(Context context, String screenKey, Object data) {
return null;
}

@Override
protected Fragment createFragment(String screenKey, Object data) {
switch (screenKey) {
case Screens.PROFILE_SCREEN:
return new ProfileFragment();
case Screens.SELECT_PHOTO_SCREEN:
return SelectPhotoFragment.getNewInstance((int) data);
}
return null;
}

@Override
protected void setupFragmentTransactionAnimation(
Command command,
Fragment currentFragment,
Fragment nextFragment,
FragmentTransaction fragmentTransaction) {
//setup animation
}
};
private Navigator navigator = new SupportAppNavigator(this, R.id.container);
```
## Sample
To see how to add, initialize and use the library and predefined navigators check out the sample.
Or look at [GitFox (Android GitLab client)](https://gitlab.com/terrakok/gitlab-client)

![](https://habrastorage.org/web/a94/d73/653/a94d736534694d9daa994e0c260fca28.gif)
![](https://habrastorage.org/web/6dd/a19/15c/6dda1915cdcf4f14bed16fcffb3fd938.gif)
![](https://habrastorage.org/web/a63/881/7f8/a638817f8bba49daacc4fa427987fabb.gif)
![](https://github.com/terrakok/Cicerone/raw/develop/media/navigation.gif)
![](https://github.com/terrakok/Cicerone/raw/develop/media/insta_tabs.gif)
![](https://github.com/terrakok/Cicerone/raw/develop/media/animations.gif)

## Participants
+ idea and code - Konstantin Tskhovrebov (@terrakok)
Expand Down Expand Up @@ -207,4 +184,4 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
```
```
178 changes: 0 additions & 178 deletions README_RUS.md

This file was deleted.

4 changes: 3 additions & 1 deletion build.gradle
Expand Up @@ -3,9 +3,10 @@
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.android.tools.build:gradle:3.3.0-alpha12'

// For the library uploading to the Bintray
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.1'
Expand All @@ -16,6 +17,7 @@ buildscript {
allprojects {
repositories {
jcenter()
google()
}
}

Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,6 @@
#Sat Dec 23 00:31:04 MSK 2017
#Thu Sep 27 15:42:22 MSK 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
3 changes: 2 additions & 1 deletion library/build.gradle
Expand Up @@ -7,6 +7,7 @@ targetCompatibility = JavaVersion.VERSION_1_7

dependencies {
compileOnly project(':stub-android')
compileOnly 'com.google.android:android:4.1.1.4'
}

ext {
Expand All @@ -15,7 +16,7 @@ ext {
bintrayName = 'cicerone'
publishedGroupId = 'ru.terrakok.cicerone'
artifact = 'cicerone'
libraryVersion = '3.0.0'
libraryVersion = '4.0.0'
gitUrl = 'https://github.com/terrakok/Cicerone'
allLicenses = ['MIT']
}
Expand Down

0 comments on commit 301f3f3

Please sign in to comment.