Skip to content

Commit c84fd10

Browse files
committed
增加了表单模式
1 parent af6f156 commit c84fd10

24 files changed

+698
-143
lines changed

.idea/markdown-navigator.xml

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 5 additions & 22 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ dependencies {
4545
annotationProcessor 'com.github.bumptech.glide:compiler:4.3.1'
4646
compile 'com.github.CymChad:BaseRecyclerViewAdapterHelper:2.9.31'
4747
compile files('libs/jxl.jar')
48-
compile 'com.scwang.smartrefresh:SmartRefreshLayout:1.0.4-7'
48+
compile 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0-alpha-1'
4949
implementation files('libs/poi-3.17.jar')
5050
implementation files('libs/poi-scratchpad-3.17.jar')
5151
compile 'com.vincent.filepicker:MultiTypeFilePicker:1.0.5'

app/src/main/AndroidManifest.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@
4747
<activity
4848
android:name=".ChoiceExcelActivity"
4949
android:label="@string/title_activity_choice_excel"
50-
android:theme="@style/AppTheme.NoActionBar"></activity>
50+
android:theme="@style/AppTheme.NoActionBar"/>
51+
<activity android:name=".FormModeActivity"
52+
android:windowSoftInputMode="adjustPan"/>
5153
</application>
5254

5355
</manifest>

app/src/main/assets/ic_class.xls

0 Bytes
Binary file not shown.

app/src/main/java/com/bin/david/smarttable/BaseApplication.java

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
11
package com.bin.david.smarttable;
22

33
import android.app.Application;
4-
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;
514
import com.zhy.http.okhttp.OkHttpUtils;
615

716
import java.util.concurrent.TimeUnit;
@@ -13,6 +22,26 @@
1322
*/
1423

1524
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+
}
1645

