Search in sources :

Example 1 with OfflineListCursorAdapter

use of com.zhan_dui.dictionary.cursoradapters.OfflineListCursorAdapter in project little-bear-dictionary by daimajia.

the class DictionaryManageFragment method onDestroyView.

@Override
public void onDestroyView() {
    super.onDestroyView();
    QueryProcessor.updateCacheDictionaryList(getActivity().getApplicationContext());
    if (mDictionaryManageFragment.mOfflineDictionaryManageView == null) {
        return;
    }
    DragSortListView dragSortListView = (DragSortListView) mDictionaryManageFragment.mOfflineDictionaryManageView.findViewById(android.R.id.list);
    OfflineListCursorAdapter dragSortCursorAdapter = (OfflineListCursorAdapter) dragSortListView.getInputAdapter();
    ArrayList<Integer> SortedResult = dragSortCursorAdapter.getCursorPositions();
    if (SortedResult == null || SortedResult.size() == 0) {
        return;
    }
    Cursor cursor = dragSortCursorAdapter.getCursor();
    cursor.moveToPosition(-1);
    int i = 0;
    DictionaryDB dictionaryDB = new DictionaryDB(getActivity(), DictionaryDB.DB_NAME, null, DictionaryDB.DB_VERSION);
    SQLiteDatabase sqLiteDatabase = dictionaryDB.getWritableDatabase();
    while (cursor.moveToNext()) {
        String[] args = { SortedResult.get(i).toString(), cursor.getString(cursor.getColumnIndex("_id")) };
        sqLiteDatabase.execSQL("update `dictionary_list` set `dictionary_order`= ? where `_id`= ?", args);
        i++;
    }
}
Also used : DictionaryDB(com.zhan_dui.dictionary.db.DictionaryDB) OfflineListCursorAdapter(com.zhan_dui.dictionary.cursoradapters.OfflineListCursorAdapter) SQLiteDatabase(android.database.sqlite.SQLiteDatabase) DragSortListView(com.mobeta.android.dslv.DragSortListView) Cursor(android.database.Cursor)

Example 2 with OfflineListCursorAdapter

use of com.zhan_dui.dictionary.cursoradapters.OfflineListCursorAdapter in project little-bear-dictionary by daimajia.

the class GetOfflineAsyncTask method onPostExecute.

@Override
protected void onPostExecute(Cursor result) {
    super.onPostExecute(result);
    mWaittingView.setVisibility(View.GONE);
    mCursorAdapter = new OfflineListCursorAdapter(mContext, result, true);
    mOfflineDragSortListView.setAdapter(mCursorAdapter);
    mSqLiteDatabase.close();
}
Also used : OfflineListCursorAdapter(com.zhan_dui.dictionary.cursoradapters.OfflineListCursorAdapter)

Aggregations

OfflineListCursorAdapter (com.zhan_dui.dictionary.cursoradapters.OfflineListCursorAdapter)2 Cursor (android.database.Cursor)1 SQLiteDatabase (android.database.sqlite.SQLiteDatabase)1 DragSortListView (com.mobeta.android.dslv.DragSortListView)1 DictionaryDB (com.zhan_dui.dictionary.db.DictionaryDB)1