Browse Source

removed old stuff

Daniel Zlotin 8 years ago
parent
commit
5f2b66273d

+ 0
- 132
android/app/src/main/java/com/reactnativenavigation/views/BottomNavigation.java View File

@@ -1,132 +0,0 @@
1
-package com.reactnativenavigation.views;
2
-
3
-import android.animation.Animator;
4
-import android.animation.AnimatorListenerAdapter;
5
-import android.animation.ObjectAnimator;
6
-import android.content.Context;
7
-import android.support.v4.view.animation.LinearOutSlowInInterpolator;
8
-import android.util.AttributeSet;
9
-import android.util.Log;
10
-import android.view.View;
11
-
12
-import com.aurelhubert.ahbottomnavigation.AHBottomNavigation;
13
-
14
-/**
15
- * Created by guyc on 10/07/16.
16
- */
17
-public class BottomNavigation extends AHBottomNavigation {
18
-    private static final String TAG = "BottomNavigation";
19
-    public static final int SCROLL_DIRECTION_UP = 0;
20
-    public static final int SCROLL_DIRECTION_DOWN = 1;
21
-
22
-    private static final int STATE_HIDDEN = 0;
23
-    private static final int STATE_ANIMATE_HIDE = 1;
24
-    private static final int STATE_SHOWN = 2;
25
-    private static final int STATE_ANIMATE_SHOW = 3;
26
-    public static final int DURATION = 300;
27
-
28
-    private int mState = STATE_SHOWN;
29
-    private ObjectAnimator mHideAnimator;
30
-    private ObjectAnimator mShowAnimator;
31
-
32
-
33
-    public BottomNavigation(Context context) {
34
-        super(context);
35
-    }
36
-
37
-    public BottomNavigation(Context context, AttributeSet attrs) {
38
-        super(context, attrs);
39
-    }
40
-
41
-    public BottomNavigation(Context context, AttributeSet attrs, int defStyleAttr) {
42
-        super(context, attrs, defStyleAttr);
43
-    }
44
-
45
-    public void toggleTabs(boolean hide, boolean animated) {
46
-        if (hide) {
47
-            hide(animated);
48
-        } else {
49
-            show(animated);
50
-        }
51
-    }
52
-
53
-    private void hide(boolean animated) {
54
-        if (animated) {
55
-            hideAnimated();
56
-        } else {
57
-            setVisibility(View.GONE);
58
-        }
59
-    }
60
-
61
-    private void hideAnimated() {
62
-        if (mHideAnimator == null) {
63
-            mHideAnimator = createHideAnimator();
64
-        }
65
-
66
-        mHideAnimator.start();
67
-    }
68
-
69
-    private ObjectAnimator createHideAnimator() {
70
-        ObjectAnimator hideAnimator = ObjectAnimator.ofFloat(this, "translationY", getHeight());
71
-        hideAnimator.setDuration(DURATION);
72
-        hideAnimator.addListener(new AnimatorListenerAdapter() {
73
-            @Override
74
-            public void onAnimationStart(Animator animation) {
75
-                mState = STATE_ANIMATE_HIDE;
76
-            }
77
-
78
-            @Override
79
-            public void onAnimationEnd(Animator animation) {
80
-                mState = STATE_HIDDEN;
81
-            }
82
-        });
83
-        hideAnimator.setInterpolator(new LinearOutSlowInInterpolator());
84
-        return hideAnimator;
85
-
86
-    }
87
-
88
-    private void show(boolean animated) {
89
-        if (animated) {
90
-            showAnimated();
91
-        } else {
92
-            setVisibility(View.VISIBLE);
93
-        }
94
-    }
95
-
96
-    private void showAnimated() {
97
-        if (mShowAnimator == null) {
98
-            mShowAnimator = createShowAnimator();
99
-        }
100
-
101
-        mShowAnimator.start();
102
-    }
103
-
104
-    private ObjectAnimator createShowAnimator() {
105
-        ObjectAnimator showAnimator = ObjectAnimator.ofFloat(this, "translationY", 0);
106
-        showAnimator.setDuration(DURATION);
107
-        showAnimator.addListener(new AnimatorListenerAdapter() {
108
-            @Override
109
-            public void onAnimationStart(Animator animation) {
110
-                mState = STATE_ANIMATE_SHOW;
111
-            }
112
-
113
-            @Override
114
-            public void onAnimationEnd(Animator animation) {
115
-                mState = STATE_SHOWN;
116
-            }
117
-        });
118
-        showAnimator.setInterpolator(new LinearOutSlowInInterpolator());
119
-        return showAnimator;
120
-    }
121
-
122
-
123
-    public void onScroll(int direction) {
124
-        Log.d(TAG, "onScroll() called with: " + "direction = [" + direction + "]");
125
-        if (direction == SCROLL_DIRECTION_DOWN && mState == STATE_SHOWN) {
126
-            hide(true);
127
-
128
-        } else if (direction == SCROLL_DIRECTION_UP && mState == STATE_HIDDEN) {
129
-            show(true);
130
-        }
131
-    }
132
-}

