From 9dfa54950bc8adadbcf1880f8694c7d863d5aa0e Mon Sep 17 00:00:00 2001 From: JakeWoki Date: Wed, 28 Nov 2018 11:37:18 +0800 Subject: [PATCH 1/4] https://github.com/huangyanbin/smartTable/issues/134 --- app/build.gradle | 62 +++--- app/src/main/AndroidManifest.xml | 1 + .../bin/david/smarttable/MainActivity.java | 1 + .../smarttable/NestedScrollActivity.java | 106 +++++++++++ .../layout/activity_nested_scroll_table.xml | 42 +++++ build.gradle | 32 +++- form/build.gradle | 12 +- .../com/bin/david/form/core/SmartTable.java | 178 +++++++++++++++++- gradle.properties | 2 +- gradle/wrapper/gradle-wrapper.properties | 2 +- 10 files changed, 402 insertions(+), 36 deletions(-) create mode 100644 app/src/main/java/com/bin/david/smarttable/NestedScrollActivity.java create mode 100644 app/src/main/res/layout/activity_nested_scroll_table.xml diff --git a/app/build.gradle b/app/build.gradle index 9fc84a9..fbdfe92 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,12 +1,12 @@ apply plugin: 'com.android.application' android { - compileSdkVersion 25 - buildToolsVersion '26.0.2' + compileSdkVersion rootProject.compileSdkVersion + buildToolsVersion rootProject.buildToolsVersion defaultConfig { applicationId "com.bin.david.smarttable" - minSdkVersion 15 - targetSdkVersion 25 + minSdkVersion rootProject.minSdk + targetSdkVersion rootProject.targetSdk versionCode 1 versionName "1.8.5" multiDexEnabled true @@ -29,24 +29,44 @@ android { } dependencies { - compile 'com.android.support:appcompat-v7:25.3.1' - compile 'com.android.support.constraint:constraint-layout:1.0.2' - testCompile 'junit:junit:4.12' - compile project(':form') - compile 'com.zhy:okhttputils:2.6.2' - compile 'com.google.code.gson:gson:2.8.0' - compile 'com.android.support:recyclerview-v7:25.3.1' - compile 'com.github.huangyanbin:SmartChart:1.3.2' - compile 'com.android.support:cardview-v7:25.3.1' - compile 'com.android.support:multidex:1.0.0' - compile 'com.github.bumptech.glide:glide:4.3.1' - compile 'jp.wasabeef:glide-transformations:3.0.1' - compile 'jp.co.cyberagent.android.gpuimage:gpuimage-library:1.4.1' + testImplementation 'junit:junit:4.12' + implementation project(':form') + implementation 'com.android.support.constraint:constraint-layout:1.1.3' + implementation supportDependencies.annotations + implementation supportDependencies.recyclerview + implementation(supportDependencies.design) { + exclude module: "support-annotations" + } + implementation 'com.zhy:okhttputils:2.6.2' + implementation 'com.google.code.gson:gson:2.8.5' + implementation 'com.github.huangyanbin:SmartChart:1.3.2' + implementation ("com.android.support:cardview-v7:${supportVersion}") { + exclude group: 'com.android.support', module: 'design' + exclude group: 'com.android.support', module: 'appcompat' + exclude group: 'com.android.support', module: 'support-v4' + exclude module: 'recyclerview-v7' + } + implementation 'com.android.support:multidex:1.0.3' + implementation 'com.github.bumptech.glide:glide:4.3.1' + implementation 'jp.wasabeef:glide-transformations:3.0.1' + implementation 'jp.co.cyberagent.android.gpuimage:gpuimage-library:1.4.1' annotationProcessor 'com.github.bumptech.glide:compiler:4.3.1' - compile 'com.github.CymChad:BaseRecyclerViewAdapterHelper:2.9.31' - compile files('libs/jxl.jar') - compile 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0-alpha-1' + implementation ('com.github.CymChad:BaseRecyclerViewAdapterHelper:2.9.31') { + exclude group: 'com.android.support', module: 'design' + exclude group: 'com.android.support', module: 'appcompat' + exclude group: 'com.android.support', module: 'support-v4' + exclude module: 'recyclerview-v7' + } + implementation files('libs/jxl.jar') + implementation ('com.scwang.smartrefresh:SmartRefreshLayout:1.1.0-alpha-15') { + exclude group: 'com.android.support', module: 'support-v4' + } implementation files('libs/poi-3.17.jar') implementation files('libs/poi-scratchpad-3.17.jar') - compile 'com.vincent.filepicker:MultiTypeFilePicker:1.0.5' + implementation ('com.vincent.filepicker:MultiTypeFilePicker:1.0.5') { + exclude group: 'com.android.support', module: 'design' + exclude group: 'com.android.support', module: 'appcompat' + exclude group: 'com.android.support', module: 'support-v4' + exclude module: 'recyclerview-v7' + } } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 1d80b4a..1a74714 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -38,6 +38,7 @@ + diff --git a/app/src/main/java/com/bin/david/smarttable/MainActivity.java b/app/src/main/java/com/bin/david/smarttable/MainActivity.java index 9119afa..34d266c 100644 --- a/app/src/main/java/com/bin/david/smarttable/MainActivity.java +++ b/app/src/main/java/com/bin/david/smarttable/MainActivity.java @@ -44,6 +44,7 @@ protected void onCreate(Bundle savedInstanceState) { items.add(new MainItem(AlignActivity.class,"文字Align测试")); items.add(new MainItem(ManyActivity.class,"测试大量列")); items.add(new MainItem(MinModeActivity.class,"设置表格最小宽度(嵌入ScrollView)")); + items.add(new MainItem(NestedScrollActivity.class,"NestedScrollView的setNestedScrollingEnabled属性")); items.add(new MainItem(TableListActivity.class,"测试手势冲突")); items.add(new MainItem(WelcomeActivity.class,"表格动画") ); items.add(new MainItem(GridModeActivity.class,"网格配置")); diff --git a/app/src/main/java/com/bin/david/smarttable/NestedScrollActivity.java b/app/src/main/java/com/bin/david/smarttable/NestedScrollActivity.java new file mode 100644 index 0000000..6f2e27c --- /dev/null +++ b/app/src/main/java/com/bin/david/smarttable/NestedScrollActivity.java @@ -0,0 +1,106 @@ +package com.bin.david.smarttable; + +import android.os.Bundle; +import android.support.annotation.Nullable; +import android.support.v4.widget.NestedScrollView; +import android.support.v7.app.AppCompatActivity; +import android.view.View; +import android.view.ViewTreeObserver; +import android.widget.Button; + +import com.bin.david.form.core.SmartTable; +import com.bin.david.form.data.style.FontStyle; +import com.bin.david.form.utils.DensityUtils; +import com.bin.david.smarttable.bean.ChildData; +import com.bin.david.smarttable.bean.Lesson; +import com.bin.david.smarttable.bean.LessonPoint; +import com.bin.david.smarttable.bean.Student; +import com.bin.david.smarttable.bean.TanBean; + +import java.util.ArrayList; +import java.util.List; +import java.util.Random; + +/** + * + * Created by owp on 2018/11/28. + */ +public class NestedScrollActivity extends AppCompatActivity { + + private NestedScrollView scrollView; + private Button btn; + private SmartTable table; + + private boolean isCeiling; + + @Override + protected void onCreate(@Nullable Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_nested_scroll_table); + + FontStyle.setDefaultTextSize(DensityUtils.sp2px(this,15)); //设置全局字体大小 + scrollView = (NestedScrollView) findViewById(R.id.scrollView); + table = (SmartTable) findViewById(R.id.table); + + + table.setNestedScrollingEnabled(true); + + + btn = (Button) findViewById(R.id.btn); + btn.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + table.setCeiling(isCeiling = !isCeiling); + btn.setText(isCeiling ? "普通效果" : "吸顶效果"); + } + }); + + table.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { + @Override + public void onGlobalLayout() { + table.getViewTreeObserver().removeGlobalOnLayoutListener(this); + table.getLayoutParams().height = scrollView.getMeasuredHeight(); + + loadData(); + } + }); + } + + private void loadData() { + List texts = new ArrayList<>(); + texts.add("测试哈1"); + texts.add("测试哈2"); + texts.add("测试哈3"); + List lessons2 = new ArrayList<>(); + Lesson lesson1 = new Lesson("软件",true); + + lesson1.setTest(texts); + lesson1.setLessonPoints(new LessonPoint[]{new LessonPoint("软件工程"),new LessonPoint("离散数学")}); + Lesson lesson2 = new Lesson("生物",true); + lesson2.setLessonPoints(new LessonPoint[]{new LessonPoint("医学构造"),new LessonPoint("生物科技")}); + //lesson2.setTest(texts); + lessons2.add(lesson1); + lessons2.add(lesson2); + lessons2.add(new Lesson("微积分",false)); + Random random = new Random(); + // Lesson[] lessonArray = new Lesson[]{new Lesson("政治",false),new Lesson("法学",false)}; + List tanBeans = TanBean.initDatas(); + final List students = new ArrayList<>(); + //测试 从其他地方获取url + int urlSize = tanBeans.size(); + for(int i = 0;i <30; i++) { + Student student = new Student("用户"+i, random.nextInt(70), System.currentTimeMillis() + - random.nextInt(70)*3600*1000*24,true,new ChildData("测试"+i)); + student.setUrl(tanBeans.get(i%urlSize).getUrl()); + //student.setLessons(i%3 ==0?lessons2:lessons); + student.setLessons(lessons2); + // student.setLessonsArray(lessonArray); + students.add(student); + } + table.setData(students); + table.getConfig().setShowTableTitle(true); + table.getConfig().setShowXSequence(true); + table.getConfig().setShowYSequence(true); + table.setZoom(true,2,0.2f); + } +} diff --git a/app/src/main/res/layout/activity_nested_scroll_table.xml b/app/src/main/res/layout/activity_nested_scroll_table.xml new file mode 100644 index 0000000..e8eb8db --- /dev/null +++ b/app/src/main/res/layout/activity_nested_scroll_table.xml @@ -0,0 +1,42 @@ + + + + + + +