Commit f6587b74 authored by Vladislav Bogdashkin's avatar Vladislav Bogdashkin 🎣

back stack issue.. will try to refactor

parent afbb9bd1
...@@ -77,6 +77,7 @@ class RoomParkMainActivity( ...@@ -77,6 +77,7 @@ class RoomParkMainActivity(
conductor_container.requestLayout() conductor_container.requestLayout()
} }
override fun showAll() { override fun showAll() {
appBar.setExpanded(true,false) appBar.setExpanded(true,false)
collapsingToolbarLayout.visibility= View.VISIBLE collapsingToolbarLayout.visibility= View.VISIBLE
......
package com.biganto.visual.roompark.presentation.screen.feed_list package com.biganto.visual.roompark.presentation.screen.feed_list
import android.view.View import android.view.View
import androidx.appcompat.widget.Toolbar
import androidx.core.os.bundleOf import androidx.core.os.bundleOf
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
...@@ -44,8 +45,10 @@ class ArticlesScreenController : ...@@ -44,8 +45,10 @@ class ArticlesScreenController :
private fun setToolbar(){ private fun setToolbar(){
toolBar.showAll() toolBar.showAll()
toolBar.appBar.visibility= Toolbar.VISIBLE
toolBar.appBar.setExpanded(false,false) toolBar.appBar.setExpanded(false,false)
toolBar.collapsingToolbarLayout.title = "ИЗБРАННОЕ" toolBar.collapsingToolbarLayout.title = "НОВОСТь"
toolBar.appBar.setLiftable(true) toolBar.appBar.setLiftable(true)
toolBar.appBarScrollable(false) toolBar.appBarScrollable(false)
articlesRecyclerView.isNestedScrollingEnabled = false articlesRecyclerView.isNestedScrollingEnabled = false
...@@ -66,7 +69,7 @@ class ArticlesScreenController : ...@@ -66,7 +69,7 @@ class ArticlesScreenController :
} }
override fun onViewBound(v: View) { override fun onViewBound(v: View) {
// setToolbar() setToolbar()
bindRecycler() bindRecycler()
} }
...@@ -89,10 +92,17 @@ class ArticlesScreenController : ...@@ -89,10 +92,17 @@ class ArticlesScreenController :
} }
private fun getComponent() = DaggerArticlesScreenComponent.factory() private fun getComponent() = DaggerArticlesScreenComponent.factory()
.create(2,RoomParkApplication.component,activity as RoomParkMainActivity) .create(args.getInt(FEED_ID)
,RoomParkApplication.component,activity as RoomParkMainActivity)
.inject(this) .inject(this)
override fun getLayoutId(): Int = R.layout.feeds_screen override fun getLayoutId(): Int = R.layout.feed_direct_screen
override fun handleBack(): Boolean {
Timber.d("handle back in class ")
router.popController(this)
return super.handleBack()
}
} }
\ No newline at end of file
...@@ -20,7 +20,7 @@ interface ArticlesScreenComponent { ...@@ -20,7 +20,7 @@ interface ArticlesScreenComponent {
@Component.Factory @Component.Factory
interface Factory{ interface Factory{
fun create( fun create(
@Named("FEED_ID_INT") feed:Int @BindsInstance @Named("FEED_ID_INT") feed:Int
, appComponent: AppComponent , appComponent: AppComponent
,@BindsInstance activity: RoomParkMainActivity ,@BindsInstance activity: RoomParkMainActivity
): ArticlesScreenComponent ): ArticlesScreenComponent
......
...@@ -23,7 +23,7 @@ class ArticlesScreenPresenter @Inject constructor( ...@@ -23,7 +23,7 @@ class ArticlesScreenPresenter @Inject constructor(
override fun bindIntents() { override fun bindIntents() {
Timber.d("feedId : $feedId") Timber.d("feedId : $feedId")
val prefetchCards = interactor.fetchArticles(1) val prefetchCards = interactor.fetchArticles(feedId)
.map { ArticlesScreenViewState.ArticlesLoaded(it.articles) } .map { ArticlesScreenViewState.ArticlesLoaded(it.articles) }
val state = restoreStateObservable val state = restoreStateObservable
......
package com.biganto.visual.roompark.presentation.screen.feed_list.util package com.biganto.visual.roompark.presentation.screen.feed_list.util
import android.view.View import android.view.View
import android.widget.ImageView
import android.widget.TextView
import butterknife.BindView
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.CommonRecyclerAdapter
import com.biganto.visual.roompark.presentation.screen.settings.util.CommonViewHolder import com.biganto.visual.roompark.presentation.screen.settings.util.CommonViewHolder
import com.biganto.visual.roompark.util.extensions.setGone
import com.squareup.picasso.Picasso
import java.text.SimpleDateFormat
import java.util.*
/** /**
* Created by Vladislav Bogdashkin on 16.10.2019. * Created by Vladislav Bogdashkin on 16.10.2019.
*/ */
class ArticlesAdapter() : CommonRecyclerAdapter<ArticleViewHolder, ArticlePreviewModel>() { class ArticlesAdapter : CommonRecyclerAdapter<ArticleViewHolder, ArticlePreviewModel>() {
override val vhKlazz = ArticleViewHolder::class override val vhKlazz = ArticleViewHolder::class
override fun getVhLayout(): Int { override fun getVhLayout(): Int = R.layout.feed_direct_viewholder
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
} }
class ArticleViewHolder(itemView: View) : CommonViewHolder<ArticlePreviewModel>(itemView) { class ArticleViewHolder(itemView: View) : CommonViewHolder<ArticlePreviewModel>(itemView) {
private val dateFormatter = SimpleDateFormat("dd / MM / yyyy", Locale.getDefault())
@BindView(R.id.imageHolder) lateinit var preview: ImageView
@BindView(R.id.feed_date_text_view) lateinit var articleDate: TextView
@BindView(R.id.feed_title_info_text_view) lateinit var articleTitle: TextView
@BindView(R.id.feed_read) lateinit var articleIsRead:View
override fun onViewBound(model: ArticlePreviewModel) { override fun onViewBound(model: ArticlePreviewModel) {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates. articleDate.text = dateFormatter.format(model.published)
articleTitle.text = model.title
articleIsRead.setGone(model.isRead)
Picasso.get()
.load(model.previewUrl)
.into(preview)
} }
} }
\ No newline at end of file
package com.biganto.visual.roompark.presentation.screen.feeds package com.biganto.visual.roompark.presentation.screen.feeds
import android.annotation.SuppressLint
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.TextView import android.widget.TextView
...@@ -11,12 +12,19 @@ import com.biganto.visual.roompark.base.RoomParkApplication ...@@ -11,12 +12,19 @@ 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.domain.model.FeedModel import com.biganto.visual.roompark.domain.model.FeedModel
import com.biganto.visual.roompark.presentation.screen.feed_list.ArticlesScreenController
import com.biganto.visual.roompark.presentation.screen.feeds.utils.AlbumsPreviewAdapter import com.biganto.visual.roompark.presentation.screen.feeds.utils.AlbumsPreviewAdapter
import com.biganto.visual.roompark.presentation.screen.feeds.utils.ArticlesPreviewAdapter import com.biganto.visual.roompark.presentation.screen.feeds.utils.ArticlesPreviewAdapter
import com.biganto.visual.roompark.presentation.screen.feeds.utils.CamsListAdapter import com.biganto.visual.roompark.presentation.screen.feeds.utils.CamsListAdapter
import com.bluelinelabs.conductor.RouterTransaction
import com.bluelinelabs.conductor.changehandler.FadeChangeHandler
import com.google.android.material.button.MaterialButton
import com.google.android.material.tabs.TabLayout import com.google.android.material.tabs.TabLayout
import com.google.android.material.textview.MaterialTextView
import com.jakewharton.rxbinding3.material.selections import com.jakewharton.rxbinding3.material.selections
import com.jakewharton.rxbinding3.view.clicks
import io.reactivex.Observable import io.reactivex.Observable
import io.reactivex.android.schedulers.AndroidSchedulers
import timber.log.Timber import timber.log.Timber
import java.util.concurrent.TimeUnit import java.util.concurrent.TimeUnit
import javax.inject.Inject import javax.inject.Inject
...@@ -32,9 +40,14 @@ class FeedsScreenController : ...@@ -32,9 +40,14 @@ class FeedsScreenController :
, FeedsScreen { , FeedsScreen {
override fun feedsTabSelected(): Observable<Int> override fun feedsTabSelected(): Observable<Int>
= feedsTabs.selections().map { it.position } = feedsTabs.selections()
.debounce (200L, TimeUnit.MILLISECONDS) .debounce (200L, TimeUnit.MILLISECONDS)
.map { it.position }
.map { storedFeedsList[it].feedId } .map { storedFeedsList[it].feedId }
.observeOn(AndroidSchedulers.mainThread())
.doOnNext { feedsBlockView.findViewById<MaterialButton>(R.id.to_feed_articles)
.text = "ВСЕ ${allFeedName(it)}" }
override fun injectDependencies() { override fun injectDependencies() {
...@@ -85,6 +98,18 @@ class FeedsScreenController : ...@@ -85,6 +98,18 @@ class FeedsScreenController :
override fun onViewBound(v: View) { override fun onViewBound(v: View) {
bindRecycler() bindRecycler()
feedsBlockView.findViewById<MaterialTextView>(R.id.to_feed_articles).clicks()
.map{ feedsTabs.getTabAt(feedsTabs.selectedTabPosition)}
.map { it.tag as? Int }
.subscribe {
it?.let {
router.pushController(
RouterTransaction.with(ArticlesScreenController(it))
.popChangeHandler(FadeChangeHandler())
.pushChangeHandler(FadeChangeHandler())
)
}
}
} }
override fun render(viewState: FeedsScreenViewState) { override fun render(viewState: FeedsScreenViewState) {
...@@ -103,12 +128,16 @@ class FeedsScreenController : ...@@ -103,12 +128,16 @@ class FeedsScreenController :
} }
private fun allFeedName(feedId:Int) = if (feedId==1) "НОВОСТИ" else "БЛОГИ"
@SuppressLint("SetTextI18n")
private fun render(viewState: FeedsScreenViewState.FeedsPages){ private fun render(viewState: FeedsScreenViewState.FeedsPages){
feedsTabs.removeAllTabs() feedsTabs.removeAllTabs()
viewState.items.forEach {feed -> viewState.items.forEach {feed ->
val tab = feedsTabs.newTab() val tab = feedsTabs.newTab()
.setCustomView(R.layout.feeds_tab_view) .setCustomView(R.layout.feeds_tab_view)
.setTag(feed.feedId)
tab.customView tab.customView
?.let { ?.let {
it.findViewById<TextView>(R.id.tab_title)?.text = feed.title it.findViewById<TextView>(R.id.tab_title)?.text = feed.title
...@@ -141,4 +170,10 @@ class FeedsScreenController : ...@@ -141,4 +170,10 @@ class FeedsScreenController :
override fun getLayoutId(): Int = R.layout.feeds_screen override fun getLayoutId(): Int = R.layout.feeds_screen
override fun handleBack(): Boolean {
Timber.d("handle back in class ")
router.popController(this)
return super.handleBack()
}
} }
\ No newline at end of file
...@@ -8,6 +8,7 @@ import com.biganto.visual.roompark.R ...@@ -8,6 +8,7 @@ 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.CommonRecyclerAdapter
import com.biganto.visual.roompark.presentation.screen.settings.util.CommonViewHolder import com.biganto.visual.roompark.presentation.screen.settings.util.CommonViewHolder
import com.biganto.visual.roompark.util.extensions.setGone
import com.squareup.picasso.Picasso import com.squareup.picasso.Picasso
import java.text.SimpleDateFormat import java.text.SimpleDateFormat
import java.util.* import java.util.*
...@@ -44,7 +45,3 @@ class ArticlePreviewViewHolder(itemView: View) : CommonViewHolder<ArticlePreview ...@@ -44,7 +45,3 @@ class ArticlePreviewViewHolder(itemView: View) : CommonViewHolder<ArticlePreview
.into(preview) .into(preview)
} }
} }
private fun View.setGone(isGone:Boolean){
this.visibility = if (isGone) View.GONE else View.VISIBLE
}
\ No newline at end of file
package com.biganto.visual.roompark.presentation.screen.home package com.biganto.visual.roompark.presentation.screen.home
import android.content.ContentValues.TAG
import android.util.Log
import android.view.View import android.view.View
import androidx.viewpager.widget.ViewPager import androidx.viewpager.widget.ViewPager
import butterknife.BindView import butterknife.BindView
...@@ -15,6 +17,7 @@ import com.biganto.visual.roompark.presentation.screen.feeds.FeedsScreenControll ...@@ -15,6 +17,7 @@ import com.biganto.visual.roompark.presentation.screen.feeds.FeedsScreenControll
import com.biganto.visual.roompark.presentation.screen.settings.SettingsScreenController import com.biganto.visual.roompark.presentation.screen.settings.SettingsScreenController
import com.biganto.visual.roompark.presentation.screen.to_flat.FindFlatScreenController import com.biganto.visual.roompark.presentation.screen.to_flat.FindFlatScreenController
import com.google.android.material.bottomnavigation.BottomNavigationView import com.google.android.material.bottomnavigation.BottomNavigationView
import timber.log.Timber
import javax.inject.Inject import javax.inject.Inject
/** /**
...@@ -96,5 +99,28 @@ class HomeController : ...@@ -96,5 +99,28 @@ class HomeController :
override fun getLayoutId(): Int = R.layout.home_screen_viewpager override fun getLayoutId(): Int = R.layout.home_screen_viewpager
override fun handleBack(): Boolean {
Timber.d("handle back in class ")
val childRouter = pageAdapter.currentPrimaryRouter
if (childRouter != null) {
val backStackSizeCondition = childRouter.backstackSize < 2
val backStackResult = childRouter.handleBack()
if (backStackResult
&& backStackSizeCondition
)
return backStackResult
} else {
Log.e(TAG, "handleBack called with getChildRouter(currentlySelectedItemId) == null.",
IllegalStateException(
"handleBack called with getChildRouter(currentlySelectedItemId) == null."))
}
return false
}
} }
\ No newline at end of file
package com.biganto.visual.roompark.util.extensions package com.biganto.visual.roompark.util.extensions
import android.view.View
import java.text.DecimalFormat import java.text.DecimalFormat
/** /**
...@@ -37,3 +38,8 @@ fun Float.format(fracDigits: Int): String { ...@@ -37,3 +38,8 @@ fun Float.format(fracDigits: Int): String {
df.maximumFractionDigits = fracDigits df.maximumFractionDigits = fracDigits
return df.format(this) return df.format(this)
} }
fun View.setGone(isGone:Boolean){
this.visibility = if (isGone) View.GONE else View.VISIBLE
}
\ No newline at end of file
...@@ -4,8 +4,7 @@ ...@@ -4,8 +4,7 @@
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/linearLayout3" android:id="@+id/linearLayout3"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content">
android:background="@color/colorFeedViewHolderBackground">
<com.biganto.visual.roompark.util.view_utils.image_view.RoundedImageView <com.biganto.visual.roompark.util.view_utils.image_view.RoundedImageView
android:id="@+id/imageHolder" android:id="@+id/imageHolder"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment