Skip to content

Commit

Permalink
增加了表单模式
Browse files Browse the repository at this point in the history
  • Loading branch information
huangyanbin committed Apr 10, 2018
1 parent af6f156 commit c84fd10
Show file tree
Hide file tree
Showing 24 changed files with 698 additions and 143 deletions.
6 changes: 3 additions & 3 deletions .idea/markdown-navigator.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 5 additions & 22 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ dependencies {
annotationProcessor 'com.github.bumptech.glide:compiler:4.3.1'
compile 'com.github.CymChad:BaseRecyclerViewAdapterHelper:2.9.31'
compile files('libs/jxl.jar')
compile 'com.scwang.smartrefresh:SmartRefreshLayout:1.0.4-7'
compile 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0-alpha-1'
implementation files('libs/poi-3.17.jar')
implementation files('libs/poi-scratchpad-3.17.jar')
compile 'com.vincent.filepicker:MultiTypeFilePicker:1.0.5'
Expand Down
4 changes: 3 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@
<activity
android:name=".ChoiceExcelActivity"
android:label="@string/title_activity_choice_excel"
android:theme="@style/AppTheme.NoActionBar"></activity>
android:theme="@style/AppTheme.NoActionBar"/>
<activity android:name=".FormModeActivity"
android:windowSoftInputMode="adjustPan"/>
</application>

</manifest>
Binary file modified app/src/main/assets/ic_class.xls
Binary file not shown.
32 changes: 31 additions & 1 deletion app/src/main/java/com/bin/david/smarttable/BaseApplication.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
package com.bin.david.smarttable;

import android.app.Application;

import android.content.Context;

import com.scwang.smartrefresh.layout.SmartRefreshLayout;
import com.scwang.smartrefresh.layout.api.DefaultRefreshFooterCreator;
import com.scwang.smartrefresh.layout.api.DefaultRefreshHeaderCreator;
import com.scwang.smartrefresh.layout.api.RefreshFooter;
import com.scwang.smartrefresh.layout.api.RefreshHeader;
import com.scwang.smartrefresh.layout.api.RefreshLayout;
import com.scwang.smartrefresh.layout.footer.ClassicsFooter;
import com.scwang.smartrefresh.layout.header.ClassicsHeader;
import com.zhy.http.okhttp.OkHttpUtils;

import java.util.concurrent.TimeUnit;
Expand All @@ -13,6 +22,26 @@
*/

public class BaseApplication extends android.support.multidex.MultiDexApplication {
//static 代码段可以防止内存泄露
static {
//设置全局的Header构建器
SmartRefreshLayout.setDefaultRefreshHeaderCreator(new DefaultRefreshHeaderCreator() {
@Override
public RefreshHeader createRefreshHeader(Context context, RefreshLayout layout) {
layout.setPrimaryColorsId(R.color.windows_bg, R.color.text_color);//全局设置主题颜色
return new ClassicsHeader(context);
}
});
//设置全局的Footer构建器
SmartRefreshLayout.setDefaultRefreshFooterCreator(new DefaultRefreshFooterCreator() {
@Override
public RefreshFooter createRefreshFooter(Context context, RefreshLayout layout) {
//指定为经典Footer,默认是 BallPulseFooter
return new ClassicsFooter(context).setDrawableSize(20);
}
});

}

@Override
public void onCreate() {
Expand All @@ -26,4 +55,5 @@ public void onCreate() {
OkHttpUtils.initClient(okHttpClient);

}

}
209 changes: 209 additions & 0 deletions app/src/main/java/com/bin/david/smarttable/FormModeActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,209 @@
package com.bin.david.smarttable;

import android.graphics.Paint;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.EditText;

import com.bin.david.form.core.SmartTable;
import com.bin.david.form.data.CellInfo;
import com.bin.david.form.data.column.Column;
import com.bin.david.form.data.format.IFormat;
import com.bin.david.form.data.format.grid.BaseGridFormat;
import com.bin.david.form.data.format.selected.BaseSelectFormat;
import com.bin.david.form.data.table.FormTableData;
import com.bin.david.form.data.table.TableData;
import com.bin.david.form.utils.DensityUtils;
import com.bin.david.smarttable.bean.Form;

/**
* Created by huang on 2018/4/10.
*/

public class FormModeActivity extends AppCompatActivity {

private SmartTable<Form> table;
private View llBottom;
private Button searchBtn;
private EditText editText;
private Form selectForm;

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_edit_table);
table = (SmartTable<Form>) findViewById(R.id.table);
int dp5 = DensityUtils.dp2px(this,10);
table.getConfig().setVerticalPadding(dp5)
.setTextLeftOffset(dp5);
llBottom = findViewById(R.id.ll_bottom);
searchBtn = (Button) findViewById(R.id.tv_query);
searchBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(selectForm !=null){
selectForm.setName(editText.getText().toString());
table.invalidate();
editText.setText("");
}
}
});
editText = (EditText)findViewById(R.id.edit_query) ;
Form[][] forms = {
{
new Form("姓名", Paint.Align.LEFT), Form.Empty,
new Form("性别", Paint.Align.LEFT), Form.Empty,
new Form("出生日期", Paint.Align.LEFT),Form.Empty,
new Form("民族", Paint.Align.LEFT), Form.Empty,
new Form("婚否", Paint.Align.LEFT), Form.Empty,
new Form(1, 4, "照片")
},
{
new Form("学历", Paint.Align.LEFT), Form.Empty,
new Form("专业", Paint.Align.LEFT), new Form(3, 1, ""),
new Form("何种语言", Paint.Align.LEFT), new Form(3, 1, "")
},
{
new Form("籍贯", Paint.Align.LEFT), Form.Empty,
new Form(2, 1, "户口所在地", Paint.Align.LEFT), new Form(3, 1, ""),
Form.Empty, new Form(2, 1, "")
},
{
new Form(2, 1, "现住址电话", Paint.Align.LEFT), new Form(8, 1, "")

},
{
new Form(2, 1, "身份证号码", Paint.Align.LEFT), new Form(4, 1, "")
, new Form(2, 1, "暂住证号码", Paint.Align.LEFT), new Form(3, 1, "")
},
{
new Form(2, 1, "应急联系人及电话", Paint.Align.LEFT), new Form(4, 1, "")
, new Form(2, 1, "联系人电话号码", Paint.Align.LEFT), new Form(3, 1, "")
},
{
new Form(2, 1, "申请职位", Paint.Align.LEFT), new Form(4, 1, "")
, new Form(2, 1, "本人要求待遇", Paint.Align.LEFT), new Form(3, 1, "")
},
{
new Form(11, 1, "家庭成员及主要社会关系")
},

{
new Form(2, 1, "姓名"),
new Form(2, 1, "与本人关系"),
new Form(7, 1, "单位及职务"),
},
{
new Form(2, 1, ""),
new Form(2, 1, ""),
new Form(7, 1, ""),
},
{
new Form(2, 1, ""),
new Form(2, 1, ""),
new Form(7, 1, ""),
},
{
new Form(2, 1, ""),
new Form(2, 1, ""),
new Form(7, 1, ""),
},
{
new Form(2, 1, ""),
new Form(2, 1, ""),
new Form(7, 1, ""),
},
{
new Form(2, 1, ""),
new Form(2, 1, ""),
new Form(7, 1, ""),
},
{
new Form(2, 1, ""),
new Form(2, 1, ""),
new Form(7, 1, ""),
},
{
new Form(11, 1, "工作经历")
},
{
new Form(4, 1, "起止时间"),
new Form(6, 1, "单位"),
new Form(1, 1, ""),
},
{
new Form(4, 1, ""),
new Form(6, 1, ""),
new Form(1, 1, ""),
},
{
new Form(4, 1, ""),
new Form(6, 1, ""),
new Form(1, 1, ""),
},
{
new Form(4, 1, ""),
new Form(6, 1, ""),
new Form(1, 1, ""),
},
{
new Form(11, 1, "本人保证以下资料全部属实,否则本人愿意承担由此造成的一切后果")
},
{
new Form(2, 1, "申请人签名"), new Form(4, 1, "")
, new Form(2, 1, "日期"), new Form(3, 1, "")
}

};
final FormTableData<Form> tableData = FormTableData.create(table, "登记表", 11, forms);
tableData.setFormat(new IFormat<Form>() {
@Override
public String format(Form form) {
if (form != null) {
return form.getName();
} else {
return "";
}
}
});
table.setSelectFormat(new BaseSelectFormat());
tableData.setOnItemClickListener(new TableData.OnItemClickListener<Form>() {
@Override
public void onClick(Column column, String value, Form form, int col, int row) {
if(form !=null){
selectForm = form;
editText.setFocusable(true);
editText.setFocusableInTouchMode(true);
editText.requestFocus();
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
}

}

});
table.getConfig().setTableGridFormat(new BaseGridFormat(){
@Override
protected boolean isShowHorizontalLine(int col, int row, CellInfo cellInfo) {
if(row == tableData.getLineSize() -1){
return false;
}
return true;
}

@Override
protected boolean isShowVerticalLine(int col, int row, CellInfo cellInfo) {
if(row == tableData.getLineSize() -1){
return false;
}
return true;
}
});
table.setTableData(tableData);


}
}
13 changes: 13 additions & 0 deletions app/src/main/java/com/bin/david/smarttable/GridModeActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.DashPathEffect;
import android.graphics.Paint;
Expand All @@ -28,6 +29,7 @@
import com.bin.david.form.data.format.draw.MultiLineDrawFormat;
import com.bin.david.form.data.format.draw.TextImageDrawFormat;
import com.bin.david.form.data.format.grid.BaseAbstractGridFormat;
import com.bin.david.form.data.format.grid.BaseGridFormat;
import com.bin.david.form.data.format.tip.MultiLineBubbleTip;
import com.bin.david.form.data.format.title.TitleImageDrawFormat;
import com.bin.david.form.data.style.FontStyle;
Expand Down Expand Up @@ -331,6 +333,16 @@ public int getBackGroundColor(CellInfo cellInfo) {


};
table.getConfig().setTableGridFormat(new BaseGridFormat(){
@Override
public void drawTableBorderGrid(Canvas canvas, int left, int top, int right, int bottom, Paint paint) {
paint.setStrokeWidth(10);
paint.setColor(Color.GREEN);
canvas.drawRect(left,top,right,bottom,paint);
}
});


//设置网格
table.getConfig().setContentCellBackgroundFormat(backgroundFormat)
.setTableGridFormat(new BaseAbstractGridFormat() {
Expand Down Expand Up @@ -404,6 +416,7 @@ public void onItemClick(TableStyle item, int position) {
items.add(TableStyle.FIXED_COUNT_ROW);
items.add(TableStyle.ZOOM);
chartDialog.show(this, true, items);

}

private void zoom(TableStyle item) {
Expand Down
Loading

0 comments on commit c84fd10

Please sign in to comment.