Skip to content

Commit

Permalink
修改SimpleOperator变量修饰符为protect,可以更好的用于自定义
Browse files Browse the repository at this point in the history
  • Loading branch information
zfman committed Sep 5, 2018
1 parent 3a6a9c1 commit fc336f5
Show file tree
Hide file tree
Showing 4 changed files with 547 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,20 @@
*/
public class SimpleOperater extends AbsOperater{

private TimetableView mView;
private Context context;
protected TimetableView mView;
protected Context context;

//保存点击的坐标
private float x, y;
protected float x, y;

//布局转换器
private LayoutInflater inflater;
private LinearLayout weekPanel;//侧边栏
private List<Schedule>[] data = new ArrayList[7];//每天的课程
private LinearLayout[] panels = new LinearLayout[7];//每天的面板
private LinearLayout containerLayout;//根布局
private LinearLayout dateLayout;//根布局、日期栏容器
private LinearLayout flagLayout;//旗标布局
protected LayoutInflater inflater;
protected LinearLayout weekPanel;//侧边栏
protected List<Schedule>[] data = new ArrayList[7];//每天的课程
protected LinearLayout[] panels = new LinearLayout[7];//每天的面板
protected LinearLayout containerLayout;//根布局
protected LinearLayout dateLayout;//根布局、日期栏容器
protected LinearLayout flagLayout;//旗标布局

@Override
public void init(Context context, AttributeSet attrs, TimetableView view) {
Expand All @@ -69,6 +69,7 @@ public void init(Context context, AttributeSet attrs, TimetableView view) {
* @param attrs
*/
protected void initAttr(AttributeSet attrs) {
if(attrs==null) return;
TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.TimetableView);
int curWeek = ta.getInteger(R.styleable.TimetableView_cur_week, 1);
String curTerm = ta.getString(R.styleable.TimetableView_cur_term);
Expand Down Expand Up @@ -344,13 +345,9 @@ public boolean onTouch(View arg0, MotionEvent arg1) {
}

/**
* 绘制课程表
* 实现ScrollView的替换,只有在初始化时替换一次
*/
@Override
public void showView() {
if (mView.dataSource() == null) return;

//实现ScrollView的替换,只有在初始化时替换一次
public void replaceScrollView(){
if (mView.findViewById(R.id.id_scrollview) == null) {
View view = mView.onScrollViewBuildListener().getScrollView(inflater);
containerLayout.addView(view);
Expand All @@ -359,24 +356,26 @@ public void showView() {
flagLayout=mView.findViewById(R.id.id_flaglayout);
initPanel();
}
}

/**
* 设置旗标布局的配置
*/
public void applyFlagLayoutConf(){
mView.hideFlaglayout();
LinearLayout.LayoutParams lp=new LinearLayout.LayoutParams(mView.monthWidth(), LinearLayout.LayoutParams.MATCH_PARENT);
weekPanel.setLayoutParams(lp);
flagLayout.setBackgroundColor(mView.flagBgcolor());
float perWidth=getPerWidth();

mView.onSpaceItemClickListener().onInit(flagLayout, mView.monthWidth(),
Math.round(perWidth),mView.itemHeight(),mView.marTop(),
Math.round(mView.marLeft()/2.0f));
}


setWeekendsVisiable(mView.isShowWeekends());

//更新日期
updateDateView();
updateSlideView();

/**
* 开始装填数据
*/
public void startTodo(){
//清空、拆分数据
for (int i = 0; i < 7; i++) {
data[i].clear();
Expand All @@ -396,6 +395,29 @@ public void showView() {
}
}

/**
* 设置宽度
*/
public void applyWidthConfig(){
setWeekendsVisiable(mView.isShowWeekends());
}

/**
* 绘制课程表
*/
@Override
public void showView() {
if (mView.dataSource() == null) return;
replaceScrollView();
applyFlagLayoutConf();
applyWidthConfig();

//更新日期
updateDateView();
updateSlideView();
startTodo();
}

/**
* 切换周次
* @param week
Expand Down
Loading

0 comments on commit fc336f5

Please sign in to comment.