本文整理汇总了Java中org.litepal.crud.DataSupport.count方法的典型用法代码示例。如果您正苦于以下问题:Java DataSupport.count方法的具体用法?Java DataSupport.count怎么用?Java DataSupport.count使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.litepal.crud.DataSupport
的用法示例。
在下文中一共展示了DataSupport.count方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onClick
import org.litepal.crud.DataSupport; //导入方法依赖的package包/类
@Override
public void onClick(View view) {
int result = 0;
switch (view.getId()) {
case R.id.count_btn1:
result = DataSupport.count(Singer.class);
mResultText.setText(String.valueOf(result));
break;
case R.id.count_btn2:
try {
result = DataSupport.where("age > ?", mAgeEdit.getText().toString()).count(
Singer.class);
mResultText.setText(String.valueOf(result));
} catch (Exception e) {
e.printStackTrace();
}
break;
default:
}
}
示例2: testCount
import org.litepal.crud.DataSupport; //导入方法依赖的package包/类
public void testCount() {
int result = DataSupport.count(Student.class);
int realResult = -100;
Cursor cursor = DataSupport.findBySQL("select count(1) from " + studentTable);
if (cursor.moveToFirst()) {
realResult = cursor.getInt(0);
}
cursor.close();
assertEquals(realResult, result);
result = DataSupport.where("id > ?", "99").count(studentTable);
cursor = DataSupport.findBySQL("select count(1) from " + studentTable + " where id > ?", "99");
if (cursor.moveToFirst()) {
realResult = cursor.getInt(0);
}
cursor.close();
assertEquals(realResult, result);
try {
DataSupport.count("nosuchtable");
fail();
} catch (Exception e) {
}
}
示例3: setStatisticsData
import org.litepal.crud.DataSupport; //导入方法依赖的package包/类
/**
* 设置统计数据
*/
public static void setStatisticsData(StatisticsCallback callback) {
int allStepsNum = DataSupport.sum(RunningInfo.class, "steps", int.class);
int allEnergyNum = DataSupport.sum(RunningInfo.class, "energy", int.class);
double allDisNum = DataSupport.sum(RunningInfo.class, "distance", int.class);
double averStepsNum = DataSupport.average(RunningInfo.class, "steps");
double averEnergyNum = DataSupport.average(RunningInfo.class, "energy");
double averDisNum = DataSupport.average(RunningInfo.class, "distance");
int allTimesNum = DataSupport.count(RunningInfo.class);
double averTimesNum = 0;
double allTimeNum = 0;
List<RunningInfo> list = RunningQueryUtil.findAllOrder();
String oldDate = null;
int runDays = 0;
for (RunningInfo info : list) {
String date = info.getDate();
if (!date.equals(oldDate)) runDays++;
oldDate = date;
allTimeNum += Utility.getMinutes(info.getDuration());
}
if (runDays != 0) {
averTimesNum = (double) allTimesNum / runDays;
}
callback.onDataPrepare(allStepsNum, allEnergyNum, allDisNum,
averStepsNum, averEnergyNum, averDisNum,
allTimesNum, averTimesNum, allTimeNum);
}
示例4: setPills
import org.litepal.crud.DataSupport; //导入方法依赖的package包/类
private void setPills(){
if(DataSupport.count(IntakeMoment.class)!=0) {
noPillsTV.setVisibility(View.GONE);
intakeMomentList.clear();
pillCardAdapter.notifyDataSetChanged();
Date today = new Date();
Date tomorrow = ClockUtils.addDays(today,1);
List<IntakeMoment> allIntakeToday = DataSupport.where("startdate between "
+today.getTime() +" and "+ tomorrow.getTime()).find(IntakeMoment.class);
if(allIntakeToday.size()==0){
noPillsTV.setText(R.string.no_pills_today);
noPillsTV.setVisibility(View.VISIBLE);
cards_layout.setVisibility(View.GONE);
}
for (IntakeMoment intake : allIntakeToday) {
intake.setMedicine(DataSupport.find(Medicine.class, intake.getMedicineId()));
intakeMomentList.add(intake);
analogClock.drawPill(intake.getStartDate().getHours());
}
pillCardAdapter.notifyDataSetChanged();
}
else{
noPillsTV.setText(R.string.no_pills_found);
noPillsTV.setVisibility(View.VISIBLE);
cards_layout.setVisibility(View.GONE);
}
}