|
|
@@ -5,12 +5,24 @@ import android.content.Intent;
|
|
|
import android.net.Uri;
|
|
|
import android.os.Bundle;
|
|
|
import android.support.annotation.Nullable;
|
|
|
+import android.text.TextUtils;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.kfzs.cfyl.share_library.util.Constant;
|
|
|
+import com.kfzs.duanduan.utils.ApkUtils;
|
|
|
+import com.sheep.gamegroup.model.api.BaseMessageConverter;
|
|
|
+import com.sheep.gamegroup.model.entity.HomeListEntity;
|
|
|
+import com.sheep.gamegroup.model.entity.SlideshowEty;
|
|
|
import com.sheep.gamegroup.util.ActionUtil;
|
|
|
+import com.sheep.gamegroup.util.CommonUtil;
|
|
|
import com.sheep.gamegroup.util.Jump2View;
|
|
|
import com.sheep.gamegroup.util.TestUtil;
|
|
|
import com.sheep.jiuyan.samllsheep.R;
|
|
|
+import com.sheep.jiuyan.samllsheep.bean.UserCenterModule;
|
|
|
import com.sheep.jiuyan.samllsheep.utils.G;
|
|
|
+import com.sheep.jiuyan.samllsheep.utils.PackageUtil;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
|
|
|
/**
|
|
|
* Created by realicing on 2018/5/10.
|
|
|
@@ -37,12 +49,85 @@ public class MiddleSchemeAct extends Activity {
|
|
|
switch (action) {
|
|
|
case Intent.ACTION_VIEW:
|
|
|
Uri uri = intent.getData();
|
|
|
- String game_id = "";
|
|
|
if (uri != null) {
|
|
|
// 完整的url信息
|
|
|
if (TestUtil.isTest())
|
|
|
G.showToast(uri.toString());
|
|
|
- game_id = uri.getQueryParameter("game_id");
|
|
|
+ parseUri(uri);
|
|
|
+ }
|
|
|
+ finish();
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void parseUri(Uri uri) {
|
|
|
+ String type = uri.getQueryParameter("type");
|
|
|
+ if(type == null){
|
|
|
+// 尝试获取game_id
|
|
|
+ //sheep://small.kfzs.com/xmy?game_id=1385&code=976873
|
|
|
+ tryGoSplashAct(uri);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ //尝试解密数据
|
|
|
+ String json = BaseMessageConverter.decrypt(uri.getQueryParameter("data"));
|
|
|
+ switch (type){
|
|
|
+ default://尝试获取game_id
|
|
|
+ tryGoSplashAct(uri);
|
|
|
+ break;
|
|
|
+ //sheep://small.kfzs.com/sheep?type=jhl&data={"Jump":"1"}
|
|
|
+ case "jump_home_list"://跳转homeList
|
|
|
+ case "jhl":
|
|
|
+ try {
|
|
|
+ HomeListEntity item = JSONObject.parseObject(json, HomeListEntity.class);
|
|
|
+ CommonUtil.getInstance().goNative(this, item, "view");
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ if(TestUtil.isTest() && TextUtils.isEmpty(e.getMessage()))
|
|
|
+ G.showToast(e.getMessage());
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ //sheep://small.kfzs.com/sheep?type=jum&data={"jump":1}
|
|
|
+ case "jump_user_module"://跳转个人中心列表功能模块
|
|
|
+ case "jum":
|
|
|
+ try {
|
|
|
+ UserCenterModule item = JSONObject.parseObject(json, UserCenterModule.class);
|
|
|
+ CommonUtil.getInstance().goNative(this, item, "view");
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ if(TestUtil.isTest() && TextUtils.isEmpty(e.getMessage()))
|
|
|
+ G.showToast(e.getMessage());
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ //sheep://small.kfzs.com/sheep?type=jss&data={"Type":1}
|
|
|
+ case "jump_slide_show"://跳转banner(主页banner或者游戏banner)
|
|
|
+ case "jss":
|
|
|
+ try {
|
|
|
+ SlideshowEty item = JSONObject.parseObject(json, SlideshowEty.class);
|
|
|
+ CommonUtil.getInstance().clickBanner(this, item);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ if(TestUtil.isTest() && TextUtils.isEmpty(e.getMessage()))
|
|
|
+ G.showToast(e.getMessage());
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ //sheep://small.kfzs.com/sheep?type=run_app&packageName=com.realicing.android.upgrade.sheep&className=com.realicing.android.upgrade.sheep.MainActivity
|
|
|
+ case "run_app":
|
|
|
+ case "run":
|
|
|
+ String packageName = uri.getQueryParameter("packageName");
|
|
|
+ String className = uri.getQueryParameter("className");
|
|
|
+ boolean packageNameIsEmpty = TextUtils.isEmpty(packageName);
|
|
|
+ boolean classNameIsEmpty = TextUtils.isEmpty(className);
|
|
|
+ if(packageNameIsEmpty && classNameIsEmpty){
|
|
|
+ tryGoSplashAct(uri);
|
|
|
+ } else if(packageNameIsEmpty){
|
|
|
+ runApp(getPackageName(), className);
|
|
|
+ } else if(classNameIsEmpty) {
|
|
|
+ PackageUtil.startApp(this, packageName);
|
|
|
+ } else {
|
|
|
+ runApp(packageName, className);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
// LogUtil.println("ActMain", "checkScheme","url: " + url);
|
|
|
// // scheme部分
|
|
|
// String scheme = uri.getScheme();
|
|
|
@@ -52,7 +137,7 @@ public class MiddleSchemeAct extends Activity {
|
|
|
// LogUtil.println("ActMain", "checkScheme","host: " + host);
|
|
|
// //port部分
|
|
|
// int port = uri.getPort();
|
|
|
-// LogUtil.println("ActMain", "checkScheme","host: " + port);
|
|
|
+// LogUtil.println("ActMain", "checkScheme","port: " + port);
|
|
|
// // 访问路劲
|
|
|
// String path = uri.getPath();
|
|
|
// LogUtil.println("ActMain", "checkScheme","path: " + path);
|
|
|
@@ -67,25 +152,37 @@ public class MiddleSchemeAct extends Activity {
|
|
|
// if(TextUtils.equals(code, "0")){
|
|
|
// finish();
|
|
|
// }
|
|
|
- /**
|
|
|
- * sheep://small.kfzs.com/xmy?game_id=1385&code=976873
|
|
|
- * ActMain checkScheme url: sheep://kfzs:8888/xmy?code=976873
|
|
|
- * ActMain checkScheme scheme: sheep
|
|
|
- * ActMain checkScheme host: kfzs
|
|
|
- * ActMain checkScheme host: 8888
|
|
|
- * ActMain checkScheme path: /xmy
|
|
|
- * ActMain checkScheme pathSegments: ["xmy"]
|
|
|
- * ActMain checkScheme query: code=976873
|
|
|
- * ActMain checkScheme code: 976873
|
|
|
- */
|
|
|
- }
|
|
|
- ActionUtil.getInstance().addNextAction(SHOW_DIALOG_GAME_OR_GIFT_TASK, game_id);
|
|
|
- Jump2View.getInstance().newTaskTopStartAct(this, SplashAct.class, null);
|
|
|
- finish();
|
|
|
- break;
|
|
|
+ }
|
|
|
+ private void runApp(String packageName, String className){
|
|
|
+ try {
|
|
|
+ Intent intent = new Intent();
|
|
|
+ intent.setClassName(packageName, className);
|
|
|
+ startActivity(intent);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ if(TestUtil.isTest() && TextUtils.isEmpty(e.getMessage()))
|
|
|
+ G.showToast(e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 进入主页,可以设置 game_id 用于展示会长推广弹出框
|
|
|
+ * sheep://small.kfzs.com/xmy?game_id=1385&code=976873
|
|
|
+ * ActMain checkScheme scheme: sheep
|
|
|
+ * ActMain checkScheme host: small.kfzs.com
|
|
|
+ * ActMain checkScheme path: /xmy
|
|
|
+ * ActMain checkScheme pathSegments: ["xmy"]
|
|
|
+ * ActMain checkScheme query: code=976873
|
|
|
+ * ActMain checkScheme code: 976873
|
|
|
+ */
|
|
|
+ private void tryGoSplashAct(Uri uri) {
|
|
|
+ String game_id = uri.getQueryParameter("game_id");
|
|
|
+ if(!TextUtils.isEmpty(game_id))//有game_id时设置game_id的回调到主页,用于展示会长推广弹出框
|
|
|
+ ActionUtil.getInstance().addNextAction(SHOW_DIALOG_GAME_OR_GIFT_TASK, game_id);
|
|
|
+ Jump2View.getInstance().newTaskTopStartAct(this, SplashAct.class, null);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
//展示会长推广弹出框的key
|
|
|
public static final String SHOW_DIALOG_GAME_OR_GIFT_TASK = "show_dialog_game_or_gift_task";
|
|
|
}
|