Github user saketkumar95 commented on a diff in the pull request:
https://github.com/apache/incubator-taverna-mobile/pull/66#discussion_r173622568
--- Diff:
app/src/main/java/org/apache/taverna/mobile/ui/tutorial/TutorialActivity.java
---
@@ -0,0 +1,204 @@
+package org.apache.taverna.mobile.ui.tutorial;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import android.content.Context;
+import android.content.Intent;
+import android.os.Build;
+import android.os.Bundle;
+import android.support.v4.view.PagerAdapter;
+import android.support.v4.view.ViewPager;
+import android.support.v7.app.AppCompatActivity;
+import android.text.Html;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.Button;
+import android.widget.LinearLayout;
+import android.widget.TextView;
+
+import org.apache.taverna.mobile.R;
+import org.apache.taverna.mobile.data.local.PreferencesHelper;
+import org.apache.taverna.mobile.ui.FlashScreenActivity;
+
+import butterknife.BindView;
+import butterknife.ButterKnife;
+import butterknife.OnClick;
+
+
+public class TutorialActivity extends AppCompatActivity {
+
+ @BindView(R.id.view_pager)
+ ViewPager viewPager;
+
+ @BindView(R.id.layoutDots)
+ LinearLayout dotsLayout;
+
+ @BindView(R.id.btn_skip)
+ Button bSkip;
+
+ @BindView(R.id.btn_next)
+ Button bNext;
+
+
+ ViewPagerAdapter viewPagerAdapter;
+ TextView[] dots;
+ int[] layouts;
+ PreferencesHelper preferencesHelper;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ preferencesHelper = new PreferencesHelper(this);
+ if (!preferencesHelper.isFirstTimeLaunch()) {
+ launchFlashScreen();
+ finish();
+ }
+
+ setContentView(R.layout.activity_tutorial);
+
+ ButterKnife.bind(this);
+
+
+ if (Build.VERSION.SDK_INT >= 21) {
+ getWindow().getDecorView()
+
.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE
+ | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
+ }
+
+ layouts = new int[]{
+ R.layout.tutorial_slide1,
+ R.layout.tutorial_slide2,
+ R.layout.tutorial_slide3,
+ R.layout.tutorial_slide4};
+
+ addBottomDots(0);
+
+ viewPagerAdapter = new ViewPagerAdapter();
+ viewPager.setAdapter(viewPagerAdapter);
+ viewPager.addOnPageChangeListener(viewPagerPageChangeListener);
+
+ }
+
+ @OnClick(R.id.btn_skip)
+ public void skipClick(View v) {
+ launchFlashScreen();
+ }
+
+ @OnClick(R.id.btn_next)
+ public void nextClick(View v) {
+ int current = getItem(+1);
+ if (current < layouts.length) {
+ viewPager.setCurrentItem(current);
+ } else {
+ launchFlashScreen();
+ }
+ }
+
+ public void addBottomDots(int currentPage) {
+ dots = new TextView[layouts.length];
+
+ int[] colorsActive =
getResources().getIntArray(R.array.array_dot_active);
+ int[] colorsInactive =
getResources().getIntArray(R.array.array_dot_inactive);
+
+ dotsLayout.removeAllViews();
+ for (int i = 0; i < dots.length; i++) {
+ dots[i] = new TextView(this);
+ dots[i].setText(Html.fromHtml("•"));
+ dots[i].setTextSize(35);
+ dots[i].setTextColor(colorsInactive[currentPage]);
+ dotsLayout.addView(dots[i]);
+ }
+
+ if (dots.length > 0)
+ dots[currentPage].setTextColor(colorsActive[currentPage]);
+ }
+
+ public int getItem(int i) {
+ return viewPager.getCurrentItem() + i;
+ }
+
+ public void launchFlashScreen() {
+ preferencesHelper.setFirstTimeLaunch(false);
+ startActivity(new Intent(TutorialActivity.this,
FlashScreenActivity.class));
+ finish();
+ }
+
+ ViewPager.OnPageChangeListener viewPagerPageChangeListener =
--- End diff --
I tried this but we need to have the selected page item in
`viewpager.addOnPageChangeListener`
---