Skip to content

Instantly share code, notes, and snippets.

View ravisorathiya's full-sized avatar

Ravi Sorathiya ravisorathiya

  • Surat Gujarat India
View GitHub Profile
class AppDataStoreManager private constructor(val context: Application) : AppDataStore {
private val Context.dataStore: DataStore<Preferences> by preferencesDataStore(name = "settings")
companion object {
@Volatile
private var INSTANCE: AppDataStoreManager? = null
@ravisorathiya
ravisorathiya / ActivityTracker.kt
Created April 4, 2024 07:32
ActivityTracker.kt
class ActivityTracker private constructor(private val context: Application) {
private val runningActivities = LinkedHashSet<Activity>()
private val exceptActivity = LinkedHashSet<Class<*>>()
private val trackOnlyActivities = LinkedHashSet<Class<*>>()
private var trackRegisterOnly = false
companion object {
@ravisorathiya
ravisorathiya / EasyAdapter.kt
Last active May 8, 2024 07:04
BaseAdapter.kt
class EasyAdapter<T : Any> private constructor(
private val layoutResId: Int,
areContentsTheSame: (T, T) -> Boolean = { old, new -> old == new },
areItemsTheSame: (T, T) -> Boolean = { old, new -> old == new },
private val onBind: (View, T) -> Unit,
private val onViewCreated: (View, position: () -> Pair<Int, T>) -> Unit,
) : ListAdapter<T, RecyclerView.ViewHolder>(
GenericDiffCallback(
areContentsTheSame,
areItemsTheSame,
@ravisorathiya
ravisorathiya / base-module.gradle
Last active February 24, 2024 05:16
multi module project gradle file
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
//apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-parcelize'
apply plugin: 'com.google.devtools.ksp'
android {
namespace = "com.ravisorathiya.dailyandroid"
compileSdk ProjectConfig.compileSdk
object MyApi {
private const val BASE_URL = " https://www.MYAPI.com/"
private val moshi = Moshi.Builder()
.add(KotlinJsonAdapterFactory())
.build()
private val retrofit = Retrofit.Builder()
.addConverterFactory(MoshiConverterFactory.create(moshi))
import android.app.Application
import android.content.Context
import androidx.room.Room
import com.example.galleryapp.MyApplication
import com.example.galleryapp.core.data.AppDatabase
import com.squareup.moshi.Moshi
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import android.annotation.SuppressLint
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.ListAdapter
import androidx.recyclerview.widget.RecyclerView
class MyAdapter(
) : ListAdapter<Any, MyAdapter.MyViewHolder>(
DiffCallBack()
<?xml version="1.0" encoding="utf-8"?>
<paths>
<external-path
name="external"
path="." />
<external-files-path
name="external_files"
path="." />
<cache-path
name="cache"
import androidx.room.TypeConverter
import com.google.gson.Gson
import com.google.gson.reflect.TypeToken
import com.wondersoftware.mastapp.business.datasource.cache.theme.ThemeEntity
import java.lang.reflect.Type
import java.util.*
class DataTypeConverter {
private val gson = Gson()
import android.app.Application
import android.content.Context
import androidx.room.Room
import com.google.gson.Gson
import com.google.gson.GsonBuilder
import com.huawei.hms.mlsdk.MLAnalyzerFactory
import com.huawei.hms.mlsdk.imgseg.MLImageSegmentationAnalyzer
import com.huawei.hms.mlsdk.imgseg.MLImageSegmentationScene
import com.huawei.hms.mlsdk.imgseg.MLImageSegmentationSetting
import com.wondersoftware.mastapp.MastApplication