+ 0
- 131
android/app/src/main/java/com/reactnativenavigation/views/RctView.java View File

@@ -1,131 +0,0 @@
1
-package com.reactnativenavigation.views;
2
-
3
-/**
4
- * Created by guyc on 10/03/16.
5
- */
6
-public class RctView {
7
-//
8
-//    private BottomTabActivity context;
9
-//    private ReactRootView reactRootView;
10
-//    private ScrollView scrollView;
11
-//    private int lastScrollY = -1;
12
-//    private final ViewTreeObserver.OnScrollChangedListener scrollChangedListener = new ViewTreeObserver.OnScrollChangedListener() {
13
-//        @Override
14
-//        public void onScrollChanged() {
15
-//            if (!scrollView.getViewTreeObserver().isAlive()) {
16
-//                return;
17
-//            }
18
-//
19
-//            final int scrollY = scrollView.getScrollY();
20
-//            if (scrollY != lastScrollY && // Scroll position changed
21
-//                scrollY > 0 && // Ignore top overscroll
22
-//                scrollY < (scrollView.getChildAt(0).getHeight() - scrollView.getHeight())) { // Ignore bottom overscroll
23
-//                int direction = scrollY > lastScrollY ?
24
-//                        BottomNavigation.SCROLL_DIRECTION_DOWN :
25
-//                        BottomNavigation.SCROLL_DIRECTION_UP;
26
-//                lastScrollY = scrollY;
27
-//                context.onScrollChanged(direction);
28
-//            }
29
-//        }
30
-//    };
31
-//    private boolean isScrollEventListenerRegistered = false;
32
-//
33
-//    private final View.OnAttachStateChangeListener stateChangeListener =
34
-//            new View.OnAttachStateChangeListener() {
35
-//                @Override
36
-//                public void onViewAttachedToWindow(View v) {
37
-//                    scrollView = getScrollView((ViewGroup) getParent());
38
-//
39
-//                    if (scrollView != null && !isScrollEventListenerRegistered) {
40
-//                        addScrollListener();
41
-//                    }
42
-//                }
43
-//
44
-//                @Override
45
-//                public void onViewDetachedFromWindow(final View detachedView) {
46
-//                    removeScrollListener();
47
-//
48
-//                    post(new Runnable() {
49
-//                        @Override
50
-//                        public void run() {
51
-//                            scrollView = getScrollView((ViewGroup) getParent());
52
-//                            if (scrollView != null && !isScrollEventListenerRegistered) {
53
-//                                isScrollEventListenerRegistered = true;
54
-//                                addScrollListener();
55
-//                            }
56
-//                        }
57
-//                    });
58
-//                }
59
-//            };
60
-//
61
-//    /**
62
-//     * Interface used to run some code when the {@link ReactRootView} is visible.
63
-//     */
64
-//    public interface OnDisplayedListener {
65
-//        /**
66
-//         * This method will be invoked when the {@link ReactRootView} is visible.
67
-//         */
68
-//        void onDisplayed();
69
-//    }
70
-//
71
-//    @SuppressWarnings("unchecked")
72
-//    public RctView(BaseReactActivity ctx, ReactInstanceManager rctInstanceManager, final _Screen screen,
73
-//                   final OnDisplayedListener onDisplayedListener) {
74
-//        super(ctx);
75
-//        setLayoutParams(new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
76
-//
77
-//        final OnDisplayedListener onDisplayedListenerInternal = screen.bottomTabsHiddenOnScroll ?
78
-//            new OnDisplayedListener() {
79
-//                @Override
80
-//                public void onDisplayed() {
81
-//                    if (onDisplayedListener != null) {
82
-//                        onDisplayedListener.onDisplayed();
83
-//                    }
84
-//
85
-//                    setupScrollViewWithBottomTabs();
86
-//                }
87
-//            } : onDisplayedListener;
88
-//
89
-//        reactRootView = new RnnReactRootView(ctx, onDisplayedListenerInternal);
90
-//        reactRootView.setLayoutParams(new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
91
-//        Bundle passProps = createPassProps(screen);
92
-//        String componentName = screen.screenId;
93
-//        reactRootView.startReactApplication(rctInstanceManager, componentName, passProps);
94
-//
95
-//        addView(reactRootView);
96
-//    }
97
-//
98
-//    private Bundle createPassProps(_Screen screen) {
99
-//        Bundle passProps = new Bundle();
100
-//        passProps.putString(_Screen.KEY_SCREEN_INSTANCE_ID, screen.screenInstanceId);
101
-//        passProps.putString(_Screen.KEY_NAVIGATOR_ID, screen.navigatorId);
102
-//        passProps.putString(_Screen.KEY_NAVIGATOR_EVENT_ID, screen.navigatorEventId);
103
-//        if (screen.passedProps != null) {
104
-//            BundleConverter.addMapToBundle(screen.passedProps, passProps);
105
-//        }
106
-//        return passProps;
107
-//    }
108
-//
109
-////    private void setupScrollViewWithBottomTabs() {
110
-////        scrollView = getScrollView((ViewGroup) getParent());
111
-////        if (scrollView != null) {
112
-////            context = (BottomTabActivity) getContext();
113
-////            attachStateChangeListener(scrollView);
114
-////            addScrollListener();
115
-////        }
116
-////    }
117
-//
118
-//
119
-////    private void attachStateChangeListener(ScrollView scrollView) {
120
-////        scrollView.addOnAttachStateChangeListener(stateChangeListener);
121
-////    }
122
-////
123
-////    private void addScrollListener() {
124
-////        scrollView.getViewTreeObserver().addOnScrollChangedListener(scrollChangedListener);
125
-////    }
126
-////
127
-////    private void removeScrollListener() {
128
-////        scrollView.getViewTreeObserver().removeOnScrollChangedListener(scrollChangedListener);
129
-////    }
130
-}
131
-

