| | |
| | | import android.content.SharedPreferences; |
| | | import android.content.pm.ActivityInfo; |
| | | import android.content.pm.PackageManager; |
| | | import android.graphics.Bitmap; |
| | | import android.graphics.drawable.Drawable; |
| | | import android.net.Uri; |
| | | import android.os.AsyncTask; |
| | | import android.os.Build; |
| | |
| | | import android.support.v4.content.ContextCompat; |
| | | import android.telephony.TelephonyManager; |
| | | import android.view.KeyEvent; |
| | | import android.view.View; |
| | | import android.view.ViewGroup; |
| | | import android.widget.ImageView; |
| | | import android.widget.LinearLayout; |
| | | import android.widget.TextView; |
| | | |
| | | import com.bumptech.glide.Glide; |
| | | import com.google.gson.Gson; |
| | | import com.lcjian.library.util.ScreenUtils; |
| | | import com.lcjian.library.util.common.BitmapUtils; |
| | | import com.lcjian.library.util.common.DrawableUtils; |
| | | import com.lcjian.library.util.common.StringUtils; |
| | | import com.tencent.smtt.sdk.WebView; |
| | | import com.umeng.analytics.MobclickAgent; |
| | | import com.lcjian.library.util.glide.GlideRoundTransform; |
| | | import com.weikou.beibeivideo.BasicTextHttpResponseHandler; |
| | | import com.weikou.beibeivideo.BeibeiVideoAPI; |
| | | import com.weikou.beibeivideo.BeibeiVideoApplication; |
| | | import com.weikou.beibeivideo.R; |
| | | import com.weikou.beibeivideo.entity.ad.AdPidInfo; |
| | | import com.weikou.beibeivideo.entity.ad.AdPositionEnum; |
| | | import com.weikou.beibeivideo.entity.ad.AdTypeVO; |
| | | import com.weikou.beibeivideo.entity.ad.SplashAdLoadInfo; |
| | | import com.weikou.beibeivideo.ui.ad.SplashADFragment; |
| | | import com.weikou.beibeivideo.ui.dialog.UserProtocolDialog; |
| | | import com.weikou.beibeivideo.ui.main.MainActivity; |
| | | import com.weikou.beibeivideo.util.BeibeiConstant; |
| | | import com.weikou.beibeivideo.util.GlideRoundTransform; |
| | | import com.weikou.beibeivideo.util.ConfigUtil; |
| | | import com.weikou.beibeivideo.util.PermissionsChecker; |
| | | import com.weikou.beibeivideo.util.SDCardUtil; |
| | | 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.SplashAdUtil; |
| | | import com.weikou.beibeivideo.util.ui.TopStatusSettings; |
| | | |
| | | import org.apache.http.Header; |
| | | import org.json.JSONObject; |
| | |
| | | |
| | | private ViewGroup vg_ad; |
| | | private ViewGroup vg_input; |
| | | private ImageView iv_bg; |
| | | |
| | | private TextView ad_close_time; |
| | | |
| | | private ImageView iv_logo; |
| | | |
| | | private static String TAG = "SplashActivity"; |
| | | |
| | |
| | | @Override |
| | | protected void onCreate(Bundle savedInstanceState) { |
| | | super.onCreate(savedInstanceState); |
| | | if (!this.isTaskRoot()) {// 判断本activity是不是任务空间的源activity,false就是不是系统重新实例化出来的 |
| | | finish(); |
| | | return; |
| | | } |
| | | // if (!this.isTaskRoot()) {// 判断本activity是不是任务空间的源activity,false就是不是系统重新实例化出来的 |
| | | // finish(); |
| | | // return; |
| | | // } |
| | | setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); |
| | | setContentView(R.layout.activity_splash); |
| | | |
| | | /* |
| | | * 计算状态栏高度并设置 |
| | | */ |
| | | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { |
| | | int result = 0; |
| | | int resourceId = getResources().getIdentifier("status_bar_height", |
| | | "dimen", "android"); |
| | | if (resourceId > 0) { |
| | | result = getResources().getDimensionPixelSize(resourceId); |
| | | } |
| | | LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, |
| | | result); |
| | | findViewById(R.id.v_status_bar).setLayoutParams(params); |
| | | } else { |
| | | findViewById(R.id.v_status_bar).setVisibility(View.GONE); |
| | | } |
| | | TopStatusSettings.setStatusViewAndDeepColor(this); |
| | | |
| | | vg_ad = findViewById(R.id.fl_splash_ad); |
| | | vg_input = findViewById(R.id.fl_input); |
| | | ad_close_time = findViewById(R.id.ad_close_time); |
| | | iv_logo = findViewById(R.id.iv_logo); |
| | | |
| | | Glide.with(getApplicationContext()).load(R.drawable.ic_launcher).transform(new GlideRoundTransform(getApplicationContext(), 5)).into(iv_logo); |
| | | iv_bg = findViewById(R.id.iv_bg); |
| | | |
| | | SharedPreferences preferences = getSharedPreferences("link_page", |
| | | Context.MODE_PRIVATE); |
| | |
| | | SDCardUtil.initStorage(this); |
| | | //初始化一次Banner,否则后面Banner使用时会出现卡顿 |
| | | // new BannerView(SplashActivity.this, ADSize.BANNER, BeibeiConstant.GDT_ID, BeibeiConstant.GDT_PLAYER_DETAIL); |
| | | //弹用户协议框 |
| | | |
| | | vg_ad.post(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | myRequetPermission(); |
| | | } |
| | | }); |
| | | showProtocol(); |
| | | |
| | | |
| | | //设置背景图片 |
| | | Drawable drawable = getResources().getDrawable(R.drawable.ic_splash_bg); |
| | | Bitmap bitmap = DrawableUtils.drawableToBitmap(drawable); |
| | | int width = ScreenUtils.getScreenWidth(this); |
| | | float scaleRate = width * 1.0f / bitmap.getWidth(); |
| | | Bitmap bitmap1 = BitmapUtils.scaleImage(bitmap, scaleRate, scaleRate); |
| | | iv_bg.setImageBitmap(bitmap1); |
| | | } |
| | | |
| | | |
| | | private void showProtocol() { |
| | | String data = "感谢您对" + getResources().getString(R.string.app_name) + "一直以来的信任!<br>"; |
| | | data += "我们依照新的监管要求条例更新了"; |
| | | data += String.format("<a href='%s'>《隐私政策》</a>和", BeibeiConstant.PRIVACY_POLICY); |
| | | data += String.format("<a href='%s'>《用户协议》</a>", BeibeiConstant.USER_AGREEMENT); |
| | | data += "为采取相应安全保护措施,尽力保护您的个人信息安全可控,特向你说明如下:<br>" + |
| | | "1、您在使用" + getResources().getString(R.string.app_name) + "各项产品或服务时,将会提供与具体功能相关的个人信息(可能涉及帐号、位置、存储等信息)。<br>" + |
| | | "2、您可以随时查询、更正、删除您的个人信息,我们也提供账户注销的渠道。<br>" + |
| | | "3、未经您的再次同意,我们不会将上述信息用于您未授权的其他用途或目的。<br>" + |
| | | "4、未经监护人同意,我们不会收集使用14周岁以下(含14周岁)未成年人个人信息,且不会利用其信息推送新闻、时政信息、广告等定向推送活动。"; |
| | | |
| | | if (!UserUtil.isAgreeUserProtocol(BeibeiVideoApplication.application) && !BeibeiConstant.IS_TEST) { |
| | | Dialog dialog = new UserProtocolDialog.Builder(this).setNegativeButton("不同意", new DialogInterface.OnClickListener() { |
| | | @Override |
| | | public void onClick(DialogInterface dialog, int which) { |
| | | SplashActivity.this.finish(); |
| | | } |
| | | }).setPositiveButton("同意并继续", new DialogInterface.OnClickListener() { |
| | | @Override |
| | | public void onClick(DialogInterface dialog, int which) { |
| | | dialog.dismiss(); |
| | | UserUtil.agreeUserProtocol(BeibeiVideoApplication.application); |
| | | //请求权限 |
| | | vg_ad.post(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | myRequetPermission(); |
| | | } |
| | | }); |
| | | } |
| | | }).setData(data).create(); |
| | | |
| | | if (!isFinishing()) { |
| | | dialog.show(); |
| | | } |
| | | |
| | | } else { |
| | | //请求权限 |
| | | vg_ad.post(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | myRequetPermission(); |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onResume() { |
| | | super.onResume(); |
| | | MobclickAgent.onPageStart("欢迎页"); |
| | | } |
| | | |
| | | private void getUid() { |
| | |
| | | BeibeiConstant.GDT_RECOMMAND_NATIVE = BeibeiConstant.GDT_DOWNLOAD_HINT_ID; |
| | | BeibeiConstant.GDT_RECOMMEND_CATEGORY_MIN_NATIVE = BeibeiConstant.GDT_DOWNLOAD_HINT_ID; |
| | | BeibeiConstant.GDT_PLAYER_NATIVE1 = BeibeiConstant.GDT_DOWNLOAD_HINT_ID; |
| | | BeibeiConstant.GDT_SEARCH_NATIVE = BeibeiConstant.GDT_DOWNLOAD_HINT_ID; |
| | | BeibeiConstant.GDT_DISCOVER_NATIVE = BeibeiConstant.GDT_DOWNLOAD_HINT_ID; |
| | | BeibeiConstant.GDT_GUESS_LIKE_NATIVE = BeibeiConstant.GDT_DOWNLOAD_HINT_ID; |
| | | BeibeiConstant.GDT_RECOMMEND_CATEGORY_NATIVE = BeibeiConstant.GDT_DOWNLOAD_HINT_ID; |
| | |
| | | GDTConstant.PID_2_VIDEO_LIST_SMALL_AD_COLUMN3 = BeibeiConstant.GDT_DOWNLOAD_HINT_ID; |
| | | GDTConstant.PID_2_VIDEO_LIST_SMALL_AD_COLUMN2 = BeibeiConstant.GDT_DOWNLOAD_HINT_ID; |
| | | GDTConstant.PID_HOME_RECOMMEND_BIG_IMG = BeibeiConstant.GDT_DOWNLOAD_HINT_ID; |
| | | GDTConstant.PID_2_VIDEO_DETAIL_PLAYER_PRE_PPTV = BeibeiConstant.GDT_DOWNLOAD_HINT_ID; |
| | | |
| | | CSJConstant.RECOMMEND_BIG_IMG_AD = CSJConstant.INVALID_AD; |
| | | } |
| | |
| | | @Override |
| | | public void onPause() { |
| | | super.onPause(); |
| | | MobclickAgent.onPageEnd("欢迎页"); |
| | | } |
| | | |
| | | private String getDay(long time) { |
| | |
| | | * |
| | | * @param adType |
| | | */ |
| | | private void loadSplashAd(final AdUtil.AD_TYPE adType) { |
| | | SplashAdUtil.loadAD(adType, SplashActivity.this, vg_input, vg_ad, ad_close_time, new SplashAdUtil.SplashAdListener() { |
| | | |
| | | private SplashADFragment splashADFragment; |
| | | |
| | | private void loadSplashAd(AdUtil.AD_TYPE adType, String pid) { |
| | | AdPidInfo adPidInfo2 = null; |
| | | if (adType == AdUtil.AD_TYPE.gdt) { |
| | | adPidInfo2 = new AdPidInfo(AdUtil.AD_TYPE.csj, CSJConstant.SPLASH_AD); |
| | | } else { |
| | | adPidInfo2 = new AdPidInfo(AdUtil.AD_TYPE.gdt, BeibeiConstant.GDT_SPLASH_POSITION_ID); |
| | | } |
| | | |
| | | splashADFragment = SplashADFragment.newInstance(new AdPidInfo(adType, pid), adPidInfo2); |
| | | splashADFragment.setAdShowListener(new SplashADFragment.AdShowListener() { |
| | | @Override |
| | | public void close() { |
| | | runOnUiThread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | toMainActivity(); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | @Override |
| | | public void noAd() {//初次加载未加载出广告 |
| | | if (AdUtil.AD_TYPE.csj == adType) { |
| | | //再次加载广点通广告 |
| | | SplashAdUtil.loadAD(AdUtil.AD_TYPE.gdt, SplashActivity.this, vg_input, vg_ad, ad_close_time, new SplashAdUtil.SplashAdListener() { |
| | | @Override |
| | | public void close() { |
| | | runOnUiThread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | toMainActivity(); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | @Override |
| | | public void noAd() { |
| | | runOnUiThread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | toMainActivity(); |
| | | } |
| | | }); |
| | | } |
| | | }); |
| | | |
| | | } else if (AdUtil.AD_TYPE.gdt == adType) { |
| | | //再次加载穿山甲广告 |
| | | //再次加载广点通广告 |
| | | SplashAdUtil.loadAD(AdUtil.AD_TYPE.csj, SplashActivity.this, vg_input, vg_ad, ad_close_time, new SplashAdUtil.SplashAdListener() { |
| | | @Override |
| | | public void close() { |
| | | runOnUiThread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | toMainActivity(); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | @Override |
| | | public void noAd() { |
| | | runOnUiThread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | toMainActivity(); |
| | | } |
| | | }); |
| | | } |
| | | }); |
| | | |
| | | } else { |
| | | runOnUiThread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | toMainActivity(); |
| | | } |
| | | }); |
| | | } |
| | | public void onClose() { |
| | | toMainActivity(); |
| | | } |
| | | }); |
| | | //直接加载广告 |
| | | getSupportFragmentManager().beginTransaction().replace(R.id.fl_splash_ad, splashADFragment).commitAllowingStateLoss(); |
| | | } |
| | | |
| | | private void myRequetPermission() { |
| | |
| | | //百度内容联盟 |
| | | // MobadsPermissionSettings.setPermissionReadDeviceID(true); |
| | | getUid(); |
| | | new WebView(this); |
| | | vg_ad.postDelayed(new Runnable() { |
| | | |
| | | @Override |
| | |
| | | if (jsonObject != null) { |
| | | if (jsonObject.getBoolean("IsPost")) { |
| | | JSONObject data = jsonObject.getJSONObject("Data"); |
| | | JSONObject ad = data.optJSONObject("ad"); |
| | | JSONObject ad = data.optJSONObject("adNew"); |
| | | String vipLink = data.optString("vipLink"); |
| | | int pptvNoAdRewardHour = data.optInt("pptvNoAdRewardHour", 3); |
| | | |
| | | //网页加速域名 |
| | | String webSpeedUpHost = data.optString("webSpeedUpHost"); |
| | | ConfigUtil.saveWebSpeedUpHost(getApplicationContext(), webSpeedUpHost); |
| | | //设置我的页面banner |
| | | ConfigUtil.saveMinePageBanner(getApplicationContext(), data.optString("minePageBanner")); |
| | | |
| | | ConfigUtil.savePlayerJumpOutProtocolPrefix(getApplicationContext(), data.optString("jumpAppProtocolPrefix")); |
| | | |
| | | //保存免广告权益持续时间 |
| | | AdUtil.setPPTVNoAdRewardHour(getApplicationContext(), pptvNoAdRewardHour); |
| | | |
| | | AdUtil.saveAdConfig(getApplicationContext(), ad); |
| | | AdUtil.AD_TYPE splash = AdUtil.getAdType(getApplicationContext(), AdUtil.POSITION_SPLASH); |
| | | loadSplashAd(splash); |
| | | AdUtil.AD_TYPE splash = AdUtil.getAdType(getApplicationContext(), AdPositionEnum.splash); |
| | | String pid = AdUtil.getAdPid(getApplicationContext(), AdPositionEnum.splash); |
| | | if (StringUtils.isBlank(pid)) { |
| | | if (splash != null) { |
| | | if (splash == AdUtil.AD_TYPE.csj) { |
| | | pid = CSJConstant.SPLASH_AD; |
| | | } else if (splash == AdUtil.AD_TYPE.gdt) { |
| | | pid = BeibeiConstant.GDT_SPLASH_POSITION_ID; |
| | | } |
| | | } |
| | | } |
| | | ConfigUtil.saveVipLink(getApplicationContext(), vipLink); |
| | | loadSplashAd(splash, pid); |
| | | } |
| | | } else { |
| | | loadSplashAd(AdUtil.AD_TYPE.gdt); |
| | | loadSplashAd(AdUtil.AD_TYPE.csj, CSJConstant.SPLASH_AD); |
| | | } |
| | | } |
| | | |
| | |
| | | @Override |
| | | public void onFailure(int statusCode, Header[] headers, String responseString, Throwable throwable) { |
| | | super.onFailure(statusCode, headers, responseString, throwable); |
| | | loadSplashAd(AdUtil.AD_TYPE.gdt); |
| | | loadSplashAd(AdUtil.AD_TYPE.csj, CSJConstant.SPLASH_AD); |
| | | } |
| | | }); |
| | | |