Skip to content

Commit

Permalink
2019-03-27 13:30
Browse files Browse the repository at this point in the history
add notifyDataSetChange function
  • Loading branch information
Aryan-mor committed Mar 27, 2019
1 parent b91b17c commit 77fa3c1
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion advancerecyclerview/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ android {
minSdkVersion 19
targetSdkVersion 28
versionCode 1
versionName "1.0.1"
versionName "1.0.2"

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ open class AdvanceRecyclerView : RecyclerView {
protected val VIEW_TYPE_ITEM = 0
protected val VIEW_TYPE_LOADING = 1
protected var erisViewType = VIEW_TYPE_ITEM
var isInitialize = false


val count: Int
Expand Down Expand Up @@ -153,6 +154,8 @@ open class AdvanceRecyclerView : RecyclerView {
processPagination(dx, dy)
}
})

isInitialize = true
}

protected fun processPagination(dx: Int, dy: Int) {
Expand Down Expand Up @@ -203,16 +206,16 @@ open class AdvanceRecyclerView : RecyclerView {

// PROPERTIES

fun notifyDataSetChanged(newItemCount:Int){
addItemCount(newItemCount)
}


fun addNewItemCount(newItemCount: Int) {
Log.e("Ari","new count -> $newItemCount")
Log.e("Ari","itemCount -> $itemCount")
addItemCount(newItemCount + itemCount + 1)
}

fun addItemCount(itemCount: Int) {

Log.e("Ari","final -> $itemCount")
this.itemCount = itemCount
myAdapter.notifyDataSetChanged()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,9 @@ package ir.aryanmo.advancerecyclerviewexample

import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import android.support.v7.widget.helper.ItemTouchHelper
import android.util.Log
import android.view.View
import android.widget.TextView
import ir.aryanmo.advancerecyclerview.AdvanceRecyclerView
import ir.aryanmo.advancerecyclerview.AdvanceRecyclerView2
import kotlinx.android.synthetic.main.activity_main.*

class MainActivity : AppCompatActivity() {
Expand All @@ -28,19 +25,22 @@ class MainActivity : AppCompatActivity() {
}
}


re.init(R.layout.test_item, myList.size, null)

goTo.setOnClickListener { re.scrollToPos(10) }
goTo.setOnClickListener {
if (re.isInitialize) {
myList.add("saom")
myList.add("hlfg")
myList.add("sifkpasj")
myList.add("dop")
myList.add("rez")
re.notifyDataSetChanged(myList.size)
}
}
smoothGoTo.setOnClickListener { re.smoothScrollToPos(10) }
re.isInitialize


// myList.add("saom")
// myList.add("hlfg")
// myList.add("sifkpasj")
// myList.add("dop")
// myList.add("rez")
// re.addNewItemCount(5)
}

private fun getList(): ArrayList<String> {
Expand Down

0 comments on commit 77fa3c1

Please sign in to comment.