浏览代码

Merge branch 'develop' of https://github.com/swict/LifeplusAndroid into develop

hyodong.min 6 年之前
父节点
当前提交
e220ef5d1d

+ 37 - 5
app/src/main/java/kr/co/zumo/app/lifeplus/view/screen/my/bucketlist/AddMyBucketListFragment.java

@@ -1,6 +1,7 @@
 package kr.co.zumo.app.lifeplus.view.screen.my.bucketlist;
 
 import android.content.Context;
+import android.graphics.Bitmap;
 import android.graphics.Rect;
 import android.os.Bundle;
 import android.support.annotation.NonNull;
@@ -19,7 +20,10 @@ import android.widget.ImageView;
 import android.widget.TextView;
 
 import com.bumptech.glide.Glide;
-import com.bumptech.glide.request.RequestOptions;
+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 java.util.List;
 
@@ -48,6 +52,8 @@ public class AddMyBucketListFragment extends FragmentBase<AddMyBucketListPresent
   private TextView textViewMyBucketDetail;
   private Button buttonAddMyBucket;
   private ImageView imageViewBackground;
+  private ImageView imageViewBackground2;
+  private ImageView targetImageView;
   private AddMyBucketListAdapter addMyBucketListAdapter;
 
   @Nullable
@@ -63,7 +69,8 @@ public class AddMyBucketListFragment extends FragmentBase<AddMyBucketListPresent
     textViewMyBucketDetail = findViewById(R.id.text_view_my_bucket_detail);
     buttonAddMyBucket = findViewById(R.id.button_add_my_bucket);
     imageViewBackground = findViewById(R.id.image_background);
-
+    imageViewBackground2 = findViewById(R.id.image_background2);
+    targetImageView = imageViewBackground2;
     editTextMyBucketTitle.requestFocus();
     InputMethodManager inputMethodManager = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
     inputMethodManager.showSoftInput(editTextMyBucketTitle, InputMethodManager.SHOW_IMPLICIT);
@@ -166,10 +173,26 @@ public class AddMyBucketListFragment extends FragmentBase<AddMyBucketListPresent
 
   @Override
   public void changeBackground(String imageUrl) {
-    Glide.with(imageViewBackground)
+
+    Glide.with(targetImageView)
       .asBitmap().load(imageUrl)
-      .apply(new RequestOptions().placeholder(ResourceUtil.getDrawable(imageViewBackground.getContext(), R.drawable.image_loading_full)))
-      .into(imageViewBackground);
+      //.apply(new RequestOptions().placeholder(ResourceUtil.getDrawable(imageViewBackground.getContext(), R.drawable.image_loading_full)))
+      .addListener(new RequestListener<Bitmap>() {
+        @Override
+        public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Bitmap> target, boolean isFirstResource) {
+          return false;
+        }
+
+        @Override
+        public boolean onResourceReady(Bitmap resource, Object model, Target<Bitmap> target, DataSource dataSource, boolean isFirstResource) {
+          targetImageView.bringToFront();
+          changeImageViewTarget();
+          return false;
+        }
+      })
+      .into(targetImageView);
+
+
     // imageViewBackground.setScaleType(ImageView.ScaleType.CENTER_CROP);
   }
 
@@ -233,4 +256,13 @@ public class AddMyBucketListFragment extends FragmentBase<AddMyBucketListPresent
 
   }
 
+  private void changeImageViewTarget() {
+    if (targetImageView == imageViewBackground2) {
+      targetImageView = imageViewBackground;
+    }
+    else {
+      targetImageView = imageViewBackground2;
+    }
+  }
+
 }

+ 28 - 9
app/src/main/res/layout/fragment_add_my_bucket_list.xml

@@ -7,16 +7,35 @@
   android:layout_height="match_parent"
   >
 
-  <ImageView
-    android:id="@+id/image_background"
+  <FrameLayout
     android:layout_width="match_parent"
-    android:layout_height="match_parent"
-    android:scaleType="centerCrop"
-    app:layout_constraintBottom_toBottomOf="parent"
-    app:layout_constraintEnd_toEndOf="parent"
-    app:layout_constraintStart_toStartOf="parent"
-    app:layout_constraintTop_toTopOf="parent"
-    tools:src="@drawable/img_bestbucket_1"/>
+    android:layout_height="match_parent">
+
+    <ImageView
+      android:id="@+id/image_background2"
+      android:layout_width="match_parent"
+      android:layout_height="match_parent"
+      android:background="@color/CFFFFFF"
+      android:scaleType="centerCrop"
+      app:layout_constraintBottom_toBottomOf="parent"
+      app:layout_constraintEnd_toEndOf="parent"
+      app:layout_constraintStart_toStartOf="parent"
+      app:layout_constraintTop_toTopOf="parent"/>
+
+
+    <ImageView
+      android:id="@+id/image_background"
+      android:layout_width="match_parent"
+      android:layout_height="match_parent"
+      android:scaleType="centerCrop"
+      tools:src="@drawable/img_bestbucket_1"
+      app:layout_constraintBottom_toBottomOf="parent"
+      app:layout_constraintEnd_toEndOf="parent"
+      app:layout_constraintStart_toStartOf="parent"
+      app:layout_constraintTop_toTopOf="parent"/>
+
+
+  </FrameLayout>
 
   <View
     android:layout_width="match_parent"