|
|
@@ -37,43 +37,8 @@ public class CustomListicleImageView extends ConstraintLayout {
|
|
|
private TextView textViewTitle;
|
|
|
private TextView textViewSubTitle;
|
|
|
private View layoutPager;
|
|
|
- private int prevIndex = 0;
|
|
|
- private RecyclerView.OnItemTouchListener touchEventListener = new RecyclerView.OnItemTouchListener() {
|
|
|
- @Override
|
|
|
- public boolean onInterceptTouchEvent(RecyclerView rv, MotionEvent e) {
|
|
|
- int action = e.getAction();
|
|
|
- switch (action) {
|
|
|
- case MotionEvent.ACTION_MOVE:
|
|
|
- case MotionEvent.ACTION_DOWN:
|
|
|
- case MotionEvent.ACTION_UP:
|
|
|
- rv.getParent().requestDisallowInterceptTouchEvent(true);
|
|
|
- break;
|
|
|
- default:
|
|
|
- break;
|
|
|
- }
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void onTouchEvent(RecyclerView rv, MotionEvent e) {
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) {
|
|
|
-
|
|
|
- }
|
|
|
- };
|
|
|
- private RecyclerView.OnScrollListener scrollEventListener = new RecyclerView.OnScrollListener() {
|
|
|
- @Override
|
|
|
- public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
|
|
|
- int index = ((LinearLayoutManager) recyclerView.getLayoutManager()).findFirstVisibleItemPosition();
|
|
|
- if (prevIndex != index) {
|
|
|
- prevIndex = index;
|
|
|
- textViewCurrentPage.setText(String.valueOf(index + 1));
|
|
|
- }
|
|
|
- }
|
|
|
- };
|
|
|
+ private int currentIndex = 0;
|
|
|
+ private int contentsLength = 0;
|
|
|
|
|
|
public CustomListicleImageView(Context context) {
|
|
|
super(context);
|
|
|
@@ -104,17 +69,54 @@ public class CustomListicleImageView extends ConstraintLayout {
|
|
|
init(context);
|
|
|
}
|
|
|
|
|
|
+ private RecyclerView.OnItemTouchListener touchEventListener = new RecyclerView.OnItemTouchListener() {
|
|
|
+ @Override
|
|
|
+ public boolean onInterceptTouchEvent(RecyclerView rv, MotionEvent e) {
|
|
|
+ int action = e.getAction();
|
|
|
+ switch (action) {
|
|
|
+ case MotionEvent.ACTION_MOVE:
|
|
|
+ case MotionEvent.ACTION_DOWN:
|
|
|
+ case MotionEvent.ACTION_UP:
|
|
|
+ /**
|
|
|
+ * todo index 가 0 일 때 좌-> 우 드래그 시 false, index 가 끝일 때 좌<-우 드래그 시 false
|
|
|
+ */
|
|
|
+ rv.getParent().requestDisallowInterceptTouchEvent(true);
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onTouchEvent(RecyclerView rv, MotionEvent e) {}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) {}
|
|
|
+ };
|
|
|
+
|
|
|
+ private RecyclerView.OnScrollListener scrollEventListener = new RecyclerView.OnScrollListener() {
|
|
|
+ @Override
|
|
|
+ public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
|
|
|
+ int index = ((LinearLayoutManager) recyclerView.getLayoutManager()).findFirstVisibleItemPosition();
|
|
|
+ if (currentIndex != index) {
|
|
|
+ currentIndex = index;
|
|
|
+ textViewCurrentPage.setText(String.valueOf(index + 1));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
public void init(Context context, int index, String title, String subTitle, List<ContentsDetailImageBean> contentsDetailImageBeans, IEventListener listener) {
|
|
|
|
|
|
textViewTitleNumber.setText(StringUtil.lpad(2, index));
|
|
|
textViewTitle.setText(title);
|
|
|
textViewSubTitle.setText(subTitle);
|
|
|
|
|
|
- int len = contentsDetailImageBeans.size();
|
|
|
- if (len > 1) {
|
|
|
+ contentsLength = contentsDetailImageBeans.size();
|
|
|
+ if (contentsLength > 1) {
|
|
|
layoutPager.setVisibility(View.VISIBLE);
|
|
|
textViewCurrentPage.setText("1");
|
|
|
- textViewTotalPage.setText(String.valueOf(len));
|
|
|
+ textViewTotalPage.setText(String.valueOf(contentsLength));
|
|
|
}
|
|
|
else {
|
|
|
layoutPager.setVisibility(View.GONE);
|
|
|
@@ -146,4 +148,5 @@ public class CustomListicleImageView extends ConstraintLayout {
|
|
|
recyclerView.removeOnItemTouchListener(touchEventListener);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
}
|