├── app
├── .gitignore
├── src
│ ├── main
│ │ ├── res
│ │ │ ├── mipmap-hdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-mdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── values
│ │ │ │ ├── dimens.xml
│ │ │ │ ├── colors.xml
│ │ │ │ ├── themes.xml
│ │ │ │ ├── styles.xml
│ │ │ │ ├── arrays.xml
│ │ │ │ └── strings.xml
│ │ │ ├── drawable
│ │ │ │ ├── bg_main_text.xml
│ │ │ │ ├── list_divider.xml
│ │ │ │ ├── bg_main_text_pressed.xml
│ │ │ │ ├── selector_rect_item.xml
│ │ │ │ └── selector_round_item.xml
│ │ │ ├── layout
│ │ │ │ ├── activity_container.xml
│ │ │ │ ├── activity_recyclerview.xml
│ │ │ │ ├── activity_toolbar.xml
│ │ │ │ ├── list_item_rect.xml
│ │ │ │ ├── list_item_round.xml
│ │ │ │ ├── activity_main.xml
│ │ │ │ ├── base_recyclerview.xml
│ │ │ │ ├── fragment_decoration.xml
│ │ │ │ ├── list_item_right.xml
│ │ │ │ ├── list_item_left.xml
│ │ │ │ └── activity_blendent.xml
│ │ │ ├── menu
│ │ │ │ ├── menu_main.xml
│ │ │ │ ├── menu_toolbar.xml
│ │ │ │ ├── menu_blendent.xml
│ │ │ │ ├── menu_multilayout.xml
│ │ │ │ └── menu_animated.xml
│ │ │ └── values-v21
│ │ │ │ ├── styles.xml
│ │ │ │ └── themes.xml
│ │ ├── java
│ │ │ └── me
│ │ │ │ └── willclub
│ │ │ │ └── learnmaterialdesign
│ │ │ │ ├── utils
│ │ │ │ ├── ArrayUtil.java
│ │ │ │ ├── TextUtil.java
│ │ │ │ ├── CollectionUtil.java
│ │ │ │ ├── DrawableUtil.java
│ │ │ │ ├── Constant.java
│ │ │ │ ├── ToastUtil.java
│ │ │ │ └── Trace.java
│ │ │ │ ├── activities
│ │ │ │ ├── BaseActivity.java
│ │ │ │ ├── RecyclerViewActivity.java
│ │ │ │ ├── BlendentActivity.java
│ │ │ │ ├── RecyclerViewListActivity.java
│ │ │ │ ├── MainActivity.java
│ │ │ │ ├── ToolBarActivity.java
│ │ │ │ ├── RecyclerViewDetailActivity.java
│ │ │ │ └── BaseListActivity.java
│ │ │ │ ├── fragments
│ │ │ │ ├── RecyclerViewFragment.java
│ │ │ │ ├── BaseFragment.java
│ │ │ │ ├── RVDecorationFragment.java
│ │ │ │ ├── RVMultiTypeFragment.java
│ │ │ │ └── RVCommonFragment.java
│ │ │ │ ├── Trace.java
│ │ │ │ └── decorations
│ │ │ │ └── DividerItemDecoration.java
│ │ └── AndroidManifest.xml
│ └── androidTest
│ │ └── java
│ │ └── me
│ │ └── willclub
│ │ └── learnmaterialdesign
│ │ └── ApplicationTest.java
├── proguard-rules.pro
├── build.gradle
└── app.iml
├── .idea
├── .name
├── copyright
│ └── profiles_settings.xml
├── vcs.xml
├── inspectionProfiles
│ ├── profiles_settings.xml
│ └── Project_Default.xml
├── modules.xml
├── gradle.xml
├── compiler.xml
└── misc.xml
├── settings.gradle
├── .gitignore
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── README.md
├── gradle.properties
├── LearnMaterialDesign.iml
├── gradlew.bat
└── gradlew
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/.idea/.name:
--------------------------------------------------------------------------------
1 | LearnMaterialDesign
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------
/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .gradle
2 | /local.properties
3 | /.idea/workspace.xml
4 | /.idea/libraries
5 | .DS_Store
6 | /build
7 | /captures
8 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/willmo1987/LearnMaterialDesign/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/willmo1987/LearnMaterialDesign/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/willmo1987/LearnMaterialDesign/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/willmo1987/LearnMaterialDesign/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/willmo1987/LearnMaterialDesign/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # LearnMaterialDesign
2 |
3 | A full demo for learning Material Design. Updating...
4 |
5 | Content includes:
6 |
7 | 1. ToolBar
8 |
9 | 2. Blendent (theme configuration)
10 |
11 | 3. RecyclerView
12 |
13 | 4. CardView
14 |
15 | 5. Animation
16 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/bg_main_text.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_container.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Wed Apr 10 15:27:10 PDT 2013
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip
7 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/list_divider.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/inspectionProfiles/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/bg_main_text_pressed.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/selector_rect_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_recyclerview.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/selector_round_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/menu_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_toolbar.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/java/me/willclub/learnmaterialdesign/utils/ArrayUtil.java:
--------------------------------------------------------------------------------
1 | package me.willclub.learnmaterialdesign.utils;
2 |
3 | /**
4 | * Created by will on 4/15/15.
5 | */
6 | public class ArrayUtil {
7 |
8 | public static boolean isValid(T[] array) {
9 | if (array == null || array.length == 0) {
10 | return false;
11 | }
12 | return true;
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/app/src/main/java/me/willclub/learnmaterialdesign/utils/TextUtil.java:
--------------------------------------------------------------------------------
1 | package me.willclub.learnmaterialdesign.utils;
2 |
3 | /**
4 | * Created by will on 4/10/15.
5 | */
6 | public class TextUtil {
7 |
8 | public static boolean isValid(CharSequence str) {
9 | if (str != null && str.length() > 0) {
10 | return true;
11 | }
12 | return false;
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/menu_toolbar.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/java/me/willclub/learnmaterialdesign/utils/CollectionUtil.java:
--------------------------------------------------------------------------------
1 | package me.willclub.learnmaterialdesign.utils;
2 |
3 | import java.util.Collection;
4 |
5 | /**
6 | * Created by will on 4/10/15.
7 | */
8 | public class CollectionUtil {
9 |
10 | public static boolean isValid(Collection collection) {
11 | if (collection != null && collection.size() > 0) {
12 | return true;
13 | }
14 | return false;
15 | }
16 |
17 | }
18 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/me/willclub/learnmaterialdesign/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package me.willclub.learnmaterialdesign;
2 |
3 | import android.app.Application;
4 | import android.test.ApplicationTestCase;
5 |
6 | /**
7 | * Testing Fundamentals
8 | */
9 | public class ApplicationTest extends ApplicationTestCase {
10 | public ApplicationTest() {
11 | super(Application.class);
12 | }
13 | }
--------------------------------------------------------------------------------
/app/src/main/res/layout/list_item_rect.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/list_item_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/res/values-v21/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
8 |
9 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/app/src/main/res/values-v21/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
12 |
13 |
--------------------------------------------------------------------------------
/app/src/main/java/me/willclub/learnmaterialdesign/utils/DrawableUtil.java:
--------------------------------------------------------------------------------
1 | package me.willclub.learnmaterialdesign.utils;
2 |
3 | import android.content.Context;
4 | import android.graphics.drawable.Drawable;
5 |
6 | /**
7 | * Created by will on 4/23/15.
8 | */
9 | public class DrawableUtil {
10 |
11 | public static Drawable getDrawable(Context mContext, int resId) {
12 | if (resId < 0) {
13 | return null;
14 | }
15 | return mContext.getResources().getDrawable(resId, null);
16 | }
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
9 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/base_recyclerview.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
9 |
13 |
--------------------------------------------------------------------------------
/app/src/main/java/me/willclub/learnmaterialdesign/activities/BaseActivity.java:
--------------------------------------------------------------------------------
1 | package me.willclub.learnmaterialdesign.activities;
2 |
3 | import android.support.v7.app.ActionBarActivity;
4 | import android.view.MenuItem;
5 |
6 | /**
7 | * Created by will on 4/16/15.
8 | */
9 | public abstract class BaseActivity extends ActionBarActivity {
10 |
11 | @Override
12 | public boolean onOptionsItemSelected(MenuItem item) {
13 | if (item.getItemId() == android.R.id.home) {
14 | finish();
15 | }
16 | return super.onOptionsItemSelected(item);
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_decoration.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
9 |
14 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/menu_blendent.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
17 |
18 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/menu_multilayout.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/java/me/willclub/learnmaterialdesign/activities/RecyclerViewActivity.java:
--------------------------------------------------------------------------------
1 | package me.willclub.learnmaterialdesign.activities;
2 |
3 | import android.os.Bundle;
4 | import android.view.ViewGroup;
5 |
6 | import me.willclub.learnmaterialdesign.R;
7 |
8 | /**
9 | * Created by will on 4/16/15.
10 | */
11 | public class RecyclerViewActivity extends BaseActivity {
12 |
13 | private ViewGroup containerView;
14 |
15 | @Override
16 | protected void onCreate(Bundle savedInstanceState) {
17 | super.onCreate(savedInstanceState);
18 | setContentView(R.layout.activity_recyclerview);
19 | containerView = (ViewGroup) findViewById(R.id.container);
20 | }
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/app/src/main/java/me/willclub/learnmaterialdesign/utils/Constant.java:
--------------------------------------------------------------------------------
1 | package me.willclub.learnmaterialdesign.utils;
2 |
3 | /**
4 | * Created by will on 4/16/15.
5 | */
6 | public class Constant {
7 |
8 | /**
9 | * Intent keys
10 | */
11 | public static final String INTENT_KEY_INITIAL_VALUE = "intent_key_initial_value";
12 |
13 | /**
14 | * Bundle keys
15 | */
16 | public static final String BUNDLE_KEY_ANIMATED = "bundle_key_animated";
17 |
18 | /**
19 | * Type constants
20 | */
21 | public static final int RV_MULTITYPE = 0;
22 | public static final int RV_MULTILAYOUT = 1;
23 | public static final int RV_ANIMATION = 2;
24 | public static final int RV_DECORATOR = 3;
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/list_item_right.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
13 |
17 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/list_item_left.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
9 |
18 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/mowei/Documents/Software/adt-bundle-mac-x86_64-20140321/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/app/src/main/java/me/willclub/learnmaterialdesign/fragments/RecyclerViewFragment.java:
--------------------------------------------------------------------------------
1 | package me.willclub.learnmaterialdesign.fragments;
2 |
3 | import android.os.Bundle;
4 | import android.view.LayoutInflater;
5 | import android.view.View;
6 | import android.view.ViewGroup;
7 |
8 | /**
9 | * Created by will on 4/16/15.
10 | */
11 | public class RecyclerViewFragment extends BaseFragment {
12 |
13 | @Override
14 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
15 | return super.onCreateView(inflater, container, savedInstanceState);
16 | }
17 |
18 | @Override
19 | public void onActivityCreated(Bundle savedInstanceState) {
20 | super.onActivityCreated(savedInstanceState);
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/.idea/inspectionProfiles/Project_Default.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14 |
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 22
5 | buildToolsVersion "22.0.1"
6 |
7 | defaultConfig {
8 | applicationId "me.willclub.learnmaterialdesign"
9 | minSdkVersion 14
10 | targetSdkVersion 22
11 | versionCode 1
12 | versionName "1.0"
13 | }
14 | buildTypes {
15 | debug {
16 | buildConfigField "boolean", "LOG_ENABLED", "true"
17 | }
18 | release {
19 | buildConfigField "boolean", "LOG_ENABLED", "false"
20 | minifyEnabled false
21 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
22 | }
23 | }
24 | }
25 |
26 | dependencies {
27 | compile fileTree(dir: 'libs', include: ['*.jar'])
28 | compile 'com.android.support:appcompat-v7:22.0.0'
29 | compile 'com.android.support:recyclerview-v7:22.0.0'
30 | }
31 |
--------------------------------------------------------------------------------
/LearnMaterialDesign.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/app/src/main/java/me/willclub/learnmaterialdesign/activities/BlendentActivity.java:
--------------------------------------------------------------------------------
1 | package me.willclub.learnmaterialdesign.activities;
2 |
3 | import android.os.Bundle;
4 | import android.support.v7.widget.Toolbar;
5 | import android.view.Menu;
6 |
7 | import me.willclub.learnmaterialdesign.R;
8 |
9 | /**
10 | * Created by will on 4/17/15.
11 | */
12 | public class BlendentActivity extends BaseActivity {
13 |
14 | private Toolbar toolbar;
15 |
16 | @Override
17 | protected void onCreate(Bundle savedInstanceState) {
18 | super.onCreate(savedInstanceState);
19 | setContentView(R.layout.activity_blendent);
20 | toolbar = (Toolbar) findViewById(R.id.toolbar);
21 | setSupportActionBar(toolbar);
22 | getSupportActionBar().setDisplayHomeAsUpEnabled(true);
23 | }
24 |
25 | @Override
26 | public boolean onCreateOptionsMenu(Menu menu) {
27 | getMenuInflater().inflate(R.menu.menu_blendent, menu);
28 | return super.onCreateOptionsMenu(menu);
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/app/src/main/java/me/willclub/learnmaterialdesign/activities/RecyclerViewListActivity.java:
--------------------------------------------------------------------------------
1 | package me.willclub.learnmaterialdesign.activities;
2 |
3 | import android.content.Intent;
4 | import android.os.Bundle;
5 |
6 | import me.willclub.learnmaterialdesign.R;
7 | import me.willclub.learnmaterialdesign.utils.Constant;
8 |
9 | /**
10 | * Created by will on 4/16/15.
11 | */
12 | public class RecyclerViewListActivity extends BaseListActivity {
13 |
14 | @Override
15 | protected int contentArrayRes() {
16 | return R.array.optionRecyclerViewArray;
17 | }
18 |
19 | @Override
20 | protected void onCreate(Bundle savedInstanceState) {
21 | super.onCreate(savedInstanceState);
22 | enableHomeAsUp();
23 | }
24 |
25 | @Override
26 | protected void onItemClick(String content, int position) {
27 | Intent intent = new Intent(this, RecyclerViewDetailActivity.class);
28 | intent.putExtra(Constant.INTENT_KEY_INITIAL_VALUE, position);
29 | startActivity(intent);
30 | }
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #FFFFFFFF
4 | #FF919195
5 | #FFC9C9C9
6 | #FF293035
7 | #FFFFFFFF
8 |
9 |
10 | #FF0288D1
11 | #FF03A9F4
12 | #FFFFFFFF
13 | #FFFF4081
14 | #FFF8BBD0
15 | #FF7C4DFF
16 | #FFC2185B
17 |
18 |
19 | #FF212121
20 |
21 |
22 | #1F000000
23 | #FF1A98DD
24 | #FFFF5F3F
25 |
26 |
27 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/menu_animated.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/java/me/willclub/learnmaterialdesign/Trace.java:
--------------------------------------------------------------------------------
1 | package me.willclub.learnmaterialdesign;
2 |
3 | import android.util.Log;
4 |
5 | /**
6 | * Created by will on 4/10/15.
7 | */
8 | public class Trace {
9 |
10 | private static final String TAG = "toolbarTag";
11 |
12 | public static void e(String msg) {
13 | if (BuildConfig.LOG_ENABLED) {
14 | Log.e(TAG, msg);
15 | }
16 | }
17 |
18 | public static void d(String msg) {
19 | if (BuildConfig.LOG_ENABLED) {
20 | Log.d(TAG, msg);
21 | }
22 | }
23 |
24 | public static void w(String msg) {
25 | if (BuildConfig.LOG_ENABLED) {
26 | Log.w(TAG, msg);
27 | }
28 | }
29 |
30 | public static void i(String msg) {
31 | if (BuildConfig.LOG_ENABLED) {
32 | Log.i(TAG, msg);
33 | }
34 | }
35 |
36 | public static void v(String msg) {
37 | if (BuildConfig.LOG_ENABLED) {
38 | Log.v(TAG, msg);
39 | }
40 | }
41 |
42 | public static void logEception(Exception e) {
43 | if (BuildConfig.LOG_ENABLED) {
44 | e.printStackTrace();
45 | Log.e(TAG, e.getMessage());
46 | }
47 | }
48 |
49 | public static void logCurrentThread(String fromWhere) {
50 | if (BuildConfig.LOG_ENABLED) {
51 | Log.d(TAG, fromWhere + " is in thread " + Thread.currentThread().toString());
52 | }
53 | }
54 |
55 | }
56 |
--------------------------------------------------------------------------------
/app/src/main/res/values/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
16 |
17 |
19 |
20 |
29 |
30 |
33 |
34 |
--------------------------------------------------------------------------------
/app/src/main/java/me/willclub/learnmaterialdesign/utils/ToastUtil.java:
--------------------------------------------------------------------------------
1 | package me.willclub.learnmaterialdesign.utils;
2 |
3 | import android.content.Context;
4 | import android.view.Gravity;
5 | import android.widget.Toast;
6 |
7 | /**
8 | * Created by will on 4/10/15.
9 | */
10 | public class ToastUtil {
11 |
12 | private static Toast toast;
13 |
14 | public static void showToast(Context mContext, int message) {
15 | if (toast != null) {
16 | toast.cancel();
17 | }
18 | toast = Toast.makeText(mContext, message, Toast.LENGTH_SHORT);
19 | toast.show();
20 | }
21 |
22 | public static void showToast(Context mContext, String message) {
23 | if (toast != null) {
24 | toast.cancel();
25 | }
26 | toast = Toast.makeText(mContext, message, Toast.LENGTH_SHORT);
27 | toast.show();
28 | }
29 |
30 | public static void showToastCenter(Context mContext, int message) {
31 | if (toast != null) {
32 | toast.cancel();
33 | }
34 | toast = Toast.makeText(mContext, message, Toast.LENGTH_SHORT);
35 | toast.setGravity(Gravity.CENTER, 0, 0);
36 | toast.show();
37 | }
38 |
39 | public static void showToastCenter(Context mContext, String message) {
40 | if (toast != null) {
41 | toast.cancel();
42 | }
43 | toast = Toast.makeText(mContext, message, Toast.LENGTH_SHORT);
44 | toast.setGravity(Gravity.CENTER, 0, 0);
45 | toast.show();
46 | }
47 |
48 | }
49 |
--------------------------------------------------------------------------------
/app/src/main/java/me/willclub/learnmaterialdesign/utils/Trace.java:
--------------------------------------------------------------------------------
1 | package me.willclub.learnmaterialdesign.utils;
2 |
3 | import android.util.Log;
4 |
5 | import me.willclub.learnmaterialdesign.BuildConfig;
6 |
7 |
8 | /**
9 | * Created by will on 4/10/15.
10 | */
11 | public class Trace {
12 |
13 | private static final String TAG = "eWashTag";
14 |
15 | public static void e(String msg) {
16 | if (BuildConfig.LOG_ENABLED) {
17 | Log.e(TAG, msg);
18 | }
19 | }
20 |
21 | public static void d(String msg) {
22 | if (BuildConfig.LOG_ENABLED) {
23 | Log.d(TAG, msg);
24 | }
25 | }
26 |
27 | public static void w(String msg) {
28 | if (BuildConfig.LOG_ENABLED) {
29 | Log.w(TAG, msg);
30 | }
31 | }
32 |
33 | public static void i(String msg) {
34 | if (BuildConfig.LOG_ENABLED) {
35 | Log.i(TAG, msg);
36 | }
37 | }
38 |
39 | public static void v(String msg) {
40 | if (BuildConfig.LOG_ENABLED) {
41 | Log.v(TAG, msg);
42 | }
43 | }
44 |
45 | public static void logException(Exception e) {
46 | if (BuildConfig.LOG_ENABLED) {
47 | e.printStackTrace();
48 | Log.e(TAG, e.getMessage());
49 | }
50 | }
51 |
52 | public static void logCurrentThread(String fromWhere) {
53 | if (BuildConfig.LOG_ENABLED) {
54 | Log.d(TAG, fromWhere + " is in thread " +
55 | Thread.currentThread().getName() + " " + Thread.currentThread().getId());
56 | }
57 | }
58 |
59 | }
60 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
10 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
24 |
28 |
32 |
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
10 |
11 |
17 |
18 |
22 |
23 |
29 |
30 |
37 |
38 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/app/src/main/java/me/willclub/learnmaterialdesign/activities/MainActivity.java:
--------------------------------------------------------------------------------
1 | package me.willclub.learnmaterialdesign.activities;
2 |
3 | import android.content.Intent;
4 |
5 | import me.willclub.learnmaterialdesign.R;
6 | import me.willclub.learnmaterialdesign.utils.ToastUtil;
7 |
8 | /**
9 | * Created by will on 4/12/15.
10 | */
11 | public class MainActivity extends BaseListActivity {
12 |
13 | private static final int POS_TOOLBAR = 0;
14 | private static final int POS_BLENDENT = 1;
15 | private static final int POS_RECYCLER_VIEW = 2;
16 | private static final int POS_CARD_VIEW = 3;
17 | private static final int POS_ANIMATION = 4;
18 | private static final int POS_GRID_LAYOUT = 5;
19 |
20 | @Override
21 | protected int contentArrayRes() {
22 | return R.array.contentArray;
23 | }
24 |
25 | @Override
26 | protected void onItemClick(String content, int position) {
27 | Intent intent = null;
28 | switch (position) {
29 | case POS_TOOLBAR:
30 | intent = new Intent(this, ToolBarActivity.class);
31 | break;
32 | case POS_BLENDENT:
33 | intent = new Intent(this, BlendentActivity.class);
34 | break;
35 | case POS_RECYCLER_VIEW:
36 | intent = new Intent(this, RecyclerViewListActivity.class);
37 | break;
38 | case POS_CARD_VIEW:
39 | break;
40 | case POS_ANIMATION:
41 | break;
42 | case POS_GRID_LAYOUT:
43 | break;
44 | }
45 | if (intent != null) {
46 | startActivity(intent);
47 | }
48 | else {
49 | ToastUtil.showToast(this, R.string.coming_soon);
50 | }
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/app/src/main/java/me/willclub/learnmaterialdesign/fragments/BaseFragment.java:
--------------------------------------------------------------------------------
1 | package me.willclub.learnmaterialdesign.fragments;
2 |
3 | import android.os.Bundle;
4 | import android.support.v4.app.Fragment;
5 | import android.support.v7.app.ActionBarActivity;
6 | import android.support.v7.widget.Toolbar;
7 | import android.view.MenuItem;
8 |
9 | /**
10 | * Created by will on 4/16/15.
11 | */
12 | public abstract class BaseFragment extends Fragment {
13 |
14 | protected ActionBarActivity getActionBarActivity() {
15 | return (ActionBarActivity) getActivity();
16 | }
17 |
18 | protected boolean hasActionBar() {
19 | return false;
20 | }
21 |
22 | @Override
23 | public void onCreate(Bundle savedInstanceState) {
24 | super.onCreate(savedInstanceState);
25 | setHasOptionsMenu(hasActionBar());
26 | }
27 |
28 | @Override
29 | public boolean onOptionsItemSelected(MenuItem item) {
30 | if (item.getItemId() == android.R.id.home) {
31 | getActivity().finish();
32 | return true;
33 | }
34 | return super.onOptionsItemSelected(item);
35 | }
36 |
37 | protected void setupActionBar(Toolbar toolbar) {
38 | getActionBarActivity().setSupportActionBar(toolbar);
39 | }
40 |
41 | protected void setActionBarTitle(int titleRes) {
42 | getActionBarActivity().getSupportActionBar().setTitle(titleRes);
43 | }
44 |
45 | protected void enableHomeAsUp() {
46 | enableHomeAsUp(-1);
47 | }
48 |
49 | protected void enableHomeAsUp(int indicator) {
50 | getActionBarActivity().getSupportActionBar().setDisplayHomeAsUpEnabled(true);
51 | if (indicator > 0) {
52 | getActionBarActivity().getSupportActionBar().setHomeAsUpIndicator(indicator);
53 | }
54 | }
55 |
56 | }
57 |
--------------------------------------------------------------------------------
/app/src/main/java/me/willclub/learnmaterialdesign/activities/ToolBarActivity.java:
--------------------------------------------------------------------------------
1 | package me.willclub.learnmaterialdesign.activities;
2 |
3 | import android.os.Bundle;
4 | import android.support.v7.widget.Toolbar;
5 | import android.view.Menu;
6 | import android.view.MenuItem;
7 |
8 | import me.willclub.learnmaterialdesign.R;
9 |
10 | /**
11 | * Created by will on 4/16/15.
12 | */
13 | public class ToolBarActivity extends BaseActivity {
14 |
15 | private Toolbar toolbar;
16 |
17 | @Override
18 | protected void onCreate(Bundle savedInstanceState) {
19 | super.onCreate(savedInstanceState);
20 | setContentView(R.layout.activity_toolbar);
21 | toolbar = (Toolbar) findViewById(R.id.toolbar);
22 | // setupToolBar();
23 | setupActionBar();
24 | }
25 |
26 | private void setupToolBar() {
27 | toolbar.setTitle("Title");
28 | toolbar.setSubtitle("Subtitle");
29 | //navigationBarIcon = homeAsUpIndicator in ActionBar
30 | toolbar.setNavigationIcon(R.mipmap.ic_launcher);
31 | toolbar.inflateMenu(R.menu.menu_toolbar);
32 | toolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
33 |
34 | @Override
35 | public boolean onMenuItemClick(MenuItem menuItem) {
36 | if (menuItem.getItemId() == android.R.id.home) {
37 | finish();
38 | }
39 | return false;
40 | }
41 |
42 | });
43 | }
44 |
45 | private void setupActionBar() {
46 | setSupportActionBar(toolbar);
47 | getSupportActionBar().setTitle("ActionBar title");
48 | getSupportActionBar().setSubtitle("ActionBar subtitle");
49 | //default homeAsUpIndicator is an arrow heading to left
50 | getSupportActionBar().setDisplayHomeAsUpEnabled(true);
51 | }
52 |
53 | @Override
54 | public boolean onCreateOptionsMenu(Menu menu) {
55 | getMenuInflater().inflate(R.menu.menu_toolbar, menu);
56 | return super.onCreateOptionsMenu(menu);
57 | }
58 |
59 | }
60 |
--------------------------------------------------------------------------------
/app/src/main/java/me/willclub/learnmaterialdesign/activities/RecyclerViewDetailActivity.java:
--------------------------------------------------------------------------------
1 | package me.willclub.learnmaterialdesign.activities;
2 |
3 | import android.os.Bundle;
4 | import android.support.v4.app.FragmentTransaction;
5 |
6 | import me.willclub.learnmaterialdesign.R;
7 | import me.willclub.learnmaterialdesign.fragments.BaseFragment;
8 | import me.willclub.learnmaterialdesign.fragments.RVCommonFragment;
9 | import me.willclub.learnmaterialdesign.fragments.RVDecorationFragment;
10 | import me.willclub.learnmaterialdesign.fragments.RVMultiTypeFragment;
11 | import me.willclub.learnmaterialdesign.utils.Constant;
12 |
13 | /**
14 | * Created by will on 4/16/15.
15 | */
16 | public class RecyclerViewDetailActivity extends BaseActivity {
17 |
18 | @Override
19 | protected void onCreate(Bundle savedInstanceState) {
20 | super.onCreate(savedInstanceState);
21 | setContentView(R.layout.activity_container);
22 | int type = getIntent().getIntExtra(Constant.INTENT_KEY_INITIAL_VALUE, -1);
23 | if (type < 0) {
24 | finish();
25 | }
26 | handleType(type);
27 | }
28 |
29 | private void handleType(int type) {
30 | BaseFragment fragment = null;
31 | Bundle bundle = new Bundle();
32 | switch (type) {
33 | case Constant.RV_MULTITYPE:
34 | fragment = new RVMultiTypeFragment();
35 | break;
36 | case Constant.RV_MULTILAYOUT:
37 | fragment = new RVCommonFragment();
38 | break;
39 | case Constant.RV_ANIMATION:
40 | fragment = new RVCommonFragment();
41 | bundle.putBoolean(Constant.BUNDLE_KEY_ANIMATED, true);
42 | break;
43 | case Constant.RV_DECORATOR:
44 | fragment = new RVDecorationFragment();
45 | break;
46 | }
47 | if (fragment != null) {
48 | fragment.setArguments(bundle);
49 | FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
50 | transaction.replace(R.id.container, fragment);
51 | transaction.commit();
52 | }
53 | }
54 |
55 | }
56 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_blendent.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
10 |
19 |
23 |
28 |
33 |
38 |
43 |
48 |
49 |
--------------------------------------------------------------------------------
/app/src/main/res/values/arrays.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | - @string/content_toolbar
5 | - @string/content_blendent
6 | - @string/content_recyclerview
7 | - @string/content_cardview
8 | - @string/content_animation
9 |
10 |
11 |
12 | - @string/option_recyclerview_multitype
13 | - @string/option_recyclerview_multilayout
14 | - @string/option_recyclerview_animation
15 | - @string/option_recyclerview_decorator
16 |
17 |
18 |
19 | - @string/multitype_left_string1
20 | - @string/multitype_right_string1
21 | - @string/multitype_left_string2
22 | - @string/multitype_right_string2
23 | - @string/multitype_left_string3
24 | - @string/multitype_right_string3
25 | - @string/multitype_left_string4
26 | - @string/multitype_right_string4
27 |
28 |
29 |
30 | - @string/multilayout_str1
31 | - @string/multilayout_str2
32 | - @string/multilayout_str3
33 | - @string/multilayout_str4
34 | - @string/multilayout_str5
35 | - @string/multilayout_str6
36 | - @string/multilayout_str7
37 | - @string/multilayout_str8
38 | - @string/multilayout_str9
39 | - @string/multilayout_str10
40 | - @string/multilayout_str11
41 | - @string/multilayout_str12
42 | - @string/multilayout_str13
43 | - @string/multilayout_str14
44 | - @string/multilayout_str15
45 | - @string/multilayout_str16
46 | - @string/multilayout_str17
47 | - @string/multilayout_str18
48 | - @string/multilayout_str19
49 | - @string/multilayout_str20
50 |
51 |
52 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/app/src/main/java/me/willclub/learnmaterialdesign/fragments/RVDecorationFragment.java:
--------------------------------------------------------------------------------
1 | package me.willclub.learnmaterialdesign.fragments;
2 |
3 | import android.os.Bundle;
4 | import android.support.v7.widget.LinearLayoutManager;
5 | import android.support.v7.widget.RecyclerView;
6 | import android.support.v7.widget.Toolbar;
7 | import android.view.LayoutInflater;
8 | import android.view.View;
9 | import android.view.ViewGroup;
10 | import android.widget.TextView;
11 |
12 | import me.willclub.learnmaterialdesign.R;
13 | import me.willclub.learnmaterialdesign.decorations.DividerItemDecoration;
14 | import me.willclub.learnmaterialdesign.utils.ArrayUtil;
15 | import me.willclub.learnmaterialdesign.utils.DrawableUtil;
16 |
17 | /**
18 | * Created by will on 4/18/15.
19 | */
20 | public class RVDecorationFragment extends BaseFragment {
21 |
22 | private RecyclerView recyclerView;
23 | private String[] contentArray;
24 |
25 | @Override
26 | protected boolean hasActionBar() {
27 | return true;
28 | }
29 |
30 | @Override
31 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
32 | return LayoutInflater.from(getActivity()).inflate(R.layout.fragment_decoration, null);
33 | }
34 |
35 | @Override
36 | public void onActivityCreated(Bundle savedInstanceState) {
37 | super.onActivityCreated(savedInstanceState);
38 | contentArray = getResources().getStringArray(R.array.multilayoutArray);
39 | Toolbar toolbar = (Toolbar) getView().findViewById(R.id.toolbar);
40 | setupActionBar(toolbar);
41 | enableHomeAsUp();
42 | setupRecyclerView();
43 | }
44 |
45 | private void setupRecyclerView() {
46 | recyclerView = (RecyclerView) getView().findViewById(R.id.recyclerView);
47 | recyclerView.setHasFixedSize(true);
48 | recyclerView.setLayoutManager(new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false));
49 | recyclerView.addItemDecoration(new DividerItemDecoration(DrawableUtil.getDrawable(getActivity(), R.drawable.list_divider)));
50 | recyclerView.setAdapter(new DecorationAdapter());
51 | }
52 |
53 | private class DecorationAdapter extends RecyclerView.Adapter {
54 |
55 | private LayoutInflater layoutInflater;
56 |
57 | public DecorationAdapter() {
58 | layoutInflater = LayoutInflater.from(getActivity());
59 | }
60 |
61 | @Override
62 | public int getItemCount() {
63 | if (ArrayUtil.isValid(contentArray)) {
64 | return contentArray.length;
65 | }
66 | return 0;
67 | }
68 |
69 | @Override
70 | public DecorationViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
71 | return new DecorationViewHolder(layoutInflater.inflate(R.layout.list_item_rect, parent, false));
72 | }
73 |
74 | @Override
75 | public void onBindViewHolder(DecorationViewHolder holder, int position) {
76 | holder.textView.setText(contentArray[position]);
77 | }
78 |
79 | }
80 |
81 | private class DecorationViewHolder extends RecyclerView.ViewHolder {
82 |
83 | TextView textView;
84 |
85 | public DecorationViewHolder(View itemView) {
86 | super(itemView);
87 | textView = (TextView) itemView;
88 | }
89 | }
90 |
91 |
92 | }
93 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | LearnMaterialDesign
3 | settings
4 | Coming soon
5 |
6 | Main
7 | Detail
8 | RecyclerView
9 | ToolBar
10 | Blendent
11 | MultiType
12 | MultiLayout
13 | Animated
14 |
15 |
16 | Search
17 | Item1
18 | Item2
19 | Item3
20 | LinearLayout
21 | GridLyout
22 | StaggerGridLayout
23 | Anim
24 | Add
25 | Delete
26 |
27 |
28 | ToolBar
29 | Blendent
30 | RecyclerView
31 | CardView
32 | Animation
33 |
34 | MultiType
35 | MultiLayout
36 | ItemAnimation
37 | ItemDecoration
38 |
39 | Hello!
40 | Hello!
41 | Who are you?
42 | I am Will!
43 | Nice to meet you!
44 | Me too!
45 | Your Android video is good!
46 | Thanks!
47 |
48 | London
49 | Nanjing
50 | Shanghai
51 | Shenzhen
52 | Macao
53 | HK
54 | Zurich
55 | Luzern
56 | Paris
57 | Tibet
58 | HK
59 | Tokyo
60 | Berlin
61 | Chicago
62 | LA
63 | Huston
64 | NewYork
65 | Wuhan
66 | Beijing
67 | Xiamen
68 |
69 |
70 |
--------------------------------------------------------------------------------
/app/src/main/java/me/willclub/learnmaterialdesign/activities/BaseListActivity.java:
--------------------------------------------------------------------------------
1 | package me.willclub.learnmaterialdesign.activities;
2 |
3 | import android.os.Bundle;
4 | import android.support.v7.widget.LinearLayoutManager;
5 | import android.support.v7.widget.RecyclerView;
6 | import android.support.v7.widget.Toolbar;
7 | import android.view.LayoutInflater;
8 | import android.view.MenuItem;
9 | import android.view.View;
10 | import android.view.ViewGroup;
11 | import android.widget.TextView;
12 |
13 | import me.willclub.learnmaterialdesign.R;
14 | import me.willclub.learnmaterialdesign.utils.ArrayUtil;
15 |
16 | /**
17 | * Created by will on 4/16/15.
18 | */
19 | public abstract class BaseListActivity extends BaseActivity {
20 |
21 | protected RecyclerView recyclerView;
22 | protected Toolbar toolbar;
23 | protected String[] contentArray;
24 |
25 | protected abstract int contentArrayRes();
26 | protected abstract void onItemClick(String content, int position);
27 |
28 | @Override
29 | protected void onCreate(Bundle savedInstanceState) {
30 | super.onCreate(savedInstanceState);
31 | setContentView(R.layout.base_recyclerview);
32 | if (contentArrayRes() < 0) {
33 | finish();
34 | }
35 | contentArray = getResources().getStringArray(contentArrayRes());
36 | setupToolBar();
37 | setupRecyclerView();
38 | }
39 |
40 | @Override
41 | public boolean onOptionsItemSelected(MenuItem item) {
42 | if (item.getItemId() == android.R.id.home) {
43 | finish();
44 | return true;
45 | }
46 | return super.onOptionsItemSelected(item);
47 | }
48 |
49 | private void setupToolBar() {
50 | toolbar = (Toolbar) findViewById(R.id.toolbar);
51 | setSupportActionBar(toolbar);
52 | }
53 |
54 | private void setupRecyclerView() {
55 | recyclerView = (RecyclerView) findViewById(R.id.recyclerView);
56 | recyclerView.setHasFixedSize(true);
57 | recyclerView.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
58 | recyclerView.setAdapter(new BaseListAdapter());
59 | }
60 |
61 | protected void enableHomeAsUp() {
62 | enableHomeAsUp(-1);
63 | }
64 |
65 | protected void enableHomeAsUp(int indicator) {
66 | getSupportActionBar().setDisplayHomeAsUpEnabled(true);
67 | if (indicator > 0) {
68 | getSupportActionBar().setHomeAsUpIndicator(indicator);
69 | }
70 | }
71 |
72 | private class BaseListAdapter extends RecyclerView.Adapter {
73 |
74 | private LayoutInflater layoutInflater;
75 |
76 | public BaseListAdapter() {
77 | layoutInflater = LayoutInflater.from(BaseListActivity.this);
78 | }
79 |
80 | @Override
81 | public int getItemCount() {
82 | if (ArrayUtil.isValid(contentArray)) {
83 | return contentArray.length;
84 | }
85 | return 0;
86 | }
87 |
88 | @Override
89 | public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
90 | return new ViewHolder(layoutInflater.inflate(R.layout.list_item_round, parent, false));
91 | }
92 |
93 | @Override
94 | public void onBindViewHolder(ViewHolder holder, int position) {
95 | holder.textView.setText(contentArray[position]);
96 | }
97 |
98 | }
99 |
100 | private class ViewHolder extends RecyclerView.ViewHolder {
101 |
102 | private TextView textView;
103 |
104 | public ViewHolder(View itemView) {
105 | super(itemView);
106 | textView = (TextView) itemView;
107 | textView.setOnClickListener(new View.OnClickListener() {
108 | @Override
109 | public void onClick(View v) {
110 | int layoutPosition = getLayoutPosition();
111 | onItemClick(contentArray[layoutPosition], layoutPosition);
112 | }
113 | });
114 | }
115 | }
116 |
117 | }
118 |
--------------------------------------------------------------------------------
/app/src/main/java/me/willclub/learnmaterialdesign/fragments/RVMultiTypeFragment.java:
--------------------------------------------------------------------------------
1 | package me.willclub.learnmaterialdesign.fragments;
2 |
3 | import android.os.Bundle;
4 | import android.support.v7.widget.LinearLayoutManager;
5 | import android.support.v7.widget.RecyclerView;
6 | import android.support.v7.widget.Toolbar;
7 | import android.view.LayoutInflater;
8 | import android.view.View;
9 | import android.view.ViewGroup;
10 | import android.widget.TextView;
11 |
12 | import me.willclub.learnmaterialdesign.R;
13 | import me.willclub.learnmaterialdesign.Trace;
14 | import me.willclub.learnmaterialdesign.utils.ArrayUtil;
15 |
16 | /**
17 | * Created by will on 4/16/15.
18 | */
19 | public class RVMultiTypeFragment extends BaseFragment {
20 |
21 | private RecyclerView recyclerView;
22 | private Toolbar toolbar;
23 | private String[] contentArray;
24 |
25 | private static final int TYPE_LEFT = 0;
26 | private static final int TYPE_RIGHT = 1;
27 |
28 | @Override
29 | protected boolean hasActionBar() {
30 | return true;
31 | }
32 |
33 | @Override
34 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
35 | return LayoutInflater.from(getActivity()).inflate(R.layout.base_recyclerview, null);
36 | }
37 |
38 | @Override
39 | public void onActivityCreated(Bundle savedInstanceState) {
40 | super.onActivityCreated(savedInstanceState);
41 | contentArray = getResources().getStringArray(R.array.multitypeArray);
42 | toolbar = (Toolbar) getView().findViewById(R.id.toolbar);
43 | setupActionBar(toolbar);
44 | enableHomeAsUp();
45 | setActionBarTitle(R.string.label__rv_multitype);
46 | setupRecyclerView();
47 | }
48 |
49 | private void setupRecyclerView() {
50 | recyclerView = (RecyclerView) getView().findViewById(R.id.recyclerView);
51 | recyclerView.setLayoutManager(new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false));
52 | recyclerView.setAdapter(new MultiTypeAdapter());
53 | }
54 |
55 | private class MultiTypeAdapter extends RecyclerView.Adapter {
56 |
57 | private LayoutInflater layoutInflater;
58 |
59 | public MultiTypeAdapter() {
60 | layoutInflater = LayoutInflater.from(getActivity());
61 | }
62 |
63 | @Override
64 | public int getItemCount() {
65 | if (ArrayUtil.isValid(contentArray)) {
66 | return contentArray.length;
67 | }
68 | return 0;
69 | }
70 |
71 | @Override
72 | public int getItemViewType(int position) {
73 | return position % 2 == 0 ? TYPE_LEFT : TYPE_RIGHT;
74 | }
75 |
76 | @Override
77 | public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
78 | if (viewType == TYPE_LEFT) {
79 | return new LeftViewHolder(layoutInflater.inflate(R.layout.list_item_left, parent, false));
80 | }
81 | else {
82 | return new RightViewHolder(layoutInflater.inflate(R.layout.list_item_right, parent, false));
83 | }
84 | }
85 |
86 | @Override
87 | public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
88 | Trace.d(holder.getClass().toString());
89 | if (holder.getItemViewType() == TYPE_LEFT) {
90 | LeftViewHolder leftHolder = (LeftViewHolder) holder;
91 | leftHolder.leftView.setText(contentArray[position]);
92 | }
93 | else {
94 | RightViewHolder rightHolder = (RightViewHolder) holder;
95 | rightHolder.rightView.setText(contentArray[position]);
96 | }
97 | }
98 |
99 | }
100 |
101 | private class LeftViewHolder extends RecyclerView.ViewHolder {
102 |
103 | TextView leftView;
104 |
105 | public LeftViewHolder(View itemView) {
106 | super(itemView);
107 | leftView = (TextView) itemView.findViewById(R.id.leftTextView);
108 | }
109 | }
110 |
111 | private class RightViewHolder extends RecyclerView.ViewHolder {
112 |
113 | TextView rightView;
114 |
115 | public RightViewHolder(View itemView) {
116 | super(itemView);
117 | rightView = (TextView) itemView.findViewById(R.id.rightTextView);
118 | }
119 | }
120 | }
121 |
--------------------------------------------------------------------------------
/app/src/main/java/me/willclub/learnmaterialdesign/decorations/DividerItemDecoration.java:
--------------------------------------------------------------------------------
1 | package me.willclub.learnmaterialdesign.decorations;
2 |
3 | import android.graphics.Canvas;
4 | import android.graphics.Rect;
5 | import android.graphics.drawable.Drawable;
6 | import android.support.v7.widget.LinearLayoutManager;
7 | import android.support.v7.widget.RecyclerView;
8 | import android.view.View;
9 |
10 | /**
11 | * RecyclerView中实现divider功能
12 | * 只支持LinearLayoutManager
13 | */
14 | public class DividerItemDecoration extends RecyclerView.ItemDecoration {
15 |
16 | private Drawable dividerDrawable;
17 |
18 | public DividerItemDecoration(Drawable divider) {
19 | dividerDrawable = divider;
20 | }
21 |
22 | @Override
23 | public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
24 | if (dividerDrawable == null) {
25 | return;
26 | }
27 |
28 | //如果是第一个item,不需要divider,所以直接return
29 | if (parent.getChildLayoutPosition(view) < 1) {
30 | return;
31 | }
32 |
33 | //相当于给itemView设置margin,给divider预留空间
34 | int layoutOrientation = getOrientation(parent);
35 | if (layoutOrientation == LinearLayoutManager.VERTICAL) {
36 | outRect.top = dividerDrawable.getIntrinsicHeight();
37 | } else if(layoutOrientation == LinearLayoutManager.HORIZONTAL) {
38 | outRect.left = dividerDrawable.getIntrinsicWidth();
39 | }
40 | }
41 |
42 | @Override
43 | public void onDrawOver(Canvas c, RecyclerView parent, RecyclerView.State state) {
44 | if (dividerDrawable == null) {
45 | return;
46 | }
47 |
48 | LinearLayoutManager layoutManager = getLinearLayoutManger(parent);
49 | if (layoutManager == null) {
50 | return;
51 | }
52 |
53 | int firstVisiblePosition = layoutManager.findFirstVisibleItemPosition();
54 | int orientation = getOrientation(layoutManager);
55 | int childCount = parent.getChildCount();
56 | if (orientation == LinearLayoutManager.VERTICAL) {
57 | int right = parent.getWidth();
58 | for (int i=0; i contentList;
32 | private CommonAdapter adapter;
33 | private boolean animated;
34 |
35 | @Override
36 | protected boolean hasActionBar() {
37 | return true;
38 | }
39 |
40 | @Override
41 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
42 | return LayoutInflater.from(getActivity()).inflate(R.layout.base_recyclerview, null);
43 | }
44 |
45 | @Override
46 | public void onActivityCreated(Bundle savedInstanceState) {
47 | super.onActivityCreated(savedInstanceState);
48 | animated = getArguments().getBoolean(Constant.BUNDLE_KEY_ANIMATED, false);
49 | Toolbar toolbar = (Toolbar) getView().findViewById(R.id.toolbar);
50 | setupActionBar(toolbar);
51 | setActionBarTitle(animated ? R.string.label__rv_animated : R.string.label__rv_multilayout);
52 | enableHomeAsUp();
53 | String[] contentArray = getResources().getStringArray(R.array.multilayoutArray);
54 | contentList = new LinkedList<>(Arrays.asList(contentArray));
55 | recyclerView = (RecyclerView) getView().findViewById(R.id.recyclerView);
56 | recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
57 | adapter = new CommonAdapter();
58 | recyclerView.setAdapter(adapter);
59 | }
60 |
61 | @Override
62 | public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
63 | inflater.inflate(animated ? R.menu.menu_animated : R.menu.menu_multilayout, menu);
64 | super.onCreateOptionsMenu(menu, inflater);
65 | }
66 |
67 | @Override
68 | public boolean onOptionsItemSelected(MenuItem item) {
69 | RecyclerView.LayoutManager layoutManager = null;
70 | switch (item.getItemId()) {
71 | case R.id.action_linearlayout:
72 | layoutManager = new LinearLayoutManager(getActivity());
73 | break;
74 | case R.id.action_gridlayout:
75 | layoutManager = new GridLayoutManager(getActivity(), 3);
76 | break;
77 | case R.id.action_staggerlayout:
78 | layoutManager = new StaggeredGridLayoutManager(4, StaggeredGridLayoutManager.HORIZONTAL);
79 | break;
80 | case R.id.action_add:
81 | contentList.add(1, generateItemString());
82 | adapter.notifyItemInserted(1);
83 | break;
84 | case R.id.action_delete:
85 | if (CollectionUtil.isValid(contentList)) {
86 | contentList.removeFirst();
87 | adapter.notifyItemRemoved(0);
88 | }
89 | break;
90 | }
91 | if (layoutManager != null) {
92 | recyclerView.setLayoutManager(layoutManager);
93 | }
94 | return super.onOptionsItemSelected(item);
95 | }
96 |
97 | private String generateItemString() {
98 | Random random = new Random();
99 | int randomInt = random.nextInt(100);
100 | return "new Item " + randomInt;
101 | }
102 |
103 | private class CommonAdapter extends RecyclerView.Adapter {
104 |
105 | private LayoutInflater layoutInflater;
106 |
107 | public CommonAdapter() {
108 | layoutInflater = LayoutInflater.from(getActivity());
109 | }
110 |
111 | @Override
112 | public int getItemCount() {
113 | if (CollectionUtil.isValid(contentList)) {
114 | return contentList.size();
115 | }
116 | return 0;
117 | }
118 |
119 | @Override
120 | public CommonViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
121 | return new CommonViewHolder(layoutInflater.inflate(R.layout.list_item_round, parent, false));
122 | }
123 |
124 | @Override
125 | public void onBindViewHolder(CommonViewHolder holder, int position) {
126 | holder.textView.setText(contentList.get(position));
127 | }
128 | }
129 |
130 | private class CommonViewHolder extends RecyclerView.ViewHolder {
131 |
132 | TextView textView;
133 |
134 | public CommonViewHolder(View itemView) {
135 | super(itemView);
136 | textView = (TextView) itemView;
137 | }
138 | }
139 |
140 | }
141 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # For Cygwin, ensure paths are in UNIX format before anything is touched.
46 | if $cygwin ; then
47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
48 | fi
49 |
50 | # Attempt to set APP_HOME
51 | # Resolve links: $0 may be a link
52 | PRG="$0"
53 | # Need this for relative symlinks.
54 | while [ -h "$PRG" ] ; do
55 | ls=`ls -ld "$PRG"`
56 | link=`expr "$ls" : '.*-> \(.*\)$'`
57 | if expr "$link" : '/.*' > /dev/null; then
58 | PRG="$link"
59 | else
60 | PRG=`dirname "$PRG"`"/$link"
61 | fi
62 | done
63 | SAVED="`pwd`"
64 | cd "`dirname \"$PRG\"`/" >&-
65 | APP_HOME="`pwd -P`"
66 | cd "$SAVED" >&-
67 |
68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
69 |
70 | # Determine the Java command to use to start the JVM.
71 | if [ -n "$JAVA_HOME" ] ; then
72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
73 | # IBM's JDK on AIX uses strange locations for the executables
74 | JAVACMD="$JAVA_HOME/jre/sh/java"
75 | else
76 | JAVACMD="$JAVA_HOME/bin/java"
77 | fi
78 | if [ ! -x "$JAVACMD" ] ; then
79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
80 |
81 | Please set the JAVA_HOME variable in your environment to match the
82 | location of your Java installation."
83 | fi
84 | else
85 | JAVACMD="java"
86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
87 |
88 | Please set the JAVA_HOME variable in your environment to match the
89 | location of your Java installation."
90 | fi
91 |
92 | # Increase the maximum file descriptors if we can.
93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
94 | MAX_FD_LIMIT=`ulimit -H -n`
95 | if [ $? -eq 0 ] ; then
96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
97 | MAX_FD="$MAX_FD_LIMIT"
98 | fi
99 | ulimit -n $MAX_FD
100 | if [ $? -ne 0 ] ; then
101 | warn "Could not set maximum file descriptor limit: $MAX_FD"
102 | fi
103 | else
104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
105 | fi
106 | fi
107 |
108 | # For Darwin, add options to specify how the application appears in the dock
109 | if $darwin; then
110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
111 | fi
112 |
113 | # For Cygwin, switch paths to Windows format before running java
114 | if $cygwin ; then
115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
158 | function splitJvmOpts() {
159 | JVM_OPTS=("$@")
160 | }
161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
163 |
164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
165 |
--------------------------------------------------------------------------------
/app/app.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
--------------------------------------------------------------------------------