|
|
@@ -7,11 +7,15 @@ import android.animation.ObjectAnimator;
|
|
|
import android.os.Bundle;
|
|
|
import android.support.annotation.NonNull;
|
|
|
import android.support.annotation.Nullable;
|
|
|
+import android.support.v4.view.NestedScrollingParent2;
|
|
|
+import android.support.v4.view.ViewCompat;
|
|
|
+import android.support.v4.view.ViewParentCompat;
|
|
|
import android.support.v7.widget.LinearLayoutManager;
|
|
|
import android.support.v7.widget.RecyclerView;
|
|
|
import android.view.LayoutInflater;
|
|
|
import android.view.View;
|
|
|
import android.view.ViewGroup;
|
|
|
+import android.view.ViewParent;
|
|
|
import android.widget.ImageView;
|
|
|
import android.widget.TextView;
|
|
|
|
|
|
@@ -44,6 +48,7 @@ public class MainFragment extends FragmentBase<MainPresenter> implements IMainVi
|
|
|
private RecyclerView contentsRecyclerView;
|
|
|
private MainContentsAdapter adapter;
|
|
|
private PageIndicator indicator;
|
|
|
+ private MainContentsSnapper snapper;
|
|
|
|
|
|
private RecyclerView.OnScrollListener scrollListener = new RecyclerView.OnScrollListener() {
|
|
|
@Override
|
|
|
@@ -92,7 +97,7 @@ public class MainFragment extends FragmentBase<MainPresenter> implements IMainVi
|
|
|
AnimatorManager.getInstance().add(indicatorAnimator);
|
|
|
|
|
|
if (contentsRecyclerView.getOnFlingListener() == null) {
|
|
|
- MainContentsSnapper snapper = new MainContentsSnapper(1000, statusBarHeight - ResourceUtil.dpToPx(5) /* 리스트 간격보다 5dp 적다 */);
|
|
|
+ snapper = new MainContentsSnapper(1000, statusBarHeight - ResourceUtil.dpToPx(5) /* 리스트 간격보다 5dp 적다 */);
|
|
|
snapper.attachToRecyclerView(contentsRecyclerView);
|
|
|
}
|
|
|
|
|
|
@@ -246,6 +251,34 @@ public class MainFragment extends FragmentBase<MainPresenter> implements IMainVi
|
|
|
findViewById(R.id.button_pin_reset).setEnabled(StringUtil.isEmpty(SuperModel.getInstance().getPreferences().getEncryptedPin()));
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void scrollToPosition(int index) {
|
|
|
+ if (null != snapper) {
|
|
|
+ snapper.smoothScrollToPosition(index);
|
|
|
+
|
|
|
+ // appbar 를 스크롤 시키기위해서 가상 이벤트를 전송한다.
|
|
|
+// NestedScrollingChildHelper helper = new NestedScrollingChildHelper(contentsRecyclerView);
|
|
|
+//
|
|
|
+// helper.startNestedScroll(ViewCompat.SCROLL_AXIS_VERTICAL, ViewCompat.TYPE_NON_TOUCH);
|
|
|
+// helper.dispatchNestedPreScroll(0, 300, new int[2], new int[2], ViewCompat.TYPE_NON_TOUCH);
|
|
|
+
|
|
|
+ // appbar 를 스크롤 시키기위해서 가상 이벤트를 전송한다.
|
|
|
+ ViewParent p = contentsRecyclerView.getParent();
|
|
|
+ ViewParent layoutCoordinator = null;
|
|
|
+ while (p != null) {
|
|
|
+ if (p instanceof NestedScrollingParent2) {
|
|
|
+ layoutCoordinator = p;
|
|
|
+ }
|
|
|
+ p = p.getParent();
|
|
|
+ }
|
|
|
+
|
|
|
+ if (null != layoutCoordinator) {
|
|
|
+ ViewParentCompat.onStartNestedScroll(layoutCoordinator, contentsRecyclerView, contentsRecyclerView, ViewCompat.SCROLL_AXIS_VERTICAL, ViewCompat.TYPE_NON_TOUCH);
|
|
|
+ ViewParentCompat.onNestedPreScroll(layoutCoordinator, contentsRecyclerView, 0, 300, new int[2], ViewCompat.TYPE_NON_TOUCH);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
protected MainPresenter definePresenter() {
|
|
|
return new MainPresenter(getModel(MainModel.class), this);
|
|
|
@@ -259,13 +292,9 @@ public class MainFragment extends FragmentBase<MainPresenter> implements IMainVi
|
|
|
AnimatorManager.getInstance().start();
|
|
|
|
|
|
adapter = new MainContentsAdapter(getContext(), data, event -> {
|
|
|
- if (event.getEventId() == Event.SCROLL) {
|
|
|
- contentsRecyclerView.smoothScrollToPosition(1);
|
|
|
- }
|
|
|
- else {
|
|
|
- presenter.onEvent(event);
|
|
|
- }
|
|
|
+ presenter.onEvent(event);
|
|
|
});
|
|
|
+
|
|
|
contentsRecyclerView.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false));
|
|
|
contentsRecyclerView.setAdapter(adapter);
|
|
|
}
|