|
|
@@ -10,6 +10,7 @@ import android.util.AttributeSet;
|
|
|
import android.view.LayoutInflater;
|
|
|
import android.view.MotionEvent;
|
|
|
import android.view.View;
|
|
|
+import android.widget.ImageView;
|
|
|
import android.widget.TextView;
|
|
|
|
|
|
import java.util.List;
|
|
|
@@ -32,6 +33,9 @@ import kr.co.zumo.app.lifeplus.view.IEventListener;
|
|
|
public class CustomListicleImageView extends ConstraintLayout {
|
|
|
|
|
|
private CustomListicleImageViewAdapter adapter;
|
|
|
+ private ImageView imageViewPrePage;
|
|
|
+ private ImageView imageViewNextPage;
|
|
|
+
|
|
|
private RecyclerView recyclerView;
|
|
|
private TextView textViewCurrentPage;
|
|
|
private TextView textViewTotalPage;
|
|
|
@@ -39,9 +43,9 @@ public class CustomListicleImageView extends ConstraintLayout {
|
|
|
private TextView textViewTitle;
|
|
|
private TextView textViewSubTitle;
|
|
|
private View layoutPager;
|
|
|
+ private int index = 0;
|
|
|
private int currentIndex = 0;
|
|
|
private int contentsLength = 0;
|
|
|
- private boolean loading = false;
|
|
|
|
|
|
public CustomListicleImageView(Context context) {
|
|
|
super(context);
|
|
|
@@ -69,6 +73,9 @@ public class CustomListicleImageView extends ConstraintLayout {
|
|
|
textViewSubTitle = findViewById(R.id.text_view_sub_title);
|
|
|
layoutPager = findViewById(R.id.layout_pager);
|
|
|
|
|
|
+ imageViewPrePage = findViewById(R.id.image_view_pre_page);
|
|
|
+ imageViewNextPage = findViewById(R.id.image_view_next_page);
|
|
|
+
|
|
|
recyclerView = findViewById(R.id.recycler_view_listicle_view);
|
|
|
|
|
|
SnapHelper snapHelper = new PagerSnapHelper();
|
|
|
@@ -170,13 +177,9 @@ public class CustomListicleImageView extends ConstraintLayout {
|
|
|
private RecyclerView.OnScrollListener scrollEventListener = new RecyclerView.OnScrollListener() {
|
|
|
@Override
|
|
|
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
|
|
|
- int index = ((LinearLayoutManager) recyclerView.getLayoutManager()).findFirstVisibleItemPosition();
|
|
|
- index = index % contentsLength;
|
|
|
- if (currentIndex != index) {
|
|
|
- currentIndex = index;
|
|
|
- textViewCurrentPage.setText(String.valueOf(index + 1));
|
|
|
- }
|
|
|
-
|
|
|
+ index = ((LinearLayoutManager) recyclerView.getLayoutManager()).findFirstVisibleItemPosition();
|
|
|
+ currentIndex = index % contentsLength;
|
|
|
+ textViewCurrentPage.setText(String.valueOf(currentIndex + 1));
|
|
|
}
|
|
|
};
|
|
|
|
|
|
@@ -186,6 +189,7 @@ public class CustomListicleImageView extends ConstraintLayout {
|
|
|
textViewTitle.setText(title);
|
|
|
textViewSubTitle.setText(subTitle);
|
|
|
|
|
|
+
|
|
|
contentsLength = contentsDetailImageBeans.size();
|
|
|
if (contentsLength > 1) {
|
|
|
layoutPager.setVisibility(View.VISIBLE);
|
|
|
@@ -211,6 +215,8 @@ public class CustomListicleImageView extends ConstraintLayout {
|
|
|
recyclerView.addOnItemTouchListener(touchEventListener);
|
|
|
recyclerView.addOnScrollListener(scrollEventListener);
|
|
|
recyclerView.scrollToPosition(contentsLength * 10000);
|
|
|
+ imageViewPrePage.setOnClickListener(view -> {onClickPrePage();});
|
|
|
+ imageViewNextPage.setOnClickListener(view -> {onClickNextPage();});
|
|
|
}
|
|
|
|
|
|
public void dispose() {
|
|
|
@@ -220,5 +226,12 @@ public class CustomListicleImageView extends ConstraintLayout {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private void onClickPrePage() {
|
|
|
+ recyclerView.smoothScrollToPosition(index - 1);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void onClickNextPage() {
|
|
|
+ recyclerView.smoothScrollToPosition(index + 1);
|
|
|
+ }
|
|
|
|
|
|
}
|