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
68e88c00
Commit
68e88c00
authored
Oct 23, 2019
by
Vladislav Bogdashkin
🎣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added abstract CommonAdapter<CommonViewHolder>
added adapter for pushes
parent
c4e3681f
Changes
11
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
191 additions
and
10 deletions
+191
-10
build.gradle
app/build.gradle
+1
-0
settings.kt
...com/biganto/visual/roompark/domain/interactor/settings.kt
+38
-1
settings.kt
...java/com/biganto/visual/roompark/domain/model/settings.kt
+1
-1
Adapter.kt
...visual/roompark/presentation/screen/deals/util/Adapter.kt
+7
-1
ScreenController.kt
...roompark/presentation/screen/settings/ScreenController.kt
+38
-3
ScreenPresenter.kt
.../roompark/presentation/screen/settings/ScreenPresenter.kt
+4
-0
ScreenViewState.kt
.../roompark/presentation/screen/settings/ScreenViewState.kt
+2
-0
Adapter.kt
...ual/roompark/presentation/screen/settings/util/Adapter.kt
+90
-0
ScreenController.kt
.../roompark/presentation/screen/to_flat/ScreenController.kt
+0
-2
bell_switcher_with_text_viewholder.xml
...rc/main/res/layout/bell_switcher_with_text_viewholder.xml
+2
-0
settings_screen.xml
app/src/main/res/layout/settings_screen.xml
+8
-2
No files found.
app/build.gradle
View file @
68e88c00
...
@@ -119,6 +119,7 @@ dependencies {
...
@@ -119,6 +119,7 @@ dependencies {
implementation
"com.jakewharton.rxbinding3:rxbinding-recyclerview:$rxBindingVersion"
implementation
"com.jakewharton.rxbinding3:rxbinding-recyclerview:$rxBindingVersion"
implementation
"com.jakewharton.rxbinding3:rxbinding-material:$rxBindingVersion"
implementation
"com.jakewharton.rxbinding3:rxbinding-material:$rxBindingVersion"
//Tests
//Tests
testImplementation
'junit:junit:4.12'
testImplementation
'junit:junit:4.12'
androidTestImplementation
'androidx.test:runner:1.2.0'
androidTestImplementation
'androidx.test:runner:1.2.0'
...
...
app/src/main/java/com/biganto/visual/roompark/domain/interactor/settings.kt
View file @
68e88c00
package
com.biganto.visual.roompark.domain.interactor
package
com.biganto.visual.roompark.domain.interactor
import
com.biganto.visual.roompark.domain.model.CachedDataModel
import
com.biganto.visual.roompark.domain.model.PushSwitchModel
import
com.biganto.visual.roompark.domain.model.SettingsModel
import
io.reactivex.Observable
import
javax.inject.Inject
import
javax.inject.Inject
/**
/**
...
@@ -8,4 +12,37 @@ import javax.inject.Inject
...
@@ -8,4 +12,37 @@ import javax.inject.Inject
class
SettingsInteractor
@Inject
constructor
(
class
SettingsInteractor
@Inject
constructor
(
){
){
fun
fetchSettings
():
Observable
<
SettingsModel
>
=
Observable
.
just
(
sampleSettings
)
companion
object
{
val
sampleSettings
=
SettingsModel
(
arrayListOf
(
PushSwitchModel
(
"Новости"
,
1
,
"zsldfj"
,
true
),
PushSwitchModel
(
"Блог"
,
2
,
"zsldfj"
,
false
),
PushSwitchModel
(
"Ход Строительства Дом №1"
,
3
,
"zsldfj"
,
true
),
PushSwitchModel
(
"Сделка кв №451"
,
4
,
"zsldfj"
,
true
),
PushSwitchModel
(
"Сделка кв №452"
,
5
,
"zsldfj"
,
true
)
),
arrayListOf
(
CachedDataModel
(
"Скачать карточки моих\n"
+
"квартир из избранного\n"
+
"и сделок"
,
8415456588L
,
900
),
CachedDataModel
(
"Скачать виртуальные туры \n"
+
"моих квартир из избранного\n"
+
"и сделок "
,
656853321588L
,
999
)
),
arrayListOf
(
CachedDataModel
(
"Всего скачано"
,
2834264238L
,
1
),
CachedDataModel
(
"Карточки квартир"
,
6434268L
,
2
),
CachedDataModel
(
"Виртуальные туры"
,
1782234268L
,
3
),
CachedDataModel
(
"Новости и заметки"
,
4323438L
,
4
),
CachedDataModel
(
"Фотографии"
,
164444L
,
5
)
)
)
}
}
}
app/src/main/java/com/biganto/visual/roompark/domain/model/settings.kt
View file @
68e88c00
...
@@ -7,8 +7,8 @@ package com.biganto.visual.roompark.domain.model
...
@@ -7,8 +7,8 @@ package com.biganto.visual.roompark.domain.model
data class
PushSwitchModel
(
data class
PushSwitchModel
(
val
title
:
String
,
val
title
:
String
,
val
pushId
:
String
,
val
innerId
:
Int
,
val
innerId
:
Int
,
val
pushId
:
String
,
val
switchState
:
Boolean
val
switchState
:
Boolean
)
)
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/deals/util/Adapter.kt
View file @
68e88c00
...
@@ -87,7 +87,13 @@ class DealViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
...
@@ -87,7 +87,13 @@ class DealViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
dealPayed
.
text
=
deal
.
dealPayout
.
toRubly
()
dealPayed
.
text
=
deal
.
dealPayout
.
toRubly
()
dealSumToPay
.
text
=
deal
.
dealToPay
.
toRubly
()
dealSumToPay
.
text
=
deal
.
dealToPay
.
toRubly
()
createStatusView
(
statusLayout
,
statusContainer
,
deal
.
statusList
,
deal
.
statusNo
,
false
)
createStatusView
(
statusLayout
,
statusContainer
,
deal
.
statusList
,
deal
.
statusNo
,
false
)
}
}
private
fun
renderCommonInfo
(
info
:
DealPreviewModel
){
private
fun
renderCommonInfo
(
info
:
DealPreviewModel
){
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/settings/ScreenController.kt
View file @
68e88c00
package
com.biganto.visual.roompark.presentation.screen.settings
package
com.biganto.visual.roompark.presentation.screen.settings
import
android.view.View
import
android.view.View
import
android.widget.ImageView
import
androidx.recyclerview.widget.LinearLayoutManager
import
androidx.recyclerview.widget.RecyclerView
import
butterknife.BindView
import
com.biganto.visual.roompark.R
import
com.biganto.visual.roompark.R
import
com.biganto.visual.roompark.base.RoomParkApplication
import
com.biganto.visual.roompark.base.RoomParkApplication
import
com.biganto.visual.roompark.base.RoomParkMainActivity
import
com.biganto.visual.roompark.base.RoomParkMainActivity
import
com.biganto.visual.roompark.conductor.BigantoBaseController
import
com.biganto.visual.roompark.conductor.BigantoBaseController
import
com.biganto.visual.roompark.presentation.screen.settings.util.PushListAdapter
import
com.google.android.material.textview.MaterialTextView
import
timber.log.Timber
import
timber.log.Timber
import
javax.inject.Inject
import
javax.inject.Inject
...
@@ -25,9 +31,33 @@ class SettingsScreenController :
...
@@ -25,9 +31,33 @@ class SettingsScreenController :
@Inject
@Inject
override
lateinit
var
injectedPresenter
:
SettingsScreenPresenter
override
lateinit
var
injectedPresenter
:
SettingsScreenPresenter
@BindView
(
R
.
id
.
pushRecyclerView
)
lateinit
var
pushRecycler
:
RecyclerView
@BindView
(
R
.
id
.
cachedRecyclerView
)
lateinit
var
cachedRecycler
:
RecyclerView
@BindView
(
R
.
id
.
downloadToursText
)
lateinit
var
toursDownloaderTitle
:
MaterialTextView
@BindView
(
R
.
id
.
downloadFlatCardsText
)
lateinit
var
flatDownloaderTitle
:
MaterialTextView
@BindView
(
R
.
id
.
downloadToursIcon
)
lateinit
var
toursDownloaderButton
:
ImageView
@BindView
(
R
.
id
.
downloadFlatCardsIcon
)
lateinit
var
flatDownloaderButton
:
ImageView
override
fun
onViewBound
(
v
:
View
)
{
override
fun
onViewBound
(
v
:
View
)
{
pushRecycler
.
isNestedScrollingEnabled
=
true
pushRecycler
.
layoutManager
=
LinearLayoutManager
(
activity
,
RecyclerView
.
VERTICAL
,
false
)
pushRecycler
.
adapter
=
PushListAdapter
()
pushRecycler
.
itemAnimator
=
null
}
}
override
fun
render
(
viewState
:
SettingsScreenViewState
)
{
override
fun
render
(
viewState
:
SettingsScreenViewState
)
{
...
@@ -35,6 +65,7 @@ class SettingsScreenController :
...
@@ -35,6 +65,7 @@ class SettingsScreenController :
Timber
.
d
(
"Render state $viewState"
)
Timber
.
d
(
"Render state $viewState"
)
when
(
viewState
){
when
(
viewState
){
is
SettingsScreenViewState
.
Idle
->
render
(
viewState
)
is
SettingsScreenViewState
.
Idle
->
render
(
viewState
)
is
SettingsScreenViewState
.
LoadSettingsList
->
render
(
viewState
)
}
}
}
}
...
@@ -42,11 +73,15 @@ class SettingsScreenController :
...
@@ -42,11 +73,15 @@ class SettingsScreenController :
}
}
private
fun
render
(
viewState
:
SettingsScreenViewState
.
LoadSettingsList
){
(
pushRecycler
.
adapter
as
PushListAdapter
).
setItems
(
viewState
.
settings
.
pushItems
)
}
private
fun
getComponent
()
=
DaggerSettingsScreenComponent
.
factory
()
private
fun
getComponent
()
=
DaggerSettingsScreenComponent
.
factory
()
.
create
(
RoomParkApplication
.
component
,
activity
as
RoomParkMainActivity
)
.
create
(
RoomParkApplication
.
component
,
activity
as
RoomParkMainActivity
)
.
inject
(
this
)
.
inject
(
this
)
override
fun
getLayoutId
():
Int
=
R
.
layout
.
favorites_screen
override
fun
getLayoutId
():
Int
=
R
.
layout
.
settings_screen
}
}
\ No newline at end of file
app/src/main/java/com/biganto/visual/roompark/presentation/screen/settings/ScreenPresenter.kt
View file @
68e88c00
...
@@ -20,7 +20,11 @@ class SettingsScreenPresenter @Inject constructor(
...
@@ -20,7 +20,11 @@ class SettingsScreenPresenter @Inject constructor(
override
fun
bindIntents
()
{
override
fun
bindIntents
()
{
val
fetchSettings
=
interactor
.
fetchSettings
()
.
map
{
SettingsScreenViewState
.
LoadSettingsList
(
it
)
}
val
state
=
restoreStateObservable
val
state
=
restoreStateObservable
.
mergeWith
(
fetchSettings
)
.
doOnError
{
Timber
.
e
(
it
)}
.
doOnError
{
Timber
.
e
(
it
)}
.
subscribeOn
(
Schedulers
.
io
())
.
subscribeOn
(
Schedulers
.
io
())
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
observeOn
(
AndroidSchedulers
.
mainThread
())
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/settings/ScreenViewState.kt
View file @
68e88c00
package
com.biganto.visual.roompark.presentation.screen.settings
package
com.biganto.visual.roompark.presentation.screen.settings
import
com.biganto.visual.roompark.conductor.BigantoBaseViewState
import
com.biganto.visual.roompark.conductor.BigantoBaseViewState
import
com.biganto.visual.roompark.domain.model.SettingsModel
/**
/**
* Created by Vladislav Bogdashkin on 30.09.2019.
* Created by Vladislav Bogdashkin on 30.09.2019.
...
@@ -9,4 +10,5 @@ import com.biganto.visual.roompark.conductor.BigantoBaseViewState
...
@@ -9,4 +10,5 @@ import com.biganto.visual.roompark.conductor.BigantoBaseViewState
sealed
class
SettingsScreenViewState
:
BigantoBaseViewState
()
{
sealed
class
SettingsScreenViewState
:
BigantoBaseViewState
()
{
class
Idle
:
SettingsScreenViewState
()
class
Idle
:
SettingsScreenViewState
()
class
LoadSettingsList
(
val
settings
:
SettingsModel
)
:
SettingsScreenViewState
()
}
}
\ No newline at end of file
app/src/main/java/com/biganto/visual/roompark/presentation/screen/settings/util/Adapter.kt
0 → 100644
View file @
68e88c00
package
com.biganto.visual.roompark.presentation.screen.settings.util
import
android.view.LayoutInflater
import
android.view.View
import
android.view.ViewGroup
import
androidx.annotation.LayoutRes
import
androidx.recyclerview.widget.RecyclerView
import
butterknife.BindView
import
butterknife.ButterKnife
import
com.biganto.visual.roompark.R
import
com.biganto.visual.roompark.domain.model.PushSwitchModel
import
com.google.android.material.switchmaterial.SwitchMaterial
import
com.google.android.material.textview.MaterialTextView
import
timber.log.Timber
import
kotlin.reflect.KClass
import
kotlin.reflect.full.valueParameters
import
kotlin.reflect.jvm.javaType
/**
* Created by Vladislav Bogdashkin on 16.10.2019.
*/
abstract
class
CommonRecyclerAdapter
<
VH
:
CommonViewHolder
<
M
>,
M
>
:
RecyclerView
.
Adapter
<
VH
>()
{
private
var
list
:
MutableList
<
M
>
=
mutableListOf
()
fun
setItems
(
list
:
List
<
M
>){
this
.
list
.
clear
()
this
.
list
.
addAll
(
list
)
notifyDataSetChanged
()
}
protected
abstract
val
vhKlazz
:
KClass
<
VH
>
@LayoutRes
protected
abstract
fun
getVhLayout
()
:
Int
private
fun
inflateViewHolder
(
parent
:
ViewGroup
):
View
=
LayoutInflater
.
from
(
parent
.
context
)
.
inflate
(
getVhLayout
(),
parent
,
false
)
private
fun
getViewHolderInstance
(
klazz
:
KClass
<
VH
>,
view
:
View
):
VH
=
klazz
.
constructors
.
first
{
it
.
valueParameters
[
0
].
type
.
javaType
==
View
::
class
.
java
}.
call
(
view
)
override
fun
onCreateViewHolder
(
parent
:
ViewGroup
,
viewType
:
Int
):
VH
=
getViewHolderInstance
(
vhKlazz
,
inflateViewHolder
(
parent
))
override
fun
getItemCount
():
Int
=
list
.
size
override
fun
onBindViewHolder
(
holder
:
VH
,
position
:
Int
)
{
holder
.
bindModel
(
list
[
position
])
}
}
abstract
class
CommonViewHolder
<
M
>(
itemView
:
View
):
RecyclerView
.
ViewHolder
(
itemView
)
{
abstract
fun
onViewBound
(
model
:
M
)
fun
bindModel
(
model
:
M
){
ButterKnife
.
bind
(
this
,
itemView
)
onViewBound
(
model
)
}
}
class
PushListAdapter
:
CommonRecyclerAdapter
<
PushViewHolder
,
PushSwitchModel
>()
{
override
val
vhKlazz
:
KClass
<
PushViewHolder
>
get
()
=
PushViewHolder
::
class
override
fun
getVhLayout
():
Int
=
R
.
layout
.
bell_switcher_with_text_viewholder
}
class
PushViewHolder
(
itemView
:
View
)
:
CommonViewHolder
<
PushSwitchModel
>(
itemView
)
{
@BindView
(
R
.
id
.
bellSwitcherTitle
)
lateinit
var
bellTitle
:
MaterialTextView
@BindView
(
R
.
id
.
bellSwitch
)
lateinit
var
switcher
:
ViewGroup
override
fun
onViewBound
(
model
:
PushSwitchModel
)
{
Timber
.
d
(
"model is : $model"
)
bellTitle
.
text
=
model
.
title
switcher
.
findViewById
<
SwitchMaterial
>(
R
.
id
.
switch1
).
isChecked
=
model
.
switchState
}
}
app/src/main/java/com/biganto/visual/roompark/presentation/screen/to_flat/ScreenController.kt
View file @
68e88c00
...
@@ -33,8 +33,6 @@ class FindFlatScreenController :
...
@@ -33,8 +33,6 @@ class FindFlatScreenController :
override
fun
getFlat
():
Observable
<
TourRequestModel
>
=
override
fun
getFlat
():
Observable
<
TourRequestModel
>
=
flatNumberEditor
.
keys
{
it
.
keyCode
==
KeyEvent
.
KEYCODE_ENTER
}
flatNumberEditor
.
keys
{
it
.
keyCode
==
KeyEvent
.
KEYCODE_ENTER
}
.
doOnNext
{
flatNumberEditor
.
hideKeyboard
()
}
.
doOnNext
{
flatNumberEditor
.
hideKeyboard
()
}
.
doOnNext
{
Timber
.
d
(
" key code is : ${it.keyCode}"
)}
.
doOnNext
{
Timber
.
d
(
" KeyEvent.FLAG_EDITOR_ACTION : ${KeyEvent.FLAG_EDITOR_ACTION}"
)}
.
map
{
.
map
{
TourRequestModel
(
TourRequestModel
(
estateTabs
[
flatTabs
.
selectedTabPosition
].
building
estateTabs
[
flatTabs
.
selectedTabPosition
].
building
...
...
app/src/main/res/layout/bell_switcher_with_text_viewholder.xml
View file @
68e88c00
...
@@ -7,6 +7,7 @@
...
@@ -7,6 +7,7 @@
android:weightSum=
"1"
>
android:weightSum=
"1"
>
<com.google.android.material.textview.MaterialTextView
<com.google.android.material.textview.MaterialTextView
android:id=
"@+id/bellSwitcherTitle"
style=
"@style/Common_Text.Default"
style=
"@style/Common_Text.Default"
android:layout_width=
"0dp"
android:layout_width=
"0dp"
android:layout_height=
"match_parent"
android:layout_height=
"match_parent"
...
@@ -15,6 +16,7 @@
...
@@ -15,6 +16,7 @@
android:text=
"блабла"
/>
android:text=
"блабла"
/>
<include
<include
android:id=
"@+id/bellSwitch"
layout=
"@layout/bell_switch_view"
layout=
"@layout/bell_switch_view"
android:layout_width=
"wrap_content"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
...
...
app/src/main/res/layout/settings_screen.xml
View file @
68e88c00
...
@@ -16,6 +16,7 @@
...
@@ -16,6 +16,7 @@
android:text=
"PUSH УВЕДОМЛЕНИЯ"
/>
android:text=
"PUSH УВЕДОМЛЕНИЯ"
/>
<androidx.recyclerview.widget.RecyclerView
<androidx.recyclerview.widget.RecyclerView
android:id=
"@+id/pushRecyclerView"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:orientation=
"vertical"
android:orientation=
"vertical"
...
@@ -41,6 +42,7 @@
...
@@ -41,6 +42,7 @@
android:weightSum=
"1"
>
android:weightSum=
"1"
>
<com.google.android.material.textview.MaterialTextView
<com.google.android.material.textview.MaterialTextView
android:id=
"@+id/downloadFlatCardsText"
style=
"@style/Common_Text.Default"
style=
"@style/Common_Text.Default"
android:layout_width=
"0dp"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
...
@@ -52,10 +54,11 @@
...
@@ -52,10 +54,11 @@
и сделок (4 MB)"
/>
и сделок (4 MB)"
/>
<ImageView
<ImageView
android:
src=
"@drawable/ic_flat
"
android:
id=
"@+id/downloadFlatCardsIcon
"
android:layout_width=
"24dp"
android:layout_width=
"24dp"
android:layout_height=
"24dp"
android:layout_height=
"24dp"
android:layout_gravity=
"end|center_vertical"
android:layout_gravity=
"end|center_vertical"
android:src=
"@drawable/ic_flat"
android:weightSum=
"1"
/>
android:weightSum=
"1"
/>
</LinearLayout>
</LinearLayout>
...
@@ -71,6 +74,7 @@
...
@@ -71,6 +74,7 @@
android:weightSum=
"1"
>
android:weightSum=
"1"
>
<com.google.android.material.textview.MaterialTextView
<com.google.android.material.textview.MaterialTextView
android:id=
"@+id/downloadToursText"
style=
"@style/Common_Text.Default"
style=
"@style/Common_Text.Default"
android:layout_width=
"0dp"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
...
@@ -82,10 +86,11 @@
...
@@ -82,10 +86,11 @@
и сделок (477 MB)"
/>
и сделок (477 MB)"
/>
<ImageView
<ImageView
android:
src=
"@drawable/ic_flat
"
android:
id=
"@+id/downloadToursIcon
"
android:layout_width=
"24dp"
android:layout_width=
"24dp"
android:layout_height=
"24dp"
android:layout_height=
"24dp"
android:layout_gravity=
"end|center_vertical"
android:layout_gravity=
"end|center_vertical"
android:src=
"@drawable/ic_flat"
android:weightSum=
"1"
/>
android:weightSum=
"1"
/>
</LinearLayout>
</LinearLayout>
...
@@ -102,6 +107,7 @@
...
@@ -102,6 +107,7 @@
<androidx.recyclerview.widget.RecyclerView
<androidx.recyclerview.widget.RecyclerView
android:id=
"@+id/cachedRecyclerView"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:orientation=
"vertical"
android:orientation=
"vertical"
...
...
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