+ 0
- 29
android/app/src/main/java/com/reactnativenavigation/views/RnnReactRootView.java View File

@@ -1,29 +0,0 @@
1
-package com.reactnativenavigation.views;
2
-
3
-/**
4
- * Created by guyc on 11/07/16.
5
- */
6
-public class RnnReactRootView {
7
-//    private final RctView.OnDisplayedListener mOnDisplayedListener;
8
-//
9
-//    public RnnReactRootView(Context context, RctView.OnDisplayedListener onDisplayedListener) {
10
-//        super(context);
11
-//        mOnDisplayedListener = onDisplayedListener;
12
-//
13
-//        if (onDisplayedListener != null) {
14
-//            detectOnDisplay();
15
-//        }
16
-//    }
17
-//
18
-//    private void detectOnDisplay() {
19
-//        getViewTreeObserver().addOnGlobalLayoutListener(this);
20
-//    }
21
-//
22
-//    @Override
23
-//    public void onGlobalLayout() {
24
-//        if (getChildCount() >= 1) {
25
-//            getViewTreeObserver().removeOnGlobalLayoutListener(this);
26
-//            mOnDisplayedListener.onDisplayed();
27
-//        }
28
-//    }
29
-}

+ 0
- 66
android/app/src/main/java/com/reactnativenavigation/views/RnnTabLayout.java View File

@@ -1,66 +0,0 @@
1
-package com.reactnativenavigation.views;
2
-
3
-/**
4
- * Created by guyc on 07/05/16.
5
- */
6
-public class RnnTabLayout {
7
-//    private Drawable mBackground;
8
-//    private ColorStateList mTabTextColors;
9
-//    private int mSelectedTabIndicatorColor;
10
-//
11
-//    public RnnTabLayout(Context context) {
12
-//        this(context, null);
13
-//    }
14
-//
15
-//    public RnnTabLayout(Context context, AttributeSet attrs) {
16
-//        this(context, attrs, 0);
17
-//    }
18
-//
19
-//    public RnnTabLayout(Context context, AttributeSet attrs, int defStyleAttr) {
20
-//        super(context, attrs, defStyleAttr);
21
-//        init(context);
22
-//    }
23
-//
24
-//    private void init(Context ctx) {
25
-//        mBackground = getBackground();
26
-//        mTabTextColors = getTabTextColors();
27
-//
28
-//        // Get default accent color which is used as the selected tab indicator color
29
-//        TypedValue typedValue = new TypedValue();
30
-//        TypedArray a = ctx.obtainStyledAttributes(typedValue.data, new int[]{R.attr.colorAccent});
31
-//        mSelectedTabIndicatorColor = a.getColor(0, 0);
32
-//        a.recycle();
33
-//    }
34
-//
35
-//    public void setStyle(_Screen screen) {
36
-//        if (screen.toolBarColor != null) {
37
-//            setBackgroundColor(screen.toolBarColor);
38
-//        } else {
39
-//            resetBackground();
40
-//        }
41
-//
42
-//        if (screen.tabNormalTextColor != null && screen.tabSelectedTextColor != null) {
43
-//            setTabTextColors(screen.tabNormalTextColor, screen.tabSelectedTextColor);
44
-//        } else {
45
-//            resetTextColors();
46
-//        }
47
-//
48
-//        if (screen.tabIndicatorColor != null) {
49
-//            setSelectedTabIndicatorColor(screen.tabIndicatorColor);
50
-//        } else {
51
-//            resetSelectedTabIndicatorColor();
52
-//        }
53
-//    }
54
-//
55
-//    public void resetBackground() {
56
-//        setBackground(mBackground);
57
-//    }
58
-//
59
-//    public void resetTextColors() {
60
-//        setTabTextColors(mTabTextColors);
61
-//    }
62
-//
63
-//    public void resetSelectedTabIndicatorColor() {
64
-//        setSelectedTabIndicatorColor(mSelectedTabIndicatorColor);
65
-//    }
66
-}

