瀏覽代碼

分享统一优化并修复type错误;
添加内部h5的分享js

zengjiebin 7 年之前
父節點
當前提交
70183792de
共有 20 個文件被更改,包括 557 次插入605 次删除
  1. 3 4
      app/src/main/java/com/sheep/gamegroup/model/entity/UserEntity.java
  2. 5 249
      app/src/main/java/com/sheep/gamegroup/util/CommonUtil.java
  3. 5 4
      app/src/main/java/com/sheep/gamegroup/util/Jump2View.java
  4. 2 4
      app/src/main/java/com/sheep/gamegroup/util/TestUtil.java
  5. 10 25
      app/src/main/java/com/sheep/gamegroup/util/ViewUtil.java
  6. 2 1
      app/src/main/java/com/sheep/gamegroup/util/WebViewJs.java
  7. 2 0
      app/src/main/java/com/sheep/gamegroup/util/js/BaseActWeb.java
  8. 41 9
      app/src/main/java/com/sheep/gamegroup/util/js/KFZSJs.java
  9. 36 0
      app/src/main/java/com/sheep/gamegroup/util/share/CommonUMShareListener.java
  10. 403 0
      app/src/main/java/com/sheep/gamegroup/util/share/ShareLinkConfig.java
  11. 2 2
      app/src/main/java/com/sheep/gamegroup/view/activity/ActGiftDetail.java
  12. 8 121
      app/src/main/java/com/sheep/gamegroup/view/activity/ActInvitation.java
  13. 2 2
      app/src/main/java/com/sheep/gamegroup/view/activity/ActSignCardRecord.java
  14. 3 2
      app/src/main/java/com/sheep/gamegroup/view/activity/ActUserAppHome.java
  15. 2 1
      app/src/main/java/com/sheep/gamegroup/view/activity/ActWeb.java
  16. 4 141
      app/src/main/java/com/sheep/gamegroup/view/activity/ActWebX5.java
  17. 3 3
      app/src/main/java/com/sheep/gamegroup/view/activity/PersonalInfoAct.java
  18. 17 31
      app/src/main/java/com/sheep/gamegroup/view/dialog/DialogShare.java
  19. 3 3
      app/src/main/java/com/sheep/gamegroup/view/fragment/FgtPersonalCenter.java
  20. 4 3
      app/src/main/java/com/sheep/jiuyan/samllsheep/ui/activity/SignActivity.java

+ 3 - 4
app/src/main/java/com/sheep/gamegroup/model/entity/UserEntity.java

@@ -3,9 +3,8 @@ package com.sheep.gamegroup.model.entity;
 import android.text.TextUtils;
 
 import com.sheep.gamegroup.util.BinaryUtils;
-import com.sheep.gamegroup.util.CommonUtil;
 import com.sheep.gamegroup.util.TestUtil;
-import com.sheep.gamegroup.view.dialog.DialogShare;
+import com.sheep.gamegroup.util.share.ShareLinkConfig;
 
 import org.xutils.db.annotation.Column;
 import org.xutils.db.annotation.Table;
@@ -365,8 +364,8 @@ public class UserEntity implements Serializable {
     }
 
     //测试服用测试分享链接,正式服用正式的
