Skip to content

Instantly share code, notes, and snippets.

View iChintanSoni's full-sized avatar

Chintan Soni iChintanSoni

View GitHub Profile
class AnimatorExtension {
// Skipping the initialization
private val animator: Animator? = null
// Normal Usage
fun normalAnimationListener() {
animator?.addListener(
onStart = {
class HomeActivity : DaggerAppCompatActivity() {
@Inject
lateinit var apiService: ApiService
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
// init UI
// Your apiService instance is ready to use.
@Module
abstract class ActivityModule {
@ContributesAndroidInjector
internal abstract fun contributeHomeActivity(): HomeActivity
}
class MyApplication : DaggerApplication() {
override fun onCreate() {
super.onCreate()
initializeTimber()
}
private fun initializeTimber() {
if (BuildConfig.DEBUG) {
@Component(modules = [AndroidSupportInjectionModule::class, AppModule::class, ActivityModule::class])
interface AppComponent : AndroidInjector<DaggerApplication> {
@Component.Builder
interface Builder {
@BindsInstance
fun application(application: Application): Builder
fun build(): AppComponent
}
@iChintanSoni
iChintanSoni / ApiService.kt
Last active January 23, 2020 00:34
Daggering kotlin-android: AppModule.kt
interface ApiService {
@GET("api")
fun getUsers(@Query("result") result: Int): Observable<RandomUserResponse>
}
@iChintanSoni
iChintanSoni / build.gradle
Created April 17, 2018 09:30
Daggering Kotlin-anroid: build.gradle
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.simform.android.dagger2advanced"
minSdkVersion 16
@iChintanSoni
iChintanSoni / BaseRecyclerAdapter.java
Created July 24, 2017 03:44
BaseRecyclerAdapter, a generic Recycler adapter, is an extended version from https://gist.github.com/chintansoni202/3c61aea787ae4bd49f26adee9dd40a08 This version should be used along with Data-binding. You can even pass empty view layout, if there is no list item.
public class BaseRecyclerAdapter<T, MVH extends BaseViewHolder<T>, EVH extends BaseViewHolder<T>> extends RecyclerView.Adapter<BaseViewHolder<T>> {
private static final int VIEW_TYPE_EMPTY = 0;
private static final int VIEW_TYPE_DATA = 1;
private List<T> list = new ArrayList<>();
@LayoutRes
private int emptyViewLayoutResource;
private Class<EVH> emptyViewHolder;
@LayoutRes
private int dataLayoutResource;
@iChintanSoni
iChintanSoni / BaseRecyclerAdapter.java
Created July 24, 2017 03:33
BaseRecyclerAdapter, a generic Recycler adapter, is an extended version from https://gist.github.com/chintansoni202/3c61aea787ae4bd49f26adee9dd40a08
public class BaseRecyclerAdapter<T, MVH extends BaseViewHolder<T>, EVH extends BaseViewHolder<T>> extends RecyclerView.Adapter<BaseViewHolder<T>> {
private static final int VIEW_TYPE_EMPTY = 0;
private static final int VIEW_TYPE_DATA = 1;
private List<T> list = new ArrayList<>();
@LayoutRes
private int emptyViewLayoutResource;
private Class<EVH> emptyViewHolder;
@LayoutRes
private int dataLayoutResource;
@iChintanSoni
iChintanSoni / ScrollingActivity.java
Last active October 3, 2018 09:07
CollapsingToolbarLayout with TabLayout
public class ScrollingActivity extends AppCompatActivity {
private SectionsPagerAdapter mSectionsPagerAdapter;
private ViewPager mViewPager;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_scrolling);