├── app
├── .gitignore
├── src
│ └── main
│ │ ├── res
│ │ ├── values
│ │ │ ├── drawable-xhdpi.xml
│ │ │ ├── strings.xml
│ │ │ ├── colors.xml
│ │ │ ├── dimens.xml
│ │ │ └── styles.xml
│ │ ├── drawable-xhdpi
│ │ │ ├── go.png
│ │ │ ├── to.png
│ │ │ ├── back.png
│ │ │ ├── hotel.png
│ │ │ ├── sanya.png
│ │ │ ├── food_1.png
│ │ │ ├── good_1.png
│ │ │ ├── user_a.png
│ │ │ ├── user_b.png
│ │ │ ├── hotel_pic.png
│ │ │ ├── airlinetiket.png
│ │ │ ├── message_left_bg.9.png
│ │ │ └── message_right_bg.9.png
│ │ ├── mipmap-xhdpi
│ │ │ ├── avatar.gif
│ │ │ └── ic_launcher.png
│ │ ├── mipmap-hdpi
│ │ │ └── ic_launcher.png
│ │ ├── mipmap-mdpi
│ │ │ └── ic_launcher.png
│ │ ├── mipmap-xxhdpi
│ │ │ └── ic_launcher.png
│ │ ├── mipmap-xxxhdpi
│ │ │ └── ic_launcher.png
│ │ ├── values-w820dp
│ │ │ └── dimens.xml
│ │ ├── layout
│ │ │ ├── item_string.xml
│ │ │ ├── item_food.xml
│ │ │ ├── test.xml
│ │ │ ├── item_good.xml
│ │ │ ├── item_image.xml
│ │ │ ├── item_text.xml
│ │ │ ├── activity_main.xml
│ │ │ ├── activity_long_page.xml
│ │ │ ├── fragment_edit.xml
│ │ │ ├── item_message_left.xml
│ │ │ ├── item_message_right.xml
│ │ │ ├── item_rich.xml
│ │ │ ├── fragment_food.xml
│ │ │ ├── fragment_shop.xml
│ │ │ ├── activity_chat.xml
│ │ │ ├── fragment_info.xml
│ │ │ ├── fragment_hotel.xml
│ │ │ ├── fragment_culture.xml
│ │ │ ├── fragment_recommend.xml
│ │ │ └── fragment_airlineticket.xml
│ │ └── drawable
│ │ │ └── square_border.xml
│ │ ├── java
│ │ └── com
│ │ │ └── shizhefei
│ │ │ └── mutitypedemo
│ │ │ ├── type
│ │ │ ├── Food.java
│ │ │ ├── Good.java
│ │ │ ├── ImageItem.java
│ │ │ ├── Message.java
│ │ │ ├── FoodProvider.java
│ │ │ ├── GoodProvider.java
│ │ │ ├── StringProvider.java
│ │ │ ├── RichItem.java
│ │ │ ├── ImageItemProvider.java
│ │ │ ├── RichItemProvider.java
│ │ │ └── MessageProvider.java
│ │ │ ├── activity
│ │ │ ├── longpagelazy
│ │ │ │ ├── InfoLazyFragment.java
│ │ │ │ ├── CultureLazyFragment.java
│ │ │ │ ├── RecommendLazyFragment.java
│ │ │ │ ├── AirlineTicketLazyFragment.java
│ │ │ │ ├── FoodLazyFragment.java
│ │ │ │ ├── ShopLazyFragment.java
│ │ │ │ ├── HotelLazyFragment.java
│ │ │ │ ├── LoadLazyFragment.java
│ │ │ │ └── EditLazyFragment.java
│ │ │ ├── longpage
│ │ │ │ ├── InfoFragment.java
│ │ │ │ ├── RecommendFragment.java
│ │ │ │ ├── CultureFragment.java
│ │ │ │ ├── AirlineTicketFragment.java
│ │ │ │ ├── FoodFragment.java
│ │ │ │ ├── ShopFragment.java
│ │ │ │ ├── HotelFragment.java
│ │ │ │ ├── LoadFragment.java
│ │ │ │ └── EditFragment.java
│ │ │ ├── BoomActivity.java
│ │ │ ├── MainActivity.java
│ │ │ ├── LoadActivity.java
│ │ │ ├── ChatActivity.java
│ │ │ ├── LongPageActivity.java
│ │ │ └── LongPageStateActivity.java
│ │ │ ├── ExampleApplication.java
│ │ │ └── util
│ │ │ └── DisplayUtils.java
│ │ └── AndroidManifest.xml
├── proguard-rules.pro
└── build.gradle
├── library
├── .gitignore
├── src
│ └── main
│ │ ├── AndroidManifest.xml
│ │ ├── res
│ │ └── values
│ │ │ ├── strings.xml
│ │ │ └── ids.xml
│ │ └── java
│ │ └── com
│ │ └── shizhefei
│ │ └── view
│ │ └── multitype
│ │ ├── data
│ │ ├── IParcelableData.java
│ │ └── SerializableData.java
│ │ ├── ItemBinder.java
│ │ ├── ItemViewProvider.java
│ │ ├── provider
│ │ ├── ChildViewHeightLayout.java
│ │ ├── ViewProvider.java
│ │ ├── ViewUtils.java
│ │ ├── FragmentDataProvider.java
│ │ └── FragmentData.java
│ │ ├── ItemViewProviderSet.java
│ │ ├── MultiTypeView.java
│ │ └── ItemBinderFactory.java
├── proguard-rules.pro
└── build.gradle
├── settings.gradle
├── raw
├── 1.png
├── 2.png
└── MutiTypeDemo.apk
├── .gitignore
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradle.properties
├── gradlew.bat
├── gradlew
├── README.md
└── License.md
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 | /build/
3 |
--------------------------------------------------------------------------------
/library/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 | /build/
3 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':library'
2 |
--------------------------------------------------------------------------------
/raw/1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LuckyJayce/MultiTypeView/HEAD/raw/1.png
--------------------------------------------------------------------------------
/raw/2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LuckyJayce/MultiTypeView/HEAD/raw/2.png
--------------------------------------------------------------------------------
/raw/MutiTypeDemo.apk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LuckyJayce/MultiTypeView/HEAD/raw/MutiTypeDemo.apk
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | .DS_Store
5 | /build
6 | /captures
7 | /.idea/
8 |
--------------------------------------------------------------------------------
/app/src/main/res/values/drawable-xhdpi.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/library/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | MutiTypeDemo
3 |
4 |
--------------------------------------------------------------------------------
/library/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | library
3 |
4 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LuckyJayce/MultiTypeView/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/go.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LuckyJayce/MultiTypeView/HEAD/app/src/main/res/drawable-xhdpi/go.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/to.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LuckyJayce/MultiTypeView/HEAD/app/src/main/res/drawable-xhdpi/to.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/back.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LuckyJayce/MultiTypeView/HEAD/app/src/main/res/drawable-xhdpi/back.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/hotel.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LuckyJayce/MultiTypeView/HEAD/app/src/main/res/drawable-xhdpi/hotel.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/sanya.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LuckyJayce/MultiTypeView/HEAD/app/src/main/res/drawable-xhdpi/sanya.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/avatar.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LuckyJayce/MultiTypeView/HEAD/app/src/main/res/mipmap-xhdpi/avatar.gif
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/food_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LuckyJayce/MultiTypeView/HEAD/app/src/main/res/drawable-xhdpi/food_1.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/good_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LuckyJayce/MultiTypeView/HEAD/app/src/main/res/drawable-xhdpi/good_1.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/user_a.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LuckyJayce/MultiTypeView/HEAD/app/src/main/res/drawable-xhdpi/user_a.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/user_b.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LuckyJayce/MultiTypeView/HEAD/app/src/main/res/drawable-xhdpi/user_b.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LuckyJayce/MultiTypeView/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LuckyJayce/MultiTypeView/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/library/src/main/res/values/ids.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/hotel_pic.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LuckyJayce/MultiTypeView/HEAD/app/src/main/res/drawable-xhdpi/hotel_pic.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LuckyJayce/MultiTypeView/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LuckyJayce/MultiTypeView/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/airlinetiket.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LuckyJayce/MultiTypeView/HEAD/app/src/main/res/drawable-xhdpi/airlinetiket.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LuckyJayce/MultiTypeView/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/message_left_bg.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LuckyJayce/MultiTypeView/HEAD/app/src/main/res/drawable-xhdpi/message_left_bg.9.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/message_right_bg.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LuckyJayce/MultiTypeView/HEAD/app/src/main/res/drawable-xhdpi/message_right_bg.9.png
--------------------------------------------------------------------------------
/app/src/main/java/com/shizhefei/mutitypedemo/type/Food.java:
--------------------------------------------------------------------------------
1 | package com.shizhefei.mutitypedemo.type;
2 |
3 | /**
4 | * Created by LuckyJayce on 2016/8/8.
5 | */
6 | public class Food {
7 | }
8 |
--------------------------------------------------------------------------------
/app/src/main/java/com/shizhefei/mutitypedemo/type/Good.java:
--------------------------------------------------------------------------------
1 | package com.shizhefei.mutitypedemo.type;
2 |
3 | /**
4 | * Created by LuckyJayce on 2016/8/8.
5 | */
6 | public class Good {
7 | }
8 |
--------------------------------------------------------------------------------
/app/src/main/java/com/shizhefei/mutitypedemo/type/ImageItem.java:
--------------------------------------------------------------------------------
1 | package com.shizhefei.mutitypedemo.type;
2 |
3 | public class ImageItem {
4 |
5 | public final int resId;
6 |
7 | public ImageItem(int resId) {
8 | this.resId = resId;
9 | }
10 | }
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Mon Dec 28 10:00:20 PST 2015
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.10-all.zip
7 |
--------------------------------------------------------------------------------
/app/src/main/java/com/shizhefei/mutitypedemo/type/Message.java:
--------------------------------------------------------------------------------
1 | package com.shizhefei.mutitypedemo.type;
2 |
3 | /**
4 | * Created by LuckyJayce on 2016/8/8.
5 | */
6 | public class Message {
7 | public String userId;
8 | public String text;
9 |
10 | public Message(String userId, String text) {
11 | this.userId = userId;
12 | this.text = text;
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_string.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | #2196F3
5 |
6 | #2196F3
7 |
8 | #8BC34A
9 |
10 | #4d4d4d
11 |
12 | #858585
13 |
14 | #dadada
15 | #00000000
16 | #ffffff
17 |
18 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_food.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
13 |
14 |
18 |
19 |
--------------------------------------------------------------------------------
/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 D:\Android\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 |
--------------------------------------------------------------------------------
/library/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 D:\Android\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/com/shizhefei/mutitypedemo/activity/longpagelazy/InfoLazyFragment.java:
--------------------------------------------------------------------------------
1 | package com.shizhefei.mutitypedemo.activity.longpagelazy;
2 |
3 | import android.os.Bundle;
4 | import android.util.Log;
5 |
6 | import com.shizhefei.fragment.LazyFragment;
7 | import com.shizhefei.mutitypedemo.R;
8 |
9 | /**
10 | * Created by LuckyJayce on 2016/8/8.
11 | */
12 | public class InfoLazyFragment extends LazyFragment {
13 | @Override
14 | protected void onCreateViewLazy(Bundle savedInstanceState) {
15 | super.onCreateViewLazy(savedInstanceState);
16 | setContentView(R.layout.fragment_info);
17 | Log.d("dddd", "onCreateView :" + getClass().getSimpleName() + " " + savedInstanceState);
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/app/src/main/java/com/shizhefei/mutitypedemo/activity/longpagelazy/CultureLazyFragment.java:
--------------------------------------------------------------------------------
1 | package com.shizhefei.mutitypedemo.activity.longpagelazy;
2 |
3 | import android.os.Bundle;
4 | import android.util.Log;
5 |
6 | import com.shizhefei.fragment.LazyFragment;
7 | import com.shizhefei.mutitypedemo.R;
8 |
9 | /**
10 | * Created by LuckyJayce on 2016/8/8.
11 | */
12 | public class CultureLazyFragment extends LazyFragment {
13 | @Override
14 | protected void onCreateViewLazy(Bundle savedInstanceState) {
15 | super.onCreateViewLazy(savedInstanceState);
16 | setContentView(R.layout.fragment_culture);
17 | Log.d("dddd", "onCreateView :" + getClass().getSimpleName() + " " + savedInstanceState);
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/app/src/main/java/com/shizhefei/mutitypedemo/activity/longpagelazy/RecommendLazyFragment.java:
--------------------------------------------------------------------------------
1 | package com.shizhefei.mutitypedemo.activity.longpagelazy;
2 |
3 | import android.os.Bundle;
4 | import android.util.Log;
5 |
6 | import com.shizhefei.fragment.LazyFragment;
7 | import com.shizhefei.mutitypedemo.R;
8 |
9 | /**
10 | * Created by LuckyJayce on 2016/8/8.
11 | */
12 | public class RecommendLazyFragment extends LazyFragment {
13 |
14 | @Override
15 | protected void onCreateViewLazy(Bundle savedInstanceState) {
16 | super.onCreateViewLazy(savedInstanceState);
17 | setContentView(R.layout.fragment_recommend);
18 | Log.d("dddd", "onCreateView :" + getClass().getSimpleName() + " " + savedInstanceState);
19 | }
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/app/src/main/java/com/shizhefei/mutitypedemo/activity/longpagelazy/AirlineTicketLazyFragment.java:
--------------------------------------------------------------------------------
1 | package com.shizhefei.mutitypedemo.activity.longpagelazy;
2 |
3 | import android.os.Bundle;
4 | import android.util.Log;
5 |
6 | import com.shizhefei.fragment.LazyFragment;
7 | import com.shizhefei.mutitypedemo.R;
8 |
9 | /**
10 | * Created by LuckyJayce on 2016/8/8.
11 | */
12 | public class AirlineTicketLazyFragment extends LazyFragment {
13 |
14 | @Override
15 | protected void onCreateViewLazy(Bundle savedInstanceState) {
16 | super.onCreateViewLazy(savedInstanceState);
17 | setContentView(R.layout.fragment_airlineticket);
18 | Log.d("dddd", "onCreateView :" + getClass().getSimpleName() + " " + savedInstanceState);
19 | }
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/app/src/main/java/com/shizhefei/mutitypedemo/type/FoodProvider.java:
--------------------------------------------------------------------------------
1 | package com.shizhefei.mutitypedemo.type;
2 |
3 | import android.support.v7.widget.RecyclerView;
4 | import android.view.LayoutInflater;
5 | import android.view.ViewGroup;
6 |
7 | import com.shizhefei.view.multitype.ItemViewProvider;
8 | import com.shizhefei.mutitypedemo.R;
9 |
10 | /**
11 | * Created by LuckyJayce on 2016/8/8.
12 | */
13 | public class FoodProvider extends ItemViewProvider {
14 |
15 | @Override
16 | public RecyclerView.ViewHolder onCreateViewHolder(LayoutInflater inflater, ViewGroup parent, int providerType) {
17 | return new RecyclerView.ViewHolder(inflater.inflate(R.layout.item_food, parent, false)) {
18 | };
19 | }
20 |
21 | @Override
22 | public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, Food food) {
23 |
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/app/src/main/java/com/shizhefei/mutitypedemo/type/GoodProvider.java:
--------------------------------------------------------------------------------
1 | package com.shizhefei.mutitypedemo.type;
2 |
3 | import android.support.v7.widget.RecyclerView;
4 | import android.view.LayoutInflater;
5 | import android.view.ViewGroup;
6 |
7 | import com.shizhefei.view.multitype.ItemViewProvider;
8 | import com.shizhefei.mutitypedemo.R;
9 |
10 | /**
11 | * Created by LuckyJayce on 2016/8/8.
12 | */
13 | public class GoodProvider extends ItemViewProvider {
14 |
15 | @Override
16 | public RecyclerView.ViewHolder onCreateViewHolder(LayoutInflater inflater, ViewGroup parent, int providerType) {
17 | return new RecyclerView.ViewHolder(inflater.inflate(R.layout.item_good, parent, false)) {
18 | };
19 | }
20 |
21 | @Override
22 | public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, Good good) {
23 |
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/app/src/main/java/com/shizhefei/mutitypedemo/activity/longpage/InfoFragment.java:
--------------------------------------------------------------------------------
1 | package com.shizhefei.mutitypedemo.activity.longpage;
2 |
3 | import android.os.Bundle;
4 | import android.support.annotation.Nullable;
5 | import android.support.v4.app.Fragment;
6 | import android.util.Log;
7 | import android.view.LayoutInflater;
8 | import android.view.View;
9 | import android.view.ViewGroup;
10 |
11 | import com.shizhefei.mutitypedemo.R;
12 |
13 | /**
14 | * Created by LuckyJayce on 2016/8/8.
15 | */
16 | public class InfoFragment extends Fragment {
17 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
18 | View view = inflater.inflate(R.layout.fragment_info, container, false);
19 | Log.d("dddd", "onCreateView :" + getClass().getSimpleName() + " " + savedInstanceState);
20 | return view;
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/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/src/main/java/com/shizhefei/mutitypedemo/activity/longpage/RecommendFragment.java:
--------------------------------------------------------------------------------
1 | package com.shizhefei.mutitypedemo.activity.longpage;
2 |
3 | import android.os.Bundle;
4 | import android.support.annotation.Nullable;
5 | import android.support.v4.app.Fragment;
6 | import android.util.Log;
7 | import android.view.LayoutInflater;
8 | import android.view.View;
9 | import android.view.ViewGroup;
10 |
11 | import com.shizhefei.mutitypedemo.R;
12 |
13 | /**
14 | * Created by LuckyJayce on 2016/8/8.
15 | */
16 | public class RecommendFragment extends Fragment {
17 |
18 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
19 | View view = inflater.inflate(R.layout.fragment_recommend, container, false);
20 | Log.d("dddd", "onCreateView :" + getClass().getSimpleName() + " " + savedInstanceState);
21 | return view;
22 | }
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/app/src/main/java/com/shizhefei/mutitypedemo/activity/longpage/CultureFragment.java:
--------------------------------------------------------------------------------
1 | package com.shizhefei.mutitypedemo.activity.longpage;
2 |
3 | import android.os.Bundle;
4 | import android.support.annotation.Nullable;
5 | import android.support.v4.app.Fragment;
6 | import android.util.Log;
7 | import android.view.LayoutInflater;
8 | import android.view.View;
9 | import android.view.ViewGroup;
10 |
11 | import com.shizhefei.mutitypedemo.R;
12 |
13 | /**
14 | * Created by LuckyJayce on 2016/8/8.
15 | */
16 | public class CultureFragment extends Fragment {
17 | @Nullable
18 | @Override
19 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
20 | View view = inflater.inflate(R.layout.fragment_culture, container, false);
21 | Log.d("dddd", "onCreateView :" + getClass().getSimpleName() + " " + savedInstanceState);
22 | return view;
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/square_border.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
19 |
20 |
23 |
--------------------------------------------------------------------------------
/app/src/main/java/com/shizhefei/mutitypedemo/activity/longpage/AirlineTicketFragment.java:
--------------------------------------------------------------------------------
1 | package com.shizhefei.mutitypedemo.activity.longpage;
2 |
3 | import android.os.Bundle;
4 | import android.support.annotation.Nullable;
5 | import android.support.v4.app.Fragment;
6 | import android.util.Log;
7 | import android.view.LayoutInflater;
8 | import android.view.View;
9 | import android.view.ViewGroup;
10 |
11 | import com.shizhefei.mutitypedemo.R;
12 |
13 | /**
14 | * Created by LuckyJayce on 2016/8/8.
15 | */
16 | public class AirlineTicketFragment extends Fragment {
17 | @Nullable
18 | @Override
19 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
20 | View view = inflater.inflate(R.layout.fragment_airlineticket, container, false);
21 | Log.d("dddd", "onCreateView :" + getClass().getSimpleName() + " " + savedInstanceState);
22 | return view;
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/library/src/main/java/com/shizhefei/view/multitype/data/IParcelableData.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2016 shizhefei(LuckyJayce)https://github.com/LuckyJayce
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | package com.shizhefei.view.multitype.data;
17 |
18 | import android.os.Parcelable;
19 |
20 | /**
21 | * Created by LuckyJayce on 2016/8/11.
22 | */
23 | public interface IParcelableData extends Parcelable {
24 | DATA getData();
25 | }
26 |
--------------------------------------------------------------------------------
/app/src/main/java/com/shizhefei/mutitypedemo/type/StringProvider.java:
--------------------------------------------------------------------------------
1 | package com.shizhefei.mutitypedemo.type;
2 |
3 | import android.support.v7.widget.RecyclerView;
4 | import android.view.LayoutInflater;
5 | import android.view.ViewGroup;
6 | import android.widget.TextView;
7 |
8 | import com.shizhefei.view.multitype.ItemViewProvider;
9 | import com.shizhefei.mutitypedemo.R;
10 |
11 | /**
12 | * Created by LuckyJayce on 2016/8/9.
13 | */
14 | public class StringProvider extends ItemViewProvider {
15 |
16 | @Override
17 | public RecyclerView.ViewHolder onCreateViewHolder(LayoutInflater inflater, ViewGroup parent, int providerType) {
18 | return new RecyclerView.ViewHolder(inflater.inflate(R.layout.item_string, parent, false)) {
19 | };
20 | }
21 |
22 | @Override
23 | public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, String s) {
24 | TextView textView = (TextView) viewHolder.itemView;
25 | textView.setText(s);
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/app/src/main/java/com/shizhefei/mutitypedemo/activity/BoomActivity.java:
--------------------------------------------------------------------------------
1 | package com.shizhefei.mutitypedemo.activity;
2 |
3 | import android.app.Activity;
4 | import android.os.Bundle;
5 | import android.view.Gravity;
6 | import android.view.View;
7 | import android.widget.Button;
8 | import android.widget.LinearLayout;
9 |
10 | /**
11 | * Created by LuckyJayce on 2016/8/8.
12 | */
13 | public class BoomActivity extends Activity {
14 | @Override
15 | protected void onCreate(Bundle savedInstanceState) {
16 | super.onCreate(savedInstanceState);
17 | LinearLayout linearLayout = new LinearLayout(this);
18 | linearLayout.setGravity(Gravity.CENTER);
19 | setContentView(linearLayout);
20 |
21 | Button button = new Button(this);
22 | linearLayout.addView(button);
23 | button.setText("点我崩溃");
24 | button.setOnClickListener(new View.OnClickListener() {
25 | @Override
26 | public void onClick(View v) {
27 | "".charAt(100);
28 | }
29 | });
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/test.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
16 |
17 |
26 |
27 |
--------------------------------------------------------------------------------
/app/src/main/java/com/shizhefei/mutitypedemo/type/RichItem.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 drakeet. https://github.com/drakeet
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.shizhefei.mutitypedemo.type;
18 |
19 | import android.support.annotation.NonNull;
20 |
21 | /**
22 | * @author drakeet
23 | */
24 | public class RichItem {
25 |
26 | @NonNull
27 | public String text;
28 | public int imageResId;
29 |
30 |
31 | public RichItem(@NonNull String text, int imageResId) {
32 | this.text = text;
33 | this.imageResId = imageResId;
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_good.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
13 |
14 |
21 |
22 |
26 |
27 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_image.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
24 |
25 |
30 |
31 |
--------------------------------------------------------------------------------
/library/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'com.novoda.bintray-release'//添加
3 |
4 | android {
5 | compileSdkVersion 24
6 | buildToolsVersion "24.0.1"
7 |
8 | defaultConfig {
9 | minSdkVersion 10
10 | targetSdkVersion 24
11 | versionCode 2
12 | versionName "1.0.1"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | dependencies {
23 | compile fileTree(dir: 'libs', include: ['*.jar'])
24 | testCompile 'junit:junit:4.12'
25 | provided 'com.android.support:support-v4:24.1.1'
26 | provided 'com.android.support:recyclerview-v7:24.1.1'
27 | }
28 |
29 | //上传到jcenter 执行
30 | //gradlew clean build bintrayUpload -PbintrayUser=用户名 -PbintrayKey=apiKey -PdryRun=false
31 | //添加
32 | publish {
33 | userOrg = 'luckyjayce'//bintray.com用户名
34 | groupId = 'com.shizhefei'//jcenter上的路径
35 | artifactId = 'MultiTypeView'//项目名称
36 | publishVersion = '1.0.1'//版本号
37 | desc = 'more type Adapter in RecyclerView'//描述,不重要
38 | website = 'https://github.com/LuckyJayce/MultiTypeView'//网站,不重要;尽量模拟github上的地址,例如我这样的;当然你有地址最好了
39 | }
40 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 24
5 | buildToolsVersion "24.0.1"
6 |
7 | defaultConfig {
8 | applicationId "com.shizhefei.mutitypedemo"
9 | minSdkVersion 10
10 | targetSdkVersion 24
11 | versionCode 1
12 | versionName "1.0"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | dependencies {
23 | compile fileTree(dir: 'libs', include: ['*.jar'])
24 | testCompile 'junit:junit:4.12'
25 | compile 'com.android.support:appcompat-v7:24.1.1'
26 | compile 'com.android.support:recyclerview-v7:24.1.1'
27 | compile 'com.android.support:cardview-v7:24.1.1'
28 | debugCompile 'com.squareup.leakcanary:leakcanary-android:1.4-beta2'
29 | releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.4-beta2'
30 | testCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.4-beta2'
31 | compile 'de.hdodenhof:circleimageview:2.1.0'
32 | compile 'com.shizhefei:ViewPagerIndicator:1.1.2'
33 | compile 'com.shizhefei:MVCHelper-Library:1.0.6'
34 | compile project(path: ':library')
35 | }
36 |
--------------------------------------------------------------------------------
/app/src/main/java/com/shizhefei/mutitypedemo/type/ImageItemProvider.java:
--------------------------------------------------------------------------------
1 | package com.shizhefei.mutitypedemo.type;
2 |
3 | import android.support.v7.widget.RecyclerView;
4 | import android.view.LayoutInflater;
5 | import android.view.View;
6 | import android.view.ViewGroup;
7 | import android.widget.ImageView;
8 |
9 | import com.shizhefei.view.multitype.ItemViewProvider;
10 | import com.shizhefei.mutitypedemo.R;
11 |
12 | public class ImageItemProvider extends ItemViewProvider {
13 |
14 | @Override
15 | public RecyclerView.ViewHolder onCreateViewHolder(LayoutInflater inflater, ViewGroup parent,int providerType) {
16 | View root = inflater.inflate(R.layout.item_image, parent, false);
17 | return new ItemViewHolder(root);
18 | }
19 |
20 | @Override
21 | public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, ImageItem data) {
22 | ItemViewHolder holder = (ItemViewHolder) viewHolder;
23 | holder.imageView.setImageResource(data.resId);
24 | }
25 |
26 | private class ItemViewHolder extends RecyclerView.ViewHolder {
27 | private final ImageView imageView;
28 |
29 | public ItemViewHolder(View itemView) {
30 | super(itemView);
31 | imageView = (ImageView) itemView.findViewById(R.id.image);
32 | }
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_text.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
24 |
25 |
32 |
33 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
18 |
19 | 12sp
20 | 14sp
21 | 16sp
22 | 18sp
23 |
24 | 16dp
25 | 16dp
26 |
27 | 8dp
28 | 4dp
29 | 2dp
30 | 16dp
31 | 24dp
32 |
33 |
--------------------------------------------------------------------------------
/app/src/main/java/com/shizhefei/mutitypedemo/ExampleApplication.java:
--------------------------------------------------------------------------------
1 | package com.shizhefei.mutitypedemo;
2 |
3 | import android.app.Application;
4 |
5 | import com.shizhefei.view.multitype.ItemBinderFactory;
6 | import com.shizhefei.mutitypedemo.type.Food;
7 | import com.shizhefei.mutitypedemo.type.FoodProvider;
8 | import com.shizhefei.mutitypedemo.type.Good;
9 | import com.shizhefei.mutitypedemo.type.GoodProvider;
10 | import com.shizhefei.mutitypedemo.type.ImageItem;
11 | import com.shizhefei.mutitypedemo.type.ImageItemProvider;
12 | import com.shizhefei.mutitypedemo.type.RichItem;
13 | import com.shizhefei.mutitypedemo.type.RichItemProvider;
14 | import com.shizhefei.mutitypedemo.type.StringProvider;
15 | import com.squareup.leakcanary.LeakCanary;
16 |
17 | public class ExampleApplication extends Application {
18 |
19 | @Override
20 | public void onCreate() {
21 | super.onCreate();
22 | LeakCanary.install(this);
23 |
24 | //这些代码可以放在应用初始化的时候,静态注册Provider
25 | //每个new ItemBinderFactory()实例共享这些注册的Provider
26 | ItemBinderFactory.registerStaticProvider(ImageItem.class, new ImageItemProvider());
27 | ItemBinderFactory.registerStaticProvider(RichItem.class, new RichItemProvider());
28 | ItemBinderFactory.registerStaticProvider(Food.class, new FoodProvider());
29 | ItemBinderFactory.registerStaticProvider(Good.class, new GoodProvider());
30 | ItemBinderFactory.registerStaticProvider(String.class, new StringProvider());
31 | }
32 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/shizhefei/mutitypedemo/type/RichItemProvider.java:
--------------------------------------------------------------------------------
1 | package com.shizhefei.mutitypedemo.type;
2 |
3 | import android.support.v7.widget.RecyclerView;
4 | import android.view.LayoutInflater;
5 | import android.view.View;
6 | import android.view.ViewGroup;
7 | import android.widget.ImageView;
8 | import android.widget.TextView;
9 |
10 | import com.shizhefei.view.multitype.ItemViewProvider;
11 | import com.shizhefei.mutitypedemo.R;
12 |
13 | public class RichItemProvider extends ItemViewProvider {
14 |
15 | @Override
16 | public RecyclerView.ViewHolder onCreateViewHolder(LayoutInflater inflater, ViewGroup parent, int providerType) {
17 | View root = inflater.inflate(R.layout.item_rich, parent, false);
18 | return new ItemViewHolder(root);
19 | }
20 |
21 | @Override
22 | public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, RichItem data) {
23 | ItemViewHolder holder = (ItemViewHolder) viewHolder;
24 | holder.text.setText(data.text);
25 | holder.image.setImageResource(data.imageResId);
26 | }
27 |
28 | private class ItemViewHolder extends RecyclerView.ViewHolder {
29 | private final TextView text;
30 | private final ImageView image;
31 |
32 | public ItemViewHolder(View itemView) {
33 | super(itemView);
34 | this.text = (TextView) itemView.findViewById(R.id.text);
35 | this.image = (ImageView) itemView.findViewById(R.id.image);
36 | }
37 | }
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
16 |
17 |
23 |
24 |
30 |
31 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_long_page.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
11 |
12 |
17 |
18 |
23 |
24 |
29 |
30 |
35 |
36 |
37 |
42 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/app/src/main/java/com/shizhefei/mutitypedemo/activity/longpagelazy/FoodLazyFragment.java:
--------------------------------------------------------------------------------
1 | package com.shizhefei.mutitypedemo.activity.longpagelazy;
2 |
3 | import android.os.Bundle;
4 | import android.support.v7.widget.GridLayoutManager;
5 | import android.support.v7.widget.RecyclerView;
6 | import android.util.Log;
7 |
8 | import com.shizhefei.fragment.LazyFragment;
9 | import com.shizhefei.mutitypedemo.R;
10 | import com.shizhefei.mutitypedemo.type.Food;
11 | import com.shizhefei.view.multitype.ItemBinderFactory;
12 | import com.shizhefei.view.multitype.MultiTypeAdapter;
13 |
14 | import java.util.ArrayList;
15 | import java.util.List;
16 |
17 | /**
18 | * Created by LuckyJayce on 2016/8/8.
19 | */
20 | public class FoodLazyFragment extends LazyFragment {
21 | private RecyclerView recyclerView;
22 |
23 | @Override
24 | protected void onCreateViewLazy(Bundle savedInstanceState) {
25 | super.onCreateViewLazy(savedInstanceState);
26 | setContentView(R.layout.fragment_food);
27 | recyclerView = (RecyclerView) findViewById(R.id.recyclerView);
28 | recyclerView.setLayoutManager(new GridLayoutManager(getContext(), 3));
29 |
30 | recyclerView.setAdapter(new MultiTypeAdapter