Kaynağa Gözat

generic stack

Daniel Zlotin 7 yıl önce
ebeveyn
işleme
f795aa4a6e

+ 17
- 0
lib/android/app/src/main/java/com/reactnativenavigation/utils/Stack.java Dosyayı Görüntüle

@@ -0,0 +1,17 @@
1
+package com.reactnativenavigation.utils;
2
+
3
+public interface Stack<E> extends Iterable<E> {
4
+
5
+	void push(E element);
6
+
7
+	E pop();
8
+
9
+	E peek();
10
+
11
+	boolean remove(E element);
12
+
13
+	int size();
14
+
15
+	boolean isEmpty();
16
+
17
+}

+ 6
- 0
lib/android/app/src/main/java/com/reactnativenavigation/utils/StackImpl.java Dosyayı Görüntüle

@@ -0,0 +1,6 @@
1
+package com.reactnativenavigation.utils;
2
+
3
+import java.util.ArrayDeque;
4
+
5
+public class StackImpl<E> extends ArrayDeque<E> implements Stack<E> {
6
+}

+ 4
- 3
lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/StackController.java Dosyayı Görüntüle

@@ -4,10 +4,11 @@ import android.app.Activity;
4 4
 import android.view.ViewGroup;
5 5
 import android.widget.FrameLayout;
6 6
 
7
-import java.util.ArrayDeque;
7
+import com.reactnativenavigation.utils.Stack;
8
+import com.reactnativenavigation.utils.StackImpl;
8 9
 
9 10
 public class StackController extends ViewController {
10
-	private ArrayDeque<ViewController> childControllers = new ArrayDeque<>();
11
+	private Stack<ViewController> childControllers = new StackImpl<>();
11 12
 
12 13
 	public StackController(final Activity activity) {
13 14
 		super(activity);
@@ -18,7 +19,7 @@ public class StackController extends ViewController {
18 19
 		return (ViewGroup) super.getView();
19 20
 	}
20 21
 
21
-	public ArrayDeque<ViewController> getChildControllers() {
22
+	public Stack<ViewController> getChildControllers() {
22 23
 		return childControllers;
23 24
 	}
24 25