├── .gitignore
├── .idea
├── gradle.xml
├── markdown-navigator.xml
├── markdown-navigator
│ └── profiles_settings.xml
├── misc.xml
├── modules.xml
├── runConfigurations.xml
└── vcs.xml
├── README.en.md
├── README.md
├── README_old_version.md
├── README_old_version_en.md
├── app
├── .gitignore
├── build.gradle
├── libs
│ ├── jxl.jar
│ ├── poi-3.17.jar
│ └── poi-scratchpad-3.17.jar
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── bin
│ │ └── david
│ │ └── smarttable
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── assets
│ │ ├── c.xls
│ │ └── ic_class.xls
│ ├── java
│ │ ├── com
│ │ │ └── bin
│ │ │ │ └── david
│ │ │ │ └── smarttable
│ │ │ │ ├── AlignActivity.java
│ │ │ │ ├── AnnotationModeActivity.java
│ │ │ │ ├── ArrayColumnModeActivity.java
│ │ │ │ ├── ArrayModeActivity.java
│ │ │ │ ├── AvatorModeActivity.java
│ │ │ │ ├── BaseApplication.java
│ │ │ │ ├── ChoiceExcelActivity.java
│ │ │ │ ├── DesktopDrawFormat.java
│ │ │ │ ├── DesktopModeActivity.java
│ │ │ │ ├── FormModeActivity.java
│ │ │ │ ├── GridModeActivity.java
│ │ │ │ ├── JXLExcelModeActivity.java
│ │ │ │ ├── MainActivity.java
│ │ │ │ ├── ManyActivity.java
│ │ │ │ ├── MapModeActivity.java
│ │ │ │ ├── MergeModeActivity.java
│ │ │ │ ├── MinModeActivity.java
│ │ │ │ ├── MultParseModeActivity.java
│ │ │ │ ├── NetHttpActivity.java
│ │ │ │ ├── POIExcelModeActivity.java
│ │ │ │ ├── PagerModeActivity.java
│ │ │ │ ├── ParseModeActivity.java
│ │ │ │ ├── RefreshActivity.java
│ │ │ │ ├── SeatModeActivity.java
│ │ │ │ ├── TableListActivity.java
│ │ │ │ ├── TanTanActivity.java
│ │ │ │ ├── WelcomeActivity.java
│ │ │ │ ├── adapter
│ │ │ │ ├── ItemAdapter.java
│ │ │ │ ├── SheetAdapter.java
│ │ │ │ ├── TableListAdapter.java
│ │ │ │ └── TanTanAdapter.java
│ │ │ │ ├── bean
│ │ │ │ ├── ChildData.java
│ │ │ │ ├── CollegeStudent.java
│ │ │ │ ├── Course.java
│ │ │ │ ├── DayTime.java
│ │ │ │ ├── Form.java
│ │ │ │ ├── ImagePoint.java
│ │ │ │ ├── Lesson.java
│ │ │ │ ├── LessonPoint.java
│ │ │ │ ├── MainItem.java
│ │ │ │ ├── MergeInfo.java
│ │ │ │ ├── PM25.java
│ │ │ │ ├── Student.java
│ │ │ │ ├── StudentInfo.java
│ │ │ │ ├── TableStyle.java
│ │ │ │ ├── TanBean.java
│ │ │ │ ├── UserInfo.java
│ │ │ │ └── Week.java
│ │ │ │ ├── excel
│ │ │ │ ├── BaseExcel2Table.java
│ │ │ │ ├── ExcelCallback.java
│ │ │ │ ├── IExcel2Table.java
│ │ │ │ ├── JXLExcel2Table.java
│ │ │ │ └── POIExcel2Table.java
│ │ │ │ ├── layoutManager
│ │ │ │ └── TanTanLayoutManager.java
│ │ │ │ ├── utils
│ │ │ │ ├── DrawHelper.java
│ │ │ │ ├── ExcelHelper.java
│ │ │ │ └── JsonHelper.java
│ │ │ │ └── view
│ │ │ │ ├── BaseCheckDialog.java
│ │ │ │ ├── BaseDialog.java
│ │ │ │ ├── GlideCircleTransform.java
│ │ │ │ └── QuickChartDialog.java
│ │ └── java
│ │ │ └── awt
│ │ │ └── Color.java
│ └── res
│ │ ├── anim
│ │ ├── fade_in_center.xml
│ │ ├── fade_out_center.xml
│ │ ├── modal_in.xml
│ │ ├── modal_out.xml
│ │ ├── out_to_left.xml
│ │ ├── slide_in_bottom.xml
│ │ ├── slide_in_top.xml
│ │ ├── slide_left_in.xml
│ │ ├── slide_left_out.xml
│ │ ├── slide_out_bottom.xml
│ │ ├── slide_out_top.xml
│ │ ├── slide_right_in.xml
│ │ └── slide_right_out.xml
│ │ ├── drawable
│ │ ├── cal_sign_bg.9.png
│ │ ├── cal_sign_bg2.9.png
│ │ ├── checkbox_btn_drawable.xml
│ │ ├── dialog_btn_bg.xml
│ │ ├── dialog_white_bg.xml
│ │ ├── dialog_window_bg.xml
│ │ ├── ic_launcher_background.xml
│ │ └── side_nav_bar.xml
│ │ ├── layout
│ │ ├── activity_annotation.xml
│ │ ├── activity_choice_excel.xml
│ │ ├── activity_edit_table.xml
│ │ ├── activity_excel_table.xml
│ │ ├── activity_full_table.xml
│ │ ├── activity_main.xml
│ │ ├── activity_pager.xml
│ │ ├── activity_recycler.xml
│ │ ├── activity_refresh_table.xml
│ │ ├── activity_scroll_table.xml
│ │ ├── activity_seat_table.xml
│ │ ├── activity_table.xml
│ │ ├── activity_weclome.xml
│ │ ├── app_bar_choice_excel.xml
│ │ ├── content_choice_excel.xml
│ │ ├── dialog_chart.xml
│ │ ├── item_main.xml
│ │ ├── item_pop_calculator.xml
│ │ ├── item_sheet.xml
│ │ ├── item_table.xml
│ │ ├── item_tantan.xml
│ │ ├── nav_header_choice_excel.xml
│ │ └── pop_base_check.xml
│ │ ├── menu
│ │ ├── activity_choice_excel_drawer.xml
│ │ └── choice_excel.xml
│ │ ├── mipmap-hdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-mdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xhdpi
│ │ ├── a9m.png
│ │ ├── activity_fill.png
│ │ ├── age.png
│ │ ├── avator_1.png
│ │ ├── avator_10.png
│ │ ├── avator_11.png
│ │ ├── avator_12.png
│ │ ├── avator_13.png
│ │ ├── avator_14.png
│ │ ├── avator_15.png
│ │ ├── avator_16.png
│ │ ├── avator_17.png
│ │ ├── avator_18.png
│ │ ├── avator_19.png
│ │ ├── avator_2.png
│ │ ├── avator_20.png
│ │ ├── avator_3.png
│ │ ├── avator_4.png
│ │ ├── avator_5.png
│ │ ├── avator_6.png
│ │ ├── avator_7.png
│ │ ├── avator_8.png
│ │ ├── avator_9.png
│ │ ├── brush_fill.png
│ │ ├── check.png
│ │ ├── clock_fill.png
│ │ ├── collection_fill.png
│ │ ├── excel_triangle.png
│ │ ├── ic_launcher.png
│ │ ├── ic_launcher_round.png
│ │ ├── level1.png
│ │ ├── level2.png
│ │ ├── morning.png
│ │ ├── name.png
│ │ ├── night.png
│ │ ├── noon.png
│ │ ├── seat.png
│ │ ├── seat_selected.png
│ │ ├── set_bg.9.png
│ │ ├── set_tow.png
│ │ ├── sort_down.png
│ │ ├── sort_up.png
│ │ ├── uncheck.png
│ │ ├── unsort.png
│ │ └── update.png
│ │ ├── mipmap-xxhdpi
│ │ ├── ic_launcher.png
│ │ ├── ic_launcher_round.png
│ │ ├── ic_select_check.png
│ │ ├── ic_unselect_check.png
│ │ ├── icon.png
│ │ ├── round_rect.9.png
│ │ ├── triangle.png
│ │ ├── zuo_03.png
│ │ └── zuo_05.png
│ │ ├── mipmap-xxxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── values-v21
│ │ └── styles.xml
│ │ └── values
│ │ ├── colors.xml
│ │ ├── dimens.xml
│ │ ├── drawables.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── com
│ └── bin
│ └── david
│ └── smarttable
│ └── ExampleUnitTest.java
├── build.gradle
├── form
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── bin
│ │ └── david
│ │ └── form
│ │ ├── annotation
│ │ ├── ColumnType.java
│ │ ├── SmartColumn.java
│ │ └── SmartTable.java
│ │ ├── component
│ │ ├── GridDrawer.java
│ │ ├── IComponent.java
│ │ ├── ITableTitle.java
│ │ ├── SelectionOperation.java
│ │ ├── TableProvider.java
│ │ ├── TableTitle.java
│ │ ├── XSequence.java
│ │ └── YSequence.java
│ │ ├── core
│ │ ├── AnnotationParser.java
│ │ ├── SmartTable.java
│ │ ├── TableConfig.java
│ │ ├── TableMeasurer.java
│ │ └── TableParser.java
│ │ ├── data
│ │ ├── ArrayStructure.java
│ │ ├── Cell.java
│ │ ├── CellInfo.java
│ │ ├── CellRange.java
│ │ ├── TableInfo.java
│ │ ├── column
│ │ │ ├── ArrayColumn.java
│ │ │ ├── Column.java
│ │ │ ├── ColumnInfo.java
│ │ │ ├── ColumnNode.java
│ │ │ └── MapColumn.java
│ │ ├── form
│ │ │ └── IForm.java
│ │ ├── format
│ │ │ ├── IFormat.java
│ │ │ ├── bg
│ │ │ │ ├── BaseBackgroundFormat.java
│ │ │ │ ├── BaseCellBackgroundFormat.java
│ │ │ │ ├── IBackgroundFormat.java
│ │ │ │ └── ICellBackgroundFormat.java
│ │ │ ├── count
│ │ │ │ ├── DecimalCountFormat.java
│ │ │ │ ├── ICountFormat.java
│ │ │ │ ├── NumberCountFormat.java
│ │ │ │ └── StringCountFormat.java
│ │ │ ├── draw
│ │ │ │ ├── BitmapDrawFormat.java
│ │ │ │ ├── FastTextDrawFormat.java
│ │ │ │ ├── IDrawFormat.java
│ │ │ │ ├── ImageResDrawFormat.java
│ │ │ │ ├── LeftTopDrawFormat.java
│ │ │ │ ├── MultiLineDrawFormat.java
│ │ │ │ ├── TextDrawFormat.java
│ │ │ │ └── TextImageDrawFormat.java
│ │ │ ├── grid
│ │ │ │ ├── BaseAbstractGridFormat.java
│ │ │ │ ├── BaseGridFormat.java
│ │ │ │ ├── IGridFormat.java
│ │ │ │ └── SimpleGridFormat.java
│ │ │ ├── selected
│ │ │ │ ├── BaseSelectFormat.java
│ │ │ │ ├── IDrawOver.java
│ │ │ │ └── ISelectFormat.java
│ │ │ ├── sequence
│ │ │ │ ├── BaseSequenceFormat.java
│ │ │ │ ├── ISequenceFormat.java
│ │ │ │ ├── LetterSequenceFormat.java
│ │ │ │ └── NumberSequenceFormat.java
│ │ │ ├── tip
│ │ │ │ ├── BaseBubbleTip.java
│ │ │ │ ├── ITip.java
│ │ │ │ ├── MultiLineBubbleTip.java
│ │ │ │ └── SingleLineBubbleTip.java
│ │ │ └── title
│ │ │ │ ├── BitmapTitleDrawFormat.java
│ │ │ │ ├── ITitleDrawFormat.java
│ │ │ │ ├── ImageResTitleDrawFormat.java
│ │ │ │ ├── TitleDrawFormat.java
│ │ │ │ └── TitleImageDrawFormat.java
│ │ ├── style
│ │ │ ├── FontStyle.java
│ │ │ ├── IStyle.java
│ │ │ ├── LineStyle.java
│ │ │ └── PointStyle.java
│ │ └── table
│ │ │ ├── ArrayTableData.java
│ │ │ ├── FormTableData.java
│ │ │ ├── MapTableData.java
│ │ │ ├── PageTableData.java
│ │ │ └── TableData.java
│ │ ├── exception
│ │ └── TableException.java
│ │ ├── listener
│ │ ├── Observable.java
│ │ ├── OnColumnClickListener.java
│ │ ├── OnColumnItemClickListener.java
│ │ ├── OnTableChangeListener.java
│ │ └── TableClickObserver.java
│ │ ├── matrix
│ │ ├── ITouch.java
│ │ ├── MatrixHelper.java
│ │ └── PointEvaluator.java
│ │ └── utils
│ │ ├── BitmapDrawer.java
│ │ ├── DensityUtils.java
│ │ ├── DrawUtils.java
│ │ └── LetterUtils.java
│ └── res
│ └── values
│ └── strings.xml
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── img
├── 1.png
├── SmartTableCode.png
├── arrayColumn.gif
├── avator.jpg
├── dashang.jpg
├── multline.jpg
├── new_excel.png
├── old_excel.png
├── progress.jpg
├── refresh.gif
├── seat.jpg
├── smartTable.apk
├── table.gif
├── table.png
└── zoom.gif
├── settings.gradle
└── use.md
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 | .externalNativeBuild
10 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
18 |
19 |
--------------------------------------------------------------------------------
/.idea/markdown-navigator/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/README_old_version.md:
--------------------------------------------------------------------------------
1 | # SmartTable历史版本
2 |
3 | ###### 一款android自动生成表格框架
4 | **- 1.8版本**
5 |
6 | > 增加List Array Column
7 |
8 | **- 1.7版本**
9 |
10 | > 修复了缩放问题以及Excel导入显示
11 | > 增加自动合并单元格功能
12 |
13 | **- 1.6版本**
14 |
15 | > 修复缩放偏移问题和闪烁问题
16 | > 增加导出JXL Excel(导出文字样式,背景,图片,批注)
17 | > 增加单元格合并
18 | > 增加左上角空隙格式化
19 | > 支持二维数组转换
20 | > 增加导出POI Excel(导入图表示例)
21 | > 支持自动单元合并
22 | > 支持设置表格最小宽度
23 |
24 |
25 |
26 | **- 1.5版本**
27 |
28 | > 修复缩放问题
29 | > 增加ArrayTableData 支持二维数组
30 |
31 | **- 1.4版本**
32 |
33 | > 删除设置固定第一列setFixedFirstColumn方法,column的setFixed(boolean fixed)来固定任意列。
34 | >支持首尾动态添加数据SmartTable.addData(List t,boolean isFoot)来实现添加数据.实现增量解析数据和计算表格大小,效率更高。
35 | > 修复缩放中心偏移问题;
36 | > 支持内容多行显示。
37 | 
38 |
39 |
40 | **- 1.3版本**
41 |
42 | - 设置单个格子背景
43 |
44 | > 在网上参考了```html```的```table```,发现样式好看多了,按到这个思路,SmartTable增加了支持对单个格子的不同背景支持,在```TableConfig```里面有5个```IBackgroundFormat```样式,可以根据```boolean isDraw(T t)```返回数据做出判断是否绘制背景```drawBackground```,默认绘制整个背景,当然你可以自己定义```IBackgroundFormat```使用其他形状。
45 |
46 | - 设置单个格子字体
47 |
48 | > 由于支持到单个格子背景的支持,字体颜色也需要根据背景还进行调整,所以又支持单个格子的字体设置,```IBackgroundFormat```中有 ```int getTextColor(T t)```,你只需重写它,根据需求设置不同颜色。
49 |
50 | - 分页
51 |
52 | > 在客户端太多数据体验不好,所以开发分页模式,在未使用注解情况下,只需要使用```PageTableData```分页表格数据类 代替之前```TableData```表格数据类即可,使用```PageTableData```的```setPageSize```方法设置每页数量。分页就完成了。
53 | 如果你使用注解,请在```@SmartTable```注解元素添加```pageSize```属性即可,setData会返回```PageTableData```对象,你可以使用它完成后面其他的设置。
54 |
55 | - 其他
56 |
57 | > SmartTable 增加notifyDataChanged方法用于重新解析计算布局;
58 |
59 | > 提供back方法fling到原点;
60 |
61 | > 增加网络请求图片显示例子。
62 |
63 | **- 1.2版本**
64 |
65 | > 自动统计,排序(也可自定义统计规则);
66 | > 表格批注;
67 | > 缩放模式和滚动模式.
68 |
69 | **- 1.1版本**
70 |
71 | > 表格列标题组合;
72 | > 表格固定左序列、顶部序列、第一行、列标题、统计行;
73 | > 自动统计,排序(也可自定义统计规则);
74 |
75 | > 表格内容、列标题点击事件;
76 |
77 |
78 |
79 | **- 1.0版本**
80 |
81 | > 快速配置自动生成表格;
82 | > 自动计算表格宽高;
83 | > 表格各组成背景、文字、网格、padding等配置;
84 | > 表格图文、序列号、列标题格式化;
85 | > 支持注解模式。
86 |
--------------------------------------------------------------------------------
/README_old_version_en.md:
--------------------------------------------------------------------------------
1 | # SmartTable version of history
2 |
3 | ###### An Android automatically generated table framework
4 |
5 |
6 | **- version 1.6**
7 |
8 | > repair the zoom offset problem
9 | > increase import Excel
10 | Increase cell merge
11 | > increase the upper left corner voids formatting
12 |
13 | **- version 1.5**
14 |
15 | > fix the zoom problem
16 | > add ArrayTableData to support two dimensional arrays
17 |
18 | **- version 1.4**
19 |
20 | > delete set the fixed first column setFixedFirstColumn method, column's setFixed (Boolean fixed) to fix any column.
21 | > support SmartTable.addData List t (Boolean isFoot) to add data. Incremental data analysis and computation form size are more efficient.
22 | > repair the zoom center offset problem;
23 | > support content multiline display.
24 | 
25 |
26 |
27 | **- version 1.3**
28 |
29 | - setting a single lattice background
30 |
31 | In the online reference ```html``` > ```table```, find the pattern pretty much, according to this idea, SmartTable added support for different backgrounds on single grid support, there are 5 ```IBackgroundFormat``` style in ```TableConfig```, according to ```boolean isDraw (T T) to determine whether ` ` ` return data to draw the background of ```drawBackground```, the default of drawing the whole background. Of course, you can define your own ```IBackgroundFormat``` using other shapes.
32 |
33 | - setting a single lattices font
34 |
35 | Due to a single grid support > background support, font color is also need to adjust according to the background, so it supports a single lattice font settings, ```int getTextColor ```IBackgroundFormat``` (T T) ', you only need to rewrite it, according to the needs of different color settings.
36 |
37 | - paging
38 |
39 | "Too much data on the client experience is not good, so the development of paging mode, without using the annotation case, only need to use the ```PageTableData``` page table data instead of tabular data before the ```TableData``` class, the ```setPageSize``` method uses the ```PageTableData``` settings page number. The paging is finished.
40 | If you use annotations, please annotate elements in ```@SmartTable```, add ```pageSize``` attribute, setData will return ```PageTableData``` object, you can use it to finish other settings.
41 |
42 | - other
43 |
44 | > SmartTable adds the notifyDataChanged method to re parse the calculation layout;
45 |
46 | > provides the back method fling to the origin;
47 |
48 | > increase the network request picture display example.
49 |
50 | **-version 1.2**
51 |
52 | Automatic statistics, sorting (also customizable statistics rules);
53 | > form annotation;
54 | > zoom mode and scroll mode.
55 |
56 | **- version 1.1**
57 |
58 | Table column header combinations;
59 | The table is fixed to the left sequence, the top sequence, the first line, the column headline and the statistical line.
60 | Automatic statistics, sorting (also customizable statistics rules);
61 |
62 | > table content, column headlines, click events;
63 |
64 |
65 |
66 | **- version 1.0**
67 |
68 | Faster configuration automatically generates forms;
69 | > automatic calculation form is wide;
70 | > the configuration of the form, text, grid, padding and so on;
71 | Table schema, sequence number, column headline formatting;
72 | > support the annotation mode.
73 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 25
5 | buildToolsVersion '26.0.2'
6 | defaultConfig {
7 | applicationId "com.bin.david.smarttable"
8 | minSdkVersion 15
9 | targetSdkVersion 25
10 | versionCode 1
11 | versionName "1.8.5"
12 | multiDexEnabled true
13 | }
14 |
15 | packagingOptions {
16 | exclude('META-INF/LICENSE.txt')
17 | exclude('META-INF/LICENSE')
18 | }
19 | buildTypes {
20 | release {
21 | minifyEnabled false
22 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
23 | }
24 | }
25 | compileOptions {
26 | sourceCompatibility JavaVersion.VERSION_1_7
27 | targetCompatibility JavaVersion.VERSION_1_7
28 | }
29 | }
30 |
31 | dependencies {
32 | compile 'com.android.support:appcompat-v7:25.3.1'
33 | compile 'com.android.support.constraint:constraint-layout:1.0.2'
34 | testCompile 'junit:junit:4.12'
35 | compile project(':form')
36 | compile 'com.zhy:okhttputils:2.6.2'
37 | compile 'com.google.code.gson:gson:2.8.0'
38 | compile 'com.android.support:recyclerview-v7:25.3.1'
39 | compile 'com.github.huangyanbin:SmartChart:1.3.2'
40 | compile 'com.android.support:cardview-v7:25.3.1'
41 | compile 'com.android.support:multidex:1.0.0'
42 | compile 'com.github.bumptech.glide:glide:4.3.1'
43 | compile 'jp.wasabeef:glide-transformations:3.0.1'
44 | compile 'jp.co.cyberagent.android.gpuimage:gpuimage-library:1.4.1'
45 | annotationProcessor 'com.github.bumptech.glide:compiler:4.3.1'
46 | compile 'com.github.CymChad:BaseRecyclerViewAdapterHelper:2.9.31'
47 | compile files('libs/jxl.jar')
48 | compile 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0-alpha-1'
49 | implementation files('libs/poi-3.17.jar')
50 | implementation files('libs/poi-scratchpad-3.17.jar')
51 | compile 'com.vincent.filepicker:MultiTypeFilePicker:1.0.5'
52 | }
53 |
--------------------------------------------------------------------------------
/app/libs/jxl.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huangyanbin/smartTable/fe975d333a79586261f4f265317b9d1e6f2a36fa/app/libs/jxl.jar
--------------------------------------------------------------------------------
/app/libs/poi-3.17.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huangyanbin/smartTable/fe975d333a79586261f4f265317b9d1e6f2a36fa/app/libs/poi-3.17.jar
--------------------------------------------------------------------------------
/app/libs/poi-scratchpad-3.17.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huangyanbin/smartTable/fe975d333a79586261f4f265317b9d1e6f2a36fa/app/libs/poi-scratchpad-3.17.jar
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/bin/david/smarttable/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.bin.david.smarttable;
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 | * Instrumented 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.bin.david.smarttable", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
51 |
53 |
54 |
55 |
--------------------------------------------------------------------------------
/app/src/main/assets/c.xls:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huangyanbin/smartTable/fe975d333a79586261f4f265317b9d1e6f2a36fa/app/src/main/assets/c.xls
--------------------------------------------------------------------------------
/app/src/main/assets/ic_class.xls:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huangyanbin/smartTable/fe975d333a79586261f4f265317b9d1e6f2a36fa/app/src/main/assets/ic_class.xls
--------------------------------------------------------------------------------
/app/src/main/java/com/bin/david/smarttable/BaseApplication.java:
--------------------------------------------------------------------------------
1 | package com.bin.david.smarttable;
2 |
3 | import android.app.Application;
4 | import android.content.Context;
5 |
6 | import com.scwang.smartrefresh.layout.SmartRefreshLayout;
7 | import com.scwang.smartrefresh.layout.api.DefaultRefreshFooterCreator;
8 | import com.scwang.smartrefresh.layout.api.DefaultRefreshHeaderCreator;
9 | import com.scwang.smartrefresh.layout.api.RefreshFooter;
10 | import com.scwang.smartrefresh.layout.api.RefreshHeader;
11 | import com.scwang.smartrefresh.layout.api.RefreshLayout;
12 | import com.scwang.smartrefresh.layout.footer.ClassicsFooter;
13 | import com.scwang.smartrefresh.layout.header.ClassicsHeader;
14 | import com.zhy.http.okhttp.OkHttpUtils;
15 |
16 | import java.util.concurrent.TimeUnit;
17 |
18 | import okhttp3.OkHttpClient;
19 |
20 | /**
21 | * Created by huang on 2017/11/4.
22 | */
23 |
24 | public class BaseApplication extends android.support.multidex.MultiDexApplication {
25 | //static 代码段可以防止内存泄露
26 | static {
27 | //设置全局的Header构建器
28 | SmartRefreshLayout.setDefaultRefreshHeaderCreator(new DefaultRefreshHeaderCreator() {
29 | @Override
30 | public RefreshHeader createRefreshHeader(Context context, RefreshLayout layout) {
31 | layout.setPrimaryColorsId(R.color.windows_bg, R.color.text_color);//全局设置主题颜色
32 | return new ClassicsHeader(context);
33 | }
34 | });
35 | //设置全局的Footer构建器
36 | SmartRefreshLayout.setDefaultRefreshFooterCreator(new DefaultRefreshFooterCreator() {
37 | @Override
38 | public RefreshFooter createRefreshFooter(Context context, RefreshLayout layout) {
39 | //指定为经典Footer,默认是 BallPulseFooter
40 | return new ClassicsFooter(context).setDrawableSize(20);
41 | }
42 | });
43 |
44 | }
45 |
46 | @Override
47 | public void onCreate() {
48 | super.onCreate();
49 | OkHttpClient okHttpClient = new OkHttpClient.Builder()
50 | // .addInterceptor(new LoggerInterceptor("TAG"))
51 | .connectTimeout(10000L, TimeUnit.MILLISECONDS)
52 | .readTimeout(10000L, TimeUnit.MILLISECONDS)
53 | //其他配置
54 | .build();
55 | OkHttpUtils.initClient(okHttpClient);
56 |
57 | }
58 |
59 | }
60 |
--------------------------------------------------------------------------------
/app/src/main/java/com/bin/david/smarttable/JXLExcelModeActivity.java:
--------------------------------------------------------------------------------
1 | package com.bin.david.smarttable;
2 |
3 |
4 | import android.os.Bundle;
5 | import android.support.v7.app.AppCompatActivity;
6 | import android.support.v7.widget.LinearLayoutManager;
7 | import android.support.v7.widget.RecyclerView;
8 | import android.view.View;
9 |
10 | import com.bin.david.form.core.SmartTable;
11 |
12 | import com.bin.david.form.data.style.FontStyle;
13 | import com.bin.david.form.utils.DensityUtils;
14 | import com.bin.david.smarttable.adapter.SheetAdapter;
15 | import com.bin.david.smarttable.excel.ExcelCallback;
16 | import com.bin.david.smarttable.excel.IExcel2Table;
17 | import com.bin.david.smarttable.excel.JXLExcel2Table;
18 | import com.chad.library.adapter.base.BaseQuickAdapter;
19 |
20 |
21 | import java.util.List;
22 |
23 | import jxl.Cell;
24 |
25 |
26 | public class JXLExcelModeActivity extends AppCompatActivity implements ExcelCallback {
27 |
28 | private SmartTable table;
29 | private RecyclerView recyclerView;
30 | private String fileName = "ic_class.xls";
31 | private IExcel2Table iExcel2Table;
32 |
33 |
34 | @Override
35 | protected void onCreate(Bundle savedInstanceState) {
36 | super.onCreate(savedInstanceState);
37 | setContentView(R.layout.activity_excel_table);
38 | FontStyle.setDefaultTextSize(DensityUtils.sp2px(this,15));
39 | recyclerView = (RecyclerView) findViewById(R.id.recyclerView);
40 | recyclerView.setLayoutManager(new LinearLayoutManager(this,LinearLayoutManager.HORIZONTAL,false));
41 | table = (SmartTable) findViewById(R.id.table);
42 | iExcel2Table = new JXLExcel2Table();
43 | iExcel2Table.initTableConfig(this,table);
44 | iExcel2Table.setCallback(this);
45 | iExcel2Table.loadSheetList(this,fileName);
46 |
47 | }
48 |
49 |
50 |
51 | @Override
52 | protected void onDestroy() {
53 | if(iExcel2Table !=null){
54 | iExcel2Table.clear();
55 | }
56 | iExcel2Table = null;
57 | super.onDestroy();
58 | }
59 |
60 | @Override
61 | public void getSheetListSuc(List sheetNames) {
62 | recyclerView.setHasFixedSize(true);
63 | if(sheetNames!=null && sheetNames.size() >0) {
64 | final SheetAdapter sheetAdapter = new SheetAdapter(sheetNames);
65 | sheetAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
66 | @Override
67 | public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
68 | sheetAdapter.setSelectPosition(position);
69 | iExcel2Table.loadSheetContent(JXLExcelModeActivity.this,position);
70 | }
71 | });
72 | recyclerView.setAdapter(sheetAdapter);
73 | iExcel2Table.loadSheetContent(JXLExcelModeActivity.this,0);
74 | }
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/app/src/main/java/com/bin/david/smarttable/MergeModeActivity.java:
--------------------------------------------------------------------------------
1 | package com.bin.david.smarttable;
2 |
3 | import android.os.Bundle;
4 | import android.support.v7.app.AppCompatActivity;
5 | import android.view.View;
6 |
7 | import com.bin.david.form.core.SmartTable;
8 | import com.bin.david.form.data.style.FontStyle;
9 | import com.bin.david.form.utils.DensityUtils;
10 | import com.bin.david.smarttable.bean.ChildData;
11 | import com.bin.david.smarttable.bean.MergeInfo;
12 |
13 | import java.util.ArrayList;
14 | import java.util.List;
15 |
16 | public class MergeModeActivity extends AppCompatActivity {
17 |
18 | private SmartTable table;
19 | @Override
20 | protected void onCreate(Bundle savedInstanceState) {
21 | super.onCreate(savedInstanceState);
22 | setContentView(R.layout.activity_full_table);
23 | FontStyle.setDefaultTextSize(DensityUtils.sp2px(this,15));
24 |
25 | List list = new ArrayList<>();
26 | for(int i = 0;i <50; i++) {
27 | list.add(new MergeInfo("huangyanbinhuangyanbinhuangyanbinhuangyanbin", 18, System.currentTimeMillis(),true,new ChildData("测试1")));
28 | list.add(new MergeInfo("huangyanbinhuangyanbinhuangyanbinhuangyanbin", 18, System.currentTimeMillis(),true,new ChildData("测试1")));
29 | list.add(new MergeInfo("huangyanbinhuangyanbinhuangyanbinhuangyanbin", 18, System.currentTimeMillis(),true,new ChildData("测试1")));
30 | list.add(new MergeInfo("huangyanbinhuangyanbinhuangyanbinhuangyanbin", 18, System.currentTimeMillis(),true,new ChildData("测试1")));
31 | list.add(new MergeInfo("lihuangyanbinhuangyanbinhuangyanbinhuangyanbin", 23, System.currentTimeMillis(),false,null));
32 | list.add(new MergeInfo("lihuangyanbinhuangyanbinhuangyanbinhuangyanbin", 23, System.currentTimeMillis(),false,null));
33 | list.add(new MergeInfo("lihuangyanbinhuangyanbinhuangyanbinhuangyanbin", 23, System.currentTimeMillis(),false,null));
34 | list.add(new MergeInfo("lihuangyanbinhuangyanbinhuangyanbinhuangyanbin", 23, System.currentTimeMillis(),false,null));
35 | }
36 | table = (SmartTable) findViewById(R.id.table);
37 | table.setData(list);
38 | table.getConfig().setShowTableTitle(false);
39 | table.setZoom(true,2,0.2f);
40 |
41 | }
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/app/src/main/java/com/bin/david/smarttable/POIExcelModeActivity.java:
--------------------------------------------------------------------------------
1 | package com.bin.david.smarttable;
2 |
3 | import android.os.Bundle;
4 | import android.support.v7.app.AppCompatActivity;
5 | import android.support.v7.widget.LinearLayoutManager;
6 | import android.support.v7.widget.RecyclerView;
7 | import android.view.View;
8 |
9 | import com.bin.david.form.core.SmartTable;
10 |
11 | import com.bin.david.form.data.style.FontStyle;
12 | import com.bin.david.form.utils.DensityUtils;
13 | import com.bin.david.smarttable.adapter.SheetAdapter;
14 | import com.bin.david.smarttable.excel.ExcelCallback;
15 | import com.bin.david.smarttable.excel.IExcel2Table;
16 | import com.bin.david.smarttable.excel.POIExcel2Table;
17 | import com.chad.library.adapter.base.BaseQuickAdapter;
18 |
19 | import org.apache.poi.ss.usermodel.Cell;
20 |
21 | import java.util.List;
22 |
23 | /**
24 | * 通过poi来填充表格
25 | * 暂时只能支持xls
26 | */
27 | public class POIExcelModeActivity extends AppCompatActivity implements ExcelCallback {
28 |
29 | private SmartTable table;
30 |
31 | private RecyclerView recyclerView;
32 | private String fileName = "c.xls";
33 | private IExcel2Table iExcel2Table;
34 |
35 |
36 | @Override
37 | protected void onCreate(Bundle savedInstanceState) {
38 | super.onCreate(savedInstanceState);
39 | setContentView(R.layout.activity_excel_table);
40 | FontStyle.setDefaultTextSize(DensityUtils.sp2px(this,15));
41 | recyclerView = (RecyclerView) findViewById(R.id.recyclerView);
42 | recyclerView.setLayoutManager(new LinearLayoutManager(this,LinearLayoutManager.HORIZONTAL,false));
43 | table = (SmartTable) findViewById(R.id.table);
44 | iExcel2Table = new POIExcel2Table();
45 | iExcel2Table.initTableConfig(this,table);
46 | iExcel2Table.setCallback(this);
47 | iExcel2Table.loadSheetList(this,fileName);
48 |
49 |
50 |
51 |
52 | }
53 |
54 |
55 |
56 |
57 | @Override
58 | protected void onDestroy() {
59 | if(iExcel2Table !=null){
60 | iExcel2Table.clear();
61 | }
62 | iExcel2Table = null;
63 | super.onDestroy();
64 | }
65 |
66 | @Override
67 | public void getSheetListSuc(List sheetNames) {
68 | recyclerView.setHasFixedSize(true);
69 | if(sheetNames!=null && sheetNames.size() >0) {
70 | final SheetAdapter sheetAdapter = new SheetAdapter(sheetNames);
71 | sheetAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
72 | @Override
73 | public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
74 | sheetAdapter.setSelectPosition(position);
75 | iExcel2Table.loadSheetContent(POIExcelModeActivity.this,position);
76 | }
77 | });
78 | recyclerView.setAdapter(sheetAdapter);
79 | iExcel2Table.loadSheetContent(POIExcelModeActivity.this,0);
80 | }
81 | }
82 |
83 | }
84 |
--------------------------------------------------------------------------------
/app/src/main/java/com/bin/david/smarttable/TableListActivity.java:
--------------------------------------------------------------------------------
1 | package com.bin.david.smarttable;
2 |
3 | import android.os.Bundle;
4 | import android.support.annotation.Nullable;
5 | import android.support.v7.app.AppCompatActivity;
6 | import android.support.v7.widget.LinearLayoutManager;
7 | import android.support.v7.widget.RecyclerView;
8 |
9 | import com.bin.david.smarttable.adapter.TableListAdapter;
10 |
11 | import java.util.ArrayList;
12 |
13 | /**
14 | * Created by huang on 2017/10/18.
15 | */
16 |
17 | public class TableListActivity extends AppCompatActivity {
18 |
19 | private RecyclerView recyclerView;
20 | private TableListAdapter itemAdapter;
21 | @Override
22 | protected void onCreate(@Nullable Bundle savedInstanceState) {
23 | super.onCreate(savedInstanceState);
24 | setContentView(R.layout.activity_recycler);
25 | recyclerView = (RecyclerView) findViewById(R.id.recyclerView);
26 | recyclerView.setLayoutManager(new LinearLayoutManager(this));
27 | ArrayList items = new ArrayList<>();
28 | for(int i = 0;i <100;i++){
29 | items.add(i+"");
30 | }
31 | itemAdapter = new TableListAdapter(items);
32 | recyclerView.setAdapter(itemAdapter);
33 | itemAdapter.openLoadAnimation();
34 |
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/app/src/main/java/com/bin/david/smarttable/adapter/ItemAdapter.java:
--------------------------------------------------------------------------------
1 | package com.bin.david.smarttable.adapter;
2 |
3 | import android.support.annotation.Nullable;
4 |
5 | import com.bin.david.smarttable.R;
6 | import com.bin.david.smarttable.bean.MainItem;
7 | import com.chad.library.adapter.base.BaseQuickAdapter;
8 | import com.chad.library.adapter.base.BaseViewHolder;
9 |
10 | import java.util.List;
11 |
12 | /**
13 | * Created by huang on 2017/10/13.
14 | */
15 |
16 | public class ItemAdapter extends BaseQuickAdapter {
17 |
18 |
19 | public ItemAdapter(@Nullable List data) {
20 | super(R.layout.item_main, data);
21 | }
22 |
23 | @Override
24 | protected void convert(BaseViewHolder helper, MainItem item) {
25 | helper.setText(R.id.tv_chart_name,item.chartName);
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/app/src/main/java/com/bin/david/smarttable/adapter/SheetAdapter.java:
--------------------------------------------------------------------------------
1 | package com.bin.david.smarttable.adapter;
2 |
3 | import android.support.annotation.Nullable;
4 | import android.support.v4.content.ContextCompat;
5 |
6 | import com.bin.david.smarttable.R;
7 | import com.chad.library.adapter.base.BaseQuickAdapter;
8 | import com.chad.library.adapter.base.BaseViewHolder;
9 |
10 | import java.util.List;
11 |
12 | /**
13 | * Created by huang on 2018/1/16.
14 | */
15 |
16 | public class SheetAdapter extends BaseQuickAdapter{
17 |
18 | private int selectPosition =0;
19 | public SheetAdapter(@Nullable List data) {
20 | super(R.layout.item_sheet, data);
21 | }
22 |
23 | @Override
24 | protected void convert(BaseViewHolder helper, String item) {
25 | helper.setText(R.id.tv_sheet_name,item).setTextColor(R.id.tv_sheet_name,
26 | ContextCompat.getColor(mContext,
27 | selectPosition == helper.getAdapterPosition()?R.color.arc23:R.color.arc_temp));
28 | helper.getView(R.id.tv_sheet_name).setBackgroundColor( ContextCompat.getColor(mContext,
29 | selectPosition == helper.getAdapterPosition()?R.color.white:R.color.arc_bg));
30 | }
31 |
32 |
33 |
34 | public void setSelectPosition(int selectPosition) {
35 | this.selectPosition = selectPosition;
36 | notifyDataSetChanged();
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/app/src/main/java/com/bin/david/smarttable/adapter/TanTanAdapter.java:
--------------------------------------------------------------------------------
1 | package com.bin.david.smarttable.adapter;
2 |
3 | import android.net.Uri;
4 | import android.support.annotation.Nullable;
5 | import android.widget.ImageView;
6 |
7 | import com.bin.david.smarttable.R;
8 | import com.bin.david.smarttable.bean.MainItem;
9 | import com.bin.david.smarttable.bean.TanBean;
10 | import com.bumptech.glide.Glide;
11 | import com.chad.library.adapter.base.BaseQuickAdapter;
12 | import com.chad.library.adapter.base.BaseViewHolder;
13 |
14 | import java.util.List;
15 |
16 | /**
17 | * Created by huang on 2017/10/13.
18 | */
19 |
20 | public class TanTanAdapter extends BaseQuickAdapter {
21 |
22 |
23 | public TanTanAdapter(@Nullable List data) {
24 | super(R.layout.item_tantan, data);
25 | }
26 |
27 | @Override
28 | protected void convert(BaseViewHolder helper, TanBean item) {
29 | helper.setText(R.id.tvName,item.getName());
30 | Glide
31 | .with(mContext)
32 | .load(item.getUrl())
33 | .into((ImageView) helper.getView(R.id.iv));
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/app/src/main/java/com/bin/david/smarttable/bean/ChildData.java:
--------------------------------------------------------------------------------
1 | package com.bin.david.smarttable.bean;
2 |
3 |
4 | import com.bin.david.form.annotation.SmartColumn;
5 |
6 | /**
7 | * Created by huang on 2017/11/1.
8 | */
9 |
10 | public class ChildData {
11 |
12 | @SmartColumn(id =5,name = "子类",autoCount = true)
13 | private String child;
14 |
15 | public ChildData(String child) {
16 | this.child = child;
17 | }
18 |
19 | public String getChild() {
20 | return child;
21 | }
22 |
23 | public void setChild(String child) {
24 | this.child = child;
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/src/main/java/com/bin/david/smarttable/bean/CollegeStudent.java:
--------------------------------------------------------------------------------
1 | package com.bin.david.smarttable.bean;
2 |
3 | import com.bin.david.form.annotation.ColumnType;
4 | import com.bin.david.form.annotation.SmartColumn;
5 | import com.bin.david.form.annotation.SmartTable;
6 | import com.bin.david.smarttable.bean.Week;
7 |
8 | import java.util.List;
9 |
10 | /**
11 | * Created by huang on 2018/2/6.
12 | */
13 | @SmartTable(name = "课程表")
14 | public class CollegeStudent {
15 | @SmartColumn(id = 1,name ="姓名")
16 | private String name;
17 |
18 | @SmartColumn(type = ColumnType.ArrayChild)
19 | private List weeks;
20 | private int age;
21 |
22 | public CollegeStudent(String name, int age, List weeks) {
23 | this.name = name;
24 | this.age = age;
25 | this.weeks = weeks;
26 | }
27 |
28 | public String getName() {
29 | return name;
30 | }
31 |
32 | public void setName(String name) {
33 | this.name = name;
34 | }
35 |
36 | public int getAge() {
37 | return age;
38 | }
39 |
40 | public void setAge(int age) {
41 | this.age = age;
42 | }
43 |
44 | public List getWeeks() {
45 | return weeks;
46 | }
47 |
48 | public void setWeeks(List weeks) {
49 | this.weeks = weeks;
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/app/src/main/java/com/bin/david/smarttable/bean/Course.java:
--------------------------------------------------------------------------------
1 | package com.bin.david.smarttable.bean;
2 |
3 | /**
4 | * Created by huang on 2018/3/21.
5 | */
6 |
7 | public class Course {
8 |
9 | private String name;
10 | private int period;
11 |
12 | public Course(String name, int period) {
13 | this.name = name;
14 | this.period = period;
15 | }
16 |
17 | public String getName() {
18 | return name;
19 | }
20 |
21 | public void setName(String name) {
22 | this.name = name;
23 | }
24 |
25 | public int getPeriod() {
26 | return period;
27 | }
28 |
29 | public void setPeriod(int period) {
30 | this.period = period;
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/app/src/main/java/com/bin/david/smarttable/bean/DayTime.java:
--------------------------------------------------------------------------------
1 | package com.bin.david.smarttable.bean;
2 |
3 | import com.bin.david.form.annotation.ColumnType;
4 | import com.bin.david.form.annotation.SmartColumn;
5 |
6 | import java.util.List;
7 |
8 | /**
9 | * Created by huang on 2018/2/6.
10 | */
11 |
12 | public class DayTime {
13 | @SmartColumn(id=3,name ="时间")
14 | private String time;
15 | @SmartColumn(type = ColumnType.ArrayChild)
16 | private List lessons;
17 |
18 | public DayTime() {
19 | }
20 |
21 | public DayTime(String time, List lessons) {
22 | this.time = time;
23 | this.lessons = lessons;
24 | }
25 |
26 | public String getTime() {
27 | return time;
28 | }
29 |
30 | public void setTime(String time) {
31 | this.time = time;
32 | }
33 |
34 | public List getLessons() {
35 | return lessons;
36 | }
37 |
38 | public void setLessons(List lessons) {
39 | this.lessons = lessons;
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/app/src/main/java/com/bin/david/smarttable/bean/Form.java:
--------------------------------------------------------------------------------
1 | package com.bin.david.smarttable.bean;
2 |
3 | import android.graphics.Paint;
4 |
5 | import com.bin.david.form.data.form.IForm;
6 |
7 | /**
8 | * Created by huang on 2018/4/10.
9 | */
10 |
11 | public class Form implements IForm {
12 |
13 | private int spanWidthSize =1;
14 | private int spanHeightSize = 1;
15 | private String name;
16 | public static Form Empty = new Form("");
17 | private Paint.Align align;
18 | public Form(int spanWidthSize, int spanHeightSize, String name) {
19 | this.spanWidthSize = spanWidthSize;
20 | this.spanHeightSize = spanHeightSize;
21 | this.name = name;
22 | }
23 |
24 | public Form(int spanWidthSize, int spanHeightSize, String name, Paint.Align align) {
25 | this.spanWidthSize = spanWidthSize;
26 | this.spanHeightSize = spanHeightSize;
27 | this.name = name;
28 | this.align = align;
29 | }
30 |
31 | public Form(String name) {
32 | this.name = name;
33 | }
34 |
35 | public Form(String name, Paint.Align align) {
36 | this.name = name;
37 | this.align = align;
38 | }
39 |
40 | public void setAlign(Paint.Align align) {
41 | this.align = align;
42 | }
43 |
44 | public void setSpanWidthSize(int spanWidthSize) {
45 | this.spanWidthSize = spanWidthSize;
46 | }
47 |
48 | public void setSpanHeightSize(int spanHeightSize) {
49 | this.spanHeightSize = spanHeightSize;
50 | }
51 |
52 | public String getName() {
53 | return name;
54 | }
55 |
56 | public void setName(String name) {
57 | this.name = name;
58 | }
59 |
60 | @Override
61 | public int getSpanWidthSize() {
62 | return spanWidthSize;
63 | }
64 |
65 | @Override
66 | public int getSpanHeightSize() {
67 | return spanHeightSize;
68 | }
69 |
70 | @Override
71 | public Paint.Align getAlign() {
72 | if(align == null) {
73 | return Paint.Align.CENTER;
74 | }else {
75 | return align;
76 | }
77 | }
78 |
79 |
80 |
81 |
82 | }
83 |
--------------------------------------------------------------------------------
/app/src/main/java/com/bin/david/smarttable/bean/ImagePoint.java:
--------------------------------------------------------------------------------
1 | package com.bin.david.smarttable.bean;
2 |
3 | /**
4 | * Created by huang on 2018/1/18.
5 | */
6 |
7 | public class ImagePoint {
8 |
9 | public double col;
10 | public double row;
11 | public double width;
12 | public double height;
13 |
14 |
15 | public ImagePoint(double col, double row) {
16 | this.col = col;
17 | this.row = row;
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/app/src/main/java/com/bin/david/smarttable/bean/Lesson.java:
--------------------------------------------------------------------------------
1 | package com.bin.david.smarttable.bean;
2 |
3 | import com.bin.david.form.annotation.ColumnType;
4 | import com.bin.david.form.annotation.SmartColumn;
5 |
6 | import java.util.List;
7 |
8 | /**
9 | * Created by huang on 2018/2/1.
10 | */
11 |
12 | public class Lesson {
13 | @SmartColumn(id = 3,name = "课程名称")
14 | private String name;
15 | @SmartColumn(id = 5,name="是否喜欢")
16 | private boolean isFav;
17 | @SmartColumn(type = ColumnType.ArrayChild)
18 | private LessonPoint[] lessonPoints;
19 | //@SmartColumn(type = ColumnType.ArrayOwn)
20 | private List test;
21 |
22 | public Lesson(String name, boolean isFav) {
23 | this.name = name;
24 | this.isFav = isFav;
25 | }
26 |
27 | public String getName() {
28 | return name;
29 | }
30 |
31 | public void setName(String name) {
32 | this.name = name;
33 | }
34 |
35 | public boolean isFav() {
36 | return isFav;
37 | }
38 |
39 | public void setFav(boolean fav) {
40 | isFav = fav;
41 | }
42 |
43 | public List getTest() {
44 | return test;
45 | }
46 |
47 | public void setTest(List test) {
48 | this.test = test;
49 | }
50 |
51 | public LessonPoint[] getLessonPoints() {
52 | return lessonPoints;
53 | }
54 |
55 | public void setLessonPoints(LessonPoint[] lessonPoints) {
56 | this.lessonPoints = lessonPoints;
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/app/src/main/java/com/bin/david/smarttable/bean/LessonPoint.java:
--------------------------------------------------------------------------------
1 | package com.bin.david.smarttable.bean;
2 |
3 | import com.bin.david.form.annotation.ColumnType;
4 | import com.bin.david.form.annotation.SmartColumn;
5 |
6 |
7 | /**
8 | * Created by huang on 2018/2/2.
9 | */
10 |
11 | public class LessonPoint {
12 |
13 | @SmartColumn(id=4,name="知识点")
14 | private String name;
15 | public LessonPoint(String name) {
16 | this.name = name;
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/app/src/main/java/com/bin/david/smarttable/bean/MainItem.java:
--------------------------------------------------------------------------------
1 | package com.bin.david.smarttable.bean;
2 |
3 | /**
4 | * Created by huang on 2017/10/13.
5 | */
6 |
7 | public class MainItem {
8 |
9 | public Class clazz;
10 | public String chartName;
11 |
12 | public MainItem(Class clazz, String chartName) {
13 | this.clazz = clazz;
14 | this.chartName = chartName;
15 | }
16 |
17 | public Class getClazz() {
18 | return clazz;
19 | }
20 |
21 | public void setClazz(Class clazz) {
22 | this.clazz = clazz;
23 | }
24 |
25 | public String getChartName() {
26 | return chartName;
27 | }
28 |
29 | public void setChartName(String chartName) {
30 | this.chartName = chartName;
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/app/src/main/java/com/bin/david/smarttable/bean/MergeInfo.java:
--------------------------------------------------------------------------------
1 | package com.bin.david.smarttable.bean;
2 |
3 | import com.bin.david.form.annotation.ColumnType;
4 | import com.bin.david.form.annotation.SmartColumn;
5 | import com.bin.david.form.annotation.SmartTable;
6 |
7 | import java.util.List;
8 |
9 | /**
10 | * Created by huang on 2017/11/1.
11 | */
12 | @SmartTable(name="合并信息列表",count = true)
13 | public class MergeInfo {
14 | @SmartColumn(id =1,name = "姓名",autoCount = true,autoMerge = true,width = 100)
15 | private String name;
16 | @SmartColumn(id=2,name="年龄",autoCount = true,autoMerge = true)
17 | private int age;
18 | @SmartColumn(id =3,name="更新时间")
19 | private long time;
20 | @SmartColumn(type= ColumnType.Child)
21 | private ChildData childData;
22 | @SmartColumn(id =4,name="选中")
23 | private boolean isCheck;
24 | private String url;
25 |
26 | public MergeInfo(String name, int age, long time, boolean isCheck, ChildData childData) {
27 | this.name = name;
28 | this.age = age;
29 | this.time = time;
30 | this.childData = childData;
31 | this.isCheck = isCheck;
32 | }
33 |
34 | public boolean isCheck() {
35 | return isCheck;
36 | }
37 |
38 | public void setCheck(boolean check) {
39 | isCheck = check;
40 | }
41 |
42 | public String getName() {
43 | return name;
44 | }
45 |
46 | public void setName(String name) {
47 | this.name = name;
48 | }
49 |
50 | public int getAge() {
51 | return age;
52 | }
53 |
54 | public void setAge(int age) {
55 | this.age = age;
56 | }
57 |
58 | public long getTime() {
59 | return time;
60 | }
61 |
62 | public void setTime(long time) {
63 | this.time = time;
64 | }
65 |
66 | public ChildData getChildData() {
67 | return childData;
68 | }
69 |
70 | public void setChildData(ChildData childData) {
71 | this.childData = childData;
72 | }
73 |
74 | public String getUrl() {
75 | return url;
76 | }
77 |
78 | public void setUrl(String url) {
79 | this.url = url;
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/app/src/main/java/com/bin/david/smarttable/bean/PM25.java:
--------------------------------------------------------------------------------
1 | package com.bin.david.smarttable.bean;
2 |
3 | import android.graphics.Paint;
4 |
5 | import com.bin.david.form.annotation.SmartColumn;
6 | import com.bin.david.form.annotation.SmartTable;
7 |
8 | /**
9 | * Created by huang on 2017/11/4.
10 | */
11 | @SmartTable(name = "PM2.5")
12 | public class PM25 {
13 |
14 |
15 | /**
16 | * aqi : 27
17 | * area : 上海
18 | * pm10 : 27
19 | * pm10_24h : 58
20 | * position_name : 徐汇上师大
21 | * primary_pollutant : null
22 | * quality : 优
23 | * station_code : 1144A
24 | * time_point : 2017-11-04T13:00:00Z
25 | */
26 |
27 | private int aqi;
28 | @SmartColumn(id =1,name="地区",align = Paint.Align.LEFT,fixed = true)
29 | private String area;
30 | @SmartColumn(parent = "PM",id =3,name="PM10",align = Paint.Align.RIGHT)
31 | private int pm10;
32 | @SmartColumn(parent = "PM",id =2,name="PM10 24小时")
33 | private int pm10_24h;
34 | @SmartColumn(id=4,name = "地址")
35 | private String position_name;
36 | @SmartColumn(id=6,name="首要污染物")
37 | private Object primary_pollutant;
38 | @SmartColumn(id=5,name = "空气质量")
39 | private String quality;
40 | @SmartColumn(id=3,name = "坐标代码")
41 | private String station_code;
42 | @SmartColumn(id=7,name = "更新时间")
43 | private String time_point;
44 |
45 | public int getAqi() {
46 | return aqi;
47 | }
48 |
49 | public void setAqi(int aqi) {
50 | this.aqi = aqi;
51 | }
52 |
53 | public String getArea() {
54 | return area;
55 | }
56 |
57 | public void setArea(String area) {
58 | this.area = area;
59 | }
60 |
61 | public int getPm10() {
62 | return pm10;
63 | }
64 |
65 | public void setPm10(int pm10) {
66 | this.pm10 = pm10;
67 | }
68 |
69 | public int getPm10_24h() {
70 | return pm10_24h;
71 | }
72 |
73 | public void setPm10_24h(int pm10_24h) {
74 | this.pm10_24h = pm10_24h;
75 | }
76 |
77 | public String getPosition_name() {
78 | return position_name;
79 | }
80 |
81 | public void setPosition_name(String position_name) {
82 | this.position_name = position_name;
83 | }
84 |
85 | public Object getPrimary_pollutant() {
86 | return primary_pollutant;
87 | }
88 |
89 | public void setPrimary_pollutant(Object primary_pollutant) {
90 | this.primary_pollutant = primary_pollutant;
91 | }
92 |
93 | public String getQuality() {
94 | return quality;
95 | }
96 |
97 | public void setQuality(String quality) {
98 | this.quality = quality;
99 | }
100 |
101 | public String getStation_code() {
102 | return station_code;
103 | }
104 |
105 | public void setStation_code(String station_code) {
106 | this.station_code = station_code;
107 | }
108 |
109 | public String getTime_point() {
110 | return time_point;
111 | }
112 |
113 | public void setTime_point(String time_point) {
114 | this.time_point = time_point;
115 | }
116 | }
117 |
--------------------------------------------------------------------------------
/app/src/main/java/com/bin/david/smarttable/bean/Student.java:
--------------------------------------------------------------------------------
1 | package com.bin.david.smarttable.bean;
2 |
3 | import com.bin.david.form.annotation.ColumnType;
4 | import com.bin.david.form.annotation.SmartColumn;
5 | import com.bin.david.form.annotation.SmartTable;
6 |
7 | import java.util.List;
8 |
9 | /**
10 | * Created by huang on 2017/11/1.
11 | */
12 | @SmartTable(name="学生信息列表",count = true)
13 | public class Student {
14 | @SmartColumn(id =1,name = "姓名",autoCount = true)
15 | private String name;
16 | @SmartColumn(id=8,name="年龄",autoCount = true)
17 | private int age;
18 | @SmartColumn(id =7,name="更新时间")
19 | private long time;
20 | @SmartColumn(type= ColumnType.Child)
21 | private ChildData childData;
22 | @SmartColumn(id =6,name="选中")
23 | private boolean isCheck;
24 | @SmartColumn(id=8,name="测试Double",autoCount = true)
25 | private double data =5;
26 | private String url;
27 | @SmartColumn(type = ColumnType.ArrayChild)
28 | private List lessons;
29 |
30 | public Student(String name, int age, long time, boolean isCheck, ChildData childData) {
31 | this.name = name;
32 | this.age = age;
33 | this.time = time;
34 | this.childData = childData;
35 | this.isCheck = isCheck;
36 | }
37 |
38 | public boolean isCheck() {
39 | return isCheck;
40 | }
41 |
42 | public void setCheck(boolean check) {
43 | isCheck = check;
44 | }
45 |
46 | public String getName() {
47 | return name;
48 | }
49 |
50 | public void setName(String name) {
51 | this.name = name;
52 | }
53 |
54 | public int getAge() {
55 | return age;
56 | }
57 |
58 | public void setAge(int age) {
59 | this.age = age;
60 | }
61 |
62 | public long getTime() {
63 | return time;
64 | }
65 |
66 | public void setTime(long time) {
67 | this.time = time;
68 | }
69 |
70 | public ChildData getChildData() {
71 | return childData;
72 | }
73 |
74 | public void setChildData(ChildData childData) {
75 | this.childData = childData;
76 | }
77 |
78 | public String getUrl() {
79 | return url;
80 | }
81 |
82 | public void setUrl(String url) {
83 | this.url = url;
84 | }
85 |
86 | public List getLessons() {
87 | return lessons;
88 | }
89 |
90 | public void setLessons(List lessons) {
91 | this.lessons = lessons;
92 | }
93 |
94 | }
95 |
--------------------------------------------------------------------------------
/app/src/main/java/com/bin/david/smarttable/bean/StudentInfo.java:
--------------------------------------------------------------------------------
1 | package com.bin.david.smarttable.bean;
2 |
3 | /**
4 | * Created by huang on 2018/3/11.
5 | */
6 |
7 | public class StudentInfo {
8 |
9 | private String name;
10 | private String url;
11 |
12 | public StudentInfo(String name) {
13 | this.name = name;
14 | }
15 |
16 | public String getName() {
17 | return name;
18 | }
19 |
20 | public void setName(String name) {
21 | this.name = name;
22 | }
23 |
24 | public String getUrl() {
25 | return url;
26 | }
27 |
28 | public void setUrl(String url) {
29 | this.url = url;
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/app/src/main/java/com/bin/david/smarttable/bean/TableStyle.java:
--------------------------------------------------------------------------------
1 | package com.bin.david.smarttable.bean;
2 |
3 | /**
4 | * Created by huang on 2017/10/13.
5 | */
6 |
7 | public enum TableStyle {
8 |
9 | FIXED_X_AXIS("固定顶部"),
10 | FIXED_Y_AXIS("固定左侧"),
11 | FIXED_TITLE("固定标题"),
12 | @Deprecated
13 | FIXED_FIRST_COLUMN("固定第一列"),
14 | FIXED_COUNT_ROW("固定统计行"),
15 | ZOOM("是否缩放"),
16 | ALIGN("文字位置"),
17 | ANIM("动画"),
18 | FLING("Fling"),
19 | SHOW_SEQ("隐藏序列");
20 |
21 |
22 |
23 |
24 |
25 | public String value;
26 |
27 | TableStyle(String value){
28 | this.value = value;
29 | }
30 |
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/app/src/main/java/com/bin/david/smarttable/bean/TanBean.java:
--------------------------------------------------------------------------------
1 | package com.bin.david.smarttable.bean;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 |
6 | /**
7 | * Created by huang on 2017/11/9.
8 | */
9 |
10 | public class TanBean {
11 |
12 | private int position;
13 | private String url;
14 | private String name;
15 |
16 | public TanBean(int position, String url, String name) {
17 | this.position = position;
18 | this.url = url;
19 | this.name = name;
20 | }
21 |
22 | public static List initDatas() {
23 | List datas = new ArrayList<>();
24 | int i = 1;
25 | datas.add(new TanBean(i++, "http://imgs.ebrun.com/resources/2016_03/2016_03_25/201603259771458878793312_origin.jpg", "张"));
26 | datas.add(new TanBean(i++, "http://p14.go007.com/2014_11_02_05/a03541088cce31b8_1.jpg", "旭童"));
27 | datas.add(new TanBean(i++, "http://news.k618.cn/tech/201604/W020160407281077548026.jpg", "多种type"));
28 | datas.add(new TanBean(i++, "http://www.kejik.com/image/1460343965520.jpg", "多种type"));
29 | datas.add(new TanBean(i++, "http://cn.chinadaily.com.cn/img/attachement/jpg/site1/20160318/eca86bd77be61855f1b81c.jpg", "多种type"));
30 | datas.add(new TanBean(i++, "http://imgs.ebrun.com/resources/2016_04/2016_04_12/201604124411460430531500.jpg", "多种type"));
31 | datas.add(new TanBean(i++, "http://imgs.ebrun.com/resources/2016_04/2016_04_24/201604244971461460826484_origin.jpeg", "多种type"));
32 | datas.add(new TanBean(i++, "http://www.lnmoto.cn/bbs/data/attachment/forum/201408/12/074018gshshia3is1cw3sg.jpg", "多种type"));
33 | return datas;
34 | }
35 |
36 | public int getPosition() {
37 | return position;
38 | }
39 |
40 | public void setPosition(int position) {
41 | this.position = position;
42 | }
43 |
44 | public String getUrl() {
45 | return url;
46 | }
47 |
48 | public void setUrl(String url) {
49 | this.url = url;
50 | }
51 |
52 | public String getName() {
53 | return name;
54 | }
55 |
56 | public void setName(String name) {
57 | this.name = name;
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/app/src/main/java/com/bin/david/smarttable/bean/UserInfo.java:
--------------------------------------------------------------------------------
1 | package com.bin.david.smarttable.bean;
2 |
3 | import com.bin.david.form.annotation.ColumnType;
4 | import com.bin.david.form.annotation.SmartColumn;
5 | import com.bin.david.form.annotation.SmartTable;
6 | import com.bin.david.smarttable.bean.ChildData;
7 |
8 | import java.util.List;
9 |
10 | /**
11 | * Created by huang on 2017/11/1.
12 | */
13 | public class UserInfo {
14 | private String name;
15 | private int age;
16 | private long time;
17 | private ChildData childData;
18 | private boolean isCheck;
19 | private String url;
20 | private Boolean isTest;
21 |
22 |
23 | public UserInfo(String name, int age, long time, boolean isCheck, ChildData childData) {
24 | this.name = name;
25 | this.age = age;
26 | this.time = time;
27 | this.childData = childData;
28 | this.isCheck = isCheck;
29 | }
30 |
31 | public boolean isCheck() {
32 | return isCheck;
33 | }
34 |
35 | public void setCheck(boolean check) {
36 | isCheck = check;
37 | }
38 |
39 | public String getName() {
40 | return name;
41 | }
42 |
43 | public void setName(String name) {
44 | this.name = name;
45 | }
46 |
47 | public int getAge() {
48 | return age;
49 | }
50 |
51 | public void setAge(int age) {
52 | this.age = age;
53 | }
54 |
55 | public long getTime() {
56 | return time;
57 | }
58 |
59 | public void setTime(long time) {
60 | this.time = time;
61 | }
62 |
63 | public ChildData getChildData() {
64 | return childData;
65 | }
66 |
67 | public void setChildData(ChildData childData) {
68 | this.childData = childData;
69 | }
70 |
71 | public String getUrl() {
72 | return url;
73 | }
74 |
75 | public void setUrl(String url) {
76 | this.url = url;
77 | }
78 |
79 | }
80 |
--------------------------------------------------------------------------------
/app/src/main/java/com/bin/david/smarttable/bean/Week.java:
--------------------------------------------------------------------------------
1 | package com.bin.david.smarttable.bean;
2 |
3 | import com.bin.david.form.annotation.ColumnType;
4 | import com.bin.david.form.annotation.SmartColumn;
5 |
6 | import java.util.List;
7 |
8 | /**
9 | * Created by huang on 2018/2/6.
10 | */
11 |
12 | public class Week {
13 | @SmartColumn(id=2,name ="星期")
14 | private String name;
15 | @SmartColumn(type = ColumnType.ArrayChild)
16 | private List times;
17 |
18 | public Week(String name, List times) {
19 | this.name = name;
20 | this.times = times;
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/app/src/main/java/com/bin/david/smarttable/excel/ExcelCallback.java:
--------------------------------------------------------------------------------
1 | package com.bin.david.smarttable.excel;
2 | import java.util.List;
3 |
4 | /**
5 | * Created by huang on 2018/1/23.
6 | */
7 |
8 | public interface ExcelCallback {
9 |
10 | void getSheetListSuc(List sheetNames);
11 |
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/app/src/main/java/com/bin/david/smarttable/excel/IExcel2Table.java:
--------------------------------------------------------------------------------
1 | package com.bin.david.smarttable.excel;
2 |
3 | import android.content.Context;
4 |
5 | import com.bin.david.form.core.SmartTable;
6 |
7 |
8 | /**
9 | * Created by huang on 2018/1/23.
10 | * excel 转换的接口
11 | */
12 |
13 | public interface IExcel2Table {
14 | /**
15 | * 初始化表格配置
16 | * @param context
17 | * @param table
18 | */
19 | void initTableConfig(Context context,SmartTable table);
20 |
21 | /**
22 | * 回调
23 | * @param excelCallback
24 | */
25 | void setCallback(ExcelCallback excelCallback);
26 |
27 | /**
28 | * 加载Sheet
29 | * @param context
30 | * @param fileName
31 | */
32 | void loadSheetList(Context context,String fileName);
33 |
34 | /**
35 | * 加载表格Sheet内容
36 | * @param context
37 | * @param position
38 | */
39 | void loadSheetContent(Context context, int position);
40 |
41 | /**
42 | * 清理数据
43 | */
44 | void clear();
45 |
46 | void setIsAssetsFile(boolean isAssetsFile);
47 |
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/app/src/main/java/com/bin/david/smarttable/layoutManager/TanTanLayoutManager.java:
--------------------------------------------------------------------------------
1 | package com.bin.david.smarttable.layoutManager;
2 |
3 | import android.support.v7.widget.RecyclerView;
4 | import android.support.v7.widget.RecyclerView.LayoutManager;
5 | import android.util.SparseArray;
6 | import android.view.View;
7 |
8 | import java.util.HashMap;
9 |
10 | /**
11 | * Created by huang on 2017/11/9.
12 | */
13 |
14 | public class TanTanLayoutManager extends LayoutManager {
15 |
16 | public static final int MAX_SHOW_COUNT = 4;
17 | public static final float SCALE = 0.05f;
18 | public static final int MAX_TRANSLATION_Y = 20;
19 | @Override
20 | public RecyclerView.LayoutParams generateDefaultLayoutParams() {
21 |
22 | return new RecyclerView.LayoutParams(RecyclerView.LayoutParams.WRAP_CONTENT, RecyclerView.LayoutParams.WRAP_CONTENT);
23 | }
24 |
25 | @Override
26 | public void onLayoutChildren(RecyclerView.Recycler recycler, RecyclerView.State state) {
27 | detachAndScrapAttachedViews(recycler);
28 | int itemCount = getItemCount();
29 | if(itemCount < MAX_SHOW_COUNT){
30 | return;
31 | }
32 | for(int position = MAX_SHOW_COUNT -1; position>=0; position--){
33 | View child = recycler.getViewForPosition(position);
34 | addView(child);
35 | measureChildWithMargins(child,0,0);
36 | int width = getDecoratedMeasuredWidth(child);
37 | int height = getDecoratedMeasuredHeight(child);
38 | int left = (getWidth() - width/2)/2;
39 | int right = left + width/2;
40 | int top = (getHeight() - height/2)/2;
41 | int bottom = top+ height/2;
42 | layoutDecoratedWithMargins(child,left,top,right,bottom);
43 | int level = position;
44 | if(level ==0){
45 | child.setScaleX(1);
46 | child.setTranslationY(0);
47 | }else if(level < MAX_SHOW_COUNT-1){
48 | child.setScaleX(1-SCALE*level);
49 | child.setTranslationY(MAX_TRANSLATION_Y *level);
50 | }else{
51 | child.setScaleX(1-SCALE*(level-1));
52 | child.setTranslationY(MAX_TRANSLATION_Y *(level-1));
53 | }
54 |
55 | }
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/app/src/main/java/com/bin/david/smarttable/utils/DrawHelper.java:
--------------------------------------------------------------------------------
1 | package com.bin.david.smarttable.utils;
2 |
3 | import android.graphics.Bitmap;
4 | import android.graphics.Canvas;
5 | import android.graphics.Paint;
6 | import android.graphics.Rect;
7 |
8 | import com.bin.david.form.core.TableConfig;
9 |
10 | /**
11 | * Created by huang on 2018/1/18.
12 | */
13 |
14 | public class DrawHelper {
15 |
16 | /**
17 | * 绘制图片
18 | * @param c 画布
19 | * @param rect 绘制大小
20 | * @param bitmap 位图
21 | * @param config 配置
22 | */
23 | public static void drawBitmap(Canvas c, Rect rect, Bitmap bitmap, TableConfig config) {
24 | if (bitmap != null) {
25 | config.getPaint().setStyle(Paint.Style.FILL);
26 | int width = bitmap.getWidth();
27 | int height = bitmap.getHeight();
28 | Rect imgRect= new Rect(0,0,width,height);
29 | float scaleX = (float) width / rect.width();
30 | float scaleY = (float) height / rect.height();
31 | if (scaleX > 1 || scaleY > 1) {
32 | if (scaleX > scaleY) {
33 | width = (int) (width / scaleX);
34 | height = rect.height();
35 | } else {
36 | height = (int) (height / scaleY);
37 | width = rect.width();
38 | }
39 | }
40 | width = (int) (width * config.getZoom());
41 | height = (int) (height * config.getZoom());
42 | int disX = (rect.right - rect.left - width) / 2;
43 | int disY = (rect.bottom - rect.top - height) / 2;
44 | Rect drawRect = new Rect();
45 | drawRect.left = rect.left + disX;
46 | drawRect.top = rect.top + disY;
47 | drawRect.right = rect.right - disX;
48 | drawRect.bottom = rect.bottom - disY;
49 | c.drawBitmap(bitmap, imgRect, drawRect, config.getPaint());
50 | }
51 | }
52 |
53 | }
54 |
--------------------------------------------------------------------------------
/app/src/main/java/com/bin/david/smarttable/utils/ExcelHelper.java:
--------------------------------------------------------------------------------
1 | package com.bin.david.smarttable.utils;
2 |
3 | import org.apache.poi.hssf.usermodel.HSSFCell;
4 | import org.apache.poi.hssf.usermodel.HSSFDateUtil;
5 | import org.apache.poi.ss.usermodel.Cell;
6 |
7 | import java.text.DecimalFormat;
8 | import java.text.SimpleDateFormat;
9 | import java.util.Date;
10 |
11 | /**
12 | * Created by huang on 2018/1/23.
13 | */
14 |
15 | public class ExcelHelper {
16 |
17 | public static String getCellValue(Cell cell){
18 | String value;
19 | switch (cell.getCellType()) {
20 | case Cell.CELL_TYPE_NUMERIC: // 数字
21 | value = cell.getNumericCellValue() + "";
22 | if (HSSFDateUtil.isCellDateFormatted(cell)) {
23 | Date date = cell.getDateCellValue();
24 | if (date != null) {
25 | value = new SimpleDateFormat("yyyy-MM-dd").format(date);
26 | } else {
27 | value = "";
28 | }
29 | } else {
30 | value = new DecimalFormat("0").format(cell.getNumericCellValue());
31 | }
32 | break;
33 | case HSSFCell.CELL_TYPE_STRING: // 字符串
34 | value = cell.getStringCellValue();
35 | break;
36 | case HSSFCell.CELL_TYPE_BOOLEAN: // Boolean
37 | value = cell.getBooleanCellValue() + "";
38 | break;
39 | case HSSFCell.CELL_TYPE_FORMULA: // 公式
40 | value = cell.getCellFormula() + "";
41 | break;
42 | case HSSFCell.CELL_TYPE_BLANK: // 空值
43 | value = "";
44 | break;
45 | case HSSFCell.CELL_TYPE_ERROR: // 故障
46 | value = "非法字符";
47 | break;
48 | default:
49 | value = "未知类型";
50 | break;
51 | }
52 | return value;
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/app/src/main/java/com/bin/david/smarttable/view/GlideCircleTransform.java:
--------------------------------------------------------------------------------
1 | package com.bin.david.smarttable.view;
2 |
3 |
4 | import android.content.Context;
5 | import android.graphics.Bitmap;
6 | import android.graphics.BitmapShader;
7 | import android.graphics.Canvas;
8 | import android.graphics.Paint;
9 |
10 | import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
11 | import com.bumptech.glide.load.resource.bitmap.BitmapTransformation;
12 |
13 | import java.security.MessageDigest;
14 |
15 | public class GlideCircleTransform extends BitmapTransformation {
16 |
17 |
18 | @Override protected Bitmap transform(BitmapPool pool, Bitmap toTransform, int outWidth, int outHeight) {
19 | return circleCrop(pool, toTransform);
20 | }
21 |
22 | private static Bitmap circleCrop(BitmapPool pool, Bitmap source) {
23 | if (source == null) return null;
24 |
25 | int size = Math.min(source.getWidth(), source.getHeight());
26 | int x = (source.getWidth() - size) / 2;
27 | int y = (source.getHeight() - size) / 2;
28 |
29 | // TODO this could be acquired from the pool too
30 | Bitmap squared = Bitmap.createBitmap(source, x, y, size, size);
31 |
32 | Bitmap result = pool.get(size, size, Bitmap.Config.ARGB_8888);
33 | if (result == null) {
34 | result = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888);
35 | }
36 |
37 | Canvas canvas = new Canvas(result);
38 | Paint paint = new Paint();
39 | paint.setShader(new BitmapShader(squared, BitmapShader.TileMode.CLAMP, BitmapShader.TileMode.CLAMP));
40 | paint.setAntiAlias(true);
41 | float r = size / 2f;
42 | canvas.drawCircle(r, r, r, paint);
43 | return result;
44 | }
45 |
46 |
47 | @Override
48 | public void updateDiskCacheKey(MessageDigest messageDigest) {
49 |
50 | }
51 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/bin/david/smarttable/view/QuickChartDialog.java:
--------------------------------------------------------------------------------
1 | package com.bin.david.smarttable.view;
2 |
3 | import android.app.Activity;
4 |
5 |
6 | import com.bin.david.smarttable.bean.TableStyle;
7 |
8 | import java.util.Arrays;
9 | import java.util.HashMap;
10 | import java.util.Map;
11 |
12 | /**
13 | * Created by huang on 2017/10/13.
14 | */
15 |
16 | public class QuickChartDialog {
17 | private Map> map;
18 |
19 | public QuickChartDialog(){
20 | map = new HashMap<>();
21 | }
22 |
23 | public void showDialog(Activity activity, TableStyle chartStyle, String[] dataList, OnCheckChangeAdapter adapter){
24 | BaseCheckDialog dialog;
25 | if(map.containsKey(chartStyle)){
26 | dialog = map.get(chartStyle);
27 | }else {
28 | dialog = new BaseCheckDialog<>(chartStyle.value,adapter);
29 | }
30 | map.put(chartStyle,dialog);
31 | dialog.show(activity,false, Arrays.asList(dataList));
32 | }
33 |
34 | public abstract static class OnCheckChangeAdapter implements BaseCheckDialog.OnCheckChangeListener {
35 | @Override
36 | public String getItemText(String s) {
37 | return s;
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/app/src/main/res/anim/fade_in_center.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
14 |
15 |
18 |
19 |
--------------------------------------------------------------------------------
/app/src/main/res/anim/fade_out_center.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
14 |
15 |
18 |
19 |
--------------------------------------------------------------------------------
/app/src/main/res/anim/modal_in.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
10 |
11 |
19 |
20 |
29 |
30 |
39 |
--------------------------------------------------------------------------------
/app/src/main/res/anim/modal_out.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
14 |
18 |
--------------------------------------------------------------------------------
/app/src/main/res/anim/out_to_left.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/anim/slide_in_bottom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/anim/slide_in_top.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/anim/slide_left_in.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/anim/slide_left_out.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/anim/slide_out_bottom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/anim/slide_out_top.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/anim/slide_right_in.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/anim/slide_right_out.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/cal_sign_bg.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huangyanbin/smartTable/fe975d333a79586261f4f265317b9d1e6f2a36fa/app/src/main/res/drawable/cal_sign_bg.9.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/cal_sign_bg2.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huangyanbin/smartTable/fe975d333a79586261f4f265317b9d1e6f2a36fa/app/src/main/res/drawable/cal_sign_bg2.9.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/checkbox_btn_drawable.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
9 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/dialog_btn_bg.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/dialog_white_bg.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/dialog_window_bg.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/side_nav_bar.xml:
--------------------------------------------------------------------------------
1 |
3 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_annotation.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
18 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_choice_excel.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
15 |
16 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_edit_table.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
17 |
24 |
41 |
42 |
50 |
51 |
52 |
53 |
54 |
55 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_excel_table.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
19 |
21 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_full_table.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_pager.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
19 |
24 |
35 |
46 |
47 |
48 |
49 |
50 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_recycler.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_refresh_table.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_scroll_table.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
11 |
15 |
16 |
21 |
22 |
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_seat_table.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_table.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
20 |
21 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_weclome.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
16 |
17 |
18 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/app_bar_choice_excel.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
14 |
15 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/content_choice_excel.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
18 |
20 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/dialog_chart.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
16 |
18 |
23 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
15 |
17 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_pop_calculator.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
16 |
24 |
27 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_sheet.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
14 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_table.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_tantan.xml:
--------------------------------------------------------------------------------
1 |
2 |
12 |
13 |
19 |
20 |
29 |
30 |
37 |
38 |
46 |
47 |
55 |
56 |
64 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/nav_header_choice_excel.xml:
--------------------------------------------------------------------------------
1 |
2 |
14 |
15 |
21 |
22 |
28 |
29 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/pop_base_check.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
16 |
18 |
22 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/activity_choice_excel_drawer.xml:
--------------------------------------------------------------------------------
1 |
2 |
19 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/choice_excel.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huangyanbin/smartTable/fe975d333a79586261f4f265317b9d1e6f2a36fa/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huangyanbin/smartTable/fe975d333a79586261f4f265317b9d1e6f2a36fa/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huangyanbin/smartTable/fe975d333a79586261f4f265317b9d1e6f2a36fa/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huangyanbin/smartTable/fe975d333a79586261f4f265317b9d1e6f2a36fa/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/a9m.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huangyanbin/smartTable/fe975d333a79586261f4f265317b9d1e6f2a36fa/app/src/main/res/mipmap-xhdpi/a9m.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/activity_fill.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huangyanbin/smartTable/fe975d333a79586261f4f265317b9d1e6f2a36fa/app/src/main/res/mipmap-xhdpi/activity_fill.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/age.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huangyanbin/smartTable/fe975d333a79586261f4f265317b9d1e6f2a36fa/app/src/main/res/mipmap-xhdpi/age.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/avator_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huangyanbin/smartTable/fe975d333a79586261f4f265317b9d1e6f2a36fa/app/src/main/res/mipmap-xhdpi/avator_1.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/avator_10.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huangyanbin/smartTable/fe975d333a79586261f4f265317b9d1e6f2a36fa/app/src/main/res/mipmap-xhdpi/avator_10.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/avator_11.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huangyanbin/smartTable/fe975d333a79586261f4f265317b9d1e6f2a36fa/app/src/main/res/mipmap-xhdpi/avator_11.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/avator_12.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huangyanbin/smartTable/fe975d333a79586261f4f265317b9d1e6f2a36fa/app/src/main/res/mipmap-xhdpi/avator_12.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/avator_13.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huangyanbin/smartTable/fe975d333a79586261f4f265317b9d1e6f2a36fa/app/src/main/res/mipmap-xhdpi/avator_13.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/avator_14.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huangyanbin/smartTable/fe975d333a79586261f4f265317b9d1e6f2a36fa/app/src/main/res/mipmap-xhdpi/avator_14.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/avator_15.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huangyanbin/smartTable/fe975d333a79586261f4f265317b9d1e6f2a36fa/app/src/main/res/mipmap-xhdpi/avator_15.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/avator_16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huangyanbin/smartTable/fe975d333a79586261f4f265317b9d1e6f2a36fa/app/src/main/res/mipmap-xhdpi/avator_16.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/avator_17.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huangyanbin/smartTable/fe975d333a79586261f4f265317b9d1e6f2a36fa/app/src/main/res/mipmap-xhdpi/avator_17.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/avator_18.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huangyanbin/smartTable/fe975d333a79586261f4f265317b9d1e6f2a36fa/app/src/main/res/mipmap-xhdpi/avator_18.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/avator_19.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huangyanbin/smartTable/fe975d333a79586261f4f265317b9d1e6f2a36fa/app/src/main/res/mipmap-xhdpi/avator_19.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/avator_2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huangyanbin/smartTable/fe975d333a79586261f4f265317b9d1e6f2a36fa/app/src/main/res/mipmap-xhdpi/avator_2.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/avator_20.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huangyanbin/smartTable/fe975d333a79586261f4f265317b9d1e6f2a36fa/app/src/main/res/mipmap-xhdpi/avator_20.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/avator_3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huangyanbin/smartTable/fe975d333a79586261f4f265317b9d1e6f2a36fa/app/src/main/res/mipmap-xhdpi/avator_3.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/avator_4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huangyanbin/smartTable/fe975d333a79586261f4f265317b9d1e6f2a36fa/app/src/main/res/mipmap-xhdpi/avator_4.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/avator_5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huangyanbin/smartTable/fe975d333a79586261f4f265317b9d1e6f2a36fa/app/src/main/res/mipmap-xhdpi/avator_5.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/avator_6.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huangyanbin/smartTable/fe975d333a79586261f4f265317b9d1e6f2a36fa/app/src/main/res/mipmap-xhdpi/avator_6.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/avator_7.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huangyanbin/smartTable/fe975d333a79586261f4f265317b9d1e6f2a36fa/app/src/main/res/mipmap-xhdpi/avator_7.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/avator_8.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huangyanbin/smartTable/fe975d333a79586261f4f265317b9d1e6f2a36fa/app/src/main/res/mipmap-xhdpi/avator_8.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/avator_9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huangyanbin/smartTable/fe975d333a79586261f4f265317b9d1e6f2a36fa/app/src/main/res/mipmap-xhdpi/avator_9.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/brush_fill.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huangyanbin/smartTable/fe975d333a79586261f4f265317b9d1e6f2a36fa/app/src/main/res/mipmap-xhdpi/brush_fill.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/check.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huangyanbin/smartTable/fe975d333a79586261f4f265317b9d1e6f2a36fa/app/src/main/res/mipmap-xhdpi/check.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/clock_fill.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huangyanbin/smartTable/fe975d333a79586261f4f265317b9d1e6f2a36fa/app/src/main/res/mipmap-xhdpi/clock_fill.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/collection_fill.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huangyanbin/smartTable/fe975d333a79586261f4f265317b9d1e6f2a36fa/app/src/main/res/mipmap-xhdpi/collection_fill.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/excel_triangle.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huangyanbin/smartTable/fe975d333a79586261f4f265317b9d1e6f2a36fa/app/src/main/res/mipmap-xhdpi/excel_triangle.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huangyanbin/smartTable/fe975d333a79586261f4f265317b9d1e6f2a36fa/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huangyanbin/smartTable/fe975d333a79586261f4f265317b9d1e6f2a36fa/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/level1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huangyanbin/smartTable/fe975d333a79586261f4f265317b9d1e6f2a36fa/app/src/main/res/mipmap-xhdpi/level1.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/level2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huangyanbin/smartTable/fe975d333a79586261f4f265317b9d1e6f2a36fa/app/src/main/res/mipmap-xhdpi/level2.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/morning.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huangyanbin/smartTable/fe975d333a79586261f4f265317b9d1e6f2a36fa/app/src/main/res/mipmap-xhdpi/morning.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/name.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huangyanbin/smartTable/fe975d333a79586261f4f265317b9d1e6f2a36fa/app/src/main/res/mipmap-xhdpi/name.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/night.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huangyanbin/smartTable/fe975d333a79586261f4f265317b9d1e6f2a36fa/app/src/main/res/mipmap-xhdpi/night.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/noon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huangyanbin/smartTable/fe975d333a79586261f4f265317b9d1e6f2a36fa/app/src/main/res/mipmap-xhdpi/noon.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/seat.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huangyanbin/smartTable/fe975d333a79586261f4f265317b9d1e6f2a36fa/app/src/main/res/mipmap-xhdpi/seat.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/seat_selected.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huangyanbin/smartTable/fe975d333a79586261f4f265317b9d1e6f2a36fa/app/src/main/res/mipmap-xhdpi/seat_selected.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/set_bg.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huangyanbin/smartTable/fe975d333a79586261f4f265317b9d1e6f2a36fa/app/src/main/res/mipmap-xhdpi/set_bg.9.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/set_tow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huangyanbin/smartTable/fe975d333a79586261f4f265317b9d1e6f2a36fa/app/src/main/res/mipmap-xhdpi/set_tow.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/sort_down.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huangyanbin/smartTable/fe975d333a79586261f4f265317b9d1e6f2a36fa/app/src/main/res/mipmap-xhdpi/sort_down.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/sort_up.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huangyanbin/smartTable/fe975d333a79586261f4f265317b9d1e6f2a36fa/app/src/main/res/mipmap-xhdpi/sort_up.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/uncheck.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huangyanbin/smartTable/fe975d333a79586261f4f265317b9d1e6f2a36fa/app/src/main/res/mipmap-xhdpi/uncheck.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/unsort.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huangyanbin/smartTable/fe975d333a79586261f4f265317b9d1e6f2a36fa/app/src/main/res/mipmap-xhdpi/unsort.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/update.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huangyanbin/smartTable/fe975d333a79586261f4f265317b9d1e6f2a36fa/app/src/main/res/mipmap-xhdpi/update.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huangyanbin/smartTable/fe975d333a79586261f4f265317b9d1e6f2a36fa/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huangyanbin/smartTable/fe975d333a79586261f4f265317b9d1e6f2a36fa/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_select_check.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huangyanbin/smartTable/fe975d333a79586261f4f265317b9d1e6f2a36fa/app/src/main/res/mipmap-xxhdpi/ic_select_check.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_unselect_check.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huangyanbin/smartTable/fe975d333a79586261f4f265317b9d1e6f2a36fa/app/src/main/res/mipmap-xxhdpi/ic_unselect_check.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huangyanbin/smartTable/fe975d333a79586261f4f265317b9d1e6f2a36fa/app/src/main/res/mipmap-xxhdpi/icon.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/round_rect.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huangyanbin/smartTable/fe975d333a79586261f4f265317b9d1e6f2a36fa/app/src/main/res/mipmap-xxhdpi/round_rect.9.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/triangle.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huangyanbin/smartTable/fe975d333a79586261f4f265317b9d1e6f2a36fa/app/src/main/res/mipmap-xxhdpi/triangle.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/zuo_03.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huangyanbin/smartTable/fe975d333a79586261f4f265317b9d1e6f2a36fa/app/src/main/res/mipmap-xxhdpi/zuo_03.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/zuo_05.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huangyanbin/smartTable/fe975d333a79586261f4f265317b9d1e6f2a36fa/app/src/main/res/mipmap-xxhdpi/zuo_05.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huangyanbin/smartTable/fe975d333a79586261f4f265317b9d1e6f2a36fa/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huangyanbin/smartTable/fe975d333a79586261f4f265317b9d1e6f2a36fa/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/values-v21/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 | #f2f2f2
7 | #ee5b4f
8 | #d4d4d4
9 | #b7d961
10 | #949494
11 | #222222
12 | #222222
13 | #dedede
14 |
15 | #099bfb
16 | #37d547
17 | #f86669
18 | #999999
19 | #bfbfbf
20 | #cfcfcf
21 | #f96767
22 | #f0f0f0
23 | #E8e8e8
24 | #333333
25 | #eeeeee
26 | #099bfb
27 | #fc843b
28 | #37d547
29 | #079df9
30 | #FFFFFF
31 | #f6f6f6
32 |
33 | #ebedf0
34 | #c6e48b
35 | #7bc96f
36 | #239a3b
37 | #196127
38 | #80000000
39 | #999999
40 |
41 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | 15dp
6 | 13dp
7 | 24dp
8 | 27dp
9 | 15dp
10 | 13dp
11 | 7dp
12 | 11dp
13 | 43dp
14 | 18dp
15 | 54dp
16 | 27dp
17 | 6dp
18 | 8dp
19 | 40dp
20 |
21 | 16dp
22 | 16dp
23 | 8dp
24 | 176dp
25 | 16dp
26 |
27 |
28 |
--------------------------------------------------------------------------------
/app/src/main/res/values/drawables.xml:
--------------------------------------------------------------------------------
1 |
2 | - @android:drawable/ic_menu_camera
3 | - @android:drawable/ic_menu_gallery
4 | - @android:drawable/ic_menu_slideshow
5 | - @android:drawable/ic_menu_manage
6 | - @android:drawable/ic_menu_share
7 | - @android:drawable/ic_menu_send
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | smartTable
3 | 400
4 | ChoiceExcelActivity
5 |
6 | Open navigation drawer
7 | Close navigation drawer
8 |
9 | Settings
10 |
11 |
--------------------------------------------------------------------------------
/app/src/test/java/com/bin/david/smarttable/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.bin.david.smarttable;
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 | }
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 |
5 | repositories {
6 | jcenter()
7 | google()
8 | }
9 | dependencies {
10 | classpath 'com.android.tools.build:gradle:3.0.1'
11 | classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
12 |
13 | // NOTE: Do not place your application dependencies here; they belong
14 | // in the individual module build.gradle files
15 | }
16 | }
17 |
18 | allprojects {
19 | repositories {
20 | google()
21 | jcenter()
22 | maven { url "https://jitpack.io" }
23 | }
24 | }
25 |
26 | task clean(type: Delete) {
27 | delete rootProject.buildDir
28 | }
29 |
--------------------------------------------------------------------------------
/form/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/form/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'com.github.dcendents.android-maven'
3 |
4 | group='com.github.huangyanbin'
5 |
6 | android {
7 | compileSdkVersion 25
8 | buildToolsVersion '26.0.2'
9 |
10 |
11 | defaultConfig {
12 | minSdkVersion 15
13 | targetSdkVersion 25
14 | versionCode 1
15 | versionName "1.0"
16 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
17 |
18 | }
19 | buildTypes {
20 | release {
21 | minifyEnabled false
22 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
23 | }
24 | }
25 | }
26 |
27 |
28 |
29 | tasks.withType(JavaCompile) {
30 | options.encoding = "UTF-8"
31 | }
32 |
33 | // 打包源码
34 | task sourcesJar(type: Jar) {
35 | from android.sourceSets.main.java.srcDirs
36 | classifier = 'sources'
37 | }
38 |
39 | task javadoc(type: Javadoc) {
40 | failOnError false
41 | javadoc.options.encoding = "UTF-8"
42 | source = android.sourceSets.main.java.sourceFiles
43 | classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
44 | classpath += configurations.compile
45 | }
46 |
47 | // 制作文档(Javadoc)
48 | task javadocJar(type: Jar, dependsOn: javadoc) {
49 | classifier = 'javadoc'
50 | from javadoc.destinationDir
51 | }
52 |
53 | artifacts {
54 | archives sourcesJar
55 | archives javadocJar
56 | }
57 |
58 | dependencies {
59 | }
60 |
--------------------------------------------------------------------------------
/form/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/form/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
--------------------------------------------------------------------------------
/form/src/main/java/com/bin/david/form/annotation/ColumnType.java:
--------------------------------------------------------------------------------
1 | package com.bin.david.form.annotation;
2 |
3 | /**
4 | * Created by huang on 2017/11/4.
5 | */
6 |
7 | public enum ColumnType {
8 | /**
9 | * 查询当前字段
10 | */
11 | Own,
12 | /**
13 | * 查询字段内部
14 | */
15 | Child,
16 |
17 | /**
18 | * 查询当前数组或List对象
19 | */
20 | ArrayOwn,
21 | /**
22 | * 查询当前数组或List对象内部
23 | */
24 | ArrayChild;
25 | }
26 |
--------------------------------------------------------------------------------
/form/src/main/java/com/bin/david/form/annotation/SmartColumn.java:
--------------------------------------------------------------------------------
1 | package com.bin.david.form.annotation;
2 |
3 |
4 | import android.graphics.Paint;
5 |
6 | import java.lang.annotation.ElementType;
7 | import java.lang.annotation.Retention;
8 | import java.lang.annotation.RetentionPolicy;
9 | import java.lang.annotation.Target;
10 |
11 | /**
12 | * Created by huang on 2017/11/4.
13 | */
14 | @Retention(RetentionPolicy.RUNTIME)
15 | @Target({ElementType.FIELD})
16 | public @interface SmartColumn {
17 |
18 | /**
19 | * 名称
20 | */
21 | String name() default "";
22 |
23 | /**
24 | * id 越小越在前面
25 | */
26 | int id() default 0;
27 |
28 | /**
29 | * 父列名称
30 | */
31 | String parent() default "";
32 |
33 | /**
34 | * 对齐
35 | */
36 | Paint.Align align() default Paint.Align.CENTER;
37 |
38 | /**
39 | * 列标题对齐
40 | */
41 | Paint.Align titleAlign() default Paint.Align.CENTER;
42 | /**
43 | * 设置是否查询下一级
44 | * @return 是否查询下一级
45 | */
46 | ColumnType type() default ColumnType.Own;
47 | /**
48 | * 设置是否自动合并
49 | * @return 是否自动合并
50 | */
51 | boolean autoMerge() default false;
52 | /**
53 | * 设置自动合并最大数量
54 | * @return 自动合并最大数量
55 | */
56 | int maxMergeCount() default -1;
57 | /**
58 | * 开启自动统计
59 | */
60 | boolean autoCount() default false;
61 | /**
62 | * 是否固定该列
63 | */
64 | boolean fixed() default false;
65 |
66 |
67 | /**
68 | * 是否开启快速显示
69 | * 当列的字体大小不变且为单行,可以开启快速显示
70 | */
71 | boolean fast() default false;
72 |
73 | /**
74 | * 最小宽度
75 | */
76 | int minWidth() default 0;
77 |
78 | /**
79 | * 最小高度
80 | */
81 | int minHeight() default 0;
82 |
83 | /**
84 | * 指定宽度
85 | * @return
86 | */
87 | int width() default 0;
88 |
89 |
90 | }
91 |
--------------------------------------------------------------------------------
/form/src/main/java/com/bin/david/form/annotation/SmartTable.java:
--------------------------------------------------------------------------------
1 | package com.bin.david.form.annotation;
2 |
3 | import java.lang.annotation.ElementType;
4 | import java.lang.annotation.Retention;
5 | import java.lang.annotation.RetentionPolicy;
6 | import java.lang.annotation.Target;
7 |
8 | /**
9 | * Created by huang on 2017/11/4.
10 | */
11 | @Retention(RetentionPolicy.RUNTIME)
12 | @Target({ElementType.TYPE})
13 | public @interface SmartTable {
14 |
15 | String name() default "";
16 | boolean count() default false;
17 | int pageSize() default Integer.MAX_VALUE;
18 | int currentPage() default 0;
19 | }
20 |
--------------------------------------------------------------------------------
/form/src/main/java/com/bin/david/form/component/GridDrawer.java:
--------------------------------------------------------------------------------
1 | package com.bin.david.form.component;
2 |
3 |
4 | import android.graphics.Rect;
5 | import com.bin.david.form.data.column.Column;
6 | import com.bin.david.form.data.Cell;
7 | import com.bin.david.form.data.table.TableData;
8 |
9 | import java.util.List;
10 |
11 | /**
12 | * Created by huang on 2018/1/16.
13 | * 网格绘制
14 | * 主要为了解决合并单元格问题
15 | */
16 |
17 | public class GridDrawer{
18 |
19 |
20 | private TableData tableData;
21 | private Cell[][] rangePoints;
22 |
23 | public GridDrawer(){
24 |
25 | }
26 |
27 | public void setTableData(TableData tableData) {
28 | this.tableData = tableData;
29 | this.rangePoints = tableData.getTableInfo().getRangeCells();
30 |
31 | }
32 |
33 |
34 | //矫正格子大小
35 | public Rect correctCellRect(int row, int col, Rect rect, float zoom) {
36 | if(rangePoints != null && rangePoints.length >row){
37 | Cell point = rangePoints[row][col];
38 | if (point != null) {
39 | if (point.col != Cell.INVALID && point.row != Cell.INVALID) {
40 | List childColumns = tableData.getChildColumns();
41 | int[] lineHeights = tableData.getTableInfo().getLineHeightArray();
42 | int width = 0, height = 0;
43 | for (int i = col; i < Math.min(childColumns.size(), col + point.col); i++) {
44 | width += childColumns.get(i).getComputeWidth();
45 | }
46 | for (int i = row; i < Math.min(lineHeights.length, row + point.row); i++) {
47 | height += lineHeights[i];
48 | }
49 | rect.right = (int) (rect.left + width*zoom);
50 | rect.bottom = (int) (rect.top + height*zoom);
51 | return rect;
52 | }
53 | return null;
54 | }
55 | }
56 | return rect;
57 | }
58 |
59 |
60 | }
61 |
--------------------------------------------------------------------------------
/form/src/main/java/com/bin/david/form/component/IComponent.java:
--------------------------------------------------------------------------------
1 | package com.bin.david.form.component;
2 |
3 | import android.graphics.Canvas;
4 | import android.graphics.Rect;
5 |
6 | import com.bin.david.form.core.TableConfig;
7 |
8 |
9 | /** 图表组件
10 | * Created by huang on 2017/10/26.
11 | */
12 |
13 | public interface IComponent {
14 |
15 | int LEFT = 0;
16 | int TOP = 1;
17 | int RIGHT =2;
18 | int BOTTOM = 3;
19 | /**
20 | * 计算组件Rect
21 | */
22 | void onMeasure(Rect scaleRect, Rect showRect, TableConfig config);
23 |
24 | /**
25 | * 绘制组件
26 | * @param canvas 画布
27 | * @param t 数据
28 | */
29 | void onDraw(Canvas canvas, Rect showRect, T t, TableConfig config);
30 |
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/form/src/main/java/com/bin/david/form/component/ITableTitle.java:
--------------------------------------------------------------------------------
1 | package com.bin.david.form.component;
2 |
3 |
4 |
5 | /**
6 | * Created by huang on 2017/10/26.
7 | */
8 |
9 | public interface ITableTitle extends IComponent {
10 |
11 | int getSize();
12 |
13 | void setSize(int size);
14 |
15 |
16 | int getDirection();
17 |
18 | void setDirection(int direction);
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/form/src/main/java/com/bin/david/form/component/SelectionOperation.java:
--------------------------------------------------------------------------------
1 | package com.bin.david.form.component;
2 |
3 | import android.graphics.Canvas;
4 | import android.graphics.Rect;
5 | import android.util.Log;
6 | import android.view.MotionEvent;
7 |
8 | import com.bin.david.form.core.SmartTable;
9 | import com.bin.david.form.core.TableConfig;
10 | import com.bin.david.form.data.format.selected.ISelectFormat;
11 | import com.bin.david.form.data.table.TableData;
12 | import com.bin.david.form.matrix.MatrixHelper;
13 |
14 | /**
15 | * Created by huang on 2018/1/12.
16 | * 选中操作
17 | * 这个类用于处理选中操作
18 | * 暂时只做比较简单点击效果
19 | */
20 |
21 | public class SelectionOperation implements MatrixHelper.OnInterceptListener {
22 | /**
23 | * 选中区域
24 | */
25 | private static final int INVALID = -1; //无效坐标
26 | private Rect selectionRect;
27 | private ISelectFormat selectFormat;
28 | private int selectRow = INVALID;
29 | private int selectColumn = INVALID;
30 | private boolean isShow;
31 |
32 | void reset(){
33 | isShow = false;
34 | }
35 |
36 | SelectionOperation() {
37 | this.selectionRect = new Rect();
38 | }
39 |
40 | void setSelectionRect(int selectColumn,int selectRow, Rect rect){
41 | this.selectRow = selectRow;
42 | this.selectColumn = selectColumn;
43 | selectionRect.set(rect);
44 | isShow = true;
45 | }
46 |
47 | boolean isSelectedPoint( int selectColumn,int selectRow){
48 |
49 | return selectRow == this.selectRow && selectColumn == this.selectColumn;
50 | }
51 |
52 | void checkSelectedPoint(int selectColumn,int selectRow, Rect rect){
53 |
54 | if(isSelectedPoint(selectColumn,selectRow)){
55 |
56 | selectionRect.set(rect);
57 | isShow = true;
58 | }
59 | }
60 |
61 |
62 |
63 |
64 |
65 | public void draw(Canvas canvas, Rect showRect, TableConfig config){
66 |
67 | if(selectFormat !=null && isShow){
68 | selectFormat.draw(canvas,selectionRect,showRect,config);
69 | }
70 | }
71 |
72 | public ISelectFormat getSelectFormat() {
73 | return selectFormat;
74 | }
75 |
76 | void setSelectFormat(ISelectFormat selectFormat) {
77 | this.selectFormat = selectFormat;
78 | }
79 |
80 | @Override
81 | public boolean isIntercept(MotionEvent e1, float distanceX, float distanceY) {
82 | return false;
83 | }
84 |
85 |
86 | }
87 |
--------------------------------------------------------------------------------
/form/src/main/java/com/bin/david/form/component/TableTitle.java:
--------------------------------------------------------------------------------
1 | package com.bin.david.form.component;
2 |
3 | import android.graphics.Canvas;
4 | import android.graphics.Paint;
5 | import android.graphics.Path;
6 | import android.graphics.Rect;
7 |
8 | import com.bin.david.form.core.TableConfig;
9 | import com.bin.david.form.utils.DrawUtils;
10 |
11 | /**
12 | * Created by huang on 2017/9/29.
13 | * 绘制标题
14 | */
15 |
16 | public class TableTitle implements ITableTitle {
17 |
18 | private int size = 100;
19 | private Rect rect = new Rect();
20 | protected int direction;
21 |
22 |
23 |
24 | @Override
25 | public void onDraw(Canvas canvas, Rect showRect, String tableName, TableConfig config){
26 | Paint paint = config.getPaint();
27 | config.getTableTitleStyle().fillPaint(paint);
28 | Rect rect = getRect();
29 | int startX = rect.centerX();
30 | Path path = new Path();
31 | switch (direction) {
32 | case TOP:
33 | case BOTTOM:
34 | DrawUtils.drawMultiText(canvas,paint,rect,tableName.split("\n"));
35 | break;
36 | case LEFT:
37 | case RIGHT:
38 | int textWidth = (int)paint.measureText(tableName);
39 | path.moveTo(startX,rect.top);
40 | path.lineTo(startX,rect.bottom);
41 | canvas.drawTextOnPath(tableName,path,textWidth/2,0,paint);
42 | break;
43 | }
44 | }
45 |
46 | @Override
47 | public void onMeasure(Rect scaleRect, Rect showRect, TableConfig config) {
48 | rect.left = showRect.left;
49 | rect.right = showRect.right;
50 | rect.top = showRect.top;
51 | rect.bottom = Math.min(showRect.bottom,scaleRect.bottom);
52 | int h = size;
53 | int w =size;
54 | switch (direction){
55 | case TOP:
56 | rect.bottom = rect.top+h;
57 | scaleRect.top +=h;
58 | showRect.top +=h;
59 | break;
60 | case LEFT:
61 | rect.right = rect.left + w;
62 | scaleRect.left +=w;
63 | showRect.left +=w;
64 | break;
65 | case RIGHT:
66 | rect.left = rect.right -w;
67 | scaleRect.right -= w;
68 | showRect.right -=w;
69 | break;
70 | case BOTTOM:
71 | rect.top = rect.bottom -h;
72 | scaleRect.bottom -= h;
73 | showRect.bottom -=h;
74 | break;
75 | }
76 | }
77 |
78 |
79 | public int getSize() {
80 | return size;
81 | }
82 |
83 | public void setSize(int size) {
84 | this.size = size;
85 | }
86 |
87 | public Rect getRect() {
88 | return rect;
89 | }
90 |
91 | public void setRect(Rect rect) {
92 | this.rect = rect;
93 | }
94 |
95 | public int getDirection() {
96 | return direction;
97 | }
98 |
99 | public void setDirection(int direction) {
100 | this.direction = direction;
101 | }
102 | }
103 |
--------------------------------------------------------------------------------
/form/src/main/java/com/bin/david/form/data/Cell.java:
--------------------------------------------------------------------------------
1 | package com.bin.david.form.data;
2 |
3 | /**
4 | * Created by huang on 2018/1/24.
5 | */
6 |
7 | public class Cell {
8 | public static final int INVALID = -1;
9 |
10 | public int col;
11 | public int row;
12 | public Cell realCell;
13 | public int width;
14 | public int height;
15 |
16 | public Cell(int col, int row) {
17 | this.col = col;
18 | this.row = row;
19 | realCell = this;
20 | }
21 |
22 | public Cell(Cell realCell) {
23 | this.col = INVALID;
24 | this.row = INVALID;
25 | this.realCell = realCell;
26 | }
27 |
28 |
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/form/src/main/java/com/bin/david/form/data/CellInfo.java:
--------------------------------------------------------------------------------
1 | package com.bin.david.form.data;
2 |
3 | import com.bin.david.form.data.column.Column;
4 |
5 | /**
6 | * Created by huang on 2017/11/15.
7 | * 单元格数据
8 | */
9 |
10 | public class CellInfo {
11 | /**
12 | * 数据
13 | */
14 | public T data;
15 | /**
16 | * 所在行位置
17 | */
18 | public int row;
19 | /**
20 | * 所在列位置
21 | */
22 | public int col;
23 |
24 | /**
25 | * 所在列
26 | */
27 | public Column column;
28 | /**
29 | * 显示的值
30 | */
31 | public String value;
32 |
33 | public void set(Column column,T t,String value,int col, int row){
34 | this.column = column;
35 | this.value= value;
36 | this.data = t;
37 | this.row = row;
38 | this.col = col;
39 | }
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/form/src/main/java/com/bin/david/form/data/CellRange.java:
--------------------------------------------------------------------------------
1 | package com.bin.david.form.data;
2 |
3 | import java.util.Arrays;
4 |
5 | /**
6 | * Created by huang on 2018/1/16.
7 | * 合并单元格
8 | */
9 |
10 | public class CellRange {
11 | private int[] cellRange;
12 |
13 | /**
14 | * 合并单元格构造方法
15 | * @param firstRow 合并第一行
16 | * @param lastRow 合并最后一行
17 | * @param firstCol 合并第一列
18 | * @param lastCol 合并最后一列
19 | */
20 | public CellRange(int firstRow , int lastRow, int firstCol, int lastCol) {
21 | this.cellRange = new int[4];
22 | this.cellRange[0] = firstRow;
23 | this.cellRange[1] = lastRow;
24 | this.cellRange[2] = firstCol;
25 | this.cellRange[3] = lastCol;
26 | }
27 |
28 | public int getFirstRow() {
29 | return cellRange[0];
30 | }
31 |
32 | public void setFirstRow(int firstRow) {
33 | this.cellRange[0] = firstRow;
34 | }
35 |
36 | public int getLastRow() {
37 | return cellRange[1];
38 | }
39 |
40 | public void setLastRow(int lastRow) {
41 | this.cellRange[1] = lastRow;
42 | }
43 |
44 | public int getFirstCol() {
45 | return cellRange[2];
46 | }
47 |
48 | public void setFirstCol(int firstCol) {
49 | this.cellRange[2] = firstCol;
50 | }
51 |
52 | public int getLastCol() {
53 | return cellRange[3];
54 | }
55 |
56 | public void setLastCol(int lastCol) {
57 | this.cellRange[3] = lastCol;
58 | }
59 |
60 | public int[] getCellRange() {
61 | return cellRange;
62 | }
63 |
64 | /**
65 | * 合并单元是否包含格子
66 | * @param row 行
67 | * @param col 列
68 | * @return 是否包含
69 | */
70 | public boolean contain(int row,int col){
71 |
72 | return cellRange[0]<= row && cellRange[1]>= row
73 | && cellRange[2]<= col && cellRange[3]>= col;
74 | }
75 | /**
76 | * 是否该格子在合并单元的左上角
77 | * @param row 行
78 | * @param col 列
79 | * @return 是否包含
80 | */
81 | public boolean isLeftAndTop(int row,int col){
82 | return cellRange[0]== row && cellRange[2]== col;
83 | }
84 |
85 | @Override
86 | public String toString() {
87 | return "CellRange{" +
88 | "cellRange=" + Arrays.toString(cellRange) +
89 | '}';
90 | }
91 | }
92 |
--------------------------------------------------------------------------------
/form/src/main/java/com/bin/david/form/data/column/ColumnInfo.java:
--------------------------------------------------------------------------------
1 | package com.bin.david.form.data.column;
2 |
3 | /**
4 | * Created by huang on 2017/11/2.
5 | * 列信息类
6 | * 用于保存计算出来列Column信息
7 | */
8 |
9 | public class ColumnInfo {
10 | /**
11 | * 列宽度
12 | */
13 | public int width;
14 | /**
15 | * 列高度
16 | */
17 | public int height;
18 | /**
19 | * 列左边
20 | */
21 | public int left;
22 | /**
23 | * 列顶部
24 | */
25 | public int top;
26 | /**
27 | * 值
28 | */
29 | public String value;
30 | /**
31 | * 列
32 | */
33 | public Column column;
34 | /**
35 | * 父列数据
36 | * 便于递归查找
37 | */
38 | private ColumnInfo parent;
39 |
40 | public ColumnInfo() {
41 |
42 | }
43 |
44 | /**
45 | * 获取最顶层列信息
46 | *
47 | * @return 最顶层列信息
48 | */
49 | public ColumnInfo getTopParent(){
50 |
51 | return getParent(this);
52 | }
53 |
54 | /**
55 | * 递归查找顶层
56 | * @param column
57 | * @return
58 | */
59 | private ColumnInfo getParent(ColumnInfo column){
60 | if(column.getParent() != null){
61 | return getParent(column.getParent());
62 | }
63 | return column;
64 | }
65 |
66 | /**
67 | * 获取父列
68 | * @return 父列
69 | */
70 | public ColumnInfo getParent() {
71 | return parent;
72 | }
73 | /**
74 | * 设置父列
75 | */
76 | public void setParent(ColumnInfo parent) {
77 | this.parent = parent;
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/form/src/main/java/com/bin/david/form/data/column/ColumnNode.java:
--------------------------------------------------------------------------------
1 | package com.bin.david.form.data.column;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 |
6 | /**
7 | * Created by huang on 2018/2/1.
8 | * */
9 |
10 | public class ColumnNode {
11 |
12 | private String name;
13 | private List children;
14 | private ArrayColumn arrayColumn;
15 | private ColumnNode parent;
16 |
17 | public ColumnNode(String name, ColumnNode parent) {
18 | this.name = name;
19 | this.parent = parent;
20 | this.children = new ArrayList<>();
21 | }
22 |
23 | public ColumnNode(String name, ColumnNode parent, ArrayColumn arrayColumn) {
24 | this(name,parent);
25 | this.arrayColumn = arrayColumn;
26 | }
27 |
28 | public String getName() {
29 | return name;
30 | }
31 |
32 | public void setName(String name) {
33 | this.name = name;
34 | }
35 |
36 | public List getChildren() {
37 | return children;
38 | }
39 |
40 |
41 | public ArrayColumn getArrayColumn() {
42 | return arrayColumn;
43 | }
44 |
45 | public void setArrayColumn(ArrayColumn arrayColumn) {
46 | this.arrayColumn = arrayColumn;
47 | }
48 |
49 | public ColumnNode getParent() {
50 | return parent;
51 | }
52 |
53 | public void setParent(ColumnNode parent) {
54 | this.parent = parent;
55 | }
56 |
57 |
58 |
59 | public static int getLevel(ColumnNode node,int level){
60 | if(node.arrayColumn != null && !node.arrayColumn.isThoroughArray()){
61 | level++;
62 | }
63 | if(node.getParent() !=null){
64 | if(node.getParent().arrayColumn == null){
65 | level++;
66 | }
67 | return getLevel(node.getParent(),level);
68 |
69 | }
70 | return level-1;
71 | }
72 |
73 |
74 |
75 |
76 | }
77 |
--------------------------------------------------------------------------------
/form/src/main/java/com/bin/david/form/data/form/IForm.java:
--------------------------------------------------------------------------------
1 | package com.bin.david.form.data.form;
2 |
3 | import android.graphics.Paint;
4 |
5 | /**
6 | * Created by huang on 2018/4/10.
7 | */
8 |
9 | public interface IForm {
10 |
11 | int getSpanWidthSize();
12 | int getSpanHeightSize();
13 | Paint.Align getAlign();
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/form/src/main/java/com/bin/david/form/data/format/IFormat.java:
--------------------------------------------------------------------------------
1 | package com.bin.david.form.data.format;
2 |
3 | /**
4 | * Created by huang on 2017/10/30.
5 | */
6 |
7 | public interface IFormat {
8 |
9 | String format(T t);
10 | }
11 |
--------------------------------------------------------------------------------
/form/src/main/java/com/bin/david/form/data/format/bg/BaseBackgroundFormat.java:
--------------------------------------------------------------------------------
1 | package com.bin.david.form.data.format.bg;
2 |
3 | import android.graphics.Canvas;
4 | import android.graphics.Paint;
5 | import android.graphics.Rect;
6 |
7 | import com.bin.david.form.core.TableConfig;
8 |
9 | /**
10 | * Created by huang on 2017/11/14.
11 | * 通用绘制背景绘制
12 | */
13 |
14 | public class BaseBackgroundFormat implements IBackgroundFormat {
15 | private int backgroundColor;
16 |
17 | public BaseBackgroundFormat(int backgroundColor){
18 | this.backgroundColor= backgroundColor;
19 | }
20 |
21 | @Override
22 | public void drawBackground(Canvas canvas, Rect rect,Paint paint) {
23 | if(backgroundColor != TableConfig.INVALID_COLOR) {
24 | paint.setColor(backgroundColor);
25 | paint.setStyle(Paint.Style.FILL);
26 | canvas.drawRect(rect, paint);
27 | }
28 | }
29 |
30 |
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/form/src/main/java/com/bin/david/form/data/format/bg/BaseCellBackgroundFormat.java:
--------------------------------------------------------------------------------
1 | package com.bin.david.form.data.format.bg;
2 |
3 | import android.graphics.Canvas;
4 | import android.graphics.Paint;
5 | import android.graphics.Rect;
6 |
7 | import com.bin.david.form.core.TableConfig;
8 |
9 | /**
10 | * Created by huang on 2017/11/14.
11 | * 通用绘制Rect格子背景绘制
12 | */
13 |
14 | public abstract class BaseCellBackgroundFormat implements ICellBackgroundFormat {
15 |
16 | @Override
17 | public void drawBackground(Canvas canvas, Rect rect, T t,Paint paint) {
18 | int color = getBackGroundColor(t);
19 | if(color != TableConfig.INVALID_COLOR) {
20 | paint.setColor(color);
21 | paint.setStyle(Paint.Style.FILL);
22 | canvas.drawRect(rect, paint);
23 | }
24 | }
25 |
26 | /**
27 | * 获取背景颜色
28 | */
29 | public abstract int getBackGroundColor(T t);
30 |
31 | /**
32 | * 默认字体颜色不跟随背景变化,
33 | * 当有需要多种字体颜色,请重写该方法
34 | * @param t
35 | * @return
36 | */
37 | @Override
38 | public int getTextColor(T t) {
39 | return TableConfig.INVALID_COLOR;
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/form/src/main/java/com/bin/david/form/data/format/bg/IBackgroundFormat.java:
--------------------------------------------------------------------------------
1 | package com.bin.david.form.data.format.bg;
2 |
3 | import android.graphics.Canvas;
4 | import android.graphics.Paint;
5 | import android.graphics.Rect;
6 |
7 | /**
8 | * Created by huang on 2018/3/9.
9 | */
10 |
11 | public interface IBackgroundFormat {
12 |
13 | /**
14 | * 绘制背景
15 | */
16 | void drawBackground(Canvas canvas, Rect rect, Paint paint);
17 | }
18 |
--------------------------------------------------------------------------------
/form/src/main/java/com/bin/david/form/data/format/bg/ICellBackgroundFormat.java:
--------------------------------------------------------------------------------
1 | package com.bin.david.form.data.format.bg;
2 |
3 | import android.graphics.Canvas;
4 | import android.graphics.Paint;
5 | import android.graphics.Rect;
6 |
7 | /**
8 | * Created by huang on 2017/11/14.
9 | * 绘制格子背景格式化
10 | */
11 |
12 | public interface ICellBackgroundFormat {
13 | /**
14 | * 绘制背景
15 | */
16 | void drawBackground(Canvas canvas, Rect rect,T t, Paint paint);
17 |
18 |
19 | /**
20 | *当背景颜色改变字体也需要跟随变化
21 | */
22 | int getTextColor(T t);
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/form/src/main/java/com/bin/david/form/data/format/count/DecimalCountFormat.java:
--------------------------------------------------------------------------------
1 | package com.bin.david.form.data.format.count;
2 |
3 | /**
4 | * Created by huang on 2017/11/6.
5 | */
6 |
7 | public class DecimalCountFormat implements ICountFormat {
8 |
9 | private double totalDoubleCount =0;
10 |
11 |
12 | @Override
13 | public void count(T t) {
14 | Number number = (Number) t;
15 | if(number instanceof Double){
16 | totalDoubleCount+=number.doubleValue();
17 | }else if(number instanceof Float){
18 | totalDoubleCount+=number.floatValue();
19 | }
20 | }
21 |
22 | @Override
23 | public Double getCount() {
24 |
25 | return totalDoubleCount;
26 | }
27 |
28 |
29 | @Override
30 | public String getCountString() {
31 | return String.valueOf(totalDoubleCount);
32 | }
33 |
34 | @Override
35 | public void clearCount() {
36 | totalDoubleCount = 0;
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/form/src/main/java/com/bin/david/form/data/format/count/ICountFormat.java:
--------------------------------------------------------------------------------
1 | package com.bin.david.form.data.format.count;
2 |
3 | /**
4 | * Created by huang on 2017/11/6.
5 | */
6 |
7 | public interface ICountFormat {
8 |
9 | void count(T t);
10 |
11 | N getCount();
12 |
13 | String getCountString();
14 |
15 | void clearCount();
16 | }
17 |
--------------------------------------------------------------------------------
/form/src/main/java/com/bin/david/form/data/format/count/NumberCountFormat.java:
--------------------------------------------------------------------------------
1 | package com.bin.david.form.data.format.count;
2 |
3 |
4 | /**
5 | * Created by huang on 2017/11/6.
6 | */
7 |
8 | public class NumberCountFormat implements ICountFormat {
9 |
10 | private long totalLongCount =0;
11 |
12 | @Override
13 | public void count(T t) {
14 | Number number = (Number) t;
15 | if(number instanceof Integer){
16 | totalLongCount+=number.intValue();
17 | }else if(number instanceof Long){
18 | totalLongCount+=number.longValue();
19 |
20 | } else if(number instanceof Byte){
21 | totalLongCount+=number.byteValue();
22 |
23 | }else if(number instanceof Short){
24 | totalLongCount+=number.shortValue();
25 | }
26 | }
27 |
28 | @Override
29 | public Long getCount() {
30 | return totalLongCount;
31 |
32 | }
33 |
34 |
35 | @Override
36 | public String getCountString() {
37 | return String.valueOf(totalLongCount);
38 | }
39 |
40 | @Override
41 | public void clearCount() {
42 | totalLongCount = 0;
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/form/src/main/java/com/bin/david/form/data/format/count/StringCountFormat.java:
--------------------------------------------------------------------------------
1 | package com.bin.david.form.data.format.count;
2 |
3 | import com.bin.david.form.data.column.Column;
4 |
5 | import java.util.HashSet;
6 | import java.util.Set;
7 |
8 | /**
9 | * Created by huang on 2017/11/6.
10 | */
11 |
12 | public class StringCountFormat implements ICountFormat {
13 |
14 | private Set valueSet;
15 | private int count;
16 | private Column column;
17 |
18 | public StringCountFormat(Column column){
19 | this.column = column;
20 | this.valueSet = new HashSet<>();
21 | }
22 |
23 |
24 | @Override
25 | public void count(T t) {
26 | String value;
27 | if(column.getFormat() != null) {
28 | value = column.getFormat().format(t);
29 | }else{
30 | value = t == null ? "" : t.toString();
31 | }
32 | if(value != null && !valueSet.contains(value)
33 | && !"".equals(value)){
34 | count++;
35 | valueSet.add(value);
36 | }
37 | }
38 |
39 | @Override
40 | public Integer getCount() {
41 | return count;
42 | }
43 |
44 | @Override
45 | public String getCountString() {
46 | return String.valueOf(count);
47 | }
48 |
49 | @Override
50 | public void clearCount() {
51 | valueSet.clear();
52 | count = 0;
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/form/src/main/java/com/bin/david/form/data/format/draw/FastTextDrawFormat.java:
--------------------------------------------------------------------------------
1 | package com.bin.david.form.data.format.draw;
2 |
3 | import android.graphics.Canvas;
4 | import android.graphics.Paint;
5 | import android.graphics.Rect;
6 |
7 | import com.bin.david.form.core.TableConfig;
8 | import com.bin.david.form.data.column.Column;
9 | import com.bin.david.form.utils.DrawUtils;
10 |
11 | /**
12 | * Created by huang on 2017/10/30.
13 | * 快速字体格式化
14 | * 当解析数目大,且字体大小和单行时,这个更快可以测量出来,节省加载时间
15 | */
16 |
17 | public class FastTextDrawFormat extends TextDrawFormat {
18 |
19 |
20 | private int height;
21 | private int width;
22 | private int maxLengthValue;
23 |
24 | @Override
25 | public int measureWidth(Columncolumn, int position, TableConfig config) {
26 | String value = column.format(position);
27 | if(value.length() >maxLengthValue){
28 | maxLengthValue = value.length();
29 | Paint paint = config.getPaint();
30 | config.getContentStyle().fillPaint(paint);
31 | width = (int) paint.measureText(value);
32 | }
33 | return width;
34 | }
35 |
36 | @Override
37 | public int measureHeight(Column column,int position, TableConfig config) {
38 | if(height ==0) {
39 | Paint paint = config.getPaint();
40 | config.getContentStyle().fillPaint(paint);
41 | height = DrawUtils.getTextHeight(paint);
42 | }
43 | return height;
44 | }
45 |
46 |
47 |
48 | protected void drawText(Canvas c, String value, Rect rect, Paint paint) {
49 | DrawUtils.drawSingleText(c,paint,rect,value);
50 | }
51 |
52 |
53 |
54 | }
55 |
--------------------------------------------------------------------------------
/form/src/main/java/com/bin/david/form/data/format/draw/IDrawFormat.java:
--------------------------------------------------------------------------------
1 | package com.bin.david.form.data.format.draw;
2 |
3 | import android.graphics.Canvas;
4 | import android.graphics.Rect;
5 |
6 | import com.bin.david.form.data.CellInfo;
7 | import com.bin.david.form.data.column.Column;
8 | import com.bin.david.form.core.TableConfig;
9 |
10 | /**
11 | * Created by huang on 2017/10/30.
12 | * 绘制格式化
13 | */
14 |
15 | public interface IDrawFormat {
16 |
17 | /**
18 | *测量宽
19 | */
20 | int measureWidth(Column column, int position, TableConfig config);
21 |
22 | /**
23 | *测量高
24 | */
25 | int measureHeight(Column column,int position, TableConfig config);
26 |
27 |
28 | void draw(Canvas c, Rect rect, CellInfo cellInfo, TableConfig config);
29 |
30 |
31 |
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/form/src/main/java/com/bin/david/form/data/format/draw/ImageResDrawFormat.java:
--------------------------------------------------------------------------------
1 | package com.bin.david.form.data.format.draw;
2 |
3 | import android.content.Context;
4 | import android.graphics.Bitmap;
5 | import android.graphics.BitmapFactory;
6 | import android.util.LruCache;
7 |
8 | /**
9 | * Created by huang on 2017/10/30.
10 | */
11 |
12 | public abstract class ImageResDrawFormat extends BitmapDrawFormat {
13 |
14 | private BitmapFactory.Options options = new BitmapFactory.Options();
15 | //使用缓存
16 | private LruCache cache;
17 |
18 | public ImageResDrawFormat(int imageWidth, int imageHeight) {
19 | this(imageWidth,imageHeight,null);
20 | int maxMemory = (int)(Runtime.getRuntime().maxMemory() / 1024);// kB
21 | int cacheSize = maxMemory / 16;
22 | cache = new LruCache(cacheSize){
23 | @Override
24 | protected int sizeOf(Integer key,Bitmap bitmap){
25 | return bitmap.getRowBytes() * bitmap.getHeight() / 1024;// KB
26 | }
27 | };
28 | }
29 |
30 | public ImageResDrawFormat(int imageWidth, int imageHeight, BitmapFactory.Options options) {
31 | super(imageWidth, imageHeight);
32 | this.options = options;
33 | }
34 |
35 | @Override
36 | protected Bitmap getBitmap(T t, String value, int position) {
37 | int resID = getResourceID(t,value,position);
38 | Bitmap bitmap = cache.get(resID);
39 | if(bitmap == null) {
40 | bitmap = BitmapFactory.decodeResource(getContext().getResources(),resID,options);
41 | if(bitmap !=null) {
42 | cache.put(resID, bitmap);
43 | }
44 | }
45 | return bitmap;
46 | }
47 |
48 | protected abstract Context getContext();
49 |
50 | protected abstract int getResourceID(T t, String value, int position);
51 |
52 |
53 | }
54 |
--------------------------------------------------------------------------------
/form/src/main/java/com/bin/david/form/data/format/draw/LeftTopDrawFormat.java:
--------------------------------------------------------------------------------
1 | package com.bin.david.form.data.format.draw;
2 |
3 | import android.graphics.Canvas;
4 | import android.graphics.Rect;
5 |
6 | import com.bin.david.form.core.TableConfig;
7 | import com.bin.david.form.data.CellInfo;
8 | import com.bin.david.form.data.column.Column;
9 |
10 | /**
11 | * Created by huang on 2017/10/30.
12 | * 左上角格式化
13 | */
14 |
15 | public abstract class LeftTopDrawFormat extends ImageResDrawFormat {
16 |
17 |
18 | public LeftTopDrawFormat() {
19 | super(20, 20);
20 | }
21 |
22 | @Override
23 | protected int getResourceID(String s, String value, int position) {
24 | return getResourceID();
25 | }
26 |
27 | protected abstract int getResourceID();
28 |
29 | public void setImageSize(int w,int h){
30 | setImageWidth(w);
31 | setImageHeight(h);
32 | }
33 |
34 |
35 | @Override
36 | public void draw(Canvas c, Rect rect, CellInfo cellInfo , TableConfig config) {
37 | //为了保持三角形不变形,不跟随缩放
38 | float zoom = config.getZoom();
39 | config.setZoom(zoom>1?1:zoom);
40 | super.draw(c, rect, cellInfo, config);
41 | config.setZoom(zoom);
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/form/src/main/java/com/bin/david/form/data/format/draw/MultiLineDrawFormat.java:
--------------------------------------------------------------------------------
1 | package com.bin.david.form.data.format.draw;
2 |
3 | import android.content.Context;
4 | import android.graphics.Canvas;
5 | import android.graphics.Paint;
6 | import android.graphics.Rect;
7 | import android.text.Layout;
8 | import android.text.StaticLayout;
9 | import android.text.TextPaint;
10 |
11 | import com.bin.david.form.core.TableConfig;
12 | import com.bin.david.form.data.CellInfo;
13 | import com.bin.david.form.data.column.Column;
14 | import com.bin.david.form.utils.DensityUtils;
15 | import com.bin.david.form.utils.DrawUtils;
16 |
17 | /**
18 | * Created by huang on 2017/10/30.
19 | * 多行文字格式化
20 | */
21 |
22 | public class MultiLineDrawFormat extends TextDrawFormat {
23 |
24 | private int width;
25 | private TextPaint textPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
26 |
27 | /**
28 | * 多行文字格式化构造方法
29 | *
30 | * @param width 指定宽度 px
31 | */
32 | public MultiLineDrawFormat(int width) {
33 | this.width = width;
34 | }
35 |
36 | /**
37 | * 多行文字格式化构造方法
38 | *
39 | * @param dpWidth 指定宽度 dp
40 | */
41 | public MultiLineDrawFormat(Context context,int dpWidth) {
42 | this.width = DensityUtils.dp2px(context,dpWidth);
43 | }
44 |
45 | @Override
46 | public int measureWidth(Column column,int position, TableConfig config) {
47 |
48 | return width;
49 | }
50 |
51 | @Override
52 | public int measureHeight(Column column, int position, TableConfig config) {
53 | config.getContentStyle().fillPaint(textPaint);
54 | StaticLayout sl = new StaticLayout(column.format(position), textPaint, width, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
55 | return sl.getHeight();
56 | }
57 |
58 | @Override
59 | public void draw(Canvas c, Rect rect, CellInfo cellInfo ,TableConfig config) {
60 | setTextPaint(config, cellInfo, textPaint);
61 | if(cellInfo.column.getTextAlign() !=null) {
62 | textPaint.setTextAlign(cellInfo.column.getTextAlign());
63 | }
64 | int hPadding = (int) (config.getHorizontalPadding()*config.getZoom());
65 | int realWidth =rect.width() - 2*hPadding;
66 | StaticLayout staticLayout = new StaticLayout(cellInfo.column.format(cellInfo.row), textPaint, realWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
67 | c.save();
68 | c.translate(DrawUtils.getTextCenterX(rect.left+hPadding,rect.right-hPadding,textPaint), rect.top+(rect.height()-staticLayout.getHeight())/2);
69 | staticLayout.draw(c);
70 | c.restore();
71 | }
72 | }
73 |
74 |
75 |
76 |
--------------------------------------------------------------------------------
/form/src/main/java/com/bin/david/form/data/format/draw/TextDrawFormat.java:
--------------------------------------------------------------------------------
1 | package com.bin.david.form.data.format.draw;
2 |
3 | import android.graphics.Canvas;
4 | import android.graphics.Paint;
5 | import android.graphics.Rect;
6 |
7 | import com.bin.david.form.data.CellInfo;
8 | import com.bin.david.form.data.column.Column;
9 | import com.bin.david.form.core.TableConfig;
10 | import com.bin.david.form.data.format.bg.ICellBackgroundFormat;
11 | import com.bin.david.form.utils.DrawUtils;
12 |
13 | import java.lang.ref.SoftReference;
14 | import java.util.HashMap;
15 | import java.util.Map;
16 |
17 | /**
18 | * Created by huang on 2017/10/30.
19 | */
20 |
21 | public class TextDrawFormat implements IDrawFormat {
22 |
23 |
24 | private Map> valueMap; //避免产生大量对象
25 |
26 | public TextDrawFormat() {
27 | valueMap = new HashMap<>();
28 | }
29 |
30 | @Override
31 | public int measureWidth(Columncolumn, int position, TableConfig config) {
32 |
33 | Paint paint = config.getPaint();
34 | config.getContentStyle().fillPaint(paint);
35 | return DrawUtils.getMultiTextWidth(paint,getSplitString(column.format(position)));
36 | }
37 |
38 |
39 | @Override
40 | public int measureHeight(Column column,int position, TableConfig config) {
41 | Paint paint = config.getPaint();
42 | config.getContentStyle().fillPaint(paint);
43 | return DrawUtils.getMultiTextHeight(paint,getSplitString(column.format(position)));
44 | }
45 |
46 | @Override
47 | public void draw(Canvas c,Rect rect, CellInfo cellInfo, TableConfig config) {
48 | Paint paint = config.getPaint();
49 | setTextPaint(config,cellInfo, paint);
50 | if(cellInfo.column.getTextAlign() !=null) {
51 | paint.setTextAlign(cellInfo.column.getTextAlign());
52 | }
53 | drawText(c, cellInfo.value, rect, paint);
54 | }
55 |
56 | protected void drawText(Canvas c, String value, Rect rect, Paint paint) {
57 | DrawUtils.drawMultiText(c,paint,rect,getSplitString(value));
58 | }
59 |
60 |
61 |
62 | public void setTextPaint(TableConfig config,CellInfo cellInfo, Paint paint) {
63 | config.getContentStyle().fillPaint(paint);
64 | ICellBackgroundFormat backgroundFormat = config.getContentCellBackgroundFormat();
65 | if(backgroundFormat!=null && backgroundFormat.getTextColor(cellInfo) != TableConfig.INVALID_COLOR){
66 | paint.setColor(backgroundFormat.getTextColor(cellInfo));
67 | }
68 | paint.setTextSize(paint.getTextSize()*config.getZoom());
69 |
70 | }
71 |
72 | protected String[] getSplitString(String val){
73 | String[] values = null;
74 | if(valueMap.get(val)!=null){
75 | values= valueMap.get(val).get();
76 | }
77 | if(values == null){
78 | values = val.split("\n");
79 |
80 | valueMap.put(val, new SoftReference<>(values));
81 | }
82 | return values;
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/form/src/main/java/com/bin/david/form/data/format/grid/BaseGridFormat.java:
--------------------------------------------------------------------------------
1 | package com.bin.david.form.data.format.grid;
2 |
3 |
4 | import com.bin.david.form.data.CellInfo;
5 |
6 | /**
7 | * Created by huang on 2018/3/9.
8 | * 通用绘制网格格式化抽象类
9 | */
10 |
11 | public class BaseGridFormat extends BaseAbstractGridFormat {
12 |
13 |
14 | @Override
15 | protected boolean isShowVerticalLine(int col, int row, CellInfo cellInfo) {
16 | return true;
17 | }
18 |
19 | @Override
20 | protected boolean isShowHorizontalLine(int col, int row, CellInfo cellInfo) {
21 | return true;
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/form/src/main/java/com/bin/david/form/data/format/grid/IGridFormat.java:
--------------------------------------------------------------------------------
1 | package com.bin.david.form.data.format.grid;
2 |
3 | import android.graphics.Canvas;
4 | import android.graphics.Paint;
5 | import android.graphics.Rect;
6 |
7 | import com.bin.david.form.data.CellInfo;
8 | import com.bin.david.form.data.column.Column;
9 |
10 | /**
11 | * Created by huang on 2018/3/9.
12 | * 表格网格绘制格式化
13 | */
14 |
15 | public interface IGridFormat {
16 |
17 | /**
18 | * 绘制内容格子网格
19 | * @param canvas 画布
20 | * @param col 列
21 | * @param row 行
22 | * @param rect 方位
23 | * @param cellInfo 格子信息
24 | * @param paint 画笔
25 | */
26 | void drawContentGrid(Canvas canvas, int col, int row, Rect rect, CellInfo cellInfo, Paint paint);
27 | /**
28 | * 绘制X序列格子网格
29 | * @param canvas 画布
30 | * @param col 列
31 | * @param rect 方位
32 | * @param paint 画笔
33 | */
34 | void drawXSequenceGrid(Canvas canvas,int col, Rect rect, Paint paint);
35 | /**
36 | * 绘制Y序列格子网格
37 | * @param canvas 画布
38 | * @param row 行
39 | * @param rect 方位
40 | * @param paint 画笔
41 | */
42 | void drawYSequenceGrid(Canvas canvas,int row, Rect rect, Paint paint);
43 | /**
44 | * 绘制统计行格子网格
45 | * @param canvas 画布
46 | * @param col 列
47 | * @param rect 方位
48 | * @param paint 画笔
49 | */
50 | void drawCountGrid(Canvas canvas, int col, Rect rect, Column column, Paint paint);
51 |
52 | /**
53 | * 绘制列标题网格
54 | * @param canvas 画布
55 | * @param rect 方位
56 | * @param paint 画笔
57 | */
58 | void drawColumnTitleGrid(Canvas canvas, Rect rect, Column column,int col, Paint paint);
59 | /**
60 | * 绘制表格边框网格
61 | * @param canvas 画布
62 | * @param rect 方位
63 | * @param paint 画笔
64 | */
65 | void drawTableBorderGrid(Canvas canvas, int left,int top,int right,int bottom,Paint paint);
66 | /**
67 | * 绘制左上角空隙网格
68 | * @param canvas 画布
69 | * @param rect 方位
70 | * @param paint 画笔
71 | */
72 | void drawLeftAndTopGrid(Canvas canvas, Rect rect,Paint paint);
73 | }
74 |
--------------------------------------------------------------------------------
/form/src/main/java/com/bin/david/form/data/format/grid/SimpleGridFormat.java:
--------------------------------------------------------------------------------
1 | package com.bin.david.form.data.format.grid;
2 |
3 |
4 | import android.graphics.Canvas;
5 | import android.graphics.Paint;
6 | import android.graphics.Rect;
7 |
8 | import com.bin.david.form.data.CellInfo;
9 | import com.bin.david.form.data.column.Column;
10 |
11 | /**
12 | * Created by huang on 2018/3/9.
13 | * 简单的绘制边界
14 | */
15 |
16 | public class SimpleGridFormat implements IGridFormat {
17 |
18 |
19 | @Override
20 | public void drawContentGrid(Canvas canvas, int col, int row, Rect rect, CellInfo cellInfo, Paint paint) {
21 | canvas.drawRect(rect,paint);
22 | }
23 |
24 | @Override
25 | public void drawXSequenceGrid(Canvas canvas, int col, Rect rect, Paint paint) {
26 | canvas.drawRect(rect,paint);
27 | }
28 |
29 | @Override
30 | public void drawYSequenceGrid(Canvas canvas, int row, Rect rect, Paint paint) {
31 | canvas.drawRect(rect,paint);
32 | }
33 |
34 | @Override
35 | public void drawCountGrid(Canvas canvas, int col, Rect rect, Column column, Paint paint) {
36 | canvas.drawRect(rect,paint);
37 | }
38 |
39 | @Override
40 | public void drawColumnTitleGrid(Canvas canvas, Rect rect, Column column, int col, Paint paint) {
41 | canvas.drawRect(rect,paint);
42 | }
43 |
44 | @Override
45 | public void drawTableBorderGrid(Canvas canvas, int left, int top, int right, int bottom, Paint paint) {
46 | canvas.drawRect(left,top,right,bottom,paint);
47 | }
48 |
49 | @Override
50 | public void drawLeftAndTopGrid(Canvas canvas, Rect rect, Paint paint) {
51 | canvas.drawRect(rect,paint);
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/form/src/main/java/com/bin/david/form/data/format/selected/BaseSelectFormat.java:
--------------------------------------------------------------------------------
1 | package com.bin.david.form.data.format.selected;
2 |
3 | import android.graphics.Canvas;
4 | import android.graphics.Color;
5 | import android.graphics.Paint;
6 | import android.graphics.Rect;
7 |
8 | import com.bin.david.form.core.TableConfig;
9 |
10 | /**
11 | * Created by huang on 2018/1/12.
12 | * 选中操作格式化
13 | */
14 |
15 | public class BaseSelectFormat implements ISelectFormat {
16 |
17 |
18 | @Override
19 | public void draw(Canvas canvas, Rect rect,Rect showRect, TableConfig config) {
20 | Paint paint = config.getPaint();
21 | paint.setColor(Color.parseColor("#3A5FCD"));
22 | paint.setStyle(Paint.Style.STROKE);
23 | paint.setStrokeWidth(3);
24 | canvas.drawRect(rect,paint);
25 | paint.setStyle(Paint.Style.FILL);
26 | canvas.drawRect(rect.left-10,rect.top-10,rect.left+10,rect.top+10,paint);
27 | canvas.drawRect(rect.right-10,rect.bottom-10,rect.right+10,rect.bottom+10,paint);
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/form/src/main/java/com/bin/david/form/data/format/selected/IDrawOver.java:
--------------------------------------------------------------------------------
1 | package com.bin.david.form.data.format.selected;
2 |
3 | import android.graphics.Canvas;
4 | import android.graphics.Rect;
5 |
6 | import com.bin.david.form.core.TableConfig;
7 |
8 | /**
9 | * Created by huang on 2018/1/18.
10 | */
11 |
12 | public interface IDrawOver {
13 |
14 | void draw(Canvas canvas,Rect scaleRect, Rect showRect, TableConfig config);
15 | }
16 |
--------------------------------------------------------------------------------
/form/src/main/java/com/bin/david/form/data/format/selected/ISelectFormat.java:
--------------------------------------------------------------------------------
1 | package com.bin.david.form.data.format.selected;
2 |
3 | import android.graphics.Canvas;
4 | import android.graphics.Rect;
5 |
6 | import com.bin.david.form.core.TableConfig;
7 |
8 | /**
9 | * Created by huang on 2018/1/12.
10 | * 选中操作格式化
11 | */
12 |
13 | public interface ISelectFormat {
14 |
15 | void draw(Canvas canvas, Rect rect,Rect showRect, TableConfig config);
16 | }
17 |
--------------------------------------------------------------------------------
/form/src/main/java/com/bin/david/form/data/format/sequence/BaseSequenceFormat.java:
--------------------------------------------------------------------------------
1 | package com.bin.david.form.data.format.sequence;
2 |
3 | import android.graphics.Canvas;
4 | import android.graphics.Paint;
5 | import android.graphics.Rect;
6 |
7 | import com.bin.david.form.core.TableConfig;
8 | import com.bin.david.form.utils.DrawUtils;
9 |
10 | /**
11 | * Created by huang on 2018/3/21.
12 | */
13 |
14 | public abstract class BaseSequenceFormat implements ISequenceFormat{
15 | @Override
16 | public void draw(Canvas canvas, int sequence, Rect rect, TableConfig config) {
17 | //字体缩放
18 | Paint paint = config.getPaint();
19 | paint.setTextSize(paint.getTextSize()*(config.getZoom()>1?1:config.getZoom()));
20 | paint.setTextAlign(Paint.Align.CENTER);
21 | canvas.drawText(format(sequence+1),rect.centerX(), DrawUtils.getTextCenterY(rect.centerY(),paint) ,paint);
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/form/src/main/java/com/bin/david/form/data/format/sequence/ISequenceFormat.java:
--------------------------------------------------------------------------------
1 | package com.bin.david.form.data.format.sequence;
2 |
3 | import android.graphics.Canvas;
4 | import android.graphics.Rect;
5 |
6 | import com.bin.david.form.core.TableConfig;
7 | import com.bin.david.form.data.format.IFormat;
8 |
9 | /**
10 | * Created by huang on 2017/11/7.
11 | *
12 | *序号格式化
13 | */
14 |
15 | public interface ISequenceFormat extends IFormat{
16 |
17 |
18 | void draw(Canvas canvas, int sequence, Rect rect,TableConfig config);
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/form/src/main/java/com/bin/david/form/data/format/sequence/LetterSequenceFormat.java:
--------------------------------------------------------------------------------
1 | package com.bin.david.form.data.format.sequence;
2 |
3 |
4 | import com.bin.david.form.utils.LetterUtils;
5 |
6 | /**
7 | * Created by huang on 2017/11/7.
8 | */
9 |
10 | public class LetterSequenceFormat extends BaseSequenceFormat{
11 |
12 | @Override
13 | public String format(Integer position) {
14 | return LetterUtils.ToNumberSystem26(position);
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/form/src/main/java/com/bin/david/form/data/format/sequence/NumberSequenceFormat.java:
--------------------------------------------------------------------------------
1 | package com.bin.david.form.data.format.sequence;
2 |
3 |
4 |
5 | /**
6 | * Created by huang on 2017/11/7.
7 | */
8 |
9 | public class NumberSequenceFormat extends BaseSequenceFormat{
10 |
11 | @Override
12 | public String format(Integer position) {
13 | return String.valueOf(position);
14 | }
15 |
16 |
17 | }
18 |
--------------------------------------------------------------------------------
/form/src/main/java/com/bin/david/form/data/format/tip/ITip.java:
--------------------------------------------------------------------------------
1 | package com.bin.david.form.data.format.tip;
2 |
3 | import android.graphics.Canvas;
4 | import android.graphics.Rect;
5 |
6 |
7 | /**
8 | * Created by huang on 2017/10/20.
9 | */
10 |
11 | public interface ITip {
12 |
13 | void drawTip(Canvas canvas, float x, float y, Rect rect, C content, int position);
14 |
15 | boolean isShowTip(C c, int position);
16 |
17 | S format(C c, int position);
18 | }
19 |
--------------------------------------------------------------------------------
/form/src/main/java/com/bin/david/form/data/format/tip/MultiLineBubbleTip.java:
--------------------------------------------------------------------------------
1 | package com.bin.david.form.data.format.tip;
2 |
3 |
4 | import android.content.Context;
5 | import android.graphics.Canvas;
6 | import android.graphics.Paint;
7 | import android.graphics.Rect;
8 |
9 | import com.bin.david.form.data.style.FontStyle;
10 | import com.bin.david.form.utils.DensityUtils;
11 |
12 |
13 | /**
14 | * Created by huang on 2017/10/20.
15 | * 气泡提示
16 | */
17 |
18 | public abstract class MultiLineBubbleTip extends BaseBubbleTip{
19 |
20 | private int lineSpacing;
21 |
22 | public MultiLineBubbleTip(Context context, int backgroundDrawableID, int triangleDrawableID, FontStyle fontStyle) {
23 | super(context, backgroundDrawableID, triangleDrawableID,fontStyle );
24 | lineSpacing = DensityUtils.dp2px(context,3);
25 | }
26 |
27 | @Override
28 | public int getTextHeight(String[] content) {
29 | Paint.FontMetrics fontMetrics = getPaint().getFontMetrics();
30 | int textHeight= (int) (fontMetrics.bottom - fontMetrics.top);
31 | return (textHeight +lineSpacing)*content.length - lineSpacing;
32 | }
33 |
34 | @Override
35 | public int getTextWidth(String[] content) {
36 | int maxLength = 0;
37 | for(int i = 0;i < content.length;i++) {
38 | int length = (int) getPaint().measureText(content[i]);
39 | if (length > maxLength) {
40 | maxLength = length;
41 | }
42 | }
43 | return maxLength;
44 | }
45 |
46 | @Override
47 | public void drawText(Canvas canvas, Rect tipRect, String[] content, int textWidth, int textHeight, Paint paint) {
48 | int lineHeight =textHeight/content.length;
49 | for(int i = 0;i < content.length;i++) {
50 | String c = content[i];
51 | int bottom = tipRect.top+getPadding()+lineHeight+ (lineHeight)*i - lineSpacing-deviation/2;
52 | int left = tipRect.centerX()-textWidth/2;
53 | paint.setTextAlign(Paint.Align.LEFT);
54 | canvas.drawText(c,left,bottom,paint);
55 |
56 | }
57 | }
58 |
59 | }
60 |
--------------------------------------------------------------------------------
/form/src/main/java/com/bin/david/form/data/format/tip/SingleLineBubbleTip.java:
--------------------------------------------------------------------------------
1 | package com.bin.david.form.data.format.tip;
2 |
3 | import android.content.Context;
4 | import android.graphics.Canvas;
5 | import android.graphics.Paint;
6 | import android.graphics.Rect;
7 |
8 | import com.bin.david.form.data.style.FontStyle;
9 |
10 |
11 | /**
12 | * Created by huang on 2017/10/20.
13 | * 单行气泡提示
14 | */
15 |
16 | public abstract class SingleLineBubbleTip extends BaseBubbleTip {
17 |
18 | public SingleLineBubbleTip(Context context, int backgroundDrawableID, int triangleDrawableID, FontStyle style){
19 | super(context,backgroundDrawableID,triangleDrawableID,style);
20 | }
21 |
22 | @Override
23 | public int getTextHeight(String content) {
24 | Paint.FontMetrics fontMetrics = getPaint().getFontMetrics();
25 | return (int) (fontMetrics.bottom - fontMetrics.top);
26 | }
27 |
28 |
29 | @Override
30 | public int getTextWidth(String content) {
31 | return (int) getPaint().measureText(content);
32 | }
33 |
34 | @Override
35 | public void drawText(Canvas canvas, Rect tipRect, String content, int textWidth,int textHeight, Paint paint) {
36 | paint.setTextAlign(Paint.Align.LEFT);
37 | canvas.drawText(content,tipRect.centerX()-textWidth/2,tipRect.centerY()+textHeight/2-deviation/2,paint);
38 | }
39 |
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/form/src/main/java/com/bin/david/form/data/format/title/ITitleDrawFormat.java:
--------------------------------------------------------------------------------
1 | package com.bin.david.form.data.format.title;
2 |
3 | import android.graphics.Canvas;
4 | import android.graphics.Rect;
5 |
6 | import com.bin.david.form.data.column.Column;
7 | import com.bin.david.form.core.TableConfig;
8 |
9 | /**
10 | * Created by huang on 2017/11/6.
11 | */
12 |
13 | public interface ITitleDrawFormat {
14 |
15 | /**
16 | *测量宽
17 | */
18 | int measureWidth(Column column, TableConfig config);
19 |
20 | /**
21 | *测量高
22 | */
23 | int measureHeight(TableConfig config);
24 |
25 | /**
26 | * 绘制
27 | * @param c 画笔
28 | * @param column 列信息
29 | */
30 | void draw(Canvas c, Column column, Rect rect, TableConfig config);
31 |
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/form/src/main/java/com/bin/david/form/data/format/title/ImageResTitleDrawFormat.java:
--------------------------------------------------------------------------------
1 | package com.bin.david.form.data.format.title;
2 |
3 | import android.content.Context;
4 | import android.graphics.Bitmap;
5 | import android.graphics.BitmapFactory;
6 | import android.util.LruCache;
7 |
8 | import com.bin.david.form.data.column.Column;
9 |
10 | /**
11 | * Created by huang on 2017/10/30.
12 | */
13 |
14 | public abstract class ImageResTitleDrawFormat extends BitmapTitleDrawFormat {
15 |
16 | private BitmapFactory.Options options = new BitmapFactory.Options();
17 | //使用缓存
18 | private LruCache cache;
19 |
20 |
21 | public ImageResTitleDrawFormat(int imageWidth, int imageHeight) {
22 | this(imageWidth,imageHeight,null);
23 | int maxMemory = (int)(Runtime.getRuntime().maxMemory() / 1024);// kB
24 | int cacheSize = maxMemory / 16;
25 | cache = new LruCache(cacheSize){
26 | @Override
27 | protected int sizeOf(Integer key,Bitmap bitmap){
28 | return bitmap.getRowBytes() * bitmap.getHeight() / 1024;// KB
29 | }
30 | };
31 | }
32 |
33 | public ImageResTitleDrawFormat(int imageWidth, int imageHeight, BitmapFactory.Options options) {
34 | super(imageWidth, imageHeight);
35 | this.options = options;
36 | }
37 |
38 | @Override
39 | protected Bitmap getBitmap(Column column) {
40 | int resID = getResourceID(column);
41 | Bitmap bitmap = cache.get(resID);
42 | if(bitmap == null) {
43 | bitmap = BitmapFactory.decodeResource(getContext().getResources(),resID,options);
44 | if(bitmap !=null) {
45 | cache.put(resID, bitmap);
46 | }
47 | }
48 | return bitmap;
49 | }
50 |
51 | protected abstract Context getContext();
52 |
53 | protected abstract int getResourceID(Column column);
54 |
55 |
56 | }
57 |
--------------------------------------------------------------------------------
/form/src/main/java/com/bin/david/form/data/format/title/TitleDrawFormat.java:
--------------------------------------------------------------------------------
1 | package com.bin.david.form.data.format.title;
2 |
3 | import android.graphics.Canvas;
4 | import android.graphics.Paint;
5 | import android.graphics.Rect;
6 |
7 | import com.bin.david.form.data.column.Column;
8 | import com.bin.david.form.core.TableConfig;
9 | import com.bin.david.form.data.format.bg.ICellBackgroundFormat;
10 | import com.bin.david.form.utils.DrawUtils;
11 |
12 | /**
13 | * Created by huang on 2017/10/30.
14 | */
15 |
16 | public class TitleDrawFormat implements ITitleDrawFormat {
17 |
18 | private boolean isDrawBg;
19 |
20 | @Override
21 | public int measureWidth(Column column, TableConfig config) {
22 | Paint paint = config.getPaint();
23 | config.getColumnTitleStyle().fillPaint(paint);
24 | return (int) (paint.measureText(column.getColumnName()));
25 | }
26 |
27 |
28 | @Override
29 | public int measureHeight(TableConfig config) {
30 | Paint paint = config.getPaint();
31 | config.getColumnTitleStyle().fillPaint(paint);
32 | return DrawUtils.getTextHeight(config.getColumnTitleStyle(),config.getPaint());
33 | }
34 |
35 | @Override
36 | public void draw(Canvas c, Column column, Rect rect, TableConfig config) {
37 | Paint paint = config.getPaint();
38 | boolean isDrawBg =drawBackground(c,column,rect,config);
39 | config.getColumnTitleStyle().fillPaint(paint);
40 | ICellBackgroundFormat backgroundFormat = config.getColumnCellBackgroundFormat();
41 |
42 | paint.setTextSize(paint.getTextSize()*config.getZoom());
43 | if(isDrawBg && backgroundFormat.getTextColor(column) != TableConfig.INVALID_COLOR){
44 | paint.setColor(backgroundFormat.getTextColor(column));
45 | }
46 | drawText(c, column, rect, paint);
47 | }
48 |
49 | private void drawText(Canvas c, Column column, Rect rect, Paint paint) {
50 | if(column.getTitleAlign() !=null) { //如果列设置Align ,则使用列的Align
51 | paint.setTextAlign(column.getTitleAlign());
52 | }
53 | c.drawText(column.getColumnName(), DrawUtils.getTextCenterX(rect.left,rect.right,paint), DrawUtils.getTextCenterY((rect.bottom+rect.top)/2,paint) ,paint);
54 | }
55 |
56 |
57 | public boolean drawBackground(Canvas c, Column column, Rect rect, TableConfig config) {
58 | ICellBackgroundFormat backgroundFormat = config.getColumnCellBackgroundFormat();
59 | if(isDrawBg && backgroundFormat != null ){
60 | backgroundFormat.drawBackground(c,rect,column,config.getPaint());
61 | return true;
62 | }
63 | return false;
64 | }
65 |
66 | public boolean isDrawBg() {
67 | return isDrawBg;
68 | }
69 |
70 | public void setDrawBg(boolean drawBg) {
71 | isDrawBg = drawBg;
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/form/src/main/java/com/bin/david/form/data/style/IStyle.java:
--------------------------------------------------------------------------------
1 | package com.bin.david.form.data.style;
2 |
3 | import android.graphics.Paint;
4 |
5 | /**
6 | * Created by huang on 2017/9/27.
7 | */
8 |
9 | public interface IStyle {
10 |
11 | void fillPaint(Paint paint);
12 | }
13 |
--------------------------------------------------------------------------------
/form/src/main/java/com/bin/david/form/data/style/LineStyle.java:
--------------------------------------------------------------------------------
1 | package com.bin.david.form.data.style;
2 |
3 | import android.content.Context;
4 | import android.graphics.Color;
5 | import android.graphics.Paint;
6 | import android.graphics.PathEffect;
7 |
8 | import com.bin.david.form.utils.DensityUtils;
9 |
10 |
11 | /**
12 | * Created by huang on 2017/9/27.
13 | */
14 |
15 | public class LineStyle implements IStyle {
16 |
17 | private float width =-1;
18 | private int color =-1;
19 | private boolean isFill;
20 | private PathEffect effect = new PathEffect();
21 | private static float defaultLineSize = 2f;
22 | private static int defaultLineColor = Color.parseColor("#e6e6e6");
23 |
24 | public LineStyle() {
25 |
26 | }
27 |
28 |
29 | public LineStyle(float width, int color) {
30 | this.width = width;
31 | this.color = color;
32 | }
33 | public LineStyle(Context context,float dp, int color) {
34 | this.width = DensityUtils.dp2px(context,dp);
35 | this.color = color;
36 | }
37 | public static void setDefaultLineSize(float width){
38 | defaultLineSize = width;
39 | }
40 |
41 | public static void setDefaultLineSize(Context context,float dp){
42 | defaultLineSize = DensityUtils.dp2px(context,dp);
43 | }
44 |
45 | public static void setDefaultLineColor(int color){
46 | defaultLineColor = color;
47 | }
48 |
49 | public float getWidth() {
50 | if(width == -1){
51 | return defaultLineSize;
52 | }
53 | return width;
54 | }
55 |
56 | public LineStyle setWidth(float width) {
57 | this.width = width;
58 | return this;
59 | }
60 | public LineStyle setWidth(Context context,int dp) {
61 | this.width = DensityUtils.dp2px(context,dp);
62 | return this;
63 | }
64 |
65 | public int getColor() {
66 | if(color == -1){
67 | return defaultLineColor;
68 | }
69 | return color;
70 | }
71 |
72 | public boolean isFill() {
73 | return isFill;
74 | }
75 |
76 | public LineStyle setFill(boolean fill) {
77 | isFill = fill;
78 | return this;
79 | }
80 |
81 | public LineStyle setColor(int color) {
82 |
83 | this.color = color;
84 | return this;
85 | }
86 |
87 | public LineStyle setEffect(PathEffect effect) {
88 | this.effect = effect;
89 | return this;
90 | }
91 |
92 | @Override
93 | public void fillPaint(Paint paint){
94 | paint.setColor(getColor());
95 | paint.setStyle(isFill?Paint.Style.FILL:Paint.Style.STROKE);
96 | paint.setStrokeWidth(getWidth());
97 | paint.setPathEffect(effect);
98 |
99 | }
100 | }
101 |
--------------------------------------------------------------------------------
/form/src/main/java/com/bin/david/form/data/style/PointStyle.java:
--------------------------------------------------------------------------------
1 | package com.bin.david.form.data.style;
2 |
3 | import android.content.Context;
4 | import android.graphics.Color;
5 | import android.graphics.Paint;
6 |
7 | import com.bin.david.form.utils.DensityUtils;
8 |
9 |
10 | /**
11 | * Created by huang on 2017/9/27.
12 | */
13 |
14 | public class PointStyle implements IStyle {
15 |
16 | public static final int CIRCLE = 0;
17 | public static final int SQUARE = 1;
18 | public static final int RECT = 2;
19 | private float width;
20 | private int color;
21 | private int shape;
22 | private Paint.Style style;
23 | private static float defaultPointSize = 10f;
24 | private static int defaultPointColor = Color.parseColor("#888888");
25 | private boolean isDraw = true;
26 | public PointStyle() {
27 | }
28 |
29 | public PointStyle(float width, int color) {
30 | this.width = width;
31 | this.color = color;
32 | }
33 | public PointStyle(Context context, float dp, int color) {
34 | this.width = DensityUtils.dp2px(context,dp);
35 | this.color = color;
36 | }
37 | public static void setDefaultPointSize(float width){
38 | defaultPointSize = width;
39 | }
40 |
41 | public static void setDefaultLineSize(Context context,float dp){
42 | defaultPointSize = DensityUtils.dp2px(context,dp);
43 | }
44 |
45 | public static void setDefaultPointColor(int color){
46 | defaultPointColor = color;
47 | }
48 |
49 | public float getWidth() {
50 | if(width == 0){
51 | return defaultPointSize;
52 | }
53 | return width;
54 | }
55 |
56 | public void setWidth(float width) {
57 | this.width = width;
58 | }
59 | public void setWidth(Context context,int dp) {
60 | this.width = DensityUtils.dp2px(context,dp);
61 | }
62 |
63 | public int getColor() {
64 | if(color == 0){
65 | return defaultPointColor;
66 | }
67 | return color;
68 | }
69 |
70 | public void setColor(int color) {
71 |
72 | this.color = color;
73 | }
74 |
75 | public int getShape() {
76 | return shape;
77 | }
78 |
79 | public void setShape(int shape) {
80 | this.shape = shape;
81 | }
82 |
83 | public Paint.Style getStyle() {
84 | if(style == null){
85 | return Paint.Style.FILL;
86 | }
87 | return style;
88 | }
89 |
90 | public void setStyle(Paint.Style style) {
91 | this.style = style;
92 | }
93 |
94 | public boolean isDraw() {
95 | return isDraw;
96 | }
97 |
98 | public void setDraw(boolean draw) {
99 | isDraw = draw;
100 | }
101 |
102 | @Override
103 | public void fillPaint(Paint paint){
104 | paint.setColor(getColor());
105 | paint.setStyle(getStyle());
106 | paint.setStrokeWidth(getWidth());
107 | }
108 | }
109 |
--------------------------------------------------------------------------------
/form/src/main/java/com/bin/david/form/exception/TableException.java:
--------------------------------------------------------------------------------
1 | package com.bin.david.form.exception;
2 |
3 | /**
4 | * Created by huang on 2017/11/3.
5 | */
6 |
7 | public class TableException extends RuntimeException {
8 |
9 | public TableException(String message) {
10 | super(message);
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/form/src/main/java/com/bin/david/form/listener/Observable.java:
--------------------------------------------------------------------------------
1 | package com.bin.david.form.listener;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 |
6 | /**
7 | * Created by huang on 2017/9/29.
8 | */
9 |
10 | public abstract class Observable {
11 |
12 | public final ArrayList observables = new ArrayList<>();
13 |
14 | /**AttachObserver(通过实例注册观察者)
15 | **/
16 | public void register(T observer){
17 | if(observer==null) throw new NullPointerException();
18 | synchronized(observables){
19 | if(!observables.contains(observer)){
20 | observables.add(observer);
21 | }
22 | }
23 | }
24 |
25 |
26 |
27 | /**UnattachObserver(注销观察者)
28 | **/
29 | public void unRegister(T observer){
30 | if(observer==null) throw new NullPointerException();
31 | if(observables.contains(observer)){
32 | observables.remove(observer);
33 | }
34 | }
35 |
36 |
37 | public void unRegisterAll(){
38 | synchronized(observables){
39 | observables.clear();
40 | }
41 | }
42 |
43 | /**Ruturnthesizeofobservers*/
44 | public int countObservers(){
45 | synchronized(observables){
46 | return observables.size();
47 | }
48 | }
49 |
50 | /**
51 | *notify all observer(通知所有观察者,在子类中实现)
52 | */
53 | public abstract void notifyObservers(List observers);
54 |
55 |
56 | }
57 |
--------------------------------------------------------------------------------
/form/src/main/java/com/bin/david/form/listener/OnColumnClickListener.java:
--------------------------------------------------------------------------------
1 | package com.bin.david.form.listener;
2 |
3 | import com.bin.david.form.data.column.ColumnInfo;
4 |
5 | /**
6 | * Created by huang on 2017/11/4.
7 | */
8 |
9 | public interface OnColumnClickListener {
10 |
11 | void onClick(ColumnInfo columnInfo);
12 | }
13 |
--------------------------------------------------------------------------------
/form/src/main/java/com/bin/david/form/listener/OnColumnItemClickListener.java:
--------------------------------------------------------------------------------
1 | package com.bin.david.form.listener;
2 |
3 | import com.bin.david.form.data.column.Column;
4 |
5 | /**
6 | * Created by huang on 2017/11/4.
7 | */
8 |
9 | public interface OnColumnItemClickListener {
10 |
11 | void onClick(Column column,String value, T t, int position);
12 | }
13 |
--------------------------------------------------------------------------------
/form/src/main/java/com/bin/david/form/listener/OnTableChangeListener.java:
--------------------------------------------------------------------------------
1 | package com.bin.david.form.listener;
2 |
3 | /**
4 | * Created by huang on 2017/11/4.
5 | */
6 |
7 | public interface OnTableChangeListener {
8 |
9 | void onTableChanged(float scale, float translateX, float translateY);
10 | }
11 |
--------------------------------------------------------------------------------
/form/src/main/java/com/bin/david/form/listener/TableClickObserver.java:
--------------------------------------------------------------------------------
1 | package com.bin.david.form.listener;
2 |
3 | /**
4 | * Created by huang on 2017/9/29.
5 | */
6 |
7 | public interface TableClickObserver {
8 |
9 | void onClick(float x, float y);
10 |
11 |
12 | }
13 |
--------------------------------------------------------------------------------
/form/src/main/java/com/bin/david/form/matrix/ITouch.java:
--------------------------------------------------------------------------------
1 | package com.bin.david.form.matrix;
2 |
3 | import android.view.MotionEvent;
4 | import android.view.View;
5 |
6 | /**
7 | * Created by huang on 2017/10/18.
8 | */
9 |
10 | public interface ITouch {
11 | /**
12 | * 用于判断是否请求不拦截事件
13 | * 解决手势冲突问题
14 | * @param view
15 | * @param event
16 | */
17 | void onDisallowInterceptEvent(View view, MotionEvent event);
18 |
19 | /**
20 | * 处理touchEvent
21 | * @param event
22 | */
23 | boolean handlerTouchEvent(MotionEvent event);
24 | }
25 |
--------------------------------------------------------------------------------
/form/src/main/java/com/bin/david/form/matrix/PointEvaluator.java:
--------------------------------------------------------------------------------
1 | package com.bin.david.form.matrix;
2 |
3 | import android.animation.TypeEvaluator;
4 | import android.graphics.Point;
5 |
6 | /**
7 | * Created by huang on 2017/11/3.
8 | */
9 | public class PointEvaluator implements TypeEvaluator {
10 |
11 | private Point point = new Point();
12 |
13 | @Override
14 | public Object evaluate(float fraction, Object startValue, Object endValue) {
15 | Point startPoint = (Point) startValue;
16 | Point endPoint = (Point) endValue;
17 | int x = (int) (startPoint.x + fraction * (endPoint.x - startPoint.x));
18 | int y = (int) (startPoint.y + fraction * (endPoint.y - startPoint.y));
19 | point.set(x,y);
20 | return point;
21 | }
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/form/src/main/java/com/bin/david/form/utils/BitmapDrawer.java:
--------------------------------------------------------------------------------
1 | package com.bin.david.form.utils;
2 |
3 | import android.content.Context;
4 | import android.graphics.Bitmap;
5 | import android.graphics.BitmapFactory;
6 | import android.graphics.Canvas;
7 | import android.graphics.Color;
8 | import android.graphics.Paint;
9 | import android.graphics.Rect;
10 | import android.util.LruCache;
11 |
12 | import com.bin.david.form.core.TableConfig;
13 |
14 | /**
15 | * Created by huang on 2018/3/12.
16 | */
17 |
18 | public class BitmapDrawer {
19 |
20 |
21 | private Rect imgRect;
22 | private Rect drawRect;
23 | private BitmapFactory.Options options = new BitmapFactory.Options();
24 | //使用缓存
25 | private LruCache cache;
26 |
27 | public BitmapDrawer() {
28 | this.imgRect = new Rect();
29 | this.drawRect = new Rect();
30 | int maxMemory = (int)(Runtime.getRuntime().maxMemory() / 1024);// kB
31 | int cacheSize = maxMemory / 16;
32 | cache = new LruCache(cacheSize){
33 | @Override
34 | protected int sizeOf(Integer key,Bitmap bitmap){
35 | return bitmap.getRowBytes() * bitmap.getHeight() / 1024;// KB
36 | }
37 | };
38 |
39 | }
40 |
41 | public void drawRes(Context context,Canvas c, Rect rect, int resID, TableConfig config){
42 | Bitmap bitmap = cache.get(resID);
43 | if(bitmap == null) {
44 | bitmap = BitmapFactory.decodeResource(context.getResources(),resID,options);
45 | if(bitmap !=null) {
46 | cache.put(resID, bitmap);
47 | }
48 | drawBitmap(c,rect,bitmap,config);
49 | }
50 | }
51 |
52 |
53 | public void drawBitmap(Canvas c, Rect rect,Bitmap bitmap,TableConfig config) {
54 | Paint paint = config.getPaint();
55 | if (bitmap != null) {
56 | paint.setColor(Color.BLACK);
57 | paint.setStyle(Paint.Style.FILL);
58 | int width = bitmap.getWidth();
59 | int height = bitmap.getHeight();
60 | imgRect.set(0, 0, width, height);
61 | float scaleX = (float) width / rect.width();
62 | float scaleY = (float) height / rect.height();
63 | if (scaleX > 1 || scaleY > 1) {
64 | if (scaleX > scaleY) {
65 | width = (int) (width / scaleX);
66 | height = rect.height();
67 | } else {
68 | height = (int) (height / scaleY);
69 | width = rect.width();
70 | }
71 | }
72 | width = (int) (width * config.getZoom());
73 | height = (int) (height * config.getZoom());
74 | int disX = (rect.right - rect.left - width) / 2;
75 | int disY = (rect.bottom - rect.top - height) / 2;
76 | drawRect.left = rect.left + disX;
77 | drawRect.top = rect.top + disY;
78 | drawRect.right = rect.right - disX;
79 | drawRect.bottom = rect.bottom - disY;
80 | c.drawBitmap(bitmap, imgRect, drawRect, paint);
81 | }
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/form/src/main/java/com/bin/david/form/utils/DensityUtils.java:
--------------------------------------------------------------------------------
1 | package com.bin.david.form.utils;
2 |
3 | import android.content.Context;
4 | import android.util.TypedValue;
5 |
6 |
7 | //常用单位转换的辅助类
8 |
9 | public class DensityUtils {
10 |
11 | private DensityUtils() {
12 |
13 | /* cannot be instantiated */
14 |
15 | throw new UnsupportedOperationException("cannot be instantiated");
16 |
17 | }
18 |
19 |
20 | /**
21 | * dp转px
22 | *
23 | * @param context
24 | * @return
25 | */
26 |
27 | public static int dp2px(Context context, float dpVal)
28 |
29 | {
30 |
31 | return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
32 |
33 | dpVal, context.getResources().getDisplayMetrics());
34 |
35 | }
36 |
37 |
38 | /**
39 | * sp转px
40 | *
41 | * @param context
42 | * @return
43 | */
44 |
45 | public static int sp2px(Context context, float spVal)
46 |
47 | {
48 |
49 | return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP,
50 |
51 | spVal, context.getResources().getDisplayMetrics());
52 |
53 | }
54 |
55 |
56 | /**
57 | * px转dp
58 | *
59 | * @param context
60 | * @param pxVal
61 | * @return
62 | */
63 |
64 | public static float px2dp(Context context, float pxVal)
65 |
66 | {
67 |
68 | final float scale = context.getResources().getDisplayMetrics().density;
69 |
70 | return (pxVal / scale);
71 |
72 | }
73 |
74 |
75 | /**
76 | * px转sp
77 | *
78 | * @param pxVal
79 | * @return
80 | */
81 |
82 | public static float px2sp(Context context, float pxVal)
83 |
84 | {
85 |
86 | return (pxVal / context.getResources().getDisplayMetrics().scaledDensity);
87 |
88 | }
89 |
90 |
91 | }
--------------------------------------------------------------------------------
/form/src/main/java/com/bin/david/form/utils/LetterUtils.java:
--------------------------------------------------------------------------------
1 | package com.bin.david.form.utils;
2 |
3 | /**
4 | * Created by huang on 2017/11/1.
5 | */
6 |
7 | public class LetterUtils {
8 |
9 | public static String ToNumberSystem26(int n) {
10 | String s = "";
11 | while (n > 0) {
12 | int m = n % 26;
13 | if (m == 0) m = 26;
14 | s = (char) (m + 64) + s;
15 | n = (n - m) / 26;
16 | }
17 | return s;
18 | }
19 |
20 |
21 | public static boolean isBasicType(Object data) {
22 | if (data != null && data instanceof Number) {
23 | return true;
24 | } else {
25 | return false;
26 | }
27 | }
28 |
29 | public static boolean isNumber(Object data) {
30 | return !(data instanceof Float || data instanceof Double);
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/form/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | form
3 |
4 |
--------------------------------------------------------------------------------
/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 | android.enableAapt2=false
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/huangyanbin/smartTable/fe975d333a79586261f4f265317b9d1e6f2a36fa/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Wed Nov 01 13:29:16 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
7 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/img/1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huangyanbin/smartTable/fe975d333a79586261f4f265317b9d1e6f2a36fa/img/1.png
--------------------------------------------------------------------------------
/img/SmartTableCode.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huangyanbin/smartTable/fe975d333a79586261f4f265317b9d1e6f2a36fa/img/SmartTableCode.png
--------------------------------------------------------------------------------
/img/arrayColumn.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huangyanbin/smartTable/fe975d333a79586261f4f265317b9d1e6f2a36fa/img/arrayColumn.gif
--------------------------------------------------------------------------------
/img/avator.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huangyanbin/smartTable/fe975d333a79586261f4f265317b9d1e6f2a36fa/img/avator.jpg
--------------------------------------------------------------------------------
/img/dashang.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huangyanbin/smartTable/fe975d333a79586261f4f265317b9d1e6f2a36fa/img/dashang.jpg
--------------------------------------------------------------------------------
/img/multline.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huangyanbin/smartTable/fe975d333a79586261f4f265317b9d1e6f2a36fa/img/multline.jpg
--------------------------------------------------------------------------------
/img/new_excel.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huangyanbin/smartTable/fe975d333a79586261f4f265317b9d1e6f2a36fa/img/new_excel.png
--------------------------------------------------------------------------------
/img/old_excel.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huangyanbin/smartTable/fe975d333a79586261f4f265317b9d1e6f2a36fa/img/old_excel.png
--------------------------------------------------------------------------------
/img/progress.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huangyanbin/smartTable/fe975d333a79586261f4f265317b9d1e6f2a36fa/img/progress.jpg
--------------------------------------------------------------------------------
/img/refresh.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huangyanbin/smartTable/fe975d333a79586261f4f265317b9d1e6f2a36fa/img/refresh.gif
--------------------------------------------------------------------------------
/img/seat.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huangyanbin/smartTable/fe975d333a79586261f4f265317b9d1e6f2a36fa/img/seat.jpg
--------------------------------------------------------------------------------
/img/smartTable.apk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huangyanbin/smartTable/fe975d333a79586261f4f265317b9d1e6f2a36fa/img/smartTable.apk
--------------------------------------------------------------------------------
/img/table.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huangyanbin/smartTable/fe975d333a79586261f4f265317b9d1e6f2a36fa/img/table.gif
--------------------------------------------------------------------------------
/img/table.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huangyanbin/smartTable/fe975d333a79586261f4f265317b9d1e6f2a36fa/img/table.png
--------------------------------------------------------------------------------
/img/zoom.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huangyanbin/smartTable/fe975d333a79586261f4f265317b9d1e6f2a36fa/img/zoom.gif
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':form'
2 |
--------------------------------------------------------------------------------
| | | | | |