Skip to content

Instantly share code, notes, and snippets.

View hantrungkien's full-sized avatar
🏠
Working from home

Hán Trung Kiên hantrungkien

🏠
Working from home
View GitHub Profile
@hantrungkien
hantrungkien / Android TimeZone Ids
Created October 12, 2017 04:59 — forked from mtrung/Android TimeZone Ids
As of July 2015, there are 582 Java/Android TimeZone Ids. Note that this list is subject to change (there are 23 additions and 2 deletions from 2011 to 2015).
Africa/Abidjan
Africa/Accra
Africa/Addis_Ababa
Africa/Algiers
Africa/Asmara
Africa/Asmera
Africa/Bamako
Africa/Bangui
Africa/Banjul
Africa/Bissau
@hantrungkien
hantrungkien / Cryptography.java
Created December 6, 2018 07:41 — forked from Diederikjh/Cryptography.java
Single class that handles encryption and decryption with keys using the Android `Keystore` API. Mostly inspired by this [blog post](https://medium.com/@ericfu/securely-storing-secrets-in-an-android-application-501f030ae5a3). This was tested with API 18 and 25 level emulator (and a level 23 device).
package com.example.yourapp;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Build;
import android.security.KeyPairGeneratorSpec;
import android.security.keystore.KeyGenParameterSpec;
import android.security.keystore.KeyProperties;
import android.support.annotation.RequiresApi;
@hantrungkien
hantrungkien / NoLimitRecycledViewPool.java
Created June 3, 2020 03:31 — forked from alexoro/NoLimitRecycledViewPool.java
RecycledViewPool with unlimited number of ViewHolders
package com.vk.im.ui.utils.recyclerview;
import android.support.v7.widget.RecyclerView;
import android.util.SparseIntArray;
/**
* RecycledViewPool with unlimited number of ViewHolders
* {@author uas.sorokin@gmail.com}
*/
public class NoLimitRecycledViewPool extends RecyclerView.RecycledViewPool {
@HiltAndroidApp
class MyApplication : Application() {
@Inject
@UserModelSingletonQualifier
lateinit var singletonUserModel: UserModel
override fun onCreate() {
super.onCreate()
@Module
@InstallIn(ApplicationComponent::class)
object CoreModule {
@Provides
@Singleton
@UserModelSingletonQualifier
fun provideUserModel() = UserModel(value = "Singleton")
}
@Module
@InstallIn(ActivityComponent::class)
object ActivityViewModelModule {
@Provides
fun provideSavedStateViewModelFactory(
application: Application,
activity: Activity,
viewModelFactories: @JvmSuppressWildcards Map<String, Provider<ViewModelAssistedFactory<out ViewModel>>>,
): DFMSavedStateViewModelFactory {
class FeatureActivity : AppCompatActivity(R.layout.feature_activity) {
@Inject
@UserModelSingletonQualifier
lateinit var singletonUserModel: UserModel
@Inject
lateinit var savedStateViewModelFactory: DFMSavedStateViewModelFactory
private val featureActivityViewModel by viewModels<FeatureActivityViewModel> { savedStateViewModelFactory }
@hantrungkien
hantrungkien / chat_message.dart
Last active December 11, 2023 03:35
chat_message.dart
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override