|
|
@@ -10,7 +10,9 @@ import android.support.annotation.Nullable;
|
|
|
import android.support.v4.view.ViewCompat;
|
|
|
import android.support.v4.view.ViewParentCompat;
|
|
|
import android.support.v7.widget.LinearLayoutManager;
|
|
|
+import android.support.v7.widget.LinearSmoothScroller;
|
|
|
import android.support.v7.widget.RecyclerView;
|
|
|
+import android.util.DisplayMetrics;
|
|
|
import android.view.LayoutInflater;
|
|
|
import android.view.View;
|
|
|
import android.view.ViewGroup;
|
|
|
@@ -101,12 +103,12 @@ public class MainFragment extends FragmentBase<MainPresenter> implements IMainVi
|
|
|
|
|
|
AnimatorManager.getInstance().add(indicatorAnimator);
|
|
|
|
|
|
- if (contentsRecyclerView.getOnFlingListener() == null) {
|
|
|
- int screenHeight = SuperModel.getInstance().getScreenHeight();
|
|
|
- int categoryHeight = ResourceUtil.getDimension(R.dimen.main_contents_category_height);
|
|
|
- snapper = new MainContentsSnapper(1000, statusBarHeight + (((screenHeight - statusBarHeight) - categoryHeight) >> 1));
|
|
|
- snapper.attachToRecyclerView(contentsRecyclerView);
|
|
|
- }
|
|
|
+// if (contentsRecyclerView.getOnFlingListener() == null) {
|
|
|
+// int screenHeight = SuperModel.getInstance().getScreenHeight();
|
|
|
+// int categoryHeight = ResourceUtil.getDimension(R.dimen.main_contents_category_height);
|
|
|
+// snapper = new MainContentsSnapper(1000, statusBarHeight + (((screenHeight - statusBarHeight) - categoryHeight) >> 1));
|
|
|
+// snapper.attachToRecyclerView(contentsRecyclerView);
|
|
|
+// }
|
|
|
|
|
|
debug();
|
|
|
|
|
|
@@ -177,8 +179,10 @@ public class MainFragment extends FragmentBase<MainPresenter> implements IMainVi
|
|
|
|
|
|
@Override
|
|
|
public void scrollToPosition(int index) {
|
|
|
- if (null != snapper) {
|
|
|
- snapper.smoothScrollToPosition(index);
|
|
|
+// if (null != snapper) {
|
|
|
+// snapper.smoothScrollToPosition(index);
|
|
|
+ if (null != contentsRecyclerView) {
|
|
|
+ contentsRecyclerView.smoothScrollToPosition(index);
|
|
|
|
|
|
// appbar 를 스크롤 시키기위해서 가상 이벤트를 전송한다.
|
|
|
// NestedScrollingChildHelper helper = new NestedScrollingChildHelper(contentsRecyclerView);
|
|
|
@@ -219,6 +223,24 @@ public class MainFragment extends FragmentBase<MainPresenter> implements IMainVi
|
|
|
protected int getExtraLayoutSpace(RecyclerView.State state) {
|
|
|
return contentsRecyclerView.getLayoutManager().getHeight() * 2;
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void smoothScrollToPosition(RecyclerView recyclerView, RecyclerView.State state, int position) {
|
|
|
+ RecyclerView.SmoothScroller smoothScroller = new LinearSmoothScroller(recyclerView.getContext()) {
|
|
|
+ @Override
|
|
|
+ protected float calculateSpeedPerPixel(DisplayMetrics displayMetrics) {
|
|
|
+ return 200f / displayMetrics.densityDpi;
|
|
|
+ }
|
|
|
+
|
|
|
+ // to screen center
|
|
|
+ @Override
|
|
|
+ public int calculateDtToFit(int viewStart, int viewEnd, int boxStart, int boxEnd, int snapPreference) {
|
|
|
+ return (boxStart + (boxEnd - boxStart) / 2) - (viewStart + (viewEnd - viewStart) / 2);
|
|
|
+ }
|
|
|
+ };
|
|
|
+ smoothScroller.setTargetPosition(position);
|
|
|
+ startSmoothScroll(smoothScroller);
|
|
|
+ }
|
|
|
});
|
|
|
contentsRecyclerView.setAdapter(adapter);
|
|
|
|
|
|
@@ -230,7 +252,6 @@ public class MainFragment extends FragmentBase<MainPresenter> implements IMainVi
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/***********************************
|
|
|
* debug
|
|
|
***********************************/
|