Skip to content

Instantly share code, notes, and snippets.

View aungtuntun's full-sized avatar

Aung Tun Tun aungtuntun

View GitHub Profile
@frett
frett / AutoCompleteAdapters.kt
Created May 15, 2019 17:53
Android Material Components - Dropdown Menu + Data Binding
import android.widget.ArrayAdapter
import android.widget.AutoCompleteTextView
import androidx.annotation.LayoutRes
import androidx.databinding.BindingAdapter
@BindingAdapter("dropDownItems", "dropDownItemLayout", "dropDownItemsIncludeEmpty", requireAll = false)
fun AutoCompleteTextView.setItems(items: Array<String>?, @LayoutRes layout: Int?, includeEmpty: Boolean?) =
setAdapter(
ArrayAdapter(
context,
@tunjid
tunjid / FabIconAnimator.java
Created October 16, 2018 19:59
A simple utility class that creates an expandable Floating Action Button
package com.mainstreetcode.teammate.util;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.support.annotation.DrawableRes;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.StringRes;
import android.support.constraint.ConstraintLayout;
import android.support.constraint.ConstraintSet;
@ThePredators
ThePredators / AndroidWorkerInjection.java
Last active December 30, 2021 03:27
[Dagger] integration with workers (For Java People)
public class AndroidWorkerInjection {
public static void inject(Worker worker) {
checkNotNull(worker, "worker");
Object application = worker.getApplicationContext();
if (!(application instanceof HasWorkerInjector)) {
throw new RuntimeException(
String.format(
"%s does not implement %s",
application.getClass().getCanonicalName(),
@alex-shpak
alex-shpak / Interceptor.java
Last active June 24, 2025 03:32
Refreshing OAuth token with okhttp interceptors. All requests will wait until token refresh finished, and then will continue with the new token.
private class HttpInterceptor implements Interceptor {
@Override
public Response intercept(Chain chain) throws IOException {
Request request = chain.request();
//Build new request
Request.Builder builder = request.newBuilder();
builder.header("Accept", "application/json"); //if necessary, say to consume JSON
@burgalon
burgalon / AccountAuthenticator.java
Last active November 12, 2025 22:46
Implementing OAuth2 with AccountManager, Retrofit and Dagger
public class AccountAuthenticator extends AbstractAccountAuthenticator {
private final Context context;
@Inject @ClientId String clientId;
@Inject @ClientSecret String clientSecret;
@Inject ApiService apiService;
public AccountAuthenticator(Context context) {
super(context);