| | |
| | | package com.weikou.beibeivideo.ui; |
| | | |
| | | import android.Manifest; |
| | | import android.app.AlertDialog; |
| | | import android.app.Dialog; |
| | | import android.content.Context; |
| | | import android.content.DialogInterface; |
| | | import android.content.Intent; |
| | | 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.os.Bundle; |
| | | import android.provider.Settings; |
| | | import android.support.v4.app.ActivityCompat; |
| | | 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.TextView; |
| | | |
| | | import com.lcjian.library.DeviceUuidFactory; |
| | | 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.qq.e.ads.splash.SplashAD; |
| | | import com.qq.e.ads.splash.SplashADListener; |
| | | import com.qq.e.comm.util.AdError; |
| | | 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.PermissionHintDialog; |
| | | import com.weikou.beibeivideo.util.PermissionsActivity; |
| | | import com.weikou.beibeivideo.util.ConfigUtil; |
| | | import com.weikou.beibeivideo.util.PermissionsChecker; |
| | | import com.weikou.beibeivideo.util.SDCardUtil; |
| | | import com.yeshi.buwanshequ.R; |
| | | 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; |
| | |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Date; |
| | | |
| | | import static android.content.pm.PackageManager.PERMISSION_GRANTED; |
| | | |
| | | public class SplashActivity extends BaseActivity { |
| | | |
| | | boolean isInput = false; |
| | | |
| | | private ViewGroup vg_ad; |
| | | private ViewGroup vg_input; |
| | | private ImageView iv_bg; |
| | | |
| | | private TextView ad_close_time; |
| | | |
| | | private static String TAG = "SplashActivity"; |
| | | |
| | | // 所需的全部权限 |
| | | static final String[] PERMISSIONS = new String[]{ |
| | | Manifest.permission.READ_PHONE_STATE, Manifest.permission.READ_EXTERNAL_STORAGE, |
| | | Manifest.permission.WRITE_EXTERNAL_STORAGE |
| | | Manifest.permission.READ_PHONE_STATE |
| | | }; |
| | | private static final int REQUEST_CODE = 0; // 请求码 |
| | | private PermissionsChecker mPermissionsChecker; // 权限检测器 |
| | |
| | | @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); |
| | | vg_ad = (ViewGroup) findViewById(R.id.fl_splash_ad); |
| | | vg_input = (ViewGroup) findViewById(R.id.fl_input); |
| | | ad_close_time = (TextView) findViewById(R.id.ad_close_time); |
| | | 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_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); |
| | | //弹用户协议框 |
| | | |
| | | 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("欢迎页"); |
| | | if (mPermissionsChecker.lacksPermissions(PERMISSIONS)) { |
| | | PermissionHintDialog.Builder builder = new PermissionHintDialog.Builder(this); |
| | | builder.setMessage("为保障正常使用相关功能,请允许影视大全获取相关基础权限").setPositiveButton("我知道啦", new DialogInterface.OnClickListener() { |
| | | @Override |
| | | public void onClick(DialogInterface dialogInterface, int i) { |
| | | startPermissionsActivity(); |
| | | dialogInterface.dismiss(); |
| | | } |
| | | }).create().show(); |
| | | } else { |
| | | getUid(); |
| | | new WebView(this); |
| | | vg_ad.postDelayed(new Runnable() { |
| | | |
| | | @Override |
| | | public void run() { |
| | | if (!BeibeiConstant.AD_SETTING_KAIPIN) |
| | | toMainActivity(); |
| | | |
| | | new SplashAD(SplashActivity.this, vg_input, BeibeiConstant.GDT_ID, BeibeiConstant.GDT_SPLASH_POSITION_ID_HUAWEI, new SplashADListener() { |
| | | @Override |
| | | public void onADDismissed() { |
| | | runOnUiThread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | toMainActivity(); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | @Override |
| | | public void onNoAD(AdError adError) { |
| | | runOnUiThread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | toMainActivity(); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | @Override |
| | | public void onADPresent() { |
| | | runOnUiThread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | vg_input.setVisibility(View.VISIBLE); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | @Override |
| | | public void onADClicked() { |
| | | System.out.println(""); |
| | | } |
| | | |
| | | @Override |
| | | public void onADTick(final long l) { |
| | | runOnUiThread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | ad_close_time.setText(l / 1000 + ""); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | @Override |
| | | public void onADExposure() { |
| | | System.out.println(""); |
| | | } |
| | | |
| | | @Override |
| | | public void onADLoaded(long l) { |
| | | System.out.println(""); |
| | | } |
| | | }, 0).fetchAndShowIn(vg_ad); |
| | | |
| | | } |
| | | }, 1000); |
| | | } |
| | | } |
| | | |
| | | private void startPermissionsActivity() { |
| | | PermissionsActivity.startActivityForResult(this, REQUEST_CODE, PERMISSIONS); |
| | | } |
| | | |
| | | |
| | | |
| | | private void getUid() { |
| | | final SharedPreferences preferences = getSharedPreferences("user", |
| | |
| | | } |
| | | |
| | | |
| | | BeibeiVideoAPI.getUid(this, channel,BeibeiVideoAPI.getDeviceId(this), preferences.getString("imei", ""), |
| | | BeibeiVideoAPI.getUid(this, channel, BeibeiVideoAPI.getDeviceId(this), preferences.getString("imei", ""), |
| | | preferences.getString("mac", ""), "", "", |
| | | new BasicTextHttpResponseHandler() { |
| | | |
| | |
| | | Header[] headers, JSONObject jsonObject) |
| | | throws Exception { |
| | | if (jsonObject.getBoolean("IsPost")) { |
| | | // String copyplate = jsonObject.getJSONObject("Data") |
| | | // .optString("copyplate"); |
| | | // |
| | | // if (!StringUtils.isEmpty(copyplate)) { |
| | | // ClipboardManager clipboardManager = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE); |
| | | // clipboardManager.setPrimaryClip(ClipData.newPlainText("copyplate", copyplate)); |
| | | // Toast.makeText(MainActivity.this, clipboardManager.getPrimaryClip().getItemAt(0).getText(), Toast.LENGTH_SHORT).show(); |
| | | // } |
| | | |
| | | String pptvso1 = jsonObject.getJSONObject("Data").optJSONArray("PPTVSO").optString(0); |
| | | String pptvso2 = jsonObject.getJSONObject("Data").optJSONArray("PPTVSO").optString(1); |
| | | JSONObject data = jsonObject.getJSONObject("Data"); |
| | | String pptvso1 = data.optJSONArray("PPTVSO").optString(0); |
| | | String pptvso2 = data.optJSONArray("PPTVSO").optString(1); |
| | | preferences.edit() |
| | | .putString( |
| | | "uid", |
| | | jsonObject.getJSONObject("Data") |
| | | "uid", data |
| | | |
| | | .optString("Uid")) |
| | | .putString("pptvso1", pptvso1) |
| | | .putString("pptvso2", pptvso2) |
| | | .putString("COMMENT_ALERT", jsonObject.getJSONObject("Data") |
| | | .putString("COMMENT_ALERT", data |
| | | .optString("COMMENT_ALERT")) |
| | | .putInt("ShowAd", Integer.parseInt(jsonObject.getJSONObject("Data") |
| | | .putInt("ShowAd", Integer.parseInt(data |
| | | .optString("ShowAd"))) |
| | | .putString( |
| | | "share_url", |
| | | jsonObject.getJSONObject("Data") |
| | | data |
| | | .optString("ShareUrl")) |
| | | .putString( |
| | | "shopurl", |
| | | jsonObject.getJSONObject("Data") |
| | | data |
| | | .optString("shopurl")) |
| | | .putString( |
| | | "share_content", |
| | | jsonObject.getJSONObject("Data") |
| | | data |
| | | .optString("ShareContent")) |
| | | .putString( |
| | | "share_url_wechat", |
| | | jsonObject.getJSONObject("Data") |
| | | data |
| | | .optString("WXShareUrl")) |
| | | .putString( |
| | | "share_content_wechat", |
| | | jsonObject |
| | | .getJSONObject("Data") |
| | | data |
| | | .optString("WXShareContent")) |
| | | .putString( |
| | | "show_more_app", |
| | | jsonObject.getJSONObject("Data") |
| | | data |
| | | .optString("ShowMoreApp")) |
| | | .putString( |
| | | "evalueate", |
| | | jsonObject.getJSONObject("Data") |
| | | data |
| | | .optString("evalueate")) |
| | | .putString( |
| | | "share_image_wechat", |
| | | jsonObject.getJSONObject("Data") |
| | | data |
| | | .optString("WXShareIcon")) |
| | | // .putString( |
| | | // "show_ad", |
| | |
| | | // .optString("ShowAd")) |
| | | .putString( |
| | | "tuiguang_add", |
| | | jsonObject.optJSONObject("Data") |
| | | data |
| | | .optString("TuiGuang")) |
| | | .putString( |
| | | "top_icon", |
| | | jsonObject.optJSONObject("Data") |
| | | data |
| | | .optString("TopIcon")) |
| | | .putString( |
| | | "zixun", |
| | | jsonObject.optJSONObject("Data") |
| | | data |
| | | .optString("ZiXun")) |
| | | .commit(); |
| | | |
| | | BeibeiVideoAPI.ERROR_NOTICE = jsonObject |
| | | .getJSONObject("Data").optString( |
| | | "NoticeContent"); |
| | | BeibeiVideoAPI.ERROR_NOTICE = data.optString( |
| | | "NoticeContent"); |
| | | |
| | | BeibeiConstant.AD_CLICK_DOWNLOAD = jsonObject.optJSONObject("Data") |
| | | BeibeiConstant.AD_CLICK_DOWNLOAD = data |
| | | .optBoolean("adClickDownload"); |
| | | if (BeibeiConstant.AD_CLICK_DOWNLOAD) { |
| | | BeibeiConstant.GDT_RECOMMAND_MIN_NATIVE = BeibeiConstant.GDT_DOWNLOAD_HINT_ID; |
| | | 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; |
| | | BeibeiConstant.GDT_EXIT_DIALOG = BeibeiConstant.GDT_DOWNLOAD_HINT_ID; |
| | | BeibeiConstant.GDT_SEARCH_RESULT_MIN_NATIVE = BeibeiConstant.GDT_DOWNLOAD_HINT_ID; |
| | | BeibeiConstant.GDT_PLAYER_DETAIL = BeibeiConstant.GDT_DOWNLOAD_HINT_ID; |
| | | BeibeiConstant.GDT_CATEGORY_BANNER = BeibeiConstant.GDT_DOWNLOAD_HINT_ID; |
| | | GDTConstant.PID_HOME_RECOMMEND_BIG_IMG = BeibeiConstant.GDT_DOWNLOAD_HINT_ID; |
| | | GDTConstant.PID_2_VIDEO_DETAIL_PLAY_EXPRESS1 = BeibeiConstant.GDT_DOWNLOAD_HINT_ID; |
| | | GDTConstant.PID_2_VIDEO_DETAIL_PLAY_EXPRESS2 = 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; |
| | | } |
| | | |
| | | new AddAliasTask(jsonObject.getJSONObject("Data") |
| | | //获取广告 |
| | | String adType = data.optString("adType"); |
| | | if (!com.weikou.beibeivideo.util.downutil.StringUtils.isNullOrEmpty(adType)) { |
| | | AdTypeVO ad = new Gson().fromJson(adType, AdTypeVO.class); |
| | | if (ad != null) |
| | | BeibeiConstant.AD_TYPE = ad; |
| | | } |
| | | |
| | | |
| | | new AddAliasTask(data |
| | | .getString("Uid"), "WEIKOU"); |
| | | SharedPreferences preferences1 = getSharedPreferences("user", |
| | | Context.MODE_PRIVATE); |
| | |
| | | @Override |
| | | public void onPause() { |
| | | super.onPause(); |
| | | MobclickAgent.onPageEnd("欢迎页"); |
| | | } |
| | | |
| | | private String getDay(long time) { |
| | |
| | | finish(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 加载开屏广告 |
| | | * |
| | | * @param adType |
| | | */ |
| | | |
| | | 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 onClose() { |
| | | toMainActivity(); |
| | | } |
| | | }); |
| | | //直接加载广告 |
| | | getSupportFragmentManager().beginTransaction().replace(R.id.fl_splash_ad, splashADFragment).commitAllowingStateLoss(); |
| | | } |
| | | |
| | | private void myRequetPermission() { |
| | | if (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_PHONE_STATE) != PERMISSION_GRANTED) { |
| | | ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.READ_PHONE_STATE}, REQUEST_CODE); |
| | | } else { |
| | | //百度内容联盟 |
| | | // MobadsPermissionSettings.setPermissionReadDeviceID(true); |
| | | getUid(); |
| | | vg_ad.postDelayed(new Runnable() { |
| | | |
| | | @Override |
| | | public void run() { |
| | | if (!BeibeiConstant.AD_SETTING_KAIPIN) |
| | | toMainActivity(); |
| | | BeibeiVideoAPI.getConfig(getApplicationContext(), new BasicTextHttpResponseHandler() { |
| | | |
| | | @Override |
| | | public void onSuccessPerfect(int statusCode, Header[] headers, JSONObject jsonObject) throws Exception { |
| | | if (jsonObject != null) { |
| | | if (jsonObject.getBoolean("IsPost")) { |
| | | JSONObject data = jsonObject.getJSONObject("Data"); |
| | | 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(), 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.csj, CSJConstant.SPLASH_AD); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onSuccess(int statusCode, Header[] headers, String responseString) { |
| | | super.onSuccess(statusCode, headers, responseString); |
| | | } |
| | | |
| | | @Override |
| | | public void onFailure(int statusCode, Header[] headers, String responseString, Throwable throwable) { |
| | | super.onFailure(statusCode, headers, responseString, throwable); |
| | | loadSplashAd(AdUtil.AD_TYPE.csj, CSJConstant.SPLASH_AD); |
| | | } |
| | | }); |
| | | |
| | | |
| | | } |
| | | }, 1000); |
| | | } |
| | | } |
| | | |
| | | Dialog mDialog; |
| | | AlertDialog alertDialog; |
| | | |
| | | @Override |
| | | public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { |
| | | super.onRequestPermissionsResult(requestCode, permissions, grantResults); |
| | | if (requestCode == REQUEST_CODE) { |
| | | for (int i = 0; i < permissions.length; i++) { |
| | | if (grantResults[i] == PERMISSION_GRANTED) {//选择了“始终允许” |
| | | myRequetPermission(); |
| | | } else { |
| | | if (!ActivityCompat.shouldShowRequestPermissionRationale(this, permissions[i])) {//用户选择了禁止不再询问 |
| | | AlertDialog.Builder builder = new AlertDialog.Builder(SplashActivity.this); |
| | | builder.setTitle("权限请求") |
| | | .setMessage("当前应用缺少必要的权限\n请点击设置-权限 打开电话和存储权限,以正常使用APP的功能") |
| | | .setPositiveButton("去设置", new DialogInterface.OnClickListener() { |
| | | public void onClick(DialogInterface dialog, int id) { |
| | | if (mDialog != null && mDialog.isShowing()) { |
| | | mDialog.dismiss(); |
| | | } |
| | | Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); |
| | | Uri uri = Uri.fromParts("package", getPackageName(), null);//注意就是"package",不用改成自己的包名 |
| | | intent.setData(uri); |
| | | startActivityForResult(intent, REQUEST_CODE); |
| | | } |
| | | }); |
| | | mDialog = builder.create(); |
| | | mDialog.setCanceledOnTouchOutside(false); |
| | | mDialog.show(); |
| | | } else {//选择禁止 |
| | | AlertDialog.Builder builder = new AlertDialog.Builder(this); |
| | | builder.setTitle("权限请求") |
| | | .setMessage("点击允许才可以使用哦") |
| | | .setPositiveButton("去允许", new DialogInterface.OnClickListener() { |
| | | public void onClick(DialogInterface dialog, int id) { |
| | | if (alertDialog != null && alertDialog.isShowing()) { |
| | | alertDialog.dismiss(); |
| | | } |
| | | ActivityCompat.requestPermissions(SplashActivity.this, |
| | | new String[]{Manifest.permission.READ_PHONE_STATE}, REQUEST_CODE); |
| | | } |
| | | }); |
| | | alertDialog = builder.create(); |
| | | alertDialog.setCanceledOnTouchOutside(false); |
| | | alertDialog.show(); |
| | | } |
| | | |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | protected void onActivityResult(int requestCode, int resultCode, Intent data) { |
| | | super.onActivityResult(requestCode, resultCode, data); |
| | | if (requestCode == REQUEST_CODE) { |
| | | myRequetPermission();//由于不知道是否选择了允许所以需要再次判断 |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | | |