278 lines
15 KiB
Java
278 lines
15 KiB
Java
package com.gh.gamecenter;
|
||
|
||
import android.content.Intent;
|
||
import android.net.Uri;
|
||
import android.os.Bundle;
|
||
import android.text.TextUtils;
|
||
|
||
import com.gh.base.BaseActivity;
|
||
import com.gh.common.util.CheckLoginUtils;
|
||
import com.gh.common.util.DirectUtils;
|
||
import com.gh.common.util.EntranceUtils;
|
||
import com.gh.common.util.PlatformUtils;
|
||
import com.gh.common.util.RunningUtils;
|
||
import com.gh.gamecenter.entity.CommunityEntity;
|
||
import com.gh.gamecenter.entity.VideoLinkEntity;
|
||
import com.gh.gamecenter.manager.UserManager;
|
||
import com.gh.gamecenter.video.detail.VideoDetailContainerViewModel;
|
||
import com.gh.gamecenter.video.videomanager.VideoManagerActivity;
|
||
import com.lightgame.config.CommonDebug;
|
||
import com.lightgame.utils.Utils;
|
||
|
||
import static com.gh.common.util.EntranceUtils.ENTRANCE_BROWSER;
|
||
import static com.gh.common.util.EntranceUtils.HOST_ANSWER;
|
||
import static com.gh.common.util.EntranceUtils.HOST_ARTICLE;
|
||
import static com.gh.common.util.EntranceUtils.HOST_CATEGORY;
|
||
import static com.gh.common.util.EntranceUtils.HOST_COLUMN;
|
||
import static com.gh.common.util.EntranceUtils.HOST_COLUMN_COLLECTION;
|
||
import static com.gh.common.util.EntranceUtils.HOST_COMMUNITY;
|
||
import static com.gh.common.util.EntranceUtils.HOST_COMMUNITY_COLUMN;
|
||
import static com.gh.common.util.EntranceUtils.HOST_COMMUNITY_COLUMN_DETAIL;
|
||
import static com.gh.common.util.EntranceUtils.HOST_COMMUNITY_QUESTION_LABEL_DETAIL;
|
||
import static com.gh.common.util.EntranceUtils.HOST_DOWNLOAD;
|
||
import static com.gh.common.util.EntranceUtils.HOST_GAME;
|
||
import static com.gh.common.util.EntranceUtils.HOST_LIBAO;
|
||
import static com.gh.common.util.EntranceUtils.HOST_QQ;
|
||
import static com.gh.common.util.EntranceUtils.HOST_QQ_GROUP;
|
||
import static com.gh.common.util.EntranceUtils.HOST_QUESTION;
|
||
import static com.gh.common.util.EntranceUtils.HOST_SUGGESTION;
|
||
import static com.gh.common.util.EntranceUtils.HOST_TOOLBOX;
|
||
import static com.gh.common.util.EntranceUtils.HOST_UPLOAD_VIDEO;
|
||
import static com.gh.common.util.EntranceUtils.HOST_USERHOME;
|
||
import static com.gh.common.util.EntranceUtils.HOST_VIDEO;
|
||
import static com.gh.common.util.EntranceUtils.HOST_VIDEO_COLLECTION;
|
||
import static com.gh.common.util.EntranceUtils.HOST_VIDEO_MORE;
|
||
import static com.gh.common.util.EntranceUtils.HOST_VIDEO_SINGLE;
|
||
import static com.gh.common.util.EntranceUtils.HOST_VIDEO_STREAMING_DESC;
|
||
import static com.gh.common.util.EntranceUtils.HOST_VIDEO_STREAMING_HOME;
|
||
import static com.gh.common.util.EntranceUtils.HOST_WEB;
|
||
import static com.gh.common.util.EntranceUtils.KEY_DATA;
|
||
import static com.gh.common.util.EntranceUtils.KEY_GAME_NAME;
|
||
import static com.gh.common.util.EntranceUtils.KEY_NAME;
|
||
import static com.gh.common.util.EntranceUtils.KEY_PACKAGENAME;
|
||
import static com.gh.common.util.EntranceUtils.KEY_PLATFORM;
|
||
import static com.gh.common.util.EntranceUtils.KEY_TO;
|
||
import static com.gh.common.util.EntranceUtils.KEY_TYPE;
|
||
import static com.gh.common.util.EntranceUtils.KEY_VERSION;
|
||
|
||
/**
|
||
* Created by LGT on 2016/11/16.
|
||
* 链接跳转用
|
||
*/
|
||
public class SkipActivity extends BaseActivity {
|
||
|
||
@Override
|
||
protected int getLayoutId() {
|
||
//TODO 暂时无意义设置,避免崩溃罢了,修改完主题和Toolbar相关内容会干掉这个
|
||
return R.layout.fragment_main;
|
||
}
|
||
|
||
@Override
|
||
protected void onCreate(Bundle savedInstanceState) {
|
||
super.onCreate(savedInstanceState);
|
||
|
||
Uri uri = getIntent().getData();
|
||
Bundle bundle;
|
||
if (uri != null) {
|
||
if (CommonDebug.IS_DEBUG) {
|
||
Utils.log("SkipActivity:: Uri=>" + uri.toString());
|
||
}
|
||
String host = uri.getHost();
|
||
String path = uri.getPath();
|
||
|
||
String to = uri.getQueryParameter("to");
|
||
String type = uri.getQueryParameter("type");
|
||
String name = uri.getQueryParameter("name");
|
||
String referer = uri.getQueryParameter("referer");
|
||
String id = uri.getQueryParameter("id");
|
||
if (!TextUtils.isEmpty(path)) {
|
||
path = path.substring(1);
|
||
}
|
||
|
||
if (host != null) {
|
||
Intent intent;
|
||
switch (host) {
|
||
case HOST_ARTICLE:
|
||
DirectUtils.directToArticle(this, path, ENTRANCE_BROWSER);
|
||
break;
|
||
case HOST_GAME:
|
||
DirectUtils.directToGameDetail(this, path, ENTRANCE_BROWSER, false, "libao".equals(to));
|
||
break;
|
||
case HOST_COLUMN:
|
||
DirectUtils.directToSubject(this, path, uri.getQueryParameter(KEY_NAME), ENTRANCE_BROWSER);
|
||
break;
|
||
case HOST_SUGGESTION:
|
||
String platform = uri.getQueryParameter(KEY_PLATFORM);
|
||
String platformName = PlatformUtils.getInstance(this).getPlatformName(platform);
|
||
String content = String.format("%s-%s-V%s,",
|
||
uri.getQueryParameter(KEY_GAME_NAME),
|
||
TextUtils.isEmpty(platformName) ? platform : platformName,
|
||
uri.getQueryParameter(KEY_VERSION));
|
||
DirectUtils.directToFeedback(this, content, ENTRANCE_BROWSER);
|
||
break;
|
||
case HOST_DOWNLOAD:
|
||
DirectUtils.directToDownloadManagerAndStartUpdate(this, path, uri.getQueryParameter(KEY_PACKAGENAME), ENTRANCE_BROWSER);
|
||
break;
|
||
case HOST_ANSWER:
|
||
DirectUtils.directToAnswerDetail(this, path, ENTRANCE_BROWSER, "浏览器");
|
||
break;
|
||
case HOST_QUESTION:
|
||
DirectUtils.directToQuestionDetail(this, path, ENTRANCE_BROWSER, "浏览器");
|
||
break;
|
||
case HOST_TOOLBOX:
|
||
DirectUtils.directToToolbox(this, uri.getQueryParameter("gameId"), uri.getQueryParameter("toolboxUrl"), ENTRANCE_BROWSER);
|
||
break;
|
||
case HOST_COMMUNITY:
|
||
UserManager.getInstance().setCommunityData(new CommunityEntity(path, name));
|
||
// 把切换放到 MainActivity 处理
|
||
if (RunningUtils.isRunning(this)
|
||
&& MainActivity.class.getName().equals(RunningUtils.getBaseActivity(this))) {
|
||
intent = new Intent(this, MainActivity.class);
|
||
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||
intent.putExtra(MainActivity.SWITCH_TO_COMMUNITY, true);
|
||
} else {
|
||
bundle = new Bundle();
|
||
bundle.putBoolean(MainActivity.SWITCH_TO_COMMUNITY, true);
|
||
intent = SplashScreenActivity.getSplashScreenIntent(this, bundle);
|
||
}
|
||
startActivity(intent);
|
||
break;
|
||
// 社区文章格式一
|
||
case "community.article":
|
||
DirectUtils.directToCommunityArticle(this, uri.getQueryParameter("articleId"), uri.getQueryParameter("communityId"), ENTRANCE_BROWSER, "浏览器");
|
||
break;
|
||
// 社区文章格式二
|
||
case "communities":
|
||
String communityId = "";
|
||
String typeId = "";
|
||
String[] split = path.split("/");
|
||
for (String text : split) {
|
||
if (TextUtils.isEmpty(communityId)) {
|
||
communityId = text;
|
||
continue;
|
||
}
|
||
if (TextUtils.isEmpty(type)) {
|
||
type = text;
|
||
continue;
|
||
}
|
||
if (TextUtils.isEmpty(typeId)) {
|
||
typeId = text;
|
||
}
|
||
}
|
||
if ("articles".equals(type)) {
|
||
DirectUtils.directToCommunityArticle(this, typeId, communityId, ENTRANCE_BROWSER, "浏览器");
|
||
break;
|
||
}
|
||
break;
|
||
case HOST_VIDEO:
|
||
DirectUtils.directToVideoDetail(this, path, VideoDetailContainerViewModel.Location.HOTTEST_GAME_VIDEO.getValue(),
|
||
false, id, ENTRANCE_BROWSER, "浏览器", TextUtils.isEmpty(referer) ? "" : referer);
|
||
break;
|
||
case HOST_UPLOAD_VIDEO://跳转上传视频
|
||
String titleParameter = uri.getQueryParameter("title");
|
||
String title = TextUtils.isEmpty(titleParameter) ? "" : "#" + titleParameter + "#";
|
||
String categoryId = uri.getQueryParameter("category_id");
|
||
String link = uri.getQueryParameter("link");
|
||
VideoLinkEntity linkEntity = new VideoLinkEntity(title, categoryId, link);
|
||
// if (!CheckLoginUtils.isLogin()) {
|
||
// HaloApp.put(HOST_UPLOAD_VIDEO, linkEntity);
|
||
// }
|
||
Bundle nextToBundle = VideoManagerActivity.getVideoManagerBundle(linkEntity, EntranceUtils.ENTRANCE_BROWSER, "");
|
||
CheckLoginUtils.checkLogin(this, nextToBundle, true, EntranceUtils.ENTRANCE_BROWSER, null);
|
||
break;
|
||
case HOST_VIDEO_SINGLE:
|
||
DirectUtils.directToVideoDetail(this, path, VideoDetailContainerViewModel.Location.SINGLE_VIDEO.getValue(),
|
||
false, "", ENTRANCE_BROWSER, "浏览器", TextUtils.isEmpty(referer) ? "" : referer);
|
||
break;
|
||
case HOST_VIDEO_MORE:
|
||
String act = uri.getQueryParameter("act");
|
||
String loaction = TextUtils.isEmpty(act) ? path : VideoDetailContainerViewModel.Location.VIDEO_ACTIVITY.getValue();
|
||
DirectUtils.directToVideoDetail(this, path, loaction,
|
||
false, "", ENTRANCE_BROWSER, "浏览器", TextUtils.isEmpty(referer) ? "" : referer, type, act);
|
||
break;
|
||
case HOST_VIDEO_STREAMING_HOME:
|
||
// 把切换放到 MainActivity 处理
|
||
if (RunningUtils.isRunning(this)
|
||
&& MainActivity.class.getName().equals(RunningUtils.getBaseActivity(this))) {
|
||
intent = new Intent(this, MainActivity.class);
|
||
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||
intent.putExtra(MainActivity.SWITCH_TO_VIDEO, true);
|
||
} else {
|
||
bundle = new Bundle();
|
||
bundle.putBoolean(MainActivity.SWITCH_TO_VIDEO, true);
|
||
intent = SplashScreenActivity.getSplashScreenIntent(this, bundle);
|
||
}
|
||
startActivity(intent);
|
||
break;
|
||
case HOST_VIDEO_STREAMING_DESC:
|
||
DirectUtils.directToGameDetailVideoStreaming(this, path, ENTRANCE_BROWSER);
|
||
break;
|
||
case HOST_VIDEO_COLLECTION:
|
||
DirectUtils.directToGameVideo(this, path, ENTRANCE_BROWSER, "浏览器");
|
||
break;
|
||
case HOST_QQ:
|
||
bundle = new Bundle();
|
||
bundle.putString(KEY_TO, HOST_QQ);
|
||
bundle.putString(KEY_DATA, path);
|
||
EntranceUtils.jumpActivity(this, bundle);
|
||
break;
|
||
case HOST_QQ_GROUP:
|
||
bundle = new Bundle();
|
||
bundle.putString(KEY_TO, HOST_QQ_GROUP);
|
||
bundle.putString(KEY_DATA, path);
|
||
EntranceUtils.jumpActivity(this, bundle);
|
||
break;
|
||
case HOST_WEB:
|
||
bundle = new Bundle();
|
||
bundle.putString(KEY_TO, HOST_WEB);
|
||
bundle.putString(KEY_DATA, to);
|
||
bundle.putString(KEY_TYPE, type);
|
||
EntranceUtils.jumpActivity(this, bundle);
|
||
break;
|
||
case HOST_LIBAO:
|
||
DirectUtils.directToGiftDetail(this, path, ENTRANCE_BROWSER);
|
||
break;
|
||
case HOST_USERHOME:
|
||
String position = uri.getQueryParameter("position");
|
||
DirectUtils.directToHomeActivity(this, path, TextUtils.isEmpty(position) ? -1 : Integer.parseInt(position), ENTRANCE_BROWSER, "浏览器");
|
||
break;
|
||
case HOST_COMMUNITY_COLUMN:
|
||
CommunityEntity community = new CommunityEntity();
|
||
community.setId(uri.getQueryParameter("community_id"));
|
||
community.setName(uri.getQueryParameter("community_name"));
|
||
String columnId = uri.getQueryParameter("column_id");
|
||
DirectUtils.directToCommunityColumn(this, community, columnId, ENTRANCE_BROWSER, "");
|
||
break;
|
||
|
||
case HOST_CATEGORY:
|
||
title = uri.getQueryParameter("title");
|
||
DirectUtils.directCategoryDirectory(this, path, title, ENTRANCE_BROWSER, "浏览器");
|
||
break;
|
||
case HOST_COLUMN_COLLECTION:
|
||
DirectUtils.directToColumnCollection(this, path, -1, ENTRANCE_BROWSER, "浏览器");
|
||
break;
|
||
case HOST_COMMUNITY_QUESTION_LABEL_DETAIL:
|
||
community = new CommunityEntity();
|
||
community.setId(uri.getQueryParameter("community_id"));
|
||
community.setName(uri.getQueryParameter("community_name"));
|
||
String tag = uri.getQueryParameter("tag");
|
||
DirectUtils.directAskColumnLabelDetail(this, tag, community, ENTRANCE_BROWSER, "浏览器");
|
||
break;
|
||
case HOST_COMMUNITY_COLUMN_DETAIL:
|
||
community = new CommunityEntity();
|
||
community.setId(uri.getQueryParameter("community_id"));
|
||
community.setName(uri.getQueryParameter("community_name"));
|
||
columnId = uri.getQueryParameter("column_id");
|
||
DirectUtils.directAskColumnDetail(this, columnId, community, ENTRANCE_BROWSER, "浏览器");
|
||
break;
|
||
default:
|
||
EntranceUtils.jumpActivity(this, new Bundle()); // 跳转至首页
|
||
return;
|
||
}
|
||
}
|
||
}
|
||
|
||
finish();
|
||
}
|
||
}
|