1746
@Override
1847
public void onCreate() {
@@ -26,4 +55,5 @@ public void onCreate() {
2655
OkHttpUtils.initClient(okHttpClient);
2756

2857
}
58+
2959
}
Lines changed: 209 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,209 @@
1+
package com.bin.david.smarttable;
2+
3+
import android.graphics.Paint;
4+
import android.os.Bundle;
5+
import android.support.annotation.Nullable;
6+
import android.support.v7.app.AppCompatActivity;
7+
import android.view.View;
8+
import android.view.WindowManager;
9+
import android.widget.Button;
10+
import android.widget.EditText;
11+
12+
import com.bin.david.form.core.SmartTable;
13+
import com.bin.david.form.data.CellInfo;
14+
import com.bin.david.form.data.column.Column;
15+
import com.bin.david.form.data.format.IFormat;
16+
import com.bin.david.form.data.format.grid.BaseGridFormat;
17+
import com.bin.david.form.data.format.selected.BaseSelectFormat;
18+
import com.bin.david.form.data.table.FormTableData;
19+
import com.bin.david.form.data.table.TableData;
20+
import com.bin.david.form.utils.DensityUtils;
21+
import com.bin.david.smarttable.bean.Form;
22+
23+
/**
24+
* Created by huang on 2018/4/10.
25+
*/
26+
27+
public class FormModeActivity extends AppCompatActivity {
28+
29+
private SmartTable<Form> table;
30+
private View llBottom;
31+
private Button searchBtn;
32+
private EditText editText;
33+
private Form selectForm;
34+
35+
@Override
36+
protected void onCreate(@Nullable Bundle savedInstanceState) {
37+
super.onCreate(savedInstanceState);
38+
setContentView(R.layout.activity_edit_table);
39+
table = (SmartTable<Form>) findViewById(R.id.table);
40+
int dp5 = DensityUtils.dp2px(this,10);
41+
table.getConfig().setVerticalPadding(dp5)
42+
.setTextLeftOffset(dp5);
43+
llBottom = findViewById(R.id.ll_bottom);
44+
searchBtn = (Button) findViewById(R.id.tv_query);
45+
searchBtn.setOnClickListener(new View.OnClickListener() {
46+
@Override
47+
public void onClick(View v) {
48+
if(selectForm !=null){
49+
selectForm.setName(editText.getText().toString());
50+
table.invalidate();
51+
editText.setText("");
52+
}
53+
}
54+
});
55+
editText = (EditText)findViewById(R.id.edit_query) ;
56+
Form[][] forms = {
57+
{
58+
new Form("姓名", Paint.Align.LEFT), Form.Empty,
59+
new Form("性别", Paint.Align.LEFT), Form.Empty,
60+
new Form("出生日期", Paint.Align.LEFT),Form.Empty,
61+
new Form("民族", Paint.Align.LEFT), Form.Empty,
62+
new Form("婚否", Paint.Align.LEFT), Form.Empty,
63+
new Form(1, 4, "照片")
64+
},
65+
{
66+
new Form("学历", Paint.Align.LEFT), Form.Empty,
67+
new Form("专业", Paint.Align.LEFT), new Form(3, 1, ""),
68+
new Form("何种语言", Paint.Align.LEFT), new Form(3, 1, "")
69+
},
70+
{
71+
new Form("籍贯", Paint.Align.LEFT), Form.Empty,
72+
new Form(2, 1, "户口所在地", Paint.Align.LEFT), new Form(3, 1, ""),
73+
Form.Empty, new Form(2, 1, "")
74+
},
75+
{
76+
new Form(2, 1, "现住址电话", Paint.Align.LEFT), new Form(8, 1, "")
77+
78+
},
79+
{
80+
new Form(2, 1, "身份证号码", Paint.Align.LEFT), new Form(4, 1, "")
81+
, new Form(2, 1, "暂住证号码", Paint.Align.LEFT), new Form(3, 1, "")
82+
},
83+
{
84+
new Form(2, 1, "应急联系人及电话", Paint.Align.LEFT), new Form(4, 1, "")
85+
, new Form(2, 1, "联系人电话号码", Paint.Align.LEFT), new Form(3, 1, "")
86+
},
87+
{
88+
new Form(2, 1, "申请职位", Paint.Align.LEFT), new Form(4, 1, "")
89+
, new Form(2, 1, "本人要求待遇", Paint.Align.LEFT), new Form(3, 1, "")
90+
},
91+
{
92+
new Form(11, 1, "家庭成员及主要社会关系")
93+
},
94+
95+
{
96+
new Form(2, 1, "姓名"),
97+
new Form(2, 1, "与本人关系"),
98+
new Form(7, 1, "单位及职务"),
99+
},
100+
{
101+
new Form(2, 1, ""),
102+
new Form(2, 1, ""),
103+
new Form(7, 1, ""),
104+
},
105+
{
106+
new Form(2, 1, ""),
107+
new Form(2, 1, ""),
108+
new Form(7, 1, ""),
109+
},
110+
{
111+
new Form(2, 1, ""),
112+
new Form(2, 1, ""),
113+
new Form(7, 1, ""),
114+
},
115+
{
116+
new Form(2, 1, ""),
117+
new Form(2, 1, ""),
118+
new Form(7, 1, ""),
119+
},
120+
{
121+
new Form(2, 1, ""),
122+
new Form(2, 1, ""),
123+
new Form(7, 1, ""),
124+
},
125+
{
126+
new Form(2, 1, ""),
127+
new Form(2, 1, ""),
128+
new Form(7, 1, ""),
129+
},
130+
{
131+
new Form(11, 1, "工作经历")
132+
},
133+
{
134+
new Form(4, 1, "起止时间"),
135+
new Form(6, 1, "单位"),
136+
new Form(1, 1, ""),
137+
},
138+
{
139+
new Form(4, 1, ""),
140+
new Form(6, 1, ""),
141+
new Form(1, 1, ""),
142+
},
143+
{
144+
new Form(4, 1, ""),
145+
new Form(6, 1, ""),
146+
new Form(1, 1, ""),
147+
},
148+
{
149+
new Form(4, 1, ""),
150+
new Form(6, 1, ""),
151+
new Form(1, 1, ""),
152+
},
153+
{
154+
new Form(11, 1, "本人保证以下资料全部属实,否则本人愿意承担由此造成的一切后果")
155+
},
156+
{
157+
new Form(2, 1, "申请人签名"), new Form(4, 1, "")
158+
, new Form(2, 1, "日期"), new Form(3, 1, "")
159+
}
160+
161+
};
162+
final FormTableData<Form> tableData = FormTableData.create(table, "登记表", 11, forms);
163+
tableData.setFormat(new IFormat<Form>() {
164+
@Override
165+
public String format(Form form) {
166+
if (form != null) {
167+
return form.getName();
168+
} else {
169+
return "";
170+
}
171+
}
172+
});
173+
table.setSelectFormat(new BaseSelectFormat());
174+
tableData.setOnItemClickListener(new TableData.OnItemClickListener<Form>() {
175+
@Override
176+
public void onClick(Column column, String value, Form form, int col, int row) {
177+
if(form !=null){
178+
selectForm = form;
179+
editText.setFocusable(true);
180+
editText.setFocusableInTouchMode(true);
181+
editText.requestFocus();
182+
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
183+
}
184+
185+
}
186+
187+
});
188+
table.getConfig().setTableGridFormat(new BaseGridFormat(){
189+
@Override
190+
protected boolean isShowHorizontalLine(int col, int row, CellInfo cellInfo) {
191+
if(row == tableData.getLineSize() -1){
192+
return false;
193+
}
194+
return true;
195+
}
196+
197+
@Override
198+
protected boolean isShowVerticalLine(int col, int row, CellInfo cellInfo) {
199+
if(row == tableData.getLineSize() -1){
200+
return false;
201+
}
202+
return true;
203+
}
204+
});
205+
table.setTableData(tableData);
206+
207+
208+
}
209+
}

