Commit ddb653e1 authored by 王雪伟's avatar 王雪伟

Merge remote-tracking branch 'origin/master'

parents d7dde877 093226cf
......@@ -56,7 +56,7 @@
<activity android:name=".activity.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
......
......@@ -2,11 +2,11 @@
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<external-path
name="cache"
path="Android/data/com.zxbw.xymh/" />
path="Android/data/com.zxbw.xxsq/" />
<external-path
name="downloadfile"
path="com.zxbw.xymh/" />
path="com.zxbw.xxsq/" />
<!--项目中用到的-->
<external-path
name="beta_external_files_path"
......
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.zxbw.modulemain">
<application>
<activity
android:name=".activity.SplashActivity"
android:screenOrientation="portrait"
android:theme="@style/Theme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="splash"
android:scheme="xxsq" />
</intent-filter>
</activity>
<activity android:name=".activity.LoginActivity">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data
android:host="login"
android:scheme="xxsq" />
</intent-filter>
</activity>
</application>
</manifest>
\ No newline at end of file
package com.zxbw.modulemain.activity
import android.text.Editable
import android.text.InputType
import android.text.TextUtils
import android.text.TextWatcher
import android.view.View
import com.badoo.mobile.util.WeakHandler
import com.zxbw.modulemain.R
import com.zxbw.modulemain.contract.LoginContract
import com.zxbw.modulemain.presenter.LoginPresenter
import com.zxhl.cms.AppContext
import com.zxhl.cms.common.Constant
import com.zxhl.cms.common.NetConfig
import com.zxhl.cms.common.base.WxImpl
import com.zxhl.cms.router.RounterApi
import com.zxhl.cms.router.RounterBus
import com.zxhl.cms.utils.JumpUtils
import com.zxhl.cms.utils.Utils
import io.reactivex.Flowable
import io.reactivex.android.schedulers.AndroidSchedulers
import kotlinx.android.synthetic.main.activity_login.*
import java.util.concurrent.TimeUnit
/**
* Created by gaoleichao on 2018/12/28
*/
class LoginActivity : WxImpl(), LoginContract.View {
private var TYPE: Int = 0
private val CODE = 1001
private val PASSWORD = 1002
private var mPresenter: LoginContract.Presenter? = null
private var mHandler: WeakHandler? = null
private var isWx = false
private var isStartTimer: Boolean = false
private var SECONDS: Long = 0
private var isShowPsw: Boolean = false
override fun layoutID(): Int {
return R.layout.activity_login
}
override fun before() {
super.before()
setStatusBarBackground(AppContext.get().resources.getColor(R.color.transparent))
}
override fun init() {
super.init()
id_tv_yonghu?.setOnClickListener {
JumpUtils.webJump("用户协议", NetConfig.H5.WEB_URL_USER)
}
id_tv_yinsi?.setOnClickListener {
JumpUtils.webJump("隐私政策", NetConfig.H5.WEB_URL_PRIVACY)
}
TYPE = CODE
mHandler = WeakHandler()
mPresenter = LoginPresenter(this)
// id_activity_login_wx?.setOnClickListener(this)
id_activity_login_switch_type?.setOnClickListener(this)
id_activity_login_edit_phone_getcode?.setOnClickListener(this)
id_activity_login_btn?.setOnClickListener(this)
id_activity_login_edit_password_show?.setOnClickListener(this)
id_activity_login_forget?.setOnClickListener(this)
id_activity_login_close?.setOnClickListener(this)
id_activity_login_edit_phone.addTextChangedListener(object : TextWatcher {
override fun beforeTextChanged(p0: CharSequence?, p1: Int, p2: Int, p3: Int) {
}
override fun onTextChanged(p0: CharSequence?, p1: Int, p2: Int, p3: Int) {
// if (!TextUtils.isEmpty(id_activity_login_edit_phone.text) && !TextUtils.isEmpty(
// id_activity_login_edit_code.text
// )
// ) {
// id_activity_login_btn.setBackgroundResource(R.drawable.shape_3a95fd_r23)
// } else {
// id_activity_login_btn.setBackgroundResource(R.drawable.shape_login_nomal_bg)
// }
if (p0?.length == 11) {
id_activity_login_edit_phone_getcode?.setTextColor(getResources().getColor(R.color.color_333333))
} else {
id_activity_login_edit_phone_getcode?.setTextColor(getResources().getColor(R.color.color_bbbbbb))
}
}
override fun afterTextChanged(p0: Editable?) {
}
})
id_activity_login_edit_code.addTextChangedListener(object : TextWatcher {
override fun beforeTextChanged(p0: CharSequence?, p1: Int, p2: Int, p3: Int) {
}
override fun onTextChanged(p0: CharSequence?, p1: Int, p2: Int, p3: Int) {
// if (!TextUtils.isEmpty(id_activity_login_edit_phone.text) && !TextUtils.isEmpty(
// id_activity_login_edit_code.text
// )
// ) {
// id_activity_login_btn.setBackgroundResource(R.drawable.shape_3a95fd_r23)
// } else {
// id_activity_login_btn.setBackgroundResource(R.drawable.shape_login_nomal_bg)
// }
}
override fun afterTextChanged(p0: Editable?) {
}
})
}
override fun onClick(v: View) {
when (v.id) {
R.id.id_activity_login_close -> finish()
// R.id.id_activity_login_wx -> {
// isWx = true
// onWxLogin()
// }
R.id.id_activity_login_switch_type -> swtichLayout()
R.id.id_activity_login_edit_phone_getcode -> checkPhone()
R.id.id_activity_login_btn -> checkNullAndLogin()
R.id.id_activity_login_edit_password_show -> {
isShowPsw = !isShowPsw
switchPsw()
}
// R.id.id_activity_login_forget -> openActivity(ForgetPassWordActivity::class.java)
}
}
private fun checkPhone() {
mLoading.setLoadText(getString(R.string.wait_ing))
mLoading.show()
val phone = id_activity_login_edit_phone?.text.toString().trim { it <= ' ' }
if (phone.length == 11) {
// if (PhoneNumUtils.isChinaPhoneLegal(phone) && PhoneNumUtils.isMobile(phone)) {
mPresenter?.requestCode(phone)
// } else {
// mLoading.setResult(false, "手机号码错误", 1000);
// }
} else {
mLoading.setResult(false, "手机号码错误", 1000)
}
}
override fun smsCodeFaild(msg: String) {
mLoading.setResult(false, msg, 1000)
}
override fun loginSuc() {
mLoading.setResult(true, "登录成功", 1000)
Constant.Switch.isBindLogin = true
JumpUtils.activityJump(
RounterBus.getRounter(RounterApi::class.java).getIntentActivityMain()
)
finish()
}
override fun smsCodeSuccess() {
startTimer(60)
mLoading.setResult(true, getString(R.string.get_sms_code_success), 1000)
}
override fun onWxSuccess(token: String, openid: String) {
isWx = false
// mPresenter?.wxLogin(token, openid)
}
private fun swtichLayout() {
if (TYPE == CODE) {
id_activity_login_edit_phone_line?.visibility = View.GONE
id_activity_login_edit_phone_getcode?.visibility = View.GONE
id_activity_login_code_layout?.visibility = View.GONE
id_activity_login_code_line?.visibility = View.GONE
id_activity_login_password_layout?.visibility = View.VISIBLE
id_activity_login_password_line?.visibility = View.VISIBLE
id_activity_login_forget?.visibility = View.VISIBLE
id_activity_login_switch_type?.text = "免密码登录"
TYPE = PASSWORD
switchPsw()
} else {
id_activity_login_edit_phone_line?.visibility = View.VISIBLE
id_activity_login_edit_phone_getcode?.visibility = View.VISIBLE
id_activity_login_code_layout?.visibility = View.VISIBLE
id_activity_login_code_line?.visibility = View.VISIBLE
id_activity_login_password_layout?.visibility = View.GONE
id_activity_login_password_line?.visibility = View.GONE
id_activity_login_forget?.visibility = View.GONE
id_activity_login_switch_type?.text = "密码登录"
TYPE = CODE
}
}
private fun startTimer(count: Long) {
isStartTimer = false
id_activity_login_edit_phone_getcode?.setTextColor(-0x39393a)
id_activity_login_edit_phone_getcode?.isEnabled = false
Flowable.intervalRange(0, count, 0, 1, TimeUnit.SECONDS).compose(bindToLifecycle())
.observeOn(AndroidSchedulers.mainThread())
.doOnNext { aLong ->
SECONDS = count - (aLong + 1)
id_activity_login_edit_phone_getcode?.text = "重新发送(" + SECONDS + "s)"
if (!isStartTimer) {
isStartTimer = true
}
}.doOnComplete {
if (SECONDS == 0L) {
isStartTimer = false
id_activity_login_edit_phone_getcode?.isEnabled = true
id_activity_login_edit_phone_getcode?.setTextColor(-0xe0e0e1)
id_activity_login_edit_phone_getcode?.text = "获取验证码"
}
}.subscribe()
}
override fun onResume() {
super.onResume()
if (isStartTimer) {
startTimer(SECONDS)
}
if (isWx) {
mHandler?.postDelayed({
if (isWx && mLoading.isShowing) {
isWx = false
mLoading.setResult(false, "取消登录", 1000)
}
}, 2000)
}
}
override fun loginFaild(msg: String) {
mLoading.setResult(false, msg, 1000)
// JumpUtils.homeJump()
}
fun oneKeyLogin() {
mLoading.setLoading(getString(R.string.login_ing))
mLoading.show()
// mPresenter?.oneKeyLogin()
}
fun checkNullAndLogin() {
val phone = id_activity_login_edit_phone?.text.toString().trim { it <= ' ' }
mLoading.setLoading(getString(R.string.login_ing))
mLoading.show()
if (TextUtils.isEmpty(phone)) {
mLoading.setResult(false, "手机号不能为空", 1000)
return
}
if (TYPE == CODE) {
val code = id_activity_login_edit_code?.text.toString().trim { it <= ' ' }
if (TextUtils.isEmpty(code)) {
mLoading.setResult(false, "验证码不能为空", 1000)
return
}
mPresenter?.codeLogin(phone, code)
} else {
val password = id_activity_login_edit_password?.text.toString().trim { it <= ' ' }
if (TextUtils.isEmpty(password)) {
mLoading.setResult(false, "密码不能为空", 1000)
return
} else if (password.length < 6) {
mLoading.setResult(false, "密码少于6位", 1000)
return
}
// mPresenter?.passwordLogin(phone, password)
}
}
private fun switchPsw() {
// if (isShowPsw) {
// id_activity_login_edit_password_show?.setBackgroundResource(R.drawable.icon_login_pass_hide)
// id_activity_login_edit_password?.inputType =
// InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD// 输入为密码且可见
// } else {
// id_activity_login_edit_password_show?.setBackgroundResource(R.drawable.icon_login_pass_show)
// id_activity_login_edit_password?.inputType =
// InputType.TYPE_TEXT_VARIATION_PASSWORD or InputType.TYPE_CLASS_TEXT// 设置文本类密码(默认不可见),这两个属性必须同时设置
// }
}
private var mPrepareExit = false
override fun onBackPressed() {
// super.onBackPressed();
exitBy2Click()
}
private fun exitBy2Click() {
if (!mPrepareExit) {
mPrepareExit = true // 准备退出
Utils.showToast(this, resources.getString(R.string.nav_back_again_finish))
id_activity_login_btn.postDelayed(Runnable {
mPrepareExit = false // 取消退出
}, 1500)
} else {
Utils.onExit(this)
}
}
}
\ No newline at end of file
package com.zxbw.modulemain.activity
import android.content.Intent
import android.text.TextUtils
import android.util.Log
import android.view.View
import androidx.core.app.ActivityCompat
import com.umeng.analytics.MobclickAgent
import com.zxbw.modulemain.R
import com.zxbw.modulemain.contract.SplashContract
import com.zxbw.modulemain.presenter.SplashPresenter
import com.zxhl.cms.common.Config
import com.zxhl.cms.common.Constant
import com.zxhl.cms.common.base.BaseActivity
import com.zxhl.cms.net.ApiClient
import com.zxhl.cms.net.RxSchedulers
import com.zxhl.cms.net.SettingPreference
import com.zxhl.cms.net.callback.BaseObserver
import com.zxhl.cms.router.RounterApi
import com.zxhl.cms.router.RounterBus
import com.zxhl.cms.utils.EventUtils
import com.zxhl.cms.utils.JumpUtils
import com.zxhl.cms.utils.Utils
import com.zxhl.cms.widget.CenterDialog
/**
* Created by gaoleichao on 2018/12/26
*/
class SplashActivity : BaseActivity(), SplashContract.View {
override fun onClick(v: View?) {
}
override fun layoutID(): Int = R.layout.activity_splash
private var mPresenter: SplashContract.Presenter? = null
override fun init() {
if (!isTaskRoot) {
finish()
return
}
EventUtils.onEvent("app_start")
if (SettingPreference.getFirstApp()) {
CenterDialog.showPrivacyProtocol(this, object : View.OnClickListener {
override fun onClick(p0: View?) {
SettingPreference.setFirstApp()
mPresenter = SplashPresenter(this@SplashActivity, this@SplashActivity)
initListener()
}
})
} else {
mPresenter = SplashPresenter(this@SplashActivity, this@SplashActivity)
initListener()
}
}
private fun initListener() {
jumpMainPage()
// id_activity_splash_skip?.setOnClickListener {
// jumpMainPage()
// }
}
override fun jumpMainPage() {
val user = SettingPreference.getUserInfoData()
val token = SettingPreference.getUserToken()
if (user == null && TextUtils.isEmpty(token)) {
// if (TextUtils.equals(Utils.getChannel(this), "baichuan")) {
// JumpUtils.loginJump()
// } else {
// mPresenter?.checkLogin()
// }
JumpUtils.loginJump()
} else {
// openApp()
JumpUtils.activityJump(
RounterBus.getRounter(RounterApi::class.java).getIntentActivityMain()
)
}
finish()
}
// override fun jumpPermissionsPage() {
// val intent = Intent(this, PermissionsActivity::class.java)
// intent.putExtra(PermissionsActivity.EXTRA_PERMISSIONS, SplashPresenter.PERMISSIONS)
// ActivityCompat.startActivityForResult(
// this,
// intent,
// Constant.REQUEST_CODE_ASK_PERMISSIONS,
// null
// )
// }
//
// override fun getDestroyed(): Boolean {
// return isDestroyed
// }
// override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
// super.onActivityResult(requestCode, resultCode, data)
// if (requestCode == Constant.REQUEST_CODE_ASK_PERMISSIONS && resultCode == PermissionsActivity.PERMISSIONS_DENIED) {
//// finish()
// mPresenter?.checkLogin()
// } else {
// Config.init(this)
// mPresenter?.checkLogin()
// }
// }
private var isPause = false
// override fun setToutiaoView(view: View) {
// isPause = true
// id_activity_splash_ad_layout?.removeAllViews()
// id_activity_splash_ad_layout?.addView(view)
// }
override fun onResume() {
super.onResume()
MobclickAgent.onResume(this)
}
override fun onPause() {
super.onPause()
MobclickAgent.onPause(this)
}
fun openApp() {
ApiClient.homeApi.openApp()
.compose(RxSchedulers.observableIO2Main())
.subscribe(object : BaseObserver<Any>() {
override fun onSuccess(result: Any?) {
Log.e("MXL","进入app上报")
}
override fun onFailure(e: Throwable?, code: String?, errorMsg: String?) {
}
})
}
}
\ No newline at end of file
package com.zxbw.modulemain.contract
/**
* Created by gaoleichao on 2018/6/20.
*/
class LoginContract {
interface View {
fun loginFaild(msg: String)
fun smsCodeFaild(msg: String)
fun loginSuc()
fun smsCodeSuccess()
}
interface Presenter {
fun requestCode(phone: String)
fun codeLogin(phone: String, code: String)
fun getUserInfo()
fun phoneLogin(phone: String)
}
}
\ No newline at end of file
package com.zxbw.modulemain.contract
import android.view.View
/**
* Created by gaoleichao on 2019/3/16
*/
class SplashContract {
interface View {
//fun getDestroyed():Boolean
// fun jumpPermissionsPage()
fun jumpMainPage()
// fun setToutiaoView(view: android.view.View)
}
interface Presenter {
fun checkLogin()
}
}
\ No newline at end of file
package com.zxbw.modulemain.presenter
import android.content.Context
import android.text.TextUtils
import android.util.Log
import com.zxbw.modulemain.contract.LoginContract
import com.zxhl.cms.net.ApiClient
import com.zxhl.cms.net.RxSchedulers
import com.zxhl.cms.net.SettingPreference
import com.zxhl.cms.net.callback.BaseObserver
import com.zxhl.cms.net.model.uc.UserInfo
import com.zxhl.cms.utils.EventUtils
import com.zxhl.cms.utils.UserDataUtils
/**
* Created by gaoleichao on 2018/6/20.
*/
class LoginPresenter:LoginContract.Presenter{
private val mView: LoginContract.View
constructor(mView: LoginContract.View) {
this.mView = mView
}
override fun requestCode(phone: String) {
ApiClient.homeApi.requestCode(phone).compose(RxSchedulers.observableIO2Main())
.subscribe(object : BaseObserver<Any>() {
override fun onSuccess(result: Any?) {
mView.smsCodeSuccess()
}
override fun onFailure(e: Throwable?, code: String?, errorMsg: String?) {
var str: String
if (TextUtils.equals("105", code)) {
str = errorMsg?:""
} else {
str = "发送失败"
}
mView.smsCodeFaild(str)
}
})
}
override fun codeLogin(phone: String, code: String) {
ApiClient.homeApi.requestCodeLogin(phone, code).compose(RxSchedulers.observableIO2Main())
.subscribe(object : BaseObserver<UserInfo>() {
override fun onSuccess(result: UserInfo) {
if(result!=null){
val token = result.token
if (TextUtils.isEmpty(token)) {
EventUtils.onEvent("login_fail", "codeLogin:" + "token为空")
mView.loginFaild("登录失败")
} else {
EventUtils.onEvent("login_suc", "codeLogin")
// Constant.newAwardFlag = result.newAwardFlag
SettingPreference.saveToken(token)
UserDataUtils.updateUserInfo(null)
mView.loginSuc()
// getUserInfo()
}
}else{
Log.e("MXL","失败")
}
}
override fun onFailure(e: Throwable, code: String, errorMsg: String) {
EventUtils.onEvent("login_fail", "codeLogin:" + errorMsg)
val str: String
if (TextUtils.equals("105", code)) {
str = errorMsg
} else {
str = "登录失败"
}
mView.loginFaild(str)
}
})
}
override fun getUserInfo() {
ApiClient.userInfoAPi.getUserInfo().compose(RxSchedulers.observableIO2Main())
.subscribe(object : BaseObserver<UserInfo>() {
override fun onSuccess(result: UserInfo) {
val uid = result.uid
if (TextUtils.isEmpty(uid)) {
EventUtils.onEvent("login_fail", "getUserInfo:" + "uid为空")
mView.loginFaild("登录失败")
} else {
SettingPreference.saveUserInfo(result)
// SettingPreference.setTrackId(result.gaodeTrackId?:0L)
// SettingPreference.setTerminalId(result.gaodeTerminalId?:0L)
mView.loginSuc()
EventUtils.onEvent("login_suc", "getUserInfo")
}
}
override fun onFailure(e: Throwable, code: String, errorMsg: String) {
EventUtils.onEvent("login_fail", "getUserInfo:" + errorMsg)
val str: String
if (TextUtils.equals("105", code)) {
str = errorMsg
} else {
str = "登录失败"
}
mView.loginFaild(str)
}
})
}
override fun phoneLogin(phone: String) {
// ApiClient.userApi.requestPhoneLogin(Constant.SHANYAN_KEY,phone).compose(RxSchedulers.observableIO2Main())
// .subscribe(object : BaseObserver<UserInfoEntity>() {
// override fun onSuccess(result: UserInfoEntity) {
// val token = result.token
// Constant.successMsg = result?.successMsg
// if (TextUtils.isEmpty(token)) {
// EventUtils.onEvent("login_fail", "codeLogin:" + "token为空")
// mView.loginFaild("登录失败")
// } else {
// EventUtils.onEvent("login_suc", "codeLogin")
// Constant.newAwardFlag = result.newAwardFlag
// SettingPreference.setToken(token)
// getUserInfo()
// }
// }
//
// override fun onFailure(e: Throwable, code: String, errorMsg: String) {
// EventUtils.onEvent("login_fail", "codeLogin:" + errorMsg)
// val str: String
// if (TextUtils.equals("105", code)) {
// str = errorMsg
// } else {
// str = "登录失败"
// }
// mView.loginFaild(str)
// }
// })
}
}
\ No newline at end of file
package com.zxbw.modulemain.presenter
import android.app.Activity
import android.os.Build
import android.text.TextUtils
import android.view.View
import com.bytedance.sdk.openadsdk.AdSlot
import com.bytedance.sdk.openadsdk.TTAdNative
import com.bytedance.sdk.openadsdk.TTAdSdk
import com.bytedance.sdk.openadsdk.TTSplashAd
import com.zxbw.modulemain.contract.SplashContract
import com.zxhl.cms.AppContext
import com.zxhl.cms.ad.upload.Utils.AdUpload
import com.zxhl.cms.ad.upload.model.NewsEntity
import com.zxhl.cms.common.Constant
import com.zxhl.cms.net.ApiClient
import com.zxhl.cms.net.RxSchedulers
import com.zxhl.cms.net.SettingPreference
import com.zxhl.cms.net.callback.BaseObserver
import com.zxhl.cms.net.model.box.AppInEntity
import com.zxhl.cms.net.model.other.IsWeChatLoginEntity
import com.zxhl.cms.net.model.uc.UserInfo
import com.zxhl.cms.utils.*
import io.reactivex.Observable
import io.reactivex.ObservableOnSubscribe
import io.reactivex.Observer
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.disposables.Disposable
import io.reactivex.schedulers.Schedulers
/**
* Created by gaoleichao on 2019/3/16
*/
class SplashPresenter : SplashContract.Presenter {
private val mView: SplashContract.View
private val mActivity: Activity
constructor(mView: SplashContract.View, mActivity: Activity) {
this.mView = mView
this.mActivity = mActivity
checkPermissions()
}
companion object {
val PERMISSIONS = arrayOf(
// Constant.Permission.PERMISSION_READ_STORAGE,
Constant.Permission.PERMISSION_PHONE
// Constant.Permission.PERMISSION_COARSE_LOCATION,
// Constant.Permission.PERMISSION_FINE_LOCATION
// , Constant.Permission.PERMISSION_CAMERA
)
}
private var mDisposablePermissions: Disposable? = null
fun checkPermissions() {
// Observable.create(ObservableOnSubscribe<Boolean> { e ->
// val flag = Utils.needPermissions(*PERMISSIONS)
// e?.onNext(flag)
// e?.onComplete()
// }).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread())
// .subscribe(object : Observer<Boolean> {
// override fun onSubscribe(d: Disposable) {
// mDisposablePermissions = d
// }
//
// override fun onNext(aBoolean: Boolean) {
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1 && mView.getDestroyed()) {
// return
// }
// // 缺少权限时, 进入权限配置页面
// if (aBoolean) {
// mView.jumpPermissionsPage()
// } else {
// checkLogin()
// }
// }
//
// override fun onError(e: Throwable) {
//
// }
//
// override fun onComplete() {
// if (mDisposablePermissions != null && mDisposablePermissions?.isDisposed == false) {
// mDisposablePermissions?.dispose()
// }
// }
// })
}
override fun checkLogin() {
val user = SettingPreference.getUserInfoData()
val token = SettingPreference.getUserToken()
if (user == null && TextUtils.isEmpty(token)) {
if (TextUtils.equals(Utils.getChannel(AppContext.get()), "baichuan")) {
// deviceLogin()
getAds()
} else {
deviceLogin()
}
} else {
UserDataUtils.updateUserInfo(null)
getAds()
}
}
private fun deviceLogin() {
ApiClient.userInfoAPi.deviceLogin().compose(RxSchedulers.observableIO2Main())
.subscribe(object : BaseObserver<UserInfo>() {
override fun onSuccess(result: UserInfo) {
val token = result.token
SettingPreference.saveToken(token)
UserDataUtils.updateUserInfo(null)
// mView?.jumpMainPage()
getAds()
}
override fun onFailure(e: Throwable, code: String, errorMsg: String) {
SettingPreference.saveToken("")
SettingPreference.saveUserInfo(null)
getAds()
}
})
}
private fun getAds() {
checkLoginIsBind()
ApiClient.adApi.getAds("splash")
.compose(RxSchedulers.observableIO2Main())
.subscribe(object : BaseObserver<List<NewsEntity>>() {
override fun onSuccess(result: List<NewsEntity>) {
if (result != null && result?.size > 0) {
val data = result[0]
if (TextUtils.equals(data.adPlatform, "chuanshanjia")) {
loadToutiao(data, 0, "splash")
}
} else {
mView.jumpMainPage()
}
}
override fun onFailure(e: Throwable?, code: String?, errorMsg: String?) {
mView.jumpMainPage()
}
})
}
private var mTTAdNative: TTAdNative? = null
private fun loadToutiao(data: NewsEntity, count: Int, slotNameL: String) {
mTTAdNative = TTAdSdk.getAdManager().createAdNative(mActivity)//baseContext建议为activity
val adSlot = AdSlot.Builder()
.setCodeId(data?.codeId)
.setSupportDeepLink(true)
.setImageAcceptedSize(
PhoneUtils.getScreenWidth(AppContext.get()),
PhoneUtils.getScreenHeight(AppContext.get())
)
.build()
mTTAdNative?.loadSplashAd(adSlot, object : TTAdNative.SplashAdListener {
override fun onError(i: Int, s: String) {
mView.jumpMainPage()
}
override fun onTimeout() {
mView.jumpMainPage()
}
override fun onSplashAdLoad(ad: TTSplashAd) {
val view = ad.splashView
// mView?.setToutiaoView(view)
ad.setSplashInteractionListener(object : TTSplashAd.AdInteractionListener {
override fun onAdClicked(view: View, i: Int) {
EventUtils.onEvent("splash_click")
AdUpload.onAdClick(data)
}
override fun onAdShow(view: View, i: Int) {
EventUtils.onEvent("splash_show")
AdUpload.onAdImpression(data)
}
override fun onAdSkip() {
mView.jumpMainPage()
}
override fun onAdTimeOver() {
mView.jumpMainPage()
}
})
}
}, 5000)
}
private fun checkLoginIsBind() {
ApiClient.homeApi.isWxLogin().compose(RxSchedulers.observableIO2Main())
.subscribe(object : BaseObserver<IsWeChatLoginEntity>() {
override fun onSuccess(result: IsWeChatLoginEntity?) {
Constant.Switch.isBindLogin = result?.status.equals("1")
}
override fun onFailure(e: Throwable?, code: String?, errorMsg: String?) {
}
})
getAppInfo()
}
private fun getAppInfo() {
ApiClient.homeApi.getAppInfo()
.compose(RxSchedulers.observableIO2Main())
.subscribe(object : BaseObserver<AppInEntity>() {
override fun onSuccess(result: AppInEntity?) {
Constant.Switch.isOpenLogin = result?.login.equals("1")
Constant.Switch.isOpenPayTips = result?.risk_open.equals("1")
SettingPreference.saveConfig(result)
}
override fun onFailure(e: Throwable?, code: String?, errorMsg: String?) {
}
})
}
}
\ 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="#ff333333" />
<corners
android:radius="25dp" />
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<stroke
android:width="1dp"
android:color="#ffb28a17" />
<corners
android:radius="15dp" />
</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="#ffffffff" />
<corners
android:bottomLeftRadius="0dp"
android:bottomRightRadius="0dp"
android:topLeftRadius="20dp"
android:topRightRadius="20dp" />
</shape>
\ 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"
android:background="@color/white"
android:orientation="vertical">
<ImageView
android:id="@+id/id_bg_top"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:src="@drawable/login_top_bg" />
<ImageView
android:id="@+id/id_activity_login_close"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="48dp"
android:padding="16dp"
android:src="@drawable/icon_close_login"
android:visibility="visible" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/id_activity_login_close"
android:layout_centerHorizontal="true"
android:layout_marginTop="16dp"
android:text="注册登录"
android:textColor="#F4E9C9"
android:textSize="16sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/id_activity_login_close"
android:layout_marginLeft="16dp"
android:layout_marginTop="36dp"
android:layout_marginRight="16dp"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="您好,"
android:textColor="#F4E9C9"
android:textSize="20sp"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="欢迎打开小象省钱"
android:textColor="#F4E9C9"
android:textSize="16sp" />
</LinearLayout>
<RelativeLayout
android:id="@+id/id_activity_login_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/id_bg_top"
android:layout_marginTop="-16dp"
android:background="@drawable/shape_ffffff_r10"
android:visibility="visible">
<TextView
android:id="@+id/id_activity_login_tips"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="登录"
android:textColor="@color/color_333333"
android:textSize="30sp"
android:textStyle="bold"
android:visibility="gone" />
<TextView
android:id="@+id/id_activity_login_tips1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/id_activity_login_tips"
android:layout_marginTop="5dp"
android:text="输入手机号码验证后即可登录"
android:textColor="#BBBBBB"
android:textSize="15sp"
android:visibility="gone" />
<LinearLayout
android:id="@+id/id_activity_login_edit_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/id_activity_login_tips1"
android:layout_marginTop="20dp"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:text="手机号"
android:textColor="@color/color_333333"
android:textSize="16sp"
android:textStyle="bold" />
<LinearLayout
android:id="@+id/id_activity_login_phone_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal">
<EditText
android:id="@+id/id_activity_login_edit_phone"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@null"
android:ellipsize="end"
android:ems="11"
android:hint="请输入手机号码"
android:inputType="phone"
android:maxLength="11"
android:maxLines="1"
android:padding="16dp"
android:saveEnabled="false"
android:scrollHorizontally="true"
android:singleLine="true"
android:textColor="@color/color_333333"
android:textColorHint="@color/color_999999"
android:textCursorDrawable="@null"
android:textSize="16sp" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:background="#E4E4E4" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginTop="20dp"
android:text="验证码"
android:textColor="@color/color_333333"
android:textSize="16sp" />
<LinearLayout
android:id="@+id/id_activity_login_code_layout"
android:layout_width="match_parent"
android:layout_height="60dp"
android:gravity="center_vertical"
android:orientation="horizontal">
<EditText
android:id="@+id/id_activity_login_edit_code"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@null"
android:ellipsize="end"
android:ems="11"
android:hint="请输入验证码"
android:inputType="phone"
android:maxLength="4"
android:maxLines="1"
android:padding="16dp"
android:saveEnabled="false"
android:scrollHorizontally="true"
android:singleLine="true"
android:textColor="@color/color_333333"
android:textColorHint="@color/color_999999"
android:textCursorDrawable="@null"
android:textSize="16sp" />
<View
android:id="@+id/id_activity_login_edit_phone_line"
android:layout_width="0.5dp"
android:layout_height="12dp"
android:background="@color/white"
android:visibility="invisible" />
<TextView
android:id="@+id/id_activity_login_edit_phone_getcode"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="16dp"
android:background="@drawable/shape_b287a17_r15_stoke"
android:gravity="center"
android:paddingLeft="15dp"
android:paddingTop="5dp"
android:paddingRight="15dp"
android:paddingBottom="5dp"
android:text="获取验证码"
android:textColor="#B28A17"
android:textSize="12sp" />
</LinearLayout>
<View
android:id="@+id/id_activity_login_code_line"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:background="#E4E4E4" />
<LinearLayout
android:id="@+id/id_activity_login_password_layout"
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_marginTop="25dp"
android:gravity="center_vertical"
android:orientation="horizontal"
android:visibility="gone">
<EditText
android:id="@+id/id_activity_login_edit_password"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_toLeftOf="@+id/id_activity_login_edit_password_show"
android:layout_weight="1"
android:background="@null"
android:ellipsize="end"
android:hint="请输入密码"
android:maxLength="20"
android:maxLines="1"
android:padding="10dp"
android:saveEnabled="false"
android:scrollHorizontally="true"
android:singleLine="true"
android:textColor="@color/white"
android:textColorHint="@color/color_99ffffff"
android:textSize="15sp" />
<ImageView
android:id="@+id/id_activity_login_edit_password_show"
android:layout_width="18dp"
android:layout_height="12dp"
android:layout_centerVertical="true"
android:layout_toLeftOf="@+id/id_activity_login_password_line" />
<View
android:id="@+id/id_activity_login_edit_password_line"
android:layout_width="0.5dp"
android:layout_height="12dp"
android:layout_marginLeft="10dp"
android:background="@color/white" />
<TextView
android:id="@+id/id_activity_login_forget"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginLeft="10dp"
android:gravity="center"
android:text="忘记密码"
android:textColor="@color/color_99ffffff"
android:textSize="15sp" />
</LinearLayout>
<View
android:id="@+id/id_activity_login_password_line"
android:layout_width="match_parent"
android:layout_height="0.5dp"
android:background="@color/white"
android:visibility="gone" />
</LinearLayout>
<TextView
android:id="@+id/id_activity_login_btn"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_below="@+id/id_activity_login_edit_layout"
android:layout_centerHorizontal="true"
android:layout_marginLeft="30dp"
android:layout_marginTop="50dp"
android:layout_marginRight="30dp"
android:background="@drawable/shape_333333_r20"
android:gravity="center"
android:text="登录"
android:textColor="#F4E9C9"
android:textSize="16sp" />
<TextView
android:id="@+id/id_activity_login_switch_type"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/id_activity_login_btn"
android:layout_centerHorizontal="true"
android:layout_marginLeft="33dp"
android:layout_marginTop="25dp"
android:layout_marginRight="33dp"
android:gravity="center"
android:text="密码登录"
android:textColor="@color/white"
android:textSize="16sp"
android:visibility="gone" />
<LinearLayout
android:id="@+id/id_activity_login_switch_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/id_activity_login_switch_type"
android:layout_marginTop="30dp"
android:gravity="center_horizontal"
android:orientation="vertical"
android:visibility="gone">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/id_activity_other_type_lable"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:text="其他方式登陆"
android:textColor="@color/white"
android:textSize="16sp" />
<View
android:layout_width="40dp"
android:layout_height="1dp"
android:layout_centerVertical="true"
android:layout_toLeftOf="@+id/id_activity_other_type_lable"
android:background="@color/white" />
<View
android:layout_width="40dp"
android:layout_height="1dp"
android:layout_centerVertical="true"
android:layout_toRightOf="@+id/id_activity_other_type_lable"
android:background="@color/white" />
</RelativeLayout>
</LinearLayout>
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="30dp"
android:gravity="center_horizontal"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:text="未注册手机验证后将自动注册"
android:textColor="@color/color_999999"
android:textSize="11sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="登录或注册即代表你同意"
android:textColor="@color/color_999999"
android:textSize="11sp" />
<TextView
android:id="@+id/id_tv_yonghu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="《省点花用户协议》"
android:textColor="#B28A17"
android:textSize="11sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="及"
android:textColor="@color/color_999999"
android:textSize="11sp" />
<TextView
android:id="@+id/id_tv_yinsi"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="《省点花隐私政策》"
android:textColor="#B28A17"
android:textSize="11sp" />
</LinearLayout>
</LinearLayout>
</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"
android:background="@drawable/splash_bg">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="150dp"
android:gravity="center_horizontal"
android:orientation="vertical">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/logo" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="小象省钱黑钻卡"
android:textColor="#D9C5A7"
android:layout_marginTop="15dp"
android:textSize="23sp"
android:textStyle="bold"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:text="一 张 巨 省 钱 的 黑 钻 卡"
android:textSize="10sp"
android:textColor="#D7CDC1"/>
</LinearLayout>
</RelativeLayout>
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