+ 0
- 361
android/app/src/main/java/com/reactnativenavigation/views/RnnToolBar.java View File

@@ -1,361 +0,0 @@
1
-package com.reactnativenavigation.views;
2
-
3
-public class RnnToolBar {
4
-
5
-//    private List<_Screen> mScreens;
6
-//    private AsyncTask mDrawerIconTask;
7
-//    private AsyncTask mSetupToolbarTask;
8
-//    private Drawable mBackground;
9
-//    private Drawable mDrawerIcon;
10
-//    private DrawerLayout mDrawerLayout;
11
-//    private ActionBarDrawerToggle mDrawerToggle;
12
-//    private ArrayList<View> mMenuItems;
13
-//
14
-//    public RnnToolBar(Context context) {
15
-//        super(context);
16
-//        init();
17
-//    }
18
-//
19
-//    private void init() {
20
-//        mMenuItems = new ArrayList<>();
21
-//        mBackground = getBackground();
22
-//    }
23
-//
24
-//    public void setScreens(List<_Screen> screens) {
25
-//        mScreens = screens;
26
-//    }
27
-//
28
-//    public void handleOnCreateOptionsMenuAsync() {
29
-////        if (mScreens != null) {
30
-////            setupToolbarButtonsAsync(null, mScreens.get(0));
31
-////        }
32
-//    }
33
-//
34
-//    public ActionBarDrawerToggle setupDrawer(DrawerLayout drawerLayout, _Screen drawerScreen, _Screen screen) {
35
-//        if (drawerLayout == null || drawerScreen == null) {
36
-//            return null;
37
-//        }
38
-//
39
-//        mDrawerLayout = drawerLayout;
40
-//        mDrawerToggle = new ActionBarDrawerToggle(
41
-//                ContextProvider.getActivityContext(),
42
-//                mDrawerLayout,
43
-//                this,
44
-//                R.string.drawer_open,
45
-//                R.string.drawer_close
46
-//        );
47
-//        mDrawerLayout.setDrawerListener(mDrawerToggle);
48
-//        setupDrawerIconAsync(drawerScreen.tabIcon, screen);
49
-//
50
-//        return mDrawerToggle;
51
-//    }
52
-//
53
-//    public void setDrawerIcon(Drawable tabIcon) {
54
-//        mDrawerIcon = tabIcon;
55
-//    }
56
-//
57
-//    public void showDrawer(boolean animated) {
58
-//        if (mDrawerLayout == null) {
59
-//            return;
60
-//        }
61
-//
62
-//        mDrawerLayout.openDrawer(Gravity.LEFT);
63
-//    }
64
-//
65
-//    public void hideDrawer(boolean animated) {
66
-//        if (mDrawerLayout == null) {
67
-//            return;
68
-//        }
69
-//
70
-//        mDrawerLayout.closeDrawer(Gravity.LEFT);
71
-//    }
72
-//
73
-//    public void toggleDrawer(boolean animated) {
74
-//        if (mDrawerLayout == null) {
75
-//            return;
76
-//        }
77
-//
78
-//        boolean visible = mDrawerLayout.isDrawerOpen(Gravity.LEFT);
79
-//        if (visible) {
80
-//            hideDrawer(animated);
81
-//        } else {
82
-//            showDrawer(animated);
83
-//        }
84
-//    }
85
-//
86
-//    public void setupDrawerIconAsync(String drawerIconSource, _Screen screen) {
87
-//        if (mDrawerIconTask == null) {
88
-//            mDrawerIconTask = new SetupDrawerIconTask(this, drawerIconSource, screen).execute();
89
-//        }
90
-//    }
91
-//
92
-//    public void setupToolbarButtonsAsync(_Screen newScreen) {
93
-//        if (newScreen != null) {
94
-//            this.setupToolbarButtonsAsync(null, newScreen);
95
-//        }
96
-//    }
97
-//
98
-//
99
-//    public void setupToolbarButtonsAsync(_Screen oldScreen, _Screen newScreen) {
100
-//        if (mSetupToolbarTask == null) {
101
-//            mSetupToolbarTask = new SetupToolbarButtonsTask(this, oldScreen, newScreen).execute();
102
-//        }
103
-//    }
104
-//
105
-//    public void showToolbar(boolean animated) {
106
-//        ActionBar actionBar = ((AppCompatActivity) getContext()).getSupportActionBar();
107
-//        if (actionBar != null) {
108
-//            actionBar.setShowHideAnimationEnabled(animated);
109
-//            // We hide the ToolBar's parent (AppBarLayout) since this animates the shadow added by AppBar as well
110
-//            ((View) getParent()).setVisibility(VISIBLE);
111
-//        }
112
-//    }
113
-//
114
-//    public void hideToolbar(boolean animated) {
115
-//        ActionBar actionBar = ((AppCompatActivity) getContext()).getSupportActionBar();
116
-//        if (actionBar != null) {
117
-//            actionBar.setShowHideAnimationEnabled(animated);
118
-//            // We hide the ToolBar's parent (AppBarLayout) since this animates the shadow added by AppBar as well
119
-//            ((View) getParent()).setVisibility(GONE);
120
-//        }
121
-//    }
122
-//
123
-//    private void showToolbar() {
124
-//        showToolbar(false);
125
-//    }
126
-//
127
-//    private void hideToolbar() {
128
-//        hideToolbar(false);
129
-//    }
130
-//
131
-//    public void setNavUpButton() {
132
-//        setNavUpButton(null);
133
-//    }
134
-//
135
-//    @SuppressWarnings({"ConstantConditions"})
136
-//    public void setNavUpButton(_Screen screen) {
137
-//        BaseReactActivity context = ContextProvider.getActivityContext();
138
-//        if (context == null) {
139
-//            return;
140
-//        }
141
-//
142
-//        ActionBar actionBar = context.getSupportActionBar();
143
-//        if (actionBar == null) {
144
-//            return;
145
-//        }
146
-//
147
-//        boolean isBack = screen != null;
148
-//        boolean hasDrawer = mDrawerToggle != null;
149
-//
150
-//        Drawable navIcon = null;
151
-//        DrawerArrowDrawable navArrow = null;
152
-//        if (hasDrawer && mDrawerIcon == null) {
153
-//            navArrow = (DrawerArrowDrawable) this.getNavigationIcon();
154
-//        } else {
155
-//            if (isBack && !screen.backButtonHidden) {
156
-//                navArrow = new DrawerArrowDrawable(context);
157
-//            } else if (hasDrawer) {
158
-//                navIcon = mDrawerIcon;
159
-//            }
160
-//        }
161
-//
162
-//        if (navArrow != null) {
163
-//            navArrow.setProgress(isBack ? 1.0f : 0.0f);
164
-//            if (screen != null && screen.navBarButtonColor != null) {
165
-//                navArrow.setColor(screen.navBarButtonColor);
166
-//            } else {
167
-//                navArrow.setColor(Color.BLACK);
168
-//            }
169
-//            navIcon = navArrow;
170
-//        }
171
-//
172
-//        actionBar.setHomeAsUpIndicator(navIcon);
173
-//        actionBar.setDisplayHomeAsUpEnabled(navIcon != null);
174
-//    }
175
-//
176
-//    /**
177
-//     * Update the ToolBar from screen. This function sets any properties that are defined
178
-//     * in the screen.
179
-//     *
180
-//     * @param screen The currently displayed screen
181
-//     */
182
-//    @UiThread
183
-//    public void update(@NonNull _Screen screen) {
184
-//        ((AppCompatActivity) getContext()).setSupportActionBar(this);
185
-//        setTitle(screen.title);
186
-//        setStyle(screen);
187
-//    }
188
-//
189
-//    public void updateAndSetButtons(_Screen screen) {
190
-//        update(screen);
191
-//        setupToolbarButtonsAsync(screen);
192
-//    }
193
-//
194
-//    private static class SetupDrawerIconTask extends AsyncTask<Void, Void, Drawable> {
195
-//        private final WeakReference<RnnToolBar> mToolbarWR;
196
-//        private final String mDrawerIconSource;
197
-//        private final Integer mTintColor;
198
-//
199
-//        public SetupDrawerIconTask(RnnToolBar toolBar, String drawerIconSource, _Screen screen) {
200
-//            mToolbarWR = new WeakReference<>(toolBar);
201
-//            mDrawerIconSource = drawerIconSource;
202
-//            mTintColor = screen.navBarButtonColor;
203
-//        }
204
-//
205
-//        @Override
206
-//        protected Drawable doInBackground(Void... params) {
207
-//            Context context = ContextProvider.getActivityContext();
208
-//            if (context == null || mDrawerIconSource == null) {
209
-//                return null;
210
-//            }
211
-//
212
-//            return ImageLoader.loadImage(mDrawerIconSource);
213
-//        }
214
-//
215
-//        @Override
216
-//        protected void onPostExecute(Drawable drawerIcon) {
217
-//            RnnToolBar toolBar = mToolbarWR.get();
218
-//            if (drawerIcon != null) {
219
-//                if (mTintColor != null) {
220
-//                    ImageUtils.tint(drawerIcon, mTintColor);
221
-//                }
222
-//                toolBar.setDrawerIcon(drawerIcon);
223
-//            }
224
-//
225
-//            toolBar.setNavUpButton();
226
-//            mToolbarWR.clear();
227
-//        }
228
-//    }
229
-//
230
-//    private static class SetupToolbarButtonsTask extends AsyncTask<Void, Void, Map<String, Drawable>> {
231
-//        private final List<_Button> mOldButtons;
232
-//        private final List<_Button> mNewButtons;
233
-//        private final WeakReference<RnnToolBar> mToolbarWR;
234
-//        @ColorInt
235
-//        private final Integer mTintColor;
236
-//        private final int mIconDimensions;
237
-//
238
-//        public SetupToolbarButtonsTask(RnnToolBar toolBar, _Screen oldScreen, _Screen newScreen) {
239
-//            mToolbarWR = new WeakReference<>(toolBar);
240
-//            mOldButtons = oldScreen == null ? null : oldScreen.getButtons();
241
-//            mNewButtons = newScreen.getButtons();
242
-//            mTintColor = newScreen.navBarButtonColor;
243
-//            mIconDimensions = (int) ImageUtils.convertDpToPixel(48, toolBar.getContext());
244
-//        }
245
-//
246
-//        @Override
247
-//        protected Map<String, Drawable> doInBackground(Void... params) {
248
-//            Context context = ContextProvider.getActivityContext();
249
-//            if (context == null) {
250
-//                return null;
251
-//            }
252
-//
253
-//            Map<String, Drawable> icons = new HashMap<>();
254
-//            for (_Button button : mNewButtons) {
255
-//                if (button.hasIcon()) {
256
-//                    icons.put(button.id, button.getIcon(context, mIconDimensions));
257
-//                }
258
-//            }
259
-//            return icons;
260
-//        }
261
-//
262
-//        @Override
263
-//        protected void onPostExecute(Map<String, Drawable> icons) {
264
-//            final Context context = ContextProvider.getActivityContext();
265
-//            if (context == null) {
266
-//                return;
267
-//            }
268
-//
269
-//            Menu menu = ((BaseReactActivity) context).getMenu();
270
-//            if (menu == null) {
271
-//                RnnToolBar toolBar = mToolbarWR.get();
272
-//                if (toolBar != null) {
273
-//                    toolBar.mSetupToolbarTask = null;
274
-//                }
275
-//                mToolbarWR.clear();
276
-//                return;
277
-//            }
278
-//
279
-//            // Remove prev screen buttons
280
-//            if (mOldButtons == null) {
281
-//                menu.clear();
282
-//            } else {
283
-//                for (_Button btn : mOldButtons) {
284
-//                    menu.removeItem(btn.getItemId());
285
-//                }
286
-//            }
287
-//
288
-//            // Add new screen buttons
289
-//            final List<String> textButtons = new ArrayList<>();
290
-//            final int size = mNewButtons.size();
291
-//            for (int i = 0; i < size; i++) {
292
-//                _Button button = mNewButtons.get(i);
293
-//                MenuItem item = menu.add(Menu.NONE, button.getItemId(), size - i - 1, button.title);
294
-//                item.setShowAsAction(getMenuItemShowAction(button.showAsAction));
295
-//
296
-//                // Set button tabIcon
297
-//                if (button.hasIcon()) {
298
-//                    Drawable tabIcon = icons.get(button.id);
299
-//                    if (mTintColor != null) {
300
-//                        ImageUtils.tint(tabIcon, mTintColor);
301
-//                    }
302
-//                    item.setIcon(tabIcon);
303
-//                } else {
304
-//                    textButtons.add(button.title);
305
-//                }
306
-//
307
-//                // Disable button if needed
308
-//                if (button.disabled) {
309
-//                    item.setEnabled(false);
310
-//                }
311
-//            }
312
-//
313
-//            final RnnToolBar toolBar = mToolbarWR.get();
314
-//            if (toolBar != null) {
315
-//                // Tint overflow tabIcon which appears when there's not enough space in Toolbar for icons
316
-//                if (mTintColor != null) {
317
-//                    ImageUtils.tint(toolBar.getOverflowIcon(), mTintColor);
318
-//                }
319
-//
320
-//                // Tint text buttons
321
-//                if (textButtons.size() > 0 && mTintColor != null) {
322
-//                    final View decorView = ((Activity) context).getWindow().getDecorView();
323
-//                    decorView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
324
-//                        @Override
325
-//                        public void onGlobalLayout() {
326
-//                            decorView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
327
-//
328
-//                            // Find TextViews
329
-//                            for (String text : textButtons) {
330
-//                                decorView.findViewsWithText(toolBar.mMenuItems, text, View.FIND_VIEWS_WITH_CONTENT_DESCRIPTION);
331
-//                            }
332
-//
333
-//                            // Set text color
334
-//                            for (View button : toolBar.mMenuItems) {
335
-//                                ((TextView) button).setTextColor(mTintColor);
336
-//                            }
337
-//
338
-//                            toolBar.mMenuItems.clear();
339
-//                        }
340
-//                    });
341
-//                }
342
-//
343
-//                toolBar.mSetupToolbarTask = null;
344
-//                mToolbarWR.clear();
345
-//            }
346
-//        }
347
-//
348
-//        private int getMenuItemShowAction(String action) {
349
-//            switch (action) {
350
-//                case "never":
351
-//                    return MenuItem.SHOW_AS_ACTION_NEVER;
352
-//                case "always":
353
-//                    return MenuItem.SHOW_AS_ACTION_ALWAYS;
354
-//                case "withText":
355
-//                    return MenuItem.SHOW_AS_ACTION_WITH_TEXT;
356
-//                default:
357
-//                    return MenuItem.SHOW_AS_ACTION_IF_ROOM;
358
-//            }
359
-//        }
360
-//    }
361
-}

