Skip to content

Commit

Permalink
完善自定义宽度例子,修复curWeek时无法监听到事件的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
zfman committed Sep 6, 2018
1 parent fc336f5 commit 1866708
Show file tree
Hide file tree
Showing 10 changed files with 191 additions and 455 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import android.content.Context;
import android.graphics.Color;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;
import android.widget.LinearLayout;

Expand Down Expand Up @@ -46,11 +47,12 @@
*/
public class TimetableView extends LinearLayout {

private static final String TAG = "TimetableView";
protected static final String TAG = "TimetableView";

//业务逻辑
private AbsOperater operater;
private Context context;
protected AttributeSet attrs;

// 当前周、学期、课程数据源
private int curWeek = 1;
Expand Down Expand Up @@ -120,6 +122,7 @@ public AbsOperater operater(){
}

public TimetableView operater(AbsOperater operater) {
operater.init(context,attrs,this);
this.operater = operater;
return this;
}
Expand Down Expand Up @@ -360,6 +363,7 @@ public ISchedule.OnWeekChangedListener onWeekChangedListener() {
*/
public TimetableView callback(ISchedule.OnWeekChangedListener onWeekChangedListener) {
this.onWeekChangedListener = onWeekChangedListener;
onWeekChangedListener.onWeekChanged(curWeek);
return this;
}

Expand Down Expand Up @@ -767,6 +771,7 @@ public int marTop() {
public TimetableView(Context context, AttributeSet attrs) {
super(context, attrs);
this.context = context;
this.attrs=attrs;
operater().init(context,attrs,this);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
* Created by Liu ZhuangFei on 2018/9/1.
*/
public class SimpleOperater extends AbsOperater{
private static final String TAG = "SimpleOperater";

protected TimetableView mView;
protected Context context;
Expand Down Expand Up @@ -105,7 +106,7 @@ public LinearLayout getDateLayout() {
}

/**
* 获取旗标布局
* 获取旗标布局,需要在showView方法执行后执行
* @return
*/
@Override
Expand Down Expand Up @@ -407,8 +408,9 @@ public void applyWidthConfig(){
*/
@Override
public void showView() {
if (mView.dataSource() == null) return;
if (mView==null||mView.dataSource() == null) return;
replaceScrollView();
Log.d(TAG, "showView: "+flagLayout);
applyFlagLayoutConf();
applyWidthConfig();

Expand Down
1 change: 1 addition & 0 deletions AndroidTimetableView/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
<activity android:name=".views.ExtrasActivity" />
<activity android:name=".views.FlaglayoutActivity" />
<activity android:name=".views.DateDelayActivity"></activity>
<activity android:name=".views.CustomWidthActivity"></activity>
</application>

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.zhuangfei.android_timetableview.views.AttrActivity;
import com.zhuangfei.android_timetableview.views.BaseFuncActivity;
import com.zhuangfei.android_timetableview.views.ColorPoolActivity;
import com.zhuangfei.android_timetableview.views.CustomWidthActivity;
import com.zhuangfei.android_timetableview.views.DateActivity;
import com.zhuangfei.android_timetableview.views.DateDelayActivity;
import com.zhuangfei.android_timetableview.views.ElasticActivity;
Expand Down Expand Up @@ -39,6 +40,7 @@ private void initView() {
Button button9=findViewById(R.id.id_btn9);
Button button10=findViewById(R.id.id_btn10);
Button button11=findViewById(R.id.id_btn11);
Button button12=findViewById(R.id.id_btn12);

button1.setOnClickListener(this);
button2.setOnClickListener(this);
Expand All @@ -51,6 +53,7 @@ private void initView() {
button9.setOnClickListener(this);
button10.setOnClickListener(this);
button11.setOnClickListener(this);
button12.setOnClickListener(this);
}

public void toTarget(Class cla){
Expand Down Expand Up @@ -94,6 +97,9 @@ public void onClick(View view) {
case R.id.id_btn11:
toTarget(DateDelayActivity.class);
break;
case R.id.id_btn12:
toTarget(CustomWidthActivity.class);
break;

}
}
Expand Down
Loading

0 comments on commit 1866708

Please sign in to comment.