|
|
@@ -9,6 +9,7 @@ import android.support.annotation.Nullable;
|
|
|
import android.support.constraint.ConstraintLayout;
|
|
|
import android.support.v7.widget.LinearLayoutManager;
|
|
|
import android.support.v7.widget.LinearSmoothScroller;
|
|
|
+import android.support.v7.widget.OrientationHelper;
|
|
|
import android.support.v7.widget.RecyclerView;
|
|
|
import android.util.DisplayMetrics;
|
|
|
import android.util.Log;
|
|
|
@@ -40,10 +41,12 @@ import kr.co.zumo.app.lifeplus.view.screen.FragmentBase;
|
|
|
*/
|
|
|
public class BookMarkListFragment extends FragmentBase<BookMarkListPresenter> implements IBookMarkListView {
|
|
|
|
|
|
- private RecyclerView recyclerViewBookMarkList;
|
|
|
+ private RecyclerView recyclerView;
|
|
|
private BookMarkListAdapter bookMarkListAdapter;
|
|
|
private CustomSpinner customSpinnerBookmark;
|
|
|
private ConstraintLayout layoutCategory;
|
|
|
+ private LinearLayoutManager layoutManager;
|
|
|
+
|
|
|
boolean isFirst = true;
|
|
|
|
|
|
@Override
|
|
|
@@ -53,8 +56,8 @@ public class BookMarkListFragment extends FragmentBase<BookMarkListPresenter> im
|
|
|
|
|
|
@Override
|
|
|
protected void onAfterActivityCreated(Bundle savedInstanceState) {
|
|
|
- recyclerViewBookMarkList = findViewById(R.id.recycler_view_book_mark_list);
|
|
|
- recyclerViewBookMarkList.addItemDecoration(new RecyclerView.ItemDecoration() {
|
|
|
+ recyclerView = findViewById(R.id.recycler_view_book_mark_list);
|
|
|
+ recyclerView.addItemDecoration(new RecyclerView.ItemDecoration() {
|
|
|
// TODO: 클래스 분리 필요함
|
|
|
@Override
|
|
|
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
|
|
|
@@ -127,7 +130,7 @@ public class BookMarkListFragment extends FragmentBase<BookMarkListPresenter> im
|
|
|
presenter.onEvent(event);
|
|
|
});
|
|
|
|
|
|
- recyclerViewBookMarkList.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false) {
|
|
|
+ layoutManager = new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false) {
|
|
|
@Override
|
|
|
public void smoothScrollToPosition(RecyclerView recyclerView, RecyclerView.State state, int position) {
|
|
|
|
|
|
@@ -142,13 +145,30 @@ public class BookMarkListFragment extends FragmentBase<BookMarkListPresenter> im
|
|
|
protected float calculateSpeedPerPixel(DisplayMetrics displayMetrics) {
|
|
|
return 50f / displayMetrics.densityDpi;
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void onTargetFound(View targetView, RecyclerView.State state, RecyclerView.SmoothScroller.Action action) {
|
|
|
+ OrientationHelper helper = OrientationHelper.createVerticalHelper(layoutManager);
|
|
|
+ final int dy = helper.getDecoratedStart(targetView);
|
|
|
+ // fixme 0 위치가 미묘하게 다르게 처리된다.
|
|
|
+ //final int dy = layoutManager.getDecoratedTop(targetView);
|
|
|
+
|
|
|
+ Log.w("APP# BookMarkListFragment | onTargetFound", "|" + "dy: " + dy);
|
|
|
+ final int time = calculateTimeForDeceleration(dy);
|
|
|
+ if (time > 0) {
|
|
|
+ int newTime = Math.max(time, 240);
|
|
|
+ action.update(0, dy, newTime, mDecelerateInterpolator);
|
|
|
+ }
|
|
|
+ }
|
|
|
};
|
|
|
|
|
|
linearSmoothScroller.setTargetPosition(position);
|
|
|
startSmoothScroll(linearSmoothScroller);
|
|
|
}
|
|
|
- });
|
|
|
- recyclerViewBookMarkList.setAdapter(bookMarkListAdapter);
|
|
|
+ };
|
|
|
+ recyclerView.setLayoutManager(layoutManager);
|
|
|
+ recyclerView.setAdapter(bookMarkListAdapter);
|
|
|
+
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -202,11 +222,6 @@ public class BookMarkListFragment extends FragmentBase<BookMarkListPresenter> im
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- public void scrollToAnchor(int itemIndex) {
|
|
|
- recyclerViewBookMarkList.smoothScrollToPosition(itemIndex);
|
|
|
- }
|
|
|
-
|
|
|
@Override
|
|
|
public void setCategoryFocus(int categoryIndex) {
|
|
|
int len = 5;
|
|
|
@@ -224,5 +239,8 @@ public class BookMarkListFragment extends FragmentBase<BookMarkListPresenter> im
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+ @Override
|
|
|
+ public void scrollToAnchor(int itemIndex) {
|
|
|
+ recyclerView.smoothScrollToPosition(itemIndex);
|
|
|
+ }
|
|
|
}
|