-
Notifications
You must be signed in to change notification settings - Fork 314
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Kotlin DSL to create Adapters (#68)
* First draft * New ListAdapterDelegateDsl implementatino * Moved dsl stuff in own submodule * Removed unusded files * Code duplication for adapter delegates * Tests added * Added dsl for other recyclerview releavant callbacks * Updated README * Updated Main Example * Update * More Docs * Fix a test * More assertions * More Readme * Better tests
- Loading branch information
Showing
33 changed files
with
1,579 additions
and
132 deletions.
There are no files selected for viewing
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
81 changes: 0 additions & 81 deletions
81
app/src/main/java/com/hannesdorfmann/adapterdelegates4/sample/MainAdapter.java
This file was deleted.
Oops, something went wrong.
18 changes: 18 additions & 0 deletions
18
app/src/main/java/com/hannesdorfmann/adapterdelegates4/sample/MainListAdapter.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,18 @@ | ||
package com.hannesdorfmann.adapterdelegates4.sample | ||
|
||
import android.app.Activity | ||
import com.hannesdorfmann.adapterdelegates4.ListDelegationAdapter | ||
import com.hannesdorfmann.adapterdelegates4.sample.adapterdelegates.AdvertisementAdapterDelegate | ||
import com.hannesdorfmann.adapterdelegates4.sample.adapterdelegates.DogAdapterDelegate | ||
import com.hannesdorfmann.adapterdelegates4.sample.adapterdelegates.GeckoAdapterDelegate | ||
import com.hannesdorfmann.adapterdelegates4.sample.adapterdelegates.SnakeListItemAdapterDelegate | ||
import com.hannesdorfmann.adapterdelegates4.sample.dsl.catAdapterDelegate | ||
import com.hannesdorfmann.adapterdelegates4.sample.model.DisplayableItem | ||
|
||
class MainListAdapter(activity: Activity) : ListDelegationAdapter<List<DisplayableItem>>( | ||
AdvertisementAdapterDelegate(activity), | ||
catAdapterDelegate(), | ||
DogAdapterDelegate(activity), | ||
GeckoAdapterDelegate(activity), | ||
SnakeListItemAdapterDelegate(activity) | ||
) |
20 changes: 20 additions & 0 deletions
20
app/src/main/java/com/hannesdorfmann/adapterdelegates4/sample/dsl/DslSample.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.hannesdorfmann.adapterdelegates4.sample.dsl | ||
|
||
import android.util.Log | ||
import com.hannesdorfmann.adapterdelegates4.dsl.adapterDelegateLayoutContainer | ||
import com.hannesdorfmann.adapterdelegates4.sample.R | ||
import com.hannesdorfmann.adapterdelegates4.sample.model.Cat | ||
import com.hannesdorfmann.adapterdelegates4.sample.model.DisplayableItem | ||
import kotlinx.android.synthetic.main.item_cat.* | ||
|
||
// Example | ||
fun catAdapterDelegate() = adapterDelegateLayoutContainer<Cat, DisplayableItem>(R.layout.item_cat) { | ||
|
||
name.setOnClickListener { | ||
Log.d("Click", "Click on $item") | ||
} | ||
|
||
bind { | ||
name.text = item.name | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,4 @@ public class Cat extends Animal { | |
public Cat(String name) { | ||
super(name); | ||
} | ||
|
||
|
||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
#Sun Mar 31 17:59:48 CEST 2019 | ||
#Wed Jul 03 19:42:09 CEST 2019 | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip |
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 @@ | ||
/build |
Oops, something went wrong.