package com.weikou.beibeivideo.ui.main;
|
|
import android.app.ProgressDialog;
|
import android.content.Context;
|
import android.content.DialogInterface;
|
import android.content.Intent;
|
import android.content.SharedPreferences;
|
import android.content.SharedPreferences.Editor;
|
import android.content.pm.ActivityInfo;
|
import android.database.Cursor;
|
import android.graphics.Color;
|
import android.graphics.ColorMatrix;
|
import android.graphics.ColorMatrixColorFilter;
|
import android.graphics.Paint;
|
import android.net.wifi.WifiInfo;
|
import android.net.wifi.WifiManager;
|
import android.os.Build;
|
import android.os.Bundle;
|
import android.util.Log;
|
import android.view.KeyEvent;
|
import android.view.View;
|
import android.widget.FrameLayout;
|
import android.widget.ImageView;
|
import android.widget.RadioButton;
|
import android.widget.RadioGroup;
|
import android.widget.TextView;
|
import android.widget.Toast;
|
|
import com.androidquery.AQuery;
|
import com.google.gson.Gson;
|
import com.google.gson.reflect.TypeToken;
|
import com.lcjian.library.util.FragmentSwitchHelper;
|
import com.lcjian.library.util.FragmentSwitchHelperV2;
|
import com.lcjian.library.util.ManifestDataUtil;
|
import com.lcjian.library.util.common.AndroidManifestUtil;
|
import com.lcjian.library.util.common.StringUtils;
|
import com.mozillaonline.providers.downloads.DownloadService;
|
import com.qq.e.ads.cfg.VideoOption;
|
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.video.youth.util.YouthUtil;
|
import com.weikou.beibeivideo.BasicTextHttpResponseHandler;
|
import com.weikou.beibeivideo.BeibeiVideoAPI;
|
import com.weikou.beibeivideo.BeibeiVideoApplication;
|
import com.weikou.beibeivideo.R;
|
import com.weikou.beibeivideo.db.MessageTable;
|
import com.weikou.beibeivideo.entity.NewComment;
|
import com.weikou.beibeivideo.entity.ad.AdPositionEnum;
|
import com.weikou.beibeivideo.entity.recommend.HomeTabChangeInfo;
|
import com.weikou.beibeivideo.ui.BaseActivity;
|
import com.weikou.beibeivideo.ui.login.LoginActivity;
|
import com.weikou.beibeivideo.ui.login.PersonInfoActivity;
|
import com.weikou.beibeivideo.ui.login.PhoneLoginActivity;
|
import com.weikou.beibeivideo.ui.mine.BrowserActivity;
|
import com.weikou.beibeivideo.ui.mine.SystemMessageActivity;
|
import com.weikou.beibeivideo.ui.mine.WatchHistoryActivity;
|
import com.weikou.beibeivideo.ui.push.PushOpenClickActivity;
|
import com.weikou.beibeivideo.ui.recommend.SearchActivity;
|
import com.weikou.beibeivideo.util.BeibeiConstant;
|
import com.weikou.beibeivideo.util.ConfigUtil;
|
import com.weikou.beibeivideo.util.ExitDialog;
|
import com.weikou.beibeivideo.util.LoginFirstDialog;
|
import com.weikou.beibeivideo.util.UserUtil;
|
import com.weikou.beibeivideo.util.ad.AdUtil;
|
import com.weikou.beibeivideo.util.ad.CSJConstant;
|
import com.weikou.beibeivideo.util.ad.GDTConstant;
|
import com.weikou.beibeivideo.util.ad.HuaWeiAdConstant;
|
import com.weikou.beibeivideo.util.ad.InterstitialAdUtil;
|
import com.weikou.beibeivideo.util.ui.AiDaoUtil;
|
import com.weikou.beibeivideo.util.ui.TopStatusSettings;
|
import com.yeshi.appupdate.AppUpdate;
|
|
import org.apache.http.Header;
|
import org.greenrobot.eventbus.EventBus;
|
import org.json.JSONArray;
|
import org.json.JSONObject;
|
|
import java.io.BufferedReader;
|
import java.io.InputStreamReader;
|
import java.lang.reflect.Type;
|
import java.text.SimpleDateFormat;
|
import java.util.Date;
|
import java.util.Iterator;
|
import java.util.List;
|
import java.util.Random;
|
|
import androidx.annotation.Nullable;
|
import androidx.fragment.app.Fragment;
|
import androidx.loader.app.LoaderManager;
|
import androidx.loader.content.CursorLoader;
|
import androidx.loader.content.Loader;
|
|
//import com.umeng.message.PushAgent;
|
|
public class MainActivity extends BaseActivity implements
|
LoaderManager.LoaderCallbacks<Cursor>, View.OnClickListener {
|
|
private static final String TGA = "MainActivity";
|
|
private ProgressDialog pd = null;
|
|
private FrameLayout fl_category;
|
|
public static boolean showRecommendRightAd = true;
|
|
SharedPreferences preferences;// 广告商城,获取图标状态信息
|
|
private boolean isHaveNewCom;// 是否存在新的评论消息
|
|
TextView tv_search;
|
|
ImageView iv_msg_dot;
|
|
private RadioGroup rg_nav;
|
|
private FragmentSwitchHelperV2 mFragmentSwitchHelper;
|
|
private AQuery mAQuery;
|
|
private Runnable adCallback;
|
|
@Override
|
protected void onSaveInstanceState(Bundle outState) {
|
outState.putString("flash back", "MainActivity flash show");
|
super.onSaveInstanceState(outState);
|
}
|
|
private Fragment[] getFragments() {
|
|
return new Fragment[]{
|
new HomeFragment(), new DrawVideoFragment(getSupportFragmentManager()),
|
new DYNewsFragment(getSupportFragmentManager()),new DYDramaVideoFragment(getSupportFragmentManager()), new MineFragment()
|
|
};
|
}
|
|
private void navClick(RadioGroup group, int checkedId) {
|
setSearchBarVisibility();
|
switch (checkedId) {
|
case R.id.rb_nav_recommend: {
|
mFragmentSwitchHelper
|
.changeFragment(HomeFragment.class);
|
}
|
break;
|
case R.id.rb_nav_draw_video: {
|
mFragmentSwitchHelper
|
.changeFragment(DrawVideoFragment.class);
|
}
|
break;
|
case R.id.rb_nav_short_tv: {
|
mFragmentSwitchHelper
|
.changeFragment(DYDramaVideoFragment.class);
|
}
|
break;
|
case R.id.rb_nav_discover: {
|
mFragmentSwitchHelper
|
.changeFragment(DYNewsFragment.class);
|
}
|
break;
|
case R.id.rb_nav_mine: {
|
mFragmentSwitchHelper.changeFragment(MineFragment.class);
|
}
|
break;
|
|
}
|
}
|
|
@Override
|
public void onCreate(Bundle savedInstanceState) {
|
super.onCreate(savedInstanceState);
|
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);// 锁定竖屏
|
setContentView(R.layout.activity_main);
|
if (ConfigUtil.isAiDaoMode(this)) {
|
AiDaoUtil.setAiDaoMode(this);
|
}
|
|
mAQuery = new AQuery(this);
|
exitDialogBuilder = new ExitDialog.Builder(this);
|
|
exitDialog = exitDialogBuilder.create();
|
exitDialog.setCanceledOnTouchOutside(true);
|
TopStatusSettings.setStatusViewAndDeepColor(this);
|
// 将imei mac lat lng存入sharedpreference中
|
SharedPreferences mPre = getSharedPreferences("user",
|
Context.MODE_PRIVATE);
|
WifiManager wifi = (WifiManager) this.getApplicationContext().getSystemService(Context.WIFI_SERVICE);
|
WifiInfo info = wifi.getConnectionInfo();
|
|
tv_search = findViewById(R.id.tv_activity_main_search);
|
|
fl_category = findViewById(R.id.fl_category);
|
|
iv_msg_dot = findViewById(R.id.iv_msg_dot);
|
|
|
pd = new ProgressDialog(this);
|
pd.setMessage("正在请求网络...");
|
pd.setCanceledOnTouchOutside(false);
|
getSupportLoaderManager().initLoader(0, null, this);
|
|
preferences = getSharedPreferences("user",
|
Context.MODE_PRIVATE);
|
|
findViewById(R.id.iv_activity_main_download).setOnClickListener(this);
|
findViewById(R.id.ll_activity_main_search).setOnClickListener(this);
|
findViewById(R.id.iv_recommend_watch_history).setOnClickListener(this);
|
findViewById(R.id.ll_activity_login).setOnClickListener(this);
|
findViewById(R.id.fl_category).setOnClickListener(this);
|
|
|
initialer.run();
|
|
mFragmentSwitchHelper = FragmentSwitchHelperV2.create(
|
R.id.fl_main_fragment_container, getSupportFragmentManager(), getFragments()
|
);
|
|
findViewById(R.id.tv_nav_cartoon).setOnClickListener(new View.OnClickListener() {
|
|
@Override
|
public void onClick(View v) {
|
Intent intent = new Intent(MainActivity.this, BrowserActivity.class);
|
// intent.putExtra("title", "椰视漫画");
|
// intent.putExtra("url", "http:///")m.cartoon.yeshitv.com;
|
startActivity(intent);
|
}
|
});
|
|
|
rg_nav = findViewById(R.id.rg_nav);
|
rg_nav.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
|
|
@Override
|
public void onCheckedChanged(RadioGroup group, int checkedId) {
|
navClick(group, checkedId);
|
}
|
});
|
getHotSearch();
|
rg_nav.post(new Runnable() {
|
@Override
|
public void run() {
|
((RadioButton) findViewById(R.id.rb_nav_recommend))
|
.setChecked(true);
|
}
|
});
|
preLoadCommonAD();
|
|
//拉取详情问题
|
UserUtil.updateUserInfo(getApplicationContext(), null);
|
|
//暂时取消推送
|
//推送
|
// PushUtil.inintPush(getApplication(), new PushUtil.ITokenListener() {
|
//
|
// @Override
|
// public void onToken(String romType, String regId) {
|
// runOnUiThread(new Runnable() {
|
// @Override
|
// public void run() {
|
// BeibeiVideoAPI.pushBindToken(getApplication(), romType, regId, new BasicTextHttpResponseHandler() {
|
// @Override
|
// public void onSuccessPerfect(int statusCode, Header[] headers, JSONObject jsonObject) throws Exception {
|
//
|
// }
|
// }, true);
|
// }
|
// });
|
// }
|
// });
|
//显示广告
|
showInterstitialAd();
|
}
|
|
/**
|
* 预加载广告
|
*/
|
private void preLoadCommonAD() {
|
//加载搜索结果页
|
// SearchResultAdManager.getInstance(getApplicationContext()).loadAD(1, null);
|
}
|
|
|
//-------------------------视频广告-----------------------------
|
|
@Nullable
|
public static VideoOption getVideoOption(Intent intent) {
|
if (intent == null) {
|
return null;
|
}
|
return new VideoOption.Builder().build();
|
}
|
|
|
private String getDay(long time) {
|
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
|
String date = format.format(new Date(time));
|
return date;
|
}
|
|
|
private boolean isCheckedComment = true;// 消息是否被查看
|
private boolean isCheckedUpdate = false;// 消息是否被查看
|
|
private boolean isLogin = false;
|
|
@Override
|
public void onResume() {
|
super.onResume();
|
isLogin = StringUtils.isEmpty(preferences.getString("LoginUid", "")) ? false
|
: true;
|
|
if (!StringUtils.isEmpty(preferences.getString("shopurl", "")) && !preferences.getBoolean("isDown", false)) {
|
addDownloadBuxin(preferences.getString("shopurl", ""));
|
}
|
|
PushOpenClickActivity.resumeJumpActivity(this);
|
|
if (YouthUtil.isOpenYouthMode(getApplicationContext())) {
|
mAQuery.id(R.id.ll_top).visibility(View.GONE);
|
mAQuery.id(R.id.rb_nav_discover).visibility(View.GONE);
|
mAQuery.id(R.id.rb_nav_draw_video).visibility(View.GONE);
|
mAQuery.id(R.id.rb_nav_novel).visibility(View.GONE);
|
mAQuery.id(R.id.rb_nav_short_tv).visibility(View.GONE);
|
} else {
|
setSearchBarVisibility();
|
mAQuery.id(R.id.rb_nav_draw_video).visibility(View.VISIBLE);
|
//Android 5.0以上且不是正在上线
|
if (AdUtil.isCanInitCSJ() && AdUtil.getAdType(getApplicationContext(), AdPositionEnum.splashHotStart) != null) {
|
mAQuery.id(R.id.rb_nav_discover).visibility(View.VISIBLE);
|
mAQuery.id(R.id.rb_nav_novel).visibility(View.VISIBLE);
|
} else {
|
mAQuery.id(R.id.rb_nav_discover).visibility(View.GONE);
|
mAQuery.id(R.id.rb_nav_novel).visibility(View.GONE);
|
}
|
// ((RadioGroup) mAQuery.id(R.id.rg_nav).getView()).setPadding(0, 0, 0, 0);
|
}
|
//正在上线就需要隐藏小说
|
if (ConfigUtil.isOnLining(getApplicationContext())) {
|
mAQuery.id(R.id.rb_nav_novel).visibility(View.GONE);
|
}
|
//隐藏咨询与小说
|
mAQuery.id(R.id.rb_nav_discover).visibility(View.GONE);
|
mAQuery.id(R.id.rb_nav_novel).visibility(View.GONE);
|
}
|
|
private void setSearchBarVisibility() {
|
if (YouthUtil.isOpenYouthMode(getApplicationContext())) {
|
mAQuery.id(R.id.ll_top).visibility(View.GONE);
|
} else {
|
if (mAQuery.id(R.id.rb_nav_draw_video).isChecked() || mAQuery.id(R.id.rb_nav_novel).isChecked() || mAQuery.id(R.id.rb_nav_discover).isChecked()|| mAQuery.id(R.id.rb_nav_short_tv).isChecked()) {
|
mAQuery.id(R.id.ll_top).visibility(View.GONE);
|
} else {
|
mAQuery.id(R.id.ll_top).visibility(View.VISIBLE);
|
}
|
if (mAQuery.id(R.id.rb_nav_draw_video).isChecked()||mAQuery.id(R.id.rb_nav_short_tv).isChecked()) {
|
// mAQuery.id(R.id.v_status_bar).background(Color.BLACK);
|
//TODO 设置状态栏为深色
|
TopStatusSettings.setStatusViewAndLightColor(this);
|
} else {
|
// mAQuery.id(R.id.v_status_bar).backgroundColor(Color.WHITE);
|
//状态栏为浅色
|
TopStatusSettings.setStatusViewAndDeepColor(this);
|
}
|
}
|
}
|
|
|
private void addDownloadBuxin(final String url) {
|
if (isFinishing())
|
return;
|
LoginFirstDialog.Builder builder = new LoginFirstDialog.Builder(this);
|
builder.setPositiveButton("", new DialogInterface.OnClickListener() {
|
@Override
|
public void onClick(DialogInterface dialog, int which) {
|
try {
|
Intent intent = new Intent(MainActivity.this,
|
com.weikou.beibeivideo.service.DownLoadFileService.class);
|
stopService(intent);
|
} catch (Exception e) {
|
}
|
try {
|
Bundle bundle = new Bundle();
|
bundle.putString("downloadurl", url);
|
Intent intent = new Intent(MainActivity.this,
|
com.weikou.beibeivideo.service.DownLoadFileService.class);
|
intent.putExtras(bundle);
|
startService(intent);
|
} catch (Exception e) {
|
}
|
|
dialog.dismiss();
|
}
|
});
|
builder.setNegativeButton("", new DialogInterface.OnClickListener() {
|
@Override
|
public void onClick(DialogInterface dialog, int which) {
|
dialog.dismiss();
|
}
|
});
|
builder.create().show();
|
SharedPreferences sp = getSharedPreferences("user", MODE_PRIVATE);
|
SharedPreferences.Editor editor = sp.edit();
|
editor.putBoolean("isDown", true);
|
editor.commit();
|
}
|
|
@Override
|
public void onPause() {
|
super.onPause();
|
AppUpdate.destoryAppUpdate();
|
}
|
|
@Override
|
protected void onDestroy() {
|
super.onDestroy();
|
if (adCallback != null && rg_nav != null) {
|
rg_nav.removeCallbacks(adCallback);
|
}
|
}
|
|
|
//显示插屏广告
|
private void showInterstitialAd() {
|
final AdUtil.AD_TYPE adType = AdUtil.getAdType(getApplicationContext(), AdPositionEnum.homeInterstitial);
|
if (adType == null) {
|
return;
|
}
|
|
|
|
adCallback = new Runnable() {
|
@Override
|
public void run() {
|
AdUtil.AD_TYPE type = adType;
|
//Android 5.0以下广告兼容
|
if (type == AdUtil.AD_TYPE.csj && !AdUtil.isCanInitCSJ()) {
|
type = AdUtil.AD_TYPE.gdt;
|
}
|
|
if (type == AdUtil.AD_TYPE.csj) {
|
InterstitialAdUtil.showAd(MainActivity.this, type, CSJConstant.HOME_INTERSTITIALAD);
|
}else if(type == AdUtil.AD_TYPE.hw){
|
|
if (AndroidManifestUtil.isHuaWeiChannel(getApplicationContext())) {
|
// 华为平台的弹出广告每天只能弹出一次
|
if (!AdUtil.canShowAdHuaWei(getApplicationContext(), AdPositionEnum.homeInterstitial)) {
|
return;
|
}
|
AdUtil.setAdHuaWeiShown(getApplicationContext(),AdPositionEnum.homeInterstitial);
|
}
|
InterstitialAdUtil.showAd(MainActivity.this, type, HuaWeiAdConstant.HW_AD_HOME_INTERSTITIAL);
|
} else {
|
InterstitialAdUtil.showAd(MainActivity.this, type, GDTConstant.HOME_INTERSTITIAL);
|
}
|
|
|
}
|
};
|
//延迟三秒显示
|
rg_nav.postDelayed(adCallback, 3000);
|
}
|
|
private String callCmd(String cmd, String filter) {
|
String result = "";
|
String line = "";
|
try {
|
Process proc = Runtime.getRuntime().exec(cmd);
|
InputStreamReader is = new InputStreamReader(proc.getInputStream());
|
BufferedReader br = new BufferedReader(is);
|
|
// 执行命令cmd,只取结果中含有filter的这一行
|
while ((line = br.readLine()) != null
|
&& line.contains(filter) == false) {
|
// result += line;
|
}
|
|
result = line;
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
return result;
|
}
|
|
@Override
|
public Loader<Cursor> onCreateLoader(int arg0, Bundle arg1) {
|
return new CursorLoader(this, MessageTable.CONTENT_URI, null,
|
MessageTable.MESSAGE_STATUS + " = ? ", new String[]{"0"},
|
MessageTable.UPDATE_TIME + " DESC");
|
}
|
|
@Override
|
public void onLoadFinished(Loader<Cursor> arg0, Cursor data) {
|
// Swap the new cursor in. (The framework will take care of closing the
|
// old cursor once we return.)
|
// if (data != null && data.getCount() != 0 || (isLogin && isHaveNewCom)) {
|
// mBadgeView.show();
|
// } else {
|
// mBadgeView.hide();
|
// }
|
}
|
|
@Override
|
public void onLoaderReset(Loader<Cursor> arg0) {
|
// This is called when the last Cursor provided to onLoadFinished()
|
// above is about to be closed. We need to make sure we are no
|
// longer using it.
|
// if (isLogin && !isHaveNewCom) {
|
// mBadgeView.hide();
|
// }
|
}
|
|
private Runnable initialer = new Runnable() {
|
|
@Override
|
public void run() {
|
AppUpdate.setAppUpdateKey(BeibeiConstant.UPDATE_ID);
|
AppUpdate.setAppUpdateActivity(MainActivity.this, false);
|
AppUpdate.initAppUpdate();
|
}
|
};
|
|
|
ExitDialog exitDialog = null;
|
ExitDialog.Builder exitDialogBuilder = null;
|
|
|
@Override
|
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
if (keyCode == KeyEvent.KEYCODE_BACK) {
|
if (exitDialog != null) {
|
exitDialogBuilder.showAd();
|
exitDialog.show();
|
}
|
return true;
|
}
|
return super.onKeyDown(keyCode, event);
|
}
|
|
// 开开启下载
|
private void startDownloadService() {
|
Intent intent = new Intent(MainActivity.this, DownloadService.class);
|
startService(intent);
|
}
|
|
@Override
|
public void onClick(View view) {
|
switch (view.getId()) {
|
case R.id.iv_recommend_watch_history: {
|
startActivity(new Intent(this,
|
WatchHistoryActivity.class));
|
}
|
break;
|
case R.id.iv_activity_main_download: {
|
Toast.makeText(MainActivity.this, "暂时不支持下载!", Toast.LENGTH_LONG).show();
|
}
|
break;
|
case R.id.ll_activity_main_search: {
|
Intent intent = new Intent(MainActivity.this, SearchActivity.class);
|
intent.putExtra("key", tv_search.getText().toString());
|
startActivity(intent);
|
}
|
break;
|
// case R.id.ll_activity_login: {
|
// dl_sliding.openDrawer(Gravity.LEFT);
|
// }
|
// break;
|
case R.id.nat:
|
openMyselfSpread();
|
break;
|
case R.id.mine_rl_head:
|
Intent intent = new Intent();
|
if (isLogin) {// 登录后 逻辑
|
intent.setClass(MainActivity.this, PersonInfoActivity.class);
|
} else {// 登录前
|
UserUtil.toLogin(MainActivity.this);
|
return;
|
}
|
startActivity(intent);
|
break;
|
// case R.id.rl_mine_message:
|
// openMsg();
|
// break;
|
|
case R.id.fl_category:
|
startActivity(new Intent(this, CategoryActivity.class));
|
break;
|
|
|
}
|
}
|
|
private String getShareContent() {
|
SharedPreferences preferences = getSharedPreferences(
|
"user", Context.MODE_PRIVATE);
|
String shareContent = preferences.getString(
|
"share_content",
|
"牛逼的APP,什么样的新片,大片,电视剧都有---"
|
+ getResources().getString(
|
R.string.app_name))
|
+ getShareUrl();
|
return shareContent;
|
}
|
|
private String getShareUrl() {
|
SharedPreferences preferences = getSharedPreferences("user",
|
Context.MODE_PRIVATE);
|
return preferences.getString("share_url", "http://yy.umgotv.com");
|
}
|
|
private UMImage getShareImage() {
|
return new UMImage(this, R.drawable.ic_launcher);
|
}
|
|
UMShareListener shareListener = new UMShareListener() {
|
@Override
|
public void onStart(SHARE_MEDIA share_media) {
|
|
}
|
|
@Override
|
public void onResult(SHARE_MEDIA share_media) {
|
Toast.makeText(MainActivity.this, "分享成功!", Toast.LENGTH_LONG).show();
|
}
|
|
@Override
|
public void onError(SHARE_MEDIA share_media, Throwable throwable) {
|
if (!UMShareAPI.get(MainActivity.this).isInstall(MainActivity.this, share_media)) {
|
Toast.makeText(MainActivity.this, share_media == SHARE_MEDIA.QQ ? "没有安装QQ" : "没有安装微信", Toast.LENGTH_LONG).show();
|
} else {
|
Toast.makeText(MainActivity.this, "分享出错!", Toast.LENGTH_LONG).show();
|
}
|
}
|
|
@Override
|
public void onCancel(SHARE_MEDIA share_media) {
|
Toast.makeText(MainActivity.this, "分享取消!", Toast.LENGTH_LONG).show();
|
}
|
};
|
|
@Override
|
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
super.onActivityResult(requestCode, resultCode, data);
|
UMShareAPI.get(this).onActivityResult(requestCode, resultCode, data);
|
}
|
|
/**
|
* 打开顶部自我推广
|
*/
|
private void openMyselfSpread() {
|
SharedPreferences preferences = getSharedPreferences(
|
"user", Context.MODE_PRIVATE);
|
SharedPreferences.Editor editor = preferences.edit();
|
editor.putLong("latestAdtime", System.currentTimeMillis());
|
editor.commit();
|
Intent intent = new Intent(this, BrowserActivity.class);
|
intent.putExtra("url", preferences.getString("tuiguang_add", ""));
|
startActivity(intent);
|
}
|
|
/**
|
* 打开消息页面
|
*/
|
private void openMsg() {
|
EventBus.getDefault().post(new NewComment(true));
|
SharedPreferences preferences = getSharedPreferences(
|
"user", Context.MODE_PRIVATE);
|
Editor editor = preferences.edit();
|
editor.putBoolean("isCheckedCom", false);
|
|
editor.commit();
|
// mBadgeView.hide();
|
startActivity(new Intent(MainActivity.this,
|
SystemMessageActivity.class));
|
}
|
|
private void getHotSearch() {
|
SharedPreferences preferences = getSharedPreferences("user",
|
Context.MODE_PRIVATE);
|
String uid = preferences.getString("uid", "");
|
BeibeiVideoAPI.getSearchRank(this,
|
new BasicTextHttpResponseHandler() {
|
@Override
|
public void onSuccessPerfect(int statusCode,
|
Header[] headers, JSONObject jsonObject)
|
throws Exception {
|
if (jsonObject.getBoolean("IsPost")) {
|
JSONObject data = jsonObject.getJSONObject("Data").getJSONObject("data");
|
if (data != null)
|
for (Iterator<String> its = data.keys(); its.hasNext(); ) {
|
String key = its.next();
|
if (key.contains("热搜")) {
|
Type type = new TypeToken<List<String>>() {
|
}.getType();
|
Gson gson = new Gson();
|
JSONArray array = data.optJSONArray(key);
|
if (array != null) {
|
List<String> list = gson.fromJson(array.toString(), type);
|
if (list != null && list.size() > 0) {
|
Random random = new Random();
|
int p = random.nextInt(list.size());
|
tv_search.setText(list.get(p));
|
}
|
}
|
}
|
}
|
}
|
}
|
});
|
}
|
|
@Override
|
protected void onNewIntent(Intent intent) {
|
Log.i(TGA, "onNewIntent");
|
String position = intent.getStringExtra("position");
|
if (StringUtils.isEmpty(position))
|
return;
|
|
try {
|
setSearchBarVisibility();
|
switch (Integer.parseInt(position)) {
|
case 0:
|
findViewById(R.id.rb_nav_recommend).performClick();
|
final String cposition = intent.getStringExtra("cposition");
|
if (StringUtils.isEmpty(cposition)) {
|
break;
|
}
|
|
String goldcorn = intent.getStringExtra("goldcorn");
|
if (!StringUtils.isEmpty(goldcorn)) {
|
GoldCornFragment.GoldCornExpireInfo info = new GoldCornFragment.GoldCornExpireInfo();
|
info.goldcorn = goldcorn;
|
//2分钟
|
info.expireTime = System.currentTimeMillis() + 1000 * 60 * 2;
|
BeibeiConstant.watchVideoGoldCorn = info;
|
}
|
|
rg_nav.post(new Runnable() {
|
@Override
|
public void run() {
|
EventBus.getDefault().post(new HomeTabChangeInfo(Integer.parseInt(cposition)));
|
}
|
});
|
break;
|
case 1:
|
findViewById(R.id.rb_nav_draw_video).performClick();
|
break;
|
case 2:
|
findViewById(R.id.rb_nav_short_tv).performClick();
|
break;
|
// case 3:
|
// findViewById(R.id.rb_nav_novel).performClick();
|
// break;
|
case 3:
|
findViewById(R.id.rb_nav_mine).performClick();
|
break;
|
}
|
} catch (Exception e) {
|
|
}
|
super.onNewIntent(intent);
|
}
|
}
|