当前位置: 首页>>代码示例>>Java>>正文


Java AndroidDatabaseResults类代码示例

本文整理汇总了Java中com.j256.ormlite.android.AndroidDatabaseResults的典型用法代码示例。如果您正苦于以下问题:Java AndroidDatabaseResults类的具体用法?Java AndroidDatabaseResults怎么用?Java AndroidDatabaseResults使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


AndroidDatabaseResults类属于com.j256.ormlite.android包,在下文中一共展示了AndroidDatabaseResults类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: makePeopleNameCursor

import com.j256.ormlite.android.AndroidDatabaseResults; //导入依赖的package包/类
private Cursor makePeopleNameCursor(CharSequence name) throws SQLException {
    if (name == null) {
        name = "";
    }
    return ((AndroidDatabaseResults) app
            .getDao(Person.class)
            .queryRaw(
                    "SELECT rowid _id, * FROM people WHERE "
                            + Person.ISBOT_FIELD + " = 0 AND "
                            + Person.ISACTIVE_FIELD + " = 1 AND "
                            + Person.NAME_FIELD
                            + " LIKE ? ESCAPE '\\' ORDER BY "
                            + Person.NAME_FIELD + " COLLATE NOCASE",
                    DatabaseHelper.likeEscape(name.toString()) + "%")
            .closeableIterator().getRawResults()).getRawCursor();
}
 
开发者ID:zulip,项目名称:zulip-android,代码行数:17,代码来源:ZulipActivity.java

示例2: makeStreamCursor

import com.j256.ormlite.android.AndroidDatabaseResults; //导入依赖的package包/类
/**
 * Creates a cursor to get the streams saved in the database
 *
 * @param streamName Filter out streams name containing this string
 */
private Cursor makeStreamCursor(CharSequence streamName)
        throws SQLException {
    if (streamName == null) {
        streamName = "";
    }

    return ((AndroidDatabaseResults) app
            .getDao(Stream.class)
            .queryRaw(
                    "SELECT rowid _id, * FROM streams WHERE "
                            + Stream.SUBSCRIBED_FIELD + " = 1 AND "
                            + Stream.NAME_FIELD
                            + " LIKE ? ESCAPE '\\' ORDER BY "
                            + Stream.NAME_FIELD + " COLLATE NOCASE",
                    DatabaseHelper.likeEscape(streamName.toString()) + "%")
            .closeableIterator().getRawResults()).getRawCursor();
}
 
开发者ID:zulip,项目名称:zulip-android,代码行数:23,代码来源:ZulipActivity.java

示例3: makeSubjectCursor

import com.j256.ormlite.android.AndroidDatabaseResults; //导入依赖的package包/类
/**
 * Creates a cursor to get the topics in the stream in
 *
 * @param stream  from which topics similar to {@param subject} are selected
 * @param subject Filter out subject containing this string
 */
private Cursor makeSubjectCursor(CharSequence stream, CharSequence subject)
        throws SQLException {
    if (subject == null) {
        subject = "";
    }
    if (stream == null) {
        stream = "";
    }

    AndroidDatabaseResults results = (AndroidDatabaseResults) app
            .getDao(Message.class)
            .queryRaw(
                    "SELECT DISTINCT "
                            + Message.SUBJECT_FIELD
                            + ", 1 AS _id FROM messages JOIN streams ON streams."
                            + Stream.ID_FIELD + " = messages."
                            + Message.STREAM_FIELD + " WHERE "
                            + Message.SUBJECT_FIELD
                            + " LIKE ? ESCAPE '\\' AND "
                            + Stream.NAME_FIELD + " = ? ORDER BY "
                            + Message.SUBJECT_FIELD + " COLLATE NOCASE",
                    DatabaseHelper.likeEscape(subject.toString()) + "%",
                    stream.toString()).closeableIterator().getRawResults();
    return results.getRawCursor();
}
 
开发者ID:zulip,项目名称:zulip-android,代码行数:32,代码来源:ZulipActivity.java

示例4: makePeopleCursor

