View .gitignore
This file contains 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
# Created by https://www.gitignore.io/api/windows,linux,osx,intellij,android,gradle,java,eclipse,jetbrains | |
### Windows ### | |
# Windows image file caches | |
Thumbs.db | |
ehthumbs.db | |
# Folder config file | |
Desktop.ini |
View checkCameraHardware.java
This file contains 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
/** Check if this device has a camera */ | |
private boolean checkCameraHardware(Context context) { | |
if (context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA)){ | |
// this device has a camera | |
return true; | |
} else { | |
// no camera on this device | |
return false; | |
} | |
} |
View AndroidManifest.xml
This file contains 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
<?xml version="1.0" encoding="utf-8"?> | |
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | |
package="com.example.hungvu.testpack"> | |
<uses-permission android:name="ANDROID.PERMISSION.CAMERA" /> | |
<uses-permission android:name="ANDROID.PERMISSION.READ_EXTERNAL_STORAGE" /> | |
<uses-permission android:name="ANDROID.PERMISSION.WRITE_EXTERNAL_STORAGE" /> | |
<uses-feature | |
android:name="android.hardware.camera" |
View Sqlite Helper.java
This file contains 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
public class DatabaseHelper { | |
private Context context; | |
private SqliteHelper sqlite; | |
private String TB_NAME; | |
private String TB_STRUCT; | |
public DatabaseHelper(Context context, String DbName, String TB_NAME, String TB_STRUCT) { | |
this.context = context; | |
this.TB_NAME = TB_NAME; | |
this.TB_STRUCT = TB_STRUCT; |
View get language
This file contains 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
Locale.getDefault().getLanguage(); | |
// ja, vi, en... |
View Hide soft keyboard
This file contains 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
public static void hideSoftKeyboard(Activity activity) { | |
InputMethodManager inputMethodManager = (InputMethodManager) activity.getSystemService(Activity.INPUT_METHOD_SERVICE); | |
inputMethodManager.hideSoftInputFromWindow(activity.getCurrentFocus().getWindowToken(), 0); | |
} |
View Folder utils
This file contains 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
public static String formatSize(long bytes, int place) { | |
int level = 0; | |
float number = bytes; | |
String[] unit = { "bytes", "KB", "MB", "GB", "TB", "PB" }; | |
while (number >= 1024f) { | |
number /= 1024f; | |
level++; | |
} |
View Set default preference setting
This file contains 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
public static void setDefaultPreference(Context context,String share_Pref_Name) { | |
SharedPreferences getpref = context.getSharedPreferences(share_Pref_Name, Context.MODE_PRIVATE); | |
Map<String, ?> tempPreference = getpref.getAll(); | |
if(tempPreference.size() <= 0){ | |
// set default (fist time) | |
Editor edit = getpref.edit(); | |
edit.putString(context.getString(R.string.pref_key_cache_capacity), StaticVar.PREF_DEFAULT_CACHE); | |
edit.putString(context.getString(R.string.pref_key_cache_mode), StaticVar.PREF_DEFAULT_CACHE_MODE); | |
edit.putBoolean(context.getString(R.string.pref_key_notification), StaticVar.PREF_DEFAULT_NOTIFICATION); | |
edit.putString(context.getString(R.string.pref_key_orientation_mode), StaticVar.PREF_DEFAULT_ORIENTATION_MODE); |
View default timestamp
This file contains 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
$table->timestamp('created_at')->default(DB::raw('CURRENT_TIMESTAMP')); | |
$table->timestamp('updated_at')->default(DB::raw('CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP')); |
View TimeZone Converter
This file contains 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
date --date='TZ="Asia/Ho_Chi_Minh" 16:33' +'%d' // get day after convert | |
date --date='TZ="Asia/Ho_Chi_Minh" 16:33' +'%m' // get month | |
date --date='TZ="Asia/Ho_Chi_Minh" 16:33' +'%Y' // get year | |
date --date='TZ="Asia/Ho_Chi_Minh" 16:33' +'%H' // 24h format | |
date --date='TZ="Asia/Ho_Chi_Minh" 16:33' +'%M' // get minutes | |
date --date='TZ="Asia/Ho_Chi_Minh" 16:33' +'%S' // get second | |
date --date='TZ="Asia/Ho_Chi_Minh" 16:33' +'%u' // get day of week | |
date --date='TZ="Asia/Ho_Chi_Minh" 16:33' +'%U' // get week of year | |
date --date='TZ="Asia/Ho_Chi_Minh" 16:33' +'%Z' // alphabetic time zone |
OlderNewer