|
@@ -6,7 +6,6 @@ import android.support.v4.view.ViewPager;
|
6
|
6
|
import android.support.v7.app.AppCompatActivity;
|
7
|
7
|
import android.view.View;
|
8
|
8
|
import android.view.ViewGroup;
|
9
|
|
-import android.widget.RelativeLayout;
|
10
|
9
|
|
11
|
10
|
import com.reactnativenavigation.params.ScreenParams;
|
12
|
11
|
import com.reactnativenavigation.params.TopTabParams;
|
|
@@ -30,15 +29,23 @@ public class ViewPagerScreen extends Screen {
|
30
|
29
|
@Override
|
31
|
30
|
protected void createContent() {
|
32
|
31
|
TabLayout tabLayout = topBar.initTabs();
|
33
|
|
- contentViews = new ArrayList<>();
|
|
32
|
+ createViewPager();
|
|
33
|
+ addPages();
|
|
34
|
+ setupViewPager(tabLayout);
|
|
35
|
+ }
|
|
36
|
+
|
|
37
|
+ private void createViewPager() {
|
34
|
38
|
viewPager = new ViewPager(getContext());
|
35
|
39
|
viewPager.setOffscreenPageLimit(99);
|
36
|
|
- RelativeLayout.LayoutParams lp = new LayoutParams(MATCH_PARENT, MATCH_PARENT);
|
|
40
|
+ LayoutParams lp = new LayoutParams(MATCH_PARENT, MATCH_PARENT);
|
37
|
41
|
if (screenParams.styleParams.drawScreenBelowTopBar) {
|
38
|
42
|
lp.addRule(BELOW, topBar.getId());
|
39
|
43
|
}
|
40
|
44
|
addView(viewPager, lp);
|
|
45
|
+ }
|
41
|
46
|
|
|
47
|
+ private void addPages() {
|
|
48
|
+ contentViews = new ArrayList<>();
|
42
|
49
|
for (TopTabParams topTabParam : screenParams.topTabParams) {
|
43
|
50
|
ContentView contentView = new ContentView(getContext(),
|
44
|
51
|
topTabParam.screenId,
|
|
@@ -47,7 +54,9 @@ public class ViewPagerScreen extends Screen {
|
47
|
54
|
addContent(contentView);
|
48
|
55
|
contentViews.add(contentView);
|
49
|
56
|
}
|
|
57
|
+ }
|
50
|
58
|
|
|
59
|
+ private void setupViewPager(TabLayout tabLayout) {
|
51
|
60
|
ContentViewPagerAdapter adapter =
|
52
|
61
|
new ContentViewPagerAdapter(viewPager, contentViews, screenParams.topTabParams);
|
53
|
62
|
viewPager.setAdapter(adapter);
|