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
20013e44
Commit
20013e44
authored
Jun 28, 2020
by
LouisWang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(项目):调整代码规范
parent
754147f8
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
41 additions
and
28 deletions
+41
-28
mvvm-demo/src/main/AndroidManifest.xml
+2
-1
mvvm-demo/src/main/java/com/autocareai/mvvmdemo/common/http/ResponseListConverter.kt
+0
-0
mvvm-demo/src/main/java/com/autocareai/mvvmdemo/common/http/request.kt
+0
-2
mvvm-demo/src/main/java/com/autocareai/mvvmdemo/demo/api/DemoApi.kt
+2
-2
mvvm-demo/src/main/java/com/autocareai/mvvmdemo/demo/enity/PopularWebsitesEntity.kt
+1
-1
mvvm-demo/src/main/java/com/autocareai/mvvmdemo/demo/list/PopularWebsitesActivity.kt
+15
-10
mvvm-demo/src/main/java/com/autocareai/mvvmdemo/demo/list/PopularWebsitesAdapter.kt
+7
-4
mvvm-demo/src/main/java/com/autocareai/mvvmdemo/demo/list/PopularWebsitesViewModel.kt
+4
-4
mvvm-demo/src/main/java/com/autocareai/mvvmdemo/demo/main/MainActivity.kt
+1
-1
mvvm-demo/src/main/java/com/autocareai/mvvmdemo/demo/route/DemoRoute.kt
+9
-3
mvvm-demo/src/main/res/layout/activity_popular_websites.xml
+0
-0
mvvm-demo/src/main/res/layout/recycle_item_popular_websites.xml
+0
-0
No files found.
mvvm-demo/src/main/AndroidManifest.xml
View file @
20013e44
...
@@ -17,7 +17,7 @@
...
@@ -17,7 +17,7 @@
<category
android:name=
"android.intent.category.LAUNCHER"
/>
<category
android:name=
"android.intent.category.LAUNCHER"
/>
</intent-filter>
</intent-filter>
</activity>
</activity>
<activity
android:name=
".demo.list.
List
Activity"
/>
<activity
android:name=
".demo.list.
PopularWebsites
Activity"
/>
</application>
</application>
</manifest>
</manifest>
\ No newline at end of file
mvvm-demo/src/main/java/com/autocareai/mvvmdemo/common/http/ResponseListConverter.kt
View file @
20013e44
mvvm-demo/src/main/java/com/autocareai/mvvmdemo/common/http/request.kt
View file @
20013e44
...
@@ -23,8 +23,6 @@ inline fun <reified D : Any> BaseRequest<*>.asResponse(): HttpObservable<D> {
...
@@ -23,8 +23,6 @@ inline fun <reified D : Any> BaseRequest<*>.asResponse(): HttpObservable<D> {
/**
/**
* 将Http响应数据转换成一个列表,去除最外层封装
* 将Http响应数据转换成一个列表,去除最外层封装
*
* @param isAuth 是否需要添加认证参数,默认是true。
*/
*/
inline
fun
<
reified
D
:
Any
>
BaseRequest
<*>.
asResponseList
():
HttpObservable
<
ArrayList
<
D
>>
{
inline
fun
<
reified
D
:
Any
>
BaseRequest
<*>.
asResponseList
():
HttpObservable
<
ArrayList
<
D
>>
{
return
HttpObservableImpl
(
this
,
ResponseListConverter
(
D
::
class
.
java
))
return
HttpObservableImpl
(
this
,
ResponseListConverter
(
D
::
class
.
java
))
...
...
mvvm-demo/src/main/java/com/autocareai/mvvmdemo/demo/api/DemoApi.kt
View file @
20013e44
...
@@ -4,7 +4,7 @@ import com.autocareai.lib.net.HttpUtil
...
@@ -4,7 +4,7 @@ import com.autocareai.lib.net.HttpUtil
import
com.autocareai.lib.net.observable.HttpObservable
import
com.autocareai.lib.net.observable.HttpObservable
import
com.autocareai.mvvmdemo.common.http.asResponse
import
com.autocareai.mvvmdemo.common.http.asResponse
import
com.autocareai.mvvmdemo.common.http.asResponseList
import
com.autocareai.mvvmdemo.common.http.asResponseList
import
com.autocareai.mvvmdemo.demo.enity.
List
Entity
import
com.autocareai.mvvmdemo.demo.enity.
PopularWebsites
Entity
import
com.autocareai.mvvmdemo.demo.enity.UserEntity
import
com.autocareai.mvvmdemo.demo.enity.UserEntity
/**
/**
...
@@ -35,7 +35,7 @@ object DemoApi {
...
@@ -35,7 +35,7 @@ object DemoApi {
/**
/**
* 获取常用网站
* 获取常用网站
*/
*/
fun
getPopularWebsites
():
HttpObservable
<
ArrayList
<
List
Entity
>>
{
fun
getPopularWebsites
():
HttpObservable
<
ArrayList
<
PopularWebsites
Entity
>>
{
return
HttpUtil
.
get
(
"friend/json"
)
return
HttpUtil
.
get
(
"friend/json"
)
.
asResponseList
()
.
asResponseList
()
}
}
...
...
mvvm-demo/src/main/java/com/autocareai/mvvmdemo/demo/enity/
List
Entity.kt
→
mvvm-demo/src/main/java/com/autocareai/mvvmdemo/demo/enity/
PopularWebsites
Entity.kt
View file @
20013e44
...
@@ -12,7 +12,7 @@ import kotlinx.android.parcel.Parcelize
...
@@ -12,7 +12,7 @@ import kotlinx.android.parcel.Parcelize
* </pre>
* </pre>
*/
*/
@Parcelize
@Parcelize
class
List
Entity
:
Parcelable
{
class
PopularWebsites
Entity
:
Parcelable
{
//网站id
//网站id
var
id
=
0
var
id
=
0
...
...
mvvm-demo/src/main/java/com/autocareai/mvvmdemo/demo/list/
List
Activity.kt
→
mvvm-demo/src/main/java/com/autocareai/mvvmdemo/demo/list/
PopularWebsites
Activity.kt
View file @
20013e44
...
@@ -7,35 +7,40 @@ import com.autocareai.lib.route.Route
...
@@ -7,35 +7,40 @@ import com.autocareai.lib.route.Route
import
com.autocareai.mvvmdemo.R
import
com.autocareai.mvvmdemo.R
import
com.autocareai.mvvmdemo.common.view.BaseLifecycleActivity
import
com.autocareai.mvvmdemo.common.view.BaseLifecycleActivity
import
com.autocareai.mvvmdemo.demo.route.DemoRoute
import
com.autocareai.mvvmdemo.demo.route.DemoRoute
import
kotlinx.android.synthetic.main.
list_activity
.*
import
kotlinx.android.synthetic.main.
activity_popular_websites
.*
/**
/**
* <pre>
* <pre>
* author : louis wang
* author : louis wang
* time : 2020/06/28
* time : 2020/06/28
* desc :
* desc :
常用网站界面
* version: 1.0
* version: 1.0
* </pre>
* </pre>
*/
*/
@Route
(
path
=
DemoRoute
.
DEMO_LIST
)
@Route
(
path
=
DemoRoute
.
POPULAR_WEBSITES
)
class
ListActivity
:
BaseLifecycleActivity
<
List
ViewModel
>()
{
class
PopularWebsitesActivity
:
BaseLifecycleActivity
<
PopularWebsites
ViewModel
>()
{
private
val
adapter
by
lazy
{
ListAdapter
()
}
//常用网站适配器
private
val
mPopularWebsitesAdapter
by
lazy
{
PopularWebsitesAdapter
()
}
override
fun
getLayoutId
():
Int
=
R
.
layout
.
list_activity
override
fun
getLayoutId
():
Int
=
R
.
layout
.
activity_popular_websites
override
fun
getViewModelClass
():
Class
<
ListViewModel
>
=
ListViewModel
::
class
.
java
override
fun
getViewModelClass
():
Class
<
PopularWebsitesViewModel
>
=
PopularWebsitesViewModel
::
class
.
java
override
fun
initView
(
savedInstanceState
:
Bundle
?)
{
override
fun
initView
(
savedInstanceState
:
Bundle
?)
{
swipeRefresh
.
setOnRefreshListener
{
loadDataOnCreate
()
}
recycleView
.
layoutManager
=
LinearLayoutManager
(
this
)
recycleView
.
layoutManager
=
LinearLayoutManager
(
this
)
recycleView
.
adapter
=
adapter
recycleView
.
adapter
=
mPopularWebsitesAdapter
}
override
fun
initListener
()
{
swipeRefresh
.
setOnRefreshListener
{
loadDataOnCreate
()
}
}
}
override
fun
initLifecycleObserver
()
{
override
fun
initLifecycleObserver
()
{
mViewModel
.
listDataEvent
.
observe
(
this
,
Observer
{
mViewModel
.
listDataEvent
.
observe
(
this
,
Observer
{
swipeRefresh
.
isRefreshing
=
false
swipeRefresh
.
isRefreshing
=
false
a
dapter
.
setNewData
(
it
)
mPopularWebsitesA
dapter
.
setNewData
(
it
)
})
})
}
}
...
...
mvvm-demo/src/main/java/com/autocareai/mvvmdemo/demo/list/
List
Adapter.kt
→
mvvm-demo/src/main/java/com/autocareai/mvvmdemo/demo/list/
PopularWebsites
Adapter.kt
View file @
20013e44
...
@@ -5,7 +5,7 @@ import com.autocareai.lib.extension.load
...
@@ -5,7 +5,7 @@ import com.autocareai.lib.extension.load
import
com.autocareai.lib.widget.recyclerview.BaseViewHolder
import
com.autocareai.lib.widget.recyclerview.BaseViewHolder
import
com.autocareai.mvvmdemo.R
import
com.autocareai.mvvmdemo.R
import
com.autocareai.mvvmdemo.common.view.BaseAdapter
import
com.autocareai.mvvmdemo.common.view.BaseAdapter
import
com.autocareai.mvvmdemo.demo.enity.
List
Entity
import
com.autocareai.mvvmdemo.demo.enity.
PopularWebsites
Entity
/**
/**
...
@@ -16,13 +16,15 @@ import com.autocareai.mvvmdemo.demo.enity.ListEntity
...
@@ -16,13 +16,15 @@ import com.autocareai.mvvmdemo.demo.enity.ListEntity
* version: 1.0
* version: 1.0
* </pre>
* </pre>
*/
*/
class
ListAdapter
:
BaseAdapter
<
ListEntity
>(
R
.
layout
.
list_item
)
{
class
PopularWebsitesAdapter
:
BaseAdapter
<
PopularWebsitesEntity
>(
R
.
layout
.
recycle_item_popular_websites
)
{
override
fun
convert
(
helper
:
BaseViewHolder
,
item
:
List
Entity
)
{
override
fun
convert
(
helper
:
BaseViewHolder
,
item
:
PopularWebsites
Entity
)
{
super
.
convert
(
helper
,
item
)
super
.
convert
(
helper
,
item
)
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
).
load
(
item
.
link
,
R
.
mipmap
.
ic_launcher
,
R
.
mipmap
.
ic_launcher
)
helper
.
getView
<
ImageView
>(
R
.
id
.
image
)
.
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/
List
ViewModel.kt
→
mvvm-demo/src/main/java/com/autocareai/mvvmdemo/demo/list/
PopularWebsites
ViewModel.kt
View file @
20013e44
...
@@ -5,22 +5,22 @@ import com.autocareai.lib.lifecycle.extension.post
...
@@ -5,22 +5,22 @@ import com.autocareai.lib.lifecycle.extension.post
import
com.autocareai.lib.lifecycle.livedata.SingleLiveEvent
import
com.autocareai.lib.lifecycle.livedata.SingleLiveEvent
import
com.autocareai.mvvmdemo.common.view.BaseViewModel
import
com.autocareai.mvvmdemo.common.view.BaseViewModel
import
com.autocareai.mvvmdemo.demo.api.DemoApi
import
com.autocareai.mvvmdemo.demo.api.DemoApi
import
com.autocareai.mvvmdemo.demo.enity.
List
Entity
import
com.autocareai.mvvmdemo.demo.enity.
PopularWebsites
Entity
/**
/**
* <pre>
* <pre>
* author : louis wang
* author : louis wang
* time : 2020/06/28
* time : 2020/06/28
* desc :
* desc :
常用网站ViewModel
* version: 1.0
* version: 1.0
* </pre>
* </pre>
*/
*/
class
List
ViewModel
:
BaseViewModel
()
{
class
PopularWebsites
ViewModel
:
BaseViewModel
()
{
/**
/**
* 常用网站数据
* 常用网站数据
*/
*/
var
listDataEvent
=
SingleLiveEvent
<
ArrayList
<
List
Entity
>>()
var
listDataEvent
=
SingleLiveEvent
<
ArrayList
<
PopularWebsites
Entity
>>()
/**
/**
* 获取常用网站
* 获取常用网站
...
...
mvvm-demo/src/main/java/com/autocareai/mvvmdemo/demo/main/MainActivity.kt
View file @
20013e44
...
@@ -38,7 +38,7 @@ class MainActivity : BaseLifecycleActivity<MainViewModel>() {
...
@@ -38,7 +38,7 @@ class MainActivity : BaseLifecycleActivity<MainViewModel>() {
mViewModel
.
toListEvent
.
observe
(
this
,
Observer
{
mViewModel
.
toListEvent
.
observe
(
this
,
Observer
{
// 跳转至列表界面
// 跳转至列表界面
DemoRoute
.
to
List
().
navigation
(
this
)
DemoRoute
.
to
PopularWebsites
().
navigation
(
this
)
})
})
}
}
}
}
mvvm-demo/src/main/java/com/autocareai/mvvmdemo/demo/route/DemoRoute.kt
View file @
20013e44
...
@@ -12,12 +12,17 @@ import com.autocareai.lib.route.RouteNavigation
...
@@ -12,12 +12,17 @@ import com.autocareai.lib.route.RouteNavigation
*/
*/
object
DemoRoute
{
object
DemoRoute
{
//登录界面
const
val
LOGIN
=
"/demo/login"
const
val
LOGIN
=
"/demo/login"
const
val
DEMO_LIST
=
"/demo/list"
//常用网站界面
const
val
POPULAR_WEBSITES
=
"/demo/list"
fun
toList
():
RouteNavigation
{
/**
return
RouteNavigation
(
DEMO_LIST
)
* 跳转常用网站界面
*/
fun
toPopularWebsites
():
RouteNavigation
{
return
RouteNavigation
(
POPULAR_WEBSITES
)
}
}
}
}
\ No newline at end of file
mvvm-demo/src/main/res/layout/
list_activity
.xml
→
mvvm-demo/src/main/res/layout/
activity_popular_websites
.xml
View file @
20013e44
File moved
mvvm-demo/src/main/res/layout/
list_item
.xml
→
mvvm-demo/src/main/res/layout/
recycle_item_popular_websites
.xml
View file @
20013e44
File moved
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