Commit 422093e5 authored by 张释方's avatar 张释方

优化代码

parent b1c256a2
...@@ -96,6 +96,7 @@ ...@@ -96,6 +96,7 @@
<activity android:name=".main.my.PermissionsActivity"/> <activity android:name=".main.my.PermissionsActivity"/>
<activity android:name=".main.my.OpenvipActivity"/> <activity android:name=".main.my.OpenvipActivity"/>
<activity android:name=".main.home.HistoricalimageActivity"/> <activity android:name=".main.home.HistoricalimageActivity"/>
<activity android:name=".main.my.BindMobileActivity"/>
<!-- ShareSDK start --> <!-- ShareSDK start -->
<activity <activity
......
package com.mints.street.login package com.mints.street.login
import android.graphics.Color
import android.os.Bundle import android.os.Bundle
import android.os.PersistableBundle
import android.view.View import android.view.View
import androidx.lifecycle.Observer import androidx.lifecycle.Observer
import com.fry.base.base.BaseActivity import com.fry.base.base.BaseActivity
...@@ -14,37 +16,45 @@ import me.goldze.mvvmhabit.utils.ToastUtils ...@@ -14,37 +16,45 @@ import me.goldze.mvvmhabit.utils.ToastUtils
* Created by 冯瑞雨 on 2021/7/2. * Created by 冯瑞雨 on 2021/7/2.
*/ */
class LoginActivity : BaseActivity<ActivityLoginBinding, LoginViewModel>(), View.OnClickListener { class LoginActivity : BaseActivity<ActivityLoginBinding, LoginViewModel>(), View.OnClickListener {
override fun initContentView(savedInstanceState: Bundle?) = R.layout.activity_login override fun initContentView(savedInstanceState: Bundle?) = R.layout.activity_login
override fun initVariableId() = BR.viewModel override fun initVariableId() = BR.viewModel
override fun initData() { override fun initData() {
super.initData() super.initData()
initView() initView()
initListener()
} }
private fun initView() { private fun initListener() {
binding.button.setOnClickListener { binding.button.setOnClickListener {
viewModel.login() viewModel.login()
} }
iv_left_icon.setImageResource(R.mipmap.iv_return_white)
// iv_left_icon.visibility = View.VISIBLE iv_left_icon.setOnClickListener(this)
iv_left_icon.setOnClickListener(this) iv_left_icon.setOnClickListener(this)
} }
private fun initView() {
iv_left_icon.setImageResource(R.mipmap.iv_return_white)
iv_left_icon.visibility = View.VISIBLE
}
override fun initViewObservable() { override fun initViewObservable() {
super.initViewObservable() super.initViewObservable()
viewModel.data.observe(this, Observer<String>{ viewModel.data.observe(this, Observer<String>{
ToastUtils.showLong("初始化成功") ToastUtils.showLong("初始化成功")
}) })
} }
override fun onClick(v: View?) { override fun onClick(v: View?) {
when (v?.id) { when (v?.id) {
R.id.iv_left_icon -> { R.id.iv_left_icon -> finish()
finish()
}
} }
} }
} }
\ No newline at end of file
...@@ -17,15 +17,18 @@ class LoginViewModel(application: Application) : BaseViewModel(application) { ...@@ -17,15 +17,18 @@ class LoginViewModel(application: Application) : BaseViewModel(application) {
val data :MutableLiveData<String> = MutableLiveData() val data :MutableLiveData<String> = MutableLiveData()
fun login() { fun login() {
ApiModel.coinMsg(lifecycleProvider).safeSubscribe( ApiModel.coinMsg(lifecycleProvider).safeSubscribe(
object : HttpSubscribeImpl<BaseResponse<AwardBean>>( object : HttpSubscribeImpl<BaseResponse<AwardBean>>(
this@LoginViewModel, true this@LoginViewModel, true
) { ) {
override fun onBusinessSuccess(response: BaseResponse<AwardBean>) { override fun onBusinessSuccess(response: BaseResponse<AwardBean>) {
data.value = response.message
KLog.e("sfdsdf", response.result.toString()) KLog.e("sfdsdf", response.result.toString())
} }
override fun onError(e: Throwable) { override fun onError(e: Throwable) {
data.value = "失败"
KLog.e("LoginViewModel", "登录错误") KLog.e("LoginViewModel", "登录错误")
} }
......
...@@ -17,6 +17,11 @@ class AboutusActivity :BaseActivity<ActivityAboutusBinding, AboutusViewModel>(), ...@@ -17,6 +17,11 @@ class AboutusActivity :BaseActivity<ActivityAboutusBinding, AboutusViewModel>(),
override fun initData() { override fun initData() {
super.initData() super.initData()
initView() initView()
initListener()
}
private fun initListener() {
iv_left_icon.setOnClickListener(this)
} }
private fun initView() { private fun initView() {
......
...@@ -11,7 +11,6 @@ import com.mints.street.databinding.ActivityBindmobileBinding ...@@ -11,7 +11,6 @@ import com.mints.street.databinding.ActivityBindmobileBinding
import com.mints.street.utils.BackInputUtil import com.mints.street.utils.BackInputUtil
import com.tbruyelle.rxpermissions2.RxPermissions import com.tbruyelle.rxpermissions2.RxPermissions
import kotlinx.android.synthetic.main.activity_bindmobile.* import kotlinx.android.synthetic.main.activity_bindmobile.*
import kotlinx.android.synthetic.main.activity_container.*
import kotlinx.android.synthetic.main.include_header.* import kotlinx.android.synthetic.main.include_header.*
import me.goldze.mvvmhabit.utils.ToastUtils import me.goldze.mvvmhabit.utils.ToastUtils
......
...@@ -43,9 +43,10 @@ class MoresettingsActivity : BaseActivity<ActivityMoresettingsBinding, Moresetti ...@@ -43,9 +43,10 @@ class MoresettingsActivity : BaseActivity<ActivityMoresettingsBinding, Moresetti
val phone = ContextCompat.getDrawable(this, R.mipmap.icon_settings_tel) val phone = ContextCompat.getDrawable(this, R.mipmap.icon_settings_tel)
phone?.setBounds(0, 0, 56, 56) phone?.setBounds(0, 0, 56, 56)
item_phone.findViewById<TextView>(R.id.tv_title).setCompoundDrawables(phone, null, null, null) item_phone.findViewById<TextView>(R.id.tv_title).setCompoundDrawables(phone, null, null, null)
item_phone.findViewById<TextView>(R.id.tv_right).visibility = View.VISIBLE // item_phone.findViewById<TextView>(R.id.tv_right).visibility=View.VISIBLE
item_phone.findViewById<ImageView>(R.id.iv_right).visibility = View.GONE // item_phone.findViewById<TextView>(R.id.tv_right).text = "未绑定"
item_phone.findViewById<TextView>(R.id.tv_right).text = "未绑定" item_phone.findViewById<TextView>(R.id.tv_right).visibility = View.GONE
item_phone.findViewById<ImageView>(R.id.iv_right).visibility = View.VISIBLE
item_userAgree.findViewById<TextView>(R.id.tv_title).text = "用户协议" item_userAgree.findViewById<TextView>(R.id.tv_title).text = "用户协议"
val userAgree = ContextCompat.getDrawable(this, R.mipmap.icon_settings_user) val userAgree = ContextCompat.getDrawable(this, R.mipmap.icon_settings_user)
......
...@@ -73,8 +73,8 @@ class MyFragment : BaseFragment<FragmentMyBinding, MyViewModel>(), View.OnClickL ...@@ -73,8 +73,8 @@ class MyFragment : BaseFragment<FragmentMyBinding, MyViewModel>(), View.OnClickL
override fun onClick(v: View?) { override fun onClick(v: View?) {
when (v?.id) { when (v?.id) {
R.id.ly_aboutus -> { R.id.ly_aboutus -> {
// startActivity(AboutusActivity::class.java) startActivity(AboutusActivity::class.java)
startActivity(HistoricalimageActivity::class.java) // startActivity(HistoricalimageActivity::class.java)
} }
R.id.ly_moresettings -> { R.id.ly_moresettings -> {
startActivity(MoresettingsActivity::class.java) startActivity(MoresettingsActivity::class.java)
......
...@@ -10,13 +10,18 @@ import kotlinx.android.synthetic.main.activity_openvip.* ...@@ -10,13 +10,18 @@ import kotlinx.android.synthetic.main.activity_openvip.*
import kotlinx.android.synthetic.main.include_header.* import kotlinx.android.synthetic.main.include_header.*
class OpenvipActivity: BaseActivity<ActivityOpenvipBinding, OpenvipViewModel>() { class OpenvipActivity: BaseActivity<ActivityOpenvipBinding, OpenvipViewModel>(), View.OnClickListener {
override fun initVariableId() = BR.viewModel override fun initVariableId() = BR.viewModel
override fun initContentView(savedInstanceState: Bundle?)= R.layout.activity_openvip override fun initContentView(savedInstanceState: Bundle?)= R.layout.activity_openvip
override fun initData() { override fun initData() {
super.initData() super.initData()
initView() initView()
initListener()
}
private fun initListener() {
iv_left_icon.setOnClickListener(this)
} }
private fun initView() { private fun initView() {
...@@ -42,6 +47,12 @@ class OpenvipActivity: BaseActivity<ActivityOpenvipBinding, OpenvipViewModel>() ...@@ -42,6 +47,12 @@ class OpenvipActivity: BaseActivity<ActivityOpenvipBinding, OpenvipViewModel>()
iv_left_icon.visibility= View.VISIBLE iv_left_icon.visibility= View.VISIBLE
} }
override fun onClick(v: View?) {
when(v?.id){
R.id.iv_left_icon->finish()
}
}
} }
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<data> <data>
<variable <variable
name="ViewModel" name="viewModel"
type="com.mints.street.main.home.HistoricalimageModel" /> type="com.mints.street.main.home.HistoricalimageModel" />
</data> </data>
<LinearLayout <LinearLayout
......
...@@ -14,7 +14,9 @@ ...@@ -14,7 +14,9 @@
android:background="#CC000000" android:background="#CC000000"
android:orientation="vertical"> android:orientation="vertical">
<include layout="@layout/include_header"/> <include
android:id="@+id/ic_q"
layout="@layout/include_header"/>
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
...@@ -22,7 +24,8 @@ ...@@ -22,7 +24,8 @@
android:layout_gravity="center" android:layout_gravity="center"
android:layout_marginTop="60dp" android:layout_marginTop="60dp"
android:text="在国内也能用的" android:text="在国内也能用的"
android:textSize="24dp" /> android:textSize="24dp"
/>
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
......
...@@ -30,18 +30,6 @@ ...@@ -30,18 +30,6 @@
android:id="@+id/item_phone" android:id="@+id/item_phone"
layout="@layout/item_settings" /> layout="@layout/item_settings" />
<include
android:id="@+id/item_wechat"
layout="@layout/item_settings" />
<include
android:id="@+id/item_invitedCode"
layout="@layout/item_settings" />
<include
android:id="@+id/item_cleanCache"
layout="@layout/item_settings" />
<include <include
android:id="@+id/item_userAgree" android:id="@+id/item_userAgree"
layout="@layout/item_settings" /> layout="@layout/item_settings" />
...@@ -50,14 +38,6 @@ ...@@ -50,14 +38,6 @@
android:id="@+id/item_privacyAgree" android:id="@+id/item_privacyAgree"
layout="@layout/item_settings" /> layout="@layout/item_settings" />
<include
android:id="@+id/item_aboutUs"
layout="@layout/item_settings" />
<include
android:id="@+id/item_feedBack"
layout="@layout/item_settings" />
<Button <Button
android:id="@+id/btn_switch" android:id="@+id/btn_switch"
android:layout_width="200dp" android:layout_width="200dp"
......
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