|
|
@@ -1,22 +1,11 @@
|
|
|
package com.sheep.gamegroup.view.activity;
|
|
|
|
|
|
-import android.annotation.SuppressLint;
|
|
|
import android.app.Activity;
|
|
|
-import android.content.Context;
|
|
|
-import android.graphics.Bitmap;
|
|
|
-import android.graphics.BitmapFactory;
|
|
|
-import android.graphics.Canvas;
|
|
|
-import android.graphics.Matrix;
|
|
|
-import android.graphics.Paint;
|
|
|
import android.os.Bundle;
|
|
|
-import android.os.Environment;
|
|
|
-import android.os.Handler;
|
|
|
-import android.os.Message;
|
|
|
import android.support.annotation.Nullable;
|
|
|
import android.support.v7.app.AppCompatActivity;
|
|
|
import android.support.v7.widget.GridLayoutManager;
|
|
|
import android.support.v7.widget.LinearLayoutManager;
|
|
|
-import android.support.v7.widget.OrientationHelper;
|
|
|
import android.support.v7.widget.RecyclerView;
|
|
|
import android.text.TextUtils;
|
|
|
import android.util.Log;
|
|
|
@@ -25,17 +14,12 @@ import android.widget.ImageView;
|
|
|
import android.widget.TextView;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
-import com.google.gson.Gson;
|
|
|
-import com.google.zxing.BarcodeFormat;
|
|
|
-import com.google.zxing.EncodeHintType;
|
|
|
-import com.google.zxing.WriterException;
|
|
|
-import com.google.zxing.common.BitMatrix;
|
|
|
-import com.google.zxing.qrcode.QRCodeWriter;
|
|
|
-import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
|
|
|
-import com.kfzs.duanduan.cardview.CardScaleHelper;
|
|
|
-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.ZXingHelper;
|
|
|
+import com.sheep.gamegroup.model.api.ICallBack;
|
|
|
import com.sheep.gamegroup.model.entity.BaseMessage;
|
|
|
import com.sheep.gamegroup.model.entity.DialogConfig;
|
|
|
import com.sheep.gamegroup.model.entity.FriendAndAwardEntity;
|
|
|
@@ -47,12 +31,10 @@ import com.sheep.gamegroup.util.DataUtil;
|
|
|
import com.sheep.gamegroup.util.FastJsonUtils;
|
|
|
import com.sheep.gamegroup.util.GlideImageLoader;
|
|
|
import com.sheep.gamegroup.util.ListUtil;
|
|
|
-import com.sheep.gamegroup.util.LogUtil;
|
|
|
import com.sheep.gamegroup.util.StringUtils;
|
|
|
import com.sheep.gamegroup.util.ViewHolder;
|
|
|
import com.sheep.gamegroup.util.ViewUtil;
|
|
|
import com.sheep.gamegroup.view.adapter.AdbCommonRecycler;
|
|
|
-import com.sheep.gamegroup.view.adapter.MyAdapter;
|
|
|
import com.sheep.gamegroup.view.dialog.DialogShare;
|
|
|
import com.sheep.jiuyan.samllsheep.BuildConfig;
|
|
|
import com.sheep.jiuyan.samllsheep.R;
|
|
|
@@ -66,8 +48,8 @@ import com.umeng.socialize.media.UMWeb;
|
|
|
|
|
|
import java.io.File;
|
|
|
import java.util.ArrayList;
|
|
|
-import java.util.Hashtable;
|
|
|
import java.util.List;
|
|
|
+import java.util.Locale;
|
|
|
|
|
|
import butterknife.BindView;
|
|
|
import butterknife.ButterKnife;
|
|
|
@@ -77,6 +59,9 @@ import rx.schedulers.Schedulers;
|
|
|
|
|
|
import static com.sheep.gamegroup.util.UMConfigUtils.Event.LINK_SHARE;
|
|
|
import static com.sheep.gamegroup.util.UMConfigUtils.Event.QR_COPY;
|
|
|
+import static com.sheep.gamegroup.util.UMConfigUtils.Event.SHARE_TO_QQ;
|
|
|
+import static com.sheep.gamegroup.util.UMConfigUtils.Event.SHARE_TO_WEIXIN_CIRCLE;
|
|
|
+import static com.sheep.gamegroup.util.UMConfigUtils.Event.SHARE_TO_WX;
|
|
|
import static com.sheep.gamegroup.util.ViewUtil.getNetImgByName;
|
|
|
|
|
|
/**
|
|
|
@@ -89,40 +74,13 @@ public class InvitationActivity extends AppCompatActivity implements ScalableCar
|
|
|
RecyclerView ask_share_list;
|
|
|
@BindView(R.id.recyclerView)
|
|
|
RecyclerView mRecyclerView;
|
|
|
- @BindView(R.id.blurView)
|
|
|
- ImageView mBlurView;
|
|
|
@BindView(R.id.img_baseactivity_title)
|
|
|
ImageView ivBack;
|
|
|
- @BindView(R.id.txt_baseactivity_title)
|
|
|
- TextView tvTitle;
|
|
|
- private List<Integer> mList = new ArrayList<>();
|
|
|
- private CardScaleHelper mCardScaleHelper = null;
|
|
|
- private Runnable mBlurRunnable;
|
|
|
- private int mLastPos = -1;//滑动当前的位置
|
|
|
- private List<String> localPathList = new ArrayList<>();
|
|
|
- private List<String> RxPathList = new ArrayList<>();
|
|
|
- private String localPicturePath = Environment.getDataDirectory().getAbsolutePath() + "/pic/+pic";
|
|
|
- private String localRxPath = Environment.getDataDirectory().getAbsolutePath() + "/rx/+rx";
|
|
|
|
|
|
GridLayoutManager gridLayoutManager;
|
|
|
UserEntity userEntity = DataUtil.getInstance().getUserEntity();
|
|
|
private FriendAndAwardEntity mEntity;
|
|
|
- private String url;
|
|
|
- private String description;
|
|
|
- private Bitmap mBitmap;
|
|
|
- private File file;
|
|
|
private List<PictureInvitationEntity> mPictureList = new ArrayList<>();
|
|
|
- private List<File> mPictureFileList = new ArrayList<>();
|
|
|
- private List<File> mRxFileList = new ArrayList<>();
|
|
|
- String localPath = "";
|
|
|
- String localRx = "";
|
|
|
- private int position = 0;
|
|
|
- private List<Bitmap> listBitmap = new ArrayList<>();
|
|
|
- private List<Bitmap> listBitmap1 = new ArrayList<>();
|
|
|
- private List<Bitmap> listBitmap2 = new ArrayList<>();
|
|
|
- private MyAdapter adapter;
|
|
|
- private int size = 0;
|
|
|
- private View view = null;
|
|
|
|
|
|
@Override
|
|
|
|
|
|
@@ -131,14 +89,13 @@ public class InvitationActivity extends AppCompatActivity implements ScalableCar
|
|
|
setContentView(R.layout.activity_invitation);
|
|
|
ButterKnife.bind(this);
|
|
|
initView();
|
|
|
+ initListener();
|
|
|
initData();
|
|
|
- // initPicture();
|
|
|
- cerateAdapter(listBitmap1, this);
|
|
|
- getPicetureList();
|
|
|
+ getPictureList();
|
|
|
}
|
|
|
|
|
|
private void initView() {
|
|
|
- tvTitle.setText("邀请赚钱");
|
|
|
+// tvTitle.setText("邀请赚钱");
|
|
|
ivBack.setOnClickListener(new View.OnClickListener() {
|
|
|
@Override
|
|
|
public void onClick(View view) {
|
|
|
@@ -146,18 +103,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 cerateAdapter(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);
|
|
|
cardHelper.attachToRecyclerView(mRecyclerView);
|
|
|
}
|
|
|
@@ -203,11 +164,18 @@ public class InvitationActivity extends AppCompatActivity implements ScalableCar
|
|
|
itemView.setOnClickListener(new View.OnClickListener() {
|
|
|
@Override
|
|
|
public void onClick(View view) {
|
|
|
- if (position == 1 || position == 2) {
|
|
|
- popShare(InvitationActivity.this, url, item, description, file);
|
|
|
- } else {
|
|
|
- popShare(InvitationActivity.this, url, item, description, null);
|
|
|
+ File file = null;
|
|
|
+ switch (position){
|
|
|
+ case 1://qq
|
|
|
+ case 2://wx
|
|
|
+ String fileName = String.format(Locale.CHINA, "share%d.jpg", position);
|
|
|
+ file = new File(ClassFileHelper.DIR, fileName);
|
|
|
+ if(!file.exists())
|
|
|
+ file = ViewUtil.saveImage(mRecyclerView.getChildAt(curPosition).findViewById(R.id.layout_view), ClassFileHelper.DIR, fileName);
|
|
|
+ break;
|
|
|
+
|
|
|
}
|
|
|
+ popShare(InvitationActivity.this, url, item, description, file);
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
@@ -240,7 +208,7 @@ public class InvitationActivity extends AppCompatActivity implements ScalableCar
|
|
|
* @param type qq wx all
|
|
|
* @param description
|
|
|
*/
|
|
|
- public void popShare(Activity activity, final String url, @DialogShare.SHARE_TYPE String type, String description, File bitmap) {
|
|
|
+ public void popShare(Activity activity, final String url, @DialogShare.SHARE_TYPE String type, String description, File file) {
|
|
|
if (activity == null || TextUtils.isEmpty(type) || TextUtils.isEmpty(url)) {
|
|
|
return;
|
|
|
}
|
|
|
@@ -267,39 +235,49 @@ public class InvitationActivity extends AppCompatActivity implements ScalableCar
|
|
|
}));
|
|
|
return;
|
|
|
case DialogShare.QQ:
|
|
|
+ SHARE_TO_QQ.onEvent();
|
|
|
share_media = SHARE_MEDIA.QQ;
|
|
|
break;
|
|
|
case DialogShare.WX:
|
|
|
+ SHARE_TO_WX.onEvent();
|
|
|
share_media = SHARE_MEDIA.WEIXIN;
|
|
|
break;
|
|
|
case DialogShare.WEIXIN_CIRCLE:
|
|
|
default:
|
|
|
+ SHARE_TO_WEIXIN_CIRCLE.onEvent();
|
|
|
share_media = SHARE_MEDIA.WEIXIN_CIRCLE;
|
|
|
break;
|
|
|
}
|
|
|
- UMImage umImage = null;
|
|
|
-
|
|
|
- if (type == DialogShare.QQ || type == DialogShare.WX) {
|
|
|
- umImage = new UMImage(activity, bitmap);
|
|
|
- } else {
|
|
|
- umImage = new UMImage(activity, R.mipmap.icon);
|
|
|
+ UMImage umImage;
|
|
|
+ switch (type){
|
|
|
+ case DialogShare.QQ:
|
|
|
+ case DialogShare.WX:
|
|
|
+ umImage = new UMImage(activity, file);
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ umImage = new UMImage(activity, R.mipmap.icon);
|
|
|
+ break;
|
|
|
}
|
|
|
UMWeb umWeb = new UMWeb(realUrl);
|
|
|
umWeb.setTitle(activity.getResources().getString(R.string.app_name));
|
|
|
umWeb.setThumb(umImage);
|
|
|
umWeb.setDescription(TextUtils.isEmpty(description) ? activity.getResources().getString(R.string.app_name) : description);
|
|
|
- if (type == DialogShare.QQ || type == DialogShare.WX) {
|
|
|
- new ShareAction(activity)
|
|
|
- .setPlatform(share_media)
|
|
|
- .withMedia(umImage)
|
|
|
- .setCallback(new CommonUtil.UMShareListener())
|
|
|
- .share();
|
|
|
- } else {
|
|
|
- new ShareAction(activity)
|
|
|
- .setPlatform(share_media)
|
|
|
- .withMedia(umWeb)
|
|
|
- .setCallback(new CommonUtil.UMShareListener())
|
|
|
- .share();
|
|
|
+ switch (type){
|
|
|
+ case DialogShare.QQ:
|
|
|
+ case DialogShare.WX:
|
|
|
+ new ShareAction(activity)
|
|
|
+ .setPlatform(share_media)
|
|
|
+ .withMedia(umImage)
|
|
|
+ .setCallback(new CommonUtil.UMShareListener())
|
|
|
+ .share();
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ new ShareAction(activity)
|
|
|
+ .setPlatform(share_media)
|
|
|
+ .withMedia(umWeb)
|
|
|
+ .setCallback(new CommonUtil.UMShareListener())
|
|
|
+ .share();
|
|
|
+ break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -320,18 +298,8 @@ public class InvitationActivity extends AppCompatActivity implements ScalableCar
|
|
|
public void onNext(BaseMessage baseMessage) {
|
|
|
if (baseMessage != null) {
|
|
|
mEntity = FastJsonUtils.toBean(JSONObject.toJSONString(baseMessage.getData()), FriendAndAwardEntity.class);
|
|
|
- description = mEntity.getShare_desc();
|
|
|
ViewUtil.newInstance().hideProgress(InvitationActivity.this);
|
|
|
getmEntity();
|
|
|
- runOnUiThread(new Runnable() {
|
|
|
- @Override
|
|
|
- public void run() {
|
|
|
- /* tvSize.setText(mEntity.getFriend_count() + "");
|
|
|
- tvMoney.setText(mEntity.getAward());*/
|
|
|
- }
|
|
|
- });
|
|
|
- } else {
|
|
|
- /* ViewUtil.newInstance().hideProgress(activity);*/
|
|
|
}
|
|
|
|
|
|
}
|
|
|
@@ -346,32 +314,22 @@ public class InvitationActivity extends AppCompatActivity implements ScalableCar
|
|
|
public void call(UserEntity result) {
|
|
|
if (result != null) {
|
|
|
userEntity = result;
|
|
|
- String audit_total_audit = String.format(getResources().getString(R.string.my_invitation_str), userEntity.getInvitation_code());
|
|
|
- /* my_invitation_tv.setText(audit_total_audit);*/
|
|
|
- url = userEntity.getShareLink();
|
|
|
- init(url, description);
|
|
|
+ init(userEntity.getShareLink(), mEntity.getShare_desc());
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+ private int curPosition = 0;
|
|
|
@Override
|
|
|
public void onPageSelected(int position) {
|
|
|
- try {
|
|
|
- mBitmap=getViewBitmap(mRecyclerView.getChildAt(position).findViewById(R.id.layout_view));
|
|
|
- file=getViewFile(mRecyclerView.getChildAt(position).findViewById(R.id.layout_view));
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- Log.i("aaaa", "当前位置" + position);
|
|
|
+ curPosition = position;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 来获取邀请图片,
|
|
|
*/
|
|
|
- private void getPicetureList() {
|
|
|
- ArrayList<PictureInvitationEntity> list = new ArrayList<>();
|
|
|
+ private void getPictureList() {
|
|
|
SheepApp
|
|
|
.getInstance()
|
|
|
.getNetComponent()
|
|
|
@@ -382,141 +340,15 @@ public class InvitationActivity extends AppCompatActivity implements ScalableCar
|
|
|
.subscribe(new SheepSubscriber<BaseMessage>(SheepApp.mContext) {
|
|
|
@Override
|
|
|
public void onNext(BaseMessage baseMessage) {
|
|
|
- LogUtil.logI("onNext__getPicetureList--" + new Gson().toJson(baseMessage));
|
|
|
mPictureList.addAll(baseMessage.getDataList(PictureInvitationEntity.class));
|
|
|
- downloadPictures();
|
|
|
+ mRecyclerViewAdapter.notifyDataSetChanged();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void onError(BaseMessage baseMessage) {
|
|
|
- LogUtil.logI("onError__getPicetureList--" + new Gson().toJson(baseMessage));
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * @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() {
|
|
|
- Log.i("aaaa", "下载成功");
|
|
|
- if (position == mPictureList.size()-1) {
|
|
|
- Log.i("aaaa", "下载成功"+"---"+size+"-----"+mPictureList.size());
|
|
|
- createBitmapList(position);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void onDownloading(int progress) {
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void onDownloadFailed() {
|
|
|
- Log.i("aaaa", "下载失败");
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- 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 bitmapx = ZXingHelper.createQRCodeWithLogo(mPictureList.get(y).getLink(), logo);
|
|
|
- listBitmap2.add(bitmapx);
|
|
|
- }
|
|
|
- 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;
|
|
|
- }
|
|
|
- }
|
|
|
- };
|
|
|
-
|
|
|
- /**
|
|
|
- * @param addViewContent
|
|
|
- * @return
|
|
|
- */
|
|
|
- private Bitmap getViewBitmap(View addViewContent) {
|
|
|
- if (addViewContent==null){
|
|
|
- return null;
|
|
|
- }
|
|
|
- addViewContent.setDrawingCacheEnabled(true);
|
|
|
- addViewContent.measure(View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED), View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED));
|
|
|
- addViewContent.layout(0, 0, addViewContent.getMeasuredWidth(), addViewContent.getMeasuredHeight());
|
|
|
- addViewContent.buildDrawingCache();
|
|
|
- Bitmap cacheBitmap = addViewContent.getDrawingCache();
|
|
|
- Bitmap bitmap = Bitmap.createBitmap(cacheBitmap);
|
|
|
- return ViewUtil.getCacheBitmapFromView((View) addViewContent.getParent());
|
|
|
- }
|
|
|
- private File getViewFile(View addViewContent) {
|
|
|
- if (addViewContent==null){
|
|
|
- return null;
|
|
|
- }
|
|
|
- return ViewUtil.saveImage(addViewContent, ClassFileHelper.DIR, System.currentTimeMillis() + ".jpg");
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * 合成图片
|
|
|
- * @param firstBitmap
|
|
|
- * @param secondBitmap
|
|
|
- * @return
|
|
|
- */
|
|
|
- private Bitmap mergeBitmap(Bitmap firstBitmap, Bitmap secondBitmap) {
|
|
|
- Bitmap bitmap = Bitmap.createBitmap(firstBitmap.getWidth(), firstBitmap.getHeight(), firstBitmap.getConfig());
|
|
|
- Canvas canvas = new Canvas(bitmap);
|
|
|
- float w = firstBitmap.getWidth();
|
|
|
- float h = firstBitmap.getHeight();
|
|
|
- Matrix matrix = new Matrix();
|
|
|
- //确定secondBitmap大小比例
|
|
|
- matrix.setScale(secondBitmap.getWidth(), h / secondBitmap.getHeight());
|
|
|
- canvas.drawBitmap(firstBitmap, new Matrix(), null);
|
|
|
- canvas.drawBitmap(zoomImage(secondBitmap, 50, 50), 320, 320, null);
|
|
|
- LogUtil.logI("bitmap----first---" + firstBitmap.getWidth() + "--" + firstBitmap.getHeight());
|
|
|
- LogUtil.logI("bitmap----secound---" + secondBitmap.getWidth() + "--" + secondBitmap.getHeight());
|
|
|
- return bitmap;
|
|
|
- }
|
|
|
-
|
|
|
- public static Bitmap zoomImage(Bitmap bgimage, double newWidth, double newHeight) {
|
|
|
- // 获取这个图片的宽和高
|
|
|
- float width = bgimage.getWidth();
|
|
|
- float height = bgimage.getHeight();
|
|
|
- // 创建操作图片用的matrix对象
|
|
|
- Matrix matrix = new Matrix();
|
|
|
- // 计算宽高缩放率
|
|
|
- float scaleWidth = ((float) newWidth) / width;
|
|
|
- float scaleHeight = ((float) newHeight) / height;
|
|
|
- // 缩放图片动作
|
|
|
- matrix.postScale(scaleWidth, scaleHeight);
|
|
|
- Bitmap bitmap = Bitmap.createBitmap(bgimage, 0, 0, (int) width,
|
|
|
- (int) height, matrix, true);
|
|
|
- return bitmap;
|
|
|
- }
|
|
|
|
|
|
}
|