This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.concurrent.atomic.AtomicBoolean | |
/** | |
* Wraps some data that should track when it has been viewed and allow future viewers to avoid a second showing. | |
* Useful for showing messages in the app that auto-hide because this class can exist in the app's state. | |
*/ | |
data class ViewOnceData<T>(private val data: T) { | |
val wasViewed = AtomicBoolean(false) | |
/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.content.Context; | |
import android.content.Intent; | |
import android.os.Bundle; | |
import android.support.annotation.NonNull; | |
import android.support.annotation.Nullable; | |
import android.support.v7.app.AppCompatActivity; | |
import com.mywebgrocer.util.ActivityResultData; | |
import java.util.Random; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Barker : NoiseMaker { | |
override fun makeSound() { | |
println("Bark!") | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.content.Context | |
import android.content.SharedPreferences | |
import kotlin.reflect.KProperty | |
/** | |
* Represents a single [SharedPreferences] file. | |
* | |
* Usage: | |
* | |
* ```kotlin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.databinding.ObservableArrayList; | |
import android.databinding.ObservableList; | |
import com.jakewharton.rxrelay.PublishRelay; | |
import java.util.List; | |
import rx.Observable; | |
/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** Example of a {@link Class} declaration */ | |
public final class MyClass { | |
private boolean someBool; | |
public MyClass() { | |
} | |
public MyClass(boolean someBool) { | |
this.someBool = someBool; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void signIn(User user) { | |
api.signIn(user, onSuccessCallback: { | |
getLinks(user); | |
}, onErrorCallback(): { | |
reauthorize(user); | |
} | |
public void getLinks(User user) { | |
api.getLinks(user, onSuccessCallback: { | |
postSuccessEvent(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { |