Skip to content

Commit 0e4e4ea

Browse files
author
Hussein Aladeen
committed
feat(FlowrScreen): Observe fragment changes in flowr screen
1 parent 38f3c25 commit 0e4e4ea

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed

flowr/src/main/java/com/fueled/flowr/AbstractFlowrActivity.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import android.os.Bundle;
77
import android.support.annotation.ColorInt;
88
import android.support.annotation.Nullable;
9+
import android.support.v4.app.Fragment;
910
import android.support.v4.app.FragmentManager;
1011
import android.support.v7.app.AppCompatActivity;
1112

@@ -61,6 +62,11 @@ protected int getDefaultNavigationBarColor() {
6162
return Color.BLACK;
6263
}
6364

65+
@Override
66+
public void onCurrentFragmentChanged(@Nullable Fragment currentFragment) {
67+
// Do Nothing. No Default implementation is required.
68+
}
69+
6470
@SuppressWarnings("WrongConstant")
6571
@Override
6672
public void setScreenOrientation(int orientation) {

flowr/src/main/java/com/fueled/flowr/Flowr.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,7 @@ public void syncScreenState() {
509509
}
510510

511511
if (screen != null) {
512+
screen.onCurrentFragmentChanged(getCurrentFragment());
512513
screen.setScreenOrientation(screenOrientation);
513514
screen.setNavigationBarColor(navigationBarColor);
514515
}

flowr/src/main/java/com/fueled/flowr/FlowrScreen.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package com.fueled.flowr;
22

33
import android.support.annotation.ColorInt;
4+
import android.support.annotation.Nullable;
5+
import android.support.v4.app.Fragment;
46
import android.support.v4.app.FragmentManager;
57

68
/**
@@ -10,11 +12,36 @@
1012

1113
public interface FlowrScreen {
1214

15+
/**
16+
* Return the FragmentManager for interacting with fragments associated
17+
* with this screen.
18+
*/
1319
FragmentManager getScreenFragmentManager();
1420

21+
/**
22+
* Invoke the {@code onBackPressed} method for this screen.
23+
*/
1524
void invokeOnBackPressed();
1625

26+
/**
27+
* Indicates that the fragment currently being displayed has changed.
28+
*
29+
* @param currentFragment the fragment currently displayed or {@code null} if no fragment
30+
* is being displayed.
31+
*/
32+
void onCurrentFragmentChanged(@Nullable Fragment currentFragment);
33+
34+
/**
35+
* Specify the screen orientation to be used for this screen.
36+
*
37+
* @param orientation the screen orientation to be used.
38+
*/
1739
void setScreenOrientation(int orientation);
1840

41+
/**
42+
* Specify the navigation bar color to be used for this screen.
43+
*
44+
* @param color the navigation bar color to be used.
45+
*/
1946
void setNavigationBarColor(@ColorInt int color);
2047
}

0 commit comments

Comments
 (0)