List of usage examples for android.util Log isLoggable
public static native boolean isLoggable(String tag, int level);
From source file:android.percent.support.PercentLayoutHelper.java
/** * Iterates over children and restores their original dimensions that were changed for * percentage values. Calling this method only makes sense if you previously called * {@link PercentLayoutHelper#adjustChildren(int, int)}. *///from w w w . j a v a 2s.c o m public void restoreOriginalParams() { for (int i = 0, N = mHost.getChildCount(); i < N; i++) { View view = mHost.getChildAt(i); ViewGroup.LayoutParams params = view.getLayoutParams(); if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "should restore " + view + " " + params); } if (params instanceof PercentLayoutParams) { PercentLayoutInfo info = ((PercentLayoutParams) params).getPercentLayoutInfo(); if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "using " + info); } if (info != null) { if (params instanceof ViewGroup.MarginLayoutParams) { info.restoreMarginLayoutParams((ViewGroup.MarginLayoutParams) params); } else { info.restoreLayoutParams(params); } } } } }
From source file:com.android.ex.chips.RecipientEditTextView.java
private CharSequence ellipsizeText(final CharSequence text, final TextPaint paint, final float maxWidth) { paint.setTextSize(mChipFontSize);/*from ww w .j a v a 2s. co m*/ if (maxWidth <= 0 && Log.isLoggable(TAG, Log.DEBUG)) Log.d(TAG, "Max width is negative: " + maxWidth); final CharSequence ellipsize = TextUtils.ellipsize(text, paint, maxWidth, TextUtils.TruncateAt.END); return ellipsize; }
From source file:com.example.android.wearable.quiz.MainActivity.java
/** * Clears the current quiz when user clicks on "New Quiz." * On this end, this involves clearing the quiz status layout and deleting all DataItems. The * wearable will then remove any outstanding question notifications upon receiving this change. *///from w w w. ja va2 s . co m public void newQuiz(View view) { clearQuizStatus(); if (mGoogleApiClient.isConnected()) { Wearable.DataApi.getDataItems(mGoogleApiClient).setResultCallback(new ResultCallback<DataItemBuffer>() { @Override public void onResult(DataItemBuffer result) { try { if (result.getStatus().isSuccess()) { List<Uri> dataItemUriList = new ArrayList<Uri>(); for (final DataItem dataItem : result) { dataItemUriList.add(dataItem.getUri()); } deleteDataItems(dataItemUriList); } else { if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "Clear quiz: failed to get Data Items for " + "deletion"); } } } finally { result.release(); } } }); } else { Log.e(TAG, "Failed to delete data items because client is disconnected from " + "Google Play Services"); } }
From source file:com.ntsync.android.sync.client.NetworkUtilities.java
/** * Perform 2-way sync with the server-side contacts. We send a request that * includes all the locally-dirty contacts so that the server can process * those changes, and we receive (and return) a list of contacts that were * updated on the server-side that need to be updated locally. * //from w w w.j av a2 s . c o m * @param account * The account being synced * @param authtoken * The authtoken stored in the AccountManager for this account * @param serverSyncState * A token returned from the server on the last sync * @param dirtyContacts * A list of the contacts to send to the server * @param newIdMap * Map of RawId to ServerId * @param explizitPhotoSave * @return A list of contacts that we need to update locally. Null if * processing of server-results failed. * @throws ParserConfigurationException * @throws TransformerException * @throws AuthenticatorException * @throws OperationCanceledException * when Authentication was canceled from user * @throws SAXException * @throws ServerException * @throws NetworkErrorException * @throws HeaderParseException * @throws HeaderCreateException */ public static SyncResponse syncContacts(Account account, String authtoken, SyncAnchor serverSyncState, List<RawContact> dirtyContacts, List<ContactGroup> dirtyGroups, SecretKey key, AccountManager accountManager, Context context, SyncResult syncResult, String pwdSaltHexStr, Map<Long, String> newIdMap, Restrictions restr, boolean explizitPhotoSave) throws AuthenticationException, OperationCanceledException, AuthenticatorException, ServerException, NetworkErrorException, HeaderParseException, HeaderCreateException { String clientId = getClientId(accountManager, account); SyncPrepErrorStatistic prepError = new SyncPrepErrorStatistic(); byte[] totBuffer = RequestGenerator.prepareServerRequest(serverSyncState, dirtyContacts, dirtyGroups, key, SystemHelper.getPkgVersion(context), clientId, pwdSaltHexStr, newIdMap, prepError, restr, explizitPhotoSave); syncResult.stats.numSkippedEntries += prepError.getIgnoredRows(); String currAuthtoken = authtoken; SyncResponse syncResponse = null; boolean retry; int retrycount = 0; do { retry = false; HttpEntity entity = new ByteArrayEntity(totBuffer); // Send the updated friends data to the server final HttpPost post = new HttpPost(SYNC_URI); post.setHeader("Content-Encoding", "application/octect-stream"); post.setEntity(entity); HttpEntity respEntity = null; try { final HttpResponse resp = getHttpClient(context).execute(post, createHttpContext(account.name, currAuthtoken)); respEntity = resp.getEntity(); if (resp.getStatusLine().getStatusCode() == HttpStatus.SC_OK) { final byte[] response = EntityUtils.toByteArray(respEntity); syncResponse = processServerResponse(account, key, accountManager, clientId, response, syncResult); if (Log.isLoggable(TAG, Log.INFO)) { Log.i(TAG, "Response-Length: " + response.length); } } else { if (resp.getStatusLine().getStatusCode() == HttpStatus.SC_UNAUTHORIZED) { currAuthtoken = retryAuthentification(retrycount, accountManager, currAuthtoken, account.name, resp); retry = true; } else { throw new ServerException( "Server error in sending dirty contacts: " + resp.getStatusLine()); } } } catch (IOException ex) { throw new NetworkErrorException(ex); } finally { consumeContent(respEntity); } retrycount++; } while (retry); return syncResponse; }
From source file:com.example.android.wearable.quiz.MainActivity.java
private void deleteDataItems(List<Uri> dataItemUriList) { if (mGoogleApiClient.isConnected()) { for (final Uri dataItemUri : dataItemUriList) { Wearable.DataApi.deleteDataItems(mGoogleApiClient, dataItemUri) .setResultCallback(new ResultCallback<DataApi.DeleteDataItemsResult>() { @Override public void onResult(DataApi.DeleteDataItemsResult deleteResult) { if (Log.isLoggable(TAG, Log.DEBUG)) { if (deleteResult.getStatus().isSuccess()) { Log.d(TAG, "Successfully deleted data item " + dataItemUri); } else { Log.d(TAG, "Failed to delete data item " + dataItemUri); }//w w w . j a v a2 s. com } } }); } } else { Log.e(TAG, "Failed to delete data items because client is disconnected from " + "Google Play Services"); } }
From source file:android.percent.support.PercentLayoutHelper.java
/** * Iterates over children and checks if any of them would like to get more space than it * received through the percentage dimension. * <p/>//from w w w . ja v a2 s. co m * If you are building a layout that supports percentage dimensions you are encouraged to take * advantage of this method. The developer should be able to specify that a child should be * remeasured by adding normal dimension attribute with {@code wrap_content} value. For example * he might specify child's attributes as {@code app:layout_widthPercent="60%p"} and * {@code android:layout_width="wrap_content"}. In this case if the child receives too little * space, it will be remeasured with width set to {@code WRAP_CONTENT}. * * @return True if the measure phase needs to be rerun because one of the children would like * to receive more space. */ public boolean handleMeasuredStateTooSmall() { boolean needsSecondMeasure = false; for (int i = 0, N = mHost.getChildCount(); i < N; i++) { View view = mHost.getChildAt(i); ViewGroup.LayoutParams params = view.getLayoutParams(); if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "should handle measured state too small " + view + " " + params); } if (params instanceof PercentLayoutParams) { PercentLayoutInfo info = ((PercentLayoutParams) params).getPercentLayoutInfo(); if (info != null) { if (shouldHandleMeasuredWidthTooSmall(view, info)) { needsSecondMeasure = true; params.width = ViewGroup.LayoutParams.WRAP_CONTENT; } if (shouldHandleMeasuredHeightTooSmall(view, info)) { needsSecondMeasure = true; params.height = ViewGroup.LayoutParams.WRAP_CONTENT; } } } } if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "should trigger second measure pass: " + needsSecondMeasure); } return needsSecondMeasure; }
From source file:com.samsung.spen.SpenPlugin.java
/** * Delete SpenSurface/*from ww w .j av a 2s.c om*/ * * @param id * String */ void deleteSpenSurface(String id) { if (Log.isLoggable(Utils.SPEN, Log.DEBUG)) { Log.d(TAG, "Inside deleteSpenSurface"); } if (mSpenSurfaceViews.getSurfaceView(id) != null) { mSpenSurfaceViews.removeSurfaceView(id); } }
From source file:com.concentriclivers.mms.com.android.mms.transaction.MessagingNotification.java
private static final void addMmsNotificationInfos(Context context, Set<Long> threads) { ContentResolver resolver = context.getContentResolver(); // This query looks like this when logged: // I/Database( 147): elapsedTime4Sql|/data/data/com.android.providers.telephony/databases/ // mmssms.db|0.362 ms|SELECT thread_id, date, _id, sub, sub_cs FROM pdu WHERE ((msg_box=1 // AND seen=0 AND (m_type=130 OR m_type=132))) ORDER BY date desc Cursor cursor = SqliteWrapper.query(context, resolver, Mms.CONTENT_URI, MMS_STATUS_PROJECTION, NEW_INCOMING_MM_CONSTRAINT, null, Mms.DATE + " desc"); if (cursor == null) { return;// w ww . j a va 2 s . c o m } try { while (cursor.moveToNext()) { long msgId = cursor.getLong(COLUMN_MMS_ID); Uri msgUri = Mms.CONTENT_URI.buildUpon().appendPath(Long.toString(msgId)).build(); String address = AddressUtils.getFrom(context, msgUri); Contact contact = Contact.get(address, false); if (contact.getSendToVoicemail()) { // don't notify, skip this one continue; } String subject = getMmsSubject(cursor.getString(COLUMN_SUBJECT), cursor.getInt(COLUMN_SUBJECT_CS)); long threadId = cursor.getLong(COLUMN_THREAD_ID); long timeMillis = cursor.getLong(COLUMN_DATE) * 1000; if (Log.isLoggable(LogTag.APP, Log.VERBOSE)) { Log.d(TAG, "addMmsNotificationInfos: count=" + cursor.getCount() + ", addr = " + address + ", thread_id=" + threadId); } // Extract the message and/or an attached picture from the first slide Bitmap attachedPicture = null; String messageBody = null; int attachmentType = WorkingMessage.TEXT; try { GenericPdu pdu = sPduPersister.load(msgUri); if (pdu != null && pdu instanceof MultimediaMessagePdu) { SlideshowModel slideshow = SlideshowModel.createFromPduBody(context, ((MultimediaMessagePdu) pdu).getBody()); attachmentType = getAttachmentType(slideshow); SlideModel firstSlide = slideshow.get(0); if (firstSlide != null) { if (firstSlide.hasImage()) { int maxDim = dp2Pixels(MAX_BITMAP_DIMEN_DP); attachedPicture = firstSlide.getImage().getBitmap(maxDim, maxDim); } if (firstSlide.hasText()) { messageBody = firstSlide.getText().getText(); } } } } catch (final MmsException e) { Log.e(TAG, "MmsException loading uri: " + msgUri, e); } NotificationInfo info = getNewMessageNotificationInfo(context, false /* isSms */, address, messageBody, subject, threadId, timeMillis, attachedPicture, contact, attachmentType); sNotificationSet.add(info); threads.add(threadId); } } finally { cursor.close(); } }
From source file:com.samsung.spen.SpenPlugin.java
/** * checks if the Spen feature is enabled or not. Send the result as * SPEN_SUPPORTED if the Spen is supported otherwise the corresponding error * message./*from w w w. j a va2 s. co m*/ * * @param context * Context * @param callbackContext * CallbackContext * @return spenState */ private int isSpenFeatureEnabled(Context context, CallbackContext callbackContext) { if (Log.isLoggable(Utils.SPEN, Log.DEBUG)) { Log.d(TAG, "inside isSpenFeatureEnabled"); } int spenState = SPEN_INITILIZATION_ERROR; Spen spenPackage = new Spen(); try { if (isStatic) { spenPackage.initialize(context, 5, Spen.SPEN_STATIC_LIB_MODE); } else { spenPackage.initialize(context); } if (spenPackage.isFeatureEnabled(Spen.DEVICE_PEN)) { spenState = SPEN_AND_HAND_SUPPORTED; } else { spenState = ONLY_HAND_SUPPORTED; } } catch (SsdkUnsupportedException e) { Log.d(TAG, "failed initializing the spen package " + e.getMessage()); e.printStackTrace(); // if the spen sdk version name (dynamic sdk) is lesser than // the jar version name (which is inlcuded in the spen plugin // then LIBRARY_UPDATE_IS_REQUIRED should be thrown. // Current, Spen SDK not handled it properly. SpenExceptionType errorType = null; boolean isExceptionTypeFound = false; if (spenPackage != null && !isStatic) { String dynamicSDKPkgName = Spen.SPEN_NATIVE_PACKAGE_NAME; try { PackageInfo packageInfo = mActivity.getPackageManager().getPackageInfo(dynamicSDKPkgName, 0); if (packageInfo != null) { String dynamicSDKVersionName = packageInfo.versionName.replace(".", ""); String pluginJarVersionName = spenPackage.getVersionName().replace(".", ""); if (dynamicSDKVersionName.compareTo(pluginJarVersionName) < 0) { errorType = SpenExceptionType.LIBRARY_UPDATE_IS_REQUIRED; isExceptionTypeFound = true; } } } catch (NameNotFoundException e1) { e1.printStackTrace(); } } if (!isExceptionTypeFound) { errorType = SpenException.processUnsupportedException(e); } PluginResult pluginResult = new PluginResult(PluginResult.Status.ERROR, errorType.toString()); pluginResult.setKeepCallback(false); callbackContext.sendPluginResult(pluginResult); } spenPackage = null; return spenState; }
From source file:com.android.contacts.model.AccountTypeManager.java
/** * Find the best {@link DataKind} matching the requested * {@link AccountType#accountType}, {@link AccountType#dataSet}, and {@link DataKind#mimeType}. * If no direct match found, we try searching {@link FallbackAccountType}. *///ww w . j a v a 2s .c o m @Override public DataKind getKindOrFallback(AccountType type, String mimeType) { DataKind kind = null; // Try finding account type and kind matching request if (type != null) { kind = type.getKindForMimetype(mimeType); } if (kind == null) { // Nothing found, so try fallback as last resort kind = mFallbackAccountType.getKindForMimetype(mimeType); } if (kind == null) { if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "Unknown type=" + type + ", mime=" + mimeType); } } return kind; }