This file contains hidden or 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
| import android.os.Bundle | |
| import android.view.LayoutInflater | |
| import android.view.View | |
| import android.view.ViewGroup | |
| import androidx.fragment.app.Fragment | |
| import androidx.recyclerview.widget.LinearLayoutManager | |
| import com.example.stickyheader.databinding.FragmentHomeListBinding | |
| import com.example.stickyheader.header.StickyHeaderItemDecorator | |
| import com.example.stickyheader.model.ItemModel |
This file contains hidden or 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
| import android.annotation.SuppressLint | |
| import android.view.LayoutInflater | |
| import android.view.ViewGroup | |
| import android.widget.LinearLayout.LayoutParams | |
| import androidx.recyclerview.widget.DiffUtil | |
| import androidx.recyclerview.widget.ListAdapter | |
| import androidx.recyclerview.widget.RecyclerView | |
| import androidx.viewbinding.ViewBinding | |
| abstract class BaseListAdapter<T : Any, VB : ViewBinding> : |
This file contains hidden or 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
| fun EditText.textChanges(): Flow<String> { | |
| return callbackFlow { | |
| val listener = doOnTextChanged { text, _, _, _ -> trySend(text.toString()) } | |
| awaitClose { removeTextChangedListener(listener) } | |
| }.onStart { emit(text.toString()) } | |
| } | |
| private fun searchQuery(searchQuery: String): Flow<List<String>> { | |
| val items = listOf("Hello", "How are You", "Oh no!", "Iam Good!") | |
| return flow { |
This file contains hidden or 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
| abstract class BaseFragment<VB: ViewBinding, VM : BaseViewModel>( | |
| private val bindingInflater: (LayoutInflater) -> VB | |
| ) : Fragment() { | |
| private var _binding: VB? = null | |
| open val binding: VB | |
| get() = _binding as VB | |
| override fun onCreateView( |
This file contains hidden or 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.filipkowicz.headeritemdecorator | |
| /* | |
| solution based on - based on Sevastyan answer on StackOverflow | |
| changes: | |
| - take to account views offsets | |
| - transformed to Kotlin | |
| - now works on viewHolders |
This file contains hidden or 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
| typealias Inflate<T> = (LayoutInflater, ViewGroup?, Boolean) -> T | |
| abstract class BaseFragment<VB : ViewBinding, VM : BaseViewModel>( | |
| private val inflate: Inflate<VB> | |
| ) : Fragment() { | |
| private var _binding: VB? = null | |
| val binding get() = _binding!! | |
| protected abstract val viewModel: VM |
This file contains hidden or 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
| import com.google.gson.Gson | |
| import com.google.gson.GsonBuilder | |
| import com.google.gson.reflect.TypeToken | |
| import java.lang.reflect.Type | |
| // region [G-SON] | |
| val gSon: Gson by lazy { GsonBuilder().disableHtmlEscaping().create() } | |
| fun Any?.toJson(): String = gSon.toJson(this) |
This file contains hidden or 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
| /** | |
| * Create the Abstract Adapter and the ViewHolder that we need to hold the item view | |
| */ | |
| abstract class AbstractAdapter<T : ViewBinding, ITEM> constructor( | |
| protected var itemList: List<ITEM>, | |
| private val bindingClass: (LayoutInflater, ViewGroup, Boolean) -> T | |
| ) : RecyclerView.Adapter<AbstractAdapter.Holder>() { | |
| var binding: T? = null |
This file contains hidden or 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
| import androidx.compose.animation.core.* | |
| import androidx.compose.foundation.background | |
| import androidx.compose.foundation.layout.* | |
| import androidx.compose.foundation.shape.CircleShape | |
| import androidx.compose.material.MaterialTheme | |
| import androidx.compose.material.Text | |
| import androidx.compose.runtime.Composable | |
| import androidx.compose.runtime.getValue | |
| import androidx.compose.ui.Alignment | |
| import androidx.compose.ui.Modifier |
This file contains hidden or 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
| class MainFragment : Fragment(R.layout.main_fragment) { | |
| companion object { | |
| fun newInstance() = MainFragment() | |
| } | |
| private lateinit var viewModel: MainViewModel | |
| override fun onCreate(savedInstanceState: Bundle?) { |
NewerOlder