Skip to content

Instantly share code, notes, and snippets.

View vamjakuldip's full-sized avatar

vamjakuldip

  • Rajkot,Gujrat,India
View GitHub Profile
@vamjakuldip
vamjakuldip / bg_snackbar.xml
Created January 23, 2020 16:13
Snackbar background
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/font_color" />
<corners android:radius="4dp" />
</shape>
@vamjakuldip
vamjakuldip / BaseViewModel.kt
Created January 24, 2020 04:17
BaseViewModel for DataBinding
package com.vk.android.base
import android.app.Application
import androidx.lifecycle.AndroidViewModel
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import com.vk.android.network.ApiService
import com.vk.android.utils.EventMsg
import io.reactivex.disposables.CompositeDisposable
import java.lang.ref.WeakReference
@vamjakuldip
vamjakuldip / ViewBidingAdapter.kt
Created January 24, 2020 04:18
View Biding Adapter
package com.vk.android.databinding
import android.view.View
import android.widget.EditText
import android.widget.ImageView
import androidx.databinding.BindingAdapter
import com.bumptech.glide.Glide
import com.vk.android.BuildConfig
import com.vk.android.R
@vamjakuldip
vamjakuldip / PreferenceHelper.kt
Created January 24, 2020 04:20
Preferance Helper
package com.vk.android.helper
import android.content.Context
import android.content.SharedPreferences
class PreferenceHelper private constructor(context: Context) {
private val sharedPref: SharedPreferences = context.getSharedPreferences(context.packageName + ".PREFERENCE", Context.MODE_PRIVATE)
@vamjakuldip
vamjakuldip / ApiService.kt
Created January 24, 2020 04:21
Network Api Service with Retrofit
package com.vk.android.network
import com.vk.android.BuildConfig
import io.reactivex.Observable
import okhttp3.OkHttpClient
import okhttp3.logging.HttpLoggingInterceptor
import retrofit2.Retrofit
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory
import retrofit2.converter.gson.GsonConverterFactory
@vamjakuldip
vamjakuldip / EventMsg.kt
Last active January 24, 2020 04:22
Event Msg Helper. Listen only one Event for LiveData
package com.vk.android.utils
import androidx.lifecycle.Observer
open class EventMsg<out T>(private val content: T) {
var hasBeenHandled = false
private set // Allow external read but not write
fun getContentIfNotHandled(): T? {
@vamjakuldip
vamjakuldip / VkApplication.kt
Created January 24, 2020 04:27
Application Context with Multidex install
package com.vk.android.utils
import android.app.Application
import android.content.Context
import androidx.multidex.MultiDex
class VkApplication : Application() {
private val TAG = this.javaClass.simpleName
override fun onCreate() {
super.onCreate()
@vamjakuldip
vamjakuldip / LogExtension.kt
Created January 24, 2020 06:36
Log Extensin Print log for debug mode
package com.vk.android.extension
import android.util.Log
import com.vk.android.BuildConfig
inline fun <reified T : Any> T.logD(text: String) {
if (BuildConfig.DEBUG)
Log.d(T::class.java.simpleName, text)
}
@vamjakuldip
vamjakuldip / RxJavaExtension.kt
Last active January 25, 2020 05:00
Rx Java Retry Api Extension
package com.vk.android.extension
import com.vk.android.utils.Const
import io.reactivex.Observable
import io.reactivex.functions.BiFunction
import retrofit2.HttpException
import java.io.IOException
import java.io.InterruptedIOException
import java.net.SocketTimeoutException
import java.util.concurrent.TimeUnit
@vamjakuldip
vamjakuldip / ViewExtension.kt
Last active September 29, 2020 07:07
Android View Extension, Snackbar extension, shake view and vibrate device.
package com.vk.android.extension
import android.content.Context
import android.os.Build
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.appcompat.content.res.AppCompatResources
import androidx.core.content.ContextCompat