项目管理实践 -- 健身小管家(Fitness housekeeper)的管理(2)
继续跟踪进度
按计划应该在14号完成的工作,今天已经完成了。
功能不算复杂,因为这一段时间看了两个框架的使用,所以时间用的多了些。一个是注入的框架androidannotation,一个是数据库的ormlite。
下面贴一些代码出来,了解一下它们是如何使用的:
androidannotation
@NoTitle
@Fullscreen
@EActivity(R.layout.record)
public class RecordActivity extends Activity {
@ViewById(R.id.tvTitle)
TextView tvTitle;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@AfterViews
void initRecord() {
tvTitle.setText(R.string.record_title);
}
@Click(R.id.etRecordDate)
void recordDateClick() {
}
}
网上有如何引入这两个包的步骤,请自行搜索,记得把api的包放在libs下,另一个不带api的包放在别的文件夹里,不要放错位置。我当初就是把这两个包放反了位置,所以悲剧了,找了2个多小时才发现错误。
ormlite
jdbc的这个包,在android开发时可以不用。
public List<Type> getAllInDate(String date) {
List<Type> types = null;
try {
types = typeDaoOpe.queryBuilder().where().ge("enddate", date).and()
.le("startdate", date).query();
} catch (SQLException e) {
e.printStackTrace();
}
return types;
}
上面的ge、le,代表“>=”和“<=”,另外还有gt、lt是“>”和“<”
下面的例子是使用transaction的,简单介绍下。
public int delete(Collection<Integer> ids) {
final Collection<Integer> finalIds = ids;
int result = 1;
try {
TransactionManager.callInTransaction(helper.getConnectionSource(),
new Callable<Void>() {
@Override
public Void call() throws Exception {
try {
recordDao.deleteByTypeIds(finalIds);
typeDaoOpe.deleteIds(finalIds);
} catch (SQLException e) {
e.printStackTrace();
}
return null;
}
});
} catch (SQLException e) {
result = -1;
e.printStackTrace();
}
return result;
}
The End.

浙公网安备 33010602011771号