Skip to content

Instantly share code, notes, and snippets.

@lampard-android
lampard-android / ListRestaurantsActivity.kt
Created November 15, 2021 17:20
ListRestaurantsActivity.kt
package com.codegym.demo.list.view
import android.os.Bundle
import android.widget.Toast
import androidx.activity.viewModels
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.isVisible
import com.codegym.demo.data.ResponseData
import com.codegym.demo.databinding.ActivityListRestaurantsBinding
import com.codegym.demo.detail.RestaurantDetailActivity
@kavanmevada
kavanmevada / ListAdapter.kt
Created April 7, 2019 22:34
RecyclerView with ModelView
class ListAdapter(val list: MutableList<User>) : RecyclerView.Adapter<ListAdapter.ViewHolder>() {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder =
ViewHolder(inflate(LayoutInflater.from(parent.context), parent, false))
override fun getItemCount() = list.size
override fun onBindViewHolder(holder: ViewHolder, position: Int) = holder.bind(position)
inner class ViewHolder(private val binding: ListItemTwoTxtImgBinding) : RecyclerView.ViewHolder(binding.root) {
@elvismetaphor
elvismetaphor / CustomSetter.java
Last active July 7, 2022 07:15
Show how to implement MVVM with Data Binding while using Glide
package edu.self.binding;
import android.databinding.BindingAdapter;
import android.widget.ImageView;
import com.bumptech.glide.Glide;
public class CustomSetter {
@wojteklu
wojteklu / clean_code.md
Last active June 1, 2024 12:45
Summary of 'Clean code' by Robert C. Martin

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules

def buildConfigAndResStringField(variant, name, value) {
variant.resValue 'string', name.toLowerCase(), value
variant.buildConfigField 'String', name, "\"$value\""
}
afterEvaluate {
android.applicationVariants.all { variant ->
variant.resValue 'string', 'application_id', variant.applicationId
buildConfigAndResStringField variant, "ACCOUNT_TYPE", variant.applicationId
buildConfigAndResStringField variant, "CONTENT_AUTHORITY", variant.applicationId + ".provider"