├── .gitignore ├── .travis.yml ├── LICENSE ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── app │ │ └── feng │ │ └── tablerecyclerview │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── app │ │ │ └── feng │ │ │ └── tablerecyclerview │ │ │ ├── FixTableAdapter.java │ │ │ ├── MainActivity.java │ │ │ └── bean │ │ │ └── DataBean.java │ └── res │ │ ├── drawable │ │ └── divider_bg.xml │ │ ├── layout │ │ └── activity_main.xml │ │ ├── mipmap-hdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-mdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ └── values │ │ ├── colors.xml │ │ ├── dimen.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── app │ └── feng │ └── tablerecyclerview │ └── ExampleUnitTest.java ├── build.gradle ├── cat1.gif ├── fixtablelayout ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── app │ │ └── feng │ │ └── fixtablelayout │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── app │ │ │ └── feng │ │ │ └── fixtablelayout │ │ │ ├── FixTableLayout.java │ │ │ ├── adapter │ │ │ └── TableAdapter.java │ │ │ ├── inter │ │ │ ├── IDataAdapter.java │ │ │ └── ILoadMoreListener.java │ │ │ └── widget │ │ │ ├── SingleLineItemDecoration.java │ │ │ ├── SingleLineLinearLayout.java │ │ │ ├── TableLayoutManager.java │ │ │ └── TextViewUtils.java │ └── res │ │ ├── drawable │ │ ├── shadow.xml │ │ └── shadow_rotate90.xml │ │ ├── layout │ │ └── table_view.xml │ │ └── values │ │ ├── attr_fixtable.xml │ │ └── dimens.xml │ └── test │ └── java │ └── com │ └── app │ └── feng │ └── fixtablelayout │ └── ExampleUnitTest.java ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea 5 | .DS_Store 6 | /build 7 | /captures 8 | .externalNativeBuild 9 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: android 2 | android: 3 | components: 4 | - tools 5 | - platform-tools 6 | - tools 7 | - build-tools-26.0.2 8 | - android-22 9 | - android-26 10 | - extra-android-m2repository 11 | - extra-android-support 12 | # 如果你需要使用模拟器测试编译出来的安装包,你需要最少添加一个系统镜像配置 13 | - sys-img-armeabi-v7a-android-22 14 | before_cache: 15 | - rm -f $HOME/.gradle/caches/modules-2/modules-2.lock 16 | - rm -fr $HOME/.gradle/caches/*/plugin-resolution/ 17 | # Emulator Management: Create, Start and Wait 18 | before_script: 19 | - echo no | android create avd --force -n test -t android-22 --abi armeabi-v7a 20 | - emulator -avd test -no-audio -no-window & 21 | - android-wait-for-emulator 22 | - adb shell input keyevent 82 & 23 | - chmod 777 gradlew 24 | cache: 25 | directories: 26 | - $HOME/.gradle/caches/ 27 | - $HOME/.gradle/wrapper/ 28 | - $HOME/.android/build-cache 29 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 余锋 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # TableRecylerView 2 | 3 | [![](https://jitpack.io/v/HYY-yu/TableRecyclerView.svg)](https://jitpack.io/#HYY-yu/TableRecyclerView) 4 | [![Build Status](https://travis-ci.org/HYY-yu/TableRecyclerView.svg?branch=master)](https://travis-ci.org/HYY-yu/TableRecyclerView) 5 | --- 6 | LayoutManager实现的大表格控件, 初步实现效果,欢迎issues和fork 7 | --- 8 | ![github](https://github.com/HYY-yu/TableRecylerView/blob/master/cat1.gif "show") 9 | 10 | **自定义属性:** 11 | 12 | 名称|格式|介绍 13 | ----|----|---- 14 | fixtable divider_color| format="color"| 表格分割线颜色 15 | fixtable divider_height| format="dimension" |表格分割线高度 16 | fixtable column-1_color" |format="color" |每隔一行就绘制此颜色作为行背景 17 | fixtable column-2_color" |format="color" |每隔一行就绘制此颜色作为行背景 18 | fixtable title_color" |format="color" |标题背景色 19 | fixtable item_width" |format="dimension" | item 宽 如果item显示不全,加大此值 20 | fixtable item-top-bottom_padding" |format="dimension" |可以控制item竖直方向的高度 21 | fixtable item_gravity" |format="enum" |枚举值 LEFT CENTER RIGHT 22 | fixtable show-left-view_shadow"| format="boolean" |是否显示leftView的阴影 23 | 24 | **使用** 25 | --- 26 | 在工程的build.gradle下添加: 27 | ``` 28 | allprojects { 29 | repositories { 30 | ... 31 | maven { url 'https://jitpack.io' } 32 | } 33 | } 34 | ``` 35 | 36 | 在项目的build.gradle下: 37 | ```compile 'com.github.HYY-yu:TableRecyclerView:v1.0.0'``` 38 | 39 | **示例代码** 40 | --- 41 | ``` 42 | // 一定要设置Adapter 否则看不到TableLayout 43 | final FixTableAdapter fixTableAdapter = new FixTableAdapter(title,data); 44 | fixTableLayout.setAdapter(fixTableAdapter); 45 | 46 | //LoadMoreData如果要打开 请在setAdapter之后 47 | fixTableLayout.enableLoadMoreData(); 48 | ``` 49 | 50 | **todo** 51 | --- 52 | - [ ] 可定制leftView的列数 53 | - [ ] 可自由修改表格中每列的宽度 54 | - [x] 支持gradle的导入方式 55 | 56 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 26 5 | buildToolsVersion '26.0.2' 6 | defaultConfig { 7 | applicationId "com.app.feng.tablerecyclerview" 8 | minSdkVersion 16 9 | targetSdkVersion 26 10 | versionCode 1 11 | versionName "1.0" 12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 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 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 25 | exclude group: 'com.android.support', module: 'support-annotations' 26 | }) 27 | compile 'com.android.support:appcompat-v7:26.1.0' 28 | compile 'com.android.support.constraint:constraint-layout:1.0.2' 29 | testCompile 'junit:junit:4.12' 30 | compile project(':fixtablelayout') 31 | } 32 | -------------------------------------------------------------------------------- /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\android-sdk-windows/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 | 19 | # Uncomment this to preserve the line number information for 20 | # debugging stack traces. 21 | #-keepattributes SourceFile,LineNumberTable 22 | 23 | # If you keep the line number information, uncomment this to 24 | # hide the original source file name. 25 | #-renamesourcefileattribute SourceFile 26 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/app/feng/tablerecyclerview/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.app.feng.tablerecyclerview; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumentation test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() throws Exception { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("com.app.feng.tablerecyclerview",appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /app/src/main/java/com/app/feng/tablerecyclerview/FixTableAdapter.java: -------------------------------------------------------------------------------- 1 | package com.app.feng.tablerecyclerview; 2 | 3 | import android.widget.TextView; 4 | 5 | import com.app.feng.fixtablelayout.inter.IDataAdapter; 6 | import com.app.feng.tablerecyclerview.bean.DataBean; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * Created by feng on 2017/4/4. 12 | */ 13 | 14 | public class FixTableAdapter implements IDataAdapter { 15 | 16 | public String[] titles; 17 | 18 | public List data; 19 | 20 | public FixTableAdapter(String[] titles,List data) { 21 | this.titles = titles; 22 | this.data = data; 23 | } 24 | 25 | public void setData(List data) { 26 | this.data = data; 27 | } 28 | 29 | @Override 30 | public String getTitleAt(int pos) { 31 | return titles[pos]; 32 | } 33 | 34 | @Override 35 | public int getTitleCount() { 36 | return titles.length; 37 | } 38 | 39 | @Override 40 | public int getItemCount() { 41 | return data.size(); 42 | } 43 | 44 | @Override 45 | public void convertData(int position,List bindViews) { 46 | DataBean dataBean = data.get(position); 47 | 48 | bindViews.get(0) 49 | .setText(dataBean.id); 50 | bindViews.get(1) 51 | .setText(dataBean.data1); 52 | bindViews.get(2) 53 | .setText(dataBean.data2); 54 | bindViews.get(3) 55 | .setText(dataBean.data3); 56 | bindViews.get(4) 57 | .setText(dataBean.data4); 58 | bindViews.get(5) 59 | .setText(dataBean.data5); 60 | bindViews.get(6) 61 | .setText(dataBean.data6); 62 | bindViews.get(7) 63 | .setText(dataBean.data7); 64 | bindViews.get(8) 65 | .setText(dataBean.data8); 66 | 67 | } 68 | 69 | @Override 70 | public void convertLeftData(int position,TextView bindView) { 71 | bindView.setText(data.get(position).id); 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /app/src/main/java/com/app/feng/tablerecyclerview/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.app.feng.tablerecyclerview; 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.util.Log; 8 | 9 | import com.app.feng.fixtablelayout.FixTableLayout; 10 | import com.app.feng.fixtablelayout.inter.ILoadMoreListener; 11 | import com.app.feng.tablerecyclerview.bean.DataBean; 12 | 13 | import java.util.ArrayList; 14 | import java.util.List; 15 | 16 | public class MainActivity extends AppCompatActivity { 17 | 18 | public String[] title = {"title1","title2","title3","title4","title5","title6","title7", 19 | "title8","title9"}; 20 | 21 | public List data = new ArrayList<>(); 22 | 23 | public String[][] dataCopy = { 24 | {"dataadd1","dataadd2","dataadd3","dataadd4","dataadd5","dataadd6","dataadd7", 25 | "dataadd8","dataadd9"}}; 26 | 27 | int currentPage = 1; 28 | int totalPage = 5; 29 | 30 | @Override 31 | protected void onCreate(Bundle savedInstanceState) { 32 | super.onCreate(savedInstanceState); 33 | setContentView(R.layout.activity_main); 34 | 35 | for (int i = 0; i < 80; i++) { 36 | data.add(new DataBean("id__","data1","data2","data3","data4","data5","data6","data7", 37 | "data8")); 38 | } 39 | 40 | final FixTableLayout fixTableLayout = (FixTableLayout) findViewById(R.id.fixTableLayout); 41 | 42 | // 一定要设置Adapter 否则看不到TableLayout 43 | final FixTableAdapter fixTableAdapter = new FixTableAdapter(title,data); 44 | fixTableLayout.setAdapter(fixTableAdapter); 45 | 46 | //LoadMoreData如果要设置 请在setAdapter之后 47 | fixTableLayout.enableLoadMoreData(); 48 | 49 | fixTableLayout.setLoadMoreListener(new ILoadMoreListener() { 50 | @Override 51 | public void loadMoreData(final Message message) { 52 | Log.i("feng"," 加载更多 Data --- "); 53 | // 请自己开启线程加载数据,并通过message发送给fixTableLayout 54 | new Thread(new Runnable() { 55 | @Override 56 | public void run() { 57 | if (currentPage <= totalPage) { 58 | for (int i = 0; i < 50; i++) { 59 | data.add(new DataBean("update_id","update_data","data2","data3","data4","data5", 60 | "data6","data7","data8")); 61 | } 62 | currentPage++; 63 | message.arg1 = 50; // 更新了50条数据 64 | } else { 65 | message.arg1 = 0; 66 | } 67 | message.sendToTarget(); 68 | } 69 | }).start(); 70 | } 71 | }); 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /app/src/main/java/com/app/feng/tablerecyclerview/bean/DataBean.java: -------------------------------------------------------------------------------- 1 | package com.app.feng.tablerecyclerview.bean; 2 | 3 | /** 4 | * Created by feng on 2017/4/10. 5 | */ 6 | 7 | public class DataBean { 8 | public String id; 9 | public String data1; 10 | public String data2; 11 | public String data3; 12 | public String data4; 13 | public String data5; 14 | public String data6; 15 | public String data7; 16 | public String data8; 17 | 18 | public DataBean( 19 | String id,String data1,String data2,String data3,String data4,String data5,String data6, 20 | String data7,String data8) { 21 | this.id = id; 22 | this.data1 = data1; 23 | this.data2 = data2; 24 | this.data3 = data3; 25 | this.data4 = data4; 26 | this.data5 = data5; 27 | this.data6 = data6; 28 | this.data7 = data7; 29 | this.data8 = data8; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/divider_bg.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HYY-yu/TableRecyclerView/e4c987af8f7b6f750e4bdbe2395fc6ca8c083c6f/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HYY-yu/TableRecyclerView/e4c987af8f7b6f750e4bdbe2395fc6ca8c083c6f/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HYY-yu/TableRecyclerView/e4c987af8f7b6f750e4bdbe2395fc6ca8c083c6f/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HYY-yu/TableRecyclerView/e4c987af8f7b6f750e4bdbe2395fc6ca8c083c6f/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HYY-yu/TableRecyclerView/e4c987af8f7b6f750e4bdbe2395fc6ca8c083c6f/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HYY-yu/TableRecyclerView/e4c987af8f7b6f750e4bdbe2395fc6ca8c083c6f/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HYY-yu/TableRecyclerView/e4c987af8f7b6f750e4bdbe2395fc6ca8c083c6f/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HYY-yu/TableRecyclerView/e4c987af8f7b6f750e4bdbe2395fc6ca8c083c6f/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HYY-yu/TableRecyclerView/e4c987af8f7b6f750e4bdbe2395fc6ca8c083c6f/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HYY-yu/TableRecyclerView/e4c987af8f7b6f750e4bdbe2395fc6ca8c083c6f/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | #b1b1b1 8 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimen.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 1dp 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | TableRecyclerView 3 | 4 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/test/java/com/app/feng/tablerecyclerview/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.app.feng.tablerecyclerview; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() throws Exception { 15 | assertEquals(4,2 + 2); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | jcenter() 6 | google() 7 | } 8 | dependencies { 9 | classpath 'com.android.tools.build:gradle:3.0.0-beta7' 10 | 11 | // NOTE: Do not place your application dependencies here; they belong 12 | // in the individual module build.gradle files 13 | classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5' 14 | } 15 | } 16 | 17 | allprojects { 18 | repositories { 19 | jcenter() 20 | google() 21 | } 22 | } 23 | 24 | task clean(type: Delete) { 25 | delete rootProject.buildDir 26 | } 27 | -------------------------------------------------------------------------------- /cat1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HYY-yu/TableRecyclerView/e4c987af8f7b6f750e4bdbe2395fc6ca8c083c6f/cat1.gif -------------------------------------------------------------------------------- /fixtablelayout/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /fixtablelayout/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | android { 4 | compileSdkVersion 26 5 | buildToolsVersion '26.0.2' 6 | 7 | defaultConfig { 8 | minSdkVersion 16 9 | targetSdkVersion 26 10 | versionCode 1 11 | versionName "1.0" 12 | 13 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 14 | 15 | } 16 | buildTypes { 17 | release { 18 | minifyEnabled false 19 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 20 | } 21 | } 22 | } 23 | 24 | dependencies { 25 | compile fileTree(dir: 'libs', include: ['*.jar']) 26 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 27 | exclude group: 'com.android.support', module: 'support-annotations' 28 | }) 29 | compile 'com.android.support:appcompat-v7:26.1.0' 30 | compile 'com.android.support.constraint:constraint-layout:1.0.2' 31 | compile 'com.android.support:recyclerview-v7:26.1.0' 32 | 33 | testCompile 'junit:junit:4.12' 34 | } 35 | 36 | /** 以下开始是将Android Library上传到jitPack的相关配置**/ 37 | 38 | apply plugin: 'com.github.dcendents.android-maven' 39 | 40 | group='com.github.HYY-yu' 41 | -------------------------------------------------------------------------------- /fixtablelayout/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\android-sdk-windows/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 | 19 | # Uncomment this to preserve the line number information for 20 | # debugging stack traces. 21 | #-keepattributes SourceFile,LineNumberTable 22 | 23 | # If you keep the line number information, uncomment this to 24 | # hide the original source file name. 25 | #-renamesourcefileattribute SourceFile 26 | -------------------------------------------------------------------------------- /fixtablelayout/src/androidTest/java/com/app/feng/fixtablelayout/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.app.feng.fixtablelayout; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumentation test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() throws Exception { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("com.app.feng.fixtablelayout.test",appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /fixtablelayout/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /fixtablelayout/src/main/java/com/app/feng/fixtablelayout/FixTableLayout.java: -------------------------------------------------------------------------------- 1 | package com.app.feng.fixtablelayout; 2 | 3 | import android.content.Context; 4 | import android.content.res.TypedArray; 5 | import android.graphics.Color; 6 | import android.os.Handler; 7 | import android.os.Message; 8 | import android.support.annotation.Nullable; 9 | import android.support.v4.content.res.TypedArrayUtils; 10 | import android.support.v7.widget.RecyclerView; 11 | import android.util.AttributeSet; 12 | import android.util.TypedValue; 13 | import android.view.Gravity; 14 | import android.view.MotionEvent; 15 | import android.view.View; 16 | import android.widget.FrameLayout; 17 | import android.widget.HorizontalScrollView; 18 | import android.widget.TextView; 19 | 20 | import com.app.feng.fixtablelayout.adapter.TableAdapter; 21 | import com.app.feng.fixtablelayout.inter.IDataAdapter; 22 | import com.app.feng.fixtablelayout.inter.ILoadMoreListener; 23 | import com.app.feng.fixtablelayout.widget.SingleLineItemDecoration; 24 | import com.app.feng.fixtablelayout.widget.TableLayoutManager; 25 | 26 | import java.lang.ref.WeakReference; 27 | 28 | /** 29 | * Created by feng on 2017/4/2. 30 | */ 31 | public class FixTableLayout extends FrameLayout { 32 | public static final int MESSAGE_FIX_TABLE_LOAD_COMPLETE = 1001; 33 | 34 | RecyclerView recyclerView; 35 | HorizontalScrollView titleView; 36 | RecyclerView leftViews; 37 | TextView left_top_view; 38 | View leftViewShadow; 39 | FrameLayout fl_load_mask; 40 | 41 | int divider_height; 42 | int divider_color; 43 | int col_1_color; 44 | int col_2_color; 45 | int title_color; 46 | int item_width; 47 | int item_padding; 48 | int item_gravity; 49 | 50 | boolean show_left_shadow = false; 51 | private IDataAdapter dataAdapter; 52 | 53 | private boolean isLoading = false; 54 | private ILoadMoreListener loadMoreListener; 55 | private boolean hasMoreData = true; 56 | 57 | public FixTableLayout(Context context) { 58 | this(context, null); 59 | } 60 | 61 | public FixTableLayout( 62 | Context context, @Nullable AttributeSet attrs) { 63 | this(context, attrs, 0); 64 | } 65 | 66 | public FixTableLayout(Context context, @Nullable AttributeSet attrs, int defStyleAttr) { 67 | super(context, attrs, defStyleAttr); 68 | 69 | TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.FixTableLayout); 70 | 71 | divider_height = array.getDimensionPixelOffset( 72 | R.styleable.FixTableLayout_fixtable_divider_height, 73 | getResources().getDimensionPixelOffset(R.dimen.divider_default_value)); 74 | divider_color = array.getColor(R.styleable.FixTableLayout_fixtable_divider_color, 75 | Color.BLACK); 76 | col_1_color = array.getColor(R.styleable.FixTableLayout_fixtable_column_1_color, 77 | Color.WHITE); 78 | col_2_color = array.getColor(R.styleable.FixTableLayout_fixtable_column_2_color, 79 | Color.WHITE); 80 | title_color = array.getColor(R.styleable.FixTableLayout_fixtable_title_color, Color.GRAY); 81 | item_width = array.getDimensionPixelOffset(R.styleable.FixTableLayout_fixtable_item_width, 82 | getResources().getDimensionPixelOffset(R.dimen.item_width_default_value)); 83 | item_padding = array.getDimensionPixelOffset( 84 | R.styleable.FixTableLayout_fixtable_item_top_bottom_padding, 0); 85 | item_gravity = array.getInteger(R.styleable.FixTableLayout_fixtable_item_gravity, 0); 86 | 87 | switch (item_gravity) { 88 | case 0: 89 | item_gravity = Gravity.CENTER; 90 | break; 91 | case 1: 92 | item_gravity = Gravity.START | Gravity.CENTER_VERTICAL; 93 | break; 94 | case 2: 95 | item_gravity = Gravity.END | Gravity.CENTER_VERTICAL; 96 | break; 97 | } 98 | 99 | show_left_shadow = array.getBoolean( 100 | R.styleable.FixTableLayout_fixtable_show_left_view_shadow, false); 101 | 102 | array.recycle(); 103 | 104 | View view = inflate(context, R.layout.table_view, null); 105 | init(view); 106 | addView(view); 107 | } 108 | 109 | private void init(View view) { 110 | recyclerView = (RecyclerView) view.findViewById(R.id.recyclerView); 111 | titleView = (HorizontalScrollView) view.findViewById(R.id.titleView); 112 | leftViews = (RecyclerView) view.findViewById(R.id.leftViews); 113 | left_top_view = (TextView) view.findViewById(R.id.left_top_view); 114 | leftViewShadow = view.findViewById(R.id.leftView_shadows); 115 | fl_load_mask = (FrameLayout) view.findViewById(R.id.load_mask); 116 | 117 | TableLayoutManager t1 = new TableLayoutManager(); 118 | TableLayoutManager t2 = new TableLayoutManager(); 119 | 120 | // Log.i("feng"," -- t : " + t1.toString().substring(54) + " t_left: " + t2.toString() 121 | // .substring(54)); 122 | 123 | recyclerView.setLayoutManager(t1); 124 | leftViews.setLayoutManager(t2); 125 | 126 | leftViews.setOnTouchListener(new OnTouchListener() { 127 | @Override 128 | public boolean onTouch(View v, MotionEvent event) { 129 | //将事件发送到RV 130 | recyclerView.onTouchEvent(event); 131 | return true; 132 | } 133 | }); 134 | 135 | titleView.setOnTouchListener(new OnTouchListener() { 136 | @Override 137 | public boolean onTouch(View v, MotionEvent event) { 138 | recyclerView.onTouchEvent(event); 139 | return true; 140 | } 141 | }); 142 | 143 | if (show_left_shadow) { 144 | leftViewShadow.setVisibility(VISIBLE); 145 | } else { 146 | leftViewShadow.setVisibility(GONE); 147 | } 148 | 149 | SingleLineItemDecoration itemDecoration = new SingleLineItemDecoration(divider_height, divider_color); 150 | 151 | leftViews.addItemDecoration(itemDecoration); 152 | recyclerView.addItemDecoration(itemDecoration); 153 | 154 | //titleView 只做横向滚动 leftView 只做纵向滚动 155 | recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() { 156 | 157 | @Override 158 | public void onScrolled(RecyclerView recyclerView, int dx, int dy) { 159 | titleView.scrollBy(dx, 0); 160 | leftViews.scrollBy(0, dy); 161 | } 162 | }); 163 | 164 | } 165 | 166 | public void setAdapter(IDataAdapter dataAdapter) { 167 | this.dataAdapter = dataAdapter; 168 | initRecyclerViewAdapter(); 169 | } 170 | 171 | int lastVisablePos = -1; 172 | FixTableHandler fixTableHandler; 173 | 174 | public void enableLoadMoreData() { 175 | fixTableHandler = new FixTableHandler(FixTableLayout.this, recyclerView); 176 | 177 | recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() { 178 | @Override 179 | public void onScrollStateChanged(RecyclerView recyclerView, int newState) { 180 | super.onScrollStateChanged(recyclerView, newState); 181 | // 当用户滑动到底部并且使用fling手势 182 | if (!isLoading && hasMoreData && 183 | newState == RecyclerView.SCROLL_STATE_IDLE && 184 | lastVisablePos == recyclerView.getAdapter().getItemCount() - 1) { 185 | 186 | isLoading = true; 187 | fl_load_mask.setVisibility(VISIBLE); 188 | 189 | if (loadMoreListener != null) { 190 | loadMoreListener.loadMoreData( 191 | fixTableHandler.obtainMessage(FixTableLayout.MESSAGE_FIX_TABLE_LOAD_COMPLETE)); 192 | } 193 | } 194 | // Log.i("feng","滑动到底部 -- 此时的View Bottom:" + recyclerView.getLayoutManager() 195 | // .getDecoratedBottom 196 | // (bottomView) + " recyclerView Height:" +recyclerView.getHeight()); 197 | 198 | } 199 | 200 | @Override 201 | public void onScrolled(RecyclerView recyclerView, int dx, int dy) { 202 | super.onScrolled(recyclerView, dx, dy); 203 | View bottomView = recyclerView.getChildAt(recyclerView.getChildCount() - 1); 204 | lastVisablePos = recyclerView.getChildAdapterPosition(bottomView); 205 | } 206 | }); 207 | } 208 | 209 | /** 210 | * 只有 enableLoadMoreData()被执行此方法设置才有效果 211 | * @param loadMoreListener 212 | */ 213 | public void setLoadMoreListener(ILoadMoreListener loadMoreListener) { 214 | this.loadMoreListener = loadMoreListener; 215 | } 216 | 217 | private void initRecyclerViewAdapter() { 218 | TableAdapter.Builder builder = new TableAdapter.Builder(); 219 | TableAdapter tableAdapter = builder.setLeft_top_view(left_top_view) 220 | .setTitleView(titleView) 221 | .setParametersHolder( 222 | new TableAdapter.ParametersHolder(col_1_color, col_2_color, title_color, 223 | item_width, item_padding, item_gravity)) 224 | .setLeftViews(leftViews) 225 | .setDataAdapter(dataAdapter) 226 | .create(); 227 | 228 | recyclerView.setAdapter(tableAdapter); 229 | } 230 | 231 | public void dataUpdate() { 232 | TableAdapter tableAdapter = (TableAdapter) recyclerView.getAdapter(); 233 | tableAdapter.notifyLoadData(); 234 | } 235 | 236 | private static class FixTableHandler extends Handler { 237 | WeakReference recyclerViewWeakReference; 238 | WeakReference fixTableLayoutWeakReference; 239 | 240 | FixTableHandler(FixTableLayout fixTableLayout, RecyclerView recyclerView) { 241 | recyclerViewWeakReference = new WeakReference<>(recyclerView); 242 | fixTableLayoutWeakReference = new WeakReference<>(fixTableLayout); 243 | } 244 | 245 | @Override 246 | public void handleMessage(Message msg) { 247 | if (msg.what == MESSAGE_FIX_TABLE_LOAD_COMPLETE) { 248 | RecyclerView recyclerView = recyclerViewWeakReference.get(); 249 | FixTableLayout fixTableLayout = fixTableLayoutWeakReference.get(); 250 | 251 | TableAdapter tableAdapter = (TableAdapter) recyclerView.getAdapter(); 252 | int startPos = tableAdapter.getItemCount() - 1; 253 | int loadNum = msg.arg1; 254 | if (loadNum > 0) { 255 | //通知Adapter更新数据 256 | tableAdapter.notifyLoadData(); 257 | 258 | // Log.i("fixtablelayout","load more completed loadNum :" + loadNum + "scrollTo " + 259 | // ":" + fixTableLayout.lastVisableMask); 260 | 261 | } else { 262 | //没有数据了 263 | fixTableLayout.hasMoreData = false; 264 | } 265 | 266 | fixTableLayout.fl_load_mask.setVisibility(GONE); 267 | fixTableLayout.isLoading = false; 268 | } 269 | } 270 | } 271 | } 272 | -------------------------------------------------------------------------------- /fixtablelayout/src/main/java/com/app/feng/fixtablelayout/adapter/TableAdapter.java: -------------------------------------------------------------------------------- 1 | package com.app.feng.fixtablelayout.adapter; 2 | 3 | import android.support.v7.widget.RecyclerView; 4 | import android.view.View; 5 | import android.view.ViewGroup; 6 | import android.widget.HorizontalScrollView; 7 | import android.widget.TextView; 8 | 9 | import com.app.feng.fixtablelayout.inter.IDataAdapter; 10 | import com.app.feng.fixtablelayout.widget.SingleLineLinearLayout; 11 | import com.app.feng.fixtablelayout.widget.TextViewUtils; 12 | 13 | import java.util.ArrayList; 14 | import java.util.List; 15 | 16 | 17 | /** 18 | * Created by feng on 2017/3/28. 19 | */ 20 | 21 | public class TableAdapter extends RecyclerView.Adapter { 22 | 23 | private HorizontalScrollView titleView; 24 | private RecyclerView leftViews; 25 | private TextView left_top_view; 26 | 27 | private ParametersHolder parametersHolder; 28 | 29 | private IDataAdapter dataAdapter; 30 | 31 | private TableAdapter( 32 | HorizontalScrollView titleView, RecyclerView leftViews, TextView left_top_view, 33 | ParametersHolder parametersHolder, IDataAdapter dataAdapter) { 34 | super(); 35 | this.titleView = titleView; 36 | this.leftViews = leftViews; 37 | this.left_top_view = left_top_view; 38 | this.parametersHolder = parametersHolder; 39 | this.dataAdapter = dataAdapter; 40 | 41 | initViews(); 42 | } 43 | 44 | private void initViews() { 45 | left_top_view.setBackgroundColor(parametersHolder.title_color); 46 | TextViewUtils.setTextView(left_top_view, dataAdapter.getTitleAt(0), parametersHolder.item_gravity, 47 | parametersHolder.item_width, parametersHolder.item_padding); 48 | 49 | leftViews.setAdapter(new LeftViewAdapter()); 50 | 51 | SingleLineLinearLayout titleChild = ((SingleLineLinearLayout) titleView.getChildAt(0)); 52 | 53 | for (int i = 0; i < dataAdapter.getTitleCount(); i++) { 54 | TextView textView = TextViewUtils.generateTextView(titleChild.getContext(), 55 | dataAdapter.getTitleAt(i), 56 | parametersHolder.item_gravity, 57 | parametersHolder.item_width, 58 | parametersHolder.item_padding); 59 | 60 | titleChild.addView(textView, i); 61 | } 62 | titleChild.setBackgroundColor(parametersHolder.title_color); 63 | } 64 | 65 | @Override 66 | public TableViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { 67 | SingleLineLinearLayout singleLineLinearLayout = new SingleLineLinearLayout( 68 | parent.getContext()); 69 | 70 | for (int i = 0; i < dataAdapter.getTitleCount(); i++) { 71 | TextView textView = TextViewUtils.generateTextView(singleLineLinearLayout.getContext(), " ", 72 | parametersHolder.item_gravity, 73 | parametersHolder.item_width, 74 | parametersHolder.item_padding); 75 | singleLineLinearLayout.addView(textView, i); 76 | } 77 | 78 | return new TableViewHolder(singleLineLinearLayout); 79 | } 80 | 81 | @Override 82 | public void onBindViewHolder(TableViewHolder holder, int position) { 83 | SingleLineLinearLayout ll_content = (SingleLineLinearLayout) holder.itemView; 84 | List bindViews = new ArrayList<>(); 85 | 86 | 87 | for (int i = 0; i < dataAdapter.getTitleCount(); i++) { 88 | TextView textView = (TextView) ll_content.getChildAt(i); 89 | bindViews.add(textView); 90 | } 91 | 92 | //给奇数列设置背景 93 | setBackgrandForItem(position, ll_content); 94 | 95 | dataAdapter.convertData(position, bindViews); 96 | } 97 | 98 | private void setBackgrandForItem(int position, SingleLineLinearLayout ll_content) { 99 | if (position % 2 != 0) { 100 | ll_content.setBackgroundColor(parametersHolder.col_1_color); 101 | } else { 102 | ll_content.setBackgroundColor(parametersHolder.col_2_color); 103 | } 104 | } 105 | 106 | @Override 107 | public int getItemCount() { 108 | return dataAdapter.getItemCount(); 109 | } 110 | 111 | class LeftViewAdapter extends RecyclerView.Adapter { 112 | 113 | @Override 114 | public LeftViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { 115 | SingleLineLinearLayout singleLineLinearLayout = new SingleLineLinearLayout( 116 | parent.getContext()); 117 | 118 | TextView textView = TextViewUtils.generateTextView(singleLineLinearLayout.getContext(), " ", 119 | parametersHolder.item_gravity, 120 | parametersHolder.item_width, 121 | parametersHolder.item_padding); 122 | 123 | singleLineLinearLayout.addView(textView); 124 | return new LeftViewHolder(singleLineLinearLayout); 125 | } 126 | 127 | @Override 128 | public void onBindViewHolder(LeftViewHolder holder, int position) { 129 | SingleLineLinearLayout ll_content = (SingleLineLinearLayout) holder.itemView; 130 | 131 | TextView child = (TextView) ll_content.getChildAt(0); 132 | 133 | setBackgrandForItem(position, ll_content); 134 | 135 | dataAdapter.convertLeftData(position, child); 136 | } 137 | 138 | @Override 139 | public int getItemCount() { 140 | return dataAdapter.getItemCount(); 141 | } 142 | 143 | class LeftViewHolder extends RecyclerView.ViewHolder { 144 | LeftViewHolder(View itemView) { 145 | super(itemView); 146 | } 147 | } 148 | } 149 | 150 | class TableViewHolder extends RecyclerView.ViewHolder { 151 | TableViewHolder(View itemView) { 152 | super(itemView); 153 | } 154 | } 155 | 156 | public static class ParametersHolder { 157 | int col_1_color; 158 | int col_2_color; 159 | int title_color; 160 | int item_width; 161 | int item_padding; 162 | int item_gravity; 163 | 164 | public ParametersHolder(int s_color, int b_color, int title_color, 165 | int item_width, int item_padding, int item_gravity) { 166 | this.col_1_color = s_color; 167 | this.col_2_color = b_color; 168 | this.title_color = title_color; 169 | this.item_width = item_width; 170 | this.item_padding = item_padding; 171 | this.item_gravity = item_gravity; 172 | } 173 | } 174 | 175 | public static class Builder { 176 | HorizontalScrollView titleView; 177 | RecyclerView leftViews; 178 | TextView left_top_view; 179 | 180 | ParametersHolder parametersHolder; 181 | IDataAdapter dataAdapter; 182 | 183 | public Builder setTitleView(HorizontalScrollView titleView) { 184 | this.titleView = titleView; 185 | return this; 186 | } 187 | 188 | public Builder setLeftViews(RecyclerView leftViews) { 189 | this.leftViews = leftViews; 190 | return this; 191 | } 192 | 193 | public Builder setLeft_top_view(TextView left_top_view) { 194 | this.left_top_view = left_top_view; 195 | return this; 196 | } 197 | 198 | public Builder setParametersHolder( 199 | ParametersHolder parametersHolder) { 200 | this.parametersHolder = parametersHolder; 201 | return this; 202 | } 203 | 204 | public Builder setDataAdapter(IDataAdapter dataAdapter) { 205 | this.dataAdapter = dataAdapter; 206 | return this; 207 | } 208 | 209 | public TableAdapter create() { 210 | return new TableAdapter(titleView, leftViews, left_top_view, parametersHolder, dataAdapter); 211 | } 212 | } 213 | 214 | public void notifyLoadData() { 215 | notifyDataSetChanged(); 216 | leftViews.getAdapter().notifyDataSetChanged(); 217 | } 218 | } 219 | -------------------------------------------------------------------------------- /fixtablelayout/src/main/java/com/app/feng/fixtablelayout/inter/IDataAdapter.java: -------------------------------------------------------------------------------- 1 | package com.app.feng.fixtablelayout.inter; 2 | 3 | import android.widget.TextView; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * Created by feng on 2017/4/4. 9 | */ 10 | 11 | public interface IDataAdapter { 12 | 13 | String getTitleAt(int pos); 14 | 15 | /** 16 | * 共有几列 17 | * @return 18 | */ 19 | int getTitleCount(); 20 | 21 | /** 22 | * 共有几行 23 | * @return 24 | */ 25 | int getItemCount(); 26 | 27 | void convertData(int position,List bindViews); 28 | 29 | void convertLeftData(int position,TextView bindView); 30 | 31 | } 32 | -------------------------------------------------------------------------------- /fixtablelayout/src/main/java/com/app/feng/fixtablelayout/inter/ILoadMoreListener.java: -------------------------------------------------------------------------------- 1 | package com.app.feng.fixtablelayout.inter; 2 | 3 | import android.os.Handler; 4 | import android.os.Message; 5 | 6 | /** 7 | * Created by feng on 2017/4/10. 8 | */ 9 | 10 | public interface ILoadMoreListener { 11 | 12 | void loadMoreData(Message message); 13 | 14 | } 15 | -------------------------------------------------------------------------------- /fixtablelayout/src/main/java/com/app/feng/fixtablelayout/widget/SingleLineItemDecoration.java: -------------------------------------------------------------------------------- 1 | package com.app.feng.fixtablelayout.widget; 2 | 3 | import android.graphics.Canvas; 4 | import android.graphics.Color; 5 | import android.graphics.Paint; 6 | import android.graphics.Rect; 7 | import android.support.v7.widget.RecyclerView; 8 | import android.view.View; 9 | 10 | /** 11 | * Created by feng on 2017/4/2. 12 | */ 13 | 14 | public class SingleLineItemDecoration extends RecyclerView.ItemDecoration { 15 | 16 | private int lineHeight = 4; 17 | private int lineColor = Color.BLACK; 18 | 19 | private Paint paint; 20 | 21 | public SingleLineItemDecoration(int divider_height,int divider_color) { 22 | lineHeight = divider_height; 23 | lineColor = divider_color; 24 | 25 | paint = new Paint(); 26 | 27 | paint.setColor(lineColor); 28 | paint.setAlpha(240); 29 | } 30 | 31 | public int getLineHeight() { 32 | return lineHeight; 33 | } 34 | 35 | public SingleLineItemDecoration setLineHeight(int lineHeight) { 36 | this.lineHeight = lineHeight; 37 | return this; 38 | } 39 | 40 | public int getLineColor() { 41 | return lineColor; 42 | } 43 | 44 | public SingleLineItemDecoration setLineColor(int lineColor) { 45 | this.lineColor = lineColor; 46 | paint.setColor(lineColor); 47 | return this; 48 | } 49 | 50 | @Override 51 | public void onDraw(Canvas c,RecyclerView parent,RecyclerView.State state) { 52 | super.onDraw(c,parent,state); 53 | int left = parent.getPaddingLeft(); 54 | int right = parent.getWidth() - parent.getPaddingRight(); 55 | 56 | 57 | for (int i = 0; i < parent.getChildCount(); i++) { 58 | View child = parent.getChildAt(i); 59 | 60 | int bottom = child.getBottom(); 61 | 62 | c.drawRect(left,bottom,right,bottom + lineHeight,paint); 63 | } 64 | } 65 | 66 | @Override 67 | public void getItemOffsets(Rect outRect,View view, 68 | RecyclerView parent,RecyclerView.State state) { 69 | outRect.bottom = lineHeight; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /fixtablelayout/src/main/java/com/app/feng/fixtablelayout/widget/SingleLineLinearLayout.java: -------------------------------------------------------------------------------- 1 | package com.app.feng.fixtablelayout.widget; 2 | 3 | import android.content.Context; 4 | import android.support.annotation.Nullable; 5 | import android.util.AttributeSet; 6 | import android.view.View; 7 | import android.view.ViewGroup; 8 | 9 | /** 10 | * 其将所有子View,单行排列。 11 | * Created by feng on 2017/3/29. 12 | */ 13 | 14 | public class SingleLineLinearLayout extends ViewGroup { 15 | 16 | public SingleLineLinearLayout(Context context) { 17 | this(context,null); 18 | } 19 | 20 | public SingleLineLinearLayout( 21 | Context context,@Nullable AttributeSet attrs) { 22 | this(context,attrs,0); 23 | } 24 | 25 | public SingleLineLinearLayout( 26 | Context context,@Nullable AttributeSet attrs,int defStyleAttr) { 27 | super(context,attrs,defStyleAttr); 28 | } 29 | 30 | @Override 31 | protected void onMeasure(int widthMeasureSpec,int heightMeasureSpec) { 32 | // 父View 不能限制我们。模式是UNSPECIFIED 宽度所有子View宽总和, 高度取子View最大 33 | int widthSize = MeasureSpec.getSize(widthMeasureSpec); 34 | int heightSize = MeasureSpec.getSize(heightMeasureSpec); 35 | 36 | int width = 0; 37 | int height = 0; 38 | 39 | // Log.i("feng", 40 | // "single 调用 onMeasure - widthMode :" + widthMode + " width size: " + widthSize + " height size " + heightSize); 41 | 42 | for (int i = 0; i < getChildCount(); i++) { 43 | View childView = getChildAt(i); 44 | 45 | int widthChild = MeasureSpec.makeMeasureSpec(widthSize,MeasureSpec.UNSPECIFIED); 46 | int heightChild = MeasureSpec.makeMeasureSpec(heightSize,MeasureSpec.UNSPECIFIED); 47 | 48 | childView.measure(widthChild,heightChild); 49 | 50 | width += childView.getMeasuredWidth(); 51 | height = Math.max(height,childView.getMeasuredHeight()); 52 | } 53 | setMeasuredDimension(width,height); 54 | } 55 | 56 | @Override 57 | protected void onLayout(boolean changed,int l,int t,int r,int b) { 58 | int tempLeft = 0; 59 | int tempHeight = 0; 60 | //非常简单,每个子View都一行摆放。 61 | // Log.i("feng","single 调用 onLayout"); 62 | 63 | for (int i = 0; i < getChildCount(); i++) { 64 | View childView = getChildAt(i); 65 | 66 | int tempRight = tempLeft + childView.getMeasuredWidth(); 67 | int tempT = 0; 68 | int tempB = childView.getMeasuredHeight(); 69 | if (tempHeight == 0) { 70 | tempHeight = tempB; 71 | } else if (tempB != tempHeight) { 72 | tempB = tempHeight; 73 | } 74 | childView.layout(tempLeft,tempT,tempRight,tempB); 75 | tempLeft += childView.getMeasuredWidth(); 76 | } 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /fixtablelayout/src/main/java/com/app/feng/fixtablelayout/widget/TableLayoutManager.java: -------------------------------------------------------------------------------- 1 | package com.app.feng.fixtablelayout.widget; 2 | 3 | import android.graphics.Rect; 4 | import android.support.v7.widget.RecyclerView; 5 | import android.util.SparseArray; 6 | import android.view.View; 7 | import android.view.ViewGroup; 8 | 9 | /** 10 | * Created by feng on 2017/3/27. 11 | */ 12 | 13 | public class TableLayoutManager extends RecyclerView.LayoutManager { 14 | 15 | private int verticalOffset; 16 | private int horizontalOffset; 17 | 18 | private int firstVisPos; 19 | private int lastVisPos; 20 | 21 | private SparseArray mItemAnchorMap = new SparseArray<>(); 22 | 23 | private int oldChildCount = 1; 24 | 25 | public TableLayoutManager() { 26 | super(); 27 | setAutoMeasureEnabled(true); 28 | } 29 | 30 | @Override 31 | public void onLayoutChildren(RecyclerView.Recycler recycler, RecyclerView.State state) { 32 | if (state.getItemCount() == 0) { 33 | detachAndScrapAttachedViews(recycler); 34 | return; 35 | } 36 | 37 | if (getChildCount() == 0 && state.isPreLayout()) {//state.isPreLayout()是支持动画的 38 | return; 39 | } 40 | 41 | // Log.i("feng", 42 | // " tag ? count " + getChildCount() + " change: " + state.didStructureChange() + " obj : " + this.toString() + " PreLayout :" + state.isPreLayout() + " Measure : " + state.isMeasuring()); 43 | 44 | if (getChildCount() > 0 && state.didStructureChange()) { 45 | //Adapter DataSetChange 46 | // 运行 下列语句, 且过后的可能还有一个再次调用,拦截它 47 | oldChildCount = getChildCount(); 48 | fill(recycler, state, 0); 49 | return; 50 | } else if (getChildCount() - oldChildCount > 0 && !state.didStructureChange()) { 51 | fill(recycler, state, 0); 52 | return; 53 | } 54 | 55 | detachAndScrapAttachedViews(recycler); 56 | verticalOffset = 0; 57 | firstVisPos = 0; 58 | lastVisPos = state.getItemCount(); 59 | fill(recycler, state, 0); 60 | } 61 | 62 | private int fill(RecyclerView.Recycler recycler, RecyclerView.State state, int dy) { 63 | int offsetTop = 0; 64 | 65 | //回收越界子View 66 | if (getChildCount() > 0) {//滑动时进来的 67 | for (int i = getChildCount() - 1; i >= 0; i--) { 68 | View child = getChildAt(i); 69 | 70 | if (dy > 0) {//需要回收当前屏幕,上越界的View 71 | if (getDecoratedBottom(child) < 0) { 72 | removeAndRecycleView(child, recycler); 73 | firstVisPos++; 74 | } 75 | } else if (dy < 0) {//回收当前屏幕,下越界的View 76 | if (getDecoratedTop(child) > getHeight() - getPaddingBottom()) { 77 | removeAndRecycleView(child, recycler); 78 | lastVisPos--; 79 | } 80 | } 81 | } 82 | } 83 | 84 | if (dy >= 0) { 85 | int minPos = firstVisPos; 86 | lastVisPos = getItemCount() - 1; 87 | 88 | if (getChildCount() > 0) { 89 | View lastView = getChildAt(getChildCount() - 1); 90 | minPos = getPosition(lastView) + 1; //从最后一个View + 1开始吧 91 | offsetTop = getDecoratedBottom(lastView); 92 | } 93 | 94 | // 填充View 95 | for (int i = minPos; i <= lastVisPos; i++) { 96 | View child = recycler.getViewForPosition(i); 97 | addView(child); 98 | 99 | measureChild(child, 0, 0); 100 | 101 | if (offsetTop - dy > getHeight()) { 102 | // 到了屏幕的末尾 退出布局 103 | removeAndRecycleView(child, recycler); 104 | lastVisPos = i - 1; 105 | } else { 106 | int w = getDecoratedMeasuredWidth(child); 107 | int h = getDecoratedMeasuredHeight(child); 108 | 109 | Rect aRect = mItemAnchorMap.get(i); 110 | if (aRect == null) { 111 | aRect = new Rect(); 112 | } 113 | aRect.set(0, offsetTop + verticalOffset, w, offsetTop + h + verticalOffset); 114 | mItemAnchorMap.put(i, aRect); 115 | 116 | // 布局到RV上 117 | layoutDecorated(child, -horizontalOffset, offsetTop, -horizontalOffset + w, 118 | offsetTop + h); 119 | offsetTop += h; 120 | 121 | } 122 | } 123 | //添加完后,判断是否已经没有更多的ItemView,并且此时屏幕仍有空白,则需要修正dy 124 | View lastChild = getChildAt(getChildCount() - 1); 125 | if (getPosition(lastChild) == getItemCount() - 1) { 126 | int gap = getHeight() - getDecoratedBottom(lastChild); 127 | if (gap > 0) { 128 | dy -= gap; 129 | } 130 | } 131 | } else { 132 | //上滑 , 通过mItemAnchorMap 拿到布局信息 133 | int maxPos = getItemCount() - 1; 134 | firstVisPos = 0; 135 | if (getChildCount() > 0) { 136 | View firstView = getChildAt(0); 137 | maxPos = getPosition(firstView) - 1; 138 | } 139 | 140 | for (int i = maxPos; i >= firstVisPos; i--) { 141 | Rect aRect = mItemAnchorMap.get(i); 142 | 143 | if (aRect != null) { 144 | if (aRect.bottom - verticalOffset - dy < 0) { 145 | firstVisPos = i + 1; 146 | break; 147 | } else { 148 | View child = recycler.getViewForPosition(i); 149 | addView(child, 0); 150 | measureChild(child, 0, 0); 151 | 152 | layoutDecorated(child, aRect.left - horizontalOffset, 153 | aRect.top - verticalOffset, aRect.right - horizontalOffset, 154 | aRect.bottom - verticalOffset); 155 | } 156 | } 157 | } 158 | } 159 | 160 | // Log.d("TAG", 161 | // "count= [" + getChildCount() + "]" + ",[recycler.getScrapList().size():" + recycler.getScrapList() 162 | // .size() + ", dy:" + dy + ", mVerticalOffset" + verticalOffset + ", "); 163 | 164 | return dy; 165 | } 166 | 167 | @Override 168 | public RecyclerView.LayoutParams generateDefaultLayoutParams() { 169 | return new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 170 | ViewGroup.LayoutParams.WRAP_CONTENT); 171 | } 172 | 173 | @Override 174 | public boolean canScrollVertically() { 175 | return true; 176 | } 177 | 178 | @Override 179 | public boolean canScrollHorizontally() { 180 | return true; 181 | } 182 | 183 | @Override 184 | public int scrollHorizontallyBy( 185 | int dx, RecyclerView.Recycler recycler, RecyclerView.State state) { 186 | View firstView = getChildAt(0); 187 | 188 | int firstViewWidth = firstView.getMeasuredWidth(); 189 | if (firstViewWidth <= getWidth()) { 190 | return 0; 191 | } 192 | 193 | if (horizontalOffset + dx > firstViewWidth - getWidth()) { 194 | dx = 0; 195 | } else if (horizontalOffset + dx <= 0) { 196 | dx = 0; 197 | } 198 | 199 | // Log.i("feng"," hOff" + horizontalOffset); 200 | 201 | horizontalOffset += dx; 202 | offsetChildrenHorizontal(-dx); 203 | return dx; 204 | } 205 | 206 | @Override 207 | public int scrollVerticallyBy( 208 | int dy, RecyclerView.Recycler recycler, RecyclerView.State state) { 209 | if (dy == 0 || getChildCount() == 0) { 210 | return 0; 211 | } 212 | int realOffset = dy; 213 | 214 | View firstView = getChildAt(0); 215 | View lastView = getChildAt(getChildCount() - 1); 216 | 217 | //Optimize the case where the entire data set is too small to scroll 218 | int viewSpan = getDecoratedBottom(lastView) - getDecoratedTop(firstView); 219 | if (viewSpan < getVerticalSpace()) { 220 | return 0; 221 | } 222 | 223 | if (verticalOffset + realOffset < 0) { 224 | //下划到了顶部 225 | realOffset = -verticalOffset; 226 | } else if (realOffset > 0) { 227 | //利用最后一个子View比较修正 228 | if (getPosition(lastView) == getItemCount() - 1) { 229 | int gap = getHeight() - getPaddingBottom() - getDecoratedBottom(lastView); 230 | if (gap > 0) { 231 | realOffset = -gap; 232 | } else if (gap == 0) { 233 | realOffset = 0; 234 | } else { 235 | realOffset = Math.min(realOffset, -gap); 236 | } 237 | } 238 | } 239 | 240 | realOffset = fill(recycler, state, realOffset); 241 | verticalOffset += realOffset; 242 | offsetChildrenVertical(-realOffset); 243 | 244 | return realOffset; 245 | } 246 | 247 | //获取控件的竖直高度 248 | private int getVerticalSpace() { 249 | return getHeight() - getPaddingBottom() - getPaddingTop(); 250 | } 251 | 252 | //获取控件的水平宽度 253 | private int getHorizontalSpace() { 254 | return getWidth() - getPaddingLeft() - getPaddingRight(); 255 | } 256 | 257 | } 258 | -------------------------------------------------------------------------------- /fixtablelayout/src/main/java/com/app/feng/fixtablelayout/widget/TextViewUtils.java: -------------------------------------------------------------------------------- 1 | package com.app.feng.fixtablelayout.widget; 2 | 3 | import android.content.Context; 4 | import android.widget.TextView; 5 | 6 | /** 7 | * Created by feng on 2017/4/4. 8 | */ 9 | 10 | public class TextViewUtils { 11 | 12 | public static TextView generateTextView( 13 | Context context, String text, int gravity, int minWidth, int padding) { 14 | TextView textView = new TextView(context); 15 | setTextView(textView, text, gravity, minWidth, padding); 16 | return textView; 17 | } 18 | 19 | public static void setTextView( 20 | TextView textView, String text, int gravity, int minWidth, int padding) { 21 | textView.setText(text); 22 | textView.setGravity(gravity); 23 | textView.setMinWidth(minWidth); 24 | 25 | textView.setPadding(0, padding / 2, 0, padding / 2); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /fixtablelayout/src/main/res/drawable/shadow.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /fixtablelayout/src/main/res/drawable/shadow_rotate90.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /fixtablelayout/src/main/res/layout/table_view.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 14 | 15 | 18 | 19 | 20 | 21 | 32 | 33 | 44 | 45 | 55 | 56 | 64 | 65 | 69 | 70 | 81 | 82 | 87 | 88 | 89 | 90 | -------------------------------------------------------------------------------- /fixtablelayout/src/main/res/values/attr_fixtable.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /fixtablelayout/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 1dp 4 | 100dp 5 | -------------------------------------------------------------------------------- /fixtablelayout/src/test/java/com/app/feng/fixtablelayout/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.app.feng.fixtablelayout; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() throws Exception { 15 | assertEquals(4,2 + 2); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /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 | org.gradle.jvmargs=-Xmx1536m 13 | 14 | # When configured, Gradle will run in incubating parallel mode. 15 | # This option should only be used with decoupled projects. More details, visit 16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 17 | # org.gradle.parallel=true 18 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HYY-yu/TableRecyclerView/e4c987af8f7b6f750e4bdbe2395fc6ca8c083c6f/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Sun Apr 02 18:55:07 CST 2017 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-4.1-all.zip -------------------------------------------------------------------------------- /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 | # Attempt to set APP_HOME 46 | # Resolve links: $0 may be a link 47 | PRG="$0" 48 | # Need this for relative symlinks. 49 | while [ -h "$PRG" ] ; do 50 | ls=`ls -ld "$PRG"` 51 | link=`expr "$ls" : '.*-> \(.*\)$'` 52 | if expr "$link" : '/.*' > /dev/null; then 53 | PRG="$link" 54 | else 55 | PRG=`dirname "$PRG"`"/$link" 56 | fi 57 | done 58 | SAVED="`pwd`" 59 | cd "`dirname \"$PRG\"`/" >/dev/null 60 | APP_HOME="`pwd -P`" 61 | cd "$SAVED" >/dev/null 62 | 63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 64 | 65 | # Determine the Java command to use to start the JVM. 66 | if [ -n "$JAVA_HOME" ] ; then 67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 68 | # IBM's JDK on AIX uses strange locations for the executables 69 | JAVACMD="$JAVA_HOME/jre/sh/java" 70 | else 71 | JAVACMD="$JAVA_HOME/bin/java" 72 | fi 73 | if [ ! -x "$JAVACMD" ] ; then 74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 75 | 76 | Please set the JAVA_HOME variable in your environment to match the 77 | location of your Java installation." 78 | fi 79 | else 80 | JAVACMD="java" 81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 82 | 83 | Please set the JAVA_HOME variable in your environment to match the 84 | location of your Java installation." 85 | fi 86 | 87 | # Increase the maximum file descriptors if we can. 88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 89 | MAX_FD_LIMIT=`ulimit -H -n` 90 | if [ $? -eq 0 ] ; then 91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 92 | MAX_FD="$MAX_FD_LIMIT" 93 | fi 94 | ulimit -n $MAX_FD 95 | if [ $? -ne 0 ] ; then 96 | warn "Could not set maximum file descriptor limit: $MAX_FD" 97 | fi 98 | else 99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 100 | fi 101 | fi 102 | 103 | # For Darwin, add options to specify how the application appears in the dock 104 | if $darwin; then 105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 106 | fi 107 | 108 | # For Cygwin, switch paths to Windows format before running java 109 | if $cygwin ; then 110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 112 | JAVACMD=`cygpath --unix "$JAVACMD"` 113 | 114 | # We build the pattern for arguments to be converted via cygpath 115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 116 | SEP="" 117 | for dir in $ROOTDIRSRAW ; do 118 | ROOTDIRS="$ROOTDIRS$SEP$dir" 119 | SEP="|" 120 | done 121 | OURCYGPATTERN="(^($ROOTDIRS))" 122 | # Add a user-defined pattern to the cygpath arguments 123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 125 | fi 126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 127 | i=0 128 | for arg in "$@" ; do 129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 131 | 132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 134 | else 135 | eval `echo args$i`="\"$arg\"" 136 | fi 137 | i=$((i+1)) 138 | done 139 | case $i in 140 | (0) set -- ;; 141 | (1) set -- "$args0" ;; 142 | (2) set -- "$args0" "$args1" ;; 143 | (3) set -- "$args0" "$args1" "$args2" ;; 144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 150 | esac 151 | fi 152 | 153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 154 | function splitJvmOpts() { 155 | JVM_OPTS=("$@") 156 | } 157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 159 | 160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 161 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app', ':fixtablelayout' 2 | --------------------------------------------------------------------------------