Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
terrakok committed Aug 21, 2017
2 parents d8266b0 + ecd214f commit ced094e
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 18 deletions.
10 changes: 5 additions & 5 deletions README.md
@@ -1,18 +1,18 @@
# Cicerone
[![jCenter](https://api.bintray.com/packages/terrakok/terramaven/cicerone/images/download.svg)](https://bintray.com/terrakok/terramaven/cicerone/_latestVersion)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

[![Join the chat at https://gitter.im/terrakok/Cicerone](https://img.shields.io/badge/Gitter-Join%20Chat-brightred.svg?style=flat)](https://gitter.im/terrakok/Cicerone)

[![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-Cicerone-green.svg?style=true)](https://android-arsenal.com/details/1/4700)
[![Android Weekly](https://img.shields.io/badge/Android%20Weekly-250-lightgrey.svg)](http://androidweekly.net/issues/issue-250)
[![Telegram](https://img.shields.io/badge/Telegram-ENG-blue.svg)](https://t.me/Cicerone_ENG)
[![Telegram](https://img.shields.io/badge/Telegram-RUS-blue.svg)](https://t.me/Cicerone_RUS)
[![Android Weekly](https://img.shields.io/badge/Android%20Weekly-250-green.svg)](http://androidweekly.net/issues/issue-250)
[![Android Weekly](https://img.shields.io/badge/Android%20Weekly-271-green.svg)](http://androidweekly.net/issues/issue-271)

![](https://habrastorage.org/files/644/32e/9eb/64432e9eb3664723b3ee438449dab3b0.png)

Cicerone (a guide, one who conducts sightseers) is a lightweight library that makes the navigation in an Android app easy.
It was designed to be used with the MVP pattern (try [Moxy](https://github.com/Arello-Mobile/Moxy)), but will work great with any architecture.

[Russian version readme](https://github.com/terrakok/Cicerone/blob/develop/README_RUS.md)

## Main advantages
+ is not tied to Fragments
+ not a framework
Expand Down
4 changes: 4 additions & 0 deletions README_RUS.md
@@ -1,5 +1,9 @@
# Cicerone

[![Telegram](https://img.shields.io/badge/Telegram-RUS-blue.svg)](https://t.me/Cicerone_RUS)

![](https://habrastorage.org/files/644/32e/9eb/64432e9eb3664723b3ee438449dab3b0.png)

Cicerone (_"褔懈-褔械-褉芯虂-薪械"_ - 褍褋褌邪褉. 谐懈写) - 谢械谐泻邪褟 斜懈斜谢懈芯褌械泻邪 写谢褟 锌褉芯褋褌芯泄 褉械邪谢懈蟹邪褑懈懈 薪邪胁懈谐邪褑懈懈 胁 邪薪写褉芯懈写 锌褉懈谢芯卸械薪懈懈.
袪邪蟹褉邪斜芯褌邪薪邪 写谢褟 懈褋锌芯谢褜蟹芯胁邪薪懈褟 胁 MVP 邪褉褏懈褌械泻褌褍褉械 (锌芯锌褉芯斜褍泄褌械 [Moxy](https://github.com/Arello-Mobile/Moxy)), 薪芯 谢械谐泻芯 胁褋褌褉邪懈胁邪械褌褋褟 胁 谢褞斜褘械 褉械褕械薪懈褟.

Expand Down
2 changes: 1 addition & 1 deletion library/build.gradle
Expand Up @@ -15,7 +15,7 @@ ext {
bintrayName = 'cicerone'
publishedGroupId = 'ru.terrakok.cicerone'
artifact = 'cicerone'
libraryVersion = '2.0.0'
libraryVersion = '2.1.0'
gitUrl = 'https://github.com/terrakok/Cicerone'
allLicenses = ['MIT']
}
Expand Down
Expand Up @@ -3,6 +3,7 @@
import android.app.Activity;
import android.app.FragmentManager;
import android.content.Intent;
import android.os.Bundle;
import android.widget.Toast;

import ru.terrakok.cicerone.commands.BackTo;
Expand Down Expand Up @@ -34,6 +35,17 @@ public AppNavigator(Activity activity, FragmentManager fragmentManager, int cont
this.activity = activity;
}

/**
* Override this method to create option for start activity
*
* @param command current navigation command. Will be only {@link Forward} or {@link Replace}
* @param activityIntent activity intent
* @return transition options
*/
protected Bundle createStartActivityOptions(Command command, Intent activityIntent) {
return null;
}

@Override
public void applyCommand(Command command) {
if (command instanceof Forward) {
Expand All @@ -42,7 +54,8 @@ public void applyCommand(Command command) {

// Start activity
if (activityIntent != null) {
activity.startActivity(activityIntent);
Bundle options = createStartActivityOptions(command, activityIntent);
activity.startActivity(activityIntent, options);
return;
}

Expand All @@ -52,7 +65,8 @@ public void applyCommand(Command command) {

// Replace activity
if (activityIntent != null) {
activity.startActivity(activityIntent);
Bundle options = createStartActivityOptions(command, activityIntent);
activity.startActivity(activityIntent, options);
activity.finish();
return;
}
Expand Down
Expand Up @@ -44,11 +44,11 @@ public FragmentNavigator(FragmentManager fragmentManager, int containerId) {
}

/**
* Override this method for setup custom fragment transaction animation.
* Override this method to setup custom fragment transaction animation.
*
* @param command current navigation command. Maybe only {@link Forward} and {@link Replace}
* @param command current navigation command. Will be only {@link Forward} or {@link Replace}
* @param currentFragment current fragment in container
* (for {@link Replace} command it will be previous screen, NOT replaced screen)
* (for {@link Replace} command it will be screen previous in new chain, NOT replaced screen)
* @param nextFragment next screen fragment
* @param fragmentTransaction fragment transaction
*/
Expand Down Expand Up @@ -183,4 +183,4 @@ protected void backToUnexisting() {
protected void unknownScreen(Command command) {
throw new RuntimeException("Can't create a screen for passed screenKey.");
}
}
}
Expand Up @@ -2,6 +2,7 @@

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.widget.Toast;
Expand Down Expand Up @@ -35,6 +36,17 @@ public SupportAppNavigator(FragmentActivity activity, FragmentManager fragmentMa
this.activity = activity;
}

/**
* Override this method to create option for start activity
*
* @param command current navigation command. Will be only {@link Forward} or {@link Replace}
* @param activityIntent activity intent
* @return transition options
*/
protected Bundle createStartActivityOptions(Command command, Intent activityIntent) {
return null;
}

@Override
public void applyCommand(Command command) {
if (command instanceof Forward) {
Expand All @@ -43,7 +55,8 @@ public void applyCommand(Command command) {

// Start activity
if (activityIntent != null) {
activity.startActivity(activityIntent);
Bundle options = createStartActivityOptions(command, activityIntent);
activity.startActivity(activityIntent, options);
return;
}

Expand All @@ -53,7 +66,8 @@ public void applyCommand(Command command) {

// Replace activity
if (activityIntent != null) {
activity.startActivity(activityIntent);
Bundle options = createStartActivityOptions(command, activityIntent);
activity.startActivity(activityIntent, options);
activity.finish();
return;
}
Expand Down
Expand Up @@ -44,11 +44,11 @@ public SupportFragmentNavigator(FragmentManager fragmentManager, int containerId
}

/**
* Override this method for setup custom fragment transaction animation.
* Override this method to setup custom fragment transaction animation.
*
* @param command current navigation command. Maybe only {@link Forward} and {@link Replace}
* @param command current navigation command. Will be only {@link Forward} or {@link Replace}
* @param currentFragment current fragment in container
* (for {@link Replace} command it will be previous screen, NOT replaced screen)
* (for {@link Replace} command it will be screen previous in new chain, NOT replaced screen)
* @param nextFragment next screen fragment
* @param fragmentTransaction fragment transaction
*/
Expand Down Expand Up @@ -182,4 +182,4 @@ protected void backToUnexisting() {
protected void unknownScreen(Command command) {
throw new RuntimeException("Can't create a screen for passed screenKey.");
}
}
}
5 changes: 5 additions & 0 deletions library/stub-android/src/main/java/android/app/Activity.java
Expand Up @@ -2,6 +2,7 @@

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;

/***
* Created by laomo on 2016-11-21.
Expand All @@ -11,6 +12,10 @@ public void startActivity(Intent intent) {
throw new RuntimeException("Stub!");
}

public void startActivity(Intent intent, Bundle options) {
throw new RuntimeException("Stub!");
}

public FragmentManager getFragmentManager() {
throw new RuntimeException("Stub!");
}
Expand Down

0 comments on commit ced094e

Please sign in to comment.