Skip to content

Instantly share code, notes, and snippets.

View DanteAndroid's full-sized avatar
💭
Looking for a job in ShangHai

Dante DanteAndroid

💭
Looking for a job in ShangHai
  • Shanghai
View GitHub Profile
@DanteAndroid
DanteAndroid / build.gradle
Last active August 9, 2023 03:44
Add a task which changes your file under project directory, and it could be run first when running.
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
}
android {
namespace 'com.example.myapplication'
compileSdk 33
defaultConfig {
@DanteAndroid
DanteAndroid / scratch.kts
Last active July 6, 2023 14:15
王荣吉占摸牌期望
main()
fun main() {
val testResult = mutableListOf<Int>()
repeat(10000) {
testResult.add(jiZhan())
}
val counts = testResult.groupingBy { it }.eachCount()
var expect = 0f
for ((number, count) in counts) {
@DanteAndroid
DanteAndroid / MainActivity.java
Created February 27, 2022 04:21
ReyclerView item animator - Color Text Change
/*
* Copyright (C) 2016 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@DanteAndroid
DanteAndroid / charles-proxy-android.md
Created November 18, 2021 10:35 — forked from twaddington/charles-proxy-android.md
How to set up Charles Proxy for the Android Emulator.

Charles Proxy Android

Steps

1. Add the Network Security Configuration to your app

<network-security-config>
   <debug-overrides>
 
@DanteAndroid
DanteAndroid / BottomDialog.kt
Last active April 30, 2021 03:58
Easy-to-use bottom dialogs
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.annotation.LayoutRes
import androidx.annotation.StyleRes
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
import com.rrtv.ui.R
/**
@DanteAndroid
DanteAndroid / Event.kt
Created March 29, 2021 07:19
One-time event wrapper for LiveData
package com.rrtv.utils
/**
* Used as a wrapper for data that is exposed via a LiveData that represents an event.
*/
open class Event<out T>(private val content: T) {
var hasBeenHandled = false
private set
@DanteAndroid
DanteAndroid / InfiniteBackgroundLayout.kt
Last active January 26, 2021 11:31
ConstrainLayout that has ability to infinitely scroll background image vertically or horizontally
import android.animation.ValueAnimator
import android.content.Context
import android.util.AttributeSet
import android.view.animation.LinearInterpolator
import android.widget.ImageView
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.constraintlayout.widget.ConstraintSet
import androidx.core.content.res.ResourcesCompat
/**