This file contains hidden or 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.net.Uri | |
object GoogleAuthenticatorUtils { | |
enum class KeyType(val uriKey: String) { | |
TIME_BASED("totp"), | |
COUNTER_BASED("hotp") | |
} | |
//Based on https://github.com/google/google-authenticator/wiki/Key-Uri-Format |
This file contains hidden or 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.graphics.Rect | |
import android.util.LayoutDirection | |
import android.view.View | |
import androidx.annotation.DimenRes | |
import androidx.recyclerview.widget.GridLayoutManager | |
import androidx.recyclerview.widget.RecyclerView | |
class MarginItemDecoration( | |
private val marginLeft: Int, |
This file contains hidden or 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.util.AttributeSet | |
import androidx.constraintlayout.widget.Placeholder | |
// You can replace it with Placeholder when you want to set layout_constraintBaseline_toBaselineOf | |
class PlaceholderWithBaseline @JvmOverloads constructor( | |
context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0 | |
) : Placeholder(context, attrs, defStyleAttr) { | |
override fun getBaseline(): Int = | |
content.baseline |
This file contains hidden or 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
#change this if you want to support other types of sequences | |
def get_char_index(c): | |
if c == 'A': | |
return 1 | |
elif c == 'C': | |
return 2 | |
elif c == 'G': | |
return 3 | |
elif c == 'T': | |
return 4 |
This file contains hidden or 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
BLOSUM62_MATRIX = [[4, 0, -2, -1, -2, 0, -2, -1, -1, -1, -1, -2, -1, -1, -1, 1, 0, 0, -3, -2], | |
[0, 9, -3, -4, -2, -3, -3, -1, -3, -1, -1, -3, -3, -3, -3, -1, -1, -1, -2, -2], | |
[-2, -3, 6, 2, -3, -1, -1, -3, -1, -4, -3, 1, -1, 0, -2, 0, -1, -3, -4, -3], | |
[-1, -4, 2, 5, -3, -2, 0, -3, 1, -3, -2, 0, -1, 2, 0, 0, -1, -2, -3, -2], | |
[-2, -2, -3, -3, 6, -3, -1, 0, -3, 0, 0, -3, -4, -3, -3, -2, -2, -1, 1, 3], | |
[0, -3, -1, -2, -3, 6, -2, -4, -2, -4, -3, 0, -2, -2, -2, 0, -2, -3, -2, -3], | |
[-2, -3, -1, 0, -1, -2, 8, -3, -1, -3, -2, 1, -2, 0, 0, -1, -2, -3, -2, 2], | |
[-1, -1, -3, -3, 0, -4, -3, 4, -3, 2, 1, -3, -3, -3, -3, -2, -1, 3, -3, -1], | |
[-1, -3, -1, 1, -3, -2, -1, -3, 5, -2, -1, 0, -1, 1, 2, 0, -1, -2, -3, -2], | |
[-1, -1, -4, -3, 0, -4, -3, 2, -2, 4, 2, -3, -3, -2, -2, -2, -1, 1, -2, -1], |
This file contains hidden or 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
@BindingAdapter("android:layout_gravity") | |
fun setLayoutGravity(view: View, gravity: Int) { | |
when (view.layoutParams) { | |
is LinearLayout.LayoutParams -> | |
(view.layoutParams as LinearLayout.LayoutParams).gravity = gravity | |
is FrameLayout.LayoutParams -> | |
(view.layoutParams as FrameLayout.LayoutParams).gravity = gravity | |
//Add more view groups here | |
} | |
} |
This file contains hidden or 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.animation.ValueAnimator | |
import android.content.Context | |
import android.graphics.* | |
import android.util.AttributeSet | |
import android.view.View | |
import android.view.animation.AccelerateDecelerateInterpolator | |
import android.view.animation.AnimationUtils | |
import android.view.animation.Interpolator | |
import org.jetbrains.anko.displayMetrics | |
import kotlin.math.absoluteValue |
This file contains hidden or 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.ArrayList; | |
import java.util.Arrays; | |
import java.util.Collections; | |
import java.util.List; | |
import java.util.stream.Collectors; | |
public class IDXData { | |
protected final ArrayList<Integer> dimensions; | |
protected final byte[][] rawData; |
This file contains hidden or 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
val windowManager = this.getSystemService(Context.WINDOW_SERVICE) as WindowManager | |
val windowLayoutParams = WindowManager.LayoutParams() | |
windowLayoutParams.width = 300 | |
windowLayoutParams.height = 300 | |
windowLayoutParams.x = 400 | |
windowLayoutParams.y = 400 | |
windowLayoutParams.format = PixelFormat.TRANSLUCENT | |
windowLayoutParams.gravity = Gravity.TOP or Gravity.LEFT | |
if (Build.VERSION.SDK_INT >= 26) | |
windowLayoutParams.type = WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY |