View MainActivity.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
binding = DataBindingUtil.setContentView(this, R.layout.activity_main) //activity | |
binding = DataBindingUtil.inflate(layoutInflater, R.layout.activity_main, container, false) //fragment, view |
View buidl.gradle
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
apply plugin: 'kotlin-kapt' | |
android { | |
... | |
buildFeatures{ | |
dataBinding = true | |
} | |
... | |
View activity_main.xml
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
<?xml version="1.0" encoding="utf-8"?> | |
<layout xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:tools="http://schemas.android.com/tools"> | |
<data> | |
<variable | |
name="user" | |
type="com.mustafayigit.databindingexample.data.User" /> |
View BindingAdapter.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
@BindingAdapter("loadImage") | |
fun loadImage(imageView: ImageView, imageUrl: String) { | |
Glide.with(imageView.context) | |
.load(imageUrl) | |
.into(imageView) | |
} |
View User.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
package com.mustafayigit.databindingexample.data | |
/** | |
* Created By MUSTAFA | |
* on 07/06/2020 | |
*/ | |
data class User( | |
val username: String, | |
val photoUrl: String, | |
val age: Int, |
View ProfileDataViewHolder.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
package com.mustafayigit.recyclerviewexample.ui.adapter | |
import android.view.LayoutInflater | |
import android.view.ViewGroup | |
import androidx.recyclerview.widget.RecyclerView | |
import com.bumptech.glide.Glide | |
import com.bumptech.glide.request.RequestOptions | |
import com.mustafayigit.recyclerviewexample.R | |
import com.mustafayigit.recyclerviewexample.model.ProfileData | |
import kotlinx.android.synthetic.main.adapter_item_profile_data.view.* |
View ProfileDataAdapter.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
package com.mustafayigit.recyclerviewexample.ui.adapter | |
import android.view.ViewGroup | |
import androidx.recyclerview.widget.RecyclerView | |
import com.mustafayigit.recyclerviewexample.model.ProfileData | |
/** | |
* Created By MUSTAFA | |
* on 26/03/2020 | |
*/ |
View adapter_item_profile_data.xml
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
<?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="horizontal"> | |
<ImageView | |
android:id="@+id/imgProfilePhoto" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" |
View ProfileData.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
package com.mustafayigit.recyclerviewexample.model | |
/** | |
* Created By MUSTAFA | |
* on 26/03/2020 | |
*/ | |
data class ProfileData( | |
val photoUrl: String, | |
val fullName: String, |
View activity_main.xml
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
<?xml version="1.0" encoding="utf-8"?> | |
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:tools="http://schemas.android.com/tools" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
tools:context=".ui.MainActivity"> | |
<androidx.recyclerview.widget.RecyclerView | |
android:id="@+id/recyclerViewProfileData" | |
android:layout_width="match_parent" |
OlderNewer