Skip to content

Instantly share code, notes, and snippets.

View samuel22gj's full-sized avatar
👨‍💻
Coding

Samuel Huang samuel22gj

👨‍💻
Coding
View GitHub Profile
@samuel22gj
samuel22gj / .gitignore
Last active September 27, 2017 06:14
for Android
# built application files
*.apk
*.ap_
# files for the dex VM
*.dex
# Java class files
*.class
@samuel22gj
samuel22gj / .travis.yml
Last active December 23, 2015 04:20
for Android
# Build Lifecycle
# before_install -> install -> before_script -> script
# -> after_success or after_failure -> after_script
language: android
sudo: false
jdk: oraclejdk8
env:
matrix:
@samuel22gj
samuel22gj / person.json
Last active September 11, 2015 07:36
A sample json file. https://goo.gl/X90Y9C
{
"firstName": "Samuel",
"lastName": "Huang",
"sex": "male",
"age": 26,
"birthday": 604116600000,
"alive": true,
"address": {
"streetAddress": "21 2nd Street",
"city": "New York",
@samuel22gj
samuel22gj / CustomView.java
Last active June 9, 2018 10:59
Android custom view template
public class CustomView extends View {
public CustomView(Context context) {
this(context, null);
}
public CustomView(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public CustomView(Context context, AttributeSet attrs, int defStyle) {
@samuel22gj
samuel22gj / MyBaseAdapter.java
Last active August 1, 2016 10:37
Android BaseAdapter tamplate
public class MyBaseAdapter extends BaseAdapter {
private static final String TAG = MyBaseAdapter.class.getSimpleName();
private Context mContext;
private LayoutInflater mInflater;
private List<FunctionItem> mItemList;
private int mSelectedItem = -1;
public HomeListAdapter(Context context, List<FunctionItem> itemList) {
@samuel22gj
samuel22gj / progress_horizontal.xml
Last active April 22, 2016 08:03
Android official progress_horizontal.xml (after code format). Find source code in https://android.googlesource.com/platform/frameworks/base/+/master/core/res/res/drawable
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2008 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
@samuel22gj
samuel22gj / sudo_alive.sh
Created March 4, 2016 09:12
Make sudo permission keep alive
#!/usr/bin/env bash
# Ask for the administrator password upfront.
sudo -v
# Keep-alive: update existing `sudo` time stamp until the script has finished.
while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null &
@samuel22gj
samuel22gj / SelectedRecyclerAdapter.java
Last active November 22, 2016 10:50
Selected RecyclerView Adapter
public class SelectedRecyclerAdapter extends RecyclerView.Adapter<SelectedRecyclerAdapter.ViewHolder>{
private static final String TAG = SelectedRecyclerAdapter.class.getSimpleName();
public interface OnItemClickListener {
void onItemClick(View v, int position);
}
private OnItemClickListener mListener;
private List<FunctionItem> mItemList;
@samuel22gj
samuel22gj / colors.xml
Last active December 28, 2016 03:28
Rainbow colors xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#3F51B5</color>
<color name="colorPrimaryDark">#303F9F</color>
<color name="colorAccent">#FF4081</color>
<color name="bright_pink">#FF007F</color>
<color name="red">#FF0000</color>
<color name="orange">#FF7F00</color>
<color name="yellow">#FFFF00</color>
public class MyRecyclerView extends RecyclerView {
private static final String TAG = MyRecyclerView.class.getSimpleName();
private int mMaxWidth = Integer.MAX_VALUE;
private int mMaxHeight = Integer.MAX_VALUE;
public MyRecyclerView(Context context) {
this(context, null);
}