Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mvvmdemo
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
LouisWang
mvvmdemo
Commits
e73b0196
Commit
e73b0196
authored
Jun 28, 2020
by
LouisWang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(项目):调整代码规范
parent
20013e44
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
66 additions
and
64 deletions
+66
-64
mvvm-demo/src/main/java/com/autocareai/mvvmdemo/demo/api/DemoApi.kt
+1
-1
mvvm-demo/src/main/java/com/autocareai/mvvmdemo/demo/list/PopularWebsitesActivity.kt
+3
-2
mvvm-demo/src/main/java/com/autocareai/mvvmdemo/demo/list/PopularWebsitesAdapter.kt
+2
-1
mvvm-demo/src/main/java/com/autocareai/mvvmdemo/demo/list/PopularWebsitesViewModel.kt
+2
-2
mvvm-demo/src/main/java/com/autocareai/mvvmdemo/demo/main/MainActivity.kt
+1
-1
mvvm-demo/src/main/res/layout/activity_main.xml
+2
-2
mvvm-demo/src/main/res/layout/recycle_item_popular_websites.xml
+46
-55
mvvm-demo/src/main/res/values/colors.xml
+3
-0
mvvm-demo/src/main/res/values/dimens.xml
+6
-0
No files found.
mvvm-demo/src/main/java/com/autocareai/mvvmdemo/demo/api/DemoApi.kt
View file @
e73b0196
...
...
@@ -35,7 +35,7 @@ object DemoApi {
/**
* 获取常用网站
*/
fun
ge
tPopularWebsites
():
HttpObservable
<
ArrayList
<
PopularWebsitesEntity
>>
{
fun
lis
tPopularWebsites
():
HttpObservable
<
ArrayList
<
PopularWebsitesEntity
>>
{
return
HttpUtil
.
get
(
"friend/json"
)
.
asResponseList
()
}
...
...
mvvm-demo/src/main/java/com/autocareai/mvvmdemo/demo/list/PopularWebsitesActivity.kt
View file @
e73b0196
...
...
@@ -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
mvvm-demo/src/main/java/com/autocareai/mvvmdemo/demo/list/PopularWebsitesAdapter.kt
View file @
e73b0196
...
...
@@ -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
.
i
mage
)
helper
.
getView
<
ImageView
>(
R
.
id
.
i
vIcon
)
.
load
(
item
.
link
,
R
.
mipmap
.
ic_launcher
,
R
.
mipmap
.
ic_launcher
)
}
}
\ No newline at end of file
mvvm-demo/src/main/java/com/autocareai/mvvmdemo/demo/list/PopularWebsitesViewModel.kt
View file @
e73b0196
...
...
@@ -25,8 +25,8 @@ class PopularWebsitesViewModel : BaseViewModel() {
/**
* 获取常用网站
*/
fun
getPopularWebsites
(
owner
:
LifecycleOwner
)
{
DemoApi
.
ge
tPopularWebsites
()
fun
loadPopularWebsitesList
(
owner
:
LifecycleOwner
)
{
DemoApi
.
lis
tPopularWebsites
()
.
attachLifecycle
(
owner
)
.
onSuccess
{
listDataEvent
.
post
(
it
)
...
...
mvvm-demo/src/main/java/com/autocareai/mvvmdemo/demo/main/MainActivity.kt
View file @
e73b0196
...
...
@@ -29,7 +29,7 @@ class MainActivity : BaseLifecycleActivity<MainViewModel>() {
// TODO: 2020/6/24 如果防止用户短时间多次点击,使用onClick,如果用户可以多次点击,还是使用原生的setOnClickListener
btnLogin
.
onClick
{
// 登录
mViewModel
.
login
(
this
,
e
dPhone
.
text
.
toString
(),
ed
Pwd
.
text
.
toString
())
mViewModel
.
login
(
this
,
e
tPhone
.
text
.
toString
(),
et
Pwd
.
text
.
toString
())
}
}
...
...
mvvm-demo/src/main/res/layout/activity_main.xml
View file @
e73b0196
...
...
@@ -8,14 +8,14 @@
android:paddingEnd=
"25dp"
>
<EditText
android:id=
"@+id/e
d
Phone"
android:id=
"@+id/e
t
Phone"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:hint=
"@string/main_input_phone_hint"
android:textSize=
"16sp"
/>
<EditText
android:id=
"@+id/e
d
Pwd"
android:id=
"@+id/e
t
Pwd"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:hint=
"@string/main_input_password_hint"
...
...
mvvm-demo/src/main/res/layout/recycle_item_popular_websites.xml
View file @
e73b0196
<?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
mvvm-demo/src/main/res/values/colors.xml
View file @
e73b0196
...
...
@@ -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
mvvm-demo/src/main/res/values/dimens.xml
0 → 100644
View file @
e73b0196
<?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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment