Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Room Park Android
Project
Project
Details
Activity
Releases
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vladislav Bogdashkin
Room Park Android
Commits
afbb9bd1
Commit
afbb9bd1
authored
Oct 25, 2019
by
Vladislav Bogdashkin
🎣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactore adapters
parent
ea9f64ac
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
31 additions
and
99 deletions
+31
-99
ScreenController.kt
...al/roompark/presentation/screen/feeds/ScreenController.kt
+7
-3
ArticlesPreviewAdapter.kt
...presentation/screen/feeds/utils/ArticlesPreviewAdapter.kt
+8
-34
CamsLIstAdapter.kt
...ompark/presentation/screen/feeds/utils/CamsLIstAdapter.kt
+7
-30
DevProgressPreviewAdapter.kt
...sentation/screen/feeds/utils/DevProgressPreviewAdapter.kt
+7
-30
feeds_screen.xml
app/src/main/res/layout/feeds_screen.xml
+2
-2
No files found.
app/src/main/java/com/biganto/visual/roompark/presentation/screen/feeds/ScreenController.kt
View file @
afbb9bd1
package
com.biganto.visual.roompark.presentation.screen.feeds
package
com.biganto.visual.roompark.presentation.screen.feeds
import
android.view.View
import
android.view.View
import
android.view.ViewGroup
import
android.widget.TextView
import
android.widget.TextView
import
androidx.recyclerview.widget.LinearLayoutManager
import
androidx.recyclerview.widget.LinearLayoutManager
import
androidx.recyclerview.widget.RecyclerView
import
androidx.recyclerview.widget.RecyclerView
...
@@ -52,6 +53,9 @@ class FeedsScreenController :
...
@@ -52,6 +53,9 @@ class FeedsScreenController :
@BindView
(
R
.
id
.
cams_recycler_view
)
@BindView
(
R
.
id
.
cams_recycler_view
)
lateinit
var
camsRecyclerView
:
RecyclerView
lateinit
var
camsRecyclerView
:
RecyclerView
@BindView
(
R
.
id
.
feedsBlock
)
lateinit
var
feedsBlockView
:
ViewGroup
private
fun
bindRecycler
(){
private
fun
bindRecycler
(){
feedsRecyclerView
.
isNestedScrollingEnabled
=
true
feedsRecyclerView
.
isNestedScrollingEnabled
=
true
...
@@ -119,15 +123,15 @@ class FeedsScreenController :
...
@@ -119,15 +123,15 @@ class FeedsScreenController :
}
}
private
fun
render
(
viewState
:
FeedsScreenViewState
.
AlbumsPages
){
private
fun
render
(
viewState
:
FeedsScreenViewState
.
AlbumsPages
){
(
devProgressRecyclerView
.
adapter
as
AlbumsPreviewAdapter
).
add
Items
(
viewState
.
items
)
(
devProgressRecyclerView
.
adapter
as
AlbumsPreviewAdapter
).
set
Items
(
viewState
.
items
)
}
}
private
fun
render
(
viewState
:
FeedsScreenViewState
.
GetFeedArticlesPreview
){
private
fun
render
(
viewState
:
FeedsScreenViewState
.
GetFeedArticlesPreview
){
(
feedsRecyclerView
.
adapter
as
ArticlesPreviewAdapter
).
add
Items
(
viewState
.
items
)
(
feedsRecyclerView
.
adapter
as
ArticlesPreviewAdapter
).
set
Items
(
viewState
.
items
)
}
}
private
fun
render
(
viewState
:
FeedsScreenViewState
.
CamsList
){
private
fun
render
(
viewState
:
FeedsScreenViewState
.
CamsList
){
(
camsRecyclerView
.
adapter
as
CamsListAdapter
).
add
Items
(
viewState
.
items
)
(
camsRecyclerView
.
adapter
as
CamsListAdapter
).
set
Items
(
viewState
.
items
)
}
}
private
fun
getComponent
()
=
DaggerFeedsScreenComponent
.
factory
()
private
fun
getComponent
()
=
DaggerFeedsScreenComponent
.
factory
()
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/feeds/utils/ArticlesPreviewAdapter.kt
View file @
afbb9bd1
package
com.biganto.visual.roompark.presentation.screen.feeds.utils
package
com.biganto.visual.roompark.presentation.screen.feeds.utils
import
android.view.LayoutInflater
import
android.view.View
import
android.view.View
import
android.view.ViewGroup
import
android.widget.ImageView
import
android.widget.ImageView
import
android.widget.TextView
import
android.widget.TextView
import
androidx.recyclerview.widget.RecyclerView
import
butterknife.BindView
import
butterknife.BindView
import
butterknife.ButterKnife
import
com.biganto.visual.roompark.R
import
com.biganto.visual.roompark.R
import
com.biganto.visual.roompark.domain.model.ArticlePreviewModel
import
com.biganto.visual.roompark.domain.model.ArticlePreviewModel
import
com.biganto.visual.roompark.presentation.screen.settings.util.CommonRecyclerAdapter
import
com.biganto.visual.roompark.presentation.screen.settings.util.CommonViewHolder
import
com.squareup.picasso.Picasso
import
com.squareup.picasso.Picasso
import
java.text.SimpleDateFormat
import
java.text.SimpleDateFormat
import
java.util.*
import
java.util.*
...
@@ -18,34 +16,16 @@ import java.util.*
...
@@ -18,34 +16,16 @@ import java.util.*
/**
/**
* Created by Vladislav Bogdashkin on 15.10.2019.
* Created by Vladislav Bogdashkin on 15.10.2019.
*/
*/
class
ArticlesPreviewAdapter
:
RecyclerView
.
Adapter
<
ArticlePreviewViewHolder
>()
{
class
ArticlesPreviewAdapter
:
CommonRecyclerAdapter
<
ArticlePreviewViewHolder
,
ArticlePreviewModel
>()
{
override
val
vhKlazz
=
ArticlePreviewViewHolder
::
class
private
var
list
:
MutableList
<
ArticlePreviewModel
>
=
mutableListOf
()
override
fun
getVhLayout
():
Int
=
R
.
layout
.
feed_preview_viewholder
fun
addItems
(
list
:
List
<
ArticlePreviewModel
>){
this
.
list
.
clear
()
this
.
list
.
addAll
(
list
)
notifyDataSetChanged
()
}
override
fun
onCreateViewHolder
(
parent
:
ViewGroup
,
viewType
:
Int
):
ArticlePreviewViewHolder
=
ArticlePreviewViewHolder
(
LayoutInflater
.
from
(
parent
.
context
)
.
inflate
(
R
.
layout
.
feed_preview_viewholder
,
parent
,
false
)
)
override
fun
getItemCount
():
Int
=
list
.
size
override
fun
onBindViewHolder
(
holder
:
ArticlePreviewViewHolder
,
position
:
Int
)
{
holder
.
bindModel
(
list
[
position
])
}
}
}
class
ArticlePreviewViewHolder
(
itemView
:
View
)
:
RecyclerView
.
ViewHolder
(
itemView
)
{
class
ArticlePreviewViewHolder
(
itemView
:
View
)
:
CommonViewHolder
<
ArticlePreviewModel
>
(
itemView
)
{
private
val
dateFormatter
=
SimpleDateFormat
(
"dd / MM / yyyy"
,
Locale
.
getDefault
())
private
val
dateFormatter
=
SimpleDateFormat
(
"dd / MM / yyyy"
,
Locale
.
getDefault
())
...
@@ -54,12 +34,7 @@ class ArticlePreviewViewHolder(itemView: View) : RecyclerView.ViewHolder(itemVie
...
@@ -54,12 +34,7 @@ class ArticlePreviewViewHolder(itemView: View) : RecyclerView.ViewHolder(itemVie
@BindView
(
R
.
id
.
feed_title_info_text_view
)
lateinit
var
articleTitle
:
TextView
@BindView
(
R
.
id
.
feed_title_info_text_view
)
lateinit
var
articleTitle
:
TextView
@BindView
(
R
.
id
.
feed_read
)
lateinit
var
articleIsRead
:
View
@BindView
(
R
.
id
.
feed_read
)
lateinit
var
articleIsRead
:
View
override
fun
onViewBound
(
model
:
ArticlePreviewModel
)
{
init
{
ButterKnife
.
bind
(
this
,
itemView
)
}
fun
bindModel
(
model
:
ArticlePreviewModel
){
articleDate
.
text
=
dateFormatter
.
format
(
model
.
published
)
articleDate
.
text
=
dateFormatter
.
format
(
model
.
published
)
articleTitle
.
text
=
model
.
title
articleTitle
.
text
=
model
.
title
articleIsRead
.
setGone
(
model
.
isRead
)
articleIsRead
.
setGone
(
model
.
isRead
)
...
@@ -68,9 +43,8 @@ class ArticlePreviewViewHolder(itemView: View) : RecyclerView.ViewHolder(itemVie
...
@@ -68,9 +43,8 @@ class ArticlePreviewViewHolder(itemView: View) : RecyclerView.ViewHolder(itemVie
.
load
(
model
.
previewUrl
)
.
load
(
model
.
previewUrl
)
.
into
(
preview
)
.
into
(
preview
)
}
}
}
}
fun
View
.
setGone
(
isGone
:
Boolean
){
private
fun
View
.
setGone
(
isGone
:
Boolean
){
this
.
visibility
=
if
(
isGone
)
View
.
GONE
else
View
.
VISIBLE
this
.
visibility
=
if
(
isGone
)
View
.
GONE
else
View
.
VISIBLE
}
}
\ No newline at end of file
app/src/main/java/com/biganto/visual/roompark/presentation/screen/feeds/utils/CamsLIstAdapter.kt
View file @
afbb9bd1
package
com.biganto.visual.roompark.presentation.screen.feeds.utils
package
com.biganto.visual.roompark.presentation.screen.feeds.utils
import
android.view.LayoutInflater
import
android.view.View
import
android.view.View
import
android.view.ViewGroup
import
android.widget.TextView
import
android.widget.TextView
import
androidx.recyclerview.widget.RecyclerView
import
butterknife.BindView
import
butterknife.BindView
import
butterknife.ButterKnife
import
com.biganto.visual.roompark.R
import
com.biganto.visual.roompark.R
import
com.biganto.visual.roompark.domain.model.WebCamModel
import
com.biganto.visual.roompark.domain.model.WebCamModel
import
com.biganto.visual.roompark.presentation.screen.settings.util.CommonRecyclerAdapter
import
com.biganto.visual.roompark.presentation.screen.settings.util.CommonViewHolder
/**
/**
* Created by Vladislav Bogdashkin on 15.10.2019.
* Created by Vladislav Bogdashkin on 15.10.2019.
*/
*/
class
CamsListAdapter
:
RecyclerView
.
Adapter
<
CamListViewHolder
>()
{
class
CamsListAdapter
:
CommonRecyclerAdapter
<
CamListViewHolder
,
WebCamModel
>()
{
override
val
vhKlazz
=
CamListViewHolder
::
class
private
var
list
:
MutableList
<
WebCamModel
>
=
mutableListOf
()
override
fun
getVhLayout
():
Int
=
R
.
layout
.
cam_button_viewholder
fun
addItems
(
list
:
List
<
WebCamModel
>){
this
.
list
.
clear
()
this
.
list
.
addAll
(
list
)
notifyDataSetChanged
()
}
override
fun
onCreateViewHolder
(
parent
:
ViewGroup
,
viewType
:
Int
):
CamListViewHolder
=
CamListViewHolder
(
LayoutInflater
.
from
(
parent
.
context
)
.
inflate
(
R
.
layout
.
cam_button_viewholder
,
parent
,
false
)
)
override
fun
getItemCount
():
Int
=
list
.
size
override
fun
onBindViewHolder
(
holder
:
CamListViewHolder
,
position
:
Int
)
{
holder
.
bindModel
(
list
[
position
])
}
}
}
class
CamListViewHolder
(
itemView
:
View
)
:
RecyclerView
.
ViewHolder
(
itemView
)
{
class
CamListViewHolder
(
itemView
:
View
)
:
CommonViewHolder
<
WebCamModel
>
(
itemView
)
{
@BindView
(
R
.
id
.
camTitle
)
lateinit
var
camTitle
:
TextView
@BindView
(
R
.
id
.
camTitle
)
lateinit
var
camTitle
:
TextView
@BindView
(
R
.
id
.
camStatus
)
lateinit
var
camStatus
:
View
@BindView
(
R
.
id
.
camStatus
)
lateinit
var
camStatus
:
View
init
{
override
fun
onViewBound
(
model
:
WebCamModel
)
{
ButterKnife
.
bind
(
this
,
itemView
)
}
fun
bindModel
(
model
:
WebCamModel
)
{
camTitle
.
text
=
model
.
title
camTitle
.
text
=
model
.
title
}
}
}
}
app/src/main/java/com/biganto/visual/roompark/presentation/screen/feeds/utils/DevProgressPreviewAdapter.kt
View file @
afbb9bd1
package
com.biganto.visual.roompark.presentation.screen.feeds.utils
package
com.biganto.visual.roompark.presentation.screen.feeds.utils
import
android.view.LayoutInflater
import
android.view.View
import
android.view.View
import
android.view.ViewGroup
import
android.widget.ImageView
import
android.widget.ImageView
import
android.widget.TextView
import
android.widget.TextView
import
androidx.recyclerview.widget.RecyclerView
import
butterknife.BindView
import
butterknife.BindView
import
butterknife.ButterKnife
import
com.biganto.visual.roompark.R
import
com.biganto.visual.roompark.R
import
com.biganto.visual.roompark.domain.model.AlbumPreviewModel
import
com.biganto.visual.roompark.domain.model.AlbumPreviewModel
import
com.biganto.visual.roompark.presentation.screen.settings.util.CommonRecyclerAdapter
import
com.biganto.visual.roompark.presentation.screen.settings.util.CommonViewHolder
import
com.squareup.picasso.Picasso
import
com.squareup.picasso.Picasso
import
java.text.SimpleDateFormat
import
java.text.SimpleDateFormat
import
java.util.*
import
java.util.*
...
@@ -18,31 +16,15 @@ import java.util.*
...
@@ -18,31 +16,15 @@ import java.util.*
/**
/**
* Created by Vladislav Bogdashkin on 15.10.2019.
* Created by Vladislav Bogdashkin on 15.10.2019.
*/
*/
class
AlbumsPreviewAdapter
:
RecyclerView
.
Adapter
<
AlbumCardViewHolder
>()
{
class
AlbumsPreviewAdapter
:
CommonRecyclerAdapter
<
AlbumCardViewHolder
,
AlbumPreviewModel
>()
{
private
var
list
:
MutableList
<
AlbumPreviewModel
>
=
mutableListOf
()
override
val
vhKlazz
=
AlbumCardViewHolder
::
class
fun
addItems
(
list
:
List
<
AlbumPreviewModel
>){
override
fun
getVhLayout
():
Int
=
R
.
layout
.
estate_card_viewholder
this
.
list
.
clear
()
this
.
list
.
addAll
(
list
)
notifyDataSetChanged
()
}
override
fun
onCreateViewHolder
(
parent
:
ViewGroup
,
viewType
:
Int
):
AlbumCardViewHolder
=
AlbumCardViewHolder
(
LayoutInflater
.
from
(
parent
.
context
)
.
inflate
(
R
.
layout
.
estate_card_viewholder
,
parent
,
false
)
)
override
fun
getItemCount
():
Int
=
list
.
size
override
fun
onBindViewHolder
(
holder
:
AlbumCardViewHolder
,
position
:
Int
)
{
holder
.
bindModel
(
list
[
position
])
}
}
}
class
AlbumCardViewHolder
(
itemView
:
View
)
:
RecyclerView
.
ViewHolder
(
itemView
)
{
class
AlbumCardViewHolder
(
itemView
:
View
)
:
CommonViewHolder
<
AlbumPreviewModel
>
(
itemView
)
{
private
val
dateFormatter
=
SimpleDateFormat
(
"dd MMMM yyyy"
,
Locale
(
"ru"
))
private
val
dateFormatter
=
SimpleDateFormat
(
"dd MMMM yyyy"
,
Locale
(
"ru"
))
...
@@ -50,11 +32,7 @@ class AlbumCardViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
...
@@ -50,11 +32,7 @@ class AlbumCardViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
@BindView
(
R
.
id
.
card_title
)
lateinit
var
articleTitle
:
TextView
@BindView
(
R
.
id
.
card_title
)
lateinit
var
articleTitle
:
TextView
@BindView
(
R
.
id
.
card_updated
)
lateinit
var
articleDate
:
TextView
@BindView
(
R
.
id
.
card_updated
)
lateinit
var
articleDate
:
TextView
init
{
override
fun
onViewBound
(
model
:
AlbumPreviewModel
)
{
ButterKnife
.
bind
(
this
,
itemView
)
}
fun
bindModel
(
model
:
AlbumPreviewModel
){
articleDate
.
text
=
dateFormatter
.
format
(
model
.
published
)
articleDate
.
text
=
dateFormatter
.
format
(
model
.
published
)
articleTitle
.
text
=
model
.
title
articleTitle
.
text
=
model
.
title
...
@@ -62,5 +40,4 @@ class AlbumCardViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
...
@@ -62,5 +40,4 @@ class AlbumCardViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
.
load
(
model
.
previewUrl
)
.
load
(
model
.
previewUrl
)
.
into
(
preview
)
.
into
(
preview
)
}
}
}
}
app/src/main/res/layout/feeds_screen.xml
View file @
afbb9bd1
...
@@ -12,7 +12,7 @@
...
@@ -12,7 +12,7 @@
android:layout_height=
"match_parent"
>
android:layout_height=
"match_parent"
>
<include
<include
android:id=
"@+id/
include
"
android:id=
"@+id/
feedsBlock
"
layout=
"@layout/feeds_block_view"
layout=
"@layout/feeds_block_view"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
...
@@ -29,7 +29,7 @@
...
@@ -29,7 +29,7 @@
android:text=
"ХОД\nСТРОИТЕЛЬСТВА"
android:text=
"ХОД\nСТРОИТЕЛЬСТВА"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@+id/
include
"
/>
app:layout_constraintTop_toBottomOf=
"@+id/
feedsBlock
"
/>
<androidx.recyclerview.widget.RecyclerView
<androidx.recyclerview.widget.RecyclerView
android:id=
"@+id/dev_progress_recycler_view"
android:id=
"@+id/dev_progress_recycler_view"
...
...
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