List of usage examples for android.database CharArrayBuffer CharArrayBuffer
public CharArrayBuffer(char[] buf)
From source file:com.cyou.cma.clockscreen.fragment.QuickContactsFragment.java
public void saveContact(int position) { // adapter.getItem(arg2); CharArrayBuffer nameBuffer = new CharArrayBuffer(128); cursor.moveToPosition(position);//from w w w . ja v a 2 s . c o m cursor.copyStringToBuffer(SUMMARY_NAME_COLUMN_INDEX, nameBuffer); // String phoneName = String.valueOf(nameBuffer.data); String phoneName = new String(nameBuffer.data, 0, nameBuffer.sizeCopied); // Util.Logjb("jiangbinb", "phonename -->" + phoneName); final long contactId = cursor.getLong(SUMMARY_ID_COLUMN_INDEX); final String lookupKey = cursor.getString(SUMMARY_LOOKUP_KEY); final String phoneNumber = getPhoneNumber(getActivity(), contactId); if (LockApplication.mQuickContact != null) { LockApplication.mQuickContactDao.delete(LockApplication.mQuickContact); } QuickContact contact = new QuickContact(); contact.setContactName(phoneName); contact.setContactNumber(phoneNumber); contact.setLaunchSetIdOfContact(QuickLaunchFragment.ID); DatabaseUtil.saveContactToLaunchset(contact); getActivity().finish(); SendEvent sendEvent = new SendEvent(); sendEvent.eventType = SendEvent.CONTACT_TYPE; EventBus.getDefault().post(sendEvent); // contact.set }
From source file:com.cyou.cma.clockscreen.fragment.QuickContactsFragment.java
public QuickContact getContactAtPostion(int position) { // adapter.getItem(arg2); CharArrayBuffer nameBuffer = new CharArrayBuffer(128); cursor.moveToPosition(position);//from w ww.ja v a 2 s . c o m cursor.copyStringToBuffer(SUMMARY_NAME_COLUMN_INDEX, nameBuffer); String phoneName = new String(nameBuffer.data, 0, nameBuffer.sizeCopied); // Util.Logjb("jiangbinb", "phonename -->" + phoneName); final long contactId = cursor.getLong(SUMMARY_ID_COLUMN_INDEX); final String lookupKey = cursor.getString(SUMMARY_LOOKUP_KEY); final String phoneNumber = getPhoneNumber(getActivity(), contactId); QuickContact contact = new QuickContact(); contact.setContactName(phoneName); contact.setContactNumber(phoneNumber); return contact; }
From source file:org.pixmob.freemobile.netstat.SyncService.java
private DailyStat computeDailyStat(long date) { long timeOnOrange = 0; long timeOnFreeMobile = 0; if (DEBUG) {//from w ww . j ava 2 s .c om 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 . ja v a 2 s . c o 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; }