billyyoyo 6 éve
szülő
commit
fa88dceb4a

+ 4 - 0
app/src/main/AndroidManifest.xml

@@ -856,6 +856,10 @@
             android:name="com.sheep.gamegroup.view.activity.ActInvitation"
             android:screenOrientation="portrait"
             android:theme="@style/AppActionTheme" /> <!-- start幂动科技 -->
+        <activity
+            android:name="com.sheep.gamegroup.view.activity.ActWebShareImage"
+            android:screenOrientation="portrait"
+            android:theme="@style/AppActionTheme" />
         <receiver
             android:name="com.mdad.sdk.mdsdk.AppInstallReceiver"
             android:enabled="true"

+ 6 - 0
app/src/main/java/com/sheep/gamegroup/model/api/ApiService.java

@@ -1098,6 +1098,12 @@ public interface ApiService {
     /**
      * 游戏礼包
      */
+    @GET("app/gift_bag/v2/{id}")
+    Observable<BaseMessage> getGiftBagById(@Path("id") int id);
+
+    /**
+     * 游戏礼包
+     */
     @GET("app/gift_bag")
     Observable<BaseMessage> getGiftBagList(@Query("page") int page, @Query("per_page") int per_page);
 

+ 1 - 0
app/src/main/java/com/sheep/gamegroup/module/home/fragment/FgtMainHeader.java

@@ -24,6 +24,7 @@ import com.sheep.gamegroup.util.Jump2View;
 import com.sheep.gamegroup.util.LogUtil;
 import com.sheep.gamegroup.util.ViewUtil;
 import com.sheep.gamegroup.view.activity.ActMsg;
+import com.sheep.gamegroup.view.activity.ActWebShareImage;
 import com.sheep.gamegroup.view.dialog.DialogNotificationOfArrival;
 import com.sheep.gamegroup.view.fragment.FgtPersonalCenter;
 import com.sheep.jiuyan.samllsheep.R;

+ 46 - 0
app/src/main/java/com/sheep/gamegroup/module/task/helper/DKListener.java

@@ -0,0 +1,46 @@
+package com.sheep.gamegroup.module.task.helper;
+
+import com.stmsdk.module.ad.StyleAdEntity;
+import com.tencent.tmsecure.dksdk.util.DkAppDownloadListener;
+
+public class DKListener implements DkAppDownloadListener {
+    @Override
+    public void onShow(String s, String s1) {
+
+    }
+
+    @Override
+    public void onPlayed(String s) {
+
+    }
+
+    @Override
+    public void onClosed(String s, boolean b, String s1, String s2) {
+
+    }
+
+    @Override
+    public void onAdClick(String s, String s1) {
+
+    }
+
+    @Override
+    public void onDownloadFinished(String s, String s1) {
+
+    }
+
+    @Override
+    public void onInstalled(String s, String s1) {
+
+    }
+
+    @Override
+    public void onLoadFail(String s, String s1) {
+
+    }
+
+    @Override
+    public void onAwakened(StyleAdEntity styleAdEntity, int i) {
+
+    }
+}

+ 41 - 2
app/src/main/java/com/sheep/gamegroup/util/CommonUtil.java

@@ -73,6 +73,7 @@ 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.module.home.adapter.AdpHomeList;
+import com.sheep.gamegroup.module.task.helper.DKListener;
 import com.sheep.gamegroup.usage.AppUsageManager;
 import com.sheep.gamegroup.util.viewHelper.PopupWindowUtil;
 import com.sheep.gamegroup.view.activity.ActMain;
@@ -92,6 +93,7 @@ import com.sheep.jiuyan.samllsheep.utils.PackageUtil;
 import com.sheep.jiuyan.samllsheep.utils.SpUtils;
 import com.tencent.mm.opensdk.modelpay.PayReq;
 import com.tencent.mm.opensdk.openapi.IWXAPI;
+import com.tencent.tmsecure.dksdk.ad.DkAdManage;
 import com.umeng.socialize.UMAuthListener;
 import com.umeng.socialize.UMShareAPI;
 import com.umeng.socialize.bean.SHARE_MEDIA;
@@ -472,6 +474,7 @@ public class CommonUtil {
     public static final int JUMP_FIND_ACT = 19;//活动
     public static final int JUMP_FIND_INFORMATION = 20;//资讯
     public static final int JUMP_FIND_GMAE = 21;//发现中的游戏
+    public static final int JUMP_WATCH_AD = 26;//发现中的游戏
 
     /**
      * 点击jump跳转
@@ -581,6 +584,8 @@ public class CommonUtil {
             case IDConstant.JUMP_H5_GAME://腾讯H5小游戏
                 Jump2View.getInstance().goH5Game(activity, jump.getUrl());
                 break;
+            case JUMP_WATCH_AD:
+                break;
             default:
                 String url = jump.getUrl();
                 if (TextUtils.isEmpty(url))
@@ -2400,7 +2405,7 @@ public class CommonUtil {
                 });
     }
 
-    public void statGameDownloadError(String gameId, String downloadUrl, String ip, String clientMd5, String serverMd5){
+    public void statGameDownloadError(String gameId, String downloadUrl, String ip, String clientMd5, String serverMd5) {
         SheepApp.getInstance().getNetComponent().getApiService().statGameDownloadError(gameId, downloadUrl, ip, clientMd5, serverMd5)
                 .subscribeOn(Schedulers.io())
                 .observeOn(AndroidSchedulers.mainThread())
@@ -2648,10 +2653,12 @@ public class CommonUtil {
     public void clickAd(Context activity, long id, int type, long linkId) {
         AdHelper.stat(id, 2);
         switch (type) {// 0,类型 1跳转试玩赚钱、2单个任务详情、3信用卡办理、4 H5页面、5 微信二维码任务
-            case 1: // 跳转试玩赚钱
+            case JUMP_TRY_PLAY: // 跳转试玩赚钱
                 Jump2View.getInstance().goTryplayView(activity, null);
                 break;
             case 2: // 单个任务详情
+            case 22: // 单个任务详情
+            case 23: // 单个任务详情
                 Jump2View.getInstance().goTaskById((int) linkId);
                 break;
             case 3: // 信用卡办理
@@ -2694,12 +2701,44 @@ public class CommonUtil {
             case JUMP_WATCH_FOCUS://看点
                 Jump2View.getInstance().goWatchFocus(activity, (int) linkId);
                 break;
+            case 24://礼包
+                Jump2View.getInstance().goGiftDetail(activity, (int) linkId);
+                break;
+            case 25://掌酷
+                G.showToast(R.string.coming_soon);
+                break;
+            case 26://点客
+                new DkAdManage(activity).loadTmAdById("samllsheep",104 ,new DKListener());
+                break;
             default:
                 G.showToast(R.string.coming_soon);
                 break;
         }
     }
 
+    public void getGiftBag(int id, final Action1<GiftBagApp> action1) {
+        SheepApp.getInstance()
+                .getNetComponent()
+                .getApiService()
+                .getGiftBagById(id)
+                .subscribeOn(Schedulers.io())
+                .observeOn(AndroidSchedulers.mainThread())
+                .subscribe(new SheepSubscriber<BaseMessage>(SheepApp.getInstance()) {
+                    @Override
+                    public void onError(BaseMessage baseMessage) {
+                        if (action1 != null)
+                            action1.call(null);
+
+                    }
+
+                    @Override
+                    public void onNext(BaseMessage baseMessage) {
+                        if (action1 != null)
+                            action1.call(baseMessage.getData(GiftBagApp.class));
+                    }
+                });
+    }
+
     /**
      * tag 标签绘制
      * R.drawable.shape_blue_stroke_rectangle_no_lb

+ 16 - 9
app/src/main/java/com/sheep/gamegroup/util/Jump2View.java

@@ -37,6 +37,7 @@ import com.sheep.gamegroup.model.entity.DiscoveryVideo;
 import com.sheep.gamegroup.model.entity.GameEntity;
 import com.sheep.gamegroup.model.entity.GameListTag;
 import com.sheep.gamegroup.model.entity.GameListType;
+import com.sheep.gamegroup.model.entity.GiftBagApp;
 import com.sheep.gamegroup.model.entity.HomeListEntity;
 import com.sheep.gamegroup.model.entity.IDBean;
 import com.sheep.gamegroup.model.entity.LoginEntity;
@@ -207,6 +208,7 @@ import java.io.Serializable;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Locale;
+import java.util.concurrent.atomic.AtomicReference;
 
 import cn.finalteam.rxgalleryfinal.utils.CameraUtil;
 import io.reactivex.Observable;
@@ -1755,9 +1757,9 @@ public class Jump2View {
                                 }
                                 //显示弹窗广告
                                 SheepAd ad = DDProviderHelper.getInstance().getSheepAd(SheepAd.FORM_POP);
-                                if(ad!=null){
+                                if (ad != null) {
                                     ViewUtil.showHalfScreenAd(activity, ad, container);
-                                } else{
+                                } else {
                                     EventBus.getDefault().post(BigEvent.get().setEventTypes(EventTypes.GUIDE_NEXT));
                                     tryShowYfShopAskDialog(activity);
                                 }
@@ -2223,13 +2225,18 @@ public class Jump2View {
      * 进入礼包详情页面
      */
     public void goGiftDetail(Context context, Object object) {
-        Intent intent = new Intent(context, ActGiftDetail.class);
-        if (object instanceof Integer)//ActGiftDetail中暂未实现获取功能
-            intent.putExtra("id", (Integer) object);
-        else if (object != null)//ActGiftDetail中暂时只支持获取 GiftBagApp
-            DataUtil.putObject(intent, object);
-        context.startActivity(intent);
-        GIFT_DETAIL.onEvent();
+        Action1<GiftBagApp> action = (gift) -> {
+            if (gift == null) return;
+            Intent intent = new Intent(context, ActGiftDetail.class);
+            DataUtil.putObject(intent, gift);
+            context.startActivity(intent);
+            GIFT_DETAIL.onEvent();
+        };
+        if (object instanceof Integer) {
+            CommonUtil.getInstance().getGiftBag((int) object, action);
+        } else {
+            action.call((GiftBagApp) object);
+        }
     }
 
     /**

+ 8 - 0
app/src/main/java/com/sheep/gamegroup/util/js/KFZSJs.java

@@ -57,6 +57,7 @@ import com.sheep.gamegroup.util.ViewUtil;
 import com.sheep.gamegroup.util.share.ShareLinkConfig;
 import com.sheep.gamegroup.view.activity.ActInvitation;
 import com.sheep.gamegroup.view.activity.ActMain;
+import com.sheep.gamegroup.view.activity.ActWebShareImage;
 import com.sheep.gamegroup.view.activity.ChangeWxOrTelAct;
 import com.sheep.gamegroup.view.activity.RealNameAuthenAct;
 import com.sheep.gamegroup.view.activity.helper.AdHelper;
@@ -309,6 +310,13 @@ public class KFZSJs {
     }
 
     @JavascriptInterface
+    public void shareWebAsImage(String url){
+        Intent in = new Intent(activity, ActWebShareImage.class);
+        in.putExtra("web_url", url);
+        activity.startActivity(in);
+    }
+
+    @JavascriptInterface
     public String getHeader() {
         return SpUtils.getToken(activity);
     }

+ 224 - 0
app/src/main/java/com/sheep/gamegroup/view/activity/ActWebShareImage.java

@@ -0,0 +1,224 @@
+package com.sheep.gamegroup.view.activity;
+
+import android.annotation.SuppressLint;
+import android.os.Bundle;
+import android.support.annotation.Nullable;
+import android.support.v4.app.Fragment;
+import android.support.v4.app.FragmentTransaction;
+import android.support.v7.widget.GridLayoutManager;
+import android.support.v7.widget.RecyclerView;
+import android.view.View;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+import com.kfzs.duanduan.utils.StatusBarUtils;
+import com.sheep.gamegroup.absBase.BaseUMActivity;
+import com.sheep.gamegroup.model.entity.BaseMessage;
+import com.sheep.gamegroup.model.entity.WebParams;
+import com.sheep.gamegroup.model.util.SheepSubscriber;
+import com.sheep.gamegroup.module.webview.fragment.FgtWeb;
+import com.sheep.gamegroup.module.webview.fragment.FgtWebX5;
+import com.sheep.gamegroup.util.ListUtil;
+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.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.G;
+import com.sheep.jiuyan.samllsheep.utils.TitleBarUtils;
+import com.snail.antifake.jni.EmulatorDetectUtil;
+import com.umeng.socialize.UMShareListener;
+import com.umeng.socialize.bean.SHARE_MEDIA;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Locale;
+
+import butterknife.BindView;
+import io.reactivex.android.schedulers.AndroidSchedulers;
+import io.reactivex.schedulers.Schedulers;
+import rx.functions.Action1;
+
+/**
+ * Created by realicing on 2018/9/7.
+ * realicing@sina.com
+ * 邀请赚钱分享界面
+ */
+public class ActWebShareImage extends BaseUMActivity {
+    @BindView(R.id.ask_share_list)
+    RecyclerView ask_share_list;
+
+    GridLayoutManager gridLayoutManager;
+
+    @BindView(R.id.fragment_container)
+    View fragmentContainer;
+
+    String webUrl;
+
+    @Override
+    protected void onCreate(@Nullable Bundle savedInstanceState) {
+        StatusBarUtils.setTranslucent(this);
+        super.onCreate(savedInstanceState);
+        if (getIntent().hasExtra("web_url")) {
+            webUrl = getIntent().getStringExtra("web_url");
+        }
+    }
+
+    @Override
+    protected int getLayoutId() {
+        return R.layout.act_web_share_image;
+    }
+
+    @Override
+    protected boolean showWhiteStatusBar() {
+        return true;
+    }
+
+    @SuppressLint("ClickableViewAccessibility")
+    @Override
+    public void initView() {
+        TitleBarUtils.getInstance().setShowOrHide(this, true)
+                .setTitle(this, "分享")
+                .setTitleFinish(this);
+        FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
+        Fragment fragment = getSupportFragmentManager().findFragmentByTag("tag");
+        if (fragment == null) {
+            if (EmulatorDetectUtil.isEmulator()) {
+                fragment = FgtWeb.newInstance(new WebParams(webUrl, "分享"));
+            } else {
+                fragment = FgtWebX5.newInstance(new WebParams(webUrl, "分享"));
+            }
+            transaction.add(R.id.fragment_container, fragment, "tag");
+            transaction.commitAllowingStateLoss();
+        } else {
+            transaction.replace(R.id.fragment_container, fragment);
+            transaction.commitAllowingStateLoss();
+        }
+        init();
+    }
+
+
+    @Override
+    public void initData() {
+
+    }
+
+    private void init() {
+        gridLayoutManager = new GridLayoutManager(this, 5);
+        ask_share_list.setLayoutManager(gridLayoutManager);
+        final List<String> list = ListUtil.emptyList();
+        final List<Integer> imgList = ListUtil.emptyList();
+        final List<String> nameList = ListUtil.emptyList();
+        list.add(ShareLinkConfig.WX);
+        list.add(ShareLinkConfig.QQ);
+        list.add(ShareLinkConfig.WEIXIN_CIRCLE);
+        imgList.add(R.mipmap.share_wx);
+        imgList.add(R.mipmap.share_qq);
+        imgList.add(R.mipmap.share_weixin_circle);
+        nameList.add("微信");
+        nameList.add("QQ好友");
+        nameList.add("朋友圈");
+        list.add(0, ShareLinkConfig.FACE_TO_FACE);
+        list.add(ShareLinkConfig.COPY_SHARE_LINK);
+        imgList.add(0, R.mipmap.share_face_to_face);
+        imgList.add(R.mipmap.share_copy_share_link);
+        nameList.add(0, "面对面");
+        nameList.add("复制链接");
+        AdbCommonRecycler<String> adapter = new AdbCommonRecycler<String>(this, list) {
+            @Override
+            public int getViewIdByType(int type) {
+                return R.layout.ask_to_share_item;
+            }
+
+            @Override
+            public void convert(ViewHolder holder, final String item) {
+                View itemView = holder.itemView;
+                if (item == null)
+                    return;
+                ImageView ask_to_share_item_img = itemView.findViewById(R.id.ask_to_share_item_img);
+                TextView ask_to_share_item_name = itemView.findViewById(R.id.ask_to_share_item_name);
+                final int position = holder.getAdapterPosition();
+                ask_to_share_item_img.setImageResource(imgList.get(position));
+                ask_to_share_item_name.setText(nameList.get(position));
+                itemView.setOnClickListener(new View.OnClickListener() {
+                    @Override
+                    public void onClick(View view) {
+                        File file;
+                        try {
+                            String fileName = String.format(Locale.CHINA, "share%s.jpg", BuildConfig.FLAVOR);
+                            file = new File(ClassFileHelper.DIR, fileName);
+                            if (!file.exists()) {
+                                file = ViewUtil.saveImage(fragmentContainer, ClassFileHelper.DIR, fileName);
+                            }
+                        } catch (Exception e) {
+                            e.printStackTrace();
+                            G.showToast(e.getMessage());
+                            return;
+                        }
+                        toShare("", item, "", file);
+//                        getShortUrl(url, item, description, file);
+                    }
+                });
+            }
+        };
+        ask_share_list.setAdapter(adapter);
+    }
+
+    private void getShortUrl(String url, String item, String description, File file) {
+        if (url != null) {
+            SheepApp.getInstance().getNetComponent().getApiService().getShortUrl(url)
+                    .subscribeOn(Schedulers.io())
+                    .observeOn(AndroidSchedulers.mainThread())
+                    .subscribe(new SheepSubscriber<BaseMessage>(SheepApp.getInstance()) {
+
+                        @Override
+                        public void onNext(BaseMessage baseMessage) {
+
+                        }
+
+                        @Override
+                        public void onError(BaseMessage baseMessage) {
+                            G.shortToast("分享失败");
+                        }
+                    });
+        } else {
+            toShare(url, item, description, file);
+        }
+    }
+
+    private void toShare(String url, String item, String description, File file) {
+        new ShareLinkConfig()
+                .setLink(url)
+                .setShareType(item)
+                .setDes(description)
+                .setIconFile(file)
+                .setType(ShareLinkConfig.IMG)
+                .toShare(ActWebShareImage.this, new UMShareListener() {
+
+                    @Override
+                    public void onStart(SHARE_MEDIA share_media) {
+
+                    }
+
+                    @Override
+                    public void onResult(SHARE_MEDIA share_media) {
+
+                    }
+
+                    @Override
+                    public void onError(SHARE_MEDIA share_media, Throwable throwable) {
+
+                    }
+
+                    @Override
+                    public void onCancel(SHARE_MEDIA share_media) {
+
+                    }
+                });
+    }
+
+}

+ 49 - 0
app/src/main/res/layout/act_web_share_image.xml

@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    android:id="@+id/main_layout"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:background="#F0F0F0"
+    android:fitsSystemWindows="true">
+
+    <LinearLayout
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:layout_above="@+id/layout_f"
+        android:gravity="center"
+        android:orientation="vertical">
+
+        <FrameLayout
+            android:id="@+id/fragment_container"
+            android:layout_width="300dp"
+            android:layout_height="400dp"></FrameLayout>
+    </LinearLayout>
+
+    <RelativeLayout
+        android:id="@+id/layout_f"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_alignParentBottom="true"
+        android:background="#ffffffff">
+
+        <TextView
+            android:id="@+id/ask_share_title"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:padding="10dp"
+            android:text="邀请好友"
+            android:textColor="#ff333333"
+            android:textSize="14sp" />
+
+        <android.support.v7.widget.RecyclerView
+            android:id="@+id/ask_share_list"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:layout_below="@+id/ask_share_title"
+            android:layout_centerVertical="true"
+            android:layout_marginBottom="8dp" />
+    </RelativeLayout>
+
+
+</RelativeLayout>