This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| Source: http://www.littlerobots.nl/blog/Handle-Android-RecyclerView-Clicks/ | |
| USAGE: | |
| ItemClickSupport.addTo(mRecyclerView).setOnItemClickListener(new ItemClickSupport.OnItemClickListener() { | |
| @Override | |
| public void onItemClicked(RecyclerView recyclerView, int position, View v) { | |
| // do it | |
| } | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import android.support.v7.widget.RecyclerView; | |
| public class RecyclerViewSwipeListener extends RecyclerView.OnFlingListener { | |
| private static final int SWIPE_THRESHOLD = 100; | |
| private static final int SWIPE_VELOCITY_THRESHOLD = 100; | |
| boolean mIsScrollingVertically; | |
| // change swipe listener depending on whether we are scanning items horizontally or vertically |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?xml version="1.0" encoding="utf-8"?> | |
| <resources> | |
| <color name="red_500_primary">#f44336</color> | |
| <color name="red_50">#ffebee</color> | |
| <color name="red_100">#ffcdd2</color> | |
| <color name="red_200">#ef9a9a</color> | |
| <color name="red_300">#e57373</color> | |
| <color name="red_400">#ef5350</color> | |
| <color name="red_600">#e53935</color> | |
| <color name="red_700">#d32f2f</color> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * Copyright 2014 Chris Banes | |
| * | |
| * 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * Copyright 2014 Chris Banes | |
| * | |
| * 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <selector xmlns:android="http://schemas.android.com/apk/res/android"> | |
| <item android:state_pressed="true" android:drawable="@drawable/btn_share_press"/> | |
| <item android:state_selected="true" android:drawable="@drawable/btn_share_press"/> | |
| <item android:state_focused="true" android:drawable="@drawable/btn_share_press"/> | |
| <item android:state_enabled="false" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Class<?> c = null; | |
| Object obj = null; | |
| Field field = null; | |
| int x = 0, sbar = 0; | |
| try { | |
| c = Class.forName("com.android.internal.R$dimen"); | |
| obj = c.newInstance(); | |
| field = c.getField("status_bar_height"); | |
| x = Integer.parseInt(field.get(obj).toString()); | |
| sbar = getResources().getDimensionPixelSize(x); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package IO; | |
| import java.io.*; | |
| public class FileDirectoryDemo { | |
| public static void main(String[] args) { | |
| // 如果没有指定参数,则缺省为当前目录。 | |
| if (args.length == 0) { | |
| args = new String[] { "." }; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| 主要数据有三张表:contacts, raw_contacts,data。 | |
| contacts:主要是raw_contacts的一个合并。 | |
| raw_contacts:是每条记录表示一条联系人。 | |
| data:最基本的表,其中包含所有联系人的数据。每条记录都有一个mime type代表该记录的类型。 | |
| */ | |
| ArrayList<ContentProviderOperation> ops = new ArrayList<ContentProviderOperation>(); | |
| ops.add(ContentProviderOperation.newInsert(ContactsContract.RawContacts.CONTENT_URI) | |
| .withValue(ContactsContract.RawContacts.ACCOUNT_TYPE, "com.android.exchange") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.test.android; | |
| import android.app.Activity; | |
| import android.os.Bundle; | |
| import android.util.Log; | |
| public class LogActivity extends Activity { | |
| private String extendClassName = null; |