Skip to content

Instantly share code, notes, and snippets.

View truongngoclinh's full-sized avatar
🎯
Focusing

Trương Ngọc Linh truongngoclinh

🎯
Focusing
  • Tokyo
View GitHub Profile
public class MyProgressDialog extends ProgressDialog {
private TextView mTvMessage;
private Context mContext;
public VedProgressDialog(Context context) {
super(context);
mContext = context;
setIndeterminate(true);
setCancelable(false);
final LinearLayout layout = (LinearLayout) findViewById(R.id.YOUR_VIEW_ID);
ViewTreeObserver vto = layout.getViewTreeObserver();
vto.addOnGlobalLayoutListener (new OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
layout.getViewTreeObserver().removeOnGlobalLayoutListener(this);
int width = layout.getMeasuredWidth();
int height = layout.getMeasuredHeight();
}
@truongngoclinh
truongngoclinh / git_submodules.md
Created April 26, 2017 13:15 — forked from gitaarik/git_submodules.md
Git Submodules basic explanation

Git Submodules basic explanation

Why submodules?

In Git you can add a submodule to a repository. This is basically a repository embedded in your main repository. This can be very useful. A couple of advantages of using submodules:

  • You can separate the code into different repositories.
@truongngoclinh
truongngoclinh / addSpacesBetweenChars.java
Created April 21, 2017 06:55
add space between chars
// add double spaces
public String addSpacesBetweenChar(String str) {
if (!str.contains("*")) {
str = "******" + str;
}
return str.replaceAll(".(?=.)", "$0 ");
}
# Built application files
*.apk
*.ap_
# Files for the ART/Dalvik VM
*.dex
# Java class files
*.class
@truongngoclinh
truongngoclinh / GsonDecodeListObject.java
Last active April 7, 2017 05:09
Passing list object through intent with gson.toJson and gson.fromJson
// passing to intent:
b.putSerializable(BUNDLE_PARAMS, new Gson().toJson(params));
// retrieving data:
List<KeyValueStringPair> params = new Gson().fromJson(b.getString(BUNDLE_PARAMS), new TypeToken<List<KeyValueStringPair>>(){}.getType())
// model class
public static class KeyValueStringPair implements Serializable {
@SerializedName("_key")
@truongngoclinh
truongngoclinh / learning_react_native.md
Created April 2, 2017 08:01 — forked from sibelius/learning.md
Learning Path React Native

Basics

  • Learn how to start a new react native project
  • Run it on ios simulator, on android emulator, on a real iPhone device and on a real Android device, with and without debugging enabled.
  • Learn how to upgrade a react native project
  • Learn how to add a package to the project
  • Learn how to add a package that has a native dependency (https://github.com/airbnb/react-native-maps, https://github.com/evollu/react-native-fcm) - DO NOT USE COCOAPODS
  • Learn how to use fetch to get data from your backend

Learn Navigation

@truongngoclinh
truongngoclinh / learning.md
Created April 2, 2017 08:01 — forked from sibelius/learning.md
Learning Path React Native

Basics

  • Learn how to start a new react native project
  • Run it on ios simulator, on android emulator, on a real iPhone device and on a real Android device, with and without debugging enabled.
  • Learn how to upgrade a react native project
  • Learn how to add a package to the project
  • Learn how to add a package that has a native dependency (https://github.com/airbnb/react-native-maps, https://github.com/evollu/react-native-fcm) - DO NOT USE COCOAPODS
  • Learn how to use fetch to get data from your backend

Learn Navigation

@truongngoclinh
truongngoclinh / GetUrlBitmap.java
Last active January 18, 2017 09:12
Get bitmap from url, scale down by set BitmapOptions.
private Bitmap getBitmapFromUrl(String src) {
if (!TextUtils.isEmpty(src)) {
try {
URL url = new URL(src);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setDoInput(true);
connection.connect();
InputStream inputStream = connection.getInputStream();
BitmapFactory.Options options = new BitmapFactory.Options();
View view = yourrecyclerview.findViewHolderForAdapterPosition(position);