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.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
This diff is collapsed.
<?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