Skip to content

Commit

Permalink
feed: fix binding
Browse files Browse the repository at this point in the history
  • Loading branch information
iTaysonLab committed Sep 24, 2020
1 parent d033812 commit d7fbc3a
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 11 deletions.
18 changes: 18 additions & 0 deletions app/release/output-metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"version": 2,
"artifactType": {
"type": "APK",
"kind": "Directory"
},
"applicationId": "ua.itaysonlab.homefeeder",
"variantName": "processReleaseResources",
"elements": [
{
"type": "SINGLE",
"filters": [],
"versionCode": 10,
"versionName": "pre-alpha 10",
"outputFile": "app-release.apk"
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ class OverlayKt(val context: Context): OverlayController(context, R.style.AppThe
}

adapter = FeedAdapter()
adapter.setHasStableIds(true)
rootView.recycler.layoutManager = LinearLayoutManager(context)
rootView.recycler.adapter = adapter

Expand Down Expand Up @@ -236,7 +235,6 @@ class OverlayKt(val context: Context): OverlayController(context, R.style.AppThe

override fun applyCompactCard(value: Boolean) {
adapter = FeedAdapter()
adapter.setHasStableIds(true)
//adapter.setCompact(value)
adapter.setTheme(themeHolder.currentTheme)
rootView.recycler.adapter = adapter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,24 @@ import ua.itaysonlab.homefeeder.R
import ua.itaysonlab.homefeeder.overlay.feed.binders.StoryCardBinder
import ua.itaysonlab.homefeeder.overlay.feed.binders.TextCardBinder
import ua.itaysonlab.homefeeder.overlay.feed.binders.TextCardWithActionsBinder
import ua.itaysonlab.homefeeder.utils.Logger

class FeedAdapter: RecyclerView.Adapter<FeedAdapter.FeedViewHolder>() {
private var list = mutableListOf<FeedItem>()
private var list = listOf<FeedItem>()
private lateinit var layoutInflater: LayoutInflater
private var theme: SparseIntArray? = null

fun replace(new: List<FeedItem>) {
list.apply {
clear()
addAll(new)
}
list = new
notifyDataSetChanged()
}

fun update(new: List<FeedItem>) {
list.apply {
fun append(new: List<FeedItem>) {
list = mutableListOf<FeedItem>().apply {
addAll(list)
addAll(new)
}

notifyDataSetChanged()
}

Expand All @@ -37,7 +37,9 @@ class FeedAdapter: RecyclerView.Adapter<FeedAdapter.FeedViewHolder>() {
notifyDataSetChanged()
}

override fun getItemCount() = list.size
override fun getItemCount(): Int {
return list.size
}

override fun getItemViewType(position: Int): Int {
return (list[position].type.ordinal)
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ buildscript {

}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.0-beta03'
classpath 'com.android.tools.build:gradle:4.1.0-rc03'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down

0 comments on commit d7fbc3a

Please sign in to comment.