├── .gitignore ├── .idea ├── .name ├── compiler.xml ├── copyright │ └── profiles_settings.xml ├── encodings.xml ├── gradle.xml ├── libraries │ ├── appcompat_v7_23_1_1.xml │ ├── design_23_1_1.xml │ ├── hamcrest_core_1_3.xml │ ├── junit_4_12.xml │ ├── recyclerview_v7_23_1_0.xml │ ├── recyclerview_v7_23_1_1.xml │ ├── support_annotations_23_1_1.xml │ ├── support_v4_23_1_1.xml │ └── ultra_ptr_1_0_11.xml ├── misc.xml ├── modules.xml ├── runConfigurations.xml ├── vcs.xml └── workspace.xml ├── LICENSE ├── README.md ├── RecyclerViewManager.iml ├── app ├── .gitignore ├── app.iml ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── space │ │ └── sye │ │ └── z │ │ └── recyclerviewmanager │ │ └── ApplicationTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── space │ │ │ └── sye │ │ │ └── z │ │ │ └── recyclerviewmanager │ │ │ └── MainActivity.java │ └── res │ │ ├── layout │ │ ├── activity_main.xml │ │ ├── content_main.xml │ │ ├── recycler_footer.xml │ │ ├── recycler_header.xml │ │ ├── recycler_header2.xml │ │ └── recycler_item.xml │ │ ├── menu │ │ └── menu_main.xml │ │ ├── mipmap-hdpi │ │ ├── header1.jpg │ │ ├── ic_launcher.png │ │ └── sye.jpg │ │ ├── mipmap-mdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxxhdpi │ │ └── ic_launcher.png │ │ ├── values-v21 │ │ └── styles.xml │ │ ├── values-w820dp │ │ └── dimens.xml │ │ └── values │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── space │ └── sye │ └── z │ └── recyclerviewmanager │ └── ExampleUnitTest.java ├── background_hd.jpg ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── library ├── .gitignore ├── build.gradle ├── library.iml ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── space │ │ └── sye │ │ └── z │ │ └── library │ │ └── ApplicationTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── space │ │ │ └── sye │ │ │ └── z │ │ │ └── library │ │ │ ├── RefreshRecyclerView.java │ │ │ ├── adapter │ │ │ └── RefreshRecyclerViewAdapter.java │ │ │ ├── holder │ │ │ └── RecyclerHeaderViewHolder.java │ │ │ ├── listener │ │ │ ├── LoadMoreRecyclerListener.java │ │ │ ├── OnBothRefreshListener.java │ │ │ ├── OnLoadMoreListener.java │ │ │ └── OnPullDownListener.java │ │ │ ├── manager │ │ │ ├── HeaderSapnSizeLookUp.java │ │ │ ├── RecyclerMode.java │ │ │ ├── RecyclerViewManager.java │ │ │ └── RefreshRecyclerAdapterManager.java │ │ │ └── widget │ │ │ ├── FlipLoadingLayout.java │ │ │ ├── RefreshHeader.java │ │ │ ├── RefreshLoadingLayout.java │ │ │ └── RotateLoadingLayout.java │ └── res │ │ ├── layout │ │ ├── header_refresh.xml │ │ └── loadinglayout.xml │ │ ├── mipmap-hdpi │ │ ├── default_ptr_flip.png │ │ ├── default_ptr_rotate.png │ │ ├── indicator_arrow.png │ │ └── refresh_complete.png │ │ └── values │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── space │ └── sye │ └── z │ └── library │ └── ExampleUnitTest.java └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | # Built application files 2 | *.apk 3 | *.ap_ 4 | 5 | # Files for the Dalvik VM 6 | *.dex 7 | 8 | # Java class files 9 | *.class 10 | 11 | # Generated files 12 | bin/ 13 | gen/ 14 | 15 | # Gradle files 16 | .gradle/ 17 | build/ 18 | /*/build/ 19 | 20 | # Local configuration file (sdk path, etc) 21 | local.properties 22 | 23 | # Proguard folder generated by Eclipse 24 | proguard/ 25 | 26 | # Log Files 27 | *.log 28 | -------------------------------------------------------------------------------- /.idea/.name: -------------------------------------------------------------------------------- 1 | RecyclerViewManager -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 24 | 25 | -------------------------------------------------------------------------------- /.idea/libraries/appcompat_v7_23_1_1.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /.idea/libraries/design_23_1_1.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /.idea/libraries/hamcrest_core_1_3.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.idea/libraries/junit_4_12.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.idea/libraries/recyclerview_v7_23_1_0.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /.idea/libraries/recyclerview_v7_23_1_1.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /.idea/libraries/support_annotations_23_1_1.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/libraries/support_v4_23_1_1.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /.idea/libraries/ultra_ptr_1_0_11.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 19 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 46 | 47 | 48 | 49 | 50 | 1.8 51 | 52 | 57 | 58 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | The MIT License (MIT) 3 | 4 | Copyright (c) 2015 Gordon Wong 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in all 14 | copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | SOFTWARE. 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # RecyclerViewManager 2 | RecyclerViewManager supports PullToRefresh and LoadMore, U can also add headers or footers for RecyclerView. 3 | Also supports onItemClickEvent. 4 | 5 | Use setMode() if you want it PullDown or LoadMore only. 6 | With RecyclerMode.PullDown replace setOnRefreshListener() to setOnPullDownListener(), and use setOnLoadMoreListener() in the same way. 7 | ```groovy 8 | allprojects { 9 | repositories { 10 | jcenter() 11 | maven { url "https://jitpack.io" } 12 | } 13 | } 14 | 15 | dependencies { 16 | compile 'com.github.Syehunter:RecyclerViewManager:0.1.7' 17 | } 18 | ``` 19 | ![RecyclerViewManagerDemo.gif](http://7xn4z4.com1.z0.glb.clouddn.com/RecyclerViewManager.gif) 20 | 21 | Layout: 22 | ```xml 23 | 27 | ``` 28 | 29 | Usage in Activity or some others: 30 | ```java 31 | recyclerView = (RefreshRecyclerView) findViewById(R.id.recyclerView); 32 | MyAdapter myAdapter = new MyAdapter(); //a RecyclerView.Adapter 33 | 34 | RecyclerViewManager.with(myAdapter, new LinearLayoutManager(this)) 35 | .setMode(RecyclerMode.BOTH) 36 | .addHeaderView(header) 37 | .addHeaderView(header2) 38 | .addFooterView(footer) 39 | .setOnBothRefreshListener(new OnBothRefreshListener() { 40 | @Override 41 | public void onPullDown() { 42 | //模拟网络请求 43 | Message msg = new Message(); 44 | msg.what = PULL_DOWN; 45 | mHandler.sendMessageDelayed(msg, 2000); 46 | } 47 | 48 | @Override 49 | public void onLoadMore() { 50 | //模拟网络请求 51 | Message msg = new Message(); 52 | msg.what = LOAD_MORE; 53 | mHandler.sendMessageDelayed(msg, 2000); 54 | } 55 | }) 56 | .setOnItemClickListener(new RefreshRecyclerViewAdapter.OnItemClickListener() { 57 | @Override 58 | public void onItemClick(RecyclerView.ViewHolder holder, int position) { 59 | Toast.makeText(MainActivity.this, "item" + position, Toast.LENGTH_SHORT).show(); 60 | } 61 | }) 62 | .into(recyclerView, this); 63 | 64 | private Handler mHandler = new Handler(){ 65 | @Override 66 | public void handleMessage(Message msg) { 67 | switch (msg.what){ 68 | case PULL_DOWN: 69 | mDatas.add(0, "new Item"); 70 | break; 71 | case LOAD_MORE: 72 | for (int i = 0; i < 10; i++){ 73 | mDatas.add("item" + (counts + i)); 74 | } 75 | counts = counts + 10; 76 | break; 77 | } 78 | recyclerView.onRefreshCompleted(); 79 | mAdapter.notifyDataSetChanged(); 80 | } 81 | }; 82 | ``` 83 | Use recyclerView.real() to get the real RecyclerView if you want to use methods of it. 84 | 85 | Simple Introduction for RecyclerViewManager(Chinese): http://z.sye.space/2015/11/23/RecyclerViewManager/ 86 | -------------------------------------------------------------------------------- /RecyclerViewManager.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/app.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 8 | 9 | 10 | 11 | 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 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 23 5 | buildToolsVersion "23.0.2" 6 | 7 | defaultConfig { 8 | applicationId "space.sye.z.recyclerviewmanager" 9 | minSdkVersion 15 10 | targetSdkVersion 23 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(include: ['*.jar'], dir: 'libs') 24 | testCompile 'junit:junit:4.12' 25 | compile 'com.android.support:appcompat-v7:23.1.1' 26 | compile 'com.android.support:design:23.1.1' 27 | compile project(':library') 28 | } 29 | -------------------------------------------------------------------------------- /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 F:\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/androidTest/java/space/sye/z/recyclerviewmanager/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package space.sye.z.recyclerviewmanager; 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/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 11 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /app/src/main/java/space/sye/z/recyclerviewmanager/MainActivity.java: -------------------------------------------------------------------------------- 1 | package space.sye.z.recyclerviewmanager; 2 | 3 | import android.os.Bundle; 4 | import android.os.Handler; 5 | import android.os.Message; 6 | import android.support.v7.app.AppCompatActivity; 7 | import android.support.v7.widget.GridLayoutManager; 8 | import android.support.v7.widget.LinearLayoutManager; 9 | import android.support.v7.widget.RecyclerView; 10 | import android.support.v7.widget.StaggeredGridLayoutManager; 11 | import android.support.v7.widget.Toolbar; 12 | import android.view.LayoutInflater; 13 | import android.view.View; 14 | import android.view.Menu; 15 | import android.view.MenuItem; 16 | import android.view.ViewGroup; 17 | import android.widget.TextView; 18 | import android.widget.Toast; 19 | 20 | import java.util.ArrayList; 21 | 22 | import space.sye.z.library.adapter.RefreshRecyclerViewAdapter; 23 | import space.sye.z.library.listener.OnBothRefreshListener; 24 | import space.sye.z.library.listener.OnLoadMoreListener; 25 | import space.sye.z.library.listener.OnPullDownListener; 26 | import space.sye.z.library.manager.RecyclerMode; 27 | import space.sye.z.library.manager.RecyclerViewManager; 28 | import space.sye.z.library.RefreshRecyclerView; 29 | 30 | public class MainActivity extends AppCompatActivity { 31 | 32 | private ArrayList mDatas; 33 | private RefreshRecyclerView recyclerView; 34 | 35 | private static final int PULL_DOWN = 1; 36 | private static final int LOAD_MORE = 2; 37 | private int counts = 10; 38 | private MyAdapter myAdapter; 39 | private int page = 1; 40 | 41 | @Override 42 | protected void onCreate(Bundle savedInstanceState) { 43 | super.onCreate(savedInstanceState); 44 | setContentView(R.layout.activity_main); 45 | Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); 46 | setSupportActionBar(toolbar); 47 | 48 | mDatas = new ArrayList<>(); 49 | for (int i = 0; i < counts; i++){ 50 | mDatas.add("Item " + i); 51 | } 52 | 53 | View header = View.inflate(this, R.layout.recycler_header, null); 54 | View header2 = View.inflate(this, R.layout.recycler_header2, null); 55 | View footer = View.inflate(this, R.layout.recycler_footer, null); 56 | 57 | recyclerView = (RefreshRecyclerView) findViewById(R.id.recyclerView); 58 | myAdapter = new MyAdapter(); 59 | 60 | RecyclerViewManager.with(myAdapter, new LinearLayoutManager(this)) 61 | .setMode(RecyclerMode.BOTH) 62 | .addHeaderView(header) 63 | .addHeaderView(header2) 64 | .addFooterView(footer) 65 | .setOnBothRefreshListener(new OnBothRefreshListener() { 66 | @Override 67 | public void onPullDown() { 68 | //模拟网络请求 69 | Message msg = new Message(); 70 | msg.what = PULL_DOWN; 71 | mHandler.sendMessageDelayed(msg, 2000); 72 | } 73 | 74 | @Override 75 | public void onLoadMore() { 76 | //模拟网络请求 77 | if (page > 5) { 78 | //模拟共有5页数据 79 | Toast.makeText(MainActivity.this, "No more datas!", Toast.LENGTH_SHORT).show(); 80 | recyclerView.onRefreshCompleted(); 81 | return; 82 | } 83 | page++; 84 | Message msg = new Message(); 85 | msg.what = LOAD_MORE; 86 | mHandler.sendMessageDelayed(msg, 2000); 87 | } 88 | }) 89 | // .setOnPullDownListener(new OnPullDownListener() { 90 | // @Override 91 | // public void onPullDown() { 92 | // Message msg = new Message(); 93 | // msg.what = PULL_DOWN; 94 | // mHandler.sendMessageDelayed(msg, 2000); 95 | // } 96 | // }) 97 | // .setOnLoadMoreListener(new OnLoadMoreListener() { 98 | // @Override 99 | // public void onLoadMore() { 100 | // //模拟网络请求 101 | // if (page > 5) { 102 | // //模拟共有5页数据 103 | // Toast.makeText(MainActivity.this, "No more datas!", Toast.LENGTH_SHORT).show(); 104 | // recyclerView.onRefreshCompleted(); 105 | // return; 106 | // } 107 | // page++; 108 | // Message msg = new Message(); 109 | // msg.what = LOAD_MORE; 110 | // mHandler.sendMessageDelayed(msg, 2000); 111 | // } 112 | // }) 113 | .setOnItemClickListener(new RefreshRecyclerViewAdapter.OnItemClickListener() { 114 | @Override 115 | public void onItemClick(RecyclerView.ViewHolder holder, int position) { 116 | Toast.makeText(MainActivity.this, "item" + position, Toast.LENGTH_SHORT).show(); 117 | } 118 | }) 119 | .into(recyclerView, this); 120 | } 121 | 122 | private Handler mHandler = new Handler(){ 123 | @Override 124 | public void handleMessage(Message msg) { 125 | switch (msg.what){ 126 | case PULL_DOWN: 127 | mDatas.add(0, "new Item"); 128 | break; 129 | case LOAD_MORE: 130 | for (int i = 0; i < 10; i++){ 131 | mDatas.add("item" + (counts + i)); 132 | } 133 | counts += 10; 134 | break; 135 | } 136 | recyclerView.onRefreshCompleted(); 137 | myAdapter.notifyDataSetChanged(); 138 | } 139 | }; 140 | 141 | private class MyViewHolder extends RecyclerView.ViewHolder{ 142 | 143 | public TextView tv_item; 144 | 145 | public MyViewHolder(View itemView) { 146 | super(itemView); 147 | tv_item = (TextView) itemView.findViewById(R.id.tv_item); 148 | } 149 | 150 | } 151 | 152 | private class MyAdapter extends RecyclerView.Adapter{ 153 | 154 | @Override 155 | public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { 156 | View v = LayoutInflater.from(MainActivity.this). 157 | inflate(R.layout.recycler_item, parent, false); 158 | MyViewHolder holder = new MyViewHolder(v); 159 | return holder; 160 | } 161 | 162 | @Override 163 | public void onBindViewHolder(MyViewHolder holder, int position) { 164 | holder.tv_item.setText(mDatas.get(position)); 165 | } 166 | 167 | @Override 168 | public int getItemCount() { 169 | return mDatas.size(); 170 | } 171 | } 172 | 173 | @Override 174 | public boolean onCreateOptionsMenu(Menu menu) { 175 | // Inflate the menu; this adds items to the action bar if it is present. 176 | getMenuInflater().inflate(R.menu.menu_main, menu); 177 | return true; 178 | } 179 | 180 | @Override 181 | public boolean onOptionsItemSelected(MenuItem item) { 182 | // Handle action bar item clicks here. The action bar will 183 | // automatically handle clicks on the Home/Up button, so long 184 | // as you specify a parent activity in AndroidManifest.xml. 185 | int id = item.getItemId(); 186 | 187 | //noinspection SimplifiableIfStatement 188 | switch (id){ 189 | case R.id.action_linear: 190 | RecyclerViewManager.setLayoutManager(new LinearLayoutManager(this)); 191 | break; 192 | case R.id.action_grid: 193 | RecyclerViewManager.setLayoutManager(new GridLayoutManager(this, 3)); 194 | break; 195 | case R.id.action_staggered: 196 | RecyclerViewManager.setLayoutManager(new StaggeredGridLayoutManager( 197 | 2, StaggeredGridLayoutManager.VERTICAL)); 198 | break; 199 | } 200 | 201 | return super.onOptionsItemSelected(item); 202 | } 203 | } 204 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 14 | 15 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /app/src/main/res/layout/content_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 15 | 16 | -------------------------------------------------------------------------------- /app/src/main/res/layout/recycler_footer.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 15 | 16 | -------------------------------------------------------------------------------- /app/src/main/res/layout/recycler_header.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/layout/recycler_header2.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 13 | 14 | 21 | 22 | 28 | 29 | 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /app/src/main/res/layout/recycler_item.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 13 | 14 | -------------------------------------------------------------------------------- /app/src/main/res/menu/menu_main.xml: -------------------------------------------------------------------------------- 1 | 5 | 10 | 15 | 20 | 21 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/header1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syehunter/RecyclerViewManager/7baba7da7372c1fbf198afe65a6e374145473ccb/app/src/main/res/mipmap-hdpi/header1.jpg -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syehunter/RecyclerViewManager/7baba7da7372c1fbf198afe65a6e374145473ccb/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/sye.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syehunter/RecyclerViewManager/7baba7da7372c1fbf198afe65a6e374145473ccb/app/src/main/res/mipmap-hdpi/sye.jpg -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syehunter/RecyclerViewManager/7baba7da7372c1fbf198afe65a6e374145473ccb/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syehunter/RecyclerViewManager/7baba7da7372c1fbf198afe65a6e374145473ccb/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syehunter/RecyclerViewManager/7baba7da7372c1fbf198afe65a6e374145473ccb/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Syehunter/RecyclerViewManager/7baba7da7372c1fbf198afe65a6e374145473ccb/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/values-v21/styles.xml: -------------------------------------------------------------------------------- 1 | > 2 | 3 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 16dp 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | RecyclerViewManager 3 | Settings 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 15 | 16 | 6 | -------------------------------------------------------------------------------- /library/src/test/java/space/sye/z/library/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package space.sye.z.library; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * To work on unit tests, switch the Test Artifact in the Build Variants view. 9 | */ 10 | public class ExampleUnitTest { 11 | @Test 12 | public void addition_isCorrect() throws Exception { 13 | assertEquals(4, 2 + 2); 14 | } 15 | } -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app', ':library' 2 | --------------------------------------------------------------------------------