Skip to content

Instantly share code, notes, and snippets.

View huutho-dev's full-sized avatar

huutho.dev huutho-dev

  • Freedom Inc.
  • HaNoi
View GitHub Profile
@huutho-dev
huutho-dev / FileExt.kt
Last active June 19, 2018 16:35
Some func support develop android by kotlin
fun getAllFileWithExtension(dir: File, fileExtension: String): MutableList<String> {
val result = mutableListOf<String>()
val listFiles: Array<File>? = dir.listFiles()
listFiles?.takeIf { listFiles.isNotEmpty() }?.let {
listFiles.forEach {
when (it.isDirectory) {
@huutho-dev
huutho-dev / Configure-Kotlin-Project
Created February 21, 2018 04:40
nguyenhuutho/Configure-Kotlin-Project
https://github.com/Kotlin/anko
@huutho-dev
huutho-dev / menu.xml
Created February 6, 2018 02:27
Show icon in menu toolbar
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/action_settings"
android:icon="@drawable/ic_more_vert_black_24dp"
android:title="More"
app:showAsAction="always">
<menu>
/**
* https://stackoverflow.com/questions/15128204/how-to-get-the-size-of-bitmap-after-displaying-it-in-imageview
*/
public int[] getSizeDrawable() {
Rect bounds = getDrawable().getBounds();
int width = bounds.width();
int height = bounds.height();
int bitmapWidth = getDrawable().getIntrinsicWidth(); //this is the bitmap's width
int bitmapHeight = getDrawable().getIntrinsicHeight(); //this is the bitmap's height
return new int[]{bitmapWidth, bitmapHeight};
@huutho-dev
huutho-dev / Lib
Last active February 21, 2018 14:07
https://github.com/Polarrco/PolarrPhotoEditorAndroidSDK
https://github.com/imgly/pesdk-android-demo
if (isExternalStorageWritable()) {
Log.e("ThoNH","isExternalStorageWritable")
val appDirectory = File("${Environment.getExternalStorageDirectory()}/MyPersonalAppFolder")
val logDirectory = File("$appDirectory/log")
val logFile = File(logDirectory, "logcat" + System.currentTimeMillis() + ".txt")
// create app folder
if (!appDirectory.exists()) {
appDirectory.mkdir()
}
@huutho-dev
huutho-dev / Permission.kt
Created January 5, 2018 01:33
Demo RunTime Permission Android 6.0
/**
Reference:
1.https://guides.codepath.com/android/Understanding-App-Permissions
2.https://guides.codepath.com/android/Managing-Runtime-Permissions-with-PermissionsDispatcher
3.https://gist.github.com/dlew/2a21b06ee8715e0f7338
*/
@huutho-dev
huutho-dev / colors.xml
Created January 3, 2018 02:11
Default value common color
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#001921</color>
<color name="colorPrimaryDark">#00151b</color>
<color name="colorAccent">#e54c4c</color>
<!--// LightBackground-->
<color name="colorTextDarkPrimary">#de000000</color>
<color name="colorTextDarkSecondary">#8a000000</color>
<color name="colorTextDarkHint">#61000000</color>
@huutho-dev
huutho-dev / dimens.xml
Last active January 24, 2018 08:45
Dimens multi screen for Android
<!-- values-mdpi -->
<?xml version="1.0" encoding="utf-8"?>
<resources>
<dimen name="divider_height">1px</dimen>
<dimen name="_1dp">1px</dimen>
<dimen name="_4dp">4px</dimen>
<dimen name="_8dp">8px</dimen>
<dimen name="_16dp">16px</dimen>
<dimen name="_24dp">24px</dimen>
<dimen name="_32dp">32px</dimen>
@huutho-dev
huutho-dev / NavigationDrawer.kt
Last active January 3, 2018 02:14
- Create Navigation Drawer Left
public override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
setSupportActionBar(mToolbar)
supportActionBar?.setDisplayHomeAsUpEnabled(true)
supportActionBar?.setDisplayShowHomeEnabled(true)
supportActionBar?.setHomeButtonEnabled(true)