Skip to content

Commit

Permalink
完成List 转换成列
Browse files Browse the repository at this point in the history
  • Loading branch information
huangyanbin committed Feb 6, 2018
1 parent 32941b7 commit fbb0405
Show file tree
Hide file tree
Showing 19 changed files with 296 additions and 429 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ protected void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.activity_annotation);
FontStyle.setDefaultTextSize(DensityUtils.sp2px(this,15));
quickChartDialog = new QuickChartDialog();
List<Lesson> lessons = new ArrayList<>();
/* List<Lesson> lessons = new ArrayList<>();
lessons.add(new Lesson("语文",true));
lessons.add(new Lesson("数学",true));
lessons.add(new Lesson("英语",false));
lessons.add(new Lesson("物理",false));
lessons.add(new Lesson("化学",true));
lessons.add(new Lesson("化学",true));*/
List<String> texts = new ArrayList<>();
texts.add("测试哈1");
texts.add("测试哈2");
Expand All @@ -53,22 +53,23 @@ protected void onCreate(Bundle savedInstanceState) {
lesson1.setLessonPoints(new LessonPoint[]{new LessonPoint("软件工程"),new LessonPoint("离散数学")});
Lesson lesson2 = new Lesson("生物",true);
lesson2.setLessonPoints(new LessonPoint[]{new LessonPoint("医学构造"),new LessonPoint("生物科技")});
lesson2.setTest(texts);
//lesson2.setTest(texts);
lessons2.add(lesson1);
lessons2.add(lesson2);
lessons2.add(new Lesson("微积分",false));
Random random = new Random();
Lesson[] lessonArray = new Lesson[]{new Lesson("政治",false),new Lesson("法学",false)};
// Lesson[] lessonArray = new Lesson[]{new Lesson("政治",false),new Lesson("法学",false)};
List<TanBean> tanBeans = TanBean.initDatas();
final List<Student> students = new ArrayList<>();
//测试 从其他地方获取url
int urlSize = tanBeans.size();
for(int i = 0;i <50; i++) {
for(int i = 0;i <2; i++) {
Student student = new Student("用户"+i, random.nextInt(70), System.currentTimeMillis()
- random.nextInt(70)*3600*1000*24,true,new ChildData("测试"+i));
student.setUrl(tanBeans.get(i%urlSize).getUrl());
student.setLessons(i%3 ==0?lessons2:lessons);
student.setLessonsArray(lessonArray);
//student.setLessons(i%3 ==0?lessons2:lessons);
student.setLessons(lessons2);
// student.setLessonsArray(lessonArray);
students.add(student);
}
table = (SmartTable<Student>) findViewById(R.id.table);
Expand All @@ -77,7 +78,7 @@ protected void onCreate(Bundle savedInstanceState) {
table.getConfig().setShowXSequence(true);
table.getConfig().setShowYSequence(true);
table.setZoom(true,2,0.2f);
//设置单个格子背景颜色
/* //设置单个格子背景颜色
table.getConfig().setContentBackgroundFormat(new BaseCellBackgroundFormat<CellInfo>() {
@Override
public int getBackGroundColor(CellInfo cellInfo) {
Expand All @@ -98,7 +99,7 @@ public int getTextColor(CellInfo cellInfo) {
return super.getTextColor(cellInfo);
}
}
});
});*/
}

public void onClick(View view) {
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/com/bin/david/smarttable/bean/Lesson.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ public class Lesson {
private String name;
@SmartColumn(id = 5,name="是否喜欢")
private boolean isFav;
@SmartColumn(type = ColumnType.Array)
@SmartColumn(type = ColumnType.ArrayChild)
private LessonPoint[] lessonPoints;
@SmartColumn(id= 5,type = ColumnType.Array,name = "测试")
//@SmartColumn(type = ColumnType.ArrayOwn)
private List<String> test;

public Lesson(String name, boolean isFav) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package com.bin.david.smarttable.bean;

import com.bin.david.form.annotation.ColumnType;
import com.bin.david.form.annotation.SmartColumn;

import java.util.List;

/**
* Created by huang on 2018/2/2.
*/
Expand All @@ -10,7 +13,8 @@ public class LessonPoint {

@SmartColumn(id=4,name="知识点")
private String name;

@SmartColumn(id=4,name="More",type = ColumnType.ArrayOwn)
private List<String> more;
public LessonPoint(String name) {
this.name = name;
}
Expand Down
17 changes: 4 additions & 13 deletions app/src/main/java/com/bin/david/smarttable/bean/Student.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,17 @@
public class Student {
@SmartColumn(id =1,name = "姓名",autoCount = true)
private String name;
@SmartColumn(id=2,name="年龄",autoCount = true)
@SmartColumn(id=8,name="年龄",autoCount = true)
private int age;
@SmartColumn(id =3,name="更新时间")
@SmartColumn(id =7,name="更新时间")
private long time;
@SmartColumn(type= ColumnType.Child)
private ChildData childData;
@SmartColumn(id =4,name="选中")
@SmartColumn(id =6,name="选中")
private boolean isCheck;
private String url;
@SmartColumn(type = ColumnType.Array)
@SmartColumn(type = ColumnType.ArrayChild)
private List<Lesson> lessons;
@SmartColumn(type = ColumnType.Array)
private Lesson[] lessonsArray;

public Student(String name, int age, long time, boolean isCheck, ChildData childData) {
this.name = name;
Expand Down Expand Up @@ -91,11 +89,4 @@ public void setLessons(List<Lesson> lessons) {
this.lessons = lessons;
}

public Lesson[] getLessonsArray() {
return lessonsArray;
}

public void setLessonsArray(Lesson[] lessonsArray) {
this.lessonsArray = lessonsArray;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ public void initTableConfig(Context context, final SmartTable<Cell> table) {
public void draw(Canvas canvas,Rect scaleRect, Rect showRect, TableConfig config) {
if(imgPointSet.size() >0){
for(ImagePoint point :imgPointSet){
if(table.getProvider().getGridDrawer().maybeContain(point.row,point.col)) {
/* if(table.getProvider().getGridDrawer().maybeContain(point.row,point.col)) {*/
Bitmap bitmap = cache.get(point);
int[] location = table.getProvider().getPointLocation(point.row,point.col);
int[] size = table.getProvider().getPointSize((int)Math.ceil(point.row),(int)Math.ceil(point.col));
int width = (int) (size[0]*point.width);
int height = (int)(size[1]*point.height);
Rect imgBitmap = new Rect(location[0],location[1],location[0]+width,location[1]+height);
DrawHelper.drawBitmap(canvas,imgBitmap,bitmap,config);
}
/*}*/
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ buildscript {
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'

// NOTE: Do not place your application dependencies here; they belong
Expand Down
18 changes: 17 additions & 1 deletion form/src/main/java/com/bin/david/form/annotation/ColumnType.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,21 @@
*/

public enum ColumnType {
Own,Child,Array;
/**
* 查询当前字段
*/
Own,
/**
* 查询字段内部
*/
Child,

/**
* 查询当前数组或List对象
*/
ArrayOwn,
/**
* 查询当前数组或List对象内部
*/
ArrayChild;
}
Loading

0 comments on commit fbb0405

Please sign in to comment.