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