Skip to content

Instantly share code, notes, and snippets.

View Reacoder's full-sized avatar

赵小龙_同学 Reacoder

  • shanghai china
View GitHub Profile
@Reacoder
Reacoder / TableLayout.xml
Created July 24, 2014 04:10
TableLayout
<TableLayout
android:id="@+id/mytubeplayer_user_info_table"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:stretchColumns="0,1" >
<TableRow>
<TextView
class PhotoDecodeRunnable implements Runnable {...    /*     * Defines the code to run for this task.     */    @Override    public void run() {        // Moves the current Thread into the background        android.os.Process.setThreadPriority(android.os.Process.THREAD_PRIORITY_BACKGROUND);        ...        /*         * Stores the current Thread in the PhotoTask instance,         * so that the instance         * can interrupt the Thread.         */        mPhotoTask.setImageDecodeThread(Thread.currentThread());        ...    }...}
@Reacoder
Reacoder / actionBarTitlePadding.xml
Created July 23, 2014 09:55
From http://stackoverflow.com/questions/9737101/padding-between-actionbars-home-icon-and-title EDIT: make sure you set this drawable as LOGO, not as your app icon like some of the commenters did. Just make an XML drawable and put it in the resource folder "drawable" (without any density or other configuration). The last step is to set this new d…
<?xml version="1.0" encoding="utf-8"?>
<layer-list
xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:drawable="@drawable/my_logo"
android:right="10dp"/>
</layer-list>
@Reacoder
Reacoder / itemActivated
Created July 23, 2014 08:12
list item 选中状态。
item_layout's background.
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/bg_music_list_item_selected" android:state_pressed="true"></item>
<item android:drawable="@drawable/bg_music_list_item_selected" android:state_selected="true"></item>
<item android:drawable="@drawable/bg_music_list_item_selected" android:state_activated="true"></item>
<item android:drawable="@drawable/bg_music_list_item_normal" ></item>
@Reacoder
Reacoder / FragmentInFragment.java
Created July 23, 2014 05:11
Add this in father fragment.
/**
* This seems to be a bug in the newly added support for nested fragments.
* Basically, the child FragmentManager ends up with a broken internal state
* when it is detached from the activity. A short-term workaround that fixed
* it for me is to add the following to onDetach() of every Fragment which
* you call getChildFragmentManager() on:
*/
@Override
public void onDetach() {
super.onDetach();
@Reacoder
Reacoder / isMain.java
Created July 23, 2014 03:56
判断是不是在主线程中。
static boolean isMain() {
return Looper.getMainLooper().getThread() == Thread.currentThread();
}
@Reacoder
Reacoder / regex.java
Created June 17, 2014 02:31
regex extract string.
public static String extractJsUrl(String originHtml) {
// <script src="//s.ytimg.com/yts/jsbin/html5player-zh_CN-vflHa9pzi.js"
// name="html5player"></script>
final String REGEX = "//s[.]ytimg[.]com/.*html5player.*[.]js";
Pattern p = Pattern.compile(REGEX);
Matcher m = p.matcher(originHtml);
String jsUrl = null;
if (m.find()) {
jsUrl = originHtml.substring(m.start(), m.end());
@Reacoder
Reacoder / softKeyBoard.java
Created June 11, 2014 07:22
hide soft key board.
InputMethodManager imm = (InputMethodManager) mActivity
.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(mSearchView.getWindowToken(), 0);
@Reacoder
Reacoder / divider.xml
Created June 11, 2014 04:20
listview divider margin left 60dp.
<?xml version="1.0" encoding="UTF-8"?>
<inset xmlns:android="http://schemas.android.com/apk/res/android"
android:insetLeft="60dp"
android:insetRight="8dp" >
<shape>
<solid android:color="#c0c0c0" />
</shape>
</inset>
@Reacoder
Reacoder / queryIntent.java
Created June 10, 2014 09:56
Check intent .
public static boolean isAvailable(Context ctx, Intent intent) {
final PackageManager mgr = ctx.getPackageManager();
List<ResolveInfo> list =
mgr.queryIntentActivities(intent,
PackageManager.MATCH_DEFAULT_ONLY);