+ 0
- 164
android/app/src/main/java/com/reactnativenavigation/views/ScreenStack.java View File

@@ -1,164 +0,0 @@
1
-package com.reactnativenavigation.views;
2
-
3
-public class ScreenStack  {
4
-//
5
-//    private static final int DISAPPEAR_ANIMATION_DELAY = 200;
6
-//
7
-//    private static class ScreenView {
8
-//        _Screen screen;
9
-//        RctView view;
10
-//
11
-//        public ScreenView(_Screen screen, RctView view) {
12
-//            this.screen = screen;
13
-//            this.view = view;
14
-//        }
15
-//    }
16
-//
17
-//    private final Stack<ScreenView> mStack = new Stack<>();
18
-//    private final ReactInstanceManager mReactInstanceManager = RctManager.getInstance().getReactInstanceManager();
19
-//    private BaseReactActivity mReactActivity;
20
-//
21
-//    public ScreenStack(BaseReactActivity context) {
22
-//        super(context);
23
-//        init(context);
24
-//    }
25
-//
26
-//    public ScreenStack(Context context, AttributeSet attrs) {
27
-//        super(context, attrs);
28
-//        init(context);
29
-//    }
30
-//
31
-//    private void init(Context context) {
32
-//        mReactActivity = (BaseReactActivity) context;
33
-//        setLayoutTransition(new LayoutTransition());
34
-//    }
35
-//
36
-//    public void push(_Screen screen) {
37
-//        push(screen, null);
38
-//    }
39
-//
40
-//    public void push(_Screen screen, RctView.OnDisplayedListener onDisplayed) {
41
-//        RctView oldView = mStack.isEmpty() ? null : mStack.peek().view;
42
-//        RctView view = new RctView(mReactActivity, mReactInstanceManager, screen, onDisplayed);
43
-//        if (oldView != null) {
44
-//            addView(view, MATCH_PARENT, MATCH_PARENT);
45
-//
46
-//            oldView.onTemporallyRemovedFromScreen();
47
-//            getLayoutTransition().setStartDelay(LayoutTransition.DISAPPEARING, DISAPPEAR_ANIMATION_DELAY);
48
-//            removeView(oldView);
49
-//            getLayoutTransition().setStartDelay(LayoutTransition.DISAPPEARING, 0);
50
-//        } else {
51
-//            addView(view, MATCH_PARENT, MATCH_PARENT);
52
-//        }
53
-//        mStack.push(new ScreenView(screen, view));
54
-//    }
55
-//
56
-//    public _Screen pop() {
57
-//        if (mStack.isEmpty() || getStackSize() == 1) {
58
-//            return null;
59
-//        }
60
-//
61
-//        ScreenView popped = mStack.pop();
62
-//
63
-//        RctView newView = mStack.peek().view;
64
-//        addView(newView);
65
-//        newView.onReAddToScreen();
66
-//
67
-//        popped.view.onRemoveFromScreen();
68
-//        removeView(popped.view);
69
-//        return popped.screen;
70
-//    }
71
-//
72
-//    public _Screen popToRoot() {
73
-//        if (mStack.isEmpty() || getStackSize() <= 1) {
74
-//            return null;
75
-//        }
76
-//
77
-//        ScreenView oldScreenView = null;
78
-//        while (getStackSize() > 1) {
79
-//            ScreenView popped = mStack.pop();
80
-//            popped.view.onRemoveFromScreen();
81
-//            removeView(popped.view);
82
-//            if (oldScreenView == null) {
83
-//                oldScreenView = popped;
84
-//            }
85
-//        }
86
-//
87
-//        if (!mStack.isEmpty()) {
88
-//            addView(mStack.peek().view, 0);
89
-//        }
90
-//
91
-//        return oldScreenView != null ? oldScreenView.screen : null;
92
-//    }
93
-//
94
-//    public _Screen resetTo(_Screen screen) {
95
-//        return resetTo(screen, null);
96
-//    }
97
-//
98
-//    public _Screen resetTo(_Screen screen, RctView.OnDisplayedListener onDisplayed) {
99
-//        RctView view = new RctView(mReactActivity, mReactInstanceManager, screen, onDisplayed);
100
-//        addView(view, MATCH_PARENT, MATCH_PARENT);
101
-//
102
-//        ScreenView oldScreenView = null;
103
-//        if (!mStack.isEmpty()) {
104
-//            while (getStackSize() > 0) {
105
-//                ScreenView popped = mStack.pop();
106
-//                popped.view.onRemoveFromScreen();
107
-//                removeView(popped.view);
108
-//                if (oldScreenView == null) {
109
-//                    oldScreenView = popped;
110
-//                }
111
-//            }
112
-//        }
113
-//
114
-//        // Add screen to stack after it's clear
115
-//        mStack.push(new ScreenView(screen, view));
116
-//
117
-//        if (oldScreenView == null) {
118
-//            return null;
119
-//        }
120
-//
121
-//        return oldScreenView.screen;
122
-//    }
123
-//
124
-//    public boolean isEmpty() {
125
-//        return mStack.isEmpty();
126
-//    }
127
-//
128
-//    public int getStackSize() {
129
-//        return mStack.size();
130
-//    }
131
-//
132
-//    public _Screen peek() {
133
-//        return mStack.peek().screen;
134
-//    }
135
-//
136
-//    /**
137
-//     * Remove the ScreenStack from {@code parent} while preventing all child react views from getting unmounted
138
-//     */
139
-//    public void removeFromScreen(ViewGroup parent) {
140
-//        mStack.peek().view.onTemporallyRemovedFromScreen();
141
-//
142
-//        parent.removeView(this);
143
-//    }
144
-//
145
-//    /**
146
-//     * Add ScreenStack to {@code parent}
147
-//     */
148
-//    public void addToScreen(ViewGroup parent) {
149
-//        mStack.peek().view.onReAddToScreen();
150
-//
151
-//        parent.addView(this, new CoordinatorLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT));
152
-//    }
153
-//
154
-//    public void removeAllReactViews() {
155
-//        while (!mStack.empty()) {
156
-//            RctView view = mStack.pop().view;
157
-//            // Ensure view will be properly detached and unmounted
158
-//            view.onRemoveFromScreen();
159
-//            // Unmount the view
160
-//            view.detachFromScreen();
161
-//        }
162
-//        removeAllViews();
163
-//    }
164
-}