当前位置: 首页>>代码示例>>Java>>正文


Java DataSupport.count方法代码示例

本文整理汇总了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:
	}
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:21,代码来源:CountSampleActivity.java

示例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) {
	}
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:23,代码来源:QueryMathTest.java

示例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);
}
 
开发者ID:SailFlorve,项目名称:RunHDU,代码行数:34,代码来源:DataQueryModel.java

示例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);

    }
}
 
开发者ID:jcolladosp,项目名称:ePills,代码行数:35,代码来源:ClockActivity.java


注:本文中的org.litepal.crud.DataSupport.count方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。