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 Feb 11, 2020
2 parents 0ba13ef + 046410e commit dcf1532
Show file tree
Hide file tree
Showing 19 changed files with 245 additions and 92 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ buildscript {
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0-alpha01'
classpath 'com.android.tools.build:gradle:3.5.0'

// For the library uploading to the Bintray
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.1'
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1-milestone-1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
5 changes: 3 additions & 2 deletions library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ targetCompatibility = JavaVersion.VERSION_1_7
dependencies {
compileOnly project(':stub-android')
compileOnly 'com.google.android:android:4.1.1.4'
implementation "org.jetbrains:annotations:16.0.3"
}

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

// Configuration of the library uploading to the Bintray
// Note: Call 'bintrayUpload' task (it will execute 'install' task first)
// I try to include as little properties as possible in these files
project.archivesBaseName ='cicerone' // to fix that project name different from artifact name
project.archivesBaseName = 'cicerone' // to fix that project name different from artifact name
apply from: 'androidmaven.gradle'
apply from: 'bintray.gradle'

Expand Down
5 changes: 4 additions & 1 deletion library/src/main/java/ru/terrakok/cicerone/BaseRouter.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

package ru.terrakok.cicerone;

import org.jetbrains.annotations.NotNull;

import ru.terrakok.cicerone.commands.Command;

/**
Expand All @@ -17,6 +19,7 @@ public BaseRouter() {
this.commandBuffer = new CommandBuffer();
}

@NotNull
CommandBuffer getCommandBuffer() {
return commandBuffer;
}
Expand All @@ -26,7 +29,7 @@ CommandBuffer getCommandBuffer() {
*
* @param commands navigation command array to execute
*/
protected void executeCommands(Command... commands) {
protected void executeCommands(@NotNull Command... commands) {
commandBuffer.executeCommands(commands);
}
}
10 changes: 8 additions & 2 deletions library/src/main/java/ru/terrakok/cicerone/Cicerone.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

package ru.terrakok.cicerone;

import org.jetbrains.annotations.NotNull;

/**
* Cicerone is the holder for other library components.
* To use it, instantiate it using one of the {@link #create()} methods.
Expand All @@ -15,21 +17,24 @@
public class Cicerone<T extends BaseRouter> {
private T router;

private Cicerone(T router) {
private Cicerone(@NotNull T router) {
this.router = router;
}

@NotNull
public NavigatorHolder getNavigatorHolder() {
return router.getCommandBuffer();
}

@NotNull
public T getRouter() {
return router;
}

/**
* Creates the Cicerone instance with the default {@link Router router}
*/
@NotNull
public static Cicerone<Router> create() {
return create(new Router());
}
Expand All @@ -38,7 +43,8 @@ public static Cicerone<Router> create() {
* Creates the Cicerone instance with the custom router.
* @param customRouter the custom router extending {@link BaseRouter}
*/
public static <T extends BaseRouter> Cicerone<T> create(T customRouter) {
@NotNull
public static <T extends BaseRouter> Cicerone<T> create(@NotNull T customRouter) {
return new Cicerone<>(customRouter);
}
}
7 changes: 5 additions & 2 deletions library/src/main/java/ru/terrakok/cicerone/CommandBuffer.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

package ru.terrakok.cicerone;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.LinkedList;
import java.util.Queue;

Expand All @@ -18,7 +21,7 @@ class CommandBuffer implements NavigatorHolder {
private Queue<Command[]> pendingCommands = new LinkedList<>();

@Override
public void setNavigator(Navigator navigator) {
public void setNavigator(@Nullable Navigator navigator) {
this.navigator = navigator;
while (!pendingCommands.isEmpty()) {
if (navigator != null) {
Expand All @@ -37,7 +40,7 @@ public void removeNavigator() {
* Else puts it to the pending commands queue to pass it later.
* @param commands navigation command array
*/
void executeCommands(Command[] commands) {
void executeCommands(@NotNull Command[] commands) {
if (navigator != null) {
navigator.applyCommands(commands);
} else {
Expand Down
4 changes: 3 additions & 1 deletion library/src/main/java/ru/terrakok/cicerone/Navigator.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

package ru.terrakok.cicerone;

import org.jetbrains.annotations.NotNull;

import ru.terrakok.cicerone.commands.Command;

/**
Expand All @@ -17,5 +19,5 @@ public interface Navigator {
*
* @param commands the navigation command array to apply per single transaction
*/
void applyCommands(Command[] commands);
void applyCommands(@NotNull Command[] commands);
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

package ru.terrakok.cicerone;

import org.jetbrains.annotations.NotNull;

/**
* Navigator holder interface.
* Use it to connect a {@link Navigator} to the {@link Cicerone}.
Expand All @@ -15,7 +17,7 @@ public interface NavigatorHolder {
*
* @param navigator new active Navigator
*/
void setNavigator(Navigator navigator);
void setNavigator(@NotNull Navigator navigator);

/**
* Remove the current Navigator and stop receive commands.
Expand Down
15 changes: 9 additions & 6 deletions library/src/main/java/ru/terrakok/cicerone/Router.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

package ru.terrakok.cicerone;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import ru.terrakok.cicerone.commands.Back;
import ru.terrakok.cicerone.commands.BackTo;
import ru.terrakok.cicerone.commands.Command;
Expand All @@ -27,7 +30,7 @@ public Router() {
*
* @param screen screen
*/
public void navigateTo(Screen screen) {
public void navigateTo(@NotNull Screen screen) {
executeCommands(new Forward(screen));
}

Expand All @@ -36,7 +39,7 @@ public void navigateTo(Screen screen) {
*
* @param screen screen
*/
public void newRootScreen(Screen screen) {
public void newRootScreen(@NotNull Screen screen) {
executeCommands(
new BackTo(null),
new Replace(screen)
Expand All @@ -51,7 +54,7 @@ public void newRootScreen(Screen screen) {
*
* @param screen screen
*/
public void replaceScreen(Screen screen) {
public void replaceScreen(@NotNull Screen screen) {
executeCommands(new Replace(screen));
}

Expand All @@ -62,15 +65,15 @@ public void replaceScreen(Screen screen) {
*
* @param screen screen
*/
public void backTo(Screen screen) {
public void backTo(@Nullable Screen screen) {
executeCommands(new BackTo(screen));
}

/**
* Opens several screens inside single transaction.
* @param screens
*/
public void newChain(Screen... screens) {
public void newChain(@NotNull Screen... screens) {
Command[] commands = new Command[screens.length];
for (int i = 0; i < commands.length; i++) {
commands[i] = new Forward(screens[i]);
Expand All @@ -82,7 +85,7 @@ public void newChain(Screen... screens) {
* Clear current stack and open several screens inside single transaction.
* @param screens
*/
public void newRootChain(Screen... screens) {
public void newRootChain(@NotNull Screen... screens) {
Command[] commands = new Command[screens.length + 1];
commands[0] = new BackTo(null);
if (screens.length > 0) {
Expand Down
3 changes: 3 additions & 0 deletions library/src/main/java/ru/terrakok/cicerone/Screen.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
package ru.terrakok.cicerone;

import org.jetbrains.annotations.NotNull;

/**
* Screen is class for description application screen.
*/
public abstract class Screen {
protected String screenKey = getClass().getCanonicalName();

@NotNull
public String getScreenKey() {
return screenKey;
}
Expand Down
Loading

0 comments on commit dcf1532

Please sign in to comment.