-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update dependencies; add one more example
- Loading branch information
Showing
25 changed files
with
145 additions
and
50 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 4 additions & 3 deletions
7
delegateadapter/src/main/java/com/example/delegateadapter/delegate/BaseDelegateAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
delegateadapter/src/main/java/com/example/delegateadapter/delegate/BaseViewHolder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 3 additions & 2 deletions
5
...eadapter/src/main/java/com/example/delegateadapter/delegate/CompositeDelegateAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 3 additions & 2 deletions
5
delegateadapter/src/main/java/com/example/delegateadapter/delegate/IDelegateAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 3 additions & 2 deletions
5
...gateadapter/src/main/java/com/example/delegateadapter/delegate/diff/DiffUtilCallback.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 3 additions & 2 deletions
5
...ter/src/main/java/com/example/delegateadapter/delegate/diff/DiffUtilCompositeAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 3 additions & 2 deletions
5
example/src/main/java/com/example/dumchev/delegateadapters/base/BadAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 5 additions & 4 deletions
9
example/src/main/java/com/example/dumchev/delegateadapters/base/BaseExampleActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
example/src/main/java/com/example/dumchev/delegateadapters/base/KotlinBaseExampleActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package com.example.dumchev.delegateadapters.base | ||
|
||
import android.os.Bundle | ||
import android.view.View | ||
import androidx.appcompat.app.AppCompatActivity | ||
import androidx.recyclerview.widget.LinearLayoutManager | ||
import com.example.delegateadapter.delegate.diff.DiffUtilCompositeAdapter | ||
import com.example.dumchev.delegateadapters.base.adapter.CheckDelegateAdapter | ||
import com.example.dumchev.delegateadapters.base.adapter.GenerateItemsDelegateAdapter | ||
import com.example.dumchev.delegateadapters.base.adapter.TextDelegateAdapter | ||
import kotlinx.android.synthetic.main.activity_base_example.* | ||
|
||
class KotlinBaseExampleActivity : AppCompatActivity() { | ||
|
||
private val diffAdapter by lazy { | ||
DiffUtilCompositeAdapter.Builder() | ||
.add(GenerateItemsDelegateAdapter { generateNewData() }) | ||
.add(TextDelegateAdapter()) | ||
.add(CheckDelegateAdapter()) | ||
.build() | ||
} | ||
|
||
private fun generateNewData() { | ||
diffAdapter.swapData(MockDataFactory.prepareData()) | ||
rv.scrollToPosition(0) | ||
} | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setContentView(com.example.dumchev.delegateadapters.R.layout.activity_base_example) | ||
rv.run { | ||
layoutManager = LinearLayoutManager(this@KotlinBaseExampleActivity) | ||
adapter = diffAdapter | ||
generateNewData() | ||
} | ||
} | ||
|
||
fun onGenerateButtonClicked(view: View) { | ||
diffAdapter.swapData(MockDataFactory.prepareData()) | ||
rv.scrollToPosition(0) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
...in/java/com/example/dumchev/delegateadapters/base/adapter/GenerateItemsDelegateAdapter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.example.dumchev.delegateadapters.base.adapter | ||
|
||
import com.example.delegateadapter.delegate.KDelegateAdapter | ||
import com.example.dumchev.delegateadapters.R | ||
import com.example.dumchev.delegateadapters.base.model.ImageViewModel | ||
import kotlinx.android.synthetic.main.image_item.* | ||
|
||
class GenerateItemsDelegateAdapter(private val generateNewItems: () -> Unit) : | ||
KDelegateAdapter<ImageViewModel>() { | ||
|
||
override fun onBind(item: ImageViewModel, viewHolder: KViewHolder) = with(viewHolder) { | ||
tv_title.text = item.title | ||
img_bg.setImageResource(item.imageRes) | ||
itemView.setOnClickListener { generateNewItems() } | ||
} | ||
|
||
override fun getLayoutId(): Int = R.layout.image_item | ||
|
||
override fun isForViewType(items: List<*>, position: Int) = items[position] is ImageViewModel | ||
} |
2 changes: 1 addition & 1 deletion
2
.../src/main/java/com/example/dumchev/delegateadapters/base/adapter/TextDelegateAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 1 addition & 2 deletions
3
example/src/main/java/com/example/dumchev/delegateadapters/base/model/ImageViewModel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.