Pārlūkot izejas kodu

Merge branch 'develop' of https://github.com/swict/LifePlusAndroid into develop

# Conflicts:
#	app/src/main/java/kr/co/zumo/app/lifeplus/view/presenter/Event.java
hyodong.min 7 gadi atpakaļ
vecāks
revīzija
480aef1c90

+ 0 - 106
app/src/main/java/kr/co/zumo/app/lifeplus/view/fragment/SectionsPagerAdapter.java

@@ -1,106 +0,0 @@
-package kr.co.zumo.app.lifeplus.view.fragment;
-
-import android.os.Bundle;
-import android.support.v4.app.Fragment;
-import android.support.v4.app.FragmentManager;
-import android.support.v4.app.FragmentPagerAdapter;
-import android.util.Log;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.TextView;
-
-import kr.co.zumo.app.R;
-import kr.co.zumo.app.lifeplus.view.presenter.Event;
-import kr.co.zumo.app.lifeplus.view.presenter.Presenter;
-
-/**
- * SectionsPagerAdapter
- * <pre>
- *  tutorial viewpager adapter 클래스
- * </pre>
- *
- * @author 하세미
- * @version 1.0
- * @history 하세미   [2018-09-18]   [최초 작성]
- * @since 2018-09-18
- */
-public class SectionsPagerAdapter extends FragmentPagerAdapter {
-
-  private Presenter presenter;
-
-  public SectionsPagerAdapter(FragmentManager fm) {
-    super(fm);
-  }
-
-  public void setPresenter(Presenter presenter){
-    this.presenter = presenter;
-  }
-  @Override
-  public Fragment getItem(int position) {
-    return PlaceholderFragment.newInstance((position + 1), presenter);
-  }
-
-  @Override
-  public int getCount() {
-    return 5;
-  }
-
-  public static class PlaceholderFragment extends Fragment {
-
-    private Presenter presenter;
-    private static final String ARG_SECTION_NUMBER = "section_number";
-
-    public PlaceholderFragment() {
-    }
-
-    /**
-     * Returns a new instance of this fragment for the given section
-     * number.
-     */
-    public static PlaceholderFragment newInstance(int sectionNumber, Presenter presenter) {
-      PlaceholderFragment fragment = new PlaceholderFragment();
-      Bundle args = new Bundle();
-      args.putInt(ARG_SECTION_NUMBER, sectionNumber);
-      fragment.setArguments(args);
-      fragment.setPresenter(presenter);
-      return fragment;
-    }
-
-    public void setPresenter(Presenter presenter){
-      this.presenter = presenter;
-
-    }
-
-    @Override
-    public View onCreateView(LayoutInflater inflater, ViewGroup container,
-                             Bundle savedInstanceState) {
-      View rootView = inflater.inflate(R.layout.tutorial_layout2, container, false);
-      int count = getArguments().getInt(ARG_SECTION_NUMBER);
-      Log.e("APP#  PlaceholderFragment | onCreateView", "|" + count);
-
-      TextView button1Tutorial = (TextView) rootView.findViewById(R.id.button1_tutorial);
-      TextView button2Tutorial = (TextView) rootView.findViewById(R.id.button2_tutorial);
-
-      TextView textViewTutorial = (TextView) rootView.findViewById(R.id.text_view_tutorial);
-      textViewTutorial.setText("Tutorial " + getArguments().getInt(ARG_SECTION_NUMBER));
-
-      if (count == 5) {
-        button1Tutorial.setVisibility(View.INVISIBLE);
-        button2Tutorial.setText("닫기");
-      }
-
-      button1Tutorial.setOnClickListener(new View.OnClickListener() {
-        @Override
-        public void onClick(View view) {
-          Log.e("APP#  PlaceholderFragment | onClick", "|" + "onClick");
-          presenter.onEvent(Event.TUTORIAL_CLOSE);
-        }
-      });
-
-      return rootView;
-    }
-  }
-
-}
-

+ 11 - 13
app/src/main/java/kr/co/zumo/app/lifeplus/view/fragment/TutorialFragment.java

@@ -1,4 +1,4 @@
-package kr.co.zumo.app.lifeplus.view.fragment;
+package kr.co.zumo.app.lifeplus.view.fragment.tutorial;
 
 import android.os.Bundle;
 import android.support.annotation.NonNull;
@@ -13,31 +13,29 @@ import kr.co.zumo.app.R;
 import kr.co.zumo.app.lifeplus.manager.ActionBarManager;
 import kr.co.zumo.app.lifeplus.supervisor.FragmentChanger;
 import kr.co.zumo.app.lifeplus.supervisor.ScreenChangerHelper;
