消息相关优化汇总1120(3,6未完成)
This commit is contained in:
@ -69,6 +69,8 @@ public class MessageShareUtils {
|
||||
|
||||
private Context context;
|
||||
|
||||
private Activity activity; // 用来关闭分享页面
|
||||
|
||||
public static MessageShareUtils getInstance(Context context) {
|
||||
if (instance == null) {
|
||||
instance = new MessageShareUtils();
|
||||
@ -82,6 +84,7 @@ public class MessageShareUtils {
|
||||
public void showShareWindows(View view, Bitmap bitmap, String picName, boolean ispopupWindow){
|
||||
this.shareBm = bitmap;
|
||||
this.picName = picName;
|
||||
this.activity= (Activity) context;
|
||||
|
||||
RelativeLayout contentView = new RelativeLayout(context);
|
||||
contentView.setBackgroundColor(0x8c000000);
|
||||
@ -181,9 +184,11 @@ public class MessageShareUtils {
|
||||
switch (holder.getPosition()){
|
||||
case 0:
|
||||
wechatSahre();
|
||||
activity.finish();
|
||||
break;
|
||||
case 1:
|
||||
wechatMomentsSahre();
|
||||
activity.finish();
|
||||
break;
|
||||
case 2:
|
||||
qqSahre();
|
||||
@ -197,7 +202,8 @@ public class MessageShareUtils {
|
||||
|
||||
if (popupWindow == null) return;
|
||||
popupWindow.dismiss();
|
||||
break;
|
||||
activity.finish();
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
@ -259,6 +265,8 @@ public class MessageShareUtils {
|
||||
private void wechatSahre(){
|
||||
Utils.toast(context,"分享跳转中...");
|
||||
|
||||
api = WXAPIFactory.createWXAPI(context, "wx3ffd0785fad18111"); //初始化微信分享
|
||||
|
||||
WXImageObject imgObj = new WXImageObject();
|
||||
imgObj.setImagePath(context.getExternalCacheDir().getPath() + "/ShareImg/" + picName);
|
||||
WXMediaMessage msg = new WXMediaMessage();
|
||||
@ -336,6 +344,8 @@ public class MessageShareUtils {
|
||||
public IUiListener QqShareListener = new IUiListener() {
|
||||
@Override
|
||||
public void onComplete(Object o) {
|
||||
activity.finish();
|
||||
activity.overridePendingTransition(0, 0);//禁止退出Activity 动画
|
||||
Utils.toast(context, "分享成功");
|
||||
}
|
||||
|
||||
@ -346,6 +356,8 @@ public class MessageShareUtils {
|
||||
|
||||
@Override
|
||||
public void onCancel() {
|
||||
activity.finish();
|
||||
activity.overridePendingTransition(0, 0);//禁止退出Activity 动画
|
||||
Utils.toast(context, "分享已取消");
|
||||
}
|
||||
};
|
||||
@ -364,6 +376,7 @@ public class MessageShareUtils {
|
||||
return false;
|
||||
}
|
||||
|
||||
//写到存储卡中
|
||||
public void writeBitmap(String path, String name, Bitmap bitmap, boolean isToast) {
|
||||
File file = new File(path);
|
||||
if (!file.exists()) {
|
||||
|
||||
Reference in New Issue
Block a user