import com.j256.ormlite.android.AndroidDatabaseResults; //导入依赖的package包/类
/**
 * Creates a cursor to get the E-Mails stored in the database
 *
 * @param email Filter out emails containing this string
 */
private Cursor makePeopleCursor(CharSequence email) throws SQLException {
    if (email == null) {
        email = "";
    }
    String[] pieces = TextUtils.split(email.toString(), ",");
    String piece;
    if (pieces.length == 0) {
        piece = "";
    } else {
        piece = pieces[pieces.length - 1].trim();
    }
    return ((AndroidDatabaseResults) app
            .getDao(Person.class)
            .queryRaw(
                    "SELECT rowid _id, * FROM people WHERE "
                            + Person.ISBOT_FIELD + " = 0 AND "
                            + Person.ISACTIVE_FIELD + " = 1 AND "
                            + Person.EMAIL_FIELD
                            + " LIKE ? ESCAPE '\\' ORDER BY "
                            + Person.NAME_FIELD + " COLLATE NOCASE",
                    DatabaseHelper.likeEscape(piece) + "%")
            .closeableIterator().getRawResults()).getRawCursor();
}
 
开发者ID:zulip,项目名称:zulip-android,代码行数:29,代码来源:ZulipActivity.java

示例5: obtainCursor

import com.j256.ormlite.android.AndroidDatabaseResults; //导入依赖的package包/类
private Cursor obtainCursor(PreparedQuery<Observation> query, Dao<Observation, Long> oDao) throws SQLException {
	Cursor c = null;
	CloseableIterator<Observation> iterator = oDao.iterator(query);

	// get the raw results which can be cast under Android
	AndroidDatabaseResults results = (AndroidDatabaseResults) iterator.getRawResults();
	c = results.getRawCursor();
	if (c.moveToLast()) {
		long oldestTime = c.getLong(c.getColumnIndex("last_modified"));
		Log.i(LOG_NAME, "last modified is: " + c.getLong(c.getColumnIndex("last_modified")));
		Log.i(LOG_NAME, "querying again in: " + (oldestTime - requeryTime)/60000 + " minutes");
		if (queryUpdateHandle != null) {
			queryUpdateHandle.cancel(true);
		}
		queryUpdateHandle = scheduler.schedule(new Runnable() {
			public void run() {
				updateFilter();
			}
		}, oldestTime - requeryTime, TimeUnit.MILLISECONDS);
		c.moveToFirst();
	}
	return c;
}
 
开发者ID:ngageoint,项目名称:mage-android,代码行数:24,代码来源:ObservationFeedFragment.java

示例6: obtainCursor

import com.j256.ormlite.android.AndroidDatabaseResults; //导入依赖的package包/类
private Cursor obtainCursor(PreparedQuery<Location> query, Dao<Location, Long> lDao) throws SQLException {
    Cursor c = null;
    CloseableIterator<Location> iterator = lDao.iterator(query);

    // get the raw results which can be cast under Android
    AndroidDatabaseResults results = (AndroidDatabaseResults) iterator.getRawResults();
    c = results.getRawCursor();
    if (c.moveToLast()) {
        if (queryUpdateHandle != null) {
            queryUpdateHandle.cancel(true);
        }
        queryUpdateHandle = scheduler.schedule(new Runnable() {
            public void run() {
                updateTimeFilter(getTimeFilterId());
            }
        }, 30*1000, TimeUnit.MILLISECONDS);
        c.moveToFirst();
    }
    return c;
}
 
开发者ID:ngageoint,项目名称:mage-android,代码行数:21,代码来源:PeopleFeedFragment.java

示例7: getView

import com.j256.ormlite.android.AndroidDatabaseResults; //导入依赖的package包/类
@Override
@SuppressWarnings("deprecation") // for compat with older APIs
public View getView(int position, View convertView, ViewGroup parent) {
    final OperationView view;

    if (convertView == null)
        view = new OperationView(mContext);
    else
        view = (OperationView) convertView;

    try {
        ((AndroidDatabaseResults) mCursor.getRawResults()).moveAbsolute(position);
        Operation op = mCursor.current();
        view.setOperation(op);
    } catch (SQLException e) {
        throw new RuntimeException(e);
    }

    return view;
}
 
