Skip to content

Instantly share code, notes, and snippets.

@VAdaihiep
VAdaihiep / ImagePickerHelper.java
Last active June 17, 2016 10:59
Pick image or capture simplest way by custom 'com.kbeanie:image-chooser-library:1.5.8@aar'
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import com.kbeanie.imagechooser.api.ChooserType;
import com.kbeanie.imagechooser.api.ChosenImage;
import com.kbeanie.imagechooser.api.ChosenImages;
import com.kbeanie.imagechooser.api.ImageChooserListener;
import com.kbeanie.imagechooser.api.ImageChooserManager;
@VAdaihiep
VAdaihiep / MoneyFormatEditText.java
Created July 2, 2016 04:01
Format money. For an example: 10000 -> 10.000
public class MoneyFormatEditText extends EditText {
public MoneyFormatEditText(Context context) {
super(context);
setupTextWatcher();
}
public MoneyFormatEditText(Context context, AttributeSet attrs) {
super(context, attrs);
setupTextWatcher();
}
@VAdaihiep
VAdaihiep / Util.java
Created January 17, 2017 09:31
Copy Android Database to SDCard
final static String DATABASE_NAME = "your-database-name";
final static String FOLDER_EXTERNAL_DIRECTORY = Environment.getExternalStorageDirectory() + "/folder";
//______________________________________________________________________________________________
/**
* Call this method from any activity in your app (
* for example -> DatabaseUtil.copyDatabaseToExtStg(MainActivity.this);
* this method will copy the database of your application into SDCard folder "shanraisshan/MyDatabase.sqlite" (DATABASE_NAME)
*/
@VAdaihiep
VAdaihiep / image.php
Created April 20, 2018 08:14
PHP Controller view file or download file. Use to check permission before return file like attach file in topic forum, private message,etc. Avoid user public file url. Ex: To view image: localhost/image.php?mode=view. To download image: localhost/image.php?mode=download.
// Check permission,...
// View image or download
$filePath = '/data/.../demo-image.jpg';
$name = basename($filePath);
if($params['mode'] == 'view'){
header("Content-Type: " . mime_content_type($filePath));
header('Content-disposition: inline; filename="' . $name . '"');
} else {
header("Content-Type: application/octet-stream");