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


Java DataSupport类代码示例

本文整理汇总了Java中org.litepal.crud.DataSupport的典型用法代码示例。如果您正苦于以下问题:Java DataSupport类的具体用法?Java DataSupport怎么用?Java DataSupport使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DataSupport类属于org.litepal.crud包,在下文中一共展示了DataSupport类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: loadData

import org.litepal.crud.DataSupport; //导入依赖的package包/类
@Override
protected void loadData() {

    DataSupport.findAllAsync(HeWeatherCity.class).listen(new FindMultiCallback() {
        @Override
        public <T> void onFinish(List<T> t) {
            List<HeWeatherCity> list = (List<HeWeatherCity>) t;
            HashSet<String> provinces = new HashSet<>();
            for (HeWeatherCity city : list) {
                provinces.add(city.getProvinceZh());
            }
            List<String> provinceArray = new ArrayList<>(provinces);
            List<SimpleItem> datas = new ArrayList<>();
            for (String s : provinceArray) {
                datas.add(new SimpleItem(s));
            }
            provinceAdapter.setNewData(datas);
        }
    });

}
 
开发者ID:li-yu,项目名称:FakeWeather,代码行数:22,代码来源:CityChooseActivity.java

示例2: recursiveSupportedGenericFields

import org.litepal.crud.DataSupport; //导入依赖的package包/类
private void recursiveSupportedGenericFields(Class<?> clazz, List<Field> supportedGenericFields) {
    if (clazz == DataSupport.class || clazz == Object.class) {
        return;
    }
    Field[] fields = clazz.getDeclaredFields();
    if (fields != null && fields.length > 0) {
        for (Field field : fields) {
            Column annotation = field.getAnnotation(Column.class);
            if (annotation != null && annotation.ignore()) {
                continue;
            }
            int modifiers = field.getModifiers();
            if (!Modifier.isStatic(modifiers) && isCollection(field.getType())) {
                String genericTypeName = getGenericTypeName(field);
                if (BaseUtility.isGenericTypeSupported(genericTypeName)) {
                    supportedGenericFields.add(field);
                }
            }
        }
    }
    recursiveSupportedGenericFields(clazz.getSuperclass(), supportedGenericFields);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:23,代码来源:LitePalBase.java

示例3: queryCities

import org.litepal.crud.DataSupport; //导入依赖的package包/类
/**
 * 查询选中省内所有的市,优先从数据库查询,如果没有查询到再去服务器上查询
 */
private void queryCities() {
    titleText.setText(selectedProvince.getProvinceName());
    backButton.setVisibility(View.VISIBLE);
    cityList = DataSupport.where("provinceid = ?", String.valueOf(selectedProvince.getId())).find(City.class);
    if (cityList.size() > 0) {
        dataList.clear();
        for (City city : cityList) {
            dataList.add(city.getCityName());
        }
        adapter.notifyDataSetChanged();
        listView.setSelection(0);
        currentLevel = LEVEL_CITY;
    } else {
        int provinceCode = selectedProvince.getProvinceCode();
        String address = "http://guolin.tech/api/china/" + provinceCode;
        queryFromServer(address, "city");
    }
}
 
开发者ID:qiaopeichen,项目名称:jojoweather,代码行数:22,代码来源:chooseAreaFragment.java

示例4: onClick

import org.litepal.crud.DataSupport; //导入依赖的package包/类
@Override
public void onClick(View view) {
	int result = 0;
	switch (view.getId()) {
	case R.id.sum_btn1:
		result = DataSupport.sum(Singer.class, "age", Integer.TYPE);
		mResultText.setText(String.valueOf(result));
		break;
	case R.id.sum_btn2:
		try {
			result = DataSupport.where("age > ?", mAgeEdit.getText().toString()).sum(
					Singer.class, "age", Integer.TYPE);
			mResultText.setText(String.valueOf(result));
		} catch (Exception e) {
			e.printStackTrace();
		}
		break;
	default:
	}
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:21,代码来源:SumSampleActivity.java

示例5: onClick

import org.litepal.crud.DataSupport; //导入依赖的package包/类
@Override
public void onClick(View view) {
	double result = 0;
	switch (view.getId()) {
	case R.id.avg_btn1:
		result = DataSupport.average(Singer.class, "age");
		mResultText.setText(String.valueOf(result));
		break;
	case R.id.avg_btn2:
		try {
			result = DataSupport.where("age > ?", mAgeEdit.getText().toString()).average(
					Singer.class, "age");
			mResultText.setText(String.valueOf(result));
		} catch (Exception e) {
			e.printStackTrace();
		}
		break;
	default:
	}
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:21,代码来源:AverageSampleActivity.java

示例6: onClick

import org.litepal.crud.DataSupport; //导入依赖的package包/类
@Override
public void onClick(View view) {
	int result = 0;
	switch (view.getId()) {
	case R.id.max_btn1:
		result = DataSupport.max(Singer.class, "age", Integer.TYPE);
		mResultText.setText(String.valueOf(result));
		break;
	case R.id.max_btn2:
		try {
			result = DataSupport.where("age < ?", mAgeEdit.getText().toString()).max(
					Singer.class, "age", Integer.TYPE);
			mResultText.setText(String.valueOf(result));
		} catch (Exception e) {
			e.printStackTrace();
		}
		break;
	default:
	}
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:21,代码来源:MaxSampleActivity.java

示例7: onOptionsItemSelected

import org.litepal.crud.DataSupport; //导入依赖的package包/类
@Override
public boolean onOptionsItemSelected(MenuItem item) {

    int id = item.getItemId();

    if (id == R.id.action_sync_calendar) {
        allIntake = DataSupport.findAll(IntakeMoment.class);
        getResultsFromApi(allIntake);

        return true;
    }
    if (id == R.id.action_add_medicine) {
        add_fab();
        return true;
    }

    return super.onOptionsItemSelected(item);
}
 
开发者ID:jcolladosp,项目名称:ePills,代码行数:19,代码来源:ClockActivity.java

示例8: queryBasicInfo

import org.litepal.crud.DataSupport; //导入依赖的package包/类
private void queryBasicInfo(){
    factory.getBasicInfo(new Observer<BasicInfo>() {
        @Override
        public void onSubscribe(Disposable d) {
        }

        @Override
        public void onNext(BasicInfo value) {
            DataSupport.deleteAll(BasicInfo.class);
            value.save();
            setBasicInfo4View(value);
        }
        @Override
        public void onError(Throwable e) {
            if(e != null && !TextUtils.isEmpty(e.getMessage())) {
                LogUtils.e(e.toString());
                Toast.makeText(getActivity(), e.getMessage(), Toast.LENGTH_SHORT).show();
            }
        }
        @Override
        public void onComplete() {

        }
    });
}
 
开发者ID:WeGdufe,项目名称:MovingGdufe-Android,代码行数:26,代码来源:MeFragment.java

示例9: calculateMonthlyMoney

import org.litepal.crud.DataSupport; //导入依赖的package包/类
public void calculateMonthlyMoney(int type, IOItem ioItem) {
    Sum sum = new Sum();
    Sum tmpSum = new Sum();
    String sumDate = formatSum.format(new Date());
    int id = (int)((double)type / 2 + 2.5);

    // 保证一定现有2号id,避免出现当月支出不更新的bug
    if (!tmpSum.isThereASum(tmpSum.MONTHLY_COST))
        tmpSum.saveSum(tmpSum, tmpSum.MONTHLY_COST, 0.0, 1, sumDate);

    if (sum.isThereASum(id)) {
        sum = DataSupport.find(Sum.class, id);
        if (sum.getDate().equals(ioItem.getTimeStamp().substring(0, 8))) {
            sum.calculateMoney(id, ioItem.getMoney(), type*type);
        } else {
            sum.saveSum(sum, id, ioItem.getMoney(), type*type, sumDate);
        }
    } else {
        sum.saveSum(sum, id, ioItem.getMoney(), type*type, sumDate);
    }
}
 
开发者ID:yuukidach,项目名称:Ucount,代码行数:22,代码来源:AddItemActivity.java

示例10: testSaveFastWithConstructors

import org.litepal.crud.DataSupport; //导入依赖的package包/类
public void testSaveFastWithConstructors() {
    Computer computer = new Computer("asus", 699.00);
    assertTrue(computer.saveFast());
    Assert.assertTrue(isDataExists(getTableName(computer), computer.getId()));
    Computer c = getComputer(computer.getId());
    assertEquals("asus", c.getBrand());
    assertEquals(699.00, c.getPrice());
    Computer cc = DataSupport.find(Computer.class, computer.getId());
    assertEquals("asus", cc.getBrand());
    assertEquals(699.00, cc.getPrice());
    Product p = new Product(null);
    p.setBrand("apple");
    p.setPrice(1222.33);
    p.saveFast();
    Product.find(Product.class, p.getId());
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:17,代码来源:SaveTest.java

示例11: onCreate

import org.litepal.crud.DataSupport; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_edit_intake);
    ButterKnife.bind(this);
    //setSupportActionBar(toolbar);
    intakeID = getIntent().getLongExtra("intakeID",-1);
    intakeMoment  = DataSupport.find(IntakeMoment.class,intakeID);
    medicine = DataSupport.find(Medicine.class,intakeMoment.getMedicineId());

    RequestOptions requestOptions = new RequestOptions();
    requestOptions.placeholder(R.drawable.pill_placeholder);
    requestOptions.error(R.drawable.pill_placeholder);
    requestOptions.centerCrop();
    String image_path= medicine.getImage();

    Glide.with(this).setDefaultRequestOptions(requestOptions).load(image_path).into(imageView);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setDisplayShowHomeEnabled(true);
    getSupportActionBar().setTitle(medicine.getName());
    imageView.setBackgroundColor(getResources().getColor(R.color.grey));

    time_text.setText(String.format("%02d:%02d", intakeMoment.getStartDate().getHours(),intakeMoment.getStartDate().getMinutes()));
    seekBar.setProgress(intakeMoment.getQuantity());
}
 
开发者ID:jcolladosp,项目名称:ePills,代码行数:27,代码来源:EditIntakeActivity.java

示例12: queryCities

import org.litepal.crud.DataSupport; //导入依赖的package包/类
/**
 * 查询选中省内所有的市,优先从数据库查询,如果没有查询到再去服务器上查询。
 */
private void queryCities() {
    titleText.setText(selectedProvince.getProvinceName());
    backButton.setVisibility(View.VISIBLE);
    cityList = DataSupport.where("provinceid = ?", String.valueOf(selectedProvince.getId())).find(City.class);
    if (cityList.size() > 0) {
        dataList.clear();
        for (City city : cityList) {
            dataList.add(city.getCityName());
        }
        adapter.notifyDataSetChanged();
        listView.setSelection(0);
        currentLevel = LEVEL_CITY;
    } else {
        int provinceCode = selectedProvince.getProvinceCode();
        String address = "http://guolin.tech/api/china/" + provinceCode;
        queryFromServer(address, "city");
    }
}
 
开发者ID:Shmilyz,项目名称:Swap,代码行数:22,代码来源:ChooseAreaFragment.java

示例13: testSaveInheritModels

import org.litepal.crud.DataSupport; //导入依赖的package包/类
public void testSaveInheritModels() {
    WeChatMessage weChatMessage = new WeChatMessage();
    weChatMessage.setFriend("Tom");
    weChatMessage.setContent("Hello nice to meet you");
    weChatMessage.setTitle("Greeting message");
    weChatMessage.setType(1);
    assertTrue(weChatMessage.save());
    assertTrue(weChatMessage.getId() > 0);
    WeChatMessage message1 = DataSupport.find(WeChatMessage.class, weChatMessage.getId());
    assertEquals("Tom", message1.getFriend());
    assertEquals("Hello nice to meet you", message1.getContent());
    assertNull(message1.getTitle());
    assertEquals(1, message1.getType());

    WeiboMessage weiboMessage = new WeiboMessage();
    weiboMessage.setType(2);
    weiboMessage.setTitle("Following message");
    weiboMessage.setContent("Something big happens");
    weiboMessage.setFollower("Jimmy");
    weiboMessage.setNumber(123456);
    assertTrue(weiboMessage.saveFast());
    assertTrue(weiboMessage.getId() > 0);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:24,代码来源:SaveTest.java

示例14: queryCounties

import org.litepal.crud.DataSupport; //导入依赖的package包/类
/**
 * 1、查询选中市所有的县,优先从数据库查询,如果没有查询到,则到服务器去查询
 * 2、更新界面
 */
private void queryCounties() {
    titleText.setText(selectedCity.getCityName());
    backButton.setVisibility(View.VISIBLE);
    countyList = DataSupport.where("cityid = ?",String.valueOf(selectedCity.getId())).find(County.class);
    if (countyList.size() > 0) {
        dataList.clear();
        for (County county : countyList) {
            dataList.add(county.getCountyName());
        }
        adapter.notifyDataSetChanged();
        listView.setSelection(0);
        currentLevel = LEVEL_COUNTY;
    } else {
        int provinceCode = selectedProvince.getProvinceCode();
        int cityCode = selectedCity.getCityCode();
        String address = "http://guolin.tech/api/china/" + provinceCode + "/" + cityCode;
        queryFromServer(address, "county");
    }
}
 
开发者ID:zhegeshijiehuiyouai,项目名称:Weather365,代码行数:24,代码来源:ChooseAreaFragment.java

示例15: queryProvinces

import org.litepal.crud.DataSupport; //导入依赖的package包/类
private void queryProvinces() {
    titleText.setText("中国");
    backButton.setVisibility(View.GONE);
    provinceList = DataSupport.findAll(Province.class);
    if (provinceList.size() > 0) {
        dataList.clear();
        for (Province province : provinceList) {
            dataList.add(province.getProvinceName());
        }
        adapter.notifyDataSetChanged();
        listView.setSelection(0);
        currentLevel = LEVEL_PROVINCE;
    } else {
        String address = "http://guolin.tech/api/china";
        queryFromServer(address, "province");
    }
}
 
开发者ID:typer9527,项目名称:project-weather,代码行数:18,代码来源:ChooseAreaFragment.java


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