-
Notifications
You must be signed in to change notification settings - Fork 500
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Converted dogs module from Epoxy to data binding (#272)
I wanted to give data binding a shot for my Droidcon NYC talk for a few reasons: I was curious. As I talk to people, a lot of people think that using MvRx requires Epoxy. It doesn't, it just happens to work really well with it. I think it adds to much overhead for the talk and scares/overwhelms people. It turns out that it's really awesome and is also super compatible with MvRx. P.S. I still ❤Epoxy
- Loading branch information
Showing
40 changed files
with
505 additions
and
468 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,17 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:orientation="vertical" | ||
tools:context=".CounterActivity"> | ||
|
||
<fragment | ||
android:id="@+id/nav_host_fragment" | ||
android:name="androidx.navigation.fragment.NavHostFragment" | ||
android:layout_width="0dp" | ||
android:name="com.airbnb.mvrx.counter.CounterFragment" | ||
android:layout_width="match_parent" | ||
android:layout_height="0dp" | ||
app:defaultNavHost="true" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintLeft_toLeftOf="parent" | ||
app:layout_constraintRight_toRightOf="parent" | ||
app:layout_constraintTop_toTopOf="parent" | ||
app:navGraph="@navigation/nav_graph" /> | ||
android:layout_weight="1" /> | ||
|
||
</androidx.constraintlayout.widget.ConstraintLayout> | ||
</LinearLayout> |
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 was deleted.
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
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,25 @@ | ||
package com.airbnb.mvrx.dogs | ||
|
||
import android.view.ViewGroup | ||
import androidx.recyclerview.widget.ListAdapter | ||
import com.airbnb.mvrx.dogs.data.Dog | ||
import com.airbnb.mvrx.dogs.databinding.DogRowBinding | ||
import com.airbnb.mvrx.dogs.utils.LayoutViewHolder | ||
import com.airbnb.mvrx.dogs.views.DogsFragmentHandler | ||
import com.airbnb.mvrx.dogs.views.HashItemCallback | ||
|
||
class DogViewHolder(parent: ViewGroup) : LayoutViewHolder(parent, R.layout.dog_row) { | ||
val binding = DogRowBinding.bind(itemView) | ||
} | ||
|
||
class DogAdapter(private val fragment: DogsFragmentHandler) : ListAdapter<Dog, DogViewHolder>(HashItemCallback()) { | ||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): DogViewHolder { | ||
return DogViewHolder(parent).apply { | ||
binding.handler = fragment | ||
} | ||
} | ||
|
||
override fun onBindViewHolder(holder: DogViewHolder, position: Int) { | ||
holder.binding.dog = getItem(position) | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...om/airbnb/mvrx/dogs/app/DogApplication.kt → ...va/com/airbnb/mvrx/dogs/DogApplication.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
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: 2 additions & 3 deletions
5
.../com/airbnb/mvrx/dogs/app/DogsActivity.kt → ...java/com/airbnb/mvrx/dogs/DogsActivity.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 |
---|---|---|
@@ -1,13 +1,12 @@ | ||
package com.airbnb.mvrx.dogs.app | ||
package com.airbnb.mvrx.dogs | ||
|
||
import android.os.Bundle | ||
import com.airbnb.mvrx.BaseMvRxActivity | ||
import com.airbnb.mvrx.dogs.R | ||
|
||
class DogsActivity : BaseMvRxActivity() { | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setContentView(R.layout.activity_dogs) | ||
setContentView(R.layout.dogs_activity) | ||
} | ||
} |
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.