瀏覽代碼

朋友圈分享时把标题与描述合并到一起显示;
邀请赚钱界面分享时,只分享图片

zengjiebin 7 年之前
父節點
當前提交
0138745993

+ 4 - 3
app/src/main/java/com/sheep/gamegroup/util/CommonUtil.java

@@ -971,14 +971,15 @@ public class CommonUtil {
                 share_media = SHARE_MEDIA.WEIXIN_CIRCLE;
                 break;
         }
+        String title = activity.getResources().getString(R.string.app_name);
         UMImage umImage = new UMImage(activity, R.mipmap.icon);
         UMWeb umWeb = new UMWeb(realUrl);
-        umWeb.setTitle(activity.getResources().getString(R.string.app_name));
+        umWeb.setTitle(title);
         umWeb.setThumb(umImage);
-        umWeb.setDescription(TextUtils.isEmpty(description) ? activity.getResources().getString(R.string.app_name) : description);
+        umWeb.setDescription(TextUtils.isEmpty(description) ? title : description);
         switch (type){
             case DialogShare.WEIXIN_CIRCLE://微信朋友圈分享时只会显示标题,所以这里使用描述
-                umWeb.setTitle(TextUtils.isEmpty(description) ? activity.getResources().getString(R.string.app_name) : description);
+                umWeb.setTitle(TextUtils.isEmpty(description) ? title : (title + "\n" +description));
                 break;
         }
         new ShareAction(activity)

+ 1 - 1
app/src/main/java/com/sheep/gamegroup/util/ViewUtil.java

@@ -778,7 +778,7 @@ public class ViewUtil {
         web.setDescription("更懂你的赚钱工具,超多福利,超多赏金,拿到你手软!");
         switch (media){
             case WEIXIN_CIRCLE:
-                web.setTitle(web.getDescription());
+                web.setTitle(web.getTitle() + "\n" + web.getDescription());
                 break;
         }
         ShareAction action = new ShareAction(activity);

+ 48 - 53
app/src/main/java/com/sheep/gamegroup/view/activity/ActInvitation.java

@@ -306,7 +306,7 @@ public class ActInvitation extends BaseActivity {
         final ImageView image_bottom = itemView.findViewById(R.id.image_bottom);
         final ImageView image_logo = itemView.findViewById(R.id.image_logo);
         final TextView image_tip = itemView.findViewById(R.id.image_tip);
-        if(viewPager != null) {
+        if (viewPager != null) {
             viewPager.postDelayed(new Runnable() {
                 @Override
                 public void run() {
@@ -407,29 +407,29 @@ public class ActInvitation extends BaseActivity {
                     @Override
                     public void onClick(View view) {
                         File file = null;
-                        switch (position) {
-                            case 2://qq
-                            case 1://wx
-                                PictureInvitationEntity picItem = ListUtil.getItem(mPictureList, curPosition);
-                                if (picItem != null && picItem.isLoaded()) {
-                                    try {
-                                        String fileName = String.format(Locale.CHINA, "share%d%s%d.jpg", curPosition, 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();
-                                        G.showToast(e.getMessage());
-                                        return;
-                                    }
-                                } else {
-                                    G.showToast("图片正在加载中,请稍等");
-                                    return;
+//                        switch (position) {
+//                            case 2://qq
+//                            case 1://wx
+                        PictureInvitationEntity picItem = ListUtil.getItem(mPictureList, curPosition);
+                        if (picItem != null && picItem.isLoaded()) {
+                            try {
+                                String fileName = String.format(Locale.CHINA, "share%d%s%d.jpg", curPosition, BuildConfig.FLAVOR, picItem.getPicture().hashCode());
+                                file = new File(ClassFileHelper.DIR, fileName);
+                                if (!file.exists()) {
+                                    file = ViewUtil.saveImage(viewList.get(curPosition), ClassFileHelper.DIR, fileName);
                                 }
-                                break;
-
+                            } catch (Exception e) {
+                                e.printStackTrace();
+                                G.showToast(e.getMessage());
+                                return;
+                            }
+                        } else {
+                            G.showToast("图片正在加载中,请稍等");
+                            return;
                         }
+//                                break;
+//
+//                        }
                         popShare(ActInvitation.this, url, item, description, file);
                     }
                 });
@@ -503,38 +503,33 @@ public class ActInvitation extends BaseActivity {
                 share_media = SHARE_MEDIA.WEIXIN_CIRCLE;
                 break;
         }
+        String title = activity.getResources().getString(R.string.app_name);
         UMImage umImage;
-        UMWeb umWeb = new UMWeb(realUrl);
-        switch (type) {
-            case DialogShare.QQ:
-            case DialogShare.WX:
-                umImage = new UMImage(activity, file);
-                break;
-            default:
-                umImage = new UMImage(activity, R.mipmap.icon);
-                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);
-                break;
-        }
-        switch (type) {
-            case DialogShare.QQ:
-            case DialogShare.WX:
-                new ShareAction(activity)
-                        .setPlatform(share_media)
-                        .withMedia(umImage)
-                        .setCallback(new CommonUtil.CommonUMShareListener())
-                        .share();
-                break;
-            case DialogShare.WEIXIN_CIRCLE://微信朋友圈分享时只会显示标题,所以这里使用描述
-                umWeb.setTitle(TextUtils.isEmpty(description) ? activity.getResources().getString(R.string.app_name) : description);
-            default:
-                new ShareAction(activity)
-                        .setPlatform(share_media)
-                        .withMedia(umWeb)
-                        .setCallback(new CommonUtil.CommonUMShareListener())
-                        .share();
-                break;
+        UMWeb umWeb;
+        if (file == null || !file.exists()) {
+            umImage = new UMImage(SheepApp.getInstance(), R.mipmap.icon);
+            umWeb = new UMWeb(realUrl);
+            umWeb.setTitle(title);
+            umWeb.setThumb(umImage);
+            umWeb.setDescription(TextUtils.isEmpty(description) ? title : description);
+            switch (type) {
+                case DialogShare.WEIXIN_CIRCLE://微信朋友圈分享时只会显示标题,所以这里使用描述
+                    umWeb.setTitle(TextUtils.isEmpty(description) ? title : (title + "\n" + description));
+                default:
+                    new ShareAction(activity)
+                            .setPlatform(share_media)
+                            .withMedia(umWeb)
+                            .setCallback(new CommonUtil.CommonUMShareListener())
+                            .share();
+                    break;
+            }
+        } else {
+            umImage = new UMImage(activity, file);
+            new ShareAction(activity)
+                    .setPlatform(share_media)
+                    .withMedia(umImage)
+                    .setCallback(new CommonUtil.CommonUMShareListener())
+                    .share();
         }
     }