|
|
@@ -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) {
|