List of usage examples for android.database Cursor copyStringToBuffer
void copyStringToBuffer(int columnIndex, CharArrayBuffer buffer);
From source file:com.example.fragmentexercise.ContactsAdapter.java
@Override public void bindView(View arg0, Context arg1, Cursor arg2) { // TODO Auto-generated method stub final ContactListItemCache cache = (ContactListItemCache) arg0.getTag(); arg2.copyStringToBuffer(mDisplayNameIndex, cache.nameBuffer); int size = cache.nameBuffer.sizeCopied; cache.nameView.setText(cache.nameBuffer.data, 0, size); final long contactId = arg2.getLong(mContactIdIndex); contactIdList.add(contactId);/*ww w .j av a 2 s . com*/ final String lookupKey = arg2.getString(mLookupKeyIndex); cache.photoView.assignContactUri(Contacts.getLookupUri(contactId, lookupKey)); android.util.Log.e("PhotoData", "photoData=" + arg2.getString(mPhotoThumbailUriIndex)); // if (arg2.getLong(arg2.getColumnIndex(Contacts.PHOTO_ID)) > 0) { String photoData = arg2.getString(mPhotoThumbailUriIndex); Bitmap thumbnailBitmap = loadContactPhotoThumbnail(photoData); cache.photoView.setImageBitmap(thumbnailBitmap); } }
From source file:org.pixmob.freemobile.netstat.SyncService.java
private DailyStat computeDailyStat(long date) { long timeOnOrange = 0; long timeOnFreeMobile = 0; if (DEBUG) {/*w ww . j a va 2 s . c o m*/ Log.d(TAG, "Computing statistics for " + DateUtils.formatDate(date)); } final Cursor c = getContentResolver().query(Events.CONTENT_URI, new String[] { Events.TIMESTAMP, Events.MOBILE_OPERATOR }, Events.TIMESTAMP + ">=? AND " + Events.TIMESTAMP + "<=?", new String[] { String.valueOf(date), String.valueOf(date + 86400 * 1000) }, Events.TIMESTAMP); try { long t0 = 0; MobileOperator op0 = null; CharArrayBuffer cBuf = new CharArrayBuffer(6); while (c.moveToNext()) { final long t = c.getLong(0); c.copyStringToBuffer(1, cBuf); final MobileOperator op = MobileOperator.fromString(cBuf); if (t0 != 0) { if (op != null && op.equals(op0)) { final long dt = t - t0; if (MobileOperator.ORANGE.equals(op)) { timeOnOrange += dt; } else if (MobileOperator.FREE_MOBILE.equals(op)) { timeOnFreeMobile += dt; } } } t0 = t; op0 = op; } } finally { c.close(); } final DailyStat s = new DailyStat(); s.orange = timeOnOrange; s.freeMobile = timeOnFreeMobile; return s; }
From source file:org.pixmob.freemobile.netstat.SyncServiceTesting.java
private DailyStat computeDailyStat(long date) { long timeOnOrange = 0; long timeOnFreeMobile = 0; long timeOnFreeMobile3G = 0; long timeOnFemtocell = 0; long timeOnFreeMobile4G = 0; if (DEBUG) {/*from w w w . j ava2s . co m*/ Log.d(TAG, "Computing statistics for " + DateUtils.formatDate(date)); } Cursor computeStatisticsCursor = null; try { computeStatisticsCursor = getContentResolver().query(Events.CONTENT_URI, new String[] { Events.TIMESTAMP, Events.MOBILE_OPERATOR, Events.MOBILE_NETWORK_TYPE, Events.FEMTOCELL }, Events.TIMESTAMP + ">=? AND " + Events.TIMESTAMP + "<=?", new String[] { String.valueOf(date), String.valueOf(date + 86400 * 1000) }, Events.TIMESTAMP); long t0 = 0; MobileOperator op0 = null; CharArrayBuffer cBuf = new CharArrayBuffer(6); while (computeStatisticsCursor.moveToNext()) { final long t = computeStatisticsCursor.getLong(0); computeStatisticsCursor.copyStringToBuffer(1, cBuf); final MobileOperator op = MobileOperator.fromString(cBuf); final NetworkClass nc = NetworkClass.getNetworkClass(computeStatisticsCursor.getInt(2)); final boolean isFemtocell = computeStatisticsCursor.getInt(3) != 0; if (t0 != 0) { if (op != null && op.equals(op0)) { final long dt = t - t0; if (MobileOperator.ORANGE.equals(op)) { timeOnOrange += dt; } else if (MobileOperator.FREE_MOBILE.equals(op)) { timeOnFreeMobile += dt; if (isFemtocell) { timeOnFemtocell += dt; } else if (NetworkClass.NC_3G.equals(nc)) { timeOnFreeMobile3G += dt; } else if (NetworkClass.NC_4G.equals(nc)) { timeOnFreeMobile4G += dt; } } } } t0 = t; op0 = op; } } catch (Exception e) { Log.e(TAG, Log.getStackTraceString(e)); } finally { try { if (computeStatisticsCursor != null) computeStatisticsCursor.close(); } catch (Exception e) { Log.e(TAG, Log.getStackTraceString(e)); } } final DailyStat s = new DailyStat(); s.orange = timeOnOrange; s.freeMobile = timeOnFreeMobile; s.freeMobile3G = timeOnFreeMobile3G; s.freeMobile4G = timeOnFreeMobile4G; s.freeMobileFemtocell = timeOnFemtocell; return s; }
From source file:com.android.contacts.common.list.ContactListItemView.java
/** * Shows data element./* w w w .j a va 2 s .c o m*/ */ public void showData(Cursor cursor, int dataColumnIndex) { cursor.copyStringToBuffer(dataColumnIndex, mDataBuffer); setData(mDataBuffer.data, mDataBuffer.sizeCopied); }
From source file:com.android.contacts.common.list.ContactListItemView.java
public void showPhoneticName(Cursor cursor, int phoneticNameColumnIndex) { cursor.copyStringToBuffer(phoneticNameColumnIndex, mPhoneticNameBuffer); int phoneticNameSize = mPhoneticNameBuffer.sizeCopied; if (phoneticNameSize != 0) { setPhoneticName(mPhoneticNameBuffer.data, phoneticNameSize); } else {/* ww w . j a v a 2s. c o m*/ setPhoneticName(null, 0); } }