app/src/main/java/com/bin/david/smarttable/GridModeActivity.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import android.content.Context;
44
import android.content.res.Resources;
55
import android.graphics.Bitmap;
6+
import android.graphics.Canvas;
67
import android.graphics.Color;
78
import android.graphics.DashPathEffect;
89
import android.graphics.Paint;
@@ -28,6 +29,7 @@
2829
import com.bin.david.form.data.format.draw.MultiLineDrawFormat;
2930
import com.bin.david.form.data.format.draw.TextImageDrawFormat;
3031
import com.bin.david.form.data.format.grid.BaseAbstractGridFormat;
32+
import com.bin.david.form.data.format.grid.BaseGridFormat;
3133
import com.bin.david.form.data.format.tip.MultiLineBubbleTip;
3234
import com.bin.david.form.data.format.title.TitleImageDrawFormat;
3335
import com.bin.david.form.data.style.FontStyle;
@@ -331,6 +333,16 @@ public int getBackGroundColor(CellInfo cellInfo) {
331333

332334

333335
};
336+
table.getConfig().setTableGridFormat(new BaseGridFormat(){
337+
@Override
338+
public void drawTableBorderGrid(Canvas canvas, int left, int top, int right, int bottom, Paint paint) {
339+
paint.setStrokeWidth(10);
340+
paint.setColor(Color.GREEN);
341+
canvas.drawRect(left,top,right,bottom,paint);
342+
}
343+
});
344+
345+
334346
//设置网格
335347
table.getConfig().setContentCellBackgroundFormat(backgroundFormat)
336348
.setTableGridFormat(new BaseAbstractGridFormat() {
@@ -404,6 +416,7 @@ public void onItemClick(TableStyle item, int position) {
404416
items.add(TableStyle.FIXED_COUNT_ROW);
405417
items.add(TableStyle.ZOOM);
406418
chartDialog.show(this, true, items);
419+
407420
}
408421

409422
private void zoom(TableStyle item) {

0 commit comments

Comments
 (0)