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(
conductor_container.requestLayout()
}
override fun showAll() {
appBar.setExpanded(true,false)
collapsingToolbarLayout.visibility= View.VISIBLE
......
package com.biganto.visual.roompark.presentation.screen.feed_list
import android.view.View
import androidx.appcompat.widget.Toolbar
import androidx.core.os.bundleOf
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
......@@ -44,8 +45,10 @@ class ArticlesScreenController :
private fun setToolbar(){
toolBar.showAll()
toolBar.appBar.visibility= Toolbar.VISIBLE
toolBar.appBar.setExpanded(false,false)
toolBar.collapsingToolbarLayout.title = "ИЗБРАННОЕ"
toolBar.collapsingToolbarLayout.title = "НОВОСТь"
toolBar.appBar.setLiftable(true)
toolBar.appBarScrollable(false)
articlesRecyclerView.isNestedScrollingEnabled = false
......@@ -66,7 +69,7 @@ class ArticlesScreenController :
}
override fun onViewBound(v: View) {
// setToolbar()
setToolbar()
bindRecycler()
}
......@@ -89,10 +92,17 @@ class ArticlesScreenController :
}
private fun getComponent() = DaggerArticlesScreenComponent.factory()
.create(2,RoomParkApplication.component,activity as RoomParkMainActivity)
.create(args.getInt(FEED_ID)
,RoomParkApplication.component,activity as RoomParkMainActivity)
.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 {
@Component.Factory
interface Factory{
fun create(
@Named("FEED_ID_INT") feed:Int
@BindsInstance @Named("FEED_ID_INT") feed:Int
, appComponent: AppComponent
,@BindsInstance activity: RoomParkMainActivity
): ArticlesScreenComponent
......
......@@ -23,7 +23,7 @@ class ArticlesScreenPresenter @Inject constructor(
override fun bindIntents() {
Timber.d("feedId : $feedId")
val prefetchCards = interactor.fetchArticles(1)
val prefetchCards = interactor.fetchArticles(feedId)
.map { ArticlesScreenViewState.ArticlesLoaded(it.articles) }
val state = restoreStateObservable
......
package com.biganto.visual.roompark.presentation.screen.feed_list.util
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.presentation.screen.settings.util.CommonRecyclerAdapter
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.
*/
class ArticlesAdapter() : CommonRecyclerAdapter<ArticleViewHolder, ArticlePreviewModel>() {
class ArticlesAdapter : CommonRecyclerAdapter<ArticleViewHolder, ArticlePreviewModel>() {
override val vhKlazz = ArticleViewHolder::class
override fun getVhLayout(): Int {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
override fun getVhLayout(): Int = R.layout.feed_direct_viewholder
}
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) {
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
import android.annotation.SuppressLint
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
......@@ -11,12 +12,19 @@ import com.biganto.visual.roompark.base.RoomParkApplication
import com.biganto.visual.roompark.base.RoomParkMainActivity
import com.biganto.visual.roompark.conductor.BigantoBaseController
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.ArticlesPreviewAdapter
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.textview.MaterialTextView
import com.jakewharton.rxbinding3.material.selections
import com.jakewharton.rxbinding3.view.clicks
import io.reactivex.Observable
import io.reactivex.android.schedulers.AndroidSchedulers
import timber.log.Timber
import java.util.concurrent.TimeUnit
import javax.inject.Inject
......@@ -32,9 +40,14 @@ class FeedsScreenController :
, FeedsScreen {
override fun feedsTabSelected(): Observable<Int>
= feedsTabs.selections().map { it.position }
= feedsTabs.selections()
.debounce (200L, TimeUnit.MILLISECONDS)
.map { it.position }
.map { storedFeedsList[it].feedId }
.observeOn(AndroidSchedulers.mainThread())
.doOnNext { feedsBlockView.findViewById<MaterialButton>(R.id.to_feed_articles)
.text = "ВСЕ ${allFeedName(it)}" }
override fun injectDependencies() {
......@@ -85,6 +98,18 @@ class FeedsScreenController :
override fun onViewBound(v: View) {
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) {
......@@ -103,12 +128,16 @@ class FeedsScreenController :
}
private fun allFeedName(feedId:Int) = if (feedId==1) "НОВОСТИ" else "БЛОГИ"
@SuppressLint("SetTextI18n")
private fun render(viewState: FeedsScreenViewState.FeedsPages){
feedsTabs.removeAllTabs()
viewState.items.forEach {feed ->
val tab = feedsTabs.newTab()
.setCustomView(R.layout.feeds_tab_view)
.setTag(feed.feedId)
tab.customView
?.let {
it.findViewById<TextView>(R.id.tab_title)?.text = feed.title
......@@ -141,4 +170,10 @@ class FeedsScreenController :
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
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.biganto.visual.roompark.util.extensions.setGone
import com.squareup.picasso.Picasso
import java.text.SimpleDateFormat
import java.util.*
......@@ -44,7 +45,3 @@ class ArticlePreviewViewHolder(itemView: View) : CommonViewHolder<ArticlePreview
.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
import android.content.ContentValues.TAG
import android.util.Log
import android.view.View
import androidx.viewpager.widget.ViewPager
import butterknife.BindView
......@@ -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.to_flat.FindFlatScreenController
import com.google.android.material.bottomnavigation.BottomNavigationView
import timber.log.Timber
import javax.inject.Inject
/**
......@@ -96,5 +99,28 @@ class HomeController :
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
import android.view.View
import java.text.DecimalFormat
/**
......@@ -37,3 +38,8 @@ fun Float.format(fracDigits: Int): String {
df.maximumFractionDigits = fracDigits
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 @@
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/linearLayout3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorFeedViewHolderBackground">
android:layout_height="wrap_content">
<com.biganto.visual.roompark.util.view_utils.image_view.RoundedImageView
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