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.Intent; | |
import android.os.Bundle; | |
import android.support.annotation.NonNull; | |
public abstract class BundleKey<T> { | |
@NonNull final String key; | |
BundleKey(@NonNull String key) { | |
this.key = key; |
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 net.aquadc.common | |
// Gist: https://gist.github.com/Miha-x64/5f626228b34175f827734596d6701008 | |
import java.util.* | |
// maps | |
inline fun <reified K : Enum<K>, V> enumMapOf(): MutableMap<K, V> { | |
return EnumMap<K, V>(K::class.java) | |
} |
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 net.aquadc.common | |
import com.google.gson.Gson | |
import com.google.gson.TypeAdapter | |
import com.google.gson.TypeAdapterFactory | |
import com.google.gson.reflect.TypeToken | |
import java.lang.reflect.ParameterizedType | |
import java.util.* | |
/** |
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
abstract class RetrofitCallback<T> : retrofit2.Callback<T> { | |
final override fun onResponse(call: Call<T>, response: Response<T>) = | |
if (response.isSuccessful) onSuccess(response.body()) | |
else | |
onError(when (response.code()) { | |
401 -> Failure.Unauthorized() | |
404 -> Failure.NotFound() | |
409 -> Failure.Conflict() | |
500 -> Failure.InternalServerError() |
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
object class BadBackendResponseDeserializer : JsonDeserializer<Any?> { | |
// register all adapters you need | |
private val gson = GsonBuilder() | |
.registerTypeAdapter(Post::class.java, WallPostAdapter) | |
.registerTypeAdapter(Attachment::class.java, AttachmentAdapter) | |
.registerTypeAdapter(User::class.java, UserAdapter) | |
.registerTypeAdapter(Group::class.java, GroupAdapter) | |
.create() |
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 com.google.gson.Gson; | |
import com.google.gson.JsonIOException; | |
import com.google.gson.TypeAdapter; | |
import com.google.gson.internal.JsonReaderInternalAccess; | |
import com.google.gson.reflect.TypeToken; | |
import com.google.gson.stream.JsonReader; | |
import com.google.gson.stream.JsonToken; | |
import com.google.gson.stream.JsonWriter; | |
import com.google.gson.stream.MalformedJsonException; | |
import okhttp3.MediaType; |
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 GradientStrokeDrawable : Drawable() { | |
var radius: Float = 0f | |
set(radius) { | |
if (field != radius) { | |
check(radius.isFinite() && radius >= 0f) | |
field = radius | |
path.rewind() | |
invalidateSelf() | |
} |
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.io.IOException; | |
import java.io.UncheckedIOException; | |
/** | |
* XML escaping utils. | |
* | |
* Source: https://gist.github.com/Miha-x64/4ed50f1d5593e45a452efbf456aa1db4 | |
*/ | |
public final class Xml { |
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 whatever.dynamicapkloading; | |
import android.app.Activity; | |
import android.content.Context; | |
import android.content.res.AssetManager; | |
import android.content.res.Configuration; | |
import android.content.res.Resources; | |
import android.os.Bundle; | |
import android.util.DisplayMetrics; | |
import android.widget.TextView; |
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
# preverify is useful only for J2ME | |
# R8 doesn't preverify by default | |
#-dontpreverify | |
-optimizationpasses 5 | |
# this seems to be enough | |
# remove indirection | |
-allowaccessmodification |