本文整理汇总了Java中org.litepal.crud.DataSupport.findFirst方法的典型用法代码示例。如果您正苦于以下问题:Java DataSupport.findFirst方法的具体用法?Java DataSupport.findFirst怎么用?Java DataSupport.findFirst使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.litepal.crud.DataSupport
的用法示例。
在下文中一共展示了DataSupport.findFirst方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreateView
import org.litepal.crud.DataSupport; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_me, container, false);
ButterKnife.bind(this, view);
getActivity().setTitle(R.string.app_name);
tvMeSno.setText(AppConfig.sno);
BasicInfo basicInfo = DataSupport.findFirst(BasicInfo.class);
if(null != basicInfo) {
setBasicInfo4View(basicInfo);
}else{
queryBasicInfo();
}
queryCurrentCash();
return view;
}
示例2: testLimit
import org.litepal.crud.DataSupport; //导入方法依赖的package包/类
public void testLimit() {
List<Book> bookList = DataSupport.limit(1).find(Book.class);
assertEquals(1, bookList.size());
Book book = bookList.get(0);
assertTrue(book.isSaved());
Book firstBook = DataSupport.findFirst(Book.class);
assertTrue(firstBook.isSaved());
assertEquals(firstBook.getBookName(), book.getBookName());
assertEquals(firstBook.getPages(), book.getPages());
assertEquals(firstBook.isPublished(), book.isPublished());
assertEquals(firstBook.getArea(), book.getArea());
assertEquals(firstBook.getPrice(), book.getPrice());
assertEquals(firstBook.getIsbn(), book.getIsbn());
assertEquals(firstBook.getLevel(), book.getLevel());
assertEquals(firstBook.getId(), book.getId());
bookList = DataSupport.order("id desc").limit(1).find(Book.class);
assertEquals(1, bookList.size());
book = bookList.get(0);
assertTrue(book.isSaved());
Book lastBook = DataSupport.findLast(Book.class);
assertTrue(lastBook.isSaved());
assertEquals(lastBook.getBookName(), book.getBookName());
assertEquals(lastBook.getPages(), book.getPages());
assertEquals(lastBook.isPublished(), book.isPublished());
assertEquals(lastBook.getArea(), book.getArea());
assertEquals(lastBook.getPrice(), book.getPrice());
assertEquals(lastBook.getIsbn(), book.getIsbn());
assertEquals(lastBook.getLevel(), book.getLevel());
assertEquals(lastBook.getId(), book.getId());
}
示例3: testFindFirst
import org.litepal.crud.DataSupport; //导入方法依赖的package包/类
public void testFindFirst() {
List<Book> expectedBooks = getBooks(null, null, null, null, null, null, null);
Book expectedFirstBook = expectedBooks.get(0);
Book realFirstBook = DataSupport.findFirst(Book.class);
assertEquals(expectedFirstBook.getId(), realFirstBook.getId());
assertEquals(expectedFirstBook.getBookName(), realFirstBook.getBookName());
assertEquals(expectedFirstBook.getPages(), realFirstBook.getPages());
assertEquals(expectedFirstBook.getPrice(), realFirstBook.getPrice());
assertEquals(expectedFirstBook.getArea(), realFirstBook.getArea());
assertEquals(expectedFirstBook.getIsbn(), realFirstBook.getIsbn());
assertEquals(expectedFirstBook.getLevel(), realFirstBook.getLevel());
assertEquals(expectedFirstBook.isPublished(), realFirstBook.isPublished());
assertTrue(realFirstBook.isSaved());
}
示例4: testEagerFindFirst
import org.litepal.crud.DataSupport; //导入方法依赖的package包/类
public void testEagerFindFirst() {
resetData();
Student s1 = DataSupport.findFirst(Student.class);
assertNull(s1.getClassroom());
s1 = DataSupport.findFirst(Student.class, true);
assertNotNull(s1);
}
示例5: getFirstYear
import org.litepal.crud.DataSupport; //导入方法依赖的package包/类
/**
* 获取当前登陆学号的大一那年的年份,如2013级则返回13(即使现在是2017年),从而构造2013-2014(大一) 这种选择框
* @return int 13
*/
public static int getFirstYear(){
int firstYear = 13; //校友则学年根据个人信息的班级获取,正常账号直接截学号
if(AppConfig.schoolmateSno.equals(AppConfig.sno)) {
BasicInfo basicInfo = DataSupport.findFirst(BasicInfo.class);
if(basicInfo == null){
LogUtils.e("校友学年获取失败");
}
firstYear = Integer.parseInt(basicInfo != null ? basicInfo.getClassroom().substring(2, 4) : "13");
}else {
firstYear = Integer.parseInt(AppConfig.sno.substring(0, 2));
}
return firstYear;
}
示例6: setDepartmentOrWeek
import org.litepal.crud.DataSupport; //导入方法依赖的package包/类
private void setDepartmentOrWeek(Context context){
String week = FileUtils.getCurrentWeek(context);
setRemoteView(context);
if(!TextUtils.isEmpty(week) && week.equals(""+FileUtils.SP_WEEK_NOT_SET)){
//设置学院文本
BasicInfo basicInfo = DataSupport.findFirst(BasicInfo.class);
if(basicInfo != null && !TextUtils.isEmpty(basicInfo.getDepartment() )){
remoteViews.setTextViewText(R.id.widget_tv_department,basicInfo.getDepartment());
}else{
remoteViews.setTextViewText(R.id.widget_tv_department,"学院获取失败");
}
}else {
remoteViews.setTextViewText(R.id.widget_tv_department, "第" + week + "周");
}
}