Skip to content

Instantly share code, notes, and snippets.

View mustafayigitt's full-sized avatar
🚀
Focusing

Mustafa Yiğit mustafayigitt

🚀
Focusing
View GitHub Profile
@mustafayigitt
mustafayigitt / MainActivity.kt
Last active June 6, 2020 23:12
Databinding inflate and setContentView
binding = DataBindingUtil.setContentView(this, R.layout.activity_main) //activity
binding = DataBindingUtil.inflate(layoutInflater, R.layout.activity_main, container, false) //fragment, view
@mustafayigitt
mustafayigitt / buidl.gradle
Last active June 6, 2020 23:25
Enable DataBinding in your module
apply plugin: 'kotlin-kapt'
android {
...
buildFeatures{
dataBinding = true
}
...
@mustafayigitt
mustafayigitt / activity_main.xml
Last active June 6, 2020 23:31
sample databinding layout
<?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" />
@mustafayigitt
mustafayigitt / BindingAdapter.kt
Created June 6, 2020 23:50
Binding Adapters for Imageview with Glide
@BindingAdapter("loadImage")
fun loadImage(imageView: ImageView, imageUrl: String) {
Glide.with(imageView.context)
.load(imageUrl)
.into(imageView)
}
@mustafayigitt
mustafayigitt / User.kt
Created June 6, 2020 22:44
Data model class
package com.mustafayigit.databindingexample.data
/**
* Created By MUSTAFA
* on 07/06/2020
*/
data class User(
val username: String,
val photoUrl: String,
val age: Int,
@mustafayigitt
mustafayigitt / ProfileDataViewHolder.kt
Last active June 14, 2020 08:51
Profile data view holder
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.*
@mustafayigitt
mustafayigitt / ProfileDataAdapter.kt
Created March 26, 2020 13:15
recyclerview adapter class
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
*/
@mustafayigitt
mustafayigitt / adapter_item_profile_data.xml
Last active June 14, 2020 08:51
adapter item layout for recyclerview
<?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"
@mustafayigitt
mustafayigitt / ProfileData.kt
Created March 26, 2020 11:49
data class for model
package com.mustafayigit.recyclerviewexample.model
/**
* Created By MUSTAFA
* on 26/03/2020
*/
data class ProfileData(
val photoUrl: String,
val fullName: String,
@mustafayigitt
mustafayigitt / activity_main.xml
Last active June 14, 2020 08:52
recyclerview in FrameLayout
<?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"