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
4ad06ff2
Commit
4ad06ff2
authored
Oct 14, 2019
by
Vladislav Bogdashkin
🎣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
customized feeds tab layout
parent
95b43e29
Changes
12
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
244 additions
and
97 deletions
+244
-97
feeds.kt
...va/com/biganto/visual/roompark/domain/interactor/feeds.kt
+114
-93
ScreenController.kt
...ual/roompark/presentation/screen/auth/ScreenController.kt
+0
-1
ScreenController.kt
...al/roompark/presentation/screen/feeds/ScreenController.kt
+29
-0
ScreenPresenter.kt
...ual/roompark/presentation/screen/feeds/ScreenPresenter.kt
+4
-0
ScreenViewState.kt
...ual/roompark/presentation/screen/feeds/ScreenViewState.kt
+2
-0
FeedsPagerAdapter.kt
...park/presentation/screen/feeds/utils/FeedsPagerAdapter.kt
+33
-0
tab_item_selector.xml
app/src/main/res/color/tab_item_selector.xml
+7
-0
feeds_block_view.xml
app/src/main/res/layout/feeds_block_view.xml
+15
-3
feeds_tab_view.xml
app/src/main/res/layout/feeds_tab_view.xml
+33
-0
strings.xml
app/src/main/res/values/strings.xml
+1
-0
styles.xml
app/src/main/res/values/styles.xml
+4
-0
view_size.xml
app/src/main/res/values/view_size.xml
+2
-0
No files found.
app/src/main/java/com/biganto/visual/roompark/domain/interactor/feeds.kt
View file @
4ad06ff2
...
@@ -13,27 +13,28 @@ import javax.inject.Inject
...
@@ -13,27 +13,28 @@ import javax.inject.Inject
*/
*/
class
FeedsInteractor
@Inject
constructor
(
class
FeedsInteractor
@Inject
constructor
(
){
)
{
fun
fetchTopFeeds
():
Single
<
FeedsHeaderModel
>
fun
fetchTopFeeds
():
Single
<
FeedsHeaderModel
>
=
Single
.
just
(
testFeeds
)
=
Single
.
just
(
testFeeds
)
fun
fetchArticles
(
feedId
:
Int
):
Single
<
ArticlesPreviewModel
>
fun
fetchArticles
(
feedId
:
Int
):
Single
<
ArticlesPreviewModel
>
=
Single
.
just
(
=
Single
.
just
(
when
(
feedId
)
{
when
(
feedId
)
{
1
->
testNewsArticles
1
->
testNewsArticles
2
->
testBlogsArticles
2
->
testBlogsArticles
3
->
testDevArticles
3
->
testDevArticles
else
->
error
(
"unknown feedId"
)
else
->
error
(
"unknown feedId"
)
})
}
)
private
companion
object
{
private
companion
object
{
private
const
val
sampleUrl
:
String
=
"https://room-park.ru/assets/news_articles/preview/00/00/00/109-8c9b72.jpeg"
private
const
val
sampleUrl
:
String
=
private
const
val
sampleUrlB
=
"https://room-park.ru/assets/news_articles/preview/00/00/00/104-2b4eff.jpeg"
"https://room-park.ru/assets/news_articles/preview/00/00/00/109-8c9b72.jpeg"
private
const
val
sampleUrlDev
=
"https://room-park.ru/assets/news_articles/preview/00/00/00/96-a972cd.jpeg"
private
const
val
sampleUrlB
=
"https://room-park.ru/assets/news_articles/preview/00/00/00/104-2b4eff.jpeg"
private
const
val
sampleUrlDev
=
"https://room-park.ru/assets/news_articles/preview/00/00/00/96-a972cd.jpeg"
val
testFeeds
=
FeedsHeaderModel
(
val
testFeeds
=
FeedsHeaderModel
(
listOf
(
listOf
(
...
@@ -43,75 +44,95 @@ class FeedsInteractor @Inject constructor(
...
@@ -43,75 +44,95 @@ class FeedsInteractor @Inject constructor(
)
)
)
)
val
testNewsArticles
=
ArticlesPreviewModel
(
1
,
val
testNewsArticles
=
ArticlesPreviewModel
(
1
,
listOf
(
listOf
(
ArticlePreviewModel
(
1
ArticlePreviewModel
(
1
,
Date
()
,
Date
()
,
"Первая новость"
,
"Первая новость"
,
"Самый очаровательной анонс в мире"
,
"Самый очаровательной анонс в мире"
,
sampleUrl
,
sampleUrl
,
false
),
,
false
ArticlePreviewModel
(
1
),
ArticlePreviewModel
(
1
,
Date
()
,
Date
()
,
"Первая новость"
,
"Первая новость"
,
"Самый очаровательной анонс в мире"
,
"Самый очаровательной анонс в мире"
,
sampleUrl
,
sampleUrl
,
false
),
,
false
ArticlePreviewModel
(
1
),
ArticlePreviewModel
(
1
,
Date
()
,
Date
()
,
"Первая новость"
,
"Первая новость"
,
"Самый очаровательной анонс в мире"
,
"Самый очаровательной анонс в мире"
,
sampleUrl
,
sampleUrl
,
false
)
,
false
)
)
)
)
)
val
testBlogsArticles
=
ArticlesPreviewModel
(
2
,
val
testBlogsArticles
=
ArticlesPreviewModel
(
2
,
listOf
(
listOf
(
ArticlePreviewModel
(
1
ArticlePreviewModel
(
1
,
Date
()
,
Date
()
,
"Первая новость"
,
"Первая новость"
,
"Самый очаровательной анонс в мире"
,
"Самый очаровательной анонс в мире"
,
sampleUrlB
,
sampleUrlB
,
false
),
,
false
ArticlePreviewModel
(
1
),
ArticlePreviewModel
(
1
,
Date
()
,
Date
()
,
"НОВЫЙ ОФИС ПРОДАЖ ЖК «РУМЯНЦЕВО-ПАРК»"
,
"НОВЫЙ ОФИС ПРОДАЖ ЖК «РУМЯНЦЕВО-ПАРК»"
,
"Самый очаровательной анонс в мире"
,
"Самый очаровательной анонс в мире"
,
sampleUrlB
,
sampleUrlB
,
false
),
,
false
ArticlePreviewModel
(
1
),
ArticlePreviewModel
(
1
,
Date
()
,
Date
()
,
"В «РУМЯНЦЕВО-ПАРК» ПРИСТУПИЛИ К МОНТАЖУ ОКОННЫХ БЛОКОВ"
,
"В «РУМЯНЦЕВО-ПАРК» ПРИСТУПИЛИ К МОНТАЖУ ОКОННЫХ БЛОКОВ"
,
"Самый очаровательной анонс в мире"
,
"Самый очаровательной анонс в мире"
,
sampleUrlB
,
sampleUrlB
,
false
)
,
false
)
)
)
)
)
val
testDevArticles
=
ArticlesPreviewModel
(
3
,
val
testDevArticles
=
ArticlesPreviewModel
(
3
,
listOf
(
listOf
(
ArticlePreviewModel
(
1
ArticlePreviewModel
(
1
,
Date
()
,
Date
()
,
"Ход1"
,
"Ход1"
,
"Самый очаровательной анонс в мире"
,
"Самый очаровательной анонс в мире"
,
sampleUrlDev
,
sampleUrlDev
,
false
),
,
false
ArticlePreviewModel
(
1
),
ArticlePreviewModel
(
1
,
Date
()
,
Date
()
,
"Ход2"
,
"Ход2"
,
"Самый очаровательной анонс в мире"
,
"Самый очаровательной анонс в мире"
,
sampleUrlDev
,
sampleUrlDev
,
false
),
,
false
ArticlePreviewModel
(
1
),
ArticlePreviewModel
(
1
,
Date
()
,
Date
()
,
"Ход3"
,
"Ход3"
,
"Самый очаровательной анонс в мире"
,
"Самый очаровательной анонс в мире"
,
sampleUrlDev
,
sampleUrlDev
,
false
)
,
false
)
)
)
)
)
}
}
}
}
}
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/auth/ScreenController.kt
View file @
4ad06ff2
...
@@ -75,7 +75,6 @@ class AuthScreenController :
...
@@ -75,7 +75,6 @@ class AuthScreenController :
is
AuthScreenViewState
.
SignedIn
->
render
(
viewState
)
is
AuthScreenViewState
.
SignedIn
->
render
(
viewState
)
is
AuthScreenViewState
.
SignInError
->
render
(
viewState
)
is
AuthScreenViewState
.
SignInError
->
render
(
viewState
)
}
}
}
}
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/feeds/ScreenController.kt
View file @
4ad06ff2
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.widget.TextView
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.feeds.utils.FeedsPagerAdapter
import
com.google.android.material.tabs.TabLayout
import
timber.log.Timber
import
timber.log.Timber
import
javax.inject.Inject
import
javax.inject.Inject
...
@@ -22,6 +26,11 @@ class FeedsScreenController :
...
@@ -22,6 +26,11 @@ class FeedsScreenController :
getComponent
()
getComponent
()
}
}
@BindView
(
R
.
id
.
feedsTabs
)
lateinit
var
feedsTabs
:
TabLayout
val
feedsAdapter
=
FeedsPagerAdapter
()
@Inject
@Inject
override
lateinit
var
injectedPresenter
:
FeedsScreenPresenter
override
lateinit
var
injectedPresenter
:
FeedsScreenPresenter
...
@@ -35,6 +44,7 @@ class FeedsScreenController :
...
@@ -35,6 +44,7 @@ class FeedsScreenController :
Timber
.
d
(
"Render state $viewState"
)
Timber
.
d
(
"Render state $viewState"
)
when
(
viewState
){
when
(
viewState
){
is
FeedsScreenViewState
.
Idle
->
render
(
viewState
)
is
FeedsScreenViewState
.
Idle
->
render
(
viewState
)
is
FeedsScreenViewState
.
FeedsPages
->
render
(
viewState
)
}
}
}
}
...
@@ -42,6 +52,25 @@ class FeedsScreenController :
...
@@ -42,6 +52,25 @@ class FeedsScreenController :
}
}
private
fun
render
(
viewState
:
FeedsScreenViewState
.
FeedsPages
){
feedsTabs
.
removeAllTabs
()
viewState
.
items
.
forEach
{
feed
->
val
tab
=
feedsTabs
.
newTab
()
.
setCustomView
(
R
.
layout
.
feeds_tab_view
)
tab
.
customView
?.
let
{
it
.
findViewById
<
TextView
>(
R
.
id
.
tab_title
)
?.
text
=
feed
.
title
it
.
findViewById
<
TextView
>(
R
.
id
.
tab_divider
)
?.
visibility
=
if
(
viewState
.
items
.
indexOf
(
feed
)
==
viewState
.
items
.
size
-
1
)
View
.
GONE
else
View
.
VISIBLE
}
feedsTabs
.
addTab
(
tab
)
}
}
private
fun
getComponent
()
=
DaggerFeedsScreenComponent
.
factory
()
private
fun
getComponent
()
=
DaggerFeedsScreenComponent
.
factory
()
.
create
(
RoomParkApplication
.
component
,
activity
as
RoomParkMainActivity
)
.
create
(
RoomParkApplication
.
component
,
activity
as
RoomParkMainActivity
)
.
inject
(
this
)
.
inject
(
this
)
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/feeds/ScreenPresenter.kt
View file @
4ad06ff2
...
@@ -20,7 +20,11 @@ class FeedsScreenPresenter @Inject constructor(
...
@@ -20,7 +20,11 @@ class FeedsScreenPresenter @Inject constructor(
override
fun
bindIntents
()
{
override
fun
bindIntents
()
{
val
fetchFeeds
=
interactor
.
fetchTopFeeds
()
.
map
{
FeedsScreenViewState
.
FeedsPages
(
it
.
feeds
.
toList
())
}
val
state
=
restoreStateObservable
val
state
=
restoreStateObservable
.
mergeWith
(
fetchFeeds
)
.
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/feeds/ScreenViewState.kt
View file @
4ad06ff2
package
com.biganto.visual.roompark.presentation.screen.feeds
package
com.biganto.visual.roompark.presentation.screen.feeds
import
com.biganto.visual.roompark.conductor.BigantoBaseViewState
import
com.biganto.visual.roompark.conductor.BigantoBaseViewState
import
com.biganto.visual.roompark.domain.model.FeedModel
/**
/**
* 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
FeedsScreenViewState
:
BigantoBaseViewState
()
{
sealed
class
FeedsScreenViewState
:
BigantoBaseViewState
()
{
class
Idle
:
FeedsScreenViewState
()
class
Idle
:
FeedsScreenViewState
()
class
FeedsPages
(
val
items
:
List
<
FeedModel
>)
:
FeedsScreenViewState
()
}
}
\ No newline at end of file
app/src/main/java/com/biganto/visual/roompark/presentation/screen/feeds/utils/FeedsPagerAdapter.kt
0 → 100644
View file @
4ad06ff2
package
com.biganto.visual.roompark.presentation.screen.feeds.utils
import
android.view.View
import
androidx.viewpager.widget.PagerAdapter
import
com.biganto.visual.roompark.domain.model.FeedModel
import
timber.log.Timber
/**
* Created by Vladislav Bogdashkin on 14.10.2019.
*/
class
FeedsPagerAdapter
:
PagerAdapter
()
{
public
fun
updateData
(
items
:
List
<
FeedModel
>){
if
(
list
.
size
>
0
)
Timber
.
w
(
"View pager list is not empty!"
)
list
.
clear
()
list
.
addAll
(
items
)
notifyDataSetChanged
()
}
private
val
list
:
MutableList
<
FeedModel
>
=
mutableListOf
()
override
fun
isViewFromObject
(
view
:
View
,
`object`
:
Any
):
Boolean
{
TODO
(
"not implemented"
)
//To change body of created functions use File | Settings | File Templates.
}
override
fun
getCount
():
Int
=
list
.
size
override
fun
getPageTitle
(
position
:
Int
):
CharSequence
?
=
list
[
position
].
title
}
\ No newline at end of file
app/src/main/res/color/tab_item_selector.xml
0 → 100644
View file @
4ad06ff2
<?xml version="1.0" encoding="utf-8"?>
<selector
xmlns:android=
"http://schemas.android.com/apk/res/android"
>
<item
android:state_selected=
"true"
android:color=
"@color/colorInvertedText"
/>
<item
android:state_focused=
"true"
android:color=
"@color/colorOpacityBackgroundInv"
/>
<item
android:state_pressed=
"true"
android:color=
"@color/colorOpacityBackgroundInv"
/>
<item
android:color=
"@color/colorOpacityBackgroundInv"
/>
</selector>
\ No newline at end of file
app/src/main/res/layout/feeds_block_view.xml
View file @
4ad06ff2
...
@@ -9,14 +9,26 @@
...
@@ -9,14 +9,26 @@
android:orientation=
"vertical"
android:orientation=
"vertical"
android:paddingStart=
"16dp"
>
android:paddingStart=
"16dp"
>
<androidx.viewpager.widget.ViewPager
<com.google.android.material.tabs.TabLayout
android:id=
"@+id/viewPager"
android:id=
"@+id/feedsTabs"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:background=
"#00000000"
app:tabMaxWidth=
"@dimen/feeds_tab_max_width"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
app:tabMode=
"scrollable"
/>
<androidx.recyclerview.widget.RecyclerView
android:id=
"@+id/feedsRecyclerView"
android:layout_width=
"0dp"
android:layout_width=
"0dp"
android:layout_height=
"0dp"
android:layout_height=
"0dp"
tools:listitem=
"@layout/feed_direct_viewholder"
app:layout_constraintBottom_toTopOf=
"@+id/feeds_divider"
app:layout_constraintBottom_toTopOf=
"@+id/feeds_divider"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_to
TopOf=
"parent"
></androidx.viewpager.widget.ViewPager
>
app:layout_constraintTop_to
BottomOf=
"@+id/feedsTabs"
/
>
<include
<include
android:id=
"@+id/feeds_divider"
android:id=
"@+id/feeds_divider"
...
...
app/src/main/res/layout/feeds_tab_view.xml
0 → 100644
View file @
4ad06ff2
<?xml version="1.0" encoding="utf-8"?>
<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=
"wrap_content"
android:layout_height=
"wrap_content"
>
<TextView
android:id=
"@+id/tab_title"
style=
"@style/Header_TextView.TabItem"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:maxLines=
"1"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
/>
<TextView
android:id=
"@+id/tab_divider"
style=
"@style/Header_TextView.TabItem"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_alignEnd=
"@id/tab_title"
android:layout_marginStart=
"16dp"
android:layout_marginEnd=
"16dp"
android:text=
"@string/feeds_tab_divider"
android:textColor=
"@color/colorInvertedNoticeText"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toEndOf=
"@+id/tab_title"
app:layout_constraintTop_toTopOf=
"parent"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
app/src/main/res/values/strings.xml
View file @
4ad06ff2
...
@@ -49,6 +49,7 @@
...
@@ -49,6 +49,7 @@
<string
name=
"can_not_download_all_tours_error"
>
Can\'t download tours!
</string>
<string
name=
"can_not_download_all_tours_error"
>
Can\'t download tours!
</string>
<string
name=
"auth_data_requirments_failed"
>
Login at least %d symbols
<string
name=
"auth_data_requirments_failed"
>
Login at least %d symbols
\nPassword at least %d symbols
</string>
\nPassword at least %d symbols
</string>
<string
name=
"feeds_tab_divider"
>
/
</string>
<!--endregion-->
<!--endregion-->
</resources>
</resources>
app/src/main/res/values/styles.xml
View file @
4ad06ff2
...
@@ -222,6 +222,10 @@
...
@@ -222,6 +222,10 @@
<item
name=
"android:textColor"
>
@color/colorInvertedText
</item>
<item
name=
"android:textColor"
>
@color/colorInvertedText
</item>
</style>
</style>
<style
name=
"Header_TextView.TabItem"
>
<item
name=
"android:textColor"
>
@color/tab_item_selector
</item>
</style>
<style
name=
"Flat_Input_TextView"
parent=
"Base.Widget.AppCompat.TextView.AcromMediumTextView"
>
<style
name=
"Flat_Input_TextView"
parent=
"Base.Widget.AppCompat.TextView.AcromMediumTextView"
>
<item
name=
"android:textSize"
>
@dimen/super_size
</item>
<item
name=
"android:textSize"
>
@dimen/super_size
</item>
</style>
</style>
...
...
app/src/main/res/values/view_size.xml
View file @
4ad06ff2
...
@@ -8,4 +8,6 @@
...
@@ -8,4 +8,6 @@
<dimen
name=
"bottom_gradient_height"
>
3dp
</dimen>
<dimen
name=
"bottom_gradient_height"
>
3dp
</dimen>
<dimen
name=
"ceil_grid_padding"
>
8dp
</dimen>
<dimen
name=
"ceil_grid_padding"
>
8dp
</dimen>
<dimen
name=
"feeds_tab_max_width"
>
999dp
</dimen>
</resources>
</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