當前位置: 首頁>>代碼示例>>Java>>正文


Java DataSupport.findLast方法代碼示例

本文整理匯總了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();
}
 
開發者ID:BoldFei,項目名稱:Zmap_test,代碼行數:26,代碼來源:AccountProfile.java

示例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);
}
 
開發者ID:BoldFei,項目名稱:Zmap_test,代碼行數:29,代碼來源:SearchPageActivity.java

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

    }
 
開發者ID:Shmilyz,項目名稱:Swap,代碼行數:22,代碼來源:SearchFragment.java

示例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());
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:31,代碼來源:QueryClusterTest.java

示例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());
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:15,代碼來源:QueryBasicTest.java

示例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());
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:8,代碼來源:QueryEagerTest.java

示例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();
}
 
開發者ID:monkeywiiu,項目名稱:Discover,代碼行數:14,代碼來源:LikeFragment.java

示例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");
    }
}
 
開發者ID:BoldFei,項目名稱:Zmap_test,代碼行數:16,代碼來源:Profile.java

示例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();
    }
}
 
開發者ID:BoldFei,項目名稱:Zmap_test,代碼行數:14,代碼來源:MainActivity.java

示例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); //上傳到遠程數據庫
}
 
開發者ID:BoldFei,項目名稱:Zmap_test,代碼行數:17,代碼來源:SearchPageActivity.java


注:本文中的org.litepal.crud.DataSupport.findLast方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。