Skip to content

Commit f1ef1a9

Browse files
committed
Init commit
0 parents  commit f1ef1a9

File tree

1 file changed

+92
-0
lines changed

1 file changed

+92
-0
lines changed
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
package com.dujiajun.courseblock;
2+
3+
import android.content.Intent;
4+
import android.os.Bundle;
5+
import android.view.Menu;
6+
import android.view.MenuItem;
7+
8+
import com.google.android.material.floatingactionbutton.FloatingActionButton;
9+
import com.zhuangfei.timetable.TimetableView;
10+
import com.zhuangfei.timetable.view.WeekView;
11+
12+
import androidx.appcompat.app.AppCompatActivity;
13+
import androidx.appcompat.widget.Toolbar;
14+
15+
public class MainActivity extends AppCompatActivity {
16+
17+
//private TextView textCourse;
18+
//private List<Schedule> scheduleList;
19+
private CourseManager courseManager;
20+
private TimetableView timetableView;
21+
private WeekView weekView;
22+
23+
@Override
24+
protected void onCreate(Bundle savedInstanceState) {
25+
super.onCreate(savedInstanceState);
26+
setContentView(R.layout.activity_main);
27+
Toolbar toolbar = findViewById(R.id.toolbar);
28+
setSupportActionBar(toolbar);
29+
30+
//textCourse = findViewById(R.id.text_course);
31+
32+
FloatingActionButton fab = findViewById(R.id.fab);
33+
fab.setOnClickListener(view ->
34+
startActivity(new Intent(MainActivity.this, LoginActivity.class))
35+
);
36+
37+
timetableView = findViewById(R.id.id_timetableView);
38+
weekView = findViewById(R.id.id_weekview);
39+
weekView.curWeek(1)
40+
.callback(week -> {
41+
int cur = timetableView.curWeek();
42+
//更新切换后的日期,从当前周cur->切换的周week
43+
timetableView.onDateBuildListener()
44+
.onUpdateDate(cur, week);
45+
timetableView.changeWeekOnly(week);
46+
})
47+
.callback(() -> {
48+
49+
})
50+
.isShow(false).showView();
51+
52+
courseManager = CourseManager.getInstance(getApplicationContext());
53+
//courseManager.setTimetableView(timetableView);
54+
//timetableView.data(courseManager.getScheduleList()).curWeek(1).showView();
55+
56+
}
57+
58+
@Override
59+
protected void onResume() {
60+
super.onResume();
61+
}
62+
63+
@Override
64+
public boolean onCreateOptionsMenu(Menu menu) {
65+
// Inflate the menu; this adds items to the action bar if it is present.
66+
getMenuInflater().inflate(R.menu.menu_main, menu);
67+
return true;
68+
}
69+
70+
@Override
71+
public boolean onOptionsItemSelected(MenuItem item) {
72+
// Handle action bar item clicks here. The action bar will
73+
// automatically handle clicks on the Home/Up button, so long
74+
// as you specify a parent activity in AndroidManifest.xml.
75+
int id = item.getItemId();
76+
77+
//noinspection SimplifiableIfStatement
78+
if (id == R.id.action_settings) {
79+
courseManager.updateCourseDatabase("2018", CourseManager.SEMESTER.SECOND,
80+
schedules -> {
81+
timetableView.data(schedules).curWeek(1).showView();
82+
weekView.data(schedules).updateView();
83+
});
84+
85+
return true;
86+
}
87+
88+
return super.onOptionsItemSelected(item);
89+
}
90+
91+
92+
}

0 commit comments

Comments
 (0)