Skip to content

Commit

Permalink
Fix the sample related issues
Browse files Browse the repository at this point in the history
  • Loading branch information
arthur3486 committed Sep 13, 2019
1 parent a51aaf3 commit c1c9766
Show file tree
Hide file tree
Showing 7 changed files with 80 additions and 5 deletions.
2 changes: 1 addition & 1 deletion sample/release/output.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":19,"versionName":"1.0.0","enabled":true,"outputFile":"sample-release.apk","fullName":"release","baseName":"release"},"path":"sample-release.apk","properties":{}}]
[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":20,"versionName":"1.1.0","enabled":true,"outputFile":"sample-release.apk","fullName":"release","baseName":"release"},"path":"sample-release.apk","properties":{}}]
Binary file added sample/release/sample-release.apk
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.arthurivanets.sample.adapters.adapster

import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.arthurivanets.adapster.Adapter
import com.arthurivanets.adapster.markers.ItemResources
import com.arthurivanets.adapster.model.BaseItem
import com.arthurivanets.adapster.model.Item
import com.arthurivanets.sample.R

class TextItem(itemModel : String) : BaseItem<String, TextItemViewHolder, ItemResources>(itemModel) {


override fun init(adapter : Adapter<out Item<RecyclerView.ViewHolder, ItemResources>>?,
parent : ViewGroup,
inflater : LayoutInflater,
resources : ItemResources?) : TextItemViewHolder {
return TextItemViewHolder(inflater.inflate(
layout,
parent,
false
))
}


override fun getLayout() : Int {
return R.layout.item_text
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.arthurivanets.sample.adapters.adapster

import android.view.View
import android.widget.TextView
import com.arthurivanets.adapster.model.BaseItem
import com.arthurivanets.sample.R

class TextItemViewHolder(
itemView : View
) : BaseItem.ViewHolder<String>(itemView) {


val textTv = itemView.findViewById<TextView>(R.id.textTv)


override fun bindData(data : String?) {
super.bindData(data)

data?.let(::handleData)
}


private fun handleData(data : String) {
textTv.text = data
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ import com.arthurivanets.adapster.recyclerview.TrackableRecyclerViewAdapter
*/
class VideoItemsRecyclerViewAdapter(
context : Context,
items : MutableList<VideoItem>,
items : MutableList<BaseItem<*, *, *>>,
private val resources : VideoItemResources
) : TrackableRecyclerViewAdapter<Long, VideoItem, BaseItem.ViewHolder<*>>(context, items) {
) : TrackableRecyclerViewAdapter<Long, BaseItem<*, *, *>, BaseItem.ViewHolder<*>>(context, items) {


override fun getResources() : ItemResources? {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ import androidx.annotation.ColorInt
import androidx.annotation.ColorRes
import androidx.annotation.DrawableRes
import androidx.core.content.ContextCompat
import androidx.core.content.res.use


@SuppressLint("Recycle")
fun Context.extractStyledAttributes(attributes : AttributeSet,
attrs : IntArray,
block : TypedArray.() -> Unit) {
obtainStyledAttributes(attributes, attrs, 0, 0)?.let {
obtainStyledAttributes(attributes, attrs, 0, 0).use {
block(it)
it.recycle()
}
}

Expand Down
15 changes: 15 additions & 0 deletions sample/src/main/res/layout/item_text.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">

<TextView
android:id="@+id/textTv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:padding="50dp"/>

</LinearLayout>

0 comments on commit c1c9766

Please sign in to comment.