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.commonandroid.views | |
import android.annotation.SuppressLint | |
import android.content.Context | |
import android.graphics.Bitmap | |
import android.graphics.drawable.BitmapDrawable | |
import android.graphics.drawable.ColorDrawable | |
import android.graphics.drawable.Drawable | |
import android.graphics.drawable.TransitionDrawable | |
import android.view.View |
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 MainActivity : AppCompatActivity(), | |
NavigationView.OnNavigationItemSelectedListener, FragmentManager.OnBackStackChangedListener { | |
private lateinit var drawer: DrawerLayout | |
private lateinit var toggle: ActionBarDrawerToggle | |
private lateinit var navigation: NavigationView | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) |
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
package net.aquadc.commonandroid.lists; | |
import android.support.v4.view.ViewCompat; | |
import android.support.v4.view.ViewPropertyAnimatorCompat; | |
import android.support.v7.widget.RecyclerView; | |
import android.view.View; | |
import com.mikepenz.itemanimators.DefaultAnimator; | |
/** | |
* ItemAnimator implementation which animates items so it looks like they're falling into list. |
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
package net.aquadc.common | |
import java.util.* | |
import kotlin.DeprecationLevel.ERROR | |
import kotlin.UnsupportedOperationException as UOE | |
/** | |
* Created by mike on 17.02.17 | |
*/ |
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
package net.aquadc.commonandroid | |
import android.content.res.Resources | |
import java.text.SimpleDateFormat | |
import java.util.* | |
/** | |
* Returns text representation of `Date` and time (in millis) | |
* after which this value should be updated; | |
* time can be -1, which means that no update will ever be needed |
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
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) | |
} |
OlderNewer