Commit e73b0196 by LouisWang

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

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