Skip to content

Instantly share code, notes, and snippets.

@chrisjyoon
chrisjyoon / pcat-install.sh
Created October 3, 2018 02:19 — forked from BretFisher/pcat-install.sh
On macOS: Install pygmentize and alias pcat for shell code syntax highlighting
# first install pygmentize to the mac OS X or macOS system with the built-in python
sudo easy_install Pygments
# then add alias to your ~/.bash_profile or ~/.bashrc or ~/.zshrc etc.
alias pcat='pygmentize -f terminal256 -O style=native -g'
@chrisjyoon
chrisjyoon / gist:ffd7d3cc5bfee653ea42ed02283d38be
Last active May 1, 2016 13:40
make custom spinner with TextView
// make custom spinner (use icon image)
<TextView
android:id="@+id/spinner_first"
android:layout_width="0dp"
android:layout_height="36dp"
android:layout_weight="1"
style="?android:attr/spinnerItemStyle"
android:background="@drawable/spinner_back"
android:drawableRight="@drawable/icon_search_more"
android:drawableEnd="@drawable/icon_search_more"/>
@chrisjyoon
chrisjyoon / Some.java
Created April 18, 2016 09:45
android:retrofit2 logging
...
HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
logging.setLevel(HttpLoggingInterceptor.Level.BODY);
OkHttpClient client = new OkHttpClient
.Builder().addInterceptor(logging).build();
...
http://stackoverflow.com/questions/12128331/how-to-change-fontfamily-of-textview-in-android
android:fontFamily="sans-serif" // roboto regular
android:fontFamily="sans-serif-light" // roboto light
android:fontFamily="sans-serif-condensed" // roboto condensed
android:fontFamily="sans-serif-thin" // roboto thin (android 4.2)
android:fontFamily="sans-serif-medium" // roboto medium (android 5.0)
@chrisjyoon
chrisjyoon / (library)build.gradle
Created March 3, 2016 06:03
publish to bintray
// library build.gradle
apply plugin: 'com.android.library'
apply plugin: 'com.novoda.bintray-release'
publish {
userOrg = 'user'
groupId = 'package'
artifactId = 'artifactId'
publishVersion = '1.0'
desc = 'Description for library'
@chrisjyoon
chrisjyoon / gist:c2c751df4a365a9d2b65
Last active February 23, 2016 01:09
start activity with custom animation
// api >= 16
Intent i = SomeActivity.newIntent(CallerActivity.this, mMember);
Bundle bundle = ActivityOptions.makeCustomAnimation(CallerActivity.this,
R.anim.slide_in_right,
R.anim.slide_out_left).toBundle();
startActivity(i, bundle);
@chrisjyoon
chrisjyoon / gist:f31f7a799a85f7d7526c
Last active February 23, 2016 01:02
android: show currency by locale
NumberFormat.getCurrencyInstance(Locale.US).format(org);
NumberFormat.getCurrencyInstance(Locale.KOREA).format(org);
Locale locale = new Locale("ko", "KR");
NumberFormat.getCurrencyInstance(locale).format(org);
NumberFormat.getCurrencyInstance(Locale.getDefault()).format(org);
@chrisjyoon
chrisjyoon / SampleActivity.java
Created January 6, 2016 03:07
Customise Android Snackbar
Snackbar snackbar = Snackbar.make(findViewById(R.id.main_content), "TEST", Snackbar.LENGTH_INDEFINITE);
View snackbarView = snackbar.getView();
// change background color of snackbar
snackbarView.setBackgroundColor(ContextCompat.getColor(this, R.color.my_color));
// align text to right end and add image icon to left
TextView textView = (TextView)snackbarView.findViewById(android.support.design.R.id.snackbar_text);
textView.setTextSize(16);
textView.setGravity(Gravity.END | Gravity.CENTER_VERTICAL);
textView.setCompoundDrawablesWithIntrinsicBounds(R.drawable.icon_test, 0, 0, 0);
@chrisjyoon
chrisjyoon / gist:4b1bafdf58dcd210ed18
Created September 18, 2015 05:20
android:Custom Spinner Adapter
private class SpinnerAdapter extends ArrayAdapter<String> {
private Context mContext;
private int mResource;
private String[] mObjects;
public SpinnerAdapter(Context context, int resource, String[] objects) {
super(context, resource, objects);
mContext = context;
mResource = resource;
mObjects = objects;
@chrisjyoon
chrisjyoon / gist:a8e24bd6d98c1850285c
Created September 8, 2015 07:20
android: get version info
public String getVersion(Context context) {
try {
return context.getPackageManager()
.getPackageInfo(context.getPackageName(), 0).versionName;
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
return "";
}
}