Commit f4c6da2c authored by mengcuiguang's avatar mengcuiguang

添加电魂

parent 77383a63
......@@ -11,11 +11,11 @@ object ZhangyueManager {
const val APPID = "10054"
fun onCreateIreader(application: Application){
fun onCreateIreader(application: Application) {
IreaderApi.onCreate(application, APPID)
}
fun attachBaseContextIreader(application: Application){
fun attachBaseContextIreader(application: Application) {
IreaderApi.attachBaseContext(application)
}
}
\ No newline at end of file
......@@ -82,7 +82,7 @@ class HomePresenter : BasePresenter<HomeView>() {
val message = baseResponse.getMessage()
when (code) {
200 -> view.getHallBaseMsgSuc(baseResponse.getData())
else -> {
else ->{
view.showToast(message)
}
}
......
package com.mints.goodmoney.ui.fragment
import android.content.Intent
import android.content.pm.ApplicationInfo
import android.net.Uri
import android.os.Build
import android.view.View
import android.view.ViewGroup
import android.webkit.WebSettings
import android.webkit.WebViewClient
import com.mints.goodmoney.R
import com.mints.goodmoney.common.AppConfig
import com.mints.goodmoney.common.Constant
import com.mints.goodmoney.manager.UserManager
import com.mints.goodmoney.ui.fragment.base.LazyLoadBaseFragment
import com.mints.goodmoney.utils.LogUtil
import com.mints.goodmoney.utils.MD5
import com.mints.goodmoney.utils.URIEncoder
import kotlinx.android.synthetic.main.fragment_main_dh.*
/**
* 描述:电魂游戏
* 作者:孟崔广
*/
class DhGameFragment : LazyLoadBaseFragment() {
class DhGameFragment : LazyLoadBaseFragment(), View.OnClickListener {
companion object {
const val CHANNEL = "14533"
const val KEY = "4932d9037fd94f6ba24fa09605203cd6"
const val AUTH_URL = "http://www.shandw.com/auth/"
}
private val TAG = DhGameFragment::class.java.simpleName
override fun getContentViewLayoutID() = R.layout.fragment_main_dh
override fun initViewsAndEvents() {
}
override fun onFragmentFirstVisible() {
loadH5Game()
initListener()
}
override fun onDestroy() {
super.onDestroy()
dh_webview?.let {
it.destroyDrawingCache()
val parent = it.getParent() as ViewGroup
parent.removeView(it)
it.removeAllViews()
it.destroy()
}
}
override fun onClick(v: View) {
when (v?.id) {
R.id.ivDhBack -> {
dh_webview.goBack()
}
R.id.tvDhRefresh -> {
loadH5Game()
}
}
}
/**
* 加载H5Game
*/
private fun loadH5Game() {
dh_webview?.let {
var loadUrl = getLoadUrl()
LogUtil.d(TAG, "url-->${loadUrl}")
val settings = it.settings
// 本地 DOM 存储(解决加载某些网页出现白板现象)
settings.domStorageEnabled = true
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
// 解决 Android 5.0 上 WebView 默认不允许加载 Http 与 Https 混合内容
settings.mixedContentMode = WebSettings.MIXED_CONTENT_ALWAYS_ALLOW
}
settings.javaScriptEnabled = true
settings.javaScriptCanOpenWindowsAutomatically = true
it.setWebViewClient(object : WebViewClient() {
override fun shouldOverrideUrlLoading(
view: android.webkit.WebView,
url: String
): Boolean {
if (url.startsWith("weixin://wap/pay?") || url.startsWith("alipay")) {
val hasApp: Boolean
hasApp = if (url.startsWith("weixin://wap/pay?")) {
isAppExist("com.tencent.mm")
} else {
(isAppExist("com.eg.android.AlipayGphone") || isAppExist("com.alipay.android.app"))
}
if (hasApp) {
val intent = Intent()
intent.action = Intent.ACTION_VIEW
intent.data = Uri.parse(url)
activity?.startActivity(intent)
} else {
showToast("客官,请先安装支付App哦~")
}
return true
}
if (url.startsWith("https")) {
val map = HashMap<String, String>()
map["Referer"] = "http://www.shandw.com"
it.loadUrl(url, map)
}
return super.shouldOverrideUrlLoading(view, url)
}
})
it.loadUrl(loadUrl)
}
}
/**
* 获取拼接url
*/
fun getLoadUrl(): String {
val currentTimeMillis = System.currentTimeMillis() / 1000
var loadUrl = "${AUTH_URL}?" +
"channel=${CHANNEL}&" +
"openid=${URIEncoder.encodeURIComponent(UserManager.getInstance().userID)}&" +
"time=${currentTimeMillis}&" +
"nick=${URIEncoder.encodeURIComponent(UserManager.getInstance().userID)}&" +
"avatar=${URIEncoder.encodeURIComponent("https://mints-pkg.oss-cn-beijing.aliyuncs.com/pkg_goodmoney/img/ic_my.png")}&" +
"sex=${0}&" +
"phone=${UserManager.getInstance().mobile}&" +
"sdw_simple=${2}&" +
"sign=${getSignStr(currentTimeMillis)}"
return loadUrl
}
/**
* 获取签名
*/
fun getSignStr(currentTimeMillis: Long): String {
val signStr = "channel=${CHANNEL}&" +
"openid=${URIEncoder.encodeURIComponent(UserManager.getInstance().userID)}&" +
"time=${currentTimeMillis}&" +
"nick=${UserManager.getInstance().userID}&" +
"avatar=https://mints-pkg.oss-cn-beijing.aliyuncs.com/pkg_goodmoney/img/ic_my.png&" +
"sex=${0}&" +
"phone=${UserManager.getInstance().mobile}${KEY}"
return MD5.GetMD5Code(signStr).toLowerCase()
}
fun isAppExist(pkgName: String): Boolean {
var info: ApplicationInfo? = null
try {
context?.getPackageManager()!!.getApplicationInfo(pkgName, 0)
context!!.startActivity(context!!.packageManager.getLaunchIntentForPackage(pkgName))
} catch (e: Exception) {
}
return if (info != null) true else false
}
private fun initListener() {
ivDhBack.setOnClickListener(this)
tvDhRefresh.setOnClickListener(this)
}
}
\ No newline at end of file
......@@ -46,8 +46,6 @@ class HorizChannelFragment : BaseFragment(), HorizChannelView, View.OnClickListe
initChannelFragment()
initListener()
// 调用金币视频信息接口
horizChannelPresenter.getSmallHomeVedioBaseMsg()
}
private fun initListener() {
......@@ -172,6 +170,9 @@ class HorizChannelFragment : BaseFragment(), HorizChannelView, View.OnClickListe
super.onResume()
if (AppConfig.fragmentClickFlag == Constant.FRAGMENT_CLICK_CHANNEL) {
// 调用金币视频信息接口
horizChannelPresenter.getSmallHomeVedioBaseMsg()
channelFragment?.onResume()
}
}
......
......@@ -118,7 +118,6 @@ class MainFragment : BaseFragment(), HomeView, View.OnClickListener {
super.onPause()
littleVideoFragment?.onPause()
// pauseDownloadTime()
}
override fun setUserVisibleHint(isVisibleToUser: Boolean) {
......@@ -130,7 +129,6 @@ class MainFragment : BaseFragment(), HomeView, View.OnClickListener {
super.onDestroy()
cdvvYilanTime?.setCountDownVedioListener(null)
// littleVideoFragment?.setUserCallBack(null)
YLPlayerConfig.config().unRegisterPlayerCallback()
homePresenter.detachView()
......@@ -183,7 +181,7 @@ class MainFragment : BaseFragment(), HomeView, View.OnClickListener {
if (isToCreateReward) {
// 防止界面切换 重置倒计时
// 第一次能过 isFirstLoadVedio 判断好兔先加载视频
// 好兔视频已加载 且 红包已转满 且 奖励已领过
if (!isFirstLoadVedio && !cdvvYilanTime.isPlaying && !isAward) {
cdvvYilanTime?.reset()
cdvvYilanTime?.start()
......@@ -196,6 +194,7 @@ class MainFragment : BaseFragment(), HomeView, View.OnClickListener {
override fun onClick(v: View) {
when (v.id) {
R.id.cdvvYilanTime -> {
// 视频已转满 且 服务返回可以领奖励
if (isAward && isToCreateReward) {
isAward = false
......@@ -264,6 +263,7 @@ class MainFragment : BaseFragment(), HomeView, View.OnClickListener {
}
override fun onStop(p0: String?, p1: String?, p2: String?) {
pauseDownloadTime()
}
})
} else {
......@@ -301,6 +301,7 @@ class MainFragment : BaseFragment(), HomeView, View.OnClickListener {
return
}
// 视频未转满 且 界面切换时可继续加进度
if (!isAward) {
cdvvYilanTime?.resume()
}
......@@ -311,7 +312,6 @@ class MainFragment : BaseFragment(), HomeView, View.OnClickListener {
* 停止转动
*/
private fun stopDownloadTime() {
// 暂停
cdvvYilanTime?.stop()
}
......
......@@ -15,8 +15,6 @@ import com.mints.goodmoney.ui.fragment.base.LazyLoadBaseFragment
import com.mints.goodmoney.utils.SpanUtils
import kotlinx.android.synthetic.main.fragment_main_zy.*
private val TAG = ZhangyueFragment::class.java.simpleName
/**
* 描述:掌阅书城
* 作者:孟崔广
......
package com.mints.goodmoney.utils;
public class URIEncoder {
import java.io.UnsupportedEncodingException;
/*
* 文件名:URIEncode.java
*/
public class URIEncoder
{
public static final String ALLOWED_CHARS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_.!~*'()";
/**
* Description:
*
* @param str
* @return
* @throws UnsupportedEncodingException
* @see
*/
public static String encodeURI(String str)
throws UnsupportedEncodingException
{
String isoStr = new String(str.getBytes("UTF8"), "ISO-8859-1");
char[] chars = isoStr.toCharArray();
StringBuffer sb = new StringBuffer();
for (int i = 0; i < chars.length; i++ )
{
if ((chars[i] <= 'z' && chars[i] >= 'a') || (chars[i] <= 'Z' && chars[i] >= 'A')
|| chars[i] == '-' || chars[i] == '_' || chars[i] == '.' || chars[i] == '!'
|| chars[i] == '~' || chars[i] == '*' || chars[i] == '\'' || chars[i] == '('
|| chars[i] == ')' || chars[i] == ';' || chars[i] == '/' || chars[i] == '?'
|| chars[i] == ':' || chars[i] == '@' || chars[i] == '&' || chars[i] == '='
|| chars[i] == '+' || chars[i] == '$' || chars[i] == ',' || chars[i] == '#'
|| (chars[i] <= '9' && chars[i] >= '0'))
{
sb.append(chars[i]);
}
else
{
sb.append("%");
sb.append(Integer.toHexString(chars[i]));
}
}
return sb.toString();
}
/**
* Description:
*
* @param input
* @return
* @see
*/
public static String encodeURIComponent(String input)
{
if (null == input || "".equals(input.trim()))
{
return input;
}
int l = input.length();
StringBuilder o = new StringBuilder(l * 3);
try
{
for (int i = 0; i < l; i++ )
{
String e = input.substring(i, i + 1);
if (ALLOWED_CHARS.indexOf(e) == -1)
{
byte[] b = e.getBytes("utf-8");
o.append(getHex(b));
continue;
}
o.append(e);
}
return o.toString();
}
catch (UnsupportedEncodingException e)
{
e.printStackTrace();
}
return input;
}
private static String getHex(byte buf[])
{
StringBuilder o = new StringBuilder(buf.length * 3);
for (int i = 0; i < buf.length; i++ )
{
int n = (int)buf[i] & 0xff;
o.append("%");
if (n < 0x10)
{
o.append("0");
}
o.append(Long.toString(n, 16).toUpperCase());
}
return o.toString();
}
}
......@@ -6,10 +6,37 @@
android:background="@color/white"
android:orientation="vertical">
<ImageView
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@mipmap/ic_launcher"/>
android:layout_height="wrap_content">
<ImageView
android:id="@+id/ivDhBack"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_centerVertical="true"
android:layout_marginLeft="10dp"
android:src="@mipmap/ic_arrow_back" />
<TextView
android:id="@+id/tvDhRefresh"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toEndOf="@id/ivDhBack"
android:paddingLeft="10dp"
android:paddingRight="30dp"
android:text="重新加载"
android:textColor="@color/black"
android:textSize="16sp" />
</RelativeLayout>
<WebView
android:id="@+id/dh_webview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fadingEdge="none"
android:overScrollMode="never" />
</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