|
|
@@ -6,18 +6,12 @@ package kr.co.zumo.app.lifeplus.view.screen.main;
|
|
|
import android.content.Context;
|
|
|
import android.graphics.Matrix;
|
|
|
import android.graphics.drawable.Drawable;
|
|
|
-import android.support.annotation.Nullable;
|
|
|
import android.support.v7.widget.RecyclerView;
|
|
|
+import android.util.Log;
|
|
|
import android.view.View;
|
|
|
import android.widget.ImageView;
|
|
|
import android.widget.TextView;
|
|
|
|
|
|
-import com.bumptech.glide.Glide;
|
|
|
-import com.bumptech.glide.load.DataSource;
|
|
|
-import com.bumptech.glide.load.engine.GlideException;
|
|
|
-import com.bumptech.glide.request.RequestListener;
|
|
|
-import com.bumptech.glide.request.target.Target;
|
|
|
-
|
|
|
import kr.co.zumo.app.R;
|
|
|
import kr.co.zumo.app.lifeplus.bean.api.MainContentsBean;
|
|
|
import kr.co.zumo.app.lifeplus.model.SuperModel;
|
|
|
@@ -143,34 +137,39 @@ public class MainContentsCategoryImageView extends MainCatogoryContentsView {
|
|
|
x = (int) itemView.getX();
|
|
|
|
|
|
if (x > -maskWidth && x < screenWidth) { // holder 가 표시되는 부분에서만 계산
|
|
|
- // x = 0 ~ screen.w - mask.w
|
|
|
- int rail = screenWidth - maskWidth;
|
|
|
- ratio = (float) x / (rail);
|
|
|
-
|
|
|
- tx = -((int) ((imageWidth - maskWidth) * ratio)); // image 이동 구간 0 ~ -image.w-mask.w
|
|
|
-
|
|
|
- if (imageWidth > screenWidth) {
|
|
|
- if (tx > 0) {
|
|
|
- tx = 0;
|
|
|
- }
|
|
|
- else if (tx < maskWidth - imageWidth) {
|
|
|
- tx = maskWidth - imageWidth;
|
|
|
- }
|
|
|
+
|
|
|
+ // x = 0 ~ image.w - screen.w
|
|
|
+ ratio = (float) (maskWidth + x) / (maskWidth + screenWidth);
|
|
|
+
|
|
|
+ if (imageWidth < screenWidth) {
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 이미지가 스크린보다 작을 때
|
|
|
+ * - 마스크가 보여지는 면적보다 많이 offset 돼지 않도록 계산한다.
|
|
|
+ */
|
|
|
+ tx = -((int) ((imageWidth - maskWidth) * ratio)); // image 이동 구간 -image.w + mask.w ~ 0
|
|
|
+
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ /**
|
|
|
+ * 이미지가 스크린보다 클 때
|
|
|
+ */
|
|
|
+ tx = -((int) ((imageWidth + maskWidth) * ratio)) + maskWidth; // image 이동 구간 -image.w ~ mask.w
|
|
|
}
|
|
|
|
|
|
cx = (int) values[2];
|
|
|
dx = tx - cx;
|
|
|
|
|
|
-// if (index == 2) {
|
|
|
-// Log.i("APP# MainContentsCategoryImageView | onScrolledInternal", "|" + " x: " + x);
|
|
|
-// Log.i("APP# MainContentsCategoryImageView | onScrolledInternal", "|" + " ratio: " + ratio);
|
|
|
-// Log.i("APP# MainContentsCategoryImageView | onScrolledInternal", "|" + " imageWidth: " + imageWidth);
|
|
|
-// Log.i("APP# MainContentsCategoryImageView | onScrolledInternal", "|" + " maskWidth: " + maskWidth);
|
|
|
-// Log.i("APP# MainContentsCategoryImageView | onScrolledInternal", "|" + " tx: " + tx);
|
|
|
-// Log.i("APP# MainContentsCategoryImageView | onScrolledInternal", "|" + " dx: " + dx);
|
|
|
-// Log.i("APP# MainContentsCategoryImageView | onScrolledInternal", "| item x: " + itemView.getX());
|
|
|
-// Log.i("APP# MainContentsCategoryImageView | onScrolledInternal", "| item y: " + itemView.getY());
|
|
|
-// }
|
|
|
+ if (index == 2) {
|
|
|
+ Log.i("APP# MainContentsCategoryImageView | onScrolledInternal", "|" + " x: " + x);
|
|
|
+ Log.i("APP# MainContentsCategoryImageView | onScrolledInternal", "|" + " ratio: " + ratio);
|
|
|
+ Log.i("APP# MainContentsCategoryImageView | onScrolledInternal", "|" + " imageWidth: " + imageWidth);
|
|
|
+ Log.i("APP# MainContentsCategoryImageView | onScrolledInternal", "|" + " maskWidth: " + maskWidth);
|
|
|
+ Log.i("APP# MainContentsCategoryImageView | onScrolledInternal", "|" + " tx: " + tx);
|
|
|
+ Log.i("APP# MainContentsCategoryImageView | onScrolledInternal", "|" + " dx: " + dx);
|
|
|
+ Log.i("APP# MainContentsCategoryImageView | onScrolledInternal", "| item x: " + itemView.getX());
|
|
|
+ Log.i("APP# MainContentsCategoryImageView | onScrolledInternal", "| item y: " + itemView.getY());
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -211,37 +210,37 @@ public class MainContentsCategoryImageView extends MainCatogoryContentsView {
|
|
|
|
|
|
String url = bean.getImageUrl();
|
|
|
|
|
|
-// Drawable drawable = imageView.getDrawable();
|
|
|
- //you should call after the bitmap drawn
|
|
|
-// imageWidth = maskWidth + 200; //drawable.getIntrinsicWidth(); //this is the bitmap's width
|
|
|
-// imageHeight = maskHeight + 100; //drawable.getIntrinsicHeight(); //this is the bitmap's height
|
|
|
-//
|
|
|
-// onScrolledInternal();
|
|
|
-
|
|
|
- Glide.with(imageView)
|
|
|
- .load(url)
|
|
|
- .listener(new RequestListener<Drawable>() {
|
|
|
- @Override
|
|
|
- public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
|
|
|
- Drawable drawable = resource;
|
|
|
- //you should call after the bitmap drawn
|
|
|
- imageWidth = drawable.getIntrinsicWidth(); //this is the bitmap's width
|
|
|
- imageHeight = drawable.getIntrinsicHeight(); //this is the bitmap's height
|
|
|
+ Drawable drawable = imageView.getDrawable();
|
|
|
+// you should call after the bitmap drawn
|
|
|
+ imageWidth = drawable.getIntrinsicWidth(); //this is the bitmap's width
|
|
|
+ imageHeight = drawable.getIntrinsicHeight(); //this is the bitmap's height
|
|
|
|
|
|
-// Log.i("APP# MainContentsCategoryImageView | init", "| maskWidth: " + maskWidth + ", maskHeight: " + maskHeight);
|
|
|
-// Log.i("APP# MainContentsCategoryImageView | init", "| imageWidth: " + imageWidth + ", imageHeight: " + imageHeight);
|
|
|
-
|
|
|
- onScrolledInternal();
|
|
|
+ onScrolledInternal();
|
|
|
|
|
|
- return false;
|
|
|
- }
|
|
|
- })
|
|
|
- .into(imageView);
|
|
|
+// Glide.with(imageView)
|
|
|
+// .load(url)
|
|
|
+// .listener(new RequestListener<Drawable>() {
|
|
|
+// @Override
|
|
|
+// public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
|
|
|
+// return false;
|
|
|
+// }
|
|
|
+//
|
|
|
+// @Override
|
|
|
+// public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
|
|
|
+// Drawable drawable = resource;
|
|
|
+// //you should call after the bitmap drawn
|
|
|
+// imageWidth = drawable.getIntrinsicWidth(); //this is the bitmap's width
|
|
|
+// imageHeight = drawable.getIntrinsicHeight(); //this is the bitmap's height
|
|
|
+//
|
|
|
+//// Log.i("APP# MainContentsCategoryImageView | init", "| maskWidth: " + maskWidth + ", maskHeight: " + maskHeight);
|
|
|
+//// Log.i("APP# MainContentsCategoryImageView | init", "| imageWidth: " + imageWidth + ", imageHeight: " + imageHeight);
|
|
|
+//
|
|
|
+// onScrolledInternal();
|
|
|
+//
|
|
|
+// return false;
|
|
|
+// }
|
|
|
+// })
|
|
|
+// .into(imageView);
|
|
|
|
|
|
|
|
|
}
|