Commit 725d1edc authored by maxiaoliang's avatar maxiaoliang

添加webview

parent 80a9c5f9
......@@ -16,12 +16,14 @@ import com.ym.game.view.HomeWareActivity
import com.ym.game.view.SiginDropsPopupwindow
import com.ym.game.view.TurntableDialog
import com.ym.library.module.AdEntity
import com.ym.library.Constant
import com.ym.library.net.BaseObserver
import com.ym.library.net.RxSchedulers
import com.ym.library.rxbus.RxBusConstant
import com.ym.library.rxbus.RxBusUtil
import com.ym.library.utils.EventUtils
import com.ym.library.utils.SettingPreference
import com.ym.library.utils.JumpUtils
import com.ym.library.utils.Utils
import com.ym.module.toponad.AdID
import com.ym.module.toponad.ToponManager
......@@ -77,6 +79,8 @@ class GameActivity : UnityPlayerActivity() {
*/
fun ranklistClick() {
Log.d("wxw", "上榜赚钱")
//JumpUtils.h5Jump("上榜赚钱", Constant.Param.RankList)
JumpUtils.h5Jump("水滴排行榜", Constant.Param.RankList, false)
}
/**
......@@ -84,6 +88,7 @@ class GameActivity : UnityPlayerActivity() {
*/
fun oneveryDayWelfareClick() {
Log.d("wxw", "每日福利")
JumpUtils.h5Jump("每日福利", Constant.Param.WelfareCenter, false)
}
......@@ -92,6 +97,7 @@ class GameActivity : UnityPlayerActivity() {
*/
fun clockInMakeMoney() {
Log.d("wxw", "打卡提现")
JumpUtils.h5Jump("打卡提现", Constant.Param.PunchRecord, false)
}
/**
......@@ -124,7 +130,7 @@ class GameActivity : UnityPlayerActivity() {
/**
* 打开飞行宝箱
*/
fun openFlyBox() {
fun openAdFlyBox() {
}
......@@ -290,7 +296,7 @@ class GameActivity : UnityPlayerActivity() {
}
//看视频领取种子
fun getVideoSeedReceive(callback: IUnitySendMessageCallback?,id: Int) {
fun getVideoSeedReceive(callback: IUnitySendMessageCallback?, id: Int) {
GameApiClient.gameApi.getVideoSeedReceive(id).compose(RxSchedulers.observableIO2Main())
.subscribe(object : BaseObserver<StatusEntity>() {
override fun onSuccess(result: StatusEntity?) {
......@@ -307,8 +313,9 @@ class GameActivity : UnityPlayerActivity() {
}
//看视频领取加速剂
fun getVideoAcceleratorsReceive(callback: IUnitySendMessageCallback?,id: Int) {
GameApiClient.gameApi.getVideoAcceleratorsReceive(id).compose(RxSchedulers.observableIO2Main())
fun getVideoAcceleratorsReceive(callback: IUnitySendMessageCallback?, id: Int) {
GameApiClient.gameApi.getVideoAcceleratorsReceive(id)
.compose(RxSchedulers.observableIO2Main())
.subscribe(object : BaseObserver<StatusEntity>() {
override fun onSuccess(result: StatusEntity?) {
Log.d("wxw", "看视频领取加速剂" + Utils.obj2Str(result))
......@@ -323,5 +330,4 @@ class GameActivity : UnityPlayerActivity() {
}
}
\ No newline at end of file
......@@ -3,4 +3,9 @@ package com.ym.game.module
class FlyBoxEntity {
var type:Int?=0
var awardNum:Int?=0
var seedList: MutableList<SeedList> = ArrayList()
class SeedList{
var id:Int=0
var num:Int=0
}
}
\ No newline at end of file
......@@ -19,6 +19,10 @@ import com.ym.library.utils.EventUtils
import com.ym.library.utils.LogUtils
import com.ym.library.utils.Utils
import com.ym.xync.R
import com.ym.module.toponad.AdID
import com.ym.module.toponad.ToponManager
import com.ym.module.toponad.listener.ToponRewardListener
/**
*Craeted by ${junqi.li}
......
......@@ -137,7 +137,7 @@ class MainActivity : BaseActivity(), NavigationBottomView.OnTabSelectedListener,
}
//怎么玩
findViewById<ImageView>(R.id.iv_how_to_play)?.setOnClickListener {
JumpUtils.h5Jump("怎么玩", Constant.PLAY_URL)
JumpUtils.h5Jump("怎么玩", Constant.PLAY_URL,false)
}
}
......
......@@ -41,12 +41,12 @@ object CenterDialog:BaseDialog() {
.setOnClickListener { activity.finish() }
val clickUa: ClickableSpan = object : ClickableSpan() {
override fun onClick(widget: View) {
JumpUtils.h5Jump("隐私政策", NetConfig.H5.WEB_URL_PRIVACY)
JumpUtils.h5Jump("隐私政策", NetConfig.H5.WEB_URL_PRIVACY,false)
}
}
val clickPrivat: ClickableSpan = object : ClickableSpan() {
override fun onClick(widget: View) {
JumpUtils.h5Jump("用户协议", NetConfig.H5.WEB_URL_USER)
JumpUtils.h5Jump("用户协议", NetConfig.H5.WEB_URL_USER,false)
}
}
// 《隐私政策》和《用户协议》,请您在使用前仔细阅读并了解
......
......@@ -62,14 +62,26 @@
android:resource="@xml/bd_file_path" />
</provider>-->
<activity
android:name="com.ym.library.net.PermissionsActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:screenOrientation="unspecified"
android:theme="@android:style/Theme.Translucent.NoTitleBar"/>
<activity
android:name="com.ym.library.activity.WebViewActivity"
android:exported="true"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data
android:host="web"
android:scheme="luckyfarm" />
</intent-filter>
</activity>
<!--全屏广告,激励视频-->
<!-- <activity
......
......@@ -15,7 +15,7 @@ import java.util.List;
public class Constant {
public static int REQUEST_CODE_ASK_PERMISSIONS = 0x0101;
public static final String scheme = "quweiguesssong";
public static final String scheme = "luckyfarm";
public static final String withdraw_right_top = "withdraw_right_top";
public static final String sign_in_again_video = "sign_in_again_video";
......@@ -452,6 +452,10 @@ public class Constant {
public static String district = "";
public static String street = "";
public static String makingMoneyUrl = "";
public static String WelfareCenter = "https://h5v3.zhangxinzhixun.com/huayuan/Welfare";//福利中心
public static String PunchRecord = "https://h5v3.zhangxinzhixun.com/huayuan/ClockIn";//打卡记录
public static String RankList = "https://h5v3.zhangxinzhixun.com/huayuan/Ranking";//排行榜
}
public static class SdkKey {
......
This diff is collapsed.
package com.ym.userinfo.module.activity;
package com.ym.library.activity;
import android.graphics.Color;
import android.app.Activity;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.JavascriptInterface;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.umeng.analytics.MobclickAgent;
import com.ym.library.R;
import com.ym.library.net.BaseActivity;
import com.ym.library.rxbus.RxBusConstant;
import com.ym.library.rxbus.RxBusUtil;
import com.ym.library.utils.StatusBarUtil;
import com.ym.module.userinfo.R;
import com.ym.library.utils.Utils;
import com.ym.module.toponad.AdID;
import com.ym.module.toponad.ToponManager;
import org.apache.poi.hssf.record.formula.functions.Int;
import org.jetbrains.annotations.NotNull;
public class WebViewActivity extends BaseActivity {
private String url;
private String title;
private LinearLayout layout;
private WebView webView;
@Override
......@@ -34,33 +44,28 @@ public class WebViewActivity extends BaseActivity {
@Override
public void init() {
url = getIntent().getData().getQueryParameter("url");
// url = getIntent().getStringExtra("url");
// title = getIntent().getStringExtra("title");
title = getIntent().getData().getQueryParameter("title");
RelativeLayout rl = findViewById(R.id.id_rl_toolbar);
if (getIntent().getData().getBooleanQueryParameter("showToolbar", true)) {
rl.setVisibility(View.VISIBLE);
} else {
rl.setVisibility(View.GONE);
}
layout = findViewById(R.id.activity_webview_layout);
initWebView();
initTitle();
}
@Override
protected void onResume() {
super.onResume();
MobclickAgent.onResume(this);
}
@Override
protected void onPause() {
super.onPause();
MobclickAgent.onPause(this);
}
private void initWebView() {
webView = findViewById(R.id.activity_webview);
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
webView = new WebView(this);
webView.setBackgroundColor(getResources().getColor(R.color.color_FEDA83));
//设置WebView的宽高
webView.setLayoutParams(layoutParams);
//把webView添加到容器中
layout.addView(webView);
webView.getSettings().setUseWideViewPort(true);
webView.getSettings().setLoadWithOverviewMode(true);
// webView.getSettings().setDefaultFontSize(56);
......@@ -86,7 +91,7 @@ public class WebViewActivity extends BaseActivity {
// },"android");
// webView.addJavascriptInterface(new WebJavaInterface(this,webView).);
webView.addJavascriptInterface(new WebJavaInterface(), "android");
webView.addJavascriptInterface(new WebJavaInterface(this, webView), "android");
webView.setWebViewClient(new WebViewClient() {
@Override
......@@ -100,14 +105,35 @@ public class WebViewActivity extends BaseActivity {
}
private void initTitle() {
findViewById(R.id.iv_user_toolbar_back).setOnClickListener(new View.OnClickListener() {
findViewById(R.id.id_iv_back).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
finish();
}
});
TextView tv_title = findViewById(R.id.tv_user_toolbar_title);
tv_title.setText(title+"");
tv_title.setText(title);
}
@Override
protected void onResume() {
super.onResume();
if (webView != null) {
webView.loadUrl("javascript:onResume()");
}
MobclickAgent.onResume(this);
// ToponManager.INSTANCE.initNativeAd(this, AdID.AD_WELFARE_CENTER_BIGIMAGE);
}
@Override
protected void onPause() {
super.onPause();
if (webView != null) {
webView.loadUrl("javascript:onPause()");
}
MobclickAgent.onPause(this);
RxBusUtil.getDefault()
.send(RxBusConstant.RX_MAIN_HIGH_WATER_DROP_UPDATE);
}
@Override
......@@ -118,13 +144,16 @@ public class WebViewActivity extends BaseActivity {
webView.removeAllViews();
webView.destroy();
webView = null;
layout.removeView(webView);
}
}
class WebJavaInterface {
@JavascriptInterface
public void finishH5() {
finish();
class WebJavaInterface extends JavaInterface {
public WebJavaInterface(@NotNull Activity act, @NotNull WebView web) {
super(act, web);
}
}
}
......@@ -2,6 +2,7 @@ package com.ym.library.net
import com.ym.library.module.*
import io.reactivex.Observable
import okhttp3.ResponseBody
import retrofit2.http.*
/**
......@@ -40,4 +41,21 @@ interface IUserApi {
@GET(NetConfig.User.URL_USER_WITHDRAW_BIND_WX)
fun bindWx(@Query("openId") oppenid: String,@Query("token") token: String): Observable<Response<WxBindEntity>>
/**
* h5-post接口
* @param
* @param
* @return
*/
@POST
fun webApiPost(@Url url: String): Observable<retrofit2.Response<ResponseBody>>
/**
* h5-get接口
* @param
* @param
* @return
*/
@GET
fun webApiGet(@Url url: String): Observable<retrofit2.Response<ResponseBody>>
}
\ No newline at end of file
......@@ -25,7 +25,8 @@ interface RounterApi {
@RounterUri(Constant.scheme + "://web")
fun getIntentActivityWeb(
@RounterParam("title") title: String,
@RounterParam("url") url: String
@RounterParam("url") url: String,
@RounterParam("showToolbar") showToolbar: Boolean
): Intent
@RounterUri(Constant.scheme + "://adshare")
......
......@@ -38,4 +38,6 @@ public class RxBusConstant {
public final static int RX_MAIN_UPDATE_HOME_INFO = 10005;
//MainFragment 每日水滴领取后刷新
public final static int RX_MAIN_WATER_DROP_UPDATE = 10008;
//MainFragment 高额水滴领取后刷新
public final static int RX_MAIN_HIGH_WATER_DROP_UPDATE = 10004;
}
......@@ -30,9 +30,9 @@ public class JumpUtils {
}
}
public static void h5Jump(String title, String url) {
public static void h5Jump(String title, String url,boolean showToolbar) {
try {
Intent intent = RounterBus.getRounter(RounterApi.class).getIntentActivityWeb(title, url);
Intent intent = RounterBus.getRounter(RounterApi.class).getIntentActivityWeb(title, url,showToolbar);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
AppliContext.get().startActivity(intent);
} catch (Exception e) {
......@@ -348,7 +348,7 @@ public class JumpUtils {
data.getDeep_url_re()
);
} else {
h5Jump(data.getTitle(), data.getUrl());
h5Jump(data.getTitle(), data.getUrl(),false);
}
} else if (data.getOpentype() == NewsEntity.AD_TYPE_APPMODEL && data.getStatus() != 2) {
if (appmodelId == 59) {
......
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout
android:id="@+id/id_rl_toolbar"
android:layout_width="match_parent"
android:layout_height="90dp"
android:background="#994B00">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_alignParentBottom="true">
<ImageView
android:id="@+id/id_iv_back"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/icon_webview_back"
android:layout_marginLeft="14dp"
android:layout_centerVertical="true"/>
<TextView
android:id="@+id/tv_user_toolbar_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#ffffffff"
android:textSize="18sp"
android:textStyle="bold"
android:layout_centerInParent="true"/>
</RelativeLayout>
</RelativeLayout>
<LinearLayout
android:id="@+id/activity_webview_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" />
</LinearLayout>
......@@ -23,4 +23,5 @@
<color name="transparent">#00000000</color>
<color name="transparent75">#60000000</color>
<color name="color_FEDA83">#FEDA83</color>
</resources>
......@@ -34,17 +34,6 @@
android:scheme="quweiguesssong" />
</intent-filter>
</activity>
<activity
android:name="com.ym.userinfo.module.activity.WebViewActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data
android:host="web"
android:scheme="quweiguesssong" />
</intent-filter>
</activity>
</application>
</manifest>
\ No newline at end of file
......@@ -23,15 +23,15 @@ class SettingActivity : BaseActivity() {
tv_user_toolbar_title.text = "设置"
//用户协议
tv_setting_user_agreement.setOnClickListener {
JumpUtils.h5Jump("用户协议", Constant.Param.USER)
JumpUtils.h5Jump("用户协议", Constant.Param.USER,false)
}
//隐私条款
tv_setting_privacy_policy.setOnClickListener {
JumpUtils.h5Jump("隐私条款", Constant.Param.PRIVACY)
JumpUtils.h5Jump("隐私条款", Constant.Param.PRIVACY,false)
}
//关于我们
tv_setting_about_us.setOnClickListener {
JumpUtils.h5Jump("关于我们", Constant.Param.ABOUTUS)
JumpUtils.h5Jump("关于我们", Constant.Param.ABOUTUS,false)
}
//版本升级
id_setting_update_version.setOnClickListener {
......
......@@ -119,10 +119,10 @@ object UserDiaLog {
// mDialog.dismiss()
// }
mDialogView.findViewById<TextView>(R.id.tv_wx_login_user).setOnClickListener {
JumpUtils.h5Jump("隐私条款", Constant.Param.USER)
JumpUtils.h5Jump("隐私条款", Constant.Param.USER,false)
}
mDialogView.findViewById<TextView>(R.id.tv_wx_login_privacy).setOnClickListener {
JumpUtils.h5Jump("隐私条款", Constant.Param.PRIVACY)
JumpUtils.h5Jump("隐私条款", Constant.Param.PRIVACY,false)
}
......
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include layout="@layout/layout_user_toolbar" />
<WebView
android:id="@+id/activity_webview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/color_FEDA83" />
</LinearLayout>
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