+import kr.co.zumo.app.lifeplus.view.fragment.FragmentBase;
 import kr.co.zumo.app.lifeplus.view.fragment.factory.BasicFragmentFactory;
 import kr.co.zumo.app.lifeplus.view.presenter.ITutorialView;
 import kr.co.zumo.app.lifeplus.view.presenter.Presenter;
-import kr.co.zumo.app.lifeplus.view.presenter.TutorialPresenter;
+import kr.co.zumo.app.lifeplus.view.presenter.tutorial.TutorialPresenter;
 
 public class TutorialFragment extends FragmentBase<TutorialPresenter> implements ITutorialView {
 
-  private SectionsPagerAdapter sectionsPagerAdapter;
+  private TutorialPagerAdapter tutorialPagerAdapter;
   private ViewPager viewPager;
   private TabLayout tabLayout;
-
+  private View view;
 
   @Nullable
   @Override
   public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
-
-    View view = inflater.inflate(R.layout.activity_tutorial, container, false);
+    view = inflater.inflate(R.layout.fragment_tutorial, container, false);
     viewPager = (ViewPager) view.findViewById(R.id.tutorial_view_pager);
     tabLayout = (TabLayout) view.findViewById(R.id.tutorial_tab_layout);
-
     return view;
   }
 
 
