Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
310 additions
and
29 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
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package android.app; | ||
|
||
/*** | ||
* Created by laomo on 2016-11-21. | ||
*/ | ||
public class Activity { | ||
} |
36 changes: 36 additions & 0 deletions
36
library/stub-android/src/main/java/android/app/Fragment.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,36 @@ | ||
package android.app; | ||
|
||
import android.os.Bundle; | ||
|
||
/*** | ||
* Created by laomo on 2016-11-21. | ||
*/ | ||
public class Fragment { | ||
public void onCreate(Bundle savedInstanceState) { | ||
throw new RuntimeException("Stub!"); | ||
} | ||
|
||
public void onStart() { | ||
throw new RuntimeException("Stub!"); | ||
} | ||
|
||
public void onDestroyView() { | ||
throw new RuntimeException("Stub!"); | ||
} | ||
|
||
public void onDestroy() { | ||
throw new RuntimeException("Stub!"); | ||
} | ||
|
||
public void onSaveInstanceState(Bundle outState) { | ||
throw new RuntimeException("Stub!"); | ||
} | ||
|
||
final public boolean isRemoving() { | ||
throw new RuntimeException("Stub!"); | ||
} | ||
|
||
public final Activity getActivity() { | ||
throw new RuntimeException("Stub!"); | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
library/stub-android/src/main/java/android/app/FragmentManager.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,41 @@ | ||
package android.app; | ||
|
||
/*** | ||
* Created by laomo on 2016-11-21. | ||
*/ | ||
public class FragmentManager { | ||
|
||
public FragmentTransaction beginTransaction() { | ||
throw new RuntimeException("Stub!"); | ||
} | ||
|
||
public boolean executePendingTransactions() { | ||
throw new RuntimeException("Stub!"); | ||
} | ||
|
||
public void popBackStack() { | ||
throw new RuntimeException("Stub!"); | ||
} | ||
|
||
public boolean popBackStackImmediate() { | ||
throw new RuntimeException("Stub!"); | ||
} | ||
|
||
public boolean popBackStackImmediate(String name, int flags) { | ||
throw new RuntimeException("Stub!"); | ||
} | ||
|
||
public int getBackStackEntryCount() { | ||
throw new RuntimeException("Stub!"); | ||
} | ||
|
||
public BackStackEntry getBackStackEntryAt(int index) { | ||
throw new RuntimeException("Stub!"); | ||
} | ||
|
||
public interface BackStackEntry { | ||
int getId(); | ||
|
||
String getName(); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
library/stub-android/src/main/java/android/app/FragmentTransaction.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,18 @@ | ||
package android.app; | ||
|
||
/*** | ||
* Created by laomo on 2016-11-21. | ||
*/ | ||
public class FragmentTransaction { | ||
public FragmentTransaction replace(int containerViewId, Fragment fragment) { | ||
throw new RuntimeException("Stub!"); | ||
} | ||
|
||
public FragmentTransaction addToBackStack(String name) { | ||
throw new RuntimeException("Stub!"); | ||
} | ||
|
||
public int commit() { | ||
throw new RuntimeException("Stub!"); | ||
} | ||
} |
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,7 @@ | ||
package android.os; | ||
|
||
/*** | ||
* Created by laomo on 2016-11-21. | ||
*/ | ||
public class Bundle { | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
26 changes: 26 additions & 0 deletions
26
sample/src/main/java/ru/terrakok/cicerone/sample/mvp/start/StartActivityPresenter.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,26 @@ | ||
package ru.terrakok.cicerone.sample.mvp.start; | ||
|
||
import com.arellomobile.mvp.MvpPresenter; | ||
|
||
import ru.terrakok.cicerone.Router; | ||
import ru.terrakok.cicerone.sample.SampleApplication; | ||
import ru.terrakok.cicerone.sample.Screens; | ||
|
||
/** | ||
* Created by terrakok 21.11.16 | ||
*/ | ||
public class StartActivityPresenter extends MvpPresenter<StartActivityView> { | ||
private Router router; | ||
|
||
public StartActivityPresenter() { | ||
router = SampleApplication.INSTANCE.getRouter(); | ||
} | ||
|
||
public void onNextPressed() { | ||
router.replaceScreen(Screens.MAIN_ACTIVITY_SCREEN); | ||
} | ||
|
||
public void onBackPressed() { | ||
router.exit(); | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
sample/src/main/java/ru/terrakok/cicerone/sample/mvp/start/StartActivityView.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,9 @@ | ||
package ru.terrakok.cicerone.sample.mvp.start; | ||
|
||
import com.arellomobile.mvp.MvpView; | ||
|
||
/** | ||
* Created by terrakok 21.11.16 | ||
*/ | ||
public interface StartActivityView extends MvpView { | ||
} |
113 changes: 113 additions & 0 deletions
113
sample/src/main/java/ru/terrakok/cicerone/sample/ui/start/StartActivity.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,113 @@ | ||
package ru.terrakok.cicerone.sample.ui.start; | ||
|
||
import android.content.Intent; | ||
import android.os.Bundle; | ||
import android.util.Log; | ||
import android.view.View; | ||
import android.widget.Toast; | ||
|
||
import com.arellomobile.mvp.MvpAppCompatActivity; | ||
import com.arellomobile.mvp.presenter.InjectPresenter; | ||
|
||
import ru.terrakok.cicerone.Navigator; | ||
import ru.terrakok.cicerone.commands.Back; | ||
import ru.terrakok.cicerone.commands.Command; | ||
import ru.terrakok.cicerone.commands.Forward; | ||
import ru.terrakok.cicerone.commands.Replace; | ||
import ru.terrakok.cicerone.commands.SystemMessage; | ||
import ru.terrakok.cicerone.sample.R; | ||
import ru.terrakok.cicerone.sample.SampleApplication; | ||
import ru.terrakok.cicerone.sample.Screens; | ||
import ru.terrakok.cicerone.sample.mvp.start.StartActivityPresenter; | ||
import ru.terrakok.cicerone.sample.mvp.start.StartActivityView; | ||
import ru.terrakok.cicerone.sample.ui.main.MainActivity; | ||
|
||
/** | ||
* Created by terrakok 21.11.16 | ||
*/ | ||
public class StartActivity extends MvpAppCompatActivity implements StartActivityView { | ||
@InjectPresenter | ||
StartActivityPresenter presenter; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
|
||
setContentView(R.layout.activity_start); | ||
initViews(); | ||
} | ||
|
||
private void initViews() { | ||
findViewById(R.id.lets_go_button).setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View view) { | ||
presenter.onNextPressed(); | ||
} | ||
}); | ||
} | ||
|
||
@Override | ||
protected void onResume() { | ||
super.onResume(); | ||
SampleApplication.INSTANCE.getNavigatorHolder().setNavigator(navigator); | ||
} | ||
|
||
@Override | ||
protected void onPause() { | ||
SampleApplication.INSTANCE.getNavigatorHolder().removeNavigator(); | ||
super.onPause(); | ||
} | ||
|
||
@Override | ||
public void onBackPressed() { | ||
presenter.onBackPressed(); | ||
} | ||
|
||
private Navigator navigator = new Navigator() { | ||
@Override | ||
public void applyCommand(Command command) { | ||
if (command instanceof Forward) { | ||
forward((Forward) command); | ||
} else if (command instanceof Replace) { | ||
replace((Replace) command); | ||
} else if (command instanceof Back) { | ||
back(); | ||
} else if (command instanceof SystemMessage) { | ||
Toast.makeText(StartActivity.this, ((SystemMessage) command).getMessage(), Toast.LENGTH_SHORT).show(); | ||
} else { | ||
Log.e("Cicerone", "Illegal command for this screen: " + command.getClass().getSimpleName()); | ||
} | ||
} | ||
|
||
private void forward(Forward command) { | ||
switch (command.getScreenKey()) { | ||
case Screens.START_ACTIVITY_SCREEN: | ||
startActivity(new Intent(StartActivity.this, StartActivity.class)); | ||
break; | ||
case Screens.MAIN_ACTIVITY_SCREEN: | ||
startActivity(new Intent(StartActivity.this, MainActivity.class)); | ||
break; | ||
default: | ||
Log.e("Cicerone", "Unknown screen: " + command.getScreenKey()); | ||
break; | ||
} | ||
} | ||
|
||
private void replace(Replace command) { | ||
switch (command.getScreenKey()) { | ||
case Screens.START_ACTIVITY_SCREEN: | ||
case Screens.MAIN_ACTIVITY_SCREEN: | ||
forward(new Forward(command.getScreenKey(), command.getTransitionData())); | ||
finish(); | ||
break; | ||
default: | ||
Log.e("Cicerone", "Unknown screen: " + command.getScreenKey()); | ||
break; | ||
} | ||
} | ||
|
||
private void back() { | ||
finish(); | ||
} | ||
}; | ||
} |
Oops, something went wrong.