Skip to content

Instantly share code, notes, and snippets.

@wispborne
wispborne / designer.html
Last active August 29, 2015 14:11
designer
<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-item/core-item.html">
<polymer-element name="my-element">
<template>
<style>
:host {
position: absolute;
@wispborne
wispborne / RetainedFragment.java
Last active August 29, 2015 14:19
RetainedFragment
package ro.ceva;
/**
* Created by David on 9/4/2015.
*/
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
@wispborne
wispborne / main_layout.xml
Last active August 29, 2015 14:20
Toolbar with shadow without Android elevation nonsense
<FrameLayout android:layout_width="match_parent"
android:layout_height="match_parent">
<include
layout="@layout/common_toolbar"/>
<FrameLayout android:layout_width="match_parent"
android:layout_height="match_parent">
<View android:layout_width="match_parent"
android:layout_height="4dp"
interface Callback { void onSuccess(int result); }
public processData() {
List<int> ints = generateTonsOfRandomInts();
addAllInts(ints, new Callback() {
public void onSuccess(int result) {
doNextThing(result, new Callback() {
public void onSuccess(int result) {
// finally do something with the results
import android.content.res.ColorStateList
import android.graphics.PorterDuff
import android.graphics.drawable.Drawable
import android.support.annotation.ColorInt
import android.support.v4.graphics.drawable.DrawableCompat
/**
* Created by David Whitman
*/
object TintUtils {
public void signIn(User user) {
api.signIn(user, onSuccessCallback: {
getLinks(user);
}, onErrorCallback(): {
reauthorize(user);
}
public void getLinks(User user) {
api.getLinks(user, onSuccessCallback: {
postSuccessEvent();
@wispborne
wispborne / KotlinComparisonClass.java
Last active August 17, 2020 19:42
Comparison of Java to Kotlin for various simple methods.
/** Example of a {@link Class} declaration */
public final class MyClass {
private boolean someBool;
public MyClass() {
}
public MyClass(boolean someBool) {
this.someBool = someBool;
}
package com.thunderclouddev.changelogs.ui
import android.content.Context
import android.os.Bundle
import android.support.annotation.LayoutRes
import android.support.annotation.StyleRes
import android.support.v7.app.AppCompatActivity
import com.thunderclouddev.changelogs.BaseApplication
import com.thunderclouddev.changelogs.R
import com.thunderclouddev.changelogs.configuration.LanguagePreference
public void onCreate() {
// Http client
OkHttpClient client = new OkHttpClient();
// Content type
MediaType JSON = MediaType.parse("application/json; charset=utf-8");
// Whatever you want to send, here it's json
RequestBody body = RequestBody.create(JSON, yourJsonString);
import android.databinding.ObservableArrayList;
import android.databinding.ObservableList;
import com.jakewharton.rxrelay.PublishRelay;
import java.util.List;
import rx.Observable;
/**