Commit 7458a1f2 authored by mengcuiguang's avatar mengcuiguang

1.0.6优化

parent 3ab3ba11
......@@ -10,8 +10,8 @@ android {
applicationId "com.mints.highgold"
minSdkVersion rootProject.ext.androidMinSdkVersion
targetSdkVersion rootProject.ext.androidTargetSdkVersion
versionCode 6
versionName "1.0.5"
versionCode 7
versionName "1.0.6"
flavorDimensions "default"
// dex突破65535的限制
......
package com.mints.highgold;
import android.app.ActivityManager;
import android.app.Notification;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.support.annotation.NonNull;
import android.support.annotation.RequiresApi;
import android.support.multidex.MultiDex;
import android.support.multidex.MultiDexApplication;
import android.support.v4.content.LocalBroadcastManager;
import android.webkit.WebView;
import com.bun.miitmdid.core.JLibrary;
import com.downloader.PRDownloader;
......@@ -98,6 +102,8 @@ public class MintsApplication extends MultiDexApplication {
super.onCreate();
mContext = this.getApplicationContext();
initWebViewDataDirectory(this);
// 三方配置
thirdConfig();
}
......@@ -108,6 +114,7 @@ public class MintsApplication extends MultiDexApplication {
super.onLowMemory();
}
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
......@@ -419,4 +426,46 @@ public class MintsApplication extends MultiDexApplication {
}
return defaultSubscribeScheduler;
}
/**
* 为webView设置目录后缀
*
* @param context
*/
private void initWebViewDataDirectory(Context context) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
try {
String processName = getProcessName(context);
if (!context.getPackageName().equals(processName)) {//判断是否是默认进程名称
WebView.setDataDirectorySuffix(processName);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
/**
* 得到进程名称
*
* @param context
* @return
*/
public static String getProcessName(Context context) {
try {
if (context == null)
return null;
ActivityManager manager = (ActivityManager)
context.getSystemService(Context.ACTIVITY_SERVICE);
for (ActivityManager.RunningAppProcessInfo processInfo :
manager.getRunningAppProcesses()) {
if (processInfo.pid == android.os.Process.myPid()) {
return processInfo.processName;
}
}
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
}
......@@ -140,35 +140,41 @@ public class VedioAdingManager {
if (weightList != null) {
weightList.clear();
}
int weight = 0;
// 若没有视频完成数,不加入权重计算范围内
if (AppConfig.csjVedioAdCount > 0) {
weightList.add(new WeightBean(csjVedioWeight, Constant.CSJ_VEDIO_AD));
weight = weight + csjVedioWeight;
System.out.print("mcg __ 权重值:csjVedioWeight:" + csjVedioWeight);
}
if (AppConfig.csjFullAdCount > 0) {
weightList.add(new WeightBean(csjFullWeight, Constant.CSJ_FULL_AD));
weight = weight + csjFullWeight;
System.out.print(" mcg __ 权重值:csjFullWeight:" + csjFullWeight);
}
if (AppConfig.hytechVedioAdCount > 0) {
weightList.add(new WeightBean(hytechVedioWeight, Constant.HYTECH_VEDIO_AD));
weight = weight + hytechVedioWeight;
System.out.print(" mcg __ 权重值:hytechVedioWeight:" + hytechVedioWeight);
}
if (AppConfig.mintegralAdCount > 0) {
weightList.add(new WeightBean(mintegralWeight, Constant.MINTEGRAL_VEDIO_AD));
System.out.println(" mcg __ 权重值:mintegralWeight:" + mintegralWeight);
weight = weight + mintegralWeight;
System.out.print(" mcg __ 权重值:mintegralWeight:" + mintegralWeight);
}
if (AppConfig.ylhAdCount > 0) {
weightList.add(new WeightBean(ylhWeight, Constant.YLH_VEDIO_AD));
weight = weight + ylhWeight;
System.out.println(" mcg __ 权重值:ylhWeight:" + ylhWeight);
}
// 权重随机
if (weightList != null && weightList.size() > 0) {
int weight = 0;
for (WeightBean weightBean : weightList) {
weight += weightBean.getWeight();
}
if (weightList != null && weightList.size() > 0 && weight > 0) {
// for (WeightBean weightBean : weightList) {
// weight += weightBean.getWeight();
// }
System.out.print("mcg __ 1、权重总值:" + weight);
Random r = new Random();
......@@ -250,7 +256,9 @@ public class VedioAdingManager {
*/
public interface VedioAdingListener {
void vedioAdingListenerError(String adType);
void vedioAdingListenerFail(String adType);
void vedioAdingListenerSuccess(String adType);
}
......
......@@ -32,7 +32,8 @@ class BannerAdmanager {
* @param view
*/
private fun initBannerAd(carrierType: String, view: View?) {
if (AppConfig.bannerAdType == 0) loadTaBannerAd(carrierType, view)
// if (AppConfig.bannerAdType == 0) loadTaBannerAd(carrierType, view)
loadTaBannerAd(carrierType, view)
}
private fun loadTaBannerAd(carrierType: String, view: View?) {
......
package com.mints.highgold.ad.inscreenvedio;
import android.app.Activity;
import android.content.IntentFilter;
import android.net.ConnectivityManager;
import com.bytedance.sdk.openadsdk.AdSlot;
import com.bytedance.sdk.openadsdk.TTAdConstant;
import com.bytedance.sdk.openadsdk.TTAdNative;
import com.bytedance.sdk.openadsdk.TTFullScreenVideoAd;
import com.mintegral.msdk.interstitialvideo.out.InterstitialVideoListener;
import com.mintegral.msdk.interstitialvideo.out.MTGInterstitialVideoHandler;
import com.mintegral.msdk.videocommon.download.NetStateOnReceive;
import com.mints.highgold.common.AppConfig;
import com.mints.highgold.manager.MintegralManager;
import com.mints.highgold.manager.TTAdManagerHolder;
import com.mints.highgold.manager.TTNativeExpressManager;
/**
* Mintegral插屏视频
*/
public class MintegralInscreenVedioAdManager {
private static MintegralInscreenVedioAdManager _inst;
private Activity activity;
private MTGInterstitialVideoHandler mMtgInterstitalVideoHandler;
private NetStateOnReceive mNetStateOnReceive;
private String mRewardUnitId = MintegralManager.MINTEGRAL_AD_INSCREEN_VEDIO_POP_DRINK;
private TTAdNative ttAdNative;
private TTFullScreenVideoAd mttFullVideoAd;
public static MintegralInscreenVedioAdManager getInstance(Activity activity) {
if (_inst != null) {
return _inst;
} else {
_inst = new MintegralInscreenVedioAdManager(activity);
return _inst;
}
}
private MintegralInscreenVedioAdManager(Activity activity) {
init(activity);
return;
}
private void init(Activity activity) {
this.activity = activity;
initHandler();
}
public void loadMintegralInscreen() {
if (mMtgInterstitalVideoHandler != null) {
mMtgInterstitalVideoHandler.load();
}
}
public void showMintegralInscreen() {
if (mMtgInterstitalVideoHandler != null && mMtgInterstitalVideoHandler.isReady()) {
mMtgInterstitalVideoHandler.show();
} else {
AppConfig.isMintegralInscreenFlag = false;
loadCsjFullAd();
System.out.println("mcg __ MintegralInscreenVedioAdManager onVideoLoadFail noReady:");
}
}
private void initHandler() {
if (activity == null) return;
try {
if (mNetStateOnReceive == null) {
mNetStateOnReceive = new NetStateOnReceive();
IntentFilter filter = new IntentFilter();
filter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
activity.registerReceiver(mNetStateOnReceive, filter);
}
mMtgInterstitalVideoHandler = new MTGInterstitialVideoHandler(activity, mRewardUnitId);
mMtgInterstitalVideoHandler.setInterstitialVideoListener(new InterstitialVideoListener() {
@Override
public void onLoadSuccess(String unitId) {
System.out.println("mcg __ MintegralInscreenVedioAdManager onLoadSuccess");
AppConfig.isMintegralInscreenFlag = true;
}
@Override
public void onVideoLoadSuccess(String unitId) {
AppConfig.isMintegralInscreenFlag = true;
System.out.println("mcg __ MintegralInscreenVedioAdManager onVideoLoadSuccess");
}
@Override
public void onVideoLoadFail(String errorMsg) {
AppConfig.isMintegralInscreenFlag = false;
System.out.println("mcg __ MintegralInscreenVedioAdManager onVideoLoadFail errorMsg:" + errorMsg);
}
@Override
public void onShowFail(String errorMsg) {
AppConfig.isMintegralInscreenFlag = false;
System.out.println("mcg __ MintegralInscreenVedioAdManager onShowFail errorMsg:" + errorMsg);
}
@Override
public void onAdShow() {
}
@Override
public void onAdClose(boolean isCompleteView) {
AppConfig.isMintegralInscreenFlag = false;
}
@Override
public void onVideoAdClicked(String unitId) {
}
@Override
public void onVideoComplete(String unitId) {
}
@Override
public void onEndcardShow(String unitId) {
}
});
} catch (Exception e) {
e.printStackTrace();
}
}
public void destory() {
try {
if (mNetStateOnReceive != null) {
activity.unregisterReceiver(mNetStateOnReceive);
}
if (mMtgInterstitalVideoHandler != null) {
mMtgInterstitalVideoHandler.setInterstitialVideoListener(null);
}
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 全屏广告
*/
@SuppressWarnings("SameParameterValue")
private void loadCsjFullAd() {
ttAdNative = new TTNativeExpressManager().initTTAd(activity, false);
String codeId = TTAdManagerHolder.TT_AD_ALLVEDIO_ID_DRINKTIME;
AdSlot adSlot = new AdSlot.Builder()
.setCodeId(codeId)
.setSupportDeepLink(true)
.setImageAcceptedSize(1080, 1920)
.setOrientation(TTAdConstant.VERTICAL)
.build();
ttAdNative.loadFullScreenVideoAd(adSlot, new TTAdNative.FullScreenVideoAdListener() {
@Override
public void onError(int code, String message) {
}
@Override
public void onFullScreenVideoAdLoad(TTFullScreenVideoAd ad) {
mttFullVideoAd = ad;
}
@Override
public void onFullScreenVideoCached() {
if (activity != null && !activity.isFinishing() && mttFullVideoAd != null) {
//step6:在获取到广告后展示
mttFullVideoAd.showFullScreenVideoAd(activity);
mttFullVideoAd = null;
}
}
});
}
}
......@@ -78,4 +78,9 @@ public class AppConfig {
* banner显示类型 0-推啊
*/
public static int bannerAdType = 0;
/**
* MintegralInscreen true-加载成功
*/
public static boolean isMintegralInscreenFlag = false;
}
......@@ -152,6 +152,7 @@ public interface Constant {
String CARRIER_HOMEPAGE_YWHZ = "HOMEPAGE_YWHZ";//首页高额游戏挑战奖励
String CARRIER_GAME_CHALLENGE_TIME = "GAME_CHALLENGE_TIME";//任务赚游戏
String CARRIER_HOMEWATER_BUBBLE = "HOMEWATER_BUBBLE";//首页喝水汽泡
String CARRIER_HOMEWATER_BUBBLE_TIME = "CARRIER_HOMEWATER_BUBBLE_TIME";//首页喝水汽泡整点
String CARRIER_HOMEWATER_HIT = "HOMEWATER_HIT";//首页喝水打卡
String CARRIER_VERSUS_HEALTH = "VERSUS_HEALTH";//任务赚健康
String CARRIER_DRAWCASH = "CARRIER_DRAWCASH";//提现
......
......@@ -17,4 +17,9 @@ public class MintegralManager {
public static final String MINTEGRAL_AD_VEDIO_REDBOX_UNITID = "253899";// 高额版_Android_抢红包_0512
public static final String MINTEGRAL_AD_VEDIO_MAIN_UNITID = "253897";// 高额版_Android_首页试玩_0512
/*插屏视频*/
public static final String MINTEGRAL_AD_INSCREEN_VEDIO_DRINK = "200436";// 高额版_Android_首页气泡_0512
/*激励视频 UNITID*/
public static final String MINTEGRAL_AD_INSCREEN_VEDIO_POP_DRINK = "255048";// 高额版_Android_首页气泡_0512
}
......@@ -55,6 +55,7 @@ public class TTAdManagerHolder {
public static final String TT_AD_ALLVEDIO_ID_CHALLENGE_TURN = "945131834";//全屏挑战大转盘
public static final String TT_AD_ALLVEDIO_ID_CHALLENGE_CARD = "945131833";//全屏挑战刮刮乐
public static final String TT_AD_ALLVEDIO_ID_EXCEPTION = "945131829";//激励视频异常或其他 时使用
public static final String TT_AD_ALLVEDIO_ID_DRINKTIME = "945177915";//喝水打卡m异常时使用
/*插屏广告*/
public static final String TT_AD_INSERT_ID_LIEBAO = "945131770";//猎豹插屏场景
......
......@@ -17,6 +17,7 @@ public class UserTaskMsgBean implements Serializable {
private int downloandCompleteCount;//下载完成数
private String alipayAccount;
private String openid;
private String niceUrl;
private String msg;
private boolean cashOut1yuan;// true-提现过1元
private boolean cashOut2yuan;// true-提现过2元
......@@ -386,4 +387,8 @@ public class UserTaskMsgBean implements Serializable {
public void setVedioplan_mintegral_vedio_surplus(int vedioplan_mintegral_vedio_surplus) {
this.vedioplan_mintegral_vedio_surplus = vedioplan_mintegral_vedio_surplus;
}
public String getNiceUrl() {
return niceUrl;
}
}
......@@ -225,7 +225,7 @@ public class DrawcashPresenter extends BasePresenter<DrawcashView> {
}
} catch (Exception e) {
}
vo.put("model", deviceInfo.getMobileModel());
vo.put("model", deviceInfo.getBrand() + " " + deviceInfo.getMobileModel());
vo.put("uuid", new DeviceUuidFactory(context).getDeviceUuid());
vo.put("osversion", deviceInfo.getOSVersion());
vo.put("appversion", deviceInfo.getVersionName());
......
......@@ -504,7 +504,7 @@ public class LoanPresenter extends BasePresenter<LoanView> {
vo.put("os", "android");
vo.put("model", deviceInfo.getMobileModel());
vo.put("model", deviceInfo.getBrand() + " " + deviceInfo.getMobileModel());
vo.put("uuid", uuid);
vo.put("osversion", deviceInfo.getOSVersion());
vo.put("appversion", deviceInfo.getVersionName());
......@@ -595,7 +595,7 @@ public class LoanPresenter extends BasePresenter<LoanView> {
}
} catch (Exception e) {
}
vo.put("model", deviceInfo.getMobileModel());
vo.put("model", deviceInfo.getBrand() + " " + deviceInfo.getMobileModel());
vo.put("uuid", new DeviceUuidFactory(context).getDeviceUuid());
vo.put("osversion", deviceInfo.getOSVersion());
vo.put("appversion", deviceInfo.getVersionName());
......
......@@ -318,7 +318,7 @@ public class LoginPresenter extends BasePresenter<LoginView> {
}
} catch (Exception e) {
}
vo.put("model", deviceInfo.getMobileModel());
vo.put("model", deviceInfo.getBrand() + " " + deviceInfo.getMobileModel());
vo.put("uuid", new DeviceUuidFactory(context).getDeviceUuid());
vo.put("osversion", deviceInfo.getOSVersion());
vo.put("appversion", deviceInfo.getVersionName());
......
package com.mints.highgold.mvp.presenters;
import com.mints.highgold.manager.AppHttpManager;
import com.mints.highgold.mvp.model.AlipayBindBean;
import com.mints.highgold.mvp.model.BaseResponse;
import com.mints.highgold.mvp.views.AlipayBindView;
import com.mints.highgold.mvp.views.NewsWebviewView;
import com.mints.library.net.neterror.BaseSubscriber;
import com.mints.library.net.neterror.Throwable;
import java.util.HashMap;
public class NewsWebviewPresenter extends BasePresenter<NewsWebviewView> {
public void editUserMsg(HashMap<String, Object> vo) {
AppHttpManager.getInstance(loanApplication)
.call(loanService.editUserMsg(vo),
new BaseSubscriber<BaseResponse<Object>>() {
@Override
public void onCompleted() {
if (isLinkView()) return;
}
@Override
public void onError(Throwable e) {
if (isLinkView()) return;
}
@Override
public void onNext(BaseResponse<Object> baseResponse) {
if (isLinkView()) return;
}
});
}
}
......@@ -152,7 +152,7 @@ public class WxLoginPresenter extends BasePresenter<WxLoginView> {
}
} catch (Exception e) {
}
vo.put("model", deviceInfo.getMobileModel());
vo.put("model", deviceInfo.getBrand() + " " + deviceInfo.getMobileModel());
vo.put("uuid", new DeviceUuidFactory(context).getDeviceUuid());
vo.put("osversion", deviceInfo.getOSVersion());
vo.put("appversion", deviceInfo.getVersionName());
......
package com.mints.highgold.mvp.views;
import com.mints.highgold.mvp.model.AlipayBindBean;
public interface NewsWebviewView extends BaseView {
}
......@@ -23,6 +23,7 @@ import com.mints.highgold.BuildConfig;
import com.mints.highgold.R;
import com.mints.highgold.ad.VedioAdingManager;
import com.mints.highgold.ad.banner.BannerAdmanager;
import com.mints.highgold.ad.inscreenvedio.MintegralInscreenVedioAdManager;
import com.mints.highgold.common.AppConfig;
import com.mints.highgold.common.Constant;
import com.mints.highgold.manager.TTAdManagerHolder;
......@@ -45,6 +46,8 @@ import com.mints.highgold.utils.SPUtil;
import com.mints.highgold.utils.SoundPoolUtil;
import com.mints.highgold.utils.SpanUtils;
import com.mints.highgold.utils.Utils;
import com.mints.highgold.utils.rxutil.CommonRxTask;
import com.mints.highgold.utils.rxutil.RxjavaUtil;
import com.mints.library.utils.json.JsonUtil;
import com.mints.library.utils.nodoubleclick.AntiShake;
import com.qq.e.ads.rewardvideo.RewardVideoAD;
......@@ -56,6 +59,7 @@ import java.util.Calendar;
import java.util.HashMap;
import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;
/**
......@@ -89,6 +93,8 @@ public class AwardActivity extends BaseActivity implements AwardView {
LinearLayout llAwardBg;
@Bind(R.id.fsv_award)
FoxStreamerView fsvAward;
@Bind(R.id.iv_banner)
ImageView ivBanner;
private AwardPresenter awardPresenter;
private SPUtil spUtil;
......@@ -142,13 +148,29 @@ public class AwardActivity extends BaseActivity implements AwardView {
flAwardAd.setVisibility(View.GONE);
tvAwardHint.setVisibility(View.INVISIBLE);
fsvAward.setVisibility(View.GONE);
ivBanner.setVisibility(View.GONE);
} else {
tvAwardHint.setVisibility(View.GONE);
ivBanner.setVisibility(View.GONE);
fsvAward.setVisibility(View.VISIBLE);
bannerAdManager = new BannerAdmanager(AwardActivity.this);
bannerAdManager.showBannerAd("", fsvAward);
if (AppConfig.bannerAdType == 0) {
ivBanner.setVisibility(View.GONE);
fsvAward.setVisibility(View.VISIBLE);
bannerAdManager = new BannerAdmanager(AwardActivity.this);
bannerAdManager.showBannerAd("", fsvAward);
AppConfig.bannerAdType = 1;
} else {
ivBanner.setVisibility(View.VISIBLE);
fsvAward.setVisibility(View.GONE);
ivBanner.setImageResource(R.mipmap.ic_award_banner);
AppConfig.bannerAdType = 0;
}
}
initDataView();
......@@ -210,7 +232,6 @@ public class AwardActivity extends BaseActivity implements AwardView {
}
}
@Override
public void onDestroy() {
if (bannerAdManager != null) {
......@@ -247,11 +268,19 @@ public class AwardActivity extends BaseActivity implements AwardView {
return super.onKeyDown(keyCode, event);
}
@OnClick({R.id.iv_award_back, R.id.tv_award_next})
@OnClick({R.id.iv_award_back, R.id.tv_award_next, R.id.iv_banner})
public void onClick(View view) {
if (AntiShake.check(view.getId())) return;
Bundle bundle;
switch (view.getId()) {
case R.id.iv_banner:
if (userConfig != null) {
bundle = new Bundle();
bundle.putString(Constant.DAICHAO_URL, userConfig.getNiceUrl());
readyGo(WebActivity.class, bundle);
}
break;
case R.id.iv_award_back:
// 界面回传值
if (isBackFlag == Constant.MAIN_CUR_TWO) {
......@@ -285,7 +314,7 @@ public class AwardActivity extends BaseActivity implements AwardView {
//awardPresenter.addLoan(null);
Bundle bundle = new Bundle();
bundle = new Bundle();
bundle.putString(Constant.DAICHAO_URL, userConfig.getLoanUrl());
readyGo(WebActivity.class, bundle);
}
......@@ -624,6 +653,31 @@ public class AwardActivity extends BaseActivity implements AwardView {
llAwardBg.setBackground(getResources().getDrawable(R.mipmap.bg_award_drink));
break;
case Constant.CARRIER_HOMEWATER_BUBBLE:// 首页喝水汽泡
tvAwardContent.setText("恭喜获得" + curCoin + "金币");
tvAwardNext.setVisibility(View.GONE);
tvAwardHint.setVisibility(View.GONE);
llAwardBg.setBackground(getResources().getDrawable(R.mipmap.bg_award_gold));
break;
case Constant.CARRIER_HOMEWATER_BUBBLE_TIME:// 首页喝水汽泡整点
RxjavaUtil.executeRxTask(new CommonRxTask<String>("") {
@Override
public void doInIOThread() {
try {
Thread.sleep(800);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
@Override
public void doInUIThread() {
if (!AwardActivity.this.isFinishing()) {
MintegralInscreenVedioAdManager.getInstance(AwardActivity.this).showMintegralInscreen();
}
}
});
tvAwardContent.setText("恭喜获得" + curCoin + "金币");
tvAwardNext.setVisibility(View.GONE);
tvAwardHint.setVisibility(View.GONE);
......
......@@ -11,9 +11,12 @@ import android.text.TextUtils;
import android.view.KeyEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.AccelerateDecelerateInterpolator;
import android.webkit.CookieManager;
import android.webkit.CookieSyncManager;
import android.webkit.JsResult;
import android.webkit.SslErrorHandler;
import android.webkit.ValueCallback;
import android.webkit.WebChromeClient;
import android.webkit.WebResourceRequest;
import android.webkit.WebResourceResponse;
......@@ -23,9 +26,16 @@ import android.webkit.WebViewClient;
import android.widget.ProgressBar;
import android.widget.TextView;
import com.daimajia.androidanimations.library.Techniques;
import com.daimajia.androidanimations.library.YoYo;
import com.mints.highgold.R;
import com.mints.highgold.common.Constant;
import com.mints.highgold.mvp.presenters.NewsWebviewPresenter;
import com.mints.highgold.mvp.views.NewsWebviewView;
import com.mints.highgold.ui.activitys.base.BaseActivity;
import com.mints.highgold.ui.widgets.NewWebView;
import com.mints.highgold.ui.widgets.countdowntimer.CountDownTimerSupport;
import com.mints.highgold.ui.widgets.countdowntimer.OnCountDownTimerListener;
import com.mints.library.utils.nodoubleclick.AntiShake;
import butterknife.Bind;
......@@ -37,18 +47,30 @@ import butterknife.OnClick;
* 时间:2020/3/30 10:47
* 邮箱:mengcga@163.com
*/
public class NewsWebviewActivity extends BaseActivity {
public class NewsWebviewActivity extends BaseActivity implements NewsWebviewView {
@Bind(R.id.tv_activity_title)
TextView tvActivityTitle;
@Bind(R.id.wb_news)
WebView mWebView;
NewWebView mWebView;
@Bind(R.id.pb_web)
ProgressBar mProgressBar;
@Bind(R.id.tv_activity_content)
TextView tvActivityContent;
private NewsWebviewPresenter newsWebviewPresenter;
CountDownTimerSupport newsTimer = null;//喝水
long countDownInterval = 1000;//间隔时长
private String url;
private String title;
private String mainUrl;// 主页url
private boolean isFirstLoad = true;// 是否首页加载,记录主页url
private boolean isScrollFlag = false;// 是否滑动过
private int stopSecond = 3;//当前停留秒数
@Override
protected int getContentViewLayoutID() {
return R.layout.activity_news_webview;
......@@ -56,6 +78,9 @@ public class NewsWebviewActivity extends BaseActivity {
@Override
protected void initViewsAndEvents() {
newsWebviewPresenter = new NewsWebviewPresenter();
newsWebviewPresenter.attachView(this);
mProgressBar.setProgress(0);
if (TextUtils.isEmpty(title)) {
......@@ -101,6 +126,8 @@ public class NewsWebviewActivity extends BaseActivity {
protected void onDestroy() {
super.onDestroy();
// stopTimer();
if (mWebView != null) {
ViewGroup parent = (ViewGroup) mWebView.getParent();
if (parent != null) {
......@@ -110,18 +137,19 @@ public class NewsWebviewActivity extends BaseActivity {
mWebView.destroy();
mWebView = null;
}
}
newsWebviewPresenter.detachView();
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK && mWebView.canGoBack()) {
mWebView.goBack();// 返回前一个页面
return true;
}
return super.onKeyDown(keyCode, event);
}
// @Override
// public boolean onKeyDown(int keyCode, KeyEvent event) {
// if (keyCode == KeyEvent.KEYCODE_BACK && mWebView.canGoBack()) {
// mWebView.goBack();// 返回前一个页面
// return true;
// }
// return super.onKeyDown(keyCode, event);
// }
private void initWebviewConfig() {
WebSettings mWebSettings = mWebView.getSettings();
......@@ -164,7 +192,7 @@ public class NewsWebviewActivity extends BaseActivity {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
mWebSettings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
}
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
CookieManager.getInstance().setAcceptThirdPartyCookies(mWebView, true);
mWebView.setScrollBarStyle(WebView.SCROLLBARS_INSIDE_OVERLAY);
......@@ -172,6 +200,44 @@ public class NewsWebviewActivity extends BaseActivity {
mWebView.setHorizontalFadingEdgeEnabled(false);
mWebView.setVerticalFadingEdgeEnabled(false);
mWebView.requestFocus();
// mWebView.setOnScrollChangeListener(new NewWebView.OnScrollChangeListener() {
// @Override
// public void onPageEnd(int l, int t, int oldl, int oldt) {
// }
//
// @Override
// public void onPageTop(int l, int t, int oldl, int oldt) {
// }
//
// @Override
// public void onScrollChanged(int l, int t, int oldl, int oldt) {
//
// if (!isScrollFlag) {
// System.out.println("mcg __ onScrollChanged");
//
// isScrollFlag = true;
//
// stopTimer();
// newsTimer = new CountDownTimerSupport((int) (stopSecond * countDownInterval), countDownInterval);
// newsTimer.setOnCountDownTimerListener(new OnCountDownTimerListener() {
// @Override
// public void onTick(long millisUntilFinished) {
// System.out.println("mcg __ millisUntilFinished" + millisUntilFinished);
// }
//
// @Override
// public void onFinish() {
// if (!NewsWebviewActivity.this.isFinishing()) {
// loadAmim(tvActivityContent, "返回查看下一条咨询");
// }
// }
// });
// newsTimer.start();
// }
// }
// });
mWebView.setWebViewClient(new WebViewClient() {
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
......@@ -217,7 +283,31 @@ public class NewsWebviewActivity extends BaseActivity {
if (mProgressBar != null && !NewsWebviewActivity.this.isFinishing()) {
if (newProgress == 100) {
mProgressBar.setVisibility(View.GONE);
// if (webView != null) {
// if (AntiShake.check(webView.getId())) return;
//
// String url = webView.getUrl();
// if (isFirstLoad) {
// isFirstLoad = false;
// mainUrl = url;
// }
//
// stopTimer();
//
// if (TextUtils.equals(mainUrl, url)) {
//// isScrollFlag = false;
//
// loadAmim(tvActivityContent, "点击任意一条咨询进入");
// } else {
// loadAmim(tvActivityContent, "向上滑动3-5次屏幕,并停留" + stopSecond + "秒");
// }
//
// System.out.println("mcg progress url :" + webView.getUrl());
// }
} else {
// tvActivityContent.setText("界面加载中...");
mProgressBar.setVisibility(View.VISIBLE);
mProgressBar.setProgress(newProgress);
}
......@@ -225,7 +315,7 @@ public class NewsWebviewActivity extends BaseActivity {
}
@Override
public boolean onJsConfirm(WebView view, String url, String message, android.webkit.JsResult result) {
public boolean onJsConfirm(WebView view, String url, String message, JsResult result) {
return super.onJsConfirm(view, url, message, result);
}
......@@ -239,12 +329,12 @@ public class NewsWebviewActivity extends BaseActivity {
}
@Override
public boolean onShowFileChooser(WebView webView, android.webkit.ValueCallback<Uri[]> filePathCallback, FileChooserParams fileChooserParams) {
public boolean onShowFileChooser(WebView webView, ValueCallback<Uri[]> filePathCallback, FileChooserParams fileChooserParams) {
return super.onShowFileChooser(webView, filePathCallback, fileChooserParams);
}
@Override
public boolean onJsAlert(WebView view, String url, String message, android.webkit.JsResult result) {
public boolean onJsAlert(WebView view, String url, String message, JsResult result) {
return super.onJsAlert(view, url, message, result);
}
......@@ -264,4 +354,20 @@ public class NewsWebviewActivity extends BaseActivity {
cookieManager.setAcceptCookie(true);
CookieSyncManager.getInstance().sync();
}
private void loadAmim(TextView view, String text) {
if (view != null) {
view.setText(text);
YoYo.with(Techniques.Flash).duration(1000)
.repeat(0)
.playOn(view);
}
}
private void stopTimer() {
if (newsTimer != null) {//防止计时器重复
newsTimer.stop();
newsTimer = null;
}
}
}
......@@ -27,8 +27,10 @@ import com.google.gson.JsonParser;
import com.mints.highgold.BuildConfig;
import com.mints.highgold.R;
import com.mints.highgold.ad.VedioAdingManager;
import com.mints.highgold.ad.inscreenvedio.MintegralInscreenVedioAdManager;
import com.mints.highgold.common.AppConfig;
import com.mints.highgold.common.Constant;
import com.mints.highgold.common.DeviceInfo;
import com.mints.highgold.manager.AmapLocationManager;
import com.mints.highgold.manager.LiebaoManager;
import com.mints.highgold.manager.ShumeiManager;
......@@ -153,6 +155,7 @@ public class MainFragment extends BaseFragment
private TTBannerManager ttUtil;
private MainWaterBean waterBean;
private MintegralInscreenVedioAdManager mintegralInscreenVedioAdManager;
@Override
protected int getContentViewLayoutID() {
......@@ -300,6 +303,10 @@ public class MainFragment extends BaseFragment
CmGameSdk.removeGameAdCallback();
CmGameSdk.removeGameExitInfoCallback();
if (mintegralInscreenVedioAdManager != null) {
mintegralInscreenVedioAdManager.destory();
}
// 取消水滴动画
if (wvWater != null) {
wvWater.destoryAnim();
......@@ -465,17 +472,17 @@ public class MainFragment extends BaseFragment
//测试数据
// data.setVedioplan_csj_vedio_rate(5);
// data.setVedioplan_lyh_vedio_rate(5);
// data.setVedioplan_csj_full_screen_video_rate(5);
// data.setVedioplan_hytech_vedio_rate(5);
// data.setVedioplan_csj_vedio_rate(0);
// data.setVedioplan_lyh_vedio_rate(0);
// data.setVedioplan_csj_full_screen_video_rate(0);
// data.setVedioplan_hytech_vedio_rate(0);
// data.setVedioplan_mintegral_vedio_rate(5);
//
// data.setVedioplan_csj_vedio_surplus(2);
// data.setVedioplan_lyh_vedio_surplus(2);
// data.setVedioplan_csj_full_screen_video_surplus(3);
// data.setVedioplan_hytech_vedio_surplus(2);
// data.setVedioplan_mintegral_vedio_surplus(2);
// data.setVedioplan_csj_vedio_surplus(0);
// data.setVedioplan_lyh_vedio_surplus(0);
// data.setVedioplan_csj_full_screen_video_surplus(0);
// data.setVedioplan_hytech_vedio_surplus(0);
// data.setVedioplan_mintegral_vedio_surplus(20);
// 设置随机广告权重
if (vedioAdingManager != null) {
......@@ -701,12 +708,20 @@ public class MainFragment extends BaseFragment
}
}
System.out.println("mcg __ 喝水 isMintegralInscreenFlag:" + AppConfig.isMintegralInscreenFlag);
// 喝水时间
if (data.getNextGetCoinTime() > 0) {
wvWater.setTvDrinkBtnText("喝水打卡");
wvWater.closeWaterViewTime();
wvWater.setWaterViewTime(getActivity(), data.getNextGetCoinTime());
} else {
if (!AppConfig.isMintegralInscreenFlag) {
if (mintegralInscreenVedioAdManager != null) {
mintegralInscreenVedioAdManager.loadMintegralInscreen();
}
}
wvWater.setTvDrinkBtnText("喝水领金币");
wvWater.setWaterViewTimeGone();
}
......@@ -770,7 +785,7 @@ public class MainFragment extends BaseFragment
if (waterCoin > 0) {
// 显示喝水金币
bundle.putInt(Constant.MAIN_CUR_COIN, waterCoin);
bundle.putString(Constant.MAIN_CARRIET_TURN, Constant.CARRIER_HOMEWATER_BUBBLE);
bundle.putString(Constant.MAIN_CARRIET_TURN, Constant.CARRIER_HOMEWATER_BUBBLE_TIME);
} else {
bundle.putString(Constant.MAIN_CARRIET_TURN, Constant.CARRIER_HOMEWATER_HIT);
}
......@@ -918,6 +933,7 @@ public class MainFragment extends BaseFragment
userManager = UserManager.getInstance();
liebaoManager = LiebaoManager.getInstance();
vedioAdingManager = VedioAdingManager.getInstance(getActivity());
mintegralInscreenVedioAdManager = MintegralInscreenVedioAdManager.getInstance(getActivity());
mLocationHandler = new AmapLocationManager.LocationHandler(getActivity());
lvMainGamelist.setFocusable(false);
......
package com.mints.highgold.ui.widgets;
import android.content.Context;
import android.util.AttributeSet;
import android.webkit.WebView;
public class NewWebView extends WebView {
private OnScrollChangeListener mOnScrollChangeListener;
public NewWebView(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
protected void onScrollChanged(int l, int t, int oldl, int oldt) {
super.onScrollChanged(l, t, oldl, oldt);
// webview的高度
try {
float webcontent = getContentHeight() * getScale();
// 当前webview的高度
float webnow = getHeight() + getScrollY();
if (mOnScrollChangeListener != null) {
if (Math.abs(webcontent - webnow) < 1) {
//处于底端
mOnScrollChangeListener.onPageEnd(l, t, oldl, oldt);
} else if (getScrollY() == 0) {
//处于顶端
mOnScrollChangeListener.onPageTop(l, t, oldl, oldt);
} else {
mOnScrollChangeListener.onScrollChanged(l, t, oldl, oldt);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
public void setOnScrollChangeListener(OnScrollChangeListener listener) {
this.mOnScrollChangeListener = listener;
}
public interface OnScrollChangeListener {
public void onPageEnd(int l, int t, int oldl, int oldt);
public void onPageTop(int l, int t, int oldl, int oldt);
public void onScrollChanged(int l, int t, int oldl, int oldt);
}
}
......@@ -80,6 +80,13 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:fox_size="foxBr" />
<ImageView
android:id="@+id/iv_banner"
android:layout_marginTop="16pt"
android:scaleType="fitXY"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</FrameLayout>
......
......@@ -5,48 +5,66 @@
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/tv_activity_back"
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="50pt"
android:paddingTop="70pt"
android:paddingRight="30pt"
android:paddingBottom="20pt"
android:scaleType="center"
android:src="@mipmap/ic_activity_arrow" />
android:orientation="horizontal">
<ImageView
android:id="@+id/tv_activity_back"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="50pt"
android:paddingTop="70pt"
android:paddingRight="30pt"
android:paddingBottom="20pt"
android:scaleType="center"
android:src="@mipmap/ic_activity_arrow" />
<ImageView
android:id="@+id/iv_activity_quit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="20pt"
android:paddingTop="70pt"
android:paddingRight="40pt"
android:paddingBottom="20pt"
android:scaleType="center"
android:src="@mipmap/ic_activity_quit" />
<ImageView
android:id="@+id/iv_activity_quit"
</LinearLayout>
<TextView
android:id="@+id/tv_activity_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="20pt"
android:paddingTop="70pt"
android:paddingRight="40pt"
android:paddingBottom="20pt"
android:scaleType="center"
android:src="@mipmap/ic_activity_quit" />
</LinearLayout>
android:layout_centerHorizontal="true"
android:layout_marginTop="80pt"
android:textColor="@color/product_net_text"
android:textSize="14sp" />
</RelativeLayout>
<TextView
android:id="@+id/tv_activity_title"
android:visibility="gone"
android:id="@+id/tv_activity_content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="80pt"
android:layout_marginTop="10pt"
android:layout_marginBottom="10pt"
android:layout_gravity="center_horizontal"
android:textColor="@color/product_net_text"
android:textSize="14sp" />
</RelativeLayout>
</LinearLayout>
<ProgressBar
android:id="@+id/pb_web"
style="?android:attr/progressBarStyleHorizontal"
......@@ -57,7 +75,7 @@
android:max="100"
android:progressDrawable="@drawable/progress_bar_horizontal" />
<WebView
<com.mints.highgold.ui.widgets.NewWebView
android:id="@+id/wb_news"
android:layout_width="match_parent"
android:layout_height="match_parent" />
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment