Skip to content

Instantly share code, notes, and snippets.

Avatar

Alex Facciorusso alexfacciorusso

View GitHub Profile
View SchrodingerCat.kt
class Cat {
val meow = "Meowww...? :3"
}
fun main(args: Array<String>) {
var aBoringClassInstance: Cat? = Cat()
aBoringClassInstance!!
val sureNull: Cat? = null
sureNull!!
@alexfacciorusso
alexfacciorusso / DaggerViewModelFactory.kt
Last active Sep 16, 2017
A Dagger 2 injected ViewModelProvider.Factory implementation.
View DaggerViewModelFactory.kt
@Singleton
class DaggerViewModelFactory
@Inject constructor(
private val creators: Map<Class<out ViewModel>, @JvmSuppressWildcards Provider<ViewModel>>
) : ViewModelProvider.Factory {
override fun <T : ViewModel> create(modelClass: Class<T>): T {
val creator = creators[modelClass] ?:
creators.asIterable().firstOrNull { modelClass.isAssignableFrom(it.key) }?.value
?: throw IllegalArgumentException("unknown model class " + modelClass)
@alexfacciorusso
alexfacciorusso / expand-collapse.java
Created Jun 27, 2016 — forked from ZkHaider/expand-collapse.java
Simple Expand / Collapse RecyclerView Item
View expand-collapse.java
public static class ExampleViewHolder extends RecyclerView.ViewHolder
implements View.OnClickListener {
private int originalHeight = 0;
private boolean isViewExpanded = false;
private YourCustomView yourCustomView
public ExampleViewHolder(View v) {
super(v);
v.setOnClickListener(this);
@alexfacciorusso
alexfacciorusso / KtRetrofit.kt
Last active Sep 12, 2019
Retrofit Kotlin extensions
View KtRetrofit.kt
import retrofit.Call
import retrofit.Callback
import retrofit.Response
import retrofit.Retrofit
/**
* @author Alex Facciorusso
* @since 06/11/15
*/
@alexfacciorusso
alexfacciorusso / BindingCompatActivity.java
Created Aug 11, 2015
Some utility classes for Data Binding.
View BindingCompatActivity.java
import android.databinding.DataBindingUtil;
import android.databinding.ViewDataBinding;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.view.ViewGroup;
/**
* @author alexfacciorusso
* @since 11/08/15.
*/
@alexfacciorusso
alexfacciorusso / layout.xml
Created May 31, 2015
Layout used in project with issue
View layout.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
android:id="@+id/main_content"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
@alexfacciorusso
alexfacciorusso / PostActivity.java
Created May 30, 2015
AppBarLayout + WebView issue
View PostActivity.java
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
android:id="@+id/main_content"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
View FloatLabelLayout.java
/*
* Copyright 2015 Chris Banes, Alex Facciorusso
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
View designer.html
<link rel="import" href="../core-icon-button/core-icon-button.html">
<link rel="import" href="../core-toolbar/core-toolbar.html">
<link rel="import" href="../core-scroll-header-panel/core-scroll-header-panel.html">
<polymer-element name="my-element">
<template>
<style>
:host {
position: absolute;