Commit e73b0196 by LouisWang

feat(项目):调整代码规范

parent 20013e44
......@@ -35,7 +35,7 @@ object DemoApi {
/**
* 获取常用网站
*/
fun getPopularWebsites(): HttpObservable<ArrayList<PopularWebsitesEntity>> {
fun listPopularWebsites(): HttpObservable<ArrayList<PopularWebsitesEntity>> {
return HttpUtil.get("friend/json")
.asResponseList()
}
......
......@@ -34,7 +34,7 @@ class PopularWebsitesActivity : BaseLifecycleActivity<PopularWebsitesViewModel>(
}
override fun initListener() {
swipeRefresh.setOnRefreshListener { loadDataOnCreate() }
swipeRefresh.setOnRefreshListener { mViewModel.loadPopularWebsitesList(this) }
}
override fun initLifecycleObserver() {
......@@ -45,7 +45,7 @@ class PopularWebsitesActivity : BaseLifecycleActivity<PopularWebsitesViewModel>(
}
override fun loadDataOnCreate() {
mViewModel.getPopularWebsites(this)
mViewModel.loadPopularWebsitesList(this)
}
}
\ No newline at end of file
......@@ -24,7 +24,7 @@ class PopularWebsitesAdapter :
helper.setText(R.id.tvTitle, item.name)
helper.setText(R.id.tvLink, item.link)
helper.getView<ImageView>(R.id.image)
helper.getView<ImageView>(R.id.ivIcon)
.load(item.link, R.mipmap.ic_launcher, R.mipmap.ic_launcher)
}
}
\ No newline at end of file
......@@ -25,8 +25,8 @@ class PopularWebsitesViewModel : BaseViewModel() {
/**
* 获取常用网站
*/
fun getPopularWebsites(owner: LifecycleOwner) {
DemoApi.getPopularWebsites()
fun loadPopularWebsitesList(owner: LifecycleOwner) {
DemoApi.listPopularWebsites()
.attachLifecycle(owner)
.onSuccess {
listDataEvent.post(it)
......
......@@ -29,7 +29,7 @@ class MainActivity : BaseLifecycleActivity<MainViewModel>() {
// TODO: 2020/6/24 如果防止用户短时间多次点击,使用onClick,如果用户可以多次点击,还是使用原生的setOnClickListener
btnLogin.onClick {
// 登录
mViewModel.login(this, edPhone.text.toString(), edPwd.text.toString())
mViewModel.login(this, etPhone.text.toString(), etPwd.text.toString())
}
}
......
......@@ -8,14 +8,14 @@
android:paddingEnd="25dp">
<EditText
android:id="@+id/edPhone"
android:id="@+id/etPhone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/main_input_phone_hint"
android:textSize="16sp" />
<EditText
android:id="@+id/edPwd"
android:id="@+id/etPwd"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/main_input_password_hint"
......
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.constraintlayout.widget.ConstraintLayout 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="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal">
android:paddingStart="@dimen/album_dp_20"
android:paddingTop="@dimen/album_dp_10"
android:paddingEnd="@dimen/album_dp_20"
android:paddingBottom="@dimen/album_dp_10">
<ImageView
android:id="@+id/image"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp" />
<LinearLayout
android:id="@+id/ivIcon"
android:layout_width="@dimen/album_dp_50"
android:layout_height="@dimen/album_dp_50"
android:contentDescription="@null"
android:src="@color/durban_ColorPrimary"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/tvTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/tvTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="12dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:text="title"
android:textColor="#333333"
android:textSize="14dp"
android:textStyle="bold" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="12dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:layout_marginBottom="12dp"
android:orientation="horizontal">
<TextView
android:id="@+id/tvLink"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_weight="1"
android:ellipsize="end"
android:lines="1"
android:text="www.baidu.com"
android:textColor="#666666"
android:textSize="13dp" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
\ No newline at end of file
android:layout_marginStart="@dimen/durban_dp_70"
android:ellipsize="end"
android:maxLines="1"
android:text="@string/album_title"
android:textColor="@color/common_black_33"
android:textSize="@dimen/sp_14"
android:textStyle="bold"
app:layout_constraintStart_toEndOf="@+id/ivIcon"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/tvLink"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/durban_dp_70"
android:layout_marginTop="@dimen/album_dp_10"
android:ellipsize="end"
android:maxLines="1"
android:text="@string/album_check_album_little"
android:textColor="@color/common_gray_66"
android:textSize="@dimen/sp_13"
app:layout_constraintStart_toEndOf="@+id/ivIcon"
app:layout_constraintTop_toBottomOf="@+id/tvTitle" />
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
......@@ -3,4 +3,6 @@
<color name="colorPrimary">#6200EE</color>
<color name="colorPrimaryDark">#3700B3</color>
<color name="colorAccent">#03DAC5</color>
<color name="common_black_33">#333333</color>
<color name="common_gray_66">#666666</color>
</resources>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<resources>
<dimen name="sp_13">13sp</dimen>
<dimen name="sp_14">14sp</dimen>
</resources>
\ 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