Skip to content

Instantly share code, notes, and snippets.

View aungtuntun's full-sized avatar

Aung Tun Tun aungtuntun

View GitHub Profile
@aungtuntun
aungtuntun / CharCount.java
Created May 5, 2020 01:24
CharCountUnitTest
package com.itscreening.tests.faker;
public class CharCount {
public static void main(String[] args) {
// String str1 = "aaabbccdaaee";
// String str2 = "a3b2c2da2e2";
// System.out.println(convert("").equals(""));
}
@aungtuntun
aungtuntun / BinaryGap.java
Created April 2, 2020 17:27
Find longest sequence of zeros in binary representation of an integer.
package com.spring.api.eastates;
import org.testng.annotations.Test;
@Test(timeOut = 1000)
public class BinaryGap {
public static void main(String[] args) {
System.out.println(transformBinary(4848));
// source https://gist.github.com/tinmegali/d4a477785f01e57066915a44543db6ed#gistcomment-3013080
class ListStringConverter {
@TypeConverter
fun fromString(value: String): List<String> {
val listType = object : TypeToken<List<String>>() {}.type
return Gson().fromJson(value, listType)
}
@aungtuntun
aungtuntun / AutoCompleteAdapters.kt
Created August 26, 2019 04:22 — forked from frett/AutoCompleteAdapters.kt
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,
@aungtuntun
aungtuntun / AccountAuthenticator.java
Created February 22, 2019 10:59 — forked from burgalon/AccountAuthenticator.java
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);
@aungtuntun
aungtuntun / FabIconAnimator.java
Created January 16, 2019 10:45 — forked from tunjid/FabIconAnimator.java
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;
@aungtuntun
aungtuntun / NetModule.java
Created January 7, 2019 11:06 — forked from staakk/NetModule.java
Dagger2 module for Retrofit with authorization, and Java 8 DateTime mappers
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.module.SimpleModule;
import org.threeten.bp.LocalDateTime;
import javax.inject.Singleton;
import dagger.Module;
import dagger.Provides;
import okhttp3.OkHttpClient;
@aungtuntun
aungtuntun / gist:a0eeb66fc7cb7c6bf9422762f6f8c3b0
Created December 12, 2018 05:28 — forked from orhanobut/gist:8665372
Up down animation for dialog fragment
// Slide up animation
<?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android" >
<translate
android:duration="@android:integer/config_mediumAnimTime"
android:fromYDelta="100%"
android:interpolator="@android:anim/accelerate_interpolator"
android:toXDelta="0" />
@aungtuntun
aungtuntun / RoundedBottomSheetDialogFragment.kt
Created October 19, 2018 09:34 — forked from ArthurNagy/RoundedBottomSheetDialogFragment.kt
Rounded modal bottom sheet as seen in new Google products(Tasks, News, etc.), described in this article: https://medium.com/halcyon-mobile/implementing-googles-refreshed-modal-bottom-sheet-4e76cb5de65b
package com.your.package
import android.app.Dialog
import android.os.Bundle
import com.your.package.R
import com.google.android.material.bottomsheet.BottomSheetDialog
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
/**
* BottomSheetDialog fragment that uses a custom
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/handlebars.js/1.0.0-rc.3/handlebars.js"></script>
<script src="http://builds.emberjs.com.s3.amazonaws.com/ember-1.0.0-rc.6.js"></script>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body>