android里面的获取信息失效如何解决

linhu007 2013-09-04 10:10:37
弄了一个android应用程序,获取课表时为什么老是上个学期的课表并非本学期的课表信息?这种问题是获取信息代码写死了么?
部分代码:

/**
* 获取学期课表
*
* @param isRefresh
* @return
* @throws AppException
* @throws IOException
*/
public LessonList getTermLessonList(boolean isRefresh) throws AppException {
int userType = this.getLoginInfo().getData().get(0).getUserType();
String term = this.getProperty(AppConfig.YEAR_TERM);

if (this.guid == null) {
throw new AppException();
}

String url = "";
// 学生
if (userType == 2) {
url = URLs.STUDENT_TIMETABLE_URL + guid;
// 教师
} else if (userType == 1) {
url = URLs.TEACHER_TIMETABLE_URL + guid;
throw new AppException();
}

if (term == null || term.equals("")) {
throw new AppException(AppException.TYPE_TERM);
}

Map<String, Object> params = new HashMap<String, Object>();
params.put("xq", term);

return this.postEntityList(isRefresh, userId, LessonList.class, url,
params);

}

/**
* 得到指定周数的课表
*
* @param account
* 帐号
* @param term
* 学期
* @param flowWeek
* 当前周数
* @return 得到当前周的课表
*/
public List<DataLesson> getWeekLessons(List<DataLesson> list,
String account, String term, int flowWeek) {
List<DataLesson> result = new ArrayList<DataLesson>();

for (int i = 0; i < list.size(); i++) {
DataLesson lesson = list.get(i);

if (lesson == null) {
continue;
}
// 判断该课上不上
boolean flag = StringUtils.isAttend(flowWeek, lesson.getSkZhou());
if (flag == true) {
result.add(lesson);
}
}

return result;
}

/**
* 获取周课表
*
* @param isRefresh
* @return
* @throws AppException
* @throws IOException
*/
public List<DataLesson> getCurrentWeekLessons(boolean isRefresh)
throws AppException {
// AppConfig appConfig = AppConfig.getAppConfig(this);
// String startDate = appConfig.getProp(AppConfig.CONF_START_DATE);
String term = StringUtils.getTermByStartDate(startDate);
int flowWeek = StringUtils.getFlowWeek(startDate, new Date());

List<DataLesson> list = getTermLessonList(isRefresh).getData();

// 得到本周课表,从数据库
String account = this.getLoginInfo().getAccount();
List<DataLesson> oldList = this.getWeekLessons(list, account, term,
flowWeek);

// 添加星期
// List<List<Lesson>> newList = Utils.sortByWeekOfDay(oldList);
return oldList;

}

/**
* 获取今天和明天课表
*
* @param isRefresh
* @return
* @throws AppException
* @throws IOException
*/
public List<DataLesson> getDayAndTomorrow(boolean isRefresh)
throws AppException {

List<DataLesson> result = new ArrayList<DataLesson>();

// 得到今天和明天的课表
Date todayDate = new Date();
Calendar cal = Calendar.getInstance();
cal.add(Calendar.DAY_OF_YEAR, 1);

Date tomorrowDate = cal.getTime();
// 得到今天的上课周数
int todayFlowWeek = StringUtils.getFlowWeek(startDate, todayDate);
// 得到明天上课周数
int tomorrowFlowWeek = StringUtils.getFlowWeek(startDate, tomorrowDate);

List<DataLesson> source = getTermLessonList(isRefresh).getData();

List<DataLesson> list1 = StringUtils.getDayLessons(source,
todayFlowWeek, StringUtils.getDayOfWeek(new Date()));

List<DataLesson> list2 = StringUtils.getDayLessons(source,
tomorrowFlowWeek, StringUtils.getDayOfWeek(tomorrowDate));

// 得到今天和明天的课表
result.addAll(list1);
result.addAll(list2);
return result;
}
...全文
53 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

80,359

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