-    public String getShareLink(@DialogShare.SHARE_TYPE String type) {
-        return CommonUtil.getInstance().jointString(getShareLink(), type);
+    public String getShareLink(@ShareLinkConfig.SHARE_TYPE String type) {
+        return ShareLinkConfig.jointString(getShareLink(), type);
     }
 
     //测试服用测试分享链接,正式服用正式的

+ 5 - 249
app/src/main/java/com/sheep/gamegroup/util/CommonUtil.java

@@ -4,11 +4,9 @@ import android.annotation.SuppressLint;
 import android.app.Activity;
 import android.content.Context;
 import android.content.Intent;
-import android.content.pm.PackageInfo;
 import android.graphics.Color;
 import android.graphics.drawable.Drawable;
 import android.graphics.drawable.GradientDrawable;
-import android.media.MediaMetadataRetriever;
 import android.net.Uri;
 import android.os.Handler;
 import android.os.Message;
@@ -41,16 +39,17 @@ import com.sheep.gamegroup.greendao.DDProviderHelper;
 import com.sheep.gamegroup.greendao.download.AcceptTaskRecord;
 import com.sheep.gamegroup.greendao.download.DownLoadInfo;
 import com.sheep.gamegroup.helper.TaskHelper;
+import com.sheep.gamegroup.model.entity.Applications;
 import com.sheep.gamegroup.model.entity.BaseMessage;
 import com.sheep.gamegroup.model.entity.DialogConfig;
 import com.sheep.gamegroup.model.entity.Ext;
 import com.sheep.gamegroup.model.entity.FriendAndAwardEntity;
 import com.sheep.gamegroup.model.entity.GameAccountEntity;
-import com.sheep.gamegroup.model.entity.Applications;
 import com.sheep.gamegroup.model.entity.GameEntity;
 import com.sheep.gamegroup.model.entity.GameListTag;
 import com.sheep.gamegroup.model.entity.GiftBagApp;
 import com.sheep.gamegroup.model.entity.HomeListEntity;
+import com.sheep.gamegroup.model.entity.Release_task;
 import com.sheep.gamegroup.model.entity.RobTask;
 import com.sheep.gamegroup.model.entity.RouserArticlesEntity;
 import com.sheep.gamegroup.model.entity.SlideshowEty;
@@ -58,33 +57,27 @@ import com.sheep.gamegroup.model.entity.TaskAcceptedEty;
 import com.sheep.gamegroup.model.entity.TaskChild;
 import com.sheep.gamegroup.model.entity.TaskDescEntity;
 import com.sheep.gamegroup.model.entity.TaskEty;
-import com.sheep.gamegroup.model.entity.Release_task;
 import com.sheep.gamegroup.model.entity.UserEntity;
 import com.sheep.gamegroup.model.entity.WithdrawalEty;
 import com.sheep.gamegroup.model.entity.XiaomiGameEntity;
 import com.sheep.gamegroup.model.util.EntityUtils;
 import com.sheep.gamegroup.model.util.SheepSubscriber;
 import com.sheep.gamegroup.usage.AppUsageManager;
+import com.sheep.gamegroup.util.share.ShareLinkConfig;
 import com.sheep.gamegroup.view.activity.GameTaskOrderListAct;
 import com.sheep.gamegroup.view.dialog.DialogNewbieTaskList;
-import com.sheep.gamegroup.view.dialog.DialogShare;
 import com.sheep.jiuyan.samllsheep.BuildConfig;
 import com.sheep.jiuyan.samllsheep.R;
 import com.sheep.jiuyan.samllsheep.SheepApp;
 import com.sheep.jiuyan.samllsheep.service.AutoCheckService;
 import com.sheep.jiuyan.samllsheep.service.DownloadService;
 import com.sheep.jiuyan.samllsheep.utils.ClassFileHelper;
-import com.sheep.jiuyan.samllsheep.utils.FileUtil;
 import com.sheep.jiuyan.samllsheep.utils.G;
 import com.sheep.jiuyan.samllsheep.utils.PackageUtil;
 import com.sheep.jiuyan.samllsheep.utils.SpUtils;
-import com.umeng.socialize.ShareAction;
 import com.umeng.socialize.UMAuthListener;
 import com.umeng.socialize.UMShareAPI;
-import com.umeng.socialize.UMShareListener;
 import com.umeng.socialize.bean.SHARE_MEDIA;
-import com.umeng.socialize.media.UMImage;
-import com.umeng.socialize.media.UMWeb;
 import com.zhy.http.okhttp.OkHttpUtils;
 import com.zhy.http.okhttp.callback.FileCallBack;
 
@@ -93,7 +86,6 @@ import org.afinal.simplecache.ApiKey;
 import org.greenrobot.eventbus.EventBus;
 
 import java.io.File;
-import java.io.IOException;
 import java.lang.reflect.Field;
 import java.net.HttpURLConnection;
 import java.net.URL;
@@ -109,20 +101,13 @@ import java.util.Locale;
 import java.util.Map;
 import java.util.Set;
 
-import okhttp3.Call;
 import io.reactivex.android.schedulers.AndroidSchedulers;
-import rx.functions.Action1;
 import io.reactivex.schedulers.Schedulers;
+import okhttp3.Call;
+import rx.functions.Action1;
 
-import static com.sheep.gamegroup.util.UMConfigUtils.Event.LINK_SHARE;
 import static com.sheep.gamegroup.util.UMConfigUtils.Event.NEWBIE_TASK;
-import static com.sheep.gamegroup.util.UMConfigUtils.Event.QR_COPY;
 import static com.sheep.gamegroup.util.UMConfigUtils.Event.RECEIVE_AWARD_GAME_TASK;
-import static com.sheep.gamegroup.util.UMConfigUtils.Event.SHARE_SYS_SEND;
-import static com.sheep.gamegroup.util.UMConfigUtils.Event.SHARE_TO_QQ;
-import static com.sheep.gamegroup.util.UMConfigUtils.Event.SHARE_TO_QZONE;
-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.UMConfigUtils.Event.XIAOMI_GAME_RECEIVE;
 import static com.sheep.gamegroup.view.adapter.TryMakeMoneyAdp.PUBLIC_TAG_PREFIX_TEXTVIEW_LIST;
 import static com.sheep.gamegroup.view.adapter.WelfareAdapter.TO_REFRESH;
@@ -915,146 +900,6 @@ public class CommonUtil {
         timerHashMap.clear();
     }
 
-    /**
-     * 分享
-     *
-     * @param activity 如果act
-     * @param url
-     * @param type        qq wx all
-     * @param description
-     */
-    public void popShare(Activity activity, final String url, @DialogShare.SHARE_TYPE String type, String description) {
-        if (activity == null || TextUtils.isEmpty(type) || TextUtils.isEmpty(url)) {
-            return;
-        }
-        final String realUrl = jointString(url, type);
-        SHARE_MEDIA share_media;
-        switch (type) {
-            case DialogShare.ALL:
-                ViewUtil.showShareDialog(activity, realUrl, description);
-                return;
-            case DialogShare.SYS_SEND:
-                SHARE_SYS_SEND.onEvent();
-                shareBySysSend(activity);
-                return;
-            case DialogShare.FACE_TO_FACE:
-                ViewUtil.showQR(activity, realUrl);
-                return;
-            case DialogShare.COPY_SHARE_LINK:
-                LINK_SHARE.onEvent();
-                ViewUtil.showMsgDialog(activity, new DialogConfig().setTitle("分享链接").setMsg(realUrl)
-                        .setMsgMore("他人通过该链接加入小绵羊即可成为你的好友").setMsgMoreColor(R.color.txt_black_9e9c9c)
-                        .setBtnLeftText("复制链接").setBtnLeftOnClickListener(new View.OnClickListener() {
-                            @Override
-                            public void onClick(View view) {
-                                QR_COPY.onEvent();
-                                StringUtils.CopyText(realUrl);
-                                G.showToast("复制链接成功");
-                            }
-                        }));
-                return;
-            case DialogShare.QQ:
-                SHARE_TO_QQ.onEvent();
-                share_media = SHARE_MEDIA.QQ;
-                break;
-            case DialogShare.QZONE:
-                SHARE_TO_QZONE.onEvent();
-                share_media = SHARE_MEDIA.QZONE;
-                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;
-        }
-        String title = activity.getResources().getString(R.string.app_name);
-        UMImage umImage = new UMImage(activity, R.mipmap.icon);
-        UMWeb 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));
-                break;
-        }
-        new ShareAction(activity)
-                .setPlatform(share_media)
-                .withMedia(umWeb)
-                .setCallback(activity instanceof UMShareListener ? (UMShareListener) activity : new CommonUMShareListener())
-                .share();
-    }
-
-    public void shareBySysSend(Activity activity) {
-        PackageInfo packageInfo = ApkUtils.getPackageInfo(SheepApp.getInstance().getPackageName());
-        if (packageInfo != null && packageInfo.applicationInfo != null && !TextUtils.isEmpty(packageInfo.applicationInfo.sourceDir)) {
-            String dir = DIR;
-            //File dir = SheepApp.getInstance().getDir("apk", Context.MODE_PRIVATE);
-            File file = new File(dir, String.format(Locale.CHINA, "sheep_release_v%s_%d-%s.apk", packageInfo.versionName, packageInfo.versionCode, DataUtil.getInstance().getInvitationCode()));
-            if (!file.exists()) {
-                try {
-                    FileUtil.copyFile(new File(packageInfo.applicationInfo.sourceDir), file);
-                    ZipChannelUtil.writeQUA(file, DataUtil.getInstance().getInvitationCode());
-                } catch (IOException e) {
-                    e.printStackTrace();
-                }
-            }
-            if (file.exists())
-                shareFile(activity, file);
-            else
-                G.showToast("暂不支持,或未打开权限");
-        } else {
-            G.showToast("暂不支持");
-        }
-    }
-
-    // 調用系統方法分享文件
-    public static void shareFile(Context context, File file) {
-        if (null != file && file.exists()) {
-            Intent share = new Intent(Intent.ACTION_SEND);
-            share.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));
-            share.setType(getMimeType(file.getAbsolutePath()));//此处可发送多种文件
-            share.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
-            share.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
-            context.startActivity(Intent.createChooser(share, "分享文件"));
-        } else {
-            G.showToast("分享文件不存在");
-        }
-    }
-
-    // 根据文件后缀名获得对应的MIME类型。
-    private static String getMimeType(String filePath) {
-        MediaMetadataRetriever mmr = new MediaMetadataRetriever();
-        String mime = "*/*";
-        if (filePath != null) {
-            try {
-                mmr.setDataSource(filePath);
-                mime = mmr.extractMetadata(MediaMetadataRetriever.METADATA_KEY_MIMETYPE);
-            } catch (IllegalStateException e) {
-                return mime;
-            } catch (IllegalArgumentException e) {
-                return mime;
-            } catch (RuntimeException e) {
-                return mime;
-            }
-        }
-        return mime;
-    }
-
-    /**
-     * 分享
-     *
-     * @param activity
-     * @param url
-     * @param type
-     */
-    public void popShare(Activity activity, String url, @DialogShare.SHARE_TYPE String type) {
-        popShare(activity, url, type, null);
-    }
 
     /**
      * 把homeList列表分开,例如:超维对决显示的图片是充满的,并且在绵羊头条下面
@@ -1076,79 +921,6 @@ public class CommonUtil {
         }));
     }
 
-    //尝试直接分享小绵羊
-    public void tryShowShareDialog(final Activity activity) {
-        tryShowShareDialog(null, activity);
-    }
-
-    /**
-     * 尝试直接分享小绵羊
-     * @param action1 初始化view
-     * @param activity
-     */
-    public void tryShowShareDialog(final Action1<View> action1, final Activity activity) {
-        callActionWithFriendCountAndAward(new Action1<FriendAndAwardEntity>() {
-            @Override
-            public void call(FriendAndAwardEntity result) {
-                if (result != null) {
-                    tryShowShareDialog(activity, result.getShare_desc(), action1);
-                } else {
-                    if(action1 != null)
-                        action1.call(null);
-                    G.showToast("分享功能调试中");
-                }
-            }
-        });
-    }
-
-    //显示分享对话框
-    public void tryShowShareDialog(final Activity activity, final String description) {
-        tryShowShareDialog(activity, description, null);
-    }
-
-    //显示分享对话框
-    public void tryShowShareDialog(final Activity activity, final String description, final Action1<View> action1) {
-        CommonUtil.getInstance().callActionWithUserInfo(new Action1<UserEntity>() {
-            @Override
-            public void call(UserEntity userEntity) {
-                if (userEntity == null) {
-                    G.showToast("分享功能调试中");
-                    if(action1 != null)
-                        action1.call(null);
-                    return;
-                }
-                String url = userEntity.getShareLink();
-                ViewUtil.showShareDialog(activity, url, description, action1);
-            }
-        });
-    }
-
-    public static class CommonUMShareListener implements com.umeng.socialize.UMShareListener {
-
-        @Override
-        public void onStart(SHARE_MEDIA share_media) {
-            LogUtil.println("UMShareListener", "start", share_media.getName());
-        }
-
-        @Override
-        public void onResult(SHARE_MEDIA share_media) {
-            LogUtil.println("UMShareListener", "result", share_media.getName());
-        }
-
-        @Override
-        public void onError(SHARE_MEDIA share_media, Throwable throwable) {
-            String msg = throwable.getMessage();
-            G.showToast(msg != null && msg.contains("没有安装应用") ? "没有安装应用" : msg);
-            LogUtil.println("UMShareListener", "error", share_media.getName() +
-                    ",msg:" + throwable.getMessage());
-        }
-
-        @Override
-        public void onCancel(SHARE_MEDIA share_media) {
-            LogUtil.println("UMShareListener", "delete", share_media.getName());
-        }
-    }
-
     /**
      * 支付接口调用
      *
@@ -2165,22 +1937,6 @@ public class CommonUtil {
     }
 
     /**
-     * 分享 url type 拼接
-     */
-    public String jointString(String url, @DialogShare.SHARE_TYPE String type) {
-        if (url.contains("&type="))
-            return url;
-        switch (type) {
-            case "qq":
-                return url + "&type=2";
-            case "wx":
-                return url + "&type=1";
-            default:
-                return url + "&type=4";
-        }
-    }
-
-    /**
      * js 下载
      */
     public void showDownLoad(final Activity activity, String url, final String name) {

+ 5 - 4
app/src/main/java/com/sheep/gamegroup/util/Jump2View.java

@@ -42,6 +42,7 @@ import com.sheep.gamegroup.model.entity.VersionInfo;
 import com.sheep.gamegroup.model.entity.WebviewEntity;
 import com.sheep.gamegroup.model.entity.XianWanEntity;
 import com.sheep.gamegroup.model.util.SheepSubscriber;
+import com.sheep.gamegroup.util.share.ShareLinkConfig;
 import com.sheep.gamegroup.view.activity.ActArticleComment;
 import com.sheep.gamegroup.view.activity.ActAudit;
 import com.sheep.gamegroup.view.activity.ActBindMobileRegister;
@@ -348,7 +349,7 @@ public class Jump2View {
             public void call(UserEntity userEntity) {
                 if (userEntity != null && !TextUtils.isEmpty(userEntity.getShare_link())) {
                     //PersionInfoAct.java与AskGetMoneyAct.java中分享二维码时的图片预下载
-                    GlideImageLoader.saveAndSetRqImage(null, userEntity.getShareLink(DialogShare.FACE_TO_FACE), 800);
+                    GlideImageLoader.saveAndSetRqImage(null, userEntity.getShareLink(ShareLinkConfig.FACE_TO_FACE), 800);
                 }
 
                 if (userEntity != null && userEntity.canBindMobile()
@@ -376,7 +377,7 @@ public class Jump2View {
             public void call(UserEntity userEntity) {
                 if (userEntity != null && !TextUtils.isEmpty(userEntity.getShare_link())) {
                     //PersionInfoAct.java与AskGetMoneyAct.java中分享二维码时的图片预下载
-                    GlideImageLoader.saveAndSetRqImage(null, userEntity.getShareLink(DialogShare.FACE_TO_FACE), 800);
+                    GlideImageLoader.saveAndSetRqImage(null, userEntity.getShareLink(ShareLinkConfig.FACE_TO_FACE), 800);
                 }
 
                 if (userEntity != null && userEntity.canBindMobile()
@@ -1653,7 +1654,7 @@ public class Jump2View {
                 @Override
                 public void call(String find_share_url) {
                     String url = String.format(Locale.CHINA, "%s?authorization=%s&%s=%d&invitation_code=%s", find_share_url, SpUtils.getToken(activity), idName, id, DataUtil.getInstance().getInvitationCode());
-                    CommonUtil.getInstance().popShare(activity, url, DialogShare.ALL, description);
+                    new ShareLinkConfig().setLink(url).setDes(description).toShare(activity);
                 }
             });
         } catch (Exception e) {
@@ -1668,7 +1669,7 @@ public class Jump2View {
                 @Override
                 public void call(String find_share_url) {
                     String url = String.format(Locale.CHINA, "%s?authorization=%s&%s=%d&invitation_code=%s", find_share_url, SpUtils.getToken(activity), idName, id, DataUtil.getInstance().getInvitationCode());
-                    CommonUtil.getInstance().popShare(activity, url, DialogShare.ALL);
+                    new ShareLinkConfig().setLink(url).toShare(activity);
                 }
             });
         } catch (Exception e) {

+ 2 - 4
app/src/main/java/com/sheep/gamegroup/util/TestUtil.java

@@ -43,7 +43,6 @@ import com.sheep.gamegroup.view.dialog.DialogGameOrTaskOrGift;
 import com.sheep.gamegroup.view.dialog.DialogLoading;
 import com.sheep.gamegroup.view.dialog.DialogNewbieTaskList;
 import com.sheep.gamegroup.view.dialog.DialogProgress;
-import com.sheep.gamegroup.view.dialog.DialogShare;
 import com.sheep.jiuyan.samllsheep.BuildConfig;
 import com.sheep.jiuyan.samllsheep.R;
 import com.sheep.jiuyan.samllsheep.SheepApp;
@@ -67,10 +66,10 @@ import java.util.Locale;
 import java.util.Map;
 
 import cn.jpush.android.api.JPushInterface;
-import okhttp3.Call;
 import io.reactivex.android.schedulers.AndroidSchedulers;
-import rx.functions.Action1;
 import io.reactivex.schedulers.Schedulers;
+import okhttp3.Call;
+import rx.functions.Action1;
 
 import static android.content.Context.NOTIFICATION_SERVICE;
 import static com.sheep.gamegroup.util.CommonUtil.LONG_MAO_APP_PACKAGE_NAME;
@@ -628,7 +627,6 @@ public class TestUtil {
      * umen 分享
      */
     private void testUmen(Activity context){
-        CommonUtil.getInstance().popShare(context, "http://www.baidu.com", DialogShare.ALL);
         UMImage umImage = new UMImage(context, R.mipmap.icon);
         new ShareAction(context)
                 .withText("hehe")

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

@@ -68,6 +68,7 @@ import com.sheep.gamegroup.model.entity.PayEntity;
 import com.sheep.gamegroup.model.entity.RobTask;
 import com.sheep.gamegroup.model.entity.TaskEty;
 import com.sheep.gamegroup.util.glide.RoundedCornersTransformation;
+import com.sheep.gamegroup.util.share.ShareLinkConfig;
 import com.sheep.gamegroup.view.activity.ActMain;
 import com.sheep.gamegroup.view.activity.PersonalInfoAct;
 import com.sheep.gamegroup.view.activity.SplashAct;
@@ -79,7 +80,6 @@ import com.sheep.gamegroup.view.dialog.DialogModifyAccount;
 import com.sheep.gamegroup.view.dialog.DialogOrienteeringDetails;
 import com.sheep.gamegroup.view.dialog.DialogPayAccount;
 import com.sheep.gamegroup.view.dialog.DialogPayGame;
-import com.sheep.gamegroup.view.dialog.DialogShare;
 import com.sheep.gamegroup.view.fragment.FgtPersonalCenter;
 import com.sheep.jiuyan.samllsheep.BuildConfig;
 import com.sheep.jiuyan.samllsheep.R;
@@ -1469,16 +1469,6 @@ public class ViewUtil {
     }
 
 
-    /**
-     * 分享
-     *
-     * @param activity
-     * @param url
-     */
-    public void showShare(Activity activity, String url, String description) {
-        new DialogShare(activity, url, description).showShare();
-    }
-
     public static void centerImage(ImageView imageView, String pictures) {
         if (imageView != null){
             if(TextUtils.isEmpty(pictures)) {
@@ -1820,18 +1810,13 @@ public class ViewUtil {
         new DialogMidong(activity).showMidongDialog(isSign, data);
     }
 
-    public static void showShareDialog(final Activity activity, final String url, final String description) {
-        showShareDialog(activity, url, description, null);
-    }
-
     /**
      * 显示分享弹出框
      * @param activity
-     * @param url
-     * @param description
+     * @param shareLinkConfig
      * @param action1 回调的view为nul时,代表流程结束;不为空时,代表初始化dialog的view,可以做自定义
      */
-    public static void showShareDialog(final Activity activity, final String url, final String description, final Action1<View> action1) {
+    public static void showShareDialog(final Activity activity, final ShareLinkConfig shareLinkConfig, final Action1<View> action1) {
         View dialogView = View.inflate(activity, R.layout.ask_to_share, null);
         final AlertDialog dialog = new AlertDialog.Builder(activity, R.style.AppTheme_Dialog_Alert)
                 .setView(dialogView)
@@ -1843,12 +1828,12 @@ public class ViewUtil {
 //        ask_share_list.setHasFixedSize(true);
 //        ask_share_list.setNestedScrollingEnabled(false);
         List<String> list = ListUtil.emptyList();
-//        list.add(DialogShare.SYS_SEND);
-        list.add(DialogShare.WX);
-        list.add(DialogShare.QQ);
-        list.add(DialogShare.WEIXIN_CIRCLE);
-        list.add(DialogShare.QZONE);
-//        list.add(DialogShare.COPY_SHARE_LINK);
+//        list.add(ShareLinkConfig.SYS_SEND);
+        list.add(ShareLinkConfig.WX);
+        list.add(ShareLinkConfig.QQ);
+        list.add(ShareLinkConfig.WEIXIN_CIRCLE);
+        list.add(ShareLinkConfig.QZONE);
+//        list.add(ShareLinkConfig.COPY_SHARE_LINK);
         final List<String> imgList = ListUtil.emptyList();
 //        imgList.add("share_face_to_face");
         imgList.add("share_wx");
@@ -1890,7 +1875,7 @@ public class ViewUtil {
                         } catch (Exception e) {
                             e.printStackTrace();
                         }
-                        CommonUtil.getInstance().popShare(activity, url, item, description);
+                        shareLinkConfig.setShareType(item).toShare(activity);
                     }
                 });
 

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

@@ -4,6 +4,7 @@ import android.text.TextUtils;
 import android.webkit.JavascriptInterface;
 
 import com.kfzs.duanduan.utils.ApkUtils;
+import com.sheep.gamegroup.util.share.ShareLinkConfig;
 import com.sheep.jiuyan.samllsheep.SheepApp;
 import com.sheep.jiuyan.samllsheep.utils.ClassFileHelper;
 import com.sheep.jiuyan.samllsheep.utils.G;
@@ -77,7 +78,7 @@ public class WebViewJs {
     }
     @JavascriptInterface
     public String popShare(String url, String type) {
-        CommonUtil.getInstance().popShare(ActivityManager.getInstance().currentActivity(), url, type);
+        new ShareLinkConfig().setLink(url).setShareType(type).toShare(ActivityManager.getInstance().currentActivity());
         return "";
     }
     @JavascriptInterface

+ 2 - 0
app/src/main/java/com/sheep/gamegroup/util/js/BaseActWeb.java

@@ -13,6 +13,8 @@ public abstract class BaseActWeb extends BaseActivity {
 
     public abstract void clearWebView();
 
+    public abstract void loadJs(String js);
+
     public abstract void showTitleBar(boolean isShow);
 
     public void superFinish(){

+ 41 - 9
app/src/main/java/com/sheep/gamegroup/util/js/KFZSJs.java

@@ -1,8 +1,6 @@
 package com.sheep.gamegroup.util.js;
 
-import android.app.Activity;
 import android.text.TextUtils;
-import android.view.View;
 import android.webkit.JavascriptInterface;
 
 import com.sheep.gamegroup.util.ApiUtil;
@@ -10,10 +8,15 @@ import com.sheep.gamegroup.util.CommonUtil;
 import com.sheep.gamegroup.util.DataUtil;
 import com.sheep.gamegroup.util.Jump2View;
 import com.sheep.gamegroup.util.QQUtil;
-import com.sheep.gamegroup.view.activity.ActWeb;
+import com.sheep.gamegroup.util.share.ShareLinkConfig;
+import com.sheep.jiuyan.samllsheep.utils.G;
 import com.sheep.jiuyan.samllsheep.utils.PackageUtil;
 import com.sheep.jiuyan.samllsheep.utils.SpUtils;
 import com.sheep.jiuyan.samllsheep.utils.TitleBarUtils;
+import com.umeng.socialize.UMShareListener;
+import com.umeng.socialize.bean.SHARE_MEDIA;
+
+import java.util.Locale;
 
 import rx.functions.Action1;
 
@@ -96,14 +99,43 @@ public class KFZSJs {
 
     @JavascriptInterface
     public String popShare(String url, String type) {
-        CommonUtil.getInstance().popShare(activity, url, type);
+        shareLink(url, null, null, null, type);
         return "";
     }
-//    @JavascriptInterface
-//    public String shareLink(String link, String iconUrl, String title, String des) {
-//        CommonUtil.getInstance().popShare(activity, url, type);
-//        return "";
-//    }
+    //h5调用分享 window.kfzsjs.shareLink(link, iconUrl, title, des);
+    @JavascriptInterface
+    public void shareLink(String link, String iconUrl, String title, String des) {
+        shareLink(link, iconUrl, title, des, ShareLinkConfig.ALL);
+    }
+    private void shareLink(String link, String iconUrl, String title, String des,@ShareLinkConfig.SHARE_TYPE String shareType) {
+        new ShareLinkConfig().setLink(link).setIconUrl(iconUrl).setTitle(title).setDes(des).setShareType(shareType).toShare(activity, new UMShareListener() {
+            @Override
+            public void onStart(SHARE_MEDIA share_media) {
+                //开始分享
+                activity.loadJs(String.format(Locale.CHINA, "callback(\"onStart\", %s)", share_media.getName()));
+            }
+
+            @Override
+            public void onResult(SHARE_MEDIA share_media) {
+                //分享成功 微信分享时,取消也会成功
+                activity.loadJs(String.format(Locale.CHINA, "callback(\"onResult\", %s)", share_media.getName()));
+            }
+
+            @Override
+            public void onError(SHARE_MEDIA share_media, Throwable throwable) {
+                //分享出错
+                String msg = throwable.getMessage();
+                G.showToast(msg != null && msg.contains("没有安装应用") ? "没有安装应用" : msg);
+                activity.loadJs(String.format(Locale.CHINA, "callback(\"onError\", %s)", share_media.getName()));
+            }
+
+            @Override
+            public void onCancel(SHARE_MEDIA share_media) {
+                //取消分享 微信分享时,没有取消
+                activity.loadJs(String.format(Locale.CHINA, "callback(\"onCancel\", %s)", share_media.getName()));
+            }
+        });
+    }
 
     @JavascriptInterface
     public String getHeader() {

+ 36 - 0
app/src/main/java/com/sheep/gamegroup/util/share/CommonUMShareListener.java

@@ -0,0 +1,36 @@
+package com.sheep.gamegroup.util.share;
+
+import com.sheep.gamegroup.util.LogUtil;
+import com.sheep.jiuyan.samllsheep.utils.G;
+import com.umeng.socialize.UMShareListener;
+import com.umeng.socialize.bean.SHARE_MEDIA;
+
+/**
+ * Created by realicing on 2018/11/23.
+ * realicing@sina.com
+ */
+public class CommonUMShareListener implements UMShareListener {
+
+    @Override
+    public void onStart(SHARE_MEDIA share_media) {
+        LogUtil.println("UMShareListener", "start", share_media.getName());
+    }
+
+    @Override
+    public void onResult(SHARE_MEDIA share_media) {
+        LogUtil.println("UMShareListener", "result", share_media.getName());
+    }
+
+    @Override
+    public void onError(SHARE_MEDIA share_media, Throwable throwable) {
+        String msg = throwable.getMessage();
+        G.showToast(msg != null && msg.contains("没有安装应用") ? "没有安装应用" : msg);
+        LogUtil.println("UMShareListener", "error", share_media.getName() +
+                ",msg:" + throwable.getMessage());
+    }
+
+    @Override
+    public void onCancel(SHARE_MEDIA share_media) {
+        LogUtil.println("UMShareListener", "delete", share_media.getName());
+    }
+}

+ 403 - 0
app/src/main/java/com/sheep/gamegroup/util/share/ShareLinkConfig.java

@@ -0,0 +1,403 @@
+package com.sheep.gamegroup.util.share;
+
+import android.app.Activity;
+import android.content.Context;
+import android.content.Intent;
+import android.content.pm.PackageInfo;
+import android.media.MediaMetadataRetriever;
+import android.net.Uri;
+import android.support.annotation.IntDef;
+import android.support.annotation.StringDef;
+import android.text.TextUtils;
+import android.view.View;
+
+import com.kfzs.duanduan.utils.ApkUtils;
+import com.sheep.gamegroup.model.entity.DialogConfig;
+import com.sheep.gamegroup.model.entity.FriendAndAwardEntity;
+import com.sheep.gamegroup.model.entity.UserEntity;
+import com.sheep.gamegroup.util.CommonUtil;
+import com.sheep.gamegroup.util.DataUtil;
+import com.sheep.gamegroup.util.StringUtils;
+import com.sheep.gamegroup.util.TestUtil;
+import com.sheep.gamegroup.util.ViewUtil;
+import com.sheep.gamegroup.util.ZipChannelUtil;
+import com.sheep.gamegroup.util.viewHelper.CacheImageUtil;
+import com.sheep.jiuyan.samllsheep.R;
+import com.sheep.jiuyan.samllsheep.SheepApp;
+import com.sheep.jiuyan.samllsheep.utils.FileUtil;
+import com.sheep.jiuyan.samllsheep.utils.G;
+import com.umeng.socialize.ShareAction;
+import com.umeng.socialize.UMShareListener;
+import com.umeng.socialize.bean.SHARE_MEDIA;
+import com.umeng.socialize.media.UMImage;
+import com.umeng.socialize.media.UMWeb;
+
+import java.io.File;
+import java.io.IOException;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.util.Locale;
+
+import rx.functions.Action1;
+
+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_SYS_SEND;
+import static com.sheep.gamegroup.util.UMConfigUtils.Event.SHARE_TO_QQ;
+import static com.sheep.gamegroup.util.UMConfigUtils.Event.SHARE_TO_QZONE;
+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.jiuyan.samllsheep.utils.ClassFileHelper.DIR;
+
+/**
+ * Created by realicing on 2018/11/23.
+ * realicing@sina.com
+ * 分享配置
+ */
+public class ShareLinkConfig {
+    private String link;
+    private String title;
+    private String des;
+    private String iconUrl;
+    private int iconResId;
+    private File file;
+    private int type = WEB;//分享类型:对应TYPE
+    private Action1<View> action1;
+    private String shareType = ALL;//分享方式:对应 SHARE_TYPE
+
+    public String getLink() {
+        return link;
+    }
+
+    public ShareLinkConfig setLink(String link) {
+        this.link = link;
+        return this;
+    }
+
+    public String getTitle() {
+        return title;
+    }
+
+    public ShareLinkConfig setTitle(String title) {
+        this.title = title;
+        return this;
+    }
+
+    public String getDes() {
+        return des;
+    }
+
+    public ShareLinkConfig setDes(String des) {
+        this.des = des;
+        return this;
+    }
+
+    public String getIconUrl() {
+        return iconUrl;
+    }
+
+    public ShareLinkConfig setIconUrl(String iconUrl) {
+        this.iconUrl = iconUrl;
+        return this;
+    }
+
+    public int getIconResId() {
+        return iconResId;
+    }
+
+    public ShareLinkConfig setIconResId(int iconResId) {
+        this.iconResId = iconResId;
+        return this;
+    }
+
+    public String getShareType() {
+        return shareType;
+    }
+
+    public ShareLinkConfig setShareType(@ShareLinkConfig.SHARE_TYPE String shareType) {
+        this.shareType = shareType;
+        return this;
+    }
+
+    public File getFile() {
+        return file;
+    }
+
+    public ShareLinkConfig setFile(File file) {
+        this.file = file;
+        return this;
+    }
+
+    public Action1<View> getAction1() {
+        return action1;
+    }
+
+    public ShareLinkConfig setAction1(Action1<View> action1) {
+        this.action1 = action1;
+        return this;
+    }
+
+    public int getType() {
+        return type;
+    }
+
+    public ShareLinkConfig setType(int type) {
+        this.type = type;
+        return this;
+    }
+
+    public void toShare(Activity activity) {
+        if(activity instanceof UMShareListener){
+            toShare(activity, (UMShareListener) activity);
+        } else {
+            toShare(activity, null);
+        }
+    }
+
+    //可以直接分享,也可以弹出分享对话框(ALL, SYS_SEND, FACE_TO_FACE, COPY_SHARE_LINK)
+    public void toShare(final Activity activity, final UMShareListener umShareListener) {
+        if (activity == null) {
+            return;
+        }
+        if(TextUtils.isEmpty(link)){
+            CommonUtil.getInstance().callActionWithUserInfo(new Action1<UserEntity>() {
+                @Override
+                public void call(UserEntity userEntity) {
+                    if (userEntity == null) {
+                        G.showToast("分享功能调试中");
+                        if(action1 != null)
+                            action1.call(null);
+                        return;
+                    }
+                    String url = userEntity.getShareLink();
+                    setLink(url).toShare(activity, umShareListener);
+                }
+            });
+            return;
+        }
+        if(TextUtils.isEmpty(des)){
+            CommonUtil.getInstance().callActionWithFriendCountAndAward(new Action1<FriendAndAwardEntity>() {
+                @Override
+                public void call(FriendAndAwardEntity result) {
+                    if (result == null) {
+                        G.showToast("分享功能调试中");
+                        if(action1 != null)
+                            action1.call(null);
+                    } else {
+                        String desc = result.getShare_desc();
+                        setDes(desc).toShare(activity, umShareListener);
+                    }
+                }
+            });
+            return;
+        }
+        if(!TextUtils.isEmpty(iconUrl)){//下载图标后分享,iconUrl只是一个要下载图片的标识,下载成功后要设置为空并且设置其对应的文件,
+            String path = CacheImageUtil.getCacheImg(link);
+            if(path == null) {
+                CacheImageUtil.cacheImg(iconUrl, new Action1<File>() {
+                    @Override
+                    public void call(File file) {
+                        if (file == null) {
+                            setIconUrl(null).toShare(activity, umShareListener);
+                        } else {
+                            setIconUrl(null).setFile(file).toShare(activity, umShareListener);
+                        }
+                    }
+                });
+                return;
+            } else {
+                setFile(new File(path));
+            }
+        }
+        final String realUrl = jointString(link, shareType);
+        SHARE_MEDIA share_media;
+        switch (shareType) {
+            case ShareLinkConfig.ALL:
+                ViewUtil.showShareDialog(activity, this, null);
+                return;
+            case ShareLinkConfig.SYS_SEND:
+                SHARE_SYS_SEND.onEvent();
+                shareBySysSend(activity);
+                return;
+            case ShareLinkConfig.FACE_TO_FACE:
+                ViewUtil.showQR(activity, realUrl);
+                return;
+            case ShareLinkConfig.COPY_SHARE_LINK:
+                LINK_SHARE.onEvent();
+                ViewUtil.showMsgDialog(activity, new DialogConfig().setTitle("分享链接").setMsg(realUrl)
+                        .setMsgMore("他人通过该链接加入小绵羊即可成为你的好友").setMsgMoreColor(R.color.txt_black_9e9c9c)
+                        .setBtnLeftText("复制链接").setBtnLeftOnClickListener(new View.OnClickListener() {
+                            @Override
+                            public void onClick(View view) {
+                                QR_COPY.onEvent();
+                                StringUtils.CopyText(realUrl);
+                                G.showToast("复制链接成功");
+                            }
+                        }));
+                return;
+                //上面为弹出对话框进行分享,下面为直接分享
+            case ShareLinkConfig.QQ:
+                SHARE_TO_QQ.onEvent();
+                share_media = SHARE_MEDIA.QQ;
+                break;
+            case ShareLinkConfig.QZONE:
+                SHARE_TO_QZONE.onEvent();
+                share_media = SHARE_MEDIA.QZONE;
+                break;
+            case ShareLinkConfig.WX:
+                SHARE_TO_WX.onEvent();
+                share_media = SHARE_MEDIA.WEIXIN;
+                break;
+            case ShareLinkConfig.WEIXIN_CIRCLE:
+            default:
+                SHARE_TO_WEIXIN_CIRCLE.onEvent();
+                share_media = SHARE_MEDIA.WEIXIN_CIRCLE;
+                break;
+        }
+        String title = activity.getResources().getString(R.string.app_name);
+        UMImage umImage;
+        UMWeb umWeb;
+        if (type == WEB) {
+            if(file != null && file.exists()){
+                umImage = new UMImage(SheepApp.getInstance(), file);
+            } else if(iconResId > 0){
+                umImage = new UMImage(SheepApp.getInstance(), iconResId);
+            } else {
+                umImage = new UMImage(SheepApp.getInstance(), R.mipmap.icon);
+            }
+            umWeb = new UMWeb(realUrl);
+            umWeb.setTitle(title);
+            umWeb.setThumb(umImage);
+            umWeb.setDescription(TextUtils.isEmpty(des) ? title : des);
+            switch (shareType) {
+                case ShareLinkConfig.WEIXIN_CIRCLE://微信朋友圈分享时只会显示标题,所以这里使用描述
+                    umWeb.setTitle(TextUtils.isEmpty(des) ? title : (title + "\n" + des));
+                default:
+                    new ShareAction(activity)
+                            .setPlatform(share_media)
+                            .withMedia(umWeb)
+                            .setCallback(umShareListener != null ? umShareListener : new CommonUMShareListener())
+                            .share();
+                    break;
+            }
+        } else {
+            if(file != null && file.exists()){
+                umImage = new UMImage(SheepApp.getInstance(), file);
+            } else if(iconResId > 0){
+                umImage = new UMImage(SheepApp.getInstance(), iconResId);
+            } else {
+                if(TestUtil.isDev()){
+                    G.showToast("应该是调用方式有问题,请检查一下:分享图片时,file必须保证不为空,且存在");
+                } else {
+                    G.showToast(R.string.coming_soon);
+                }
+                return;
+            }
+            new ShareAction(activity)
+                    .setPlatform(share_media)
+                    .withMedia(umImage)
+                    .setCallback(umShareListener != null ? umShareListener : new CommonUMShareListener())
+                    .share();
+        }
+    }
+
+
+
+    public static void shareBySysSend(Activity activity) {
+        PackageInfo packageInfo = ApkUtils.getPackageInfo(SheepApp.getInstance().getPackageName());
+        if (packageInfo != null && packageInfo.applicationInfo != null && !TextUtils.isEmpty(packageInfo.applicationInfo.sourceDir)) {
+            String dir = DIR;
+            //File dir = SheepApp.getInstance().getDir("apk", Context.MODE_PRIVATE);
+            File file = new File(dir, String.format(Locale.CHINA, "sheep_release_v%s_%d-%s.apk", packageInfo.versionName, packageInfo.versionCode, DataUtil.getInstance().getInvitationCode()));
+            if (!file.exists()) {
+                try {
+                    FileUtil.copyFile(new File(packageInfo.applicationInfo.sourceDir), file);
+                    ZipChannelUtil.writeQUA(file, DataUtil.getInstance().getInvitationCode());
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+            if (file.exists())
+                shareFile(activity, file);
+            else
+                G.showToast("暂不支持,或未打开权限");
+        } else {
+            G.showToast("暂不支持");
+        }
+    }
+
+    // 調用系統方法分享文件
+    public static void shareFile(Context context, File file) {
+        if (null != file && file.exists()) {
+            Intent share = new Intent(Intent.ACTION_SEND);
+            share.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));
+            share.setType(getMimeType(file.getAbsolutePath()));//此处可发送多种文件
+            share.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+            share.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
+            context.startActivity(Intent.createChooser(share, "分享文件"));
+        } else {
+            G.showToast("分享文件不存在");
+        }
+    }
+
+    // 根据文件后缀名获得对应的MIME类型。
+    private static String getMimeType(String filePath) {
+        MediaMetadataRetriever mmr = new MediaMetadataRetriever();
+        String mime = "*/*";
+        if (filePath != null) {
+            try {
+                mmr.setDataSource(filePath);
+                mime = mmr.extractMetadata(MediaMetadataRetriever.METADATA_KEY_MIMETYPE);
+            } catch (IllegalStateException e) {
+                return mime;
+            } catch (IllegalArgumentException e) {
+                return mime;
+            } catch (RuntimeException e) {
+                return mime;
+            }
+        }
+        return mime;
+    }
+    /**
+     * 分享 url type 拼接
+     * 1:微信 2:QQ 3:短信 4:二维码 5:其他
+     */
+    public static String jointString(String url, @ShareLinkConfig.SHARE_TYPE String type) {
+        if (url.contains("&type="))
+            return url;
+        switch (type) {
+            case ShareLinkConfig.WX:
+            case ShareLinkConfig.WEIXIN_CIRCLE:
+                return url + "&type=1";
+            case ShareLinkConfig.QQ:
+            case ShareLinkConfig.QZONE:
+                return url + "&type=2";
+            case ShareLinkConfig.FACE_TO_FACE:
+                return url + "&type=4";
+            default:
+                return url + "&type=5";
+        }
+    }
+    public final static String FACE_TO_FACE = "face_to_face";
+    public final static String COPY_SHARE_LINK = "copy_share_link";
+    public final static String WEIXIN_CIRCLE = "weixin_circle";
+    public final static String QZONE = "qzone";
+    public final static String QQ = "qq";
+    public final static String WX = "wx";
+    public final static String ALL = "all";
+    public final static String SYS_SEND = "sys_send";
+    public final static String OTHER = "other";
+
+    @StringDef({FACE_TO_FACE, COPY_SHARE_LINK, WEIXIN_CIRCLE, QZONE, QQ, WX, OTHER, SYS_SEND, ALL})
+    @Retention(RetentionPolicy.SOURCE)
+    public @interface SHARE_TYPE {
+    }
+
+
+    public final static int WEB = 1;//分享网页,
+    public final static int IMG = 2;//分享图片,图片对应的是一个文件:file
+    @IntDef({WEB, IMG})
+    @Retention(RetentionPolicy.SOURCE)
+    public @interface TYPE {
+    }
+}

+ 2 - 2
app/src/main/java/com/sheep/gamegroup/view/activity/ActGiftDetail.java

@@ -7,11 +7,11 @@ import android.widget.TextView;
 
 import com.sheep.gamegroup.absBase.BaseActivity;
 import com.sheep.gamegroup.model.entity.GiftBagApp;
-import com.sheep.gamegroup.util.CommonUtil;
 import com.sheep.gamegroup.util.DataUtil;
 import com.sheep.gamegroup.util.GlideImageLoader;
 import com.sheep.gamegroup.util.StringUtils;
 import com.sheep.gamegroup.util.ViewUtil;
+import com.sheep.gamegroup.util.share.ShareLinkConfig;
 import com.sheep.gamegroup.view.adapter.GiftCenterAdapter;
 import com.sheep.jiuyan.samllsheep.R;
 import com.sheep.jiuyan.samllsheep.utils.G;
@@ -64,7 +64,7 @@ public class ActGiftDetail extends BaseActivity {
                 .setRightBtn(this, "分享", 0, new View.OnClickListener() {
                     @Override
                     public void onClick(View view) {
-                        CommonUtil.getInstance().tryShowShareDialog(ActGiftDetail.this);
+                        new ShareLinkConfig().toShare(ActGiftDetail.this);
                     }
                 });
         item_download_welfare_line.setVisibility(View.GONE);

+ 8 - 121
app/src/main/java/com/sheep/gamegroup/view/activity/ActInvitation.java

@@ -1,7 +1,6 @@
 package com.sheep.gamegroup.view.activity;
 
 import android.annotation.SuppressLint;
-import android.app.Activity;
 import android.graphics.BitmapFactory;
 import android.graphics.drawable.Drawable;
 import android.graphics.drawable.GradientDrawable;
@@ -12,7 +11,6 @@ import android.support.constraint.ConstraintLayout;
 import android.support.v4.view.ViewPager;
 import android.support.v7.widget.GridLayoutManager;
 import android.support.v7.widget.RecyclerView;
-import android.text.TextUtils;
 import android.util.SparseArray;
 import android.view.LayoutInflater;
 import android.view.MotionEvent;
@@ -32,7 +30,6 @@ import com.bumptech.glide.request.target.Target;
 import com.kfzs.duanduan.utils.StatusBarUtils;
 import com.sheep.gamegroup.absBase.BaseActivity;
 import com.sheep.gamegroup.model.entity.BaseMessage;
-import com.sheep.gamegroup.model.entity.DialogConfig;
 import com.sheep.gamegroup.model.entity.FriendAndAwardEntity;
 import com.sheep.gamegroup.model.entity.PictureInvitationEntity;
 import com.sheep.gamegroup.model.entity.UserEntity;
@@ -42,22 +39,17 @@ import com.sheep.gamegroup.util.CommonUtil;
 import com.sheep.gamegroup.util.DataUtil;
 import com.sheep.gamegroup.util.GlideImageLoader;
 import com.sheep.gamegroup.util.ListUtil;
-import com.sheep.gamegroup.util.StringUtils;
 import com.sheep.gamegroup.util.ViewHolder;
 import com.sheep.gamegroup.util.ViewUtil;
+import com.sheep.gamegroup.util.share.ShareLinkConfig;
 import com.sheep.gamegroup.view.adapter.AdbCommonRecycler;
 import com.sheep.gamegroup.view.adapter.ArrayPagerAdapter;
-import com.sheep.gamegroup.view.dialog.DialogShare;
 import com.sheep.jiuyan.samllsheep.BuildConfig;
 import com.sheep.jiuyan.samllsheep.R;
 import com.sheep.jiuyan.samllsheep.SheepApp;
 import com.sheep.jiuyan.samllsheep.utils.ClassFileHelper;
 import com.sheep.jiuyan.samllsheep.utils.FileUtil;
 import com.sheep.jiuyan.samllsheep.utils.G;
-import com.umeng.socialize.ShareAction;
-import com.umeng.socialize.bean.SHARE_MEDIA;
-import com.umeng.socialize.media.UMImage;
-import com.umeng.socialize.media.UMWeb;
 
 import java.io.File;
 import java.util.ArrayList;
@@ -70,11 +62,6 @@ import io.reactivex.android.schedulers.AndroidSchedulers;
 import io.reactivex.schedulers.Schedulers;
 import rx.functions.Action1;
 
-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;
 
 /**
@@ -370,11 +357,11 @@ public class ActInvitation extends BaseActivity {
         gridLayoutManager = new GridLayoutManager(this, 5);
         ask_share_list.setLayoutManager(gridLayoutManager);
         final List<String> list = ListUtil.emptyList();
-        list.add(DialogShare.FACE_TO_FACE);
-        list.add(DialogShare.WX);
-        list.add(DialogShare.QQ);
-        list.add(DialogShare.WEIXIN_CIRCLE);
-        list.add(DialogShare.COPY_SHARE_LINK);
+        list.add(ShareLinkConfig.FACE_TO_FACE);
+        list.add(ShareLinkConfig.WX);
+        list.add(ShareLinkConfig.QQ);
+        list.add(ShareLinkConfig.WEIXIN_CIRCLE);
+        list.add(ShareLinkConfig.COPY_SHARE_LINK);
         final List<String> imgList = ListUtil.emptyList();
         imgList.add("share_face_to_face");
         imgList.add("share_wx");
@@ -406,10 +393,7 @@ public class ActInvitation extends BaseActivity {
                 itemView.setOnClickListener(new View.OnClickListener() {
                     @Override
                     public void onClick(View view) {
-                        File file = null;
-//                        switch (position) {
-//                            case 2://qq
-//                            case 1://wx
+                        File file;
                         PictureInvitationEntity picItem = ListUtil.getItem(mPictureList, curPosition);
                         if (picItem != null && picItem.isLoaded()) {
                             try {
@@ -427,10 +411,7 @@ public class ActInvitation extends BaseActivity {
                             G.showToast("图片正在加载中,请稍等");
                             return;
                         }
-//                                break;
-//
-//                        }
-                        popShare(ActInvitation.this, url, item, description, file);
+                        new ShareLinkConfig().setLink(url).setShareType(item).setDes(description).setFile(file).setType(ShareLinkConfig.IMG).toShare(ActInvitation.this);
                     }
                 });
             }
@@ -439,100 +420,6 @@ public class ActInvitation extends BaseActivity {
     }
 
 
-    /**
-     * 分享 url type 拼接
-     */
-    public String jointString(String url, @DialogShare.SHARE_TYPE String type) {
-        if (url.contains("&type="))
-            return url;
-        switch (type) {
-            case "qq":
-                return url + "&type=2";
-            case "wx":
-                return url + "&type=1";
-            default:
-                return url + "&type=4";
-        }
-    }
-
-    /**
-     * 分享
-     *
-     * @param activity
-     * @param url
-     * @param type        qq wx all
-     * @param description
-     */
-    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;
-        }
-        final String realUrl = jointString(url, type);
-        SHARE_MEDIA share_media;
-        switch (type) {
-            case DialogShare.ALL:
-                ViewUtil.showShareDialog(activity, realUrl, description);
-                return;
-            case DialogShare.FACE_TO_FACE:
-                ViewUtil.showQR(activity, realUrl);
-                return;
-            case DialogShare.COPY_SHARE_LINK:
-                LINK_SHARE.onEvent();
-                ViewUtil.showMsgDialog(activity, new DialogConfig().setTitle("分享链接").setMsg(realUrl)
-                        .setMsgMore("他人通过该链接加入小绵羊即可成为你的好友").setMsgMoreColor(R.color.txt_black_9e9c9c)
-                        .setBtnLeftText("复制链接").setBtnLeftOnClickListener(new View.OnClickListener() {
-                            @Override
-                            public void onClick(View view) {
-                                QR_COPY.onEvent();
-                                StringUtils.CopyText(realUrl);
-                                G.showToast("复制链接成功");
-                            }
-                        }));
-                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;
-        }
-        String title = activity.getResources().getString(R.string.app_name);
-        UMImage umImage;
-        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();
-        }
-    }
-
     @OnClick(R.id.img_baseactivity_title)
     public void onViewClicked(View view) {
         switch (view.getId()) {

+ 2 - 2
app/src/main/java/com/sheep/gamegroup/view/activity/ActSignCardRecord.java

@@ -6,7 +6,7 @@ import android.support.v4.app.FragmentTransaction;
 import android.view.View;
 
 import com.sheep.gamegroup.absBase.BaseActivity;
-import com.sheep.gamegroup.util.CommonUtil;
+import com.sheep.gamegroup.util.share.ShareLinkConfig;
 import com.sheep.gamegroup.view.fragment.FgtSignCardRecord;
 import com.sheep.jiuyan.samllsheep.R;
 import com.sheep.jiuyan.samllsheep.utils.TitleBarUtils;
@@ -34,7 +34,7 @@ public class ActSignCardRecord extends BaseActivity {
                 .setRightBtn(activity, "分享", 0, new View.OnClickListener() {
                     @Override
                     public void onClick(View view) {
-                        CommonUtil.getInstance().tryShowShareDialog(activity);
+                        new ShareLinkConfig().toShare(activity);
                     }
                 });
 

+ 3 - 2
app/src/main/java/com/sheep/gamegroup/view/activity/ActUserAppHome.java

@@ -20,8 +20,8 @@ import com.scwang.smartrefresh.layout.listener.OnRefreshLoadMoreListener;
 import com.sheep.gamegroup.absBase.BaseActivity;
 import com.sheep.gamegroup.absBase.ILoadMore;
 import com.sheep.gamegroup.absBase.IRefresh;
-import com.sheep.gamegroup.model.entity.BaseMessage;
 import com.sheep.gamegroup.model.entity.Applications;
+import com.sheep.gamegroup.model.entity.BaseMessage;
 import com.sheep.gamegroup.model.entity.GameInfoList;
 import com.sheep.gamegroup.model.entity.LatelyGame;
 import com.sheep.gamegroup.model.entity.UserFocus;
@@ -33,6 +33,7 @@ import com.sheep.gamegroup.util.ListUtil;
 import com.sheep.gamegroup.util.RefreshUtil;
 import com.sheep.gamegroup.util.TestUtil;
 import com.sheep.gamegroup.util.ViewUtil;
+import com.sheep.gamegroup.util.share.ShareLinkConfig;
 import com.sheep.gamegroup.view.adapter.AdpGcGameAppInfoList;
 import com.sheep.gamegroup.view.adapter.AdpGcGameAppList;
 import com.sheep.gamegroup.view.adapter.TitleFragmentListAdapter;
@@ -333,7 +334,7 @@ public class ActUserAppHome extends BaseActivity {
 //        G.showToast(R.string.coming_soon);
 //        FIND_SHARE.onEvent("application_id", id);
 //        Jump2View.getInstance().tryShare(this, "find_share_url", "application_id", id);
-        CommonUtil.getInstance().tryShowShareDialog(this);
+        new ShareLinkConfig().toShare(this);
     }
 
     //点击赞

+ 2 - 1
app/src/main/java/com/sheep/gamegroup/view/activity/ActWeb.java

@@ -344,7 +344,8 @@ public class ActWeb extends BaseActWeb {
         }
     }
 
-    private void loadJs(String js) {
+    @Override
+    public void loadJs(String js) {
         ViewUtil.loadJs(mWebView, js);
     }
 

+ 4 - 141
app/src/main/java/com/sheep/gamegroup/view/activity/ActWebX5.java

@@ -13,21 +13,15 @@ import android.support.annotation.RequiresApi;
 import android.support.v7.app.AlertDialog;
 import android.text.TextUtils;
 import android.view.View;
-import android.webkit.JavascriptInterface;
 
-import com.sheep.gamegroup.absBase.BaseActivity;
-import com.sheep.gamegroup.util.ApiUtil;
 import com.sheep.gamegroup.util.CommonUtil;
-import com.sheep.gamegroup.util.DataUtil;
-import com.sheep.gamegroup.util.Jump2View;
 import com.sheep.gamegroup.util.LogUtil;
-import com.sheep.gamegroup.util.QQUtil;
 import com.sheep.gamegroup.util.TestUtil;
 import com.sheep.gamegroup.util.ViewUtil;
 import com.sheep.gamegroup.util.js.BaseActWeb;
+import com.sheep.gamegroup.util.js.KFZSJs;
 import com.sheep.jiuyan.samllsheep.R;
 import com.sheep.jiuyan.samllsheep.SheepApp;
-import com.sheep.jiuyan.samllsheep.utils.PackageUtil;
 import com.sheep.jiuyan.samllsheep.utils.SpUtils;
 import com.sheep.jiuyan.samllsheep.utils.TitleBarUtils;
 import com.tencent.smtt.sdk.ValueCallback;
@@ -43,7 +37,6 @@ import java.util.HashMap;
 import java.util.Map;
 
 import butterknife.BindView;
-import rx.functions.Action1;
 
 
 /**
@@ -287,7 +280,7 @@ public class ActWebX5 extends BaseActWeb {
             }
         });
         webViewSettings.setJavaScriptEnabled(true);
-        mWebView.addJavascriptInterface(new KFZSJs(), "kfzsjs");
+        mWebView.addJavascriptInterface(new KFZSJs(this), "kfzsjs");
         String loadUrl = addUrlToken(url);
         LogUtil.println("ActWeb loadUrl = " + loadUrl);
         if (CommonUtil.getInstance().judgeUrlPicture(url)) {
@@ -323,137 +316,6 @@ public class ActWebX5 extends BaseActWeb {
     }
 
     /**
-     * window.kfzsjs.方法名(参数)
-     */
-    public class KFZSJs {
-        @JavascriptInterface
-        public void setTitle(final String title) {
-            runOnUiThread(new Runnable() {
-                @Override
-                public void run() {
-                    TitleBarUtils
-                            .getInstance()
-                            .setTitle(ActWebX5.this, title);
-                }
-            });
-        }
-
-        /**
-         * 是否响应返回键
-         */
-        @JavascriptInterface
-        public boolean isResponseBack() {
-            return responseBack;
-        }
-
-        /**
-         * 设置是否响应返回键
-         */
-        @JavascriptInterface
-        public void setResponseBack(boolean responseBack) {
-            ActWebX5.this.responseBack = responseBack;
-        }
-
-        @JavascriptInterface
-        public void downloadFile(final String url, final String name) {
-            CommonUtil.getInstance().showDownLoad(ActWebX5.this, url, name);
-        }
-
-        @JavascriptInterface
-        public void startApp(String pkg, String cls) {
-            PackageUtil.startApp(ActWebX5.this, pkg);
-        }
-
-        @JavascriptInterface
-        public void gotoLogin() {
-            mWebView = null;
-            Jump2View.getInstance().gotoLoginAgain();
-        }
-
-        @JavascriptInterface
-        public void gotoWeb(String url, String title) {
-            if (!TextUtils.isEmpty(url)) {
-                if (TextUtils.isEmpty(title)) {
-                    Jump2View.getInstance().goWeb(ActWebX5.this, url);//启动浏览器h5
-                } else {
-                    Jump2View.getInstance().goWeb(ActWebX5.this, url, title);//进入小绵羊h5界面
-                }
-            }
-        }
-
-        @JavascriptInterface
-        public void gotoRecharge() {
-            Jump2View.getInstance().goRechargeAct(ActWebX5.this, "内部H5");//进入充值绵羊币界面
-        }
-
-        @JavascriptInterface
-        public String getInvitationCode() {
-            return DataUtil.getInstance().getInvitationCode();
-        }
-
-        @JavascriptInterface
-        public String popShare(String url, String type) {
-            CommonUtil.getInstance().popShare(ActWebX5.this, url, type);
-            return "";
-        }
-
-        @JavascriptInterface
-        public String getHeader() {
-            return SpUtils.getToken(ActWebX5.this);
-        }
-
-        @JavascriptInterface
-        public String getWcUrl(String url) {
-            if (!TextUtils.isEmpty(url)) {
-                Jump2View.getInstance().goWeb(ActWebX5.this, url);
-            }
-            return "";
-        }
-
-        @JavascriptInterface
-        public void showTitleBar(final boolean isShow) {
-            runOnUiThread(new Runnable() {
-                @Override
-                public void run() {
-                    if (layout_navigationBar != null)
-                        layout_navigationBar.setVisibility(isShow ? View.VISIBLE : View.GONE);
-                }
-            });
-        }
-
-        @JavascriptInterface
-        public void goBack() {
-            runOnUiThread(new Runnable() {
-                @Override
-                public void run() {
-                    finish();
-                }
-            });
-        }
-
-        @JavascriptInterface
-        public void finishAct() {
-            runOnUiThread(new Runnable() {
-                @Override
-                public void run() {
-                    ActWebX5.super.finish();
-                }
-            });
-        }
-
-        @JavascriptInterface
-        public void skip2QQ() {
-            ApiUtil.getNewAboutUsComplainQq(new Action1<String>() {
-                @Override
-                public void call(String qq) {
-                    QQUtil.skip3(ActWebX5.this, qq);
-                }
-            });
-        }
-
-    }
-
-    /**
      * 是否响应返回键
      */
     private boolean responseBack = true;
@@ -467,7 +329,8 @@ public class ActWebX5 extends BaseActWeb {
         }
     }
 
-    private void loadJs(String js) {
+    @Override
+    public void loadJs(String js) {
         ViewUtil.loadJs(mWebView, js);
     }
 

+ 3 - 3
app/src/main/java/com/sheep/gamegroup/view/activity/PersonalInfoAct.java

@@ -19,7 +19,7 @@ import com.sheep.gamegroup.util.DataUtil;
 import com.sheep.gamegroup.util.GlideImageLoader;
 import com.sheep.gamegroup.util.Jump2View;
 import com.sheep.gamegroup.util.ViewUtil;
-import com.sheep.gamegroup.view.dialog.DialogShare;
+import com.sheep.gamegroup.util.share.ShareLinkConfig;
 import com.sheep.jiuyan.samllsheep.R;
 import com.sheep.jiuyan.samllsheep.SheepApp;
 import com.sheep.jiuyan.samllsheep.utils.G;
@@ -202,7 +202,7 @@ public class PersonalInfoAct extends AbsChooseImageActivity {
                 USER_INFO_NAME.onEvent();
                 break;
             case R.id.personal_info_qr_container:
-                ViewUtil.showQR(PersonalInfoAct.this, userEntity.getShareLink(DialogShare.OTHER));
+                ViewUtil.showQR(PersonalInfoAct.this, userEntity.getShareLink(ShareLinkConfig.OTHER));
                 break;
             case R.id.personal_info_phone_container:   //跳转到绑定手机号
                 Jump2View.getInstance().goBindPhone(activity, null);
@@ -441,7 +441,7 @@ public class PersonalInfoAct extends AbsChooseImageActivity {
         personal_info_name.setText(userEntity.getNickname());
         personal_info_code.setText(userEntity.getInvitation_code());
 
-        GlideImageLoader.saveAndSetRqImage(personal_info_qr, userEntity.getShareLink(DialogShare.FACE_TO_FACE), 90);
+        GlideImageLoader.saveAndSetRqImage(personal_info_qr, userEntity.getShareLink(ShareLinkConfig.FACE_TO_FACE), 90);
         GlideImageLoader.setAvatar(personal_info_avatar, userEntity.getAvatar());
         //账号与安全
 

+ 17 - 31
app/src/main/java/com/sheep/gamegroup/view/dialog/DialogShare.java

@@ -2,7 +2,6 @@ package com.sheep.gamegroup.view.dialog;
 
 import android.app.Activity;
 import android.content.DialogInterface;
-import android.support.annotation.StringDef;
 import android.support.v7.app.AlertDialog;
 import android.text.TextUtils;
 import android.view.Gravity;
@@ -12,42 +11,29 @@ import android.view.WindowManager;
 import android.widget.LinearLayout;
 import android.widget.TextView;
 
-import com.sheep.gamegroup.util.CommonUtil;
 import com.sheep.gamegroup.util.StringUtils;
+import com.sheep.gamegroup.util.share.ShareLinkConfig;
 import com.sheep.jiuyan.samllsheep.R;
 import com.sheep.jiuyan.samllsheep.utils.G;
+import com.umeng.socialize.UMShareListener;
 
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-
+import static com.sheep.gamegroup.util.share.ShareLinkConfig.QQ;
+import static com.sheep.gamegroup.util.share.ShareLinkConfig.WX;
 /**
- * Created by ljy on 2018/6/22.
+ * Created by realicing on 2018/11/23.
+ * realicing@sina.com
+ * 通过对话框进行分享
  */
-
 public class DialogShare {
-    public final static String FACE_TO_FACE = "face_to_face";
-    public final static String COPY_SHARE_LINK = "copy_share_link";
-    public final static String WEIXIN_CIRCLE = "weixin_circle";
-    public final static String QZONE = "qzone";
-    public final static String QQ = "qq";
-    public final static String WX = "wx";
-    public final static String ALL = "all";
-    public final static String SYS_SEND = "sys_send";
-    public final static String OTHER = "other";
-
-    @StringDef({FACE_TO_FACE, COPY_SHARE_LINK, WEIXIN_CIRCLE, QZONE, QQ, WX, OTHER, SYS_SEND, ALL})
-    @Retention(RetentionPolicy.SOURCE)
-    public @interface SHARE_TYPE {
-    }
 
     private Activity activity;
-    private String link;
-    private String description;
+    private UMShareListener umShareListener;
+    private ShareLinkConfig shareLinkConfig;
 
-    public DialogShare(Activity activity, String link, String description) {
+    public DialogShare(Activity activity, ShareLinkConfig shareLinkConfig, UMShareListener umShareListener) {
         this.activity = activity;
-        this.link = link;
-        this.description = description;
+        this.shareLinkConfig = shareLinkConfig;
+        this.umShareListener = umShareListener;
     }
 
     public void showShare() {
@@ -63,13 +49,13 @@ public class DialogShare {
         TextView withdrawal = dialog_parent.findViewById(R.id.withdrawal);
         TextView tv_link = dialog_parent.findViewById(R.id.tv_link);
         TextView cancel_share_tv = dialog_parent.findViewById(R.id.cancel_share_tv);
-        if (!TextUtils.isEmpty(link))
-            tv_link.setText(link);
+        if (!TextUtils.isEmpty(shareLinkConfig.getLink()))
+            tv_link.setText(shareLinkConfig.getLink());
 
         withdrawal.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {
-                StringUtils.CopyText(link);
+                StringUtils.CopyText(shareLinkConfig.getLink());
                 G.showToast("复制链接成功");
             }
         });
@@ -78,7 +64,7 @@ public class DialogShare {
         qq_layotu.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {
-                CommonUtil.getInstance().popShare(activity, link, QQ, description);
+                shareLinkConfig.setShareType(QQ).toShare(activity, umShareListener);
 
                 dialog.dismiss();
             }
@@ -86,7 +72,7 @@ public class DialogShare {
         weixin_layotu.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {
-                CommonUtil.getInstance().popShare(activity, link, WX, description);
+                shareLinkConfig.setShareType(WX).toShare(activity, umShareListener);
                 dialog.dismiss();
             }
         });

+ 3 - 3
app/src/main/java/com/sheep/gamegroup/view/fragment/FgtPersonalCenter.java

@@ -31,10 +31,10 @@ import com.sheep.gamegroup.util.ListUtil;
 import com.sheep.gamegroup.util.SysAppUtil;
 import com.sheep.gamegroup.util.TestUtil;
 import com.sheep.gamegroup.util.ViewUtil;
+import com.sheep.gamegroup.util.share.ShareLinkConfig;
 import com.sheep.gamegroup.view.activity.ActMsg;
 import com.sheep.gamegroup.view.activity.PersonalCenterAct;
 import com.sheep.gamegroup.view.adapter.AdpUserCenterModule;
-import com.sheep.gamegroup.view.dialog.DialogShare;
 import com.sheep.jiuyan.samllsheep.R;
 import com.sheep.jiuyan.samllsheep.SheepApp;
 import com.sheep.jiuyan.samllsheep.base.BaseFragment;
@@ -51,8 +51,8 @@ import java.util.Locale;
 import butterknife.BindView;
 import butterknife.OnClick;
 import io.reactivex.android.schedulers.AndroidSchedulers;
-import rx.functions.Action1;
 import io.reactivex.schedulers.Schedulers;
+import rx.functions.Action1;
 
 import static com.sheep.gamegroup.util.UMConfigUtils.Event.USER_AGENT;
 import static com.sheep.gamegroup.util.UMConfigUtils.Event.USER_FAQ;
@@ -490,7 +490,7 @@ public class FgtPersonalCenter extends BaseFragment {
                 break;
             case R.id.recommend_friend_layout://推荐给好友
                 if (userEntity != null) {
-                    ViewUtil.shareLink(activity, CommonUtil.getInstance().jointString(userEntity.getShareLink(DialogShare.OTHER), DialogShare.OTHER));
+                    ViewUtil.shareLink(activity, userEntity.getShareLink(ShareLinkConfig.OTHER));
                 }
                 USER_SHARE.onEvent();
                 break;

+ 4 - 3
app/src/main/java/com/sheep/jiuyan/samllsheep/ui/activity/SignActivity.java

@@ -27,6 +27,7 @@ import com.sheep.gamegroup.util.ListUtil;
 import com.sheep.gamegroup.util.TestUtil;
 import com.sheep.gamegroup.util.TimeUtil;
 import com.sheep.gamegroup.util.ViewUtil;
+import com.sheep.gamegroup.util.share.ShareLinkConfig;
 import com.sheep.gamegroup.util.viewHelper.LayoutParamsUtil;
 import com.sheep.gamegroup.view.customview.ErasableTextView;
 import com.sheep.jiuyan.samllsheep.R;
@@ -45,8 +46,8 @@ import java.util.Locale;
 import butterknife.BindView;
 import butterknife.OnClick;
 import io.reactivex.android.schedulers.AndroidSchedulers;
-import rx.functions.Action1;
 import io.reactivex.schedulers.Schedulers;
+import rx.functions.Action1;
 
 /**
  * Created by: zhoujuncai.
@@ -435,7 +436,7 @@ public class SignActivity extends BaseActivity implements UMShareListener {
             if(lastUserSign.signShared()){//可以进行补签且进行过分享操作,可以直接补签
                 signInSupplement();
             } else {
-                CommonUtil.getInstance().tryShowShareDialog(new Action1<View>() {
+                new ShareLinkConfig().setAction1(new Action1<View>() {
                     @Override
                     public void call(View view) {
                         if(view == null){
@@ -444,7 +445,7 @@ public class SignActivity extends BaseActivity implements UMShareListener {
                             ViewUtil.setText((TextView) view.findViewById(R.id.ask_share_title), "邀请获得复活机会");
                         }
                     }
-                }, this);
+                }).toShare(this);
             }
         } else {
             signNow();