本文整理汇总了Java中org.litepal.crud.DataSupport.findLast方法的典型用法代码示例。如果您正苦于以下问题:Java DataSupport.findLast方法的具体用法?Java DataSupport.findLast怎么用?Java DataSupport.findLast使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.litepal.crud.DataSupport
的用法示例。
在下文中一共展示了DataSupport.findLast方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreate
import org.litepal.crud.DataSupport; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_account_profile_layout);
getSupportActionBar().hide();
url=getString(R.string.URl); //服务器接口地址
user_head_icon_btn = (ImageButton)findViewById(R.id.Account_profile_head_icon_btn);
top_view = findViewById(R.id.Account_profile_head_icon_choose_view);
bottom_view = findViewById(R.id.Account_profile_view);
TextView username_view = findViewById(R.id.Account_profile_nick_name_text);
current_user = DataSupport.findLast(Users.class); //从数据库读出当前登陆的用户
username_view.setText( current_user.getUsername());
user_head_icon_btn.setImageResource(getHeadIconResourceFromId(current_user.getId_head()));
addListener(R.id.Account_profile_head_icon_setting);//头像设置界面
addListener(R.id.Account_profile_logout); //logout
addListener(R.id.Account_profile_user_name_setting);//设置用户名
addListener(R.id.Account_profile_head_icon_choose_view);//头像选择界面
addListenerForChooseButton();
}
示例2: getAndShowSearchHistoryRecord
import org.litepal.crud.DataSupport; //导入方法依赖的package包/类
/**
* 从数据库获取历史记录
*/
public void getAndShowSearchHistoryRecord(){
current_user= DataSupport.findLast(Users.class);
Type type = new TypeToken<ArrayList<String>>() {}.getType();
historyList=gson.fromJson(current_user.getSearchHistory(), type); //解析获得的字符串为json
searchHistoryHolder.removeAllViews();
int listSize =historyList.size();
TextView tmp = (TextView) findViewById(R.id.SearchPageActivity_clear_all_history);
if(listSize > 0) tmp.setVisibility(View.VISIBLE);
else tmp.setVisibility(View.GONE);
Collections.reverse(historyList);
for(String text : historyList ){
final SearchHistoryItemLayout item = new SearchHistoryItemLayout(this, null, text);
item.setOnItemClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
getSearchResultAndUpdateList(item.getItemText());
editText.setText(item.getItemText());
}
});
searchHistoryHolder.addView(item);
}
Collections.reverse(historyList);
}
示例3: initv
import org.litepal.crud.DataSupport; //导入方法依赖的package包/类
private void initv() {
List<Data> count=DataSupport.select().find(Data.class);
int counts=count.size();
if (counts>0){
Data lastData= DataSupport.findLast(Data.class);
int last=lastData.getId();
if (last>5){
recent=DataSupport.limit(5).offset(last-5).find(Data.class);
}
else {
recent=DataSupport.findAll(Data.class);
}
}
final SearchRecentAdapter adapter=new SearchRecentAdapter(getActivity(),R.layout.hot_item,recent);
ListView listView= (ListView) rootView.findViewById(R.id.recent_view);
listView.setDivider(null);
listView.setAdapter(adapter);
}
示例4: 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());
}
示例5: testFindLast
import org.litepal.crud.DataSupport; //导入方法依赖的package包/类
public void testFindLast() {
List<Book> expectedBooks = getBooks(null, null, null, null, null, null, null);
Book expectedLastBook = expectedBooks.get(expectedBooks.size() - 1);
Book realLastBook = DataSupport.findLast(Book.class);
assertEquals(expectedLastBook.getId(), realLastBook.getId());
assertEquals(expectedLastBook.getBookName(), realLastBook.getBookName());
assertEquals(expectedLastBook.getPages(), realLastBook.getPages());
assertEquals(expectedLastBook.getPrice(), realLastBook.getPrice());
assertEquals(expectedLastBook.getArea(), realLastBook.getArea());
assertEquals(expectedLastBook.getIsbn(), realLastBook.getIsbn());
assertEquals(expectedLastBook.getLevel(), realLastBook.getLevel());
assertEquals(expectedLastBook.isPublished(), realLastBook.isPublished());
assertTrue(realLastBook.isSaved());
}
示例6: testEagerFindLast
import org.litepal.crud.DataSupport; //导入方法依赖的package包/类
public void testEagerFindLast() {
resetData();
Teacher t1 = DataSupport.findLast(Teacher.class);
assertEquals(0, t1.getStudents().size());
t1 = DataSupport.findLast(Teacher.class, true);
assertTrue(0 < t1.getStudents().size());
}
示例7: onActivityCreated
import org.litepal.crud.DataSupport; //导入方法依赖的package包/类
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
isPrepare = true;
likeVideoList = DataSupport.order("id desc").limit(mNum).find(LikeVideo.class);
if (DataSupport.findLast(LikeVideo.class) != null) {
largestId = DataSupport.findLast(LikeVideo.class).getId();
}
totalNum = DataSupport.findAll(LikeVideo.class).size();
initRecyclerView();
loadData();
showContentView();
}
示例8: onStart
import org.litepal.crud.DataSupport; //导入方法依赖的package包/类
@Override
protected void onStart(){
Log.e(TAG,"onStart");
super.onStart();
current_user = DataSupport.findLast(Users.class);
if(current_user !=null && current_user.getUser_id() != 0){
username_textView.setText(current_user.getUsername()); //修改用户名显示
user_head_icon_btn.setImageResource(AccountProfile.getHeadIconResourceFromId(current_user.getId_head()));
Log.e(TAG, "onCreate: get user"+current_user.getUser_id());
}else {
username_textView.setText("登录/注册");
user_head_icon_btn.setImageResource(R.drawable.profile_head);
Log.e(TAG, "onCreate: lose user");
}
}
示例9: unLoginAccount
import org.litepal.crud.DataSupport; //导入方法依赖的package包/类
private void unLoginAccount(){
Users users;
users=DataSupport.findLast(Users.class);
if(users==null){
Gson gson =new Gson();
users =new Users();
users.setUsername("noName");
users.setSearchHistory(gson.toJson(new ArrayList<String>()));
users.setUser_id(0);
users.setStatusCode(0);
users.save();
}
}
示例10: putSearchRecordToDatabase
import org.litepal.crud.DataSupport; //导入方法依赖的package包/类
/**
* 将记录保存到本地以及远程数据库
* @param text:搜索内容
*/
public void putSearchRecordToDatabase(String text){
if(TextUtils.isEmpty(text)) return;
current_user= DataSupport.findLast(Users.class);
Type type = new TypeToken<ArrayList<String>>() {}.getType();
historyList=gson.fromJson(current_user.getSearchHistory(), type);
if(historyList.contains(text)) return;
historyList.add(text);
current_user.setSearchHistory(gson.toJson(historyList));
current_user.updateAll("User_id = ?",""+current_user.getUser_id());
putSearchRecordToOrigin(text); //上传到远程数据库
}