Skip to content

Instantly share code, notes, and snippets.

View yccheok's full-sized avatar

Yan Cheng Cheok yccheok

View GitHub Profile
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/tabanim_maincontent"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- fitsSystemWindows??? -->
<android.support.design.widget.AppBarLayout
android:id="@+id/tabanim_appbar"
android:layout_width="match_parent"
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<FrameLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<!--
Whenever you change the margin in this layout, please update code in BuyArrayRecyclerViewAdapter
as well. We do have hard coded value in BuyArrayRecyclerViewAdapter.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/card_view"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="10dp"
@yccheok
yccheok / JStockPreferenceFragment.java
Last active April 23, 2016 04:32
A elegant preference, without too much dividers - http://i.imgur.com/pq3piNC.png
public class JStockPreferenceFragment extends PreferenceFragmentCompatFix implements SharedPreferences.OnSharedPreferenceChangeListener, PreferenceFragmentCompat.OnPreferenceDisplayDialogCallback {
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
this.setDivider(null);
this.setDividerHeight(0);
}
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
style="?attr/actionButtonStyle"
android:background="?attr/selectableItemBackground"
android:id="@+id/actionbar_done"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1">
<TextView style="?attr/actionBarTabTextStyle"
android:layout_width="wrap_content"
<Button
android:theme="@style/Shop.Button.Light"
android:id="@+id/buy_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="?attr/shopButtonTextColor"
style="?attr/buttonStyle"
android:stateListAnimator="@null"
android:textStyle="bold"
android:text="@string/shop_buy" />
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
<PreferenceCategoryFix
android:title="@string/preference_ui">
<CheckBoxPreference
android:title="@string/preference_touch_to_sort_title"
android:summary="@string/preference_touch_to_sort_summary"
android:key="TOUCH_TO_SORT"
android:defaultValue="true" />
<CheckBoxPreference
public static boolean saveToGoogleDrive(GoogleApiClient googleApiClient, File file, HandleStatusable h, PublishProgressable p) {
// Should we new or replace?
GoogleCloudFile googleCloudFile = searchFromGoogleDrive(googleApiClient, h, p);
try {
p.publishProgress(JStockApplication.instance().getString(R.string.uploading));
final long checksum = org.yccheok.jstock.gui.Utils.getChecksum(file);
final long date = new Date().getTime();
@yccheok
yccheok / rounded_background_bottom.xml
Created May 14, 2017 11:04
This is how we can customize the card's corners
<?xml version="1.0" encoding="utf-8"?>
<selector android:shape="rectangle"
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true">
<shape>
<corners android:topLeftRadius="0.0dip" android:topRightRadius="0.0dip" android:bottomLeftRadius="@dimen/cardview_default_radius" android:bottomRightRadius="@dimen/cardview_default_radius" />
<solid android:color="@color/pressed_black" />
</shape>
</item>
<item>
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginTop="16dp"
app:cardElevation="2dp"