Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

支持NestedScrollView的setNestedScrollingEnabled属性 #134 #135

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 41 additions & 21 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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'
}
}
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
<activity android:name=".MergeModeActivity" />
<activity android:name=".RefreshActivity" />
<activity android:name=".MinModeActivity" />
<activity android:name=".NestedScrollActivity" />
<activity android:name=".ArrayColumnModeActivity" />
<activity android:name=".MapModeActivity" />
<activity android:name=".WelcomeActivity" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,"网格配置"));
Expand Down
106 changes: 106 additions & 0 deletions app/src/main/java/com/bin/david/smarttable/NestedScrollActivity.java
Original file line number Diff line number Diff line change
@@ -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<Student> 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<Student>) 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<String> texts = new ArrayList<>();
texts.add("测试哈1");
texts.add("测试哈2");
texts.add("测试哈3");
List<Lesson> 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<TanBean> tanBeans = TanBean.initDatas();
final List<Student> 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);
}
}
42 changes: 42 additions & 0 deletions app/src/main/res/layout/activity_nested_scroll_table.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.bin.david.smarttable.MinModeActivity">

<android.support.v4.widget.NestedScrollView
android:id="@+id/scrollView"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">

<Button
android:id="@+id/btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:background="@drawable/dialog_btn_bg"
android:text="吸顶效果"
android:textColor="#fff" />

<TextView
android:id="@+id/text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="18sp"
android:text="dddddddddddddddd\n2222222222222222222233333\n大规模枯干无可奈何花落去枯干奇才地霜无可奈何花落去地地夺奇才无可奈何花落去楏柘城地城可想而知枯干地需要地奇才村地标有夺夺电灯泡显加盟田影响力口田迷影响力\ndsffsdfh;lklkjkljlkjljlkjloiuoiukljk.,m.,m.mkwer3243243432432434343454565465465645654654645"/>

<com.bin.david.form.core.SmartTable
android:id="@+id/table"
android:layout_width="match_parent"
android:layout_height="match_parent" />

</LinearLayout>
</android.support.v4.widget.NestedScrollView>

</FrameLayout>
32 changes: 30 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ buildscript {
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand All @@ -26,3 +26,31 @@ allprojects {
task clean(type: Delete) {
delete rootProject.buildDir
}

ext {
minSdk = 15
targetSdk = 28
compileSdkVersion = 28
buildToolsVersion = "28.0.3"
supportLibVersion = "28.0.0"
runnerVersion = "1.0.1"
rulesVersion = "1.0.1"
espressoVersion = "3.0.1"

// Libraries
junitVersion = '4.12'
supportVersion = '28.0.0'

javaSourceCompatibility = JavaVersion.VERSION_1_8
javaTargetCompatibility = JavaVersion.VERSION_1_8

//Support Libraries dependencies
supportDependencies = [
annotations : "com.android.support:support-annotations:${supportVersion}",
palette : "com.android.support:palette-v7:${supportVersion}",
appcompat : "com.android.support:appcompat-v7:${supportVersion}",
design : "com.android.support:design:${supportVersion}",
vector : "com.android.support:support-vector-drawable:${supportVersion}",
recyclerview : "com.android.support:recyclerview-v7:${supportVersion}",
]
}
12 changes: 8 additions & 4 deletions form/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ apply plugin: 'com.github.dcendents.android-maven'
group='com.github.huangyanbin'

android {
compileSdkVersion 25
buildToolsVersion '26.0.2'
compileSdkVersion rootProject.compileSdkVersion
buildToolsVersion rootProject.buildToolsVersion


defaultConfig {
minSdkVersion 15
targetSdkVersion 25
minSdkVersion rootProject.minSdk
targetSdkVersion rootProject.targetSdk
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
Expand Down Expand Up @@ -56,4 +56,8 @@ artifacts {
}

dependencies {
implementation supportDependencies.annotations
implementation(supportDependencies.design) {
exclude module: "support-annotations"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ private void drawCount(Canvas canvas) {
}else if(isPerColumnFixed){
canvas.save();
clipCount++;
canvas.clipRect(clipRect.left, showRect.bottom - countHeight,
showRect.right, showRect.bottom);
canvas.clipRect(clipRect.left, bottom - countHeight,
showRect.right, bottom);
}
tempRect.set((int)left, (int)top, (int)(left+width), (int)bottom);
drawCountText(canvas, column,i,tempRect, column.getTotalNumString(), config);
Expand Down Expand Up @@ -379,6 +379,7 @@ protected void drawContentCell(Canvas c, CellInfo<T> cellInfo, Rect rect,TableCo
config.getTableGridFormat().drawContentGrid(c,cellInfo.col,cellInfo.row,rect,cellInfo,config.getPaint());
}
rect.left += config.getTextLeftOffset();
rect.right -= config.getTextRightOffset();
cellInfo.column.getDrawFormat().draw(c,rect, cellInfo, config);
}

Expand Down Expand Up @@ -430,7 +431,7 @@ private void drawCountText(Canvas canvas,Column column,int position, Rect rect,
if(column.getTextAlign() !=null) {
paint.setTextAlign(column.getTextAlign());
}
canvas.drawText(text, DrawUtils.getTextCenterX(rect.left,rect.right,paint), DrawUtils.getTextCenterY(rect.centerY(), paint), paint);
canvas.drawText(text, DrawUtils.getTextCenterX(rect.left+config.getTextLeftOffset(), rect.right-config.getTextRightOffset(),paint), DrawUtils.getTextCenterY(rect.centerY(), paint), paint);
}


Expand Down
Loading