开发者ID:Adonai,项目名称:WalletMaster,代码行数:21,代码来源:OperationsFragment.java

示例8: newView

import com.j256.ormlite.android.AndroidDatabaseResults; //导入依赖的package包/类
public View newView(int position, View convertView, ViewGroup parent, int resId) {
    final View view;

    if (convertView == null) {
        final LayoutInflater inflater = LayoutInflater.from(mContext);
        view = inflater.inflate(resId, parent, false);
    } else
        view = convertView;

    try {
        ((AndroidDatabaseResults) mCursor.getRawResults()).moveAbsolute(position);
        Category cat = mCursor.current();

        final TextView name = (TextView) view.findViewById(android.R.id.text1);
        name.setText(cat.getName());
    } catch (SQLException e) {
        throw new RuntimeException(e); // should not happen
    }

    return view;
}
 
开发者ID:Adonai,项目名称:WalletMaster,代码行数:22,代码来源:CategoriesFragment.java

示例9: newView

import com.j256.ormlite.android.AndroidDatabaseResults; //导入依赖的package包/类
@Override
public View newView(int position, View convertView, ViewGroup parent, int resId) {
    final View view;

    if (convertView == null) {
        final LayoutInflater inflater = LayoutInflater.from(mContext);
        view = inflater.inflate(resId, parent, false);
    } else
        view = convertView;

    final TextView name = (TextView) view.findViewById(android.R.id.text1);
    if (position == 0)
        name.setText(mNoneResId);
    else {
        try {
            ((AndroidDatabaseResults) mCursor.getRawResults()).moveAbsolute(position - 1);
            T entity = mCursor.current();
            name.setText(entity.toString());
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
    }

    return view;
}
 
开发者ID:Adonai,项目名称:WalletMaster,代码行数:26,代码来源:WithDefaultAdapter.java

示例10: query

import com.j256.ormlite.android.AndroidDatabaseResults; //导入依赖的package包/类
@Override
public Cursor query(Uri uri, String[] projection, String selection,
                    String[] selectionArgs, String sortOrder) {

    switch (uriMatcher.match(uri)){
        case Type.MANGA_ALL:
            return ((AndroidDatabaseResults) dbHelper.getMangaRunDao().iterator().getRawResults()).getRawCursor();
        case Type.MANGA_ID:
            QueryBuilder<Manga,String> qb = dbHelper.getMangaRunDao().queryBuilder();
            try {
                qb.where().eq(Manga.ID_COLUMN_NAME, selection);
                return ((AndroidDatabaseResults) dbHelper.getMangaRunDao().iterator(qb.prepare()).getRawResults()).getRawCursor();
            } catch (SQLException e) {
                e.printStackTrace();
            }

        default:
            throw new RuntimeException("No content provider URI match.");
    }

}
 
开发者ID:Vrael,项目名称:eManga,代码行数:22,代码来源:DataContentProvider.java

示例11: getSteamCursorGenerator

import com.j256.ormlite.android.AndroidDatabaseResults; //导入依赖的package包/类
private Callable<Cursor> getSteamCursorGenerator() {

        Callable<Cursor> steamCursorGenerator = new Callable<Cursor>() {
            @Override
            public Cursor call() throws Exception {
                String query = "SELECT s.id as _id,  s.name, s.color"
                        + " FROM streams as s LEFT JOIN messages as m ON s.id=m.stream ";
                String selectArg = null;
                if (!etSearchStream.getText().toString().equals("") && !etSearchStream.getText().toString().isEmpty()) {
                    //append where clause
                    selectArg = etSearchStream.getText().toString() + '%';
                    query += " WHERE s.name LIKE ? " + " and s." + Stream.SUBSCRIBED_FIELD + " = " + "1 ";
                    //set visibility of this image false
                    ivSearchStreamCancel.setVisibility(View.VISIBLE);
                } else {
                    //set visibility of this image false
                    query += " WHERE s." + Stream.SUBSCRIBED_FIELD + " = " + "1 ";
                    ivSearchStreamCancel.setVisibility(View.GONE);
                }
                //append group by
                query += " group by s.name order by s.name COLLATE NOCASE";

                if (selectArg != null) {
                    return ((AndroidDatabaseResults) app.getDao(Stream.class).queryRaw(query, selectArg).closeableIterator().getRawResults()).getRawCursor();
                } else {
                    return ((AndroidDatabaseResults) app.getDao(Stream.class).queryRaw(query).closeableIterator().getRawResults()).getRawCursor();
                }
            }
        };
        return steamCursorGenerator;
    }
 
开发者ID:zulip,项目名称:zulip-android,代码行数:32,代码来源:ZulipActivity.java

示例12: makeEmojiCursor

import com.j256.ormlite.android.AndroidDatabaseResults; //导入依赖的package包/类
/**
 * Returns a cursor for the combinedAdapter used to suggest Emoji when ':' is typed in the {@link #messageEt}
 *
 * @param emoji A string to search in the existing database
 */
private Cursor makeEmojiCursor(CharSequence emoji)
        throws SQLException {
    if (emoji == null) {
        emoji = "";
    }
    return ((AndroidDatabaseResults) app
            .getDao(Emoji.class)
            .queryRaw("SELECT  rowid _id,name FROM emoji WHERE name LIKE '%" + emoji + "%'")
            .closeableIterator().getRawResults()).getRawCursor();
}
 
开发者ID:zulip,项目名称:zulip-android,代码行数:16,代码来源:ZulipActivity.java

示例13: bindView

import com.j256.ormlite.android.AndroidDatabaseResults; //导入依赖的package包/类
@Override
public void bindView(View listItem, Context context, Cursor cursor) {
	if (mQuery == null || cursor == null || listItem == null || context == null) {
		return;
	}

	try {
		T dto = mQuery.mapRow(new AndroidDatabaseResults(cursor,null));
		mListItemBinder.setItemContent(listItem, dto);
	} catch (SQLException e) {
		throw new RuntimeException(e);
	}
}
 
开发者ID:seguemodev,项目名称:Meducated-Ninja,代码行数:14,代码来源:ORMQueryAdapter.java

示例14: getItem

import com.j256.ormlite.android.AndroidDatabaseResults; //导入依赖的package包/类
@Override
public Object getItem(int position) {
	try {
		return mQuery.mapRow(new AndroidDatabaseResults((Cursor) super.getItem(position), null));
	}
	catch (SQLException e) {
		throw new RuntimeException(e);
	}
}
 
开发者ID:seguemodev,项目名称:Meducated-Ninja,代码行数:10,代码来源:ORMQueryAdapter.java

示例15: onItemClick

import com.j256.ormlite.android.AndroidDatabaseResults; //导入依赖的package包/类
/**
    * Zoom to map.
    * 
    */
@Override
public void onItemClick(AdapterView<?> adapter, View arg1, int position, long id) {
	HeaderViewListAdapter headerAdapter = (HeaderViewListAdapter)adapter.getAdapter();
	Cursor c = ((PeopleCursorAdapter) headerAdapter.getWrappedAdapter()).getCursor();
	c.moveToPosition(position);
	try {
		Location l = query.mapRow(new AndroidDatabaseResults(c, null, false));
		Intent profileView = new Intent(getActivity().getApplicationContext(), ProfileActivity.class);
		profileView.putExtra(ProfileActivity.USER_ID, l.getUser().getRemoteId());
		getActivity().startActivityForResult(profileView, 2);
	} catch (Exception e) {
		Log.e(LOG_NAME, "Problem.", e);
	}
}
 
开发者ID:ngageoint,项目名称:mage-android,代码行数:19,代码来源:PeopleFeedFragment.java


注:本文中的com.j256.ormlite.android.AndroidDatabaseResults类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。