Browse Source

[알림][Common] 노티 뷰페이저 변경중4

Hasemi 6 năm trước cách đây
mục cha
commit
7150f33307

+ 6 - 1
app/src/main/java/kr/co/zumo/app/lifeplus/view/screen/notification/NotiFragment.java

@@ -39,6 +39,7 @@ public class NotiFragment extends FragmentBase<NotiPresenter> implements INotiVi
   public static final int CATEGORY_KEY_BENEFIT = 2;
   private ViewPager viewPagerAlarm;
   private ActionButtonHelper actionButtonHelper;
+  private NotiViewPagerAdapter notiPagerAdapter;
 
   @Override
   protected View onAfterCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
@@ -60,8 +61,12 @@ public class NotiFragment extends FragmentBase<NotiPresenter> implements INotiVi
       @Override
       public void onPageSelected(int position) {
         presenter.onPageChanged(position);
+        notiPagerAdapter.setFocusPage(position);
+
       }
     });
+
+
   }
 
   @Override
@@ -100,7 +105,7 @@ public class NotiFragment extends FragmentBase<NotiPresenter> implements INotiVi
   }
 
   //private NotiPagerAdapter notiPagerAdapter;
-  private NotiViewPagerAdapter notiPagerAdapter;
+
 
   @Override
   public void drawList(List<NoticeBean> beans) {

+ 29 - 0
app/src/main/java/kr/co/zumo/app/lifeplus/view/screen/notification/NotiViewPagerAdapter.java

@@ -7,6 +7,7 @@ import android.support.annotation.Nullable;
 import android.support.v4.view.PagerAdapter;
 import android.support.v7.widget.LinearLayoutManager;
 import android.support.v7.widget.RecyclerView;
+import android.util.Log;
 import android.util.SparseArray;
 import android.view.LayoutInflater;
 import android.view.View;
@@ -74,6 +75,8 @@ public class NotiViewPagerAdapter extends PagerAdapter {
   @NonNull
   @Override
   public Object instantiateItem(@NonNull ViewGroup container, int position) {
+    Log.e("APP#  NotiViewPagerAdapter | instantiateItem, 77", "position |" + position);
+
     View view = inflater.inflate(R.layout.fragment_noti_list, container, false);
     recyclerView = view.findViewById(R.id.recycler_view_alarm_list);
     layoutNothing = view.findViewById(R.id.layout_nothing);
@@ -176,4 +179,30 @@ public class NotiViewPagerAdapter extends PagerAdapter {
 
     }
   }
+
+  public void setFocusPage(int position) {
+    Log.e("APP#  NotiViewPagerAdapter | setFocusPage, 185", "position |" + position);
+    Log.e("APP#  NotiViewPagerAdapter | setFocusPage, 186", "type |" + NoticeBean.getCategoryName(position));
+    if (null != notiListAdapter) {
+      if (NoticeBean.CATEGORY_NOTICE.equals(NoticeBean.getCategoryName(position))) {
+        // 공지 탭 보여질 때 첫 번째 아이템 확장
+        notiListAdapter.expand(0, true);
+      }
+      else if (NoticeBean.CATEGORY_ALL.equals(NoticeBean.getCategoryName(position))) {
+        // 전체 탭 모든 아이탬 축소
+        notiListAdapter.collapseDataAll();
+      }
+    }
+    else {
+      if (null != recyclerView) {
+        recyclerView.scrollToPosition(0);
+      }
+    }
+
+  }
+
+  @Override
+  public void destroyItem(@NonNull ViewGroup container, int position, @NonNull Object object) {
+    container.removeView((View) object);
+  }
 }