|
|
@@ -1,6 +1,7 @@
|
|
|
package com.sheep.gamegroup.view.activity;
|
|
|
|
|
|
import android.app.Activity;
|
|
|
+import android.graphics.drawable.Drawable;
|
|
|
import android.os.Bundle;
|
|
|
import android.support.annotation.Nullable;
|
|
|
import android.support.v7.app.AppCompatActivity;
|
|
|
@@ -9,14 +10,19 @@ import android.support.v7.widget.LinearLayoutManager;
|
|
|
import android.support.v7.widget.RecyclerView;
|
|
|
import android.text.TextUtils;
|
|
|
import android.util.Log;
|
|
|
+import android.util.SparseArray;
|
|
|
import android.view.View;
|
|
|
import android.widget.ImageView;
|
|
|
import android.widget.TextView;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.bumptech.glide.Glide;
|
|
|
+import com.bumptech.glide.load.DataSource;
|
|
|
+import com.bumptech.glide.load.engine.GlideException;
|
|
|
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
|
|
|
+import com.bumptech.glide.request.RequestListener;
|
|
|
import com.bumptech.glide.request.RequestOptions;
|
|
|
+import com.bumptech.glide.request.target.Target;
|
|
|
import com.kfzs.appstore.utils.adapter.recyclerview.RecyclerViewAdapter;
|
|
|
import com.sheep.gamegroup.helper.ScalableCardHelper;
|
|
|
import com.sheep.gamegroup.model.api.ICallBack;
|
|
|
@@ -110,10 +116,28 @@ public class InvitationActivity extends AppCompatActivity implements ScalableCar
|
|
|
|
|
|
mRecyclerViewAdapter = new RecyclerViewAdapter<PictureInvitationEntity>(mRecyclerView.getContext(), R.layout.item_image2, mPictureList) {
|
|
|
@Override
|
|
|
- public void convert(com.kfzs.appstore.utils.adapter.recyclerview.ViewHolder viewHolder, PictureInvitationEntity item, int i) {
|
|
|
+ public void convert(com.kfzs.appstore.utils.adapter.recyclerview.ViewHolder viewHolder, final PictureInvitationEntity item, int i) {
|
|
|
ImageView image_full = viewHolder.getView(R.id.image_full);
|
|
|
ImageView image_bottom = viewHolder.getView(R.id.image_bottom);
|
|
|
- GlideImageLoader.roundedCornersImage1(image_full, item.getPicture(), (int) getResources().getDimension(R.dimen.content_padding_8));
|
|
|
+// GlideImageLoader.roundedCornersImage1(image_full, item.getPicture(), (int) getResources().getDimension(R.dimen.content_padding_8));
|
|
|
+ viewList.put(i, viewHolder.itemView);
|
|
|
+ Glide.with(SheepApp.getInstance())
|
|
|
+ .load(item.getPicture())
|
|
|
+ .listener(new RequestListener<Drawable>() {
|
|
|
+ @Override
|
|
|
+ public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
|
|
|
+ item.setLoaded(false);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
|
|
|
+ item.setLoaded(true);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .apply(new RequestOptions().centerCrop().transform(new RoundedCorners((int) getResources().getDimension(R.dimen.content_padding_8))))
|
|
|
+ .into(image_full);
|
|
|
GlideImageLoader.saveAndSetRqImage(image_bottom, item.getLink(), 800);
|
|
|
}
|
|
|
|
|
|
@@ -122,7 +146,7 @@ public class InvitationActivity extends AppCompatActivity implements ScalableCar
|
|
|
ScalableCardHelper cardHelper = new ScalableCardHelper(this);
|
|
|
cardHelper.attachToRecyclerView(mRecyclerView);
|
|
|
}
|
|
|
-
|
|
|
+ private SparseArray<View> viewList = new SparseArray<>();
|
|
|
|
|
|
private void init(final String url, final String description) {
|
|
|
gridLayoutManager = new GridLayoutManager(this, 5);
|
|
|
@@ -168,13 +192,20 @@ public class InvitationActivity extends AppCompatActivity implements ScalableCar
|
|
|
switch (position){
|
|
|
case 1://qq
|
|
|
case 2://wx
|
|
|
- try {
|
|
|
- String fileName = String.format(Locale.CHINA, "share%d%s%d.jpg", position, BuildConfig.FLAVOR, mPictureList.get(position).getLink().hashCode());
|
|
|
- file = new File(ClassFileHelper.DIR, fileName);
|
|
|
- if(!file.exists())
|
|
|
- file = ViewUtil.saveImage(mRecyclerView.getChildAt(curPosition).findViewById(R.id.layout_view), ClassFileHelper.DIR, fileName);
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
+ PictureInvitationEntity picItem = ListUtil.getItem(mPictureList, curPosition);
|
|
|
+ if(picItem != null && picItem.isLoaded()) {
|
|
|
+ try {
|
|
|
+ String fileName = String.format(Locale.CHINA, "share%d%s%d.jpg", position, BuildConfig.FLAVOR, picItem.getPicture().hashCode());
|
|
|
+ file = new File(ClassFileHelper.DIR, fileName);
|
|
|
+ if (!file.exists()) {
|
|
|
+ file = ViewUtil.saveImage(viewList.get(curPosition), ClassFileHelper.DIR, fileName);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ G.showToast("图片正在加载中,请稍等");
|
|
|
+ return;
|
|
|
}
|
|
|
break;
|
|
|
|