本文整理匯總了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);
}
}