|
|
@@ -42,6 +42,9 @@ public class MainCategoryContentsImageView extends MainCategoryContentsView {
|
|
|
private TextView textBig;
|
|
|
private TextView textSmall;
|
|
|
private ImageView imageView;
|
|
|
+ private View mask0;
|
|
|
+ private View mask1;
|
|
|
+ private View mask2;
|
|
|
|
|
|
private int maskWidth;
|
|
|
private int maskHeight;
|
|
|
@@ -51,6 +54,7 @@ public class MainCategoryContentsImageView extends MainCategoryContentsView {
|
|
|
private int imageHeight;
|
|
|
private int screenWidth;
|
|
|
private int screenHeight;
|
|
|
+ private int spaceWidth;
|
|
|
|
|
|
public MainCategoryContentsImageView(Context context, View view) {
|
|
|
super(context, view);
|
|
|
@@ -217,7 +221,7 @@ public class MainCategoryContentsImageView extends MainCategoryContentsView {
|
|
|
/**
|
|
|
* 이미지가 스크린보다 클 때
|
|
|
*/
|
|
|
- ratio = (float) (maskHeight + x) / (maskHeight + screenHeight);
|
|
|
+ ratio = (float) (maskHeight + y) / (maskHeight + screenHeight);
|
|
|
ty = -((int) ((imageHeight + maskHeight) * ratio)) + maskHeight;
|
|
|
|
|
|
}
|
|
|
@@ -229,15 +233,51 @@ public class MainCategoryContentsImageView extends MainCategoryContentsView {
|
|
|
|
|
|
imageView.setImageMatrix(matrix);
|
|
|
}
|
|
|
+
|
|
|
+ x = (int) itemView.getX();
|
|
|
+ if (x > -maskWidth && x < screenWidth) { // holder 가 표시되는 부분에서만 계산
|
|
|
+ // modify itemView x
|
|
|
+ cx = x;
|
|
|
+ ratio = (float) -cx / maskWidth;
|
|
|
+
|
|
|
+ if (ratio > 1) {
|
|
|
+ ratio = 1;
|
|
|
+ }
|
|
|
+ else if (ratio < 0) {
|
|
|
+ ratio = 0;
|
|
|
+ }
|
|
|
+ tx = (int) -(spaceWidth * ratio);
|
|
|
+ imageView.setX(tx);
|
|
|
+ mask0.setX(tx);
|
|
|
+ mask1.setX(tx);
|
|
|
+ mask2.setX(tx);
|
|
|
+
|
|
|
+// if (index == 2) {
|
|
|
+// Log.i("APP# MainCategoryContentsImageView | onScrolledInternal", "|" + " cx: " + cx);
|
|
|
+// Log.i("APP# MainCategoryContentsImageView | onScrolledInternal", "|" + " ratio: " + ratio);
|
|
|
+// Log.i("APP# MainCategoryContentsImageView | onScrolledInternal", "|" + " imageWidth: " + imageWidth);
|
|
|
+// Log.i("APP# MainCategoryContentsImageView | onScrolledInternal", "|" + " maskWidth: " + maskWidth);
|
|
|
+// Log.i("APP# MainCategoryContentsImageView | onScrolledInternal", "|" + " tx: " + tx);
|
|
|
+// Log.i("APP# MainCategoryContentsImageView | onScrolledInternal", "|" + " dx: " + dx);
|
|
|
+// Log.i("APP# MainCategoryContentsImageView | onScrolledInternal", "| item x: " + itemView.getX());
|
|
|
+// Log.i("APP# MainCategoryContentsImageView | onScrolledInternal", "| item y: " + itemView.getY());
|
|
|
+// }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
+
|
|
|
@Override
|
|
|
public void init(int index, MainContentsCategoryBean bean, IEventListener listener) {
|
|
|
this.index = index;
|
|
|
+ this.listener = listener;
|
|
|
+ this.bean = bean;
|
|
|
|
|
|
textBig = itemView.findViewById(R.id.text_big);
|
|
|
textSmall = itemView.findViewById(R.id.text_small);
|
|
|
imageView = itemView.findViewById(R.id.image_contents);
|
|
|
+ mask0 = itemView.findViewById(R.id.mask_0);
|
|
|
+ mask1 = itemView.findViewById(R.id.mask_1);
|
|
|
+ mask2 = itemView.findViewById(R.id.mask_2);
|
|
|
imageView.setOnClickListener(v -> listener.onEvent(new Event.Builder(Event.CONTENTS).integer(index).build()));
|
|
|
|
|
|
this.screenWidth = SuperModel.getInstance().getScreenWidth();
|
|
|
@@ -251,6 +291,8 @@ public class MainCategoryContentsImageView extends MainCategoryContentsView {
|
|
|
maskWidth = ResourceUtil.getDimension(R.dimen.main_contents_image_width);
|
|
|
maskHeight = ResourceUtil.getDimension(R.dimen.main_contents_image_height);
|
|
|
|
|
|
+ spaceWidth = ResourceUtil.getDimension(R.dimen.main_contents_start_gap);
|
|
|
+
|
|
|
String url = bean.getImageUrl();
|
|
|
|
|
|
// Drawable drawable = imageView.getDrawable();
|
|
|
@@ -262,6 +304,7 @@ public class MainCategoryContentsImageView extends MainCategoryContentsView {
|
|
|
|
|
|
Glide.with(imageView)
|
|
|
.load(url)
|
|
|
+// .apply(new RequestOptions().override(maskWidth, maskHeight))
|
|
|
.listener(new RequestListener<Drawable>() {
|
|
|
@Override
|
|
|
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
|
|
|
@@ -274,8 +317,8 @@ public class MainCategoryContentsImageView extends MainCategoryContentsView {
|
|
|
imageWidth = resource.getIntrinsicWidth(); //this is the bitmap's width
|
|
|
imageHeight = resource.getIntrinsicHeight(); //this is the bitmap's height
|
|
|
|
|
|
-// Log.i("APP# MainCategoryContentsImageView | init", "| maskWidth: " + maskWidth + ", maskHeight: " + maskHeight);
|
|
|
-// Log.i("APP# MainCategoryContentsImageView | init", "| imageWidth: " + imageWidth + ", imageHeight: " + imageHeight);
|
|
|
+// Log.i("APP# MainCategoryContentsImageView | init", "| maskWidth: " + maskWidth + ", maskHeight: " + maskHeight);
|
|
|
+// Log.i("APP# MainCategoryContentsImageView | init", "| imageWidth: " + imageWidth + ", imageHeight: " + imageHeight);
|
|
|
|
|
|
onScrolledInternal();
|
|
|
|
|
|
@@ -288,17 +331,30 @@ public class MainCategoryContentsImageView extends MainCategoryContentsView {
|
|
|
|
|
|
}
|
|
|
|
|
|
- private int getScreenY(View view) {
|
|
|
- int[] containerPos = new int[2];
|
|
|
- view.getLocationOnScreen(containerPos);
|
|
|
+ @Override
|
|
|
+ public void attach() {
|
|
|
+ }
|
|
|
|
|
|
- return containerPos[1];
|
|
|
+ @Override
|
|
|
+ public void detach() {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void dispose() {
|
|
|
- // 이미지가 화면에서 사라진 뒤 변환 됨
|
|
|
-// Glide.with(imageView).clear(imageView);
|
|
|
+ if (null != imageView) {
|
|
|
+ Glide.with(imageView).clear(imageView);
|
|
|
+ imageView.setOnClickListener(null);
|
|
|
+ imageView = null;
|
|
|
+ textBig = null;
|
|
|
+ textSmall = null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private int getScreenY(View view) {
|
|
|
+ int[] containerPos = new int[2];
|
|
|
+ view.getLocationOnScreen(containerPos);
|
|
|
+
|
|
|
+ return containerPos[1];
|
|
|
}
|
|
|
|
|
|
}
|