Commit 447910b6 authored by mengcuiguang's avatar mengcuiguang

代码优化

parent 4fe678f9
......@@ -103,7 +103,12 @@
android:exported="false"
android:launchMode="singleTop"
android:screenOrientation="portrait" />
<activity
android:name=".ui.activitys.WxLoginActivity"
android:configChanges="orientation|screenSize|keyboardHidden"
android:exported="false"
android:launchMode="singleTop"
android:screenOrientation="portrait" />
<activity
android:name=".ui.activitys.MainActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
......
......@@ -67,7 +67,6 @@ class HomePresenter : BasePresenter<HomeView>() {
when (code) {
200 -> {
view.topTabsSuc(baseResponse.data)
showTurn()
}
else -> {
view.showToast(message)
......@@ -77,46 +76,9 @@ class HomePresenter : BasePresenter<HomeView>() {
})
}
private fun showTurn() {
AppHttpManager.getInstance(loanApplication)
.call(loanService.showTurn(),
object : BaseSubscriber<BaseResponse<NineShowBean>>() {
override fun onCompleted() {
if (isLinkView) return
}
override fun onNext(baseResponse: BaseResponse<NineShowBean>) {
if (isLinkView) return
val code = baseResponse.status
val message = baseResponse.message
when (code) {
200 -> {
val data = baseResponse.data
if (data != null) {
view.showTurnSuc(data)
// AppPreferencesManager.get()
// .put(Constant.LUCKY_FLAG, data.isShow)
// AppPreferencesManager.get()
// .put(Constant.LUCKY_COMPLETE, data.complete)
// AppPreferencesManager.get()
// .put(Constant.LUCKY_NEED, data.need)
}
}
}
}
override fun onError(e: Throwable?) {
if (isLinkView) return
}
})
}
fun orders() {
AppHttpManager.getInstance(loanApplication)
.call(loanService.orders(),
.call(loanService.history(),
object : BaseSubscriber<BaseResponse<BannerList>>() {
override fun onCompleted() {
if (isLinkView) return
......@@ -224,57 +186,4 @@ class HomePresenter : BasePresenter<HomeView>() {
}
})
}
fun getSoltVedio() {
AppHttpManager.getInstance(loanApplication)
.call(loanService.getSoltVedio(),
object : BaseSubscriber<BaseResponse<IndexList>>() {
override fun onCompleted() {
if (isLinkView) return
}
override fun onError(e: Throwable) {
if (isLinkView) return
}
override fun onNext(baseResponse: BaseResponse<IndexList>) {
if (isLinkView) return
val code = baseResponse.status
val message = baseResponse.message
when (code) {
200 -> {
view.getSoltVedioSuc(baseResponse.data)
}
}
}
})
}
fun getRecommendVedio() {
AppHttpManager.getInstance(loanApplication)
.call(loanService.getRecommendVedio(),
object : BaseSubscriber<BaseResponse<RecoBean>>() {
override fun onCompleted() {
if (isLinkView) return
}
override fun onError(e: Throwable) {
if (isLinkView) return
}
override fun onNext(baseResponse: BaseResponse<RecoBean>) {
if (isLinkView) return
val code = baseResponse.status
when (code) {
200 -> {
view.getRecommendVedioSuc(baseResponse.data)
}
}
}
})
}
}
\ No newline at end of file
......@@ -7,8 +7,4 @@ interface HomeView : BaseView {
fun getHomeV1MsgSuc(data: HotStyleTypesList)
fun topTabsSuc(data: BannerList?)
fun ordersSuc(data: BannerList?)
fun getSoltVedioSuc(data: IndexList?)
fun getRecommendVedioSuc(data: RecoBean?)
fun showTurnSuc(data: NineShowBean)
}
package com.mints.helivideo.ui.activitys
import android.os.Bundle
import android.os.Handler
import android.os.Looper
import android.text.TextPaint
import android.text.style.ClickableSpan
import android.view.View
import androidx.core.content.ContextCompat
import cn.sharesdk.framework.ShareSDK
import cn.sharesdk.wechat.friends.Wechat
import com.daimajia.androidanimations.library.Techniques
import com.daimajia.androidanimations.library.YoYo
import com.mints.helivideo.MintsApplication
import com.mints.helivideo.R
import com.mints.helivideo.common.Constant
import com.mints.helivideo.login.LoginApi
import com.mints.helivideo.login.OnLoginListener
import com.mints.helivideo.mvp.model.WXInfo
import com.mints.helivideo.mvp.presenters.LoginPresenter
import com.mints.helivideo.mvp.views.LoginView
import com.mints.helivideo.ui.activitys.base.BaseActivity
import com.mints.helivideo.utils.CommonUtils
import com.mints.helivideo.utils.SpanUtils
import com.mints.helivideo.utils.ToastUtil
import com.mints.library.utils.json.JsonUtil
import com.mints.library.utils.nodoubleclick.AntiShake
import kotlinx.android.synthetic.main.activity_wx_login.*
/**
* 描述:微信登录
* 作者:孟崔广
* 时间:2020/12/2 13:50
*/
class WxLoginActivity : BaseActivity(), LoginView, View.OnClickListener, OnLoginListener {
private val loginPresenter by lazy { LoginPresenter() }
private val loginApi by lazy { LoginApi() }
private var wxInfo: WXInfo? = null
private var channel: String = ""
private var isCheckAgree = false
override fun getContentViewLayoutID() = R.layout.activity_wx_login
override fun toggleOverridePendingTransition() = true
override fun getOverridePendingTransitionMode() = TransitionMode.BOTTOM
override fun isApplyKitKatTranslucency() = false
override fun initViewsAndEvents() {
loginPresenter.attachView(this)
channel = CommonUtils.getAppMetaData(MintsApplication.getContext(), "CHANNEL_NAME")
initView()
initListener()
}
override fun onDestroy() {
super.onDestroy()
loginApi.setOnLoginListener(null)
loginPresenter.detachView()
}
override fun finish() {
super.finish()
//关闭窗体动画显示
overridePendingTransition(0, R.anim.push_bottom_out)
}
override fun onClick(v: View?) {
if (AntiShake.check(v?.id)) return
when (v?.id) {
R.id.ivLoginBack -> {
finish()
}
R.id.tvLoginMobile -> {
readyGo(MobileLoginActivity::class.java)
}
R.id.rlLoginWx -> {
if (!isCheckAgree) {
ToastUtil.showLong(context,"请勾选同意后再进行登录")
llWxloginCheck.postDelayed({
YoYo.with(Techniques.Shake).duration(500).repeat(2).playOn(llWxloginCheck)
}, 200)
return
}
val wechat = ShareSDK.getPlatform(Wechat.NAME)
if (!wechat.isClientValid) {
showToast("请先安装微信")
return
}
// RxPermissions(this)
// .request(Manifest.permission.READ_PHONE_STATE)
// .subscribe { granted: Boolean ->
// if (granted) {
// loginApi.setOnLoginListener(this@WxLoginActivity)
// loginApi.setPlatform(Wechat.NAME)
// loginApi.login(this@WxLoginActivity)
// } else {
// showMissingPermissionDialog("设备")
// }
// }
loginApi.setOnLoginListener(this@WxLoginActivity)
loginApi.setPlatform(Wechat.NAME)
loginApi.login(this@WxLoginActivity)
// readyGo(TestActivity::class.java)
}
}
}
override fun loginSuc() {
showToast("登录成功")
hideLoading()
Handler(Looper.getMainLooper()).postDelayed({
readyGoThenKill(MainActivity::class.java)
}, 1000)
}
override fun sendCodeSuc() {
}
override fun mergeAccount(mobile: String, wxOpenId: String, key: String) {
}
override fun onLogin(platform: String?, res: HashMap<String, Any>): Boolean {
try {
wxInfo = WXInfo()
wxInfo?.let {
it.unionid = res["unionid"].toString() + ""
it.openid = res["openid"].toString() + ""
it.province = res["province"].toString() + ""
it.city = res["city"].toString() + ""
it.country = res["country"].toString() + ""
it.headimgurl = res["headimgurl"].toString() + ""
it.nickname = res["nickname"].toString() + ""
it.sex = (res["sex"].toString() + "").toInt()
}
if (!isFinishing) {
loginPresenter.login(JsonUtil.toJson(wxInfo))
}
} catch (e: Exception) {
e.printStackTrace()
}
return false
}
private fun initView() {
SpanUtils.with(tvLoginAgreement)
.append("已阅读并同意")
.append("《用户注册协议》").setClickSpan(object : ClickableSpan() {
override fun onClick(widget: View) {
val bundle = Bundle()
bundle.putString(WebActivity.WEB_TITLE, getString(R.string.register_name))
bundle.putString(WebActivity.WEB_URL, Constant.REGISTER_URL)
readyGo(WebActivity::class.java, bundle)
}
override fun updateDrawState(ds: TextPaint) {
ds.color = ContextCompat.getColor(mContext, R.color.color_FF9837)
ds.isUnderlineText = false
}
})
.append("、")
.append("《用户隐私协议》").setClickSpan(object : ClickableSpan() {
override fun onClick(widget: View) {
val bundle = Bundle()
bundle.putString(WebActivity.WEB_TITLE, getString(R.string.privacy_name))
bundle.putString(WebActivity.WEB_URL, Constant.PRIVACY_URL)
readyGo(WebActivity::class.java, bundle)
}
override fun updateDrawState(ds: TextPaint) {
ds.color = ContextCompat.getColor(mContext, R.color.color_FF9837)
ds.isUnderlineText = false
}
})
.append("与您的利益切身相关。请您注册前务必仔细阅读!")
.create()
}
private fun initListener() {
ivLoginBack.setOnClickListener(this)
tvLoginMobile.setOnClickListener(this)
rlLoginWx.setOnClickListener(this)
wxloginCheck.setOnCheckedChangeListener { buttonView, isChecked ->
this.isCheckAgree = isChecked
}
}
}
......@@ -22,10 +22,9 @@ class TopAdapter(val topList: MutableList<VedioBean>?) :
inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
val rlTopItemRoot: LinearLayout = view.findViewById(R.id.rlTopItemRoot)
val ivTopItem: ImageView = view.findViewById(R.id.ivTopItem)
val tvTopItemLable: TextView = view.findViewById(R.id.tvTopItemLable)
val tvTopItemCount: TextView = view.findViewById(R.id.tvTopItemCount)
val tvTopItemTitle: TextView = view.findViewById(R.id.tvTopItemTitle)
val tvTopItemText: TextView = view.findViewById(R.id.tvTopItemText)
val tvTopCurText: TextView = view.findViewById(R.id.tvTopCurText)
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
......@@ -38,17 +37,9 @@ class TopAdapter(val topList: MutableList<VedioBean>?) :
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
val topBean = topList?.get(position)
if (topBean != null) {
holder.tvTopItemLable.text = "${position + 1}"
holder.tvTopItemCount.text = topBean.showNum
holder.tvTopItemTitle.text = "${topBean.title}"
if (topBean.orderTags != null && topBean.orderTags.size > 0) {
val sb = StringBuilder()
for (i in 0 until topBean.orderTags.size) {
sb.append(topBean.orderTags.get(i) + " ")
}
holder.tvTopItemText.text = "${sb}"
}
holder.tvTopItemText.text = "共${topBean.freeIndex}集"
holder.tvTopCurText.text = "观看至第${topBean.seeIndex}集"
GlideUtils.loadImageViewGifForCenterCrop(
context,
topBean.coverImage,
......@@ -56,21 +47,6 @@ class TopAdapter(val topList: MutableList<VedioBean>?) :
)
}
when (position) {
0 -> {
holder.tvTopItemLable.setBackgroundResource(R.mipmap.y43)
}
1 -> {
holder.tvTopItemLable.setBackgroundResource(R.mipmap.y42)
}
2 -> {
holder.tvTopItemLable.setBackgroundResource(R.mipmap.y41)
}
else -> {
holder.tvTopItemLable.setBackgroundResource(R.mipmap.y4)
}
}
holder.rlTopItemRoot.setOnClickListener {
mOnItemClickListener.onItemClick(position)
}
......
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools"
android:background="@color/white"
android:orientation="vertical">
<ImageView
android:id="@+id/ivLoginBack"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="25dp"
android:paddingTop="40dp"
android:paddingRight="25dp"
android:paddingBottom="10dp"
android:scaleType="center"
android:src="@mipmap/ic_activity_quit" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="70dp"
android:layout_height="70dp"
android:layout_centerHorizontal="true"
android:layout_marginTop="50dp"
android:src="@mipmap/ic_launcher_main" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="30dp"
android:orientation="vertical">
<RelativeLayout
android:id="@+id/rlLoginWx"
android:layout_width="match_parent"
android:layout_height="52dp"
android:layout_gravity="center_horizontal"
android:layout_marginLeft="40dp"
android:layout_marginTop="230dp"
android:layout_marginRight="40dp"
android:background="@drawable/shape_green">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:drawableLeft="@mipmap/ic_wx_white_login"
android:drawablePadding="10dp"
android:gravity="center_vertical"
android:text="微信登录"
android:textColor="@color/white"
android:textSize="14sp" />
</RelativeLayout>
<TextView
android:id="@+id/tvLoginMobile"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:padding="24dp"
android:text="其他登录方式"
android:textColor="@color/gray"
android:textSize="14sp" />
<LinearLayout
android:id="@+id/llWxloginCheck"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<CheckBox
android:id="@+id/wxloginCheck"
android:layout_width="wrap_content"
android:layout_marginLeft="20dp"
android:gravity="center"
android:checked="false"
android:layout_gravity="center_vertical"
android:layout_height="wrap_content"></CheckBox>
<TextView
android:id="@+id/tvLoginAgreement"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginRight="30dp"
android:layout_marginLeft="2dp"
tools:text="123123123123123123123123123123123123123123123123123123123123123123"
android:textColor="#707A8D"
android:textSize="12sp" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
</LinearLayout>
\ No newline at end of file
......@@ -76,17 +76,37 @@
android:background="@drawable/shape_bg_write"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="6dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:text="排行榜"
android:text="最近观看"
android:textColor="@color/black"
android:textSize="16sp"
android:textStyle="bold" />
<TextView
android:id="@+id/tv_main_watchmore"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginLeft="6dp"
android:layout_marginTop="14dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="10dp"
android:text="查看更多"
android:textColor="@color/gray"
android:textSize="12sp"
android:textStyle="bold" />
</RelativeLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_main_list"
android:layout_width="match_parent"
......@@ -243,35 +263,4 @@
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:id="@+id/ll_lucky"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"
android:layout_marginEnd="10dp"
android:layout_marginBottom="120dp"
android:gravity="center"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent">
<ImageView
android:id="@+id/iv_lucky_gif"
android:layout_width="80dp"
android:layout_height="70dp"
android:src="@mipmap/ic_get_mobile" />
<TextView
android:id="@+id/tv_lucky_status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="6dp"
android:background="@drawable/shape_bg_black2"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:text="0/5"
android:textColor="@color/white"
android:textSize="12sp" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
......@@ -3,73 +3,30 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/rlTopItemRoot"
android:layout_width="110dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="3dp"
android:layout_marginRight="3dp"
android:orientation="vertical">
<FrameLayout
android:layout_width="110dp"
android:layout_height="150dp">
android:orientation="horizontal">
<ImageView
android:id="@+id/ivTopItem"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_width="110dp"
android:layout_height="120dp"
android:scaleType="fitXY" />
<TextView
android:id="@+id/tvTopItemLable"
android:layout_width="22dp"
android:layout_height="22dp"
android:layout_marginLeft="10dp"
android:background="@mipmap/y4"
android:gravity="center"
android:paddingBottom="2dp"
android:text="1"
android:textColor="@color/white"
android:textSize="12sp"
android:textStyle="bold" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="@drawable/bg_shape_twoban"
android:drawableLeft="@mipmap/ic_load"
android:drawablePadding="4dp"
android:gravity="center_vertical"
android:orientation="horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="6dp"
android:src="@mipmap/ic_load"></ImageView>
<TextView
android:id="@+id/tvTopItemCount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:paddingLeft="6dp"
android:paddingTop="2dp"
android:paddingRight="8dp"
android:paddingBottom="2dp"
android:text="143.2万"
android:textColor="@color/white"
android:textSize="12sp" />
</LinearLayout>
</FrameLayout>
android:layout_marginLeft="8dp"
android:layout_marginRight="20dp"
android:orientation="vertical">
<TextView
android:id="@+id/tvTopItemTitle"
android:layout_width="match_parent"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:layout_marginTop="12dp"
android:singleLine="true"
android:text="我去平行时空"
android:textColor="@color/black"
......@@ -79,8 +36,20 @@
android:id="@+id/tvTopItemText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:singleLine="true"
android:textColor="@color/gray"
android:textSize="11sp" />
<TextView
android:id="@+id/tvTopCurText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:singleLine="true"
android:textColor="@color/red"
android:textSize="11sp" />
</LinearLayout>
</LinearLayout>
\ No newline at end of file
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