-
   @Override
   protected Presenter definePresenter() {
     ScreenChangerHelper helper = ScreenChangerHelper.getInstance();
@@ -66,18 +64,18 @@ public class TutorialFragment extends FragmentBase<TutorialPresenter> implements
 
   @Override
   protected void draw() {
-    sectionsPagerAdapter = new SectionsPagerAdapter(getFragmentManager());
-    sectionsPagerAdapter.setPresenter(presenter);
+    tutorialPagerAdapter = new TutorialPagerAdapter(getActivity());
+    tutorialPagerAdapter.setPresenter(presenter);
     tabLayout.setupWithViewPager(viewPager, true);
-    viewPager.setAdapter(sectionsPagerAdapter);
+    viewPager.setAdapter(tutorialPagerAdapter);
   }
 
   /**
    * 건너뛰기 클릭시 main page 이동
    */
   @Override
-  public void onJumpMainButtonClick() {
-
+  public void onNextButtonClick() {
+    viewPager.setCurrentItem(viewPager.getCurrentItem() + 1, true);
   }
 
 }

+ 132 - 0
app/src/main/java/kr/co/zumo/app/lifeplus/view/fragment/tutorial/TutorialPagerAdapter.java

@@ -0,0 +1,132 @@
+package kr.co.zumo.app.lifeplus.view.fragment.tutorial;
+
+import android.content.Context;
+import android.support.annotation.NonNull;
+import android.support.v4.view.PagerAdapter;
+import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.TextView;
+
+import kr.co.zumo.app.R;
+import kr.co.zumo.app.lifeplus.view.presenter.Event;
+import kr.co.zumo.app.lifeplus.view.presenter.Presenter;
+
+/**
+ * TutorialPagerAdapter
+ * <pre>
+ *  tutorial viewpager adapter 클래스
+ * </pre>
+ *
+ * @author 하세미
+ * @version 1.0
+ * @history 하세미   [2018-09-18]   [최초 작성]
+ * @since 2018-09-18
+ */
+public class TutorialPagerAdapter extends PagerAdapter {
+
+  private Presenter presenter;
+  private LayoutInflater layoutInflater;
+  private static final int VIEW_COUNT = 5;
+
+  /**
+   * event 처리를 위한 presenter 설정
+   *
+   * @param presenter
+   */
+  public void setPresenter(Presenter presenter) {
+    this.presenter = presenter;
+  }
+
+  public TutorialPagerAdapter(Context context) {
+    layoutInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+  }
+
+  /**
+   * viewPager의 item 갯수 return
+   *
+   * @return
+   */
+  @Override
+  public int getCount() {
+    return VIEW_COUNT;
+  }
+
+  /**
+   * instantiateItem에서 생성한 객체를 이용할 것인지 여부 반환
+   *
+   * @param view
+   * @param object
+   * @return
+   */
+  @Override
+  public boolean isViewFromObject(@NonNull View view, @NonNull Object object) {
+    return view == object;
+
+  }
+
+
+  /**
+   * viewPager에서 사용할 View 생성 및 등록
+   *
+   * @param container item이 포함되는 view
+   * @param position  item 선택값
+   * @return
+   */
+  @NonNull
+  @Override
+  public Object instantiateItem(@NonNull ViewGroup container, int position) {
+
+    Log.e("APP#  TutorialPagerAdapter | instantiateItem", "|" + "position" + position);
+    View view = layoutInflater.inflate(R.layout.tutorial_layout, container, false);
+    TextView buttonTutorial1 = (TextView) view.findViewById(R.id.button1_tutorial);
+    TextView buttonTutorial2 = (TextView) view.findViewById(R.id.button2_tutorial);
+
+    if (position == 4) {
+      buttonTutorial1.setVisibility(View.INVISIBLE);
+      buttonTutorial2.setText("닫기");
+    }
+
+    buttonTutorial1.setOnClickListener(new View.OnClickListener() {
+      @Override
+      public void onClick(View view) {
+        presenter.onEvent(Event.TUTORIAL_CLOSE);
+      }
+    });
+
+    if (buttonTutorial2.getText().equals("다음")) {
+      buttonTutorial2.setOnClickListener(new View.OnClickListener() {
+        @Override
+        public void onClick(View view) {
+          presenter.onEvent(Event.TUTORIAL_NEXT);
+        }
+      });
+    }
+    else {
+      buttonTutorial2.setOnClickListener(new View.OnClickListener() {
+        @Override
+        public void onClick(View view) {
+          presenter.onEvent(Event.TUTORIAL_CLOSE);
+        }
+      });
+    }
+
+    container.addView(view);
+    return view;
+  }
+
+  /**
+   * 화면에 보이지 않는 view 삭제
+   *
+   * @param container
+   * @param position
+   * @param object
+   */
+  @Override
+  public void destroyItem(@NonNull ViewGroup container, int position, @NonNull Object object) {
+    container.removeView((View) object);
+  }
+
+}
+

+ 2 - 1
app/src/main/java/kr/co/zumo/app/lifeplus/view/presenter/Event.java

@@ -23,7 +23,8 @@ public class Event {
   public static final int UNCHECK = 5;
   public static final int JOINED = 7;
   public static final int TUTORIAL_CLOSE = 11;
-  public static final int RETRY = 12;
+  public static final int TUTORIAL_NEXT = 12;
+  public static final int RETRY = 13;
 
   public static final int HOLDER_AGREE_CHANGED = 200;
   public static final int HOLDER_CREATED = 201;

+ 1 - 1
app/src/main/java/kr/co/zumo/app/lifeplus/view/presenter/ITutorialView.java

@@ -12,6 +12,6 @@ package kr.co.zumo.app.lifeplus.view.presenter;
  */
 public interface ITutorialView extends IPresenterView{
 
-  void onJumpMainButtonClick();
+  void onNextButtonClick();
 
 }

+ 12 - 3
app/src/main/java/kr/co/zumo/app/lifeplus/view/presenter/TutorialPresenter.java

@@ -1,10 +1,13 @@
-package kr.co.zumo.app.lifeplus.view.presenter;
+package kr.co.zumo.app.lifeplus.view.presenter.tutorial;
 
 import android.support.annotation.Nullable;
-import android.util.Log;
 
 import kr.co.zumo.app.lifeplus.supervisor.ScreenChanger;
 import kr.co.zumo.app.lifeplus.supervisor.ScreenID;
+import kr.co.zumo.app.lifeplus.view.fragment.tutorial.TutorialFragment;
+import kr.co.zumo.app.lifeplus.view.presenter.Event;
+import kr.co.zumo.app.lifeplus.view.presenter.ITutorialView;
+import kr.co.zumo.app.lifeplus.view.presenter.Presenter;
 
 /**
  * TutorialPresenter
@@ -19,6 +22,8 @@ import kr.co.zumo.app.lifeplus.supervisor.ScreenID;
  */
 public class TutorialPresenter extends Presenter<ITutorialView> {
 
+  private TutorialFragment fragment = new TutorialFragment();
+
   public TutorialPresenter(ScreenChanger screenChanger, ITutorialView view) {
     super(screenChanger, view);
   }
@@ -37,9 +42,11 @@ public class TutorialPresenter extends Presenter<ITutorialView> {
   protected void performOnEvent(int eventId, int intValue, @Nullable String stringValue) {
     switch (eventId) {
       case Event.TUTORIAL_CLOSE:
-        Log.e("APP#  TutorialPresenter | onEvent", "|" + "tutorial close");
         exitTo(ScreenID.MAIN);
         break;
+      case Event.TUTORIAL_NEXT:
+        view.onNextButtonClick();
+        break;
       default:
         break;
     }
@@ -64,4 +71,6 @@ public class TutorialPresenter extends Presenter<ITutorialView> {
   public void exitByBackKey() {
 
   }
+
+
 }

+ 2 - 3
app/src/main/res/layout/activity_tutorial.xml

@@ -7,7 +7,7 @@
   android:layout_width="match_parent"
   android:layout_height="match_parent"
   android:fitsSystemWindows="true"
-  tools:context=".lifeplus.view.fragment.TutorialFragment">
+  tools:context=".lifeplus.view.fragment.tutorial.TutorialFragment">
 
   <android.support.v4.view.ViewPager
     android:id="@+id/tutorial_view_pager"
@@ -24,7 +24,6 @@
     android:layout_alignParentTop="true"
     app:tabGravity="center"
     app:tabIndicatorHeight="0dp"
-    app:tabBackground="@drawable/tab_selector"
-    />
+    app:tabBackground="@drawable/tab_selector"/>
 
 </RelativeLayout>

app/src/main/res/layout/tutorial_layout2.xml → app/src/main/res/layout/tutorial_layout.xml


+ 0 - 73
app/src/main/res/layout/tutorial_layout1.xml

@@ -1,73 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout
-  xmlns:android="http://schemas.android.com/apk/res/android"
-  xmlns:app="http://schemas.android.com/apk/res-auto"
-  xmlns:tools="http://schemas.android.com/tools"
-  android:layout_width="match_parent"
-  android:layout_height="match_parent"
-  android:orientation="vertical">
-
-  <LinearLayout
-    android:layout_width="match_parent"
-    android:layout_height="wrap_content"
-    android:layout_marginTop="15dp"
-    android:orientation="vertical">
-
-    <TextView
-      android:layout_width="match_parent"
-      android:layout_height="wrap_content"
-      android:text="@string/tutorial_title"
-      android:textAlignment="center"
-      android:textSize="20dp"
-      />
-
-    <ImageView
-      android:layout_width="match_parent"
-      android:layout_height="wrap_content"
-      android:src="@drawable/cancel"
-
-      />
-  </LinearLayout>
-
-  <android.support.constraint.ConstraintLayout
-    android:layout_width="match_parent"
-    android:layout_height="wrap_content">
-
-    <ImageView
-      android:id="@+id/imageView"
-      android:layout_width="388dp"
-      android:layout_height="401dp"
-      app:layout_constraintEnd_toEndOf="parent"
-      app:layout_constraintStart_toStartOf="parent"
-      app:layout_constraintTop_toTopOf="parent"
-      app:srcCompat="@android:color/darker_gray"/>
-
-    <TextView
-      android:id="@+id/textView3"
-      android:layout_width="wrap_content"
-      android:layout_height="wrap_content"
-      android:layout_marginBottom="8dp"
-      android:layout_marginEnd="8dp"
-      android:layout_marginStart="8dp"
-      android:layout_marginTop="8dp"
-      android:text="@string/tutorial_start"
-      android:textAlignment="center"
-      app:layout_constraintBottom_toTopOf="@+id/button"
-      app:layout_constraintEnd_toEndOf="@+id/imageView"
-      app:layout_constraintHorizontal_bias="0.501"
-      app:layout_constraintStart_toStartOf="@+id/imageView"
-      app:layout_constraintTop_toTopOf="@+id/imageView"
-      app:layout_constraintVertical_bias="1.0"/>
-
-    <Button
-      android:id="@+id/button"
-      android:layout_width="wrap_content"
-      android:layout_height="wrap_content"
-      android:text="@string/tutorial_button_message"
-      app:layout_constraintBottom_toBottomOf="parent"
-      app:layout_constraintEnd_toEndOf="parent"
-      app:layout_constraintStart_toStartOf="parent"
-      app:layout_constraintTop_toTopOf="parent"
-      app:layout_constraintVertical_bias="0.859"/>
-  </android.support.constraint.ConstraintLayout>
-</LinearLayout>

+ 1 - 1
app/src/main/res/menu/menu_tutorial.xml

@@ -1,7 +1,7 @@
 <menu xmlns:android="http://schemas.android.com/apk/res/android"
       xmlns:app="http://schemas.android.com/apk/res-auto"
       xmlns:tools="http://schemas.android.com/tools"
-      tools:context="kr.co.zumo.app.lifeplus.view.fragment.TutorialFragment">
+      tools:context="kr.co.zumo.app.lifeplus.view.fragment.tutorial.TutorialFragment">
   <item
     android:id="@+id/action_settings"
     android:orderInCategory="100"