Commit eacec14a authored by maxiaoliang's avatar maxiaoliang

修改bug

parent 65f239f0
......@@ -183,7 +183,7 @@ class SiginDropsPopupwindow : PopupWindow(), WateringRewardContract.View,
if (data.isPop == 1) {
//首次签到弹窗
// MainDialog.showgetWaterDrop(mContext, 1, "签到", data?.awardNum)
MainDialog.showgetWaterDrop(mContext, 4, "签到", data.awardNum, null)
RxBusUtil.getDefault().send(RxBusConstant.RX_MAIN_TURNTABLE_LOTTERYED)
}
}
......
package com.ym.game.view
import android.annotation.SuppressLint
import android.app.Activity
import android.app.Dialog
import android.content.Context
import android.os.CountDownTimer
......@@ -8,9 +9,12 @@ import android.view.Gravity
import android.view.View
import android.widget.ImageView
import android.widget.TextView
import com.anythink.core.api.ATAdInfo
import com.anythink.core.api.AdError
import com.ym.game.contract.TurntableContract
import com.ym.game.module.TurntableEntity
import com.ym.game.presenter.TurntablePresenter
import com.ym.library.module.AdEntity
import com.ym.library.rxbus.RxBusConstant
import com.ym.library.rxbus.RxBusUtil
import com.ym.library.rxbus.Subscribe
......@@ -18,6 +22,9 @@ import com.ym.library.rxbus.ThreadMode
import com.ym.library.utils.EventUtils
import com.ym.library.utils.LogUtils
import com.ym.library.utils.Utils
import com.ym.module.toponad.AdID
import com.ym.module.toponad.ToponManager
import com.ym.module.toponad.listener.ToponRewardListener
import com.ym.xync.R
......@@ -80,16 +87,16 @@ object TurntableDialog : TurntableUtils(), TurntableContract.View {
btnTurntableLottery?.setOnClickListener {
if (Utils.isFastClick()) {
//开启转盘
btnTurntableLottery?.isEnabled = false
isStartAnim = true
mPresenter?.getTurntableLotteryResult()
if (turntables?.showVideo == 0 && turntables?.countDownSecond!! < 0) {
if (turntables?.showVideo == 0 && turntables?.countDownSecond!! < 0) {
//开启转盘
btnTurntableLottery?.isEnabled = false
isStartAnim = true
mPresenter?.getTurntableLotteryResult()
} else if (turntables?.showVideo == 1) {
//看广告 结束调用转盘结果接口 刷新列表 并开启转盘动画
EventUtils.onEvent("turntable_video_dialog_click", "转盘视频")
// showAd()
showAd()
}
}
}
......@@ -116,58 +123,59 @@ object TurntableDialog : TurntableUtils(), TurntableContract.View {
mDialog?.show()
}
// private fun showAd() {
// ToponManager.loadReward((context as Activity), object : ToponRewardListener {
// override fun onRewardedVideoAdPlayClicked(entity: ATAdInfo) {
// EventUtils.onEvent(
// "ad_click",
// Utils.obj2Str(
// AdEntity(
// entity.networkFirmId,
// AdID.AD_LUCKY_TURNTABLE_VIDEO,
// "幸运转盘激励视频广告"
// )
// )
// )
// }
//
// override fun onRewardedVideoAdClosed(entity: ATAdInfo) {
// reset()
// btnTurntableLottery?.isEnabled = false
// isStartAnim = true
// isUpdate = true
// mPresenter?.getTurntableLotteryResult()
// RxBusUtil.getDefault().send(RxBusConstant.RX_MAIN_REQUEST_TEPORT)
// }
//
// override fun onRewardedVideoAdFailed(errorCode: AdError) {
// reset()
// btnTurntableLottery?.isEnabled = false
// isStartAnim = true
// isUpdate = true
// mPresenter?.getTurntableLotteryResult()
//
// }
//
// override fun onRewardedVideoAdPlayEnd(entity: ATAdInfo) {
// EventUtils.onEvent("ad_ended", Utils.obj2Str(AdEntity("ad_ended", "ad_ended", "幸运转盘激励视频广告")))
// }
//
// override fun onRewardedVideoAdPlayStart(entity: ATAdInfo) {
// EventUtils.onEvent(
// "ad_show",
// Utils.obj2Str(
// AdEntity(
// entity.networkFirmId,
// AdID.AD_LUCKY_TURNTABLE_VIDEO,
// "幸运转盘激励视频广告"
// )
// )
// )
// }
//
// }, AdID.AD_LUCKY_TURNTABLE_VIDEO)
// }
private fun showAd() {
ToponManager.loadReward((context as Activity), object : ToponRewardListener {
override fun onRewardedVideoAdPlayClicked(entity: ATAdInfo) {
EventUtils.onEvent(
"ad_click",
Utils.obj2Str(
AdEntity(
entity.networkFirmId,
AdID.mPlacementId_Reward_video_luck_farm,
"幸运转盘激励视频广告"
)
)
)
}
override fun onRewardedVideoAdClosed(entity: ATAdInfo) {
reset()
btnTurntableLottery?.isEnabled = false
isStartAnim = true
isUpdate = true
mPresenter?.getTurntableLotteryResult()
}
override fun onRewardedVideoAdFailed(errorCode: AdError) {
reset()
btnTurntableLottery?.isEnabled = false
isStartAnim = true
isUpdate = true
mPresenter?.getTurntableLotteryResult()
}
override fun onRewardedVideoAdPlayEnd(entity: ATAdInfo) {
EventUtils.onEvent("ad_ended", Utils.obj2Str(AdEntity("ad_ended", "ad_ended", "幸运转盘激励视频广告")))
}
override fun onRewardedVideoAdPlayStart(entity: ATAdInfo) {
EventUtils.onEvent(
"ad_show",
Utils.obj2Str(
AdEntity(
entity.networkFirmId,
AdID.mPlacementId_Reward_video_luck_farm,
"幸运转盘激励视频广告"
)
)
)
}
}, AdID.mPlacementId_Reward_video_luck_farm)
}
/**
* 获取转盘数据
......@@ -214,7 +222,7 @@ object TurntableDialog : TurntableUtils(), TurntableContract.View {
tvTime?.visibility = View.GONE
btnCountdown?.visibility = View.GONE
btnTurntableLottery?.visibility = View.VISIBLE
// btnTurntableLottery?.setImageResource(R.drawable.icon_main_turntable_free_draw_ad)
btnTurntableLottery?.setBackgroundResource(R.drawable.icon_main_turntable_free_draw_ad)
} else if (data.countDownSecond != null && data.countDownSecond!! > 0) {
//倒计时
tvTime?.visibility = View.VISIBLE
......
......@@ -102,7 +102,7 @@
android:gravity="center"
android:text="免费抽奖"
android:textColor="@color/white"
android:textSize="24sp"
android:textSize="20sp"
android:visibility="visible" />
</RelativeLayout>
......
......@@ -82,6 +82,35 @@
android:scheme="luckyfarm" />
</intent-filter>
</activity>
<activity
android:name=".activity.WebActivity"
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="ad_web"
android:scheme="luckyfarm" />
</intent-filter>
</activity>
<activity
android:name=".activity.NewWebActivity"
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="new_web"
android:scheme="luckyfarm" />
</intent-filter>
</activity>
<!--全屏广告,激励视频-->
<!-- <activity
......
......@@ -28,10 +28,13 @@ import com.ym.library.AppliContext
import com.ym.library.Constant
import com.ym.library.module.NewsEntity
import com.ym.library.net.ApiClient
import com.ym.library.net.BaseObserver
import com.ym.library.net.RxSchedulers
import com.ym.library.net.UserInfoEntity
import com.ym.library.rxbus.RxBusConstant
import com.ym.library.rxbus.RxBusUtil
import com.ym.library.utils.*
import com.ym.library.wechat.UserApiClient
import io.reactivex.Observer
import io.reactivex.disposables.Disposable
import okhttp3.ResponseBody
......@@ -190,7 +193,8 @@ abstract class JavaInterface {
var str = c.getString(c.getColumnIndex(DownloadManager.COLUMN_URI))
Log.i("DownLoadService", str)
val file = File(
Environment.getExternalStorageDirectory().getAbsolutePath() + "/" + Environment.DIRECTORY_DOWNLOADS,
Environment.getExternalStorageDirectory()
.getAbsolutePath() + "/" + Environment.DIRECTORY_DOWNLOADS,
apkName
)
isLoading
......@@ -608,6 +612,54 @@ abstract class JavaInterface {
return SettingPreference.getSignSessionId()
}
@JavascriptInterface
fun jumpSetting() {
JumpUtils.jumpSettingActivity()
}
@JavascriptInterface
fun withDraw() {
val token = SettingPreference.getToken()
UserApiClient.userApi.getIsBindWithdrawWx(token)
.compose(RxSchedulers.observableIO2Main())
.subscribe(object : BaseObserver<UserInfoEntity>() {
override fun onSuccess(data: UserInfoEntity) {
act?.runOnUiThread {
if (data?.isBind == true) {
// val userInfoData = SettingPreference.getUserInfoData()
// userInfoData.isBind = true
// SettingPreference.saveUserInfo(userInfoData)
// var sessionId = ""
// if (mData?.ifUse == 1) {
// showToast("已提现")
// } else {
// if (mData?.id != null) {
// mPresenter?.requestWxWithdraw(mData?.id!!)
// }
// }
mWebView?.loadUrl("javascript:wechat_login_cb()")
} else {
WxImplUtils().onAuth(
act
) { token, openid ->
Log.i("WxImplUtils", "onWxSuccess")
Utils.showToast(act, "登录成功")
}
}
}
}
override fun onFailure(e: Throwable, code: String, errorMsg: String?) {
if (null != errorMsg) {
// mView.wxBindFailure(errorMsg?:"")
}
}
})
}
// @JavascriptInterface
// fun onRewardVideo(codeId: String, coins: String) {
// mWebView?.post {
......@@ -793,7 +845,7 @@ abstract class JavaInterface {
act?.runOnUiThread(Runnable {
RxBusUtil.getDefault().send(RxBusConstant.RX_MAIN_ACTIVITY_TAB, 1)
act?.finish()
// Constant.Utils.ExchangeShopFragmentBackFlag = false
// Constant.Utils.ExchangeShopFragmentBackFlag = false
})
}
......@@ -851,7 +903,7 @@ abstract class JavaInterface {
@JavascriptInterface
fun showWithdrawSucces(cashStr: String) {
mWebView.context.runOnUiThread {
// CenterDialog.showGuideGetMoney(act,cashStr,mWebView)
// CenterDialog.showGuideGetMoney(act,cashStr,mWebView)
}
}
}
\ No newline at end of file
package com.ym.library.activity
import android.app.Dialog
import android.content.Context
import android.graphics.Bitmap
import android.graphics.Color
import android.net.http.SslError
import android.os.Build
import android.text.TextUtils
import android.view.KeyEvent
import android.view.MotionEvent
import android.view.View
import android.webkit.DownloadListener
import android.webkit.SslErrorHandler
import android.webkit.WebView
import android.webkit.WebViewClient
import androidx.annotation.RequiresApi
import androidx.coordinatorlayout.widget.CoordinatorLayout
import com.bumptech.glide.Glide
import com.umeng.analytics.MobclickAgent
import com.ym.library.AppliContext
import com.ym.library.Constant
import com.ym.library.R
import com.ym.library.activity.contract.NewWebContract
import com.ym.library.activity.presenter.NewWebPresenter
import com.ym.library.module.ReportEntity
import com.ym.library.net.BaseActivity
import com.ym.library.rxbus.RxBusConstant
import com.ym.library.rxbus.RxBusUtil
import com.ym.library.utils.*
import com.ym.library.widget.ScrollWebView
import kotlinx.android.synthetic.main.activity_new_web.*
/**
* Created by gaoleichao on 2019/4/22
*/
class NewWebActivity : BaseActivity(), NewWebContract.View, ScrollWebView.OnScrollChangeListener,
DownloadListener,
View.OnClickListener {
override fun layoutID(): Int = R.layout.activity_new_web
private var mPresenter: NewWebContract.Presenter? = null
@RequiresApi(Build.VERSION_CODES.LOLLIPOP)
override fun before() {
super.before()
// StatusBarUtil.setTranslucent(this, resources.getColor(R.color.transparent))
// getWindow().setStatusBarColor(Color.parseColor("#ffffff"));
StatusBarUtil.setLightMode(this)
}
override fun init() {
val lp = app_bar_layout.getLayoutParams() as CoordinatorLayout.LayoutParams
lp.topMargin = getStatusBarHeight(this)
app_bar_layout.layoutParams = lp
mPresenter = NewWebPresenter(
this,
this,
intent,
webview
)
initListener()
if (TextUtils.isEmpty(SettingPreference.getH5Data("guide"))) {
SettingPreference.setH5Data("guide", "1")
id_activity_new_web_guide_layout?.visibility = View.VISIBLE
Glide.with(AppliContext.get()).asGif().load(R.drawable.slide_head)
.into(id_activity_new_web_guide_img)
}
}
/**
* 获取状态栏高度
* @param context
* @return
*/
fun getStatusBarHeight(context: Context): Int {
return context.getResources().getDimensionPixelSize(
context.getResources().getIdentifier("status_bar_height", "dimen", "android")
)
}
override fun closePage() {
finish()
}
override fun loadUrl(url: String) {
webview?.loadUrl(url)
}
override fun setTitle(title: String?) {
// id_activity_web_title?.text = title
}
override fun setTitleEnabled(visibility: Int) {
id_activity_web_titlebar?.visibility = visibility
}
override fun addJavascriptInterface(
javaScriptInterface: NewWebPresenter.NewWebJavaScriptInterface,
name: String
) {
webview?.addJavascriptInterface(javaScriptInterface, name)
}
override fun setCloseVisibility(visibility: Int) {
id_activity_web_close?.visibility = View.VISIBLE
}
override fun setTimerDesc(desc: String) {
id_activity_web_timer_desc?.text = desc
}
override fun setTopDesc(desc: String) {
id_activity_web_top_tips?.text = desc
}
override fun setTopDescVisibity(visibility: Int) {
id_activity_web_top_tips?.visibility = visibility
}
override fun dispatchTouchEvent(ev: MotionEvent?): Boolean {
if (id_activity_new_web_guide_layout?.visibility == View.VISIBLE) {
id_activity_new_web_guide_layout?.visibility = View.GONE
}
mPresenter?.dispatchTouchEvent()
return super.dispatchTouchEvent(ev)
}
override fun setTimerLayoutVisibility(visibility: Int) {
id_activity_web_timer_layout?.visibility = visibility
}
private var isAdds = false
private var isOpen = true
private var showNewCoinsDialog: Dialog? = null
@RequiresApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
override fun showCoinsDialog(coins: Int, value: String) {
// showCoins(coins)
isAdds = true
var text = "阅读奖励 金币+" + coins
if (Constant.kkz_award_render_type == 1) {
CenterDialog.showDialogReadCoins(this, coins, value, object : View.OnClickListener {
override fun onClick(v: View?) {
isAdds = false
mPresenter?.nextUrl()
}
})
} else {
showNewCoinsDialog = CenterDialog.showNewCoinsDialog(this@NewWebActivity, coins)
}
}
override fun setTimerMaxProgress(max: Int) {
// id_activity_web_timer_progress?.maxProgress = max
}
override fun updateTimerProgress(progress: Int) {
// id_activity_web_timer_progress?.progress = progress
}
override fun setBottomDesc(desc: String) {
id_activity_web_bottom_tips?.text = desc
}
override fun setBottomVisibity(visibility: Int) {
id_activity_web_bottom_progress_layout?.visibility = visibility
}
override fun setBottomMaxProgress(progress: Int) {
id_activity_web_bottom_progress?.max = progress
}
override fun updateBottomProgress(progress: Int) {
id_activity_web_bottom_progress?.progress = progress
}
override fun setBottomProgressVisibity(visibility: Int) {
id_activity_web_bottom_progress?.visibility = View.VISIBLE
}
override fun setCurrentNum(num: Int,title: String) {
if (!title.equals("")) {
tv_newweb_title.text = "${title.split(" ")[0]}"
} else {
tv_newweb_title.text = "看4篇可得2000金币"
}
if (num == 0) {
id_read_round_1.setBackgroundResource(R.drawable.shape_c9c9c9_r)
id_read_line_1.setBackgroundColor(Color.parseColor("#c9c9c9"))
id_read_round_2.setBackgroundResource(R.drawable.shape_c9c9c9_r)
id_read_line_2.setBackgroundColor(Color.parseColor("#c9c9c9"))
id_read_round_3.setBackgroundResource(R.drawable.shape_c9c9c9_r)
id_read_line_3.setBackgroundColor(Color.parseColor("#c9c9c9"))
id_read_round_4.setBackgroundResource(R.drawable.shape_c9c9c9_r)
} else if (num == 1) {
id_read_round_1.setBackgroundResource(R.drawable.shape_0090ff_r)
id_read_line_1.setBackgroundColor(Color.parseColor("#0090ff"))
id_read_round_2.setBackgroundResource(R.drawable.shape_c9c9c9_r)
id_read_line_2.setBackgroundColor(Color.parseColor("#c9c9c9"))
id_read_round_3.setBackgroundResource(R.drawable.shape_c9c9c9_r)
id_read_line_3.setBackgroundColor(Color.parseColor("#c9c9c9"))
id_read_round_4.setBackgroundResource(R.drawable.shape_c9c9c9_r)
} else if (num == 2) {
id_read_round_1.setBackgroundResource(R.drawable.shape_0090ff_r)
id_read_line_1.setBackgroundColor(Color.parseColor("#0090ff"))
id_read_round_2.setBackgroundResource(R.drawable.shape_0090ff_r)
id_read_line_2.setBackgroundColor(Color.parseColor("#0090ff"))
id_read_round_3.setBackgroundResource(R.drawable.shape_c9c9c9_r)
id_read_line_3.setBackgroundColor(Color.parseColor("#c9c9c9"))
id_read_round_4.setBackgroundResource(R.drawable.shape_c9c9c9_r)
} else if (num == 3) {
id_read_round_1.setBackgroundResource(R.drawable.shape_0090ff_r)
id_read_line_1.setBackgroundColor(Color.parseColor("#0090ff"))
id_read_round_2.setBackgroundResource(R.drawable.shape_0090ff_r)
id_read_line_2.setBackgroundColor(Color.parseColor("#0090ff"))
id_read_round_3.setBackgroundResource(R.drawable.shape_0090ff_r)
id_read_line_3.setBackgroundColor(Color.parseColor("#0090ff"))
id_read_round_4.setBackgroundResource(R.drawable.shape_c9c9c9_r)
} else if (num == 4) {
id_read_round_1.setBackgroundResource(R.drawable.shape_0090ff_r)
id_read_line_1.setBackgroundColor(Color.parseColor("#0090ff"))
id_read_round_2.setBackgroundResource(R.drawable.shape_0090ff_r)
id_read_line_2.setBackgroundColor(Color.parseColor("#0090ff"))
id_read_round_3.setBackgroundResource(R.drawable.shape_0090ff_r)
id_read_line_3.setBackgroundColor(Color.parseColor("#0090ff"))
id_read_round_4.setBackgroundResource(R.drawable.shape_0090ff_r)
}
}
private fun initListener() {
/* id_activity_web_go_home?.setOnClickListener {
webview?.loadUrl(mPresenter?.getHomeUrl())
}*/
webview?.setOnLongClickListener {
val result = webview?.hitTestResult
?: return@setOnLongClickListener false
if (result.type == WebView.HitTestResult.IMAGE_TYPE) {
// 检查权限。Manifest.permission.WRITE_EXTERNAL_STORAGE
// CenterDialog.showDialogSavePic(this, object : View.OnClickListener {
// override fun onClick(v: View?) {
// mPresenter?.savePic(result.extra)
// }
// })
// return@setOnLongClickListener true
}
return@setOnLongClickListener false
}
id_activity_web_back_layout?.setOnClickListener {
if (webview?.canGoBack() == true) {
webview?.goBack()
} else {
finish()
}
}
id_activity_web_close?.setOnClickListener { finish() }
webview?.setOnScrollChangeListener(this)
webview?.setDownloadListener(this)
webview?.webChromeClient = object : MyWebChromeClient() {
override fun onProgressChanged(webView: WebView, i: Int) {
if (i != 100) {
id_activity_web_progress?.progress = i
} else {
id_activity_web_progress?.visibility = View.GONE
}
}
}
webview?.webViewClient = object : WebViewClient() {
override fun onPageStarted(view: WebView, urls: String, favicon: Bitmap?) {
mPresenter?.onPageStarted(urls)
super.onPageStarted(view, urls, favicon)
}
override fun shouldOverrideUrlLoading(view: WebView, url: String): Boolean {
return mPresenter?.shouldOverrideUrlLoading(url) ?: false
}
override fun onPageFinished(view: WebView, urls: String) {
super.onPageFinished(view, urls)
mPresenter?.onPageFinished(urls)
}
override fun onReceivedSslError(
view: WebView,
handler: SslErrorHandler,
error: SslError
) {
handler.proceed() // 接受所有网站的证书
}
}
}
override fun onPageEnd(l: Int, t: Int, oldl: Int, oldt: Int) {
}
override fun onPageTop(l: Int, t: Int, oldl: Int, oldt: Int) {
}
override fun onScrollChanged(l: Int, t: Int, oldl: Int, oldt: Int) {
mPresenter?.onScrollChanged()
}
override fun onDownloadStart(
url: String?,
userAgent: String?,
contentDisposition: String?,
mimetype: String?,
contentLength: Long
) {
mPresenter?.onDownloadStart(url)
}
override fun onKeyDown(keyCode: Int, event: KeyEvent): Boolean {
println("id_webview?.canGoBack():" + webview?.canGoBack())
if (keyCode == KeyEvent.KEYCODE_BACK) {
if (webview?.canGoBack() == true) {
webview?.goBack()
return true
} else {
return super.onKeyDown(keyCode, event)
}
}
return super.onKeyDown(keyCode, event)
}
override fun finish() {
if (isAdds == true) {
super.finish()
} else {
CenterDialog.showSignOutDialog(this, this)
}
}
override fun onClick(v: View?) {
super.finish()
}
override fun onDestroy() {
super.onDestroy()
if (showNewCoinsDialog != null) {
showNewCoinsDialog?.dismiss()
}
webview?.visibility = View.GONE
}
override fun onResume() {
super.onResume()
if (webview != null) {
webview?.loadUrl("javascript:onResume()")
}
EventUtils.onEvent("page_status", Utils.obj2Str(ReportEntity(Constant.ReportSessionId, "NewWebActivity", "onResume")))
MobclickAgent.onResume(this)
}
override fun onPause() {
super.onPause()
RxBusUtil.getDefault()
.send(RxBusConstant.RX_MAIN_HIGH_WATER_DROP_UPDATE)
MobclickAgent.onPause(this)
EventUtils.onEvent("page_status", Utils.obj2Str(ReportEntity(Constant.ReportSessionId, "NewWebActivity", "onPause")))
if (webview != null) {
// webview?.loadUrl("javascript:onPause()")
}
}
}
\ No newline at end of file
package com.ym.library.activity
import android.annotation.SuppressLint
import android.app.Activity
import android.content.Intent
import android.content.pm.PackageManager
import android.graphics.Bitmap
import android.graphics.PixelFormat
import android.net.Uri
import android.net.http.SslError
import android.os.Build
import android.text.TextUtils
import android.util.Log
import android.view.*
import android.webkit.*
import androidx.annotation.RequiresApi
import com.badoo.mobile.util.WeakHandler
import com.umeng.analytics.MobclickAgent
import com.umeng.socialize.UMShareAPI
import com.ym.library.AppliContext
import com.ym.library.Constant
import com.ym.library.R
import com.ym.library.module.CoinEntity
import com.ym.library.module.NewsEntity
import com.ym.library.module.ReportEntity
import com.ym.library.module.TaskEntity
import com.ym.library.net.ApiClient
import com.ym.library.net.BaseActivity
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.*
import com.ym.library.widget.ScrollWebView
import kotlinx.android.synthetic.main.activity_new_web.*
import kotlinx.android.synthetic.main.activity_web.*
import kotlinx.android.synthetic.main.activity_web.id_activity_web_back_layout
import kotlinx.android.synthetic.main.activity_web.id_activity_web_close
import kotlinx.android.synthetic.main.activity_web.id_activity_web_progress
import kotlinx.android.synthetic.main.activity_web.id_activity_web_timer_desc
import kotlinx.android.synthetic.main.activity_web.id_activity_web_timer_layout
import kotlinx.android.synthetic.main.activity_web.id_activity_web_titlebar
import kotlinx.android.synthetic.main.activity_web.id_activity_web_top_tips
import kotlinx.android.synthetic.main.activity_web.webview
import java.util.regex.Pattern
/**
* Created by gaoleichao on 2018/5/8.
*/
class WebActivity : BaseActivity(), View.OnClickListener {
private val TAG = "WebActivity"
private val INIT: Int = 1
private val ING: Int = 2
private val PAUSE: Int = 3
private val STOP: Int = 4
private val START: Int = 5
private val OVER: Int = 6
private var status: Int = INIT
private var videoSrc: String? = null
private var mUrlList: MutableList<String>? = null
private var title: String? = null
private var url: String = ""
private var slot_id: String? = null
private var alert: String? = null
private var deep_url_re: String? = null
private var timeTrigger: String? = null
private var incentive_level: Int = 0
private var sid: Int = 0
private var delay: Int = 0
private var mJavaInterFace: WebJavaScriptInterface? = null
private var mWeakHandler: WeakHandler? = null
private var isAdd = false
private var isReward = false
private var pkg: String? = null
private var session_id: String = ""
private var alertRenderType: String? = ""
private var isKeyEnabled: Boolean = false
private var mCurrentTime: Int = 0
private var isSuc = false
private var mPageUrl = ""
private var mUploadMessage: ValueCallback<Uri>? = null
private var mUploadCallbackAboveL: ValueCallback<Array<Uri>>? = null
private val PERMISSION_CAMERA = 101
private var imageUri: Uri? = null
private var isPhotoCannle: Boolean = false
override fun layoutID(): Int {
return R.layout.activity_web
}
override fun before() {
super.before()
StatusBarUtil.setLightMode(this)
}
override fun init() {
initData()
initView()
// initPhotoDialog)
initWebView()
setOnListener()
}
private fun initData() {
// 完整的url信息
title = intent.getStringExtra("title") ?: ""
url = intent.getStringExtra("url") ?: ""
alert = intent.getStringExtra("alert") ?: ""
slot_id = intent.getStringExtra("slot_id") ?: ""
deep_url_re = intent.getStringExtra("deep_url_re") ?: ""
timeTrigger = intent.getStringExtra("timeTrigger") ?: ""
alertRenderType = intent.getStringExtra("alertRenderType") ?: ""
val incentive = intent.getStringExtra("incentive_level") ?: ""
if (!TextUtils.isEmpty(incentive) && !TextUtils.equals(incentive, "null")) {
incentive_level = Integer.valueOf(incentive)
}
val de = intent.getStringExtra("delay") ?: ""
if (!TextUtils.isEmpty(de) && !TextUtils.equals(de, "null")) {
delay = Integer.valueOf(de)
}
val s = intent.getStringExtra("sid") ?: ""
if (!TextUtils.isEmpty(s) && !TextUtils.equals(s, "null")) {
sid = Integer.valueOf(s)
}
if (TextUtils.isEmpty(url)) {
finish()
}
session_id = Utils.md5(url)
mWeakHandler = WeakHandler()
}
private fun initView() {
window.setFormat(PixelFormat.TRANSLUCENT)
if (TextUtils.isEmpty(title) || TextUtils.equals(title, "null")) {
id_activity_web_title?.text = ""
} else {
id_activity_web_title?.text = title
}
if (incentive_level == 3 || incentive_level == 7 || incentive_level == 8) {
mUrlList = arrayListOf()
queryTask()
}
webview?.setDelay(delay)
}
private fun setOnListener() {
id_activity_web_back_layout?.setOnClickListener {
if (webview?.canGoBack() == true) {
webview?.goBack()
} else {
finish()
}
}
id_activity_web_close?.setOnClickListener { finish() }
webview?.setOnScrollChangeListener(object : ScrollWebView.OnScrollChangeListener {
override fun onPageEnd(l: Int, t: Int, oldl: Int, oldt: Int) {
}
override fun onPageTop(l: Int, t: Int, oldl: Int, oldt: Int) {
}
override fun onScrollChanged(l: Int, t: Int, oldl: Int, oldt: Int) {
if (!TextUtils.equals(
Utils.replaceAll(url),
Utils.replaceAll(mPageUrl)
) && (incentive_level == 3 || incentive_level == 8)
) {
if (TextUtils.isEmpty(mPageUrl)) {
return
}
if (mUrlList?.contains(mPageUrl) != true) {
if (status == INIT) {
mCurrentTime = 0
startTimer()
}
}
}
if (incentive_level == 7) {
if (status == INIT) {
mCurrentTime = 0
startTimer()
}
}
}
})
webview?.setDownloadListener(DownloadListener { url, userAgent, contentDisposition, mimetype, contentLength ->
if (!TextUtils.isEmpty(videoSrc) && !TextUtils.equals(videoSrc, "null")) {
} else {
try {
val uri = Uri.parse(url)
val intent = Intent(Intent.ACTION_VIEW, uri)
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
AppliContext.get().startActivity(intent)
} catch (e: Exception) {
}
}
})
webview?.webChromeClient = object : MyWebChromeClient() {
override fun onProgressChanged(webView: WebView, i: Int) {
if (i != 100) {
id_activity_web_progress?.progress = i
} else {
id_activity_web_progress?.visibility = View.GONE
}
if (i == 100) {
if (isAdd) {
return
}
if (incentive_level == 1) {
if (delay > 0) {
if (!TextUtils.isEmpty(alert) && !TextUtils.equals(alert, "null")) {
setTimerLayoutView(alert ?: "")
} else {
setTimerLayoutView("")
}
startTimer()
} else {
mJavaInterFace?.addCoin(
url
?: return, CoinEntity.EXTERNAL_SDK_AD_TYPE
)
}
} else if (incentive_level == 2) {
if (!TextUtils.isEmpty(alert) && !TextUtils.equals(alert, "null")) {
setTimerLayoutView(alert ?: "")
} else {
setTimerLayoutView("")
}
}
}
}
}
webview?.webViewClient = object : WebViewClient() {
override fun onPageStarted(view: WebView, urls: String, favicon: Bitmap?) {
if (!TextUtils.equals(urls, url)) {
id_activity_web_close?.visibility = View.VISIBLE
} else {
id_activity_web_close?.visibility = View.GONE
}
super.onPageStarted(view, url, favicon)
}
override fun shouldOverrideUrlLoading(view: WebView, url: String): Boolean {
Log.d("glc", url)
if (TextUtils.isEmpty(url)) return false
try {
if (!url.startsWith("http") && !url.startsWith("https") && !url.startsWith("ftp")) {
val intent = Intent(Intent.ACTION_VIEW, Uri.parse(url))
if (isInstall(intent)) {
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
AppliContext.get().startActivity(intent)
}
return true
}
} catch (e: Exception) {
return false
}
return false
}
override fun onPageFinished(view: WebView, urls: String) {
super.onPageFinished(view, urls)
mPageUrl = urls
if (incentive_level == 2) {
if (isAdd) {
return
}
if (TextUtils.isEmpty(deep_url_re) || TextUtils.equals(deep_url_re, "null")) {
return
}
val url = view.url
if (TextUtils.isEmpty(url)) {
return
}
try {
val pattern = Pattern.compile(deep_url_re)
if (!isReward && null != pattern && pattern.matcher(url).matches()) {
isReward = true
val entity = NewsEntity()
entity.sid = sid
entity.slot_id = slot_id
// AdUpload.onDeepClick(entity)
if (delay > 0) {
startTimer()
} else {
mJavaInterFace?.addCoin(
mPageUrl
?: return, CoinEntity.EXTERNAL_SDK_AD_TYPE
)
}
}
} catch (e: Exception) {
}
}
if (!TextUtils.isEmpty(videoSrc) && !TextUtils.equals(videoSrc, "null")) {
webview?.loadUrl("javascript:videoPlay()")
}
if (incentive_level == 8) {
mCurrentTime = 0
id_activity_web_timer_progress?.progress = mCurrentTime
RxTimerUtil.cancel()
status = INIT
}
if (!TextUtils.equals(url, mPageUrl)) {
// EventUtils.onH5AdClick(session_id, mPageUrl)
}
}
override fun onReceivedSslError(view: WebView, handler: SslErrorHandler, error: SslError) {
handler.proceed() // 接受所有网站的证书
}
}
}
@SuppressLint("JavascriptInterface")
private fun initWebView() {
webview?.loadUrl(url)
mJavaInterFace = WebJavaScriptInterface(this, webview)
// if (sid == 1919) {
webview?.addJavascriptInterface(mJavaInterFace, "android")
// } else {
// webview?.addJavascriptInterface(mJavaInterFace, "novel")
// }
}
private fun coins(url: String, type: Int) {
Log.d("WebActivity", " in:" + incentive_level)
ApiClient.userApi.addCoins(Utils.md5(url), 201, sid.toString(), slot_id?:"")
.compose(RxSchedulers.observableIO2Main())
.subscribe(object : BaseObserver<CoinEntity>() {
@RequiresApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
override fun onSuccess(result: CoinEntity?) {
if (result != null && result.coins > 0) {
var text = "阅读奖励 金币+" + result.coins
CenterDialog.showNewCoinsDialog(this@WebActivity, result.coins)
isSuc = true
status = OVER
setTimerLayoutGone()
id_activity_web_top_tips?.visibility = View.GONE
id_activity_web_top_tips?.text = ""
} else {
isAdd = false
if (sid == 347) {
Utils.showToast(applicationContext, "搜索完成次数+1")
}
if (incentive_level == 3 || incentive_level == 7 || incentive_level == 8) {
mUrlList?.add(url)
queryTask()
}
}
}
override fun onFailure(e: Throwable, code: String, errorMsg: String) {
isAdd = false
if ((incentive_level == 3 || incentive_level == 8) && TextUtils.equals("155", code)) {
mUrlList?.add(url)
}
if (incentive_level == 3 || incentive_level == 7 || incentive_level == 8) {
queryTask()
}
if (TextUtils.equals("105", code)) {
Utils.showToast(AppliContext.get(), errorMsg)
}
}
})
}
override fun onDestroy() {
super.onDestroy()
webview?.visibility = View.GONE
RxTimerUtil.cancel()
if (null != webview) {
webview?.loadUrl("javascript:onDestroy()")
webview?.destroy()
}
}
override fun onBackPressed() {
super.onBackPressed()
if (null != webview && webview?.canGoBack() == true) {
webview?.goBack()
}
}
override fun onResume() {
super.onResume()
if (webview != null) {
webview?.loadUrl("javascript:onResume()")
}
EventUtils.onEvent("page_status", Utils.obj2Str(
ReportEntity(
Constant.ReportSessionId,
"WebActivity",
"onResume"
)
))
MobclickAgent.onResume(this)
}
override fun onPause() {
super.onPause()
if (webview != null) {
webview?.loadUrl("javascript:onPause()")
}
RxTimerUtil.cancel()
status = INIT
EventUtils.onEvent("page_status", Utils.obj2Str(
ReportEntity(
Constant.ReportSessionId,
"WebActivity",
"onPause"
)
))
MobclickAgent.onPause(this)
RxBusUtil.getDefault()
.send(RxBusConstant.RX_MAIN_HIGH_WATER_DROP_UPDATE)
}
private fun queryTask() {
if (sid == 0) {
return
}
ApiClient.taskApi.queryTaskStatus(sid.toString(), slot_id?:"").compose(RxSchedulers.observableIO2Main(this))
.subscribe(object : BaseObserver<TaskEntity>() {
override fun onSuccess(entity: TaskEntity?) {
if (entity == null || TextUtils.isEmpty(entity.coins) || TextUtils.equals(entity.coins, "null")) {
return
}
if (entity.delay > 0) {
delay = entity.delay
status = INIT
}
if (incentive_level == 3 || incentive_level == 8) {
if (TextUtils.equals("1", alertRenderType)) {
id_activity_web_top_tips?.visibility = View.GONE
if (!TextUtils.isEmpty(entity.alert) && !TextUtils.equals(entity.alert, "null")) {
setTimerLayoutView(entity.alert)
} else {
setTimerLayoutView("")
}
} else {
id_activity_web_top_tips?.visibility = View.VISIBLE
id_activity_web_top_tips?.text = entity.alert?.replace("\n", "")
setTimerLayoutGone()
}
}
if (incentive_level == 7) {
if (TextUtils.equals("1", alertRenderType)) {
id_activity_web_top_tips?.visibility = View.GONE
if (!TextUtils.isEmpty(entity.alert) && !TextUtils.equals(entity.alert, "null")) {
setTimerLayoutView(entity.alert)
} else {
setTimerLayoutView("")
}
} else {
id_activity_web_top_tips?.visibility = View.VISIBLE
id_activity_web_top_tips?.text = entity.alert?.replace("\n", "")
setTimerLayoutGone()
}
}
}
override fun onFailure(e: Throwable, code: String, errorMsg: String) {
}
})
}
private fun setTimerLayoutView(alert: String) {
id_activity_web_timer_layout?.visibility = View.VISIBLE
id_activity_web_timer_desc?.text = alert
id_activity_web_timer_progress?.maxProgress = delay
id_activity_web_timer_progress?.progress = 0
}
private fun setTimerLayoutGone() {
id_activity_web_timer_layout?.visibility = View.GONE
id_activity_web_timer_progress?.progress = 0
}
//判断app是否安装
private fun isInstall(intent: Intent): Boolean {
return AppliContext.get().packageManager.queryIntentActivities(
intent,
PackageManager.MATCH_DEFAULT_ONLY
).size > 0
}
override fun onKeyDown(keyCode: Int, event: KeyEvent): Boolean {
return if (keyCode == KeyEvent.KEYCODE_BACK) {
if (isKeyEnabled) {
true
} else {
super.onKeyDown(keyCode, event)
}
} else {
super.onKeyDown(keyCode, event)
}
}
internal inner class WebJavaScriptInterface(context: Activity, mWebView: WebView) :
JavaInterface(context, mWebView) {
@android.webkit.JavascriptInterface
fun getIncentiveLevel(): Int = incentive_level
@android.webkit.JavascriptInterface
fun getVideoSrc(): String {
return videoSrc ?: ""
}
@android.webkit.JavascriptInterface
fun setVideoSrc(video: String) {
videoSrc = video
}
@android.webkit.JavascriptInterface
fun setKeyEnabled(isEnabled: Boolean) {
isKeyEnabled = isEnabled
runOnUiThread {
id_activity_web_titlebar?.visibility = if (isEnabled) View.GONE else View.VISIBLE
}
}
@android.webkit.JavascriptInterface
fun hideTitleBar() {
runOnUiThread {
StatusBarUtil.setTranslucent(this@WebActivity, resources.getColor(R.color.transparent))
id_activity_web_parent?.fitsSystemWindows = false
id_activity_web_titlebar?.visibility = View.GONE
}
}
@android.webkit.JavascriptInterface
fun setPkg(pg: String) {
pkg = pg
}
// onApiPost()
// onApiGet()
// onLoadFullVideo()
// onShowFullVideo()
@android.webkit.JavascriptInterface
fun addCoin(url: String, type: Int) {
if (isAdd) {
return
}
isAdd = true
if (sid == 0) {
return
}
mWeakHandler?.postDelayed(
{ coins(url, type) },
(if (incentive_level == 1 || incentive_level == 2 || incentive_level == 3 || incentive_level == 7 || incentive_level == 8) 0 else delay * 1000).toLong()
)
}
}
private fun startTimer() {
if (status == OVER || status == ING || status == STOP) {
return
}
RxTimerUtil.cancel()
if (status == INIT) {
beginTimer()
}
}
private fun beginTimer() {
status = ING
RxTimerUtil.interval(1000) {
mCurrentTime++
if (TextUtils.equals(alertRenderType, "1")) {
id_activity_web_timer_progress?.progress = mCurrentTime
}
if (mCurrentTime >= delay) {
RxTimerUtil.cancel()
status = STOP
if (incentive_level == 1) {
mJavaInterFace?.addCoin(
mPageUrl
?: return@interval, CoinEntity.EXTERNAL_SDK_AD_TYPE
)
} else if (incentive_level == 2) {
mJavaInterFace?.addCoin(
mPageUrl
?: return@interval, CoinEntity.EXTERNAL_SDK_AD_TYPE
)
} else {
mJavaInterFace?.addCoin(mPageUrl ?: return@interval, 201)
}
}
}
}
override fun dispatchTouchEvent(ev: MotionEvent): Boolean {
if (TextUtils.equals(timeTrigger, "1")) {
if (incentive_level == 7 || incentive_level == 8 || incentive_level == 3) {
if (status == INIT) {
startTimer()
}
}
}
return super.dispatchTouchEvent(ev)
}
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
try {
UMShareAPI.get(this).onActivityResult(requestCode, resultCode, data)
} catch (ex: java.lang.Exception) {
}
}
override fun finish() {
if (incentive_level == 2 || incentive_level == 8 || incentive_level == 9 || incentive_level == 11) {
if (!isAdd) {
CenterDialog.showSignOutDialog(this, this)
} else {
super.finish()
}
} else {
super.finish()
}
}
override fun onClick(v: View?) {
super.finish()
}
}
package com.ym.library.activity.contract
import com.ym.library.activity.presenter.NewWebPresenter
/**
* Created by gaoleichao on 2019/4/22
*/
class NewWebContract {
interface View {
fun closePage()
fun loadUrl(url: String)
fun setTitle(title: String?)
fun setTitleEnabled(visibility: Int)
fun addJavascriptInterface(javaScriptInterface: NewWebPresenter.NewWebJavaScriptInterface, name: String)
fun setCloseVisibility(visibility: Int)
fun setTimerDesc(desc: String)
fun setTopDesc(desc: String)
fun setTopDescVisibity(visibility: Int)
fun setTimerLayoutVisibility(visibility: Int)
fun setTimerMaxProgress(max: Int)
fun updateTimerProgress(progress: Int)
fun showCoinsDialog(coins: Int,string: String)
fun setBottomDesc(desc: String)
fun setCurrentNum(num: Int,title: String)
fun setBottomVisibity(visibility: Int)
fun setBottomMaxProgress(progress: Int)
fun updateBottomProgress(progress: Int)
fun setBottomProgressVisibity(visibility: Int)
}
interface Presenter {
fun savePic(path: String)
fun onScrollChanged()
fun onDownloadStart(url: String?)
fun onPageStarted(newUrl: String)
fun onPageFinished(url: String)
fun shouldOverrideUrlLoading(url: String): Boolean
fun dispatchTouchEvent()
fun getHomeUrl():String
fun nextUrl()
}
}
\ No newline at end of file
package com.ym.library.activity.presenter
import android.app.Activity
import android.content.Intent
import android.net.Uri
import android.text.TextUtils
import android.util.Log
import android.view.View
import android.webkit.WebView
import com.ym.library.AppliContext
import com.ym.library.activity.JavaInterface
import com.ym.library.module.AdStatusEntity
import com.ym.library.module.CoinEntity
import com.ym.library.module.NewsEntity
import com.ym.library.net.ApiClient
import com.ym.library.net.BaseObserver
import com.ym.library.net.RxSchedulers
import com.ym.library.net.ZXADClient
import com.ym.library.utils.EventUtils
import com.ym.library.utils.MainLooper
import com.ym.library.utils.RxTimerUtil
import com.ym.library.utils.Utils
import com.ym.library.widget.ScrollWebView
import com.ym.library.activity.contract.NewWebContract
/**
* Created by gaoleichao on 2019/4/22
*/
class NewWebPresenter : NewWebContract.Presenter {
private val mView: NewWebContract.View
private val mActivity: Activity
private val intent: Intent
private val mJavaInterFace: NewWebJavaScriptInterface
private val INIT: Int = 1
private val ING: Int = 2
private val PAUSE: Int = 3
private val STOP: Int = 4
private val START: Int = 5
private val OVER: Int = 6
private var STATUS: Int = INIT
private var mPageUrl: String = ""
constructor(mView: NewWebContract.View, mActivity: Activity, intent: Intent, webview: ScrollWebView) {
this.mView = mView
this.mActivity = mActivity
this.intent = intent
mJavaInterFace = NewWebJavaScriptInterface(mActivity, webview)
initData(intent)
}
private var title: String? = ""
private var oldUrl: String = ""
private var slot_id: String = ""
private var sid: Int = 0
private var session_id: String = ""
private fun initData(intent: Intent) {
// val uri = intent.data
if (intent != null) {
// 完整的url信息
title = intent?.data?.getQueryParameter("title") ?: ""
oldUrl = intent?.data?.getQueryParameter("url") ?: ""
slot_id = intent?.data?.getQueryParameter("slot_id") ?: ""
val s = intent?.data?.getQueryParameter("sid") ?: ""
if (!TextUtils.isEmpty(s) && !TextUtils.equals(s, "null")) {
sid = Integer.valueOf(s)
}
session_id = Utils.md5(oldUrl)
}
if (TextUtils.isEmpty(oldUrl)) {
Utils.showToast(AppliContext.get(), "url is null")
mView.closePage()
} else {
mView.loadUrl(oldUrl)
}
if (TextUtils.isEmpty(title) || TextUtils.equals(title, "null")) {
mView.setTitle("")
} else {
mView.setTitle(title)
}
if (sid == 1919) {
mView.addJavascriptInterface(mJavaInterFace, "android")
} else {
mView.addJavascriptInterface(mJavaInterFace, "novel")
}
}
override fun savePic(path: String) {
// mJavaInterFace?.savePic(path)
}
override fun onScrollChanged() {
if (!isKeyDown() && (alertRenderType == 1 || alertRenderType == 2 || alertRenderType == 3) && STATUS == INIT) {
//开启计时器
startTimer(mPageUrl)
}
}
override fun onDownloadStart(url: String?) {
try {
val uri = Uri.parse(url)
val intent = Intent(Intent.ACTION_VIEW, uri)
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
AppliContext.get().startActivity(intent)
} catch (e: Exception) {
}
}
override fun onPageStarted(newUrl: String) {
if (!TextUtils.equals(newUrl, oldUrl)) {
mView.setCloseVisibility(View.VISIBLE)
} else {
mView.setCloseVisibility(View.GONE)
}
if ((alertRenderType == 1 || alertRenderType == 2 || alertRenderType == 3) && STATUS == ING && redirect_reset == 1) {
stopTimer()
} else {
RxTimerUtil.cancel()
STATUS = OVER
}
}
override fun onPageFinished(url: String) {
mPageUrl = url
getAdStatus(mPageUrl/*, Base64.encodeToString(url.toByteArray(), Base64.URL_SAFE)*/)
}
override fun shouldOverrideUrlLoading(url: String): Boolean {
if (TextUtils.isEmpty(url)) return false
try {
if (!url.startsWith("http") && !url.startsWith("https") && !url.startsWith("ftp")) {
val intent = Intent(Intent.ACTION_VIEW, Uri.parse(url))
if (Utils.isInstall(intent)) {
mActivity.startActivity(intent)
return true
}
}
} catch (e: Exception) {
return false
}
return false
}
override fun dispatchTouchEvent() {
if (isKeyDown() && (alertRenderType == 1 || alertRenderType == 2 || alertRenderType == 3) && STATUS == INIT) {
//开启计时器
EventUtils.onEvent("kkz_page_slide")
startTimer(mPageUrl)
}
}
private var redirect_reset: Int = 0
private var time_trigger: Int = 0
private var delay = 0
private var alertRenderType = 0
private var adSign: String = ""
private var status: Int = 0
private var progressStatus: Int = 0
private fun getAdStatus(sUrl: String/*, url: String*/) {
Log.d("glc", "sUrl" + sUrl)
ApiClient.adApi.getAdStatus(slot_id, sid, sUrl, Utils.md5(sUrl)).compose(RxSchedulers.observableIO2Main())
.subscribe(object : BaseObserver<AdStatusEntity>() {
override fun onSuccess(result: AdStatusEntity?) {
if (result != null) {
status = result.status ?: 0
delay = result.delay ?: 0
adSign = result.adSign ?: ""
progressStatus = result.progressStatus ?: 0
if (result.alertRenderType == 1) {
setTimerViewMode(result.alert ?: "")
} else if (result.alertRenderType == 2) {
setTopViewMode(result.alert ?: "")
} else if (result.alertRenderType == 3) {
// setBottomViewMode(result.alert ?: "")
if (delay > 0 && status == 1 && progressStatus == 0) {
// mView.setBottomMaxProgress(delay)
// mView.setBottomProgressVisibity(View.VISIBLE)
STATUS = INIT
}
mView.setCurrentNum(result.current_nums ?: 0,result?.alert?:"")
}
if (result.delay == 0) {
//加金币
addCoins(sUrl)
}
alertRenderType = result.alertRenderType ?: 0
redirect_reset = result.redirect_reset ?: 0//1是 0否
time_trigger = result.time_trigger ?: 0//1按下 其他滑动 2代表直接计时
}
}
override fun onFailure(e: Throwable?, code: String?, errorMsg: String?) {
}
})
}
private fun setTopViewMode(alert: String) {
mView.setTimerLayoutVisibility(View.GONE)
mView.setBottomVisibity(View.GONE)
STATUS = INIT
mView.setTimerDesc("")
mView.setTopDescVisibity(View.VISIBLE)
mView.setTopDesc(alert)
}
private fun setBottomViewMode(alert: String) {
mView.setTimerLayoutVisibility(View.GONE)
mView.setTopDescVisibity(View.GONE)
mView.setBottomVisibity(View.VISIBLE)
mView.setBottomDesc(alert)
if (delay > 0 && status == 1 && progressStatus == 0) {
mView.setBottomMaxProgress(delay)
mView.setBottomProgressVisibity(View.VISIBLE)
STATUS = INIT
} else {
mView.setBottomProgressVisibity(View.GONE)
}
}
private fun setTimerViewMode(alert: String) {
mView.setTimerDesc(alert)
mView.setTopDesc("")
mView.setBottomVisibity(View.GONE)
mView.setTopDescVisibity(View.GONE)
if (delay > 0 && status == 1) {
//计时器初始化
mView.setTimerMaxProgress(delay)
mView.setTimerLayoutVisibility(View.VISIBLE)
STATUS = INIT
} else {
mView.setTimerLayoutVisibility(View.GONE)
}
}
private fun updateProgress() {
if (alertRenderType == 1) {
mView.updateTimerProgress(mCurrentProgress)
} else if (alertRenderType == 3) {
mView.updateBottomProgress(mCurrentProgress)
}
}
private var mCurrentProgress: Int = 0
private fun startTimer(url: String) {
Log.d("NewWebPresenter", "startTimer")
STATUS = START
RxTimerUtil.interval(1000) {
if (STATUS == START) {
STATUS = ING
}
mCurrentProgress++
updateProgress()
Log.d("NewWebPresenter", "progress:" + mCurrentProgress)
if (mCurrentProgress >= delay) {
if (STATUS == ING) {
stopTimer()
addCoins(url)
}
}
}
}
private fun stopTimer() {
RxTimerUtil.cancel()
STATUS = OVER
mCurrentProgress = 0
updateProgress()
}
private fun isKeyDown(): Boolean {
return time_trigger == 1
}
private fun isResetTimer(): Boolean {
return redirect_reset == 1
}
private fun addCoins(url: String) {
ApiClient.userApi.readAddCoins(
Utils.md5(url),
201,
sid.toString(),
slot_id,
adSign
).compose(RxSchedulers.observableIO2Main()).subscribe(object : BaseObserver<CoinEntity>() {
override fun onSuccess(result: CoinEntity?) {
println("onFailure$url")
if (result != null && result.coins > 0) {
mView.showCoinsDialog(result.coins, result.leftAward ?: "")
}
getAdStatus(url)
}
override fun onFailure(e: Throwable, code: String, errorMsg: String) {
println("onFailure$errorMsg")
if (TextUtils.equals("105", code)) {
Utils.showToast(AppliContext.get(), errorMsg)
}
}
})
}
private var keyEnabled: Boolean? = true
private var videoSrc: String = ""
inner class NewWebJavaScriptInterface(context: Activity, mWebView: WebView) : JavaInterface(context, mWebView) {
@android.webkit.JavascriptInterface
fun getVideoSrc(): String {
return videoSrc
}
@android.webkit.JavascriptInterface
fun setVideoSrc(video: String) {
videoSrc = video
}
@android.webkit.JavascriptInterface
fun setKeyEnabled(isEnabled: Boolean) {
keyEnabled = isEnabled
MainLooper.get()?.post(Runnable {
mView.setTitleEnabled(if (isEnabled) View.GONE else View.VISIBLE)
})
}
@android.webkit.JavascriptInterface
fun setPkg(pg: String) {
// pkg = pg
}
@android.webkit.JavascriptInterface
fun addCoin(url: String, type: Int) {
// if (isAdd) {
// return
// }
// isAdd = true
// if (sid == 0) {
// return
// }
// mWeakHandler?.postDelayed({ coins(url, type) }, (if (incentive_level == 1 || incentive_level == 2 || incentive_level == 3 || incentive_level == 7 || incentive_level == 8) 0 else delay * 1000).toLong())
// }
}
}
override fun getHomeUrl(): String {
return oldUrl
}
override fun nextUrl() {
ZXADClient.adApi.getAd("kkz").compose(RxSchedulers.observableIO2Main())
.subscribe(object : BaseObserver<List<NewsEntity>>() {
override fun onSuccess(result: List<NewsEntity>?) {
var data: NewsEntity? = null
result?.forEach {
if (it.status == 0) {
data = it
return@forEach
}
}
if (data != null) {
oldUrl = data?.url ?: ""
slot_id = data?.slot_id ?: ""
title = data?.title ?: ""
sid = data?.sid ?: 0
session_id = Utils.md5(oldUrl)
mView.loadUrl(oldUrl)
onPageFinished(oldUrl)
} else {
Utils.showToast(AppliContext.get(), "您已经完成全部任务了")
}
}
override fun onFailure(e: Throwable?, code: String?, errorMsg: String?) {
Utils.showToast(AppliContext.get(), errorMsg)
Utils.getStatusBarHeight()
}
})
}
}
\ No newline at end of file
......@@ -15,7 +15,7 @@ interface IUserApi {
*
* @return
*/
@GET( "api/v1/version/com.ym.xync")
@GET("api/v1/version/com.ym.xync")
fun getVersion(): Observable<Response<VersionEntity>>
/**
......@@ -39,7 +39,10 @@ interface IUserApi {
*/
@GET(NetConfig.User.URL_USER_WITHDRAW_BIND_WX)
fun bindWx(@Query("openId") oppenid: String,@Query("token") token: String): Observable<Response<WxBindEntity>>
fun bindWx(
@Query("openId") oppenid: String,
@Query("token") token: String
): Observable<Response<WxBindEntity>>
/**
* h5-post接口
......@@ -58,4 +61,31 @@ interface IUserApi {
*/
@GET
fun webApiGet(@Url url: String): Observable<retrofit2.Response<ResponseBody>>
/**
* 加金币接口
*
* @return
*/
@POST(NetConfig.Ad.URL_AD_NEW_GET_STATUS)
fun readAddCoins(
@Query("md5") md5: String,
@Query("type") type: Long,
@Query("adId") sid: String,
@Query("slot_id") slot_id: String,
@Query("adSign") adSign: String
): Observable<Response<CoinEntity>>
/**
* @param
* @param
* @return
*/
@POST(NetConfig.User.URL_TASK_ADD_COINS)
fun addCoins(
@Query("md5") sessionId: String,
@Query("type") type: Int,
@Query("sid") sid: String,
@Query(
"slot_id"
) slot_id: String
): Observable<Response<CoinEntity>>
}
\ No newline at end of file
......@@ -226,7 +226,7 @@ interface RounterApi {
) sid: String
): Intent
@RounterUri(Constant.scheme + "://web")
@RounterUri(Constant.scheme + "://ad_web")
fun getIntentAdWeb(
@RounterParam("incentive_level") incentive_level: String,
@RounterParam("alert") alert: String,
......
......@@ -3,13 +3,16 @@ package com.ym.library.utils
import android.annotation.SuppressLint
import android.app.Activity
import android.app.Dialog
import android.os.Build
import android.os.CountDownTimer
import android.text.TextUtils
import android.view.Gravity
import android.view.View
import android.widget.FrameLayout
import android.widget.ImageView
import android.widget.RelativeLayout
import android.widget.TextView
import androidx.annotation.RequiresApi
import com.anythink.core.api.ATAdInfo
import com.anythink.core.api.AdError
import com.anythink.nativead.api.ATNativeAdView
......@@ -323,7 +326,103 @@ object CenterDialog : BaseDialog() {
mDialog?.show()
countDown(3000, tv_time, img_close)
}
var coinsDialog: Dialog? = null
@RequiresApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
fun showNewCoinsDialog(context: Activity, rewardCoins: Int): Dialog? {
coinsDialog = Dialog(context, R.style.CenterCompatDialogTheme)
val mDialogView: View? = showBottomDialog(R.layout.dialog_coins, context, coinsDialog!!, 0, Gravity.CENTER)
val mCoinsText: TextView = mDialogView!!.findViewById(R.id.id_dialog_coins_num)
coinsDialog?.window?.setDimAmount(0f)
mCoinsText.text = rewardCoins.toString()
mCoinsText.postDelayed(Runnable {
if (context == null || context.isDestroyed() || context.isFinishing()) {
return@Runnable
}
coinsDialog?.dismiss()
}, 2000)
try {
if (context != null && !context.isDestroyed() && !context.isFinishing()) {
coinsDialog?.show()
}
} catch (e: Exception) {
}
return coinsDialog
}
fun showDialogReadCoins(
activity: Activity?,
coins: Int,
value: String,
onClickListener: View.OnClickListener
) {
if (activity == null) {
return
}
val mDialog = Dialog(activity, R.style.UpdateVersionCompatDialogTheme)
val mDialogView =
showBottomDialog(R.layout.dialog_read_coins, activity, mDialog, 0, Gravity.CENTER)
var closeImg = mDialogView.findViewById<ImageView>(R.id.id_dialog_read_coins_close)
var mDesc = mDialogView.findViewById<TextView>(R.id.id_dialog_read_coins_desc)
var mValue = mDialogView.findViewById<TextView>(R.id.id_dialog_read_coins_value)
var mBtn = mDialogView.findViewById<TextView>(R.id.id_dialog_read_coins_btn)
mValue?.text = "+" + coins + "金币"
if (TextUtils.equals(value, "0")) {
mDesc?.text = "恭喜您,任务达成"
mBtn?.text = "立即提现"
} else {
mBtn?.text = "继续赚"
// mDesc?.text = Html.fromHtml("再赚<font color=\"#FF6B6B\">${value}</font>金币即可提现")
}
closeImg?.setOnClickListener {
mDialog?.dismiss()
}
mBtn.setOnClickListener {
mDialog?.dismiss()
if (TextUtils.equals(value, "0")) {
mDialog?.dismiss()
activity.finish()
JumpUtils.withdrawCash()
EventUtils.onEvent("kkz_go_withdraw_click")
} else {
EventUtils.onEvent("kkz_continue_click")
onClickListener.onClick(it)
}
}
mDialog?.setCancelable(false)
mDialog?.show()
}
/**
* 退出弹窗
*/
fun showSignOutDialog(activity: Activity, callBack: View.OnClickListener) {
if (activity == null) {
return
}
Constant.isDialogActivity = 1
val mDialog = Dialog(activity, R.style.UpdateVersionCompatDialogTheme)
val mDialogView = showBottomDialog(R.layout.dialog_sign_out_layout, activity, mDialog, 0, Gravity.CENTER)
val closeImg = mDialogView.findViewById<ImageView>(R.id.dialog_scratch_dialog_close_img)
val btn = mDialogView.findViewById<TextView>(R.id.dialog_scratch_dialog_bg)
val cancelBtn = mDialogView.findViewById<TextView>(R.id.dialog_scratch_dialog_cancel)
closeImg?.setOnClickListener {
mDialog?.dismiss()
}
btn?.setOnClickListener {
mDialog?.dismiss()
}
cancelBtn?.setOnClickListener {
callBack.onClick(it)
activity?.finish()
}
mDialog?.setCancelable(false)
mDialog?.show()
}
/**
* 倒计时
......
package com.ym.library.utils
import android.os.Environment
import com.ym.library.AppliContext
import com.ym.library.Constant
import java.io.File
import java.io.FileInputStream
import java.text.DecimalFormat
/**
* Created by gaoleichao on 2018/8/31.
*/
object FileUtils {
fun getDownLoadDiectory(): String {
var photoDir = AppliContext.get().getExternalFilesDir("download")
var path = if (photoDir != null) photoDir!!.absolutePath
else
Environment.getExternalStorageDirectory().absolutePath + File.separator + "com.zxhl.weather" + File.separator + "download"
return path
}
fun getWebViewCacheDiectory(): String {
return AppliContext.get().filesDir.absolutePath + "/webcache"
}
//删除指定文件夹下所有文件
//param path 文件夹完整绝对路径
fun delAllFile(path: String): Boolean {
var flag = false
val file = File(path)
if (!file.exists()) {
return flag
}
if (!file.isDirectory) {
return flag
}
val tempList = file.list()
var temp: File? = null
for (i in tempList!!.indices) {
if (path.endsWith(File.separator)) {
temp = File(path + tempList[i])
} else {
temp = File(path + File.separator + tempList[i])
}
if (temp.isFile) {
temp.delete()
}
if (temp.isDirectory) {
delAllFile(path + "/" + tempList[i])//先删除文件夹里面的文件
// delFolder(path + "/" + tempList[i])//再删除空文件夹
flag = true
}
}
return flag
}
/**
* 调用此方法自动计算指定文件或指定文件夹的大小
*
* @param filePath 文件路径
* @return 计算好的带B、KB、MB、GB的字符串
*/
fun getAutoFileOrFilesSize(filePath: String): String {
val file = File(filePath)
var blockSize: Long = 0
try {
if (file.isDirectory) {
blockSize = getFileSizes(file)
} else {
blockSize = getFileSize(file)
}
} catch (e: Exception) {
e.printStackTrace()
}
return FormetFileSize(blockSize)
}
/**
* 获取指定文件夹
*
* @param f
* @return
* @throws Exception
*/
private fun getFileSizes(f: File): Long {
var size: Long = 0
val flist = f.listFiles()
try {
for (i in flist!!.indices) {
if (flist[i].isDirectory) {
size = size + getFileSizes(flist[i])
} else {
size = size + getFileSize(flist[i])
}
}
} catch (e: Exception) {
}
return size
}
/**
* 获取指定文件大小
*
* @param file
* @return
* @throws Exception
*/
private fun getFileSize(file: File): Long {
var size: Long = 0
try {
if (file.exists()) {
var fis: FileInputStream? = null
fis = FileInputStream(file)
size = fis?.available().toLong()
} else {
file.createNewFile()
}
} catch (e: Exception) {
}
return size
}
fun getCacheFileSize(): String {
val file1 = AppliContext.get().cacheDir
val file2 = AppliContext.get().externalCacheDir
val fileSizes = getFileSizes(file1)
val fileSizes2 = getFileSizes(file2)
return FormetFileSize(fileSizes + fileSizes2)
}
fun clearAllCache(): Boolean {
val externalCacheDir = AppliContext.get().externalCacheDir
val cacheDir = AppliContext.get().cacheDir
var result = false
if (cacheDir != null) {
result = delAllFile(cacheDir?.absolutePath)
}
if (externalCacheDir != null) {
result = delAllFile(externalCacheDir?.absolutePath) || result//原生是真 或者现在是true就是true
}
return result
}
/**
* 转换文件大小
*
* @param fileS
* @return
*/
private fun FormetFileSize(fileS: Long): String {
val df = DecimalFormat("#.00")
var fileSizeString = ""
val wrongSize = "0B"
if (fileS == 0L) {
return wrongSize
}
if (fileS < 1024) {
fileSizeString = df.format(fileS.toDouble()) + "B"
} else if (fileS < 1048576) {
fileSizeString = df.format(fileS.toDouble() / 1024) + "KB"
} else if (fileS < 1073741824) {
fileSizeString = df.format(fileS.toDouble() / 1048576) + "MB"
} else {
fileSizeString = df.format(fileS.toDouble() / 1073741824) + "GB"
}
return fileSizeString
}
fun getPhotoDirectory(): String {
var photoDir = AppliContext.get().getExternalFilesDir("photos")
var path = if (photoDir != null) photoDir?.absolutePath
else
Environment.getExternalStorageDirectory().absolutePath + File.separator + Constant.Param.mPacketName + File.separator + "photos"
return path
}
}
package com.ym.library.utils;
import android.annotation.TargetApi;
import android.net.Uri;
import android.os.Build;
import android.webkit.ValueCallback;
import android.webkit.WebChromeClient;
import android.webkit.WebView;
/**
* Copyright @ 2018 Bitgoose All rights reserved.
*
* @class name: MyWebChromeClient
* @class describe:
* @author: fuxin
* @date: 2019/1/21 下午6:44
*/
public class MyWebChromeClient extends WebChromeClient {
/**
* For Android 3.0-
*/
public void openFileChooser(ValueCallback<Uri> uploadMsg) {
}
/**
* For Android 3.0+
*/
public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType) {
}
/**
* For Android 4.1+
*/
public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType, String capture) {
}
/**
* For Android 5.0+
*/
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public boolean onShowFileChooser(WebView mWebView, ValueCallback<Uri[]> filePathCallback, FileChooserParams fileChooserParams) {
return super.onShowFileChooser(mWebView,filePathCallback,fileChooserParams);
}
}
package com.ym.library.utils;
import android.util.Log;
import java.util.concurrent.TimeUnit;
import io.reactivex.Observable;
import io.reactivex.Observer;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.annotations.NonNull;
import io.reactivex.disposables.Disposable;
/**
* Created by gaoleichao on 2018/8/6.
*/
public class RxTimerUtil {
private static Disposable mTimerDisposable;
private static Disposable mIntervalDisposable;
private static Disposable mDisposable;
/**
* milliseconds毫秒后执行next操作
*
* @param milliseconds
* @param next
*/
public static void timer(long milliseconds, final IRxNext next) {
Observable.timer(milliseconds, TimeUnit.SECONDS)
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Observer<Long>() {
@Override
public void onSubscribe(@NonNull Disposable disposable) {
mDisposable = disposable;
}
@Override
public void onNext(@NonNull Long number) {
if (next != null) {
next.doNext(number);
}
}
@Override
public void onError(@NonNull Throwable e) {
//取消订阅
LogUtils.d("RxTimerUtil", "timer:onError");
cancel();
}
@Override
public void onComplete() {
//取消订阅
LogUtils.d("RxTimerUtil", "timer:onComplete");
cancel();
}
});
}
/**
* 每隔milliseconds毫秒后执行next操作
*
* @param milliseconds
* @param next
*/
public static void interval(long milliseconds, final IRxNext next) {
cancel();
Observable.interval(milliseconds, TimeUnit.MILLISECONDS)
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Observer<Long>() {
@Override
public void onSubscribe(@NonNull Disposable disposable) {
mDisposable = disposable;
}
@Override
public void onNext(@NonNull Long number) {
if (next != null) {
next.doNext(number);
}
}
@Override
public void onError(@NonNull Throwable e) {
Log.d("RxTimerUtil", "interval:onComplete");
}
@Override
public void onComplete() {
Log.d("RxTimerUtil", "interval:onComplete");
}
});
}
/**
* 取消订阅
*/
public static void cancel() {
if (mDisposable != null && !mDisposable.isDisposed()) {
mDisposable.dispose();
}
}
public interface IRxNext {
void doNext(long number);
}
}
package com.ym.library.wechat
import com.ym.library.module.*
import com.ym.library.net.NetConfig
import com.ym.library.net.Response
import com.ym.library.net.UserInfoEntity
import io.reactivex.Observable
import okhttp3.ResponseBody
import retrofit2.http.*
/**
* Created by Antonio on 2019/5/15.
*/
interface IUserInfoApi {
/**
* 拉取提现配置
*
* @return
*/
@POST(NetConfig.Withdraw.URL_USER_WITHDRA_LIST)
fun getWithdrawList(): Observable<Response<List<WithdrawEntity>>>
/**
* 微信提现
*
* @return
*/
@POST(NetConfig.Withdraw.URL_USER_GS_DO_WD)
fun getUserWxWithdraw(@Query("wdId") wdId: Int): Observable<Response<WithdrawEntity>>
/**
* 微信是否绑定
*
* @return
*/
@GET(NetConfig.User.URL_USER_ISBINDWITHDRAWWX)
fun getIsBindWithdrawWx(@Query("token") token: String):
Observable<Response<UserInfoEntity>>
/**
* 提现记录
*
* @return
*/
@GET(NetConfig.Withdraw.URL_USER_WD_HISTORY)
fun getUserhiWithdrawHistory(): Observable<Response<List<WithdrawEntity>>>
/**
* 注意事项
*
* @return
*/
@GET(NetConfig.User.URL_USER_MIND)
fun getUserMind(): Observable<Response<UserInfoEntity>>
/**
* 注意事项
*
* @return
*/
@GET(NetConfig.User.URL_USER_COIN2CASH_CHECK)
fun getUserCoin2cash_check(): Observable<Response<WithdrawEntity>>
/**
* 我的抽奖提现
*
* @return
*/
@POST(NetConfig.Withdraw.URL_USER_GS_DO_LOTTERY_WD)
fun getUserWxWithdrawLottery(@Query("sessionId") sessionId: String): Observable<Response<WithdrawEntity>>
/**
* 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
package com.ym.library.wechat
import android.text.TextUtils
import com.ym.library.Constant
import com.ym.library.net.NetConfig
import com.ym.library.utils.PhoneUtils
import com.ym.library.utils.SettingPreference
import okhttp3.*
import okhttp3.logging.HttpLoggingInterceptor
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory
import retrofit2.converter.gson.GsonConverterFactory
import java.util.concurrent.TimeUnit
/**
* Created by gaoleichao on 2018/5/2.
*/
object UserApiClient {
private val logInterceptor = HttpLoggingInterceptor()
private val paramsInterceptor = Interceptor { chain ->
val request = chain.request()
val builder = request.url().newBuilder()
if (request.url().toString().contains("yilan")) {
chain.proceed(request.newBuilder().build())
} else {
PhoneUtils.addParam(request, builder)
chain.proceed(request.newBuilder().url(builder.build()).build())
}
}
private val headInterceptor = Interceptor { chain ->
val request = chain.request()
val builder = request.newBuilder()
builder.addHeader(Constant.aid, SettingPreference.getAndroidId())
builder.addHeader(Constant.Device.env, Constant.Param.env)
if (!TextUtils.isEmpty(SettingPreference.getUserAgent())) {
builder.addHeader("web-user-agent", SettingPreference.getUserAgent())
builder.removeHeader("User-Agent")
builder.addHeader("User-Agent", SettingPreference.getUserAgent())
}
val headers: Request = builder.build()
chain.proceed(headers)
}
private val httpClient = okhttp3.OkHttpClient.Builder()
.connectTimeout(10000, TimeUnit.MILLISECONDS)
.readTimeout(10000, TimeUnit.MILLISECONDS)
.addInterceptor(logInterceptor.apply {
level = HttpLoggingInterceptor.Level.BODY
})
// .retryOnConnectionFailure(false)
.hostnameVerifier { hostname, session ->
true
}
.addInterceptor(paramsInterceptor)
.addInterceptor(headInterceptor)
.build()!!
private val retrofit = retrofit2.Retrofit.Builder()
.client(httpClient)
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
.addConverterFactory(GsonConverterFactory.create())
.baseUrl(NetConfig.BASE_FEED_URL)
.build()
val userApi by lazy { retrofit.create(IUserInfoApi::class.java) }
}
\ No newline at end of file
package com.ym.library.widget;
import android.content.Context;
import android.os.Build;
import android.util.AttributeSet;
import android.webkit.CookieManager;
import android.webkit.WebSettings;
import android.webkit.WebView;
import com.ym.library.utils.FileUtils;
/**
* Created by gaoleichao on 2018/5/26.
*/
public class ScrollWebView extends WebView {
public ScrollWebView(Context context) {
super(context);
init();
}
public ScrollWebView(Context context, AttributeSet attrs) {
super(context, attrs);
init();
}
public ScrollWebView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
init();
}
private int delay;
public void setDelay(int delay) {
this.delay = delay;
}
private void init() {
WebSettings webSettings = getSettings();
webSettings.setJavaScriptEnabled(true);
webSettings.setDefaultTextEncodingName("UTF-8");
webSettings.setBuiltInZoomControls(false);
webSettings.setSupportZoom(false);
webSettings.setPluginState(WebSettings.PluginState.ON);
webSettings.setLoadsImagesAutomatically(true);
webSettings.setAllowFileAccess(true);
webSettings.setAllowContentAccess(true);
webSettings.setCacheMode(WebSettings.LOAD_DEFAULT);
webSettings.setDomStorageEnabled(true);
webSettings.setUseWideViewPort(true);
webSettings.setLoadWithOverviewMode(true);
webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NARROW_COLUMNS);
webSettings.setAppCachePath(FileUtils.INSTANCE.getWebViewCacheDiectory());
webSettings.setAppCacheEnabled(true);
webSettings.setAllowUniversalAccessFromFileURLs(true);
webSettings.setAllowFileAccessFromFileURLs(false);
webSettings.setJavaScriptCanOpenWindowsAutomatically(true);
CookieManager.getInstance().setAcceptCookie(true);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
setWebContentsDebuggingEnabled(true);
}
}
@Override
protected void onScrollChanged(int l, int t, int oldl, int oldt) {
super.onScrollChanged(l, t, oldl, oldt);
float webcontent = getContentHeight() * getScale();// webview的高度
float webnow = getHeight() + getScrollY();// 当前webview的高度
if (Math.abs(webcontent - webnow) < 1) {
// 已经处于底端
// LogUtils.i("TAG1", "已经处于底端");
listener.onPageEnd(l, t, oldl, oldt);
} else if (getScrollY() == 0) {
// LogUtils.i("TAG1", "已经处于顶端");
listener.onPageTop(l, t, oldl, oldt);
}
listener.onScrollChanged(l, t, oldl, oldt);
}
private long lastTime;
public OnScrollChangeListener listener;
public void setOnScrollChangeListener(OnScrollChangeListener listener) {
this.listener = listener;
}
public interface OnScrollChangeListener {
void onPageEnd(int l, int t, int oldl, int oldt);
void onPageTop(int l, int t, int oldl, int oldt);
void onScrollChanged(int l, int t, int oldl, int oldt);
}
}
package com.ym.library.widget;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.RectF;
import android.graphics.Typeface;
import android.util.AttributeSet;
import android.view.View;
import com.bumptech.glide.Glide;
import com.bumptech.glide.request.target.SimpleTarget;
import com.bumptech.glide.request.transition.Transition;
import com.ym.library.AppliContext;
import com.ym.library.R;
import com.ym.library.utils.Utils;
/**
* Created by huchen on 2017/12/1.
*/
public class TimerReadProgressBar extends View {
private int mMaxProgress = 100;
private int mProgress = 0;
private int mCenterText = 0;
private final int mCircleLineStrokeWidth = Utils.dip2px(4);
// 画圆所在的距形区域
private RectF mRectF;
private RectF mBitmapRectF;
private RectF mCenterRectF;
private Paint mPaint;
private int dp5, dp11, dp8, dp38, dp44, mTextSize;
private Bitmap mProgressBg, mCenterBg;
public TimerReadProgressBar(Context context) {
super(context);
init();
}
public TimerReadProgressBar(Context context, AttributeSet attrs) {
super(context, attrs);
init();
}
private void init() {
mRectF = new RectF();
mBitmapRectF = new RectF();
mCenterRectF = new RectF();
mPaint = new Paint();
dp11 = Utils.dip2px(11);
dp5 = Utils.dip2px(3);
dp8 = Utils.dip2px(7);
dp38 = Utils.dip2px(19);
dp44 = Utils.dip2px(22);
mTextSize = Utils.dip2px(18);
Glide.with(AppliContext.get()).asBitmap().load(R.drawable.icon_timer_read_bg).into(new SimpleTarget<Bitmap>() {
@Override
public void onResourceReady(Bitmap resource, Transition<? super Bitmap> transition) {
mProgressBg = resource;
}
});
Glide.with(AppliContext.get()).asBitmap().load(R.drawable.icon_timer_read_center_bg).into(new SimpleTarget<Bitmap>() {
@Override
public void onResourceReady(Bitmap resource, Transition<? super Bitmap> transition) {
mCenterBg = resource;
}
});
setBackgroundResource(R.drawable.icon_timer_read_bg);
setPaint();
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
int width = this.getWidth();
int height = this.getHeight();
if (width != height) {
int min = Math.min(width, height);
width = min;
height = min;
}
if (mPaint == null) {
return;
}
drawProgress(canvas, width, height);
if (0 == getProgress()) {
drawCenterCenterIcon(canvas, width, height);
} else {
drawProgressText(canvas, width, height);
}
}
private String mTextContent;
private void drawProgressText(Canvas canvas, int cx, int cy) {
mPaint.setColor(0xfff7403b);
mPaint.setTextSize(mTextSize);
mPaint.setTypeface(Typeface.DEFAULT_BOLD);
mPaint.setStrokeWidth(0);
mTextContent = mProgress + "s";
float textWidth = mPaint.measureText(mTextContent);
canvas.drawText(mTextContent, (cx / 2) - textWidth / 2, (cx / 2) + (mTextSize / 2 - dp5), mPaint);
}
private void drawCenterCenterIcon(Canvas canvas, int width, int height) {
mCenterRectF.left = dp44;
mCenterRectF.top = dp38;
mCenterRectF.right = width - dp44;
mCenterRectF.bottom = height - dp38;
if (mCenterBg != null && !mCenterBg.isRecycled()) {
canvas.drawBitmap(mCenterBg, null, mCenterRectF, mPaint);
}
}
private void drawProgress(Canvas canvas, int width, int height) {
mRectF.left = dp11; // 左上角x
mRectF.top = dp11; // 左上角y
mRectF.right = width - dp11; // 左下角x
mRectF.bottom = height - dp11; // 右下角y
mPaint.setColor(0xfff7403b);
mPaint.setStyle(Paint.Style.STROKE);
mPaint.setStrokeWidth(mCircleLineStrokeWidth);
canvas.drawArc(mRectF, -90, ((float) mProgress / mMaxProgress) * 360, false, mPaint);
}
private void setPaint() {
// 设置画笔相关属性
mPaint.setAntiAlias(true);
}
public int getMaxProgress() {
return mMaxProgress;
}
public void setMaxProgress(int maxProgress) {
this.mMaxProgress = maxProgress;
}
public void setProgress(int progress) {
if (progress >= mMaxProgress) {
this.mProgress = 0;
} else {
this.mProgress = progress;
}
this.invalidate();
}
public int getProgress() {
return mProgress;
}
public void setProgressNotInUiThread(int progress) {
this.mProgress = progress;
this.postInvalidate();
}
@Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
}
}
<?xml version ="1.0" encoding ="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:useLevel="false">
<solid android:color="#91EBF9"/>
<corners android:radius="8dp"/>
</shape>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@android:id/background">
<shape>
<!--<corners android:radius="5dip" />-->
<gradient
android:startColor="#00000000"
android:centerColor="#00000000"
android:centerY="0.75"
android:endColor="#00000000"
android:angle="270"
/>
</shape>
</item>
<item android:id="@android:id/secondaryProgress">
<clip>
<shape>
<!--<corners android:radius="5dip" />-->
<gradient
android:startColor="#80ffd300"
android:centerColor="#80ffb600"
android:centerY="0.75"
android:endColor="#a0ffcb00"
android:angle="270"
/>
</shape>
</clip>
</item>
<item android:id="@android:id/progress">
<clip>
<shape>
<!--<corners android:radius="5dip" />-->
<solid android:color="@color/color_ffd000"/>
</shape>
</clip>
</item>
</layer-list>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<solid android:color="#0090ff"/>
<size
android:width="12dp"
android:height="12dp"/>
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<size
android:width="12dp"
android:height="12dp"/>
<solid android:color="#ffffff"/>
<stroke
android:width="1.5dp"
android:color="#c9c9c9"/>
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#f0f0f0"/>
<corners android:radius="10dp"/>
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="6dp" />
<solid android:color="#75000000" />
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:fitsSystemWindows="false">
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/app_bar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:elevation="0dp">
<RelativeLayout
android:id="@+id/id_activity_web_titlebar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/white"
android:paddingLeft="18dp">
<RelativeLayout
android:id="@+id/id_activity_web_back_layout"
android:layout_width="32dp"
android:layout_height="match_parent">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:src="@drawable/back_img" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/id_activity_web_close"
android:layout_width="32dp"
android:layout_height="match_parent"
android:layout_toRightOf="@id/id_activity_web_back_layout">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:src="@drawable/icon_activity_web_close" />
</RelativeLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginRight="40dp"
android:layout_centerInParent="true"
android:orientation="vertical"
android:gravity="center_horizontal">
<!-- <TextView
android:id="@+id/id_activity_web_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:maxLength="8"
android:maxLines="1"
android:textColor="@color/color_343434"
android:textSize="17sp"
android:visibility="gone" />-->
<!-- <ImageView
android:id="@+id/id_activity_web_go_home"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="@drawable/go_home" />-->
<TextView
android:id="@+id/tv_newweb_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="看4篇可得2000金币"
android:textColor="#ff222222"
android:textSize="12sp"
android:layout_marginBottom="8dp"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="20dp"
android:background="@drawable/shape_f0f0f0_r9"
android:gravity="center_vertical"
android:paddingLeft="20dp"
android:paddingRight="20dp">
<View
android:id="@+id/id_read_round_1"
android:layout_width="12dp"
android:layout_height="12dp"
android:background="@drawable/shape_c9c9c9_r"/>
<View
android:id="@+id/id_read_line_1"
android:layout_width="34dp"
android:layout_height="1dp"
android:background="#c9c9c9"/>
<View
android:id="@+id/id_read_round_2"
android:layout_width="12dp"
android:layout_height="12dp"
android:background="@drawable/shape_c9c9c9_r"/>
<View
android:id="@+id/id_read_line_2"
android:layout_width="34dp"
android:layout_height="1dp"
android:background="#c9c9c9"/>
<View
android:id="@+id/id_read_round_3"
android:layout_width="12dp"
android:layout_height="12dp"
android:background="@drawable/shape_c9c9c9_r"/>
<View
android:id="@+id/id_read_line_3"
android:layout_width="34dp"
android:layout_height="1dp"
android:background="#c9c9c9"/>
<View
android:id="@+id/id_read_round_4"
android:layout_width="12dp"
android:layout_height="12dp"
android:background="@drawable/shape_c9c9c9_r"/>
</LinearLayout>
</LinearLayout>
</RelativeLayout>
</com.google.android.material.appbar.AppBarLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
android:orientation="vertical"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<com.ym.library.widget.ScrollWebView
android:id="@+id/webview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/transparent" />
<RelativeLayout
android:id="@+id/id_activity_web_timer_layout"
android:layout_width="wrap_content"
android:layout_height="73dp"
android:layout_marginTop="30dp"
android:visibility="gone">
<TextView
android:id="@+id/id_activity_web_timer_desc"
android:layout_width="229.5dp"
android:layout_height="47.5dp"
android:layout_centerVertical="true"
android:layout_marginRight="-42dp"
android:gravity="center_vertical"
android:lineSpacingExtra="1dp"
android:paddingLeft="62dp"
android:textColor="@color/white"
android:textSize="14sp" />
</RelativeLayout>
<ProgressBar
android:id="@+id/id_activity_web_progress"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="3dp"
android:layout_alignParentTop="true"
android:progressBackgroundTint="@android:color/transparent"
android:progressDrawable="@drawable/progress_web_color" />
<TextView
android:id="@+id/id_activity_web_top_tips"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#99000000"
android:paddingLeft="16dp"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:textColor="@color/white"
android:visibility="gone" />
<RelativeLayout
android:id="@+id/id_activity_web_bottom_progress_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#99000000"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:visibility="gone">
<ProgressBar
android:id="@+id/id_activity_web_bottom_progress"
style="@android:style/Widget.ProgressBar.Horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:visibility="gone" />
<TextView
android:id="@+id/id_activity_web_bottom_tips"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/id_activity_web_bottom_progress"
android:layout_marginTop="8dp"
android:paddingBottom="10dp"
android:textColor="@color/white" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/id_activity_new_web_guide_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="15dp"
android:visibility="gone">
<ImageView
android:id="@+id/id_activity_new_web_guide_img"
android:layout_width="47.5dp"
android:layout_height="64dp" />
<ImageView
android:id="@+id/id_activity_new_web_guide_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/id_activity_new_web_guide_img"
android:layout_marginTop="5dp"
android:background="@drawable/jiantou" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/id_activity_new_web_guide_icon"
android:layout_marginTop="-1dp"
android:layout_toRightOf="@+id/id_activity_new_web_guide_icon"
android:includeFontPadding="false"
android:text="向上滑动开始阅读任务"
android:textColor="#368EF7"
android:textSize="14sp" />
</RelativeLayout>
</RelativeLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/id_activity_web_parent"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:orientation="vertical">
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/app_bar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:elevation="0dp">
<RelativeLayout
android:id="@+id/id_activity_web_titlebar"
android:layout_width="match_parent"
android:background="#FFFFFF"
android:layout_height="?attr/actionBarSize"
android:paddingLeft="18dp">
<RelativeLayout
android:id="@+id/id_activity_web_back_layout"
android:layout_width="32dp"
android:layout_height="match_parent">
<ImageView
android:id="@+id/id_activity_web_back"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:src="@drawable/nav_ic_back" />
</RelativeLayout>
<TextView
android:id="@+id/id_activity_web_close"
android:layout_width="50dp"
android:layout_height="match_parent"
android:layout_centerVertical="true"
android:layout_toRightOf="@+id/id_activity_web_back_layout"
android:gravity="center"
android:text="关闭"
android:textColor="@color/color_343434"
android:visibility="gone" />
<TextView
android:id="@+id/id_activity_web_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:maxLength="8"
android:maxLines="1"
android:textColor="@color/color_343434"
android:textSize="17sp" />
</RelativeLayout>
</com.google.android.material.appbar.AppBarLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFFFFF"
android:orientation="vertical"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<com.ym.library.widget.ScrollWebView
android:id="@+id/webview"
android:overScrollMode="never"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/transparent" />
<RelativeLayout
android:id="@+id/id_activity_web_timer_layout"
android:layout_width="wrap_content"
android:layout_height="73dp"
android:layout_marginTop="30dp"
android:visibility="gone">
<TextView
android:id="@+id/id_activity_web_timer_desc"
android:layout_width="229.5dp"
android:layout_height="47.5dp"
android:layout_centerVertical="true"
android:layout_marginRight="-42dp"
android:layout_toLeftOf="@+id/id_activity_web_timer_progress"
android:background="@drawable/icon_timer_left_bg"
android:gravity="center_vertical"
android:lineSpacingExtra="1dp"
android:paddingLeft="62dp"
android:textColor="#FFFFFF"
android:textSize="14sp" />
<com.ym.library.widget.TimerReadProgressBar
android:id="@+id/id_activity_web_timer_progress"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="73dp"
android:layout_height="73dp"
android:layout_alignParentRight="true"
android:layout_marginRight="12dp" />
</RelativeLayout>
<ProgressBar
android:id="@+id/id_activity_web_progress"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="3dp"
android:layout_alignParentTop="true"
android:progressBackgroundTint="@android:color/transparent"
android:progressDrawable="@drawable/progress_web_color" />
<TextView
android:id="@+id/id_activity_web_top_tips"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:background="@color/color_4f4b4c"
android:paddingLeft="16dp"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:textColor="#FFFFFF"
android:visibility="gone" />
<RelativeLayout
android:id="@+id/id_activity_web_bottom_progress_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#99000000"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:visibility="gone">
<ProgressBar
android:id="@+id/id_activity_web_bottom_progress"
style="@android:style/Widget.ProgressBar.Horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:visibility="gone" />
<TextView
android:id="@+id/id_activity_web_bottom_tips"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/id_activity_web_bottom_progress"
android:layout_marginTop="8dp"
android:paddingBottom="10dp"
android:textColor="#FFFFFF" />
</RelativeLayout>
</RelativeLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/id_dialog_coins_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="vertical">
<RelativeLayout
android:layout_width="210dp"
android:layout_height="179dp"
android:layout_gravity="center"
android:background="@drawable/shape_new_coin_tips_bg">
<ImageView
android:layout_width="202dp"
android:layout_height="172dp"
android:layout_centerInParent="true"
android:src="@drawable/detail_local_pic_coin" />
<TextView
android:id="@+id/id_dialog_coins_num"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="44dp"
android:textColor="#ef5030"
android:textSize="32sp"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/id_dialog_coins_num"
android:layout_centerHorizontal="true"
android:text="金币"
android:textColor="#ef5030"
android:textSize="15sp"
/>
</RelativeLayout>
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_marginLeft="28dp"
android:layout_marginRight="28dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="55.5dp"
android:background="@drawable/shape_white_r10"
android:paddingBottom="28.5dp">
<TextView
android:id="@+id/id_dialog_read_coins_value"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="69dp"
android:includeFontPadding="false"
android:text="+200金币"
android:textColor="#FF6B6B"
android:textSize="24sp"
android:textStyle="bold" />
<TextView
android:id="@+id/id_dialog_read_coins_desc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="107.5dp"
android:includeFontPadding="false"
android:text=""
android:textColor="#ff999999"
android:textSize="15sp" />
<TextView
android:id="@+id/id_dialog_read_coins_btn"
android:layout_width="162dp"
android:layout_height="36dp"
android:layout_centerHorizontal="true"
android:layout_marginTop="146dp"
android:background="@drawable/read_dialog_btn_bg"
android:gravity="center"
android:text="继续赚"
android:textColor="#ffcf5c01"
android:textSize="15sp" />
<ImageView
android:id="@+id/id_dialog_read_coins_close"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginTop="12.5dp"
android:layout_marginRight="30dp"
android:background="@drawable/dialog_read_coins_close" />
</RelativeLayout>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:background="@drawable/happy" />
</RelativeLayout>
</RelativeLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:id="@+id/id_dialog_water_fail_layout"
android:layout_width="310dp"
android:layout_height="230dp"
android:layout_marginTop="70dp"
android:layout_centerInParent="true"
android:background="@drawable/shape_white_r10">
<ImageView
android:id="@+id/dialog_scratch_dialog_close_img"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_margin="16dp"
android:src="@drawable/scratch_dialog_close_img"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="39dp"
android:text="温馨提示"
android:textColor="#333333"
android:textSize="22sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="任务还未完成,现在退出将无法\n获得奖励,确认要退出么"
android:gravity="center"
android:textColor="#333333"
android:textSize="18sp" />
<TextView
android:id="@+id/dialog_scratch_dialog_cancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="30dp"
android:background="@drawable/dialog_sign_out_cancel_bg"
android:gravity="center"
android:text="仍要退出"
android:layout_marginLeft="15dp"
android:textColor="#0090FF"
android:textSize="19sp" />
<TextView
android:id="@+id/dialog_scratch_dialog_bg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_marginBottom="30dp"
android:layout_marginRight="15dp"
android:background="@drawable/dialog_sign_out_conform_bg"
android:gravity="center"
android:text="继续任务"
android:textColor="#FFFFFF"
android:textSize="19sp" />
</RelativeLayout>
</RelativeLayout>
......@@ -31,7 +31,7 @@
<data
android:host="setting"
android:scheme="quweiguesssong" />
android:scheme="luckyfarm" />
</intent-filter>
</activity>
</application>
......
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#dcf0ff" />
<solid android:color="#FFFDF6" />
<corners android:radius="4dp" />
<stroke
android:width="3dp"
android:color="@color/black"/>
android:width="2.5dp"
android:color="#994A00"/>
</shape>
\ No newline at end of file
......@@ -4,33 +4,35 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/bg_guess_song"
android:background="#F9EAC3"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="80dp"
android:background="#5A62BA">
android:background="#EC8D3B">
<ImageView
android:id="@+id/id_iv_back"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/icon_setting_page_back"
android:layout_alignParentBottom="true"
android:layout_marginLeft="22dp"
android:layout_marginBottom="14dp"
android:layout_marginLeft="22dp"/>
android:src="@drawable/icon_setting_page_back" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="14dp"
android:text="设置"
android:textStyle="bold"
android:textColor="#ffffffff"
android:textSize="20sp"
android:layout_marginBottom="14dp"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"/>
android:textStyle="bold" />
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
......@@ -39,24 +41,27 @@
android:layout_marginRight="15dp"
android:background="@drawable/shape_user_dcf0ff_r4_bg"
android:orientation="vertical">
<TextView
android:id="@+id/tv_setting_user_id"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="20dp"
android:textStyle="bold"
android:paddingTop="17dp"
android:paddingRight="20dp"
android:paddingBottom="17dp"
android:text="ID:1234567"
android:textColor="@color/color_8D5313"
android:textSize="15sp" />
android:textColor="#664F31"
android:textSize="15sp"
android:textStyle="bold" />
<View
android:layout_width="match_parent"
android:layout_height="3dp"
android:layout_marginLeft="14dp"
android:layout_marginRight="14dp"
android:background="@drawable/bg_setting_line"/>
android:background="@drawable/bg_setting_line" />
<TextView
android:id="@+id/tv_setting_user_contact_us"
android:layout_width="match_parent"
......@@ -67,14 +72,16 @@
android:paddingRight="20dp"
android:paddingBottom="17dp"
android:text="联系我们"
android:textColor="@color/color_8D5313"
android:textColor="#664F31"
android:textSize="15sp" />
<View
android:layout_width="match_parent"
android:layout_height="3dp"
android:layout_marginLeft="14dp"
android:layout_marginRight="14dp"
android:background="@drawable/bg_setting_line"/>
android:background="@drawable/bg_setting_line" />
<TextView
android:id="@+id/id_setting_update_version"
android:layout_width="match_parent"
......@@ -83,17 +90,19 @@
android:paddingLeft="20dp"
android:paddingTop="17dp"
android:paddingRight="20dp"
android:visibility="visible"
android:paddingBottom="17dp"
android:text="检查更新"
android:textColor="@color/color_8D5313"
android:textSize="15sp" />
android:textColor="#664F31"
android:textSize="15sp"
android:visibility="visible" />
<View
android:layout_width="match_parent"
android:layout_height="3dp"
android:layout_marginLeft="14dp"
android:layout_marginRight="14dp"
android:background="@drawable/bg_setting_line"/>
android:background="@drawable/bg_setting_line" />
<TextView
android:id="@+id/tv_setting_user_agreement"
android:layout_width="match_parent"
......@@ -104,14 +113,16 @@
android:paddingRight="20dp"
android:paddingBottom="17dp"
android:text="@string/user_agreement"
android:textColor="@color/color_8D5313"
android:textColor="#664F31"
android:textSize="15sp" />
<View
android:layout_width="match_parent"
android:layout_height="3dp"
android:layout_marginLeft="14dp"
android:layout_marginRight="14dp"
android:background="@drawable/bg_setting_line"/>
android:background="@drawable/bg_setting_line" />
<TextView
android:id="@+id/tv_setting_privacy_policy"
android:layout_width="match_parent"
......@@ -122,14 +133,16 @@
android:paddingRight="20dp"
android:paddingBottom="17dp"
android:text="@string/user_privacy_policy"
android:textColor="@color/color_8D5313"
android:textColor="#664F31"
android:textSize="15sp" />
<View
android:layout_width="match_parent"
android:layout_height="3dp"
android:layout_marginLeft="14dp"
android:layout_marginRight="14dp"
android:background="@drawable/bg_setting_line"/>
android:background="@drawable/bg_setting_line" />
<TextView
android:id="@+id/tv_setting_about_us"
android:layout_width="match_parent"
......@@ -140,7 +153,7 @@
android:paddingRight="20dp"
android:paddingBottom="17dp"
android:text="@string/user_about_us"
android:textColor="@color/color_8D5313"
android:textColor="#664F31"
android:textSize="15sp" />
</LinearLayout>
</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