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
@truongngoclinh
truongngoclinh / randomFunction.java
Last active December 25, 2015 10:47
Random value from 0 to MAX
/**
* Make an int random array with value from 0 to max
* @param size: size = max + 1
* @return result: an int array
*/
private int[] makeRandomArray(int size) {
int result[] = new int[size];
List<Integer> ascesdingArray = new ArrayList<>();
for (int i = 0; i < size; i++) {
ascesdingArray.add(i);
@truongngoclinh
truongngoclinh / FragmentAnimation.java
Last active September 7, 2016 07:29
Fragment transaction animation when replace, pop backstack
// put animation on anim folder
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
transaction.setCustomAnimations(R.anim.enter_to_left, R.anim.exit_left, R.anim.enter_to_right, R.anim.exit_right);
@truongngoclinh
truongngoclinh / WCLinearLayoutManager.java
Last active January 5, 2016 17:15
Wrap_content LinearLayoutManager for RecyclerView
import android.content.Context;
import android.graphics.Rect;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
/**
* from the question: http://stackoverflow.com/questions/26649406/nested-recycler-view-height-doesnt-wrap-its-content
*/
@truongngoclinh
truongngoclinh / UiAutomatorAutoTouch.java
Last active September 7, 2016 07:29
SMW auto touch
package com.samsung.android.tests.snote;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.text.DecimalFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
Hex Opacity Values
100% — FF
95% — F2
90% — E6
85% — D9
80% — CC
75% — BF
70% — B3
65% — A6
@truongngoclinh
truongngoclinh / AdjustUnknownLengthTexts.java
Last active February 15, 2016 05:11
The logic is prefer smaller one first then...
// divide two unknown length texts to fit fixed parent width
private void adjustEmployeeInfoLayoutWidth() {
int dp10 = PlandayUtils.dpToPx(getContext(), 10);
int dp15 = PlandayUtils.dpToPx(getContext(), 15);
int dp50 = PlandayUtils.dpToPx(getContext(), 50);
// civAvatar.width = 50dp + marginLeft = 15dp, nameMarginLeft = 10dp, roleMarginLeft = 15dp, roleMarginRight = 15dp
int parentWidth = PlandayUtils.getScreenSize(getContext())[0] - dp50 - 3 * dp15 - dp10;
int nameWidth = (int) tvEmployeeName.getPaint().measureText(tvEmployeeName.getText().toString());
int roleWidth = (int) tvRoleName.getPaint().measureText(tvRoleName.getText().toString());
for (int i = 568; i <= 647; i++) {
String fileName1 = "Image#" + i + ".jpg";
//String fileName2 = "image"+i+".jpg";
//File file1 = new File(PATH+"/"+fileName1);
//File file2 = new File(PATH+"/"+fileName2);
if (file1.exists()) {
file1.renameTo(file2);
}
Bitmap bitmap = BitmapFactory.decodeFile(PATH + File.separator + fileName1);
Bitmap resized = Bitmap.createBitmap(bitmap, 0, bitmap.getHeight() / 8 + 10, bitmap.getWidth(), bitmap.getHeight() / 2 - 3);
@truongngoclinh
truongngoclinh / CustomLogAndroid
Created May 20, 2016 09:28
Create custom log
public class TLog {
private static final int V = 0;
private static final int D = 1;
private static final int I = 2;
private static final int W = 3;
private static final int E = 4;
private static final String TAG = "CustomLog";
@truongngoclinh
truongngoclinh / pokemon_area_search_notify.java
Last active August 26, 2016 08:02
Searching pokemon around your work desk and get notifies by specific pokemons
import POGOProtos.Enums.PokemonIdOuterClass;
import com.pokegoapi.api.PokemonGo;
import com.pokegoapi.api.map.pokemon.CatchablePokemon;
import com.pokegoapi.api.map.pokemon.NearbyPokemon;
import com.pokegoapi.auth.GoogleUserCredentialProvider;
import com.pokegoapi.exceptions.LoginFailedException;
import com.pokegoapi.exceptions.RemoteServerException;
import okhttp3.OkHttpClient;
import java.io.IOException;
@truongngoclinh
truongngoclinh / iterm2-solarized.md
Created August 26, 2016 08:03 — forked from kevin-smets/iterm2-solarized.md
iTerm2 + Oh My Zsh + Solarized color scheme + Meslo powerline font (OS X / macOS)

Solarized