|
@@ -1,19 +1,11 @@
|
|
|
package com.sheep.gamegroup.view.activity;
|
|
package com.sheep.gamegroup.view.activity;
|
|
|
|
|
|
|
|
-import android.annotation.SuppressLint;
|
|
|
|
|
import android.app.Activity;
|
|
import android.app.Activity;
|
|
|
-import android.content.Context;
|
|
|
|
|
-import android.graphics.Bitmap;
|
|
|
|
|
-import android.graphics.BitmapFactory;
|
|
|
|
|
import android.os.Bundle;
|
|
import android.os.Bundle;
|
|
|
-import android.os.Environment;
|
|
|
|
|
-import android.os.Handler;
|
|
|
|
|
-import android.os.Message;
|
|
|
|
|
import android.support.annotation.Nullable;
|
|
import android.support.annotation.Nullable;
|
|
|
import android.support.v7.app.AppCompatActivity;
|
|
import android.support.v7.app.AppCompatActivity;
|
|
|
import android.support.v7.widget.GridLayoutManager;
|
|
import android.support.v7.widget.GridLayoutManager;
|
|
|
import android.support.v7.widget.LinearLayoutManager;
|
|
import android.support.v7.widget.LinearLayoutManager;
|
|
|
-import android.support.v7.widget.OrientationHelper;
|
|
|
|
|
import android.support.v7.widget.RecyclerView;
|
|
import android.support.v7.widget.RecyclerView;
|
|
|
import android.text.TextUtils;
|
|
import android.text.TextUtils;
|
|
|
import android.util.Log;
|
|
import android.util.Log;
|
|
@@ -22,10 +14,12 @@ import android.widget.ImageView;
|
|
|
import android.widget.TextView;
|
|
import android.widget.TextView;
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
-import com.google.gson.Gson;
|
|
|
|
|
-import com.sheep.gamegroup.helper.DownloadUtil;
|
|
|
|
|
|
|
+import com.bumptech.glide.Glide;
|
|
|
|
|
+import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
|
|
|
|
|
+import com.bumptech.glide.request.RequestOptions;
|
|
|
|
|
+import com.kfzs.appstore.utils.adapter.recyclerview.RecyclerViewAdapter;
|
|
|
import com.sheep.gamegroup.helper.ScalableCardHelper;
|
|
import com.sheep.gamegroup.helper.ScalableCardHelper;
|
|
|
-import com.sheep.gamegroup.helper.ZXingHelper;
|
|
|
|
|
|
|
+import com.sheep.gamegroup.model.api.ICallBack;
|
|
|
import com.sheep.gamegroup.model.entity.BaseMessage;
|
|
import com.sheep.gamegroup.model.entity.BaseMessage;
|
|
|
import com.sheep.gamegroup.model.entity.DialogConfig;
|
|
import com.sheep.gamegroup.model.entity.DialogConfig;
|
|
|
import com.sheep.gamegroup.model.entity.FriendAndAwardEntity;
|
|
import com.sheep.gamegroup.model.entity.FriendAndAwardEntity;
|
|
@@ -37,12 +31,10 @@ import com.sheep.gamegroup.util.DataUtil;
|
|
|
import com.sheep.gamegroup.util.FastJsonUtils;
|
|
import com.sheep.gamegroup.util.FastJsonUtils;
|
|
|
import com.sheep.gamegroup.util.GlideImageLoader;
|
|
import com.sheep.gamegroup.util.GlideImageLoader;
|
|
|
import com.sheep.gamegroup.util.ListUtil;
|
|
import com.sheep.gamegroup.util.ListUtil;
|
|
|
-import com.sheep.gamegroup.util.LogUtil;
|
|
|
|
|
import com.sheep.gamegroup.util.StringUtils;
|
|
import com.sheep.gamegroup.util.StringUtils;
|
|
|
import com.sheep.gamegroup.util.ViewHolder;
|
|
import com.sheep.gamegroup.util.ViewHolder;
|
|
|
import com.sheep.gamegroup.util.ViewUtil;
|
|
import com.sheep.gamegroup.util.ViewUtil;
|
|
|
import com.sheep.gamegroup.view.adapter.AdbCommonRecycler;
|
|
import com.sheep.gamegroup.view.adapter.AdbCommonRecycler;
|
|
|
-import com.sheep.gamegroup.view.adapter.MyAdapter;
|
|
|
|
|
import com.sheep.gamegroup.view.dialog.DialogShare;
|
|
import com.sheep.gamegroup.view.dialog.DialogShare;
|
|
|
import com.sheep.jiuyan.samllsheep.BuildConfig;
|
|
import com.sheep.jiuyan.samllsheep.BuildConfig;
|
|
|
import com.sheep.jiuyan.samllsheep.R;
|
|
import com.sheep.jiuyan.samllsheep.R;
|
|
@@ -88,10 +80,6 @@ public class InvitationActivity extends AppCompatActivity implements ScalableCar
|
|
|
private String description;
|
|
private String description;
|
|
|
private File file;
|
|
private File file;
|
|
|
private List<PictureInvitationEntity> mPictureList = new ArrayList<>();
|
|
private List<PictureInvitationEntity> mPictureList = new ArrayList<>();
|
|
|
- private int position = 0;
|
|
|
|
|
- private List<Bitmap> listBitmap1 = new ArrayList<>();
|
|
|
|
|
- private List<Bitmap> listBitmap2 = new ArrayList<>();
|
|
|
|
|
- private MyAdapter adapter;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
|
|
|
|
@@ -100,8 +88,8 @@ public class InvitationActivity extends AppCompatActivity implements ScalableCar
|
|
|
setContentView(R.layout.activity_invitation);
|
|
setContentView(R.layout.activity_invitation);
|
|
|
ButterKnife.bind(this);
|
|
ButterKnife.bind(this);
|
|
|
initView();
|
|
initView();
|
|
|
|
|
+ initListener();
|
|
|
initData();
|
|
initData();
|
|
|
- createAdapter(listBitmap1, this);
|
|
|
|
|
getPictureList();
|
|
getPictureList();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -114,18 +102,22 @@ public class InvitationActivity extends AppCompatActivity implements ScalableCar
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
+ private RecyclerViewAdapter<PictureInvitationEntity> mRecyclerViewAdapter;
|
|
|
|
|
+ private void initListener() {
|
|
|
|
|
+ mRecyclerView.setLayoutManager(new LinearLayoutManager(mRecyclerView.getContext(), LinearLayoutManager.HORIZONTAL, false));
|
|
|
|
|
+ mRecyclerView.setNestedScrollingEnabled(false);
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * @param list Bitmap集合
|
|
|
|
|
- * @param context
|
|
|
|
|
- */
|
|
|
|
|
- private void createAdapter(List<Bitmap> list, Context context) {
|
|
|
|
|
- adapter = new MyAdapter(context, list, listBitmap2);
|
|
|
|
|
- LinearLayoutManager layoutManager = new LinearLayoutManager(context);
|
|
|
|
|
- layoutManager.setOrientation(OrientationHelper.HORIZONTAL);
|
|
|
|
|
- mRecyclerView.setLayoutManager(layoutManager);
|
|
|
|
|
- // recyclerView.addItemDecoration(new InvitationPictureAdapter.SpacesItemDecoration(15));
|
|
|
|
|
- mRecyclerView.setAdapter(adapter);
|
|
|
|
|
|
|
+ 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) {
|
|
|
|
|
+ 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.saveAndSetRqImage(image_bottom, item.getLink(), 800);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ };
|
|
|
|
|
+ mRecyclerView.setAdapter(mRecyclerViewAdapter);
|
|
|
ScalableCardHelper cardHelper = new ScalableCardHelper(this);
|
|
ScalableCardHelper cardHelper = new ScalableCardHelper(this);
|
|
|
cardHelper.attachToRecyclerView(mRecyclerView);
|
|
cardHelper.attachToRecyclerView(mRecyclerView);
|
|
|
}
|
|
}
|
|
@@ -345,6 +337,7 @@ public class InvitationActivity extends AppCompatActivity implements ScalableCar
|
|
|
@Override
|
|
@Override
|
|
|
public void onNext(BaseMessage baseMessage) {
|
|
public void onNext(BaseMessage baseMessage) {
|
|
|
mPictureList.addAll(baseMessage.getDataList(PictureInvitationEntity.class));
|
|
mPictureList.addAll(baseMessage.getDataList(PictureInvitationEntity.class));
|
|
|
|
|
+ mRecyclerViewAdapter.notifyDataSetChanged();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -352,67 +345,14 @@ public class InvitationActivity extends AppCompatActivity implements ScalableCar
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
+// private void createBitmapList(int y) {
|
|
|
|
|
+// for (int i = 0; i < mPictureList.size(); i++) {
|
|
|
|
|
+// listBitmap1.add(BitmapFactory.decodeFile(getSavePath(mPictureList.get(i).getPicture())));
|
|
|
|
|
+// Bitmap logo = BitmapFactory.decodeResource(getResources(), R.mipmap.sheep_logo);
|
|
|
|
|
+// Bitmap bitmap = ZXingHelper.createQRCodeWithLogo(mPictureList.get(y).getLink(), logo);
|
|
|
|
|
+// }
|
|
|
|
|
+// }
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * @param url ,,图片地址
|
|
|
|
|
- * @return /storage/emulated/0/sheep/aaa
|
|
|
|
|
- */
|
|
|
|
|
- private String getSavePath(String url) {
|
|
|
|
|
- return Environment.getExternalStorageDirectory() + "/sheep/" + url.substring(url.lastIndexOf("/") + 1);
|
|
|
|
|
- }
|
|
|
|
|
- private void downloadPictures() {
|
|
|
|
|
- for (int i = 0; i < mPictureList.size(); i++) {
|
|
|
|
|
- position = i;
|
|
|
|
|
- DownloadUtil.get().download(mPictureList.get(position).getPicture(), "sheep", new DownloadUtil.OnDownloadListener() {
|
|
|
|
|
- @Override
|
|
|
|
|
- public void onDownloadSuccess() {
|
|
|
|
|
- if (position == mPictureList.size()-1) {
|
|
|
|
|
- createBitmapList(position);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- @Override
|
|
|
|
|
- public void onDownloading(int progress) {
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- @Override
|
|
|
|
|
- public void onDownloadFailed() {
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- private void createBitmapList(int y) {
|
|
|
|
|
- for (int i = 0; i < mPictureList.size(); i++) {
|
|
|
|
|
- listBitmap1.add(BitmapFactory.decodeFile(getSavePath(mPictureList.get(i).getPicture())));
|
|
|
|
|
- Bitmap logo = BitmapFactory.decodeResource(getResources(), R.mipmap.sheep_logo);
|
|
|
|
|
- Bitmap bitmap = ZXingHelper.createQRCodeWithLogo(mPictureList.get(y).getLink(), logo);
|
|
|
|
|
- listBitmap2.add(bitmap);
|
|
|
|
|
- }
|
|
|
|
|
- handler.sendEmptyMessage(1);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- @SuppressLint("HandlerLeak")
|
|
|
|
|
- private Handler handler = new Handler() {
|
|
|
|
|
- @Override
|
|
|
|
|
- public void handleMessage(Message msg) {
|
|
|
|
|
- super.handleMessage(msg);
|
|
|
|
|
- switch (msg.what) {
|
|
|
|
|
- case 1:
|
|
|
|
|
- /* for (int i = 0; i < size; i++) {
|
|
|
|
|
- listBitmap.add(mergeBitmap(listBitmap1.get(i), listBitmap2.get(i)));
|
|
|
|
|
- }*/
|
|
|
|
|
- adapter.notifyDataSetChanged();
|
|
|
|
|
-
|
|
|
|
|
- break;
|
|
|
|
|
- case 2:
|
|
|
|
|
- break;
|
|
|
|
|
- default:
|
|
|
|
|
-
|
|
|
|
|
- break;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- };
|
|
|
|
|
|
|
|
|
|
private File getViewFile(View addViewContent) {
|
|
private File getViewFile(View addViewContent) {
|
|
|
if (addViewContent==null){
|
|
if (addViewContent==null){
|