List of usage examples for android.util Log isLoggable
public static native boolean isLoggable(String tag, int level);
From source file:KSView.PercentLayoutHelper.java
/** * Constructs a PercentLayoutInfo from attributes associated with a View. Call this method from * {@code LayoutParams(Context c, AttributeSet attrs)} constructor. */// w ww . ja v a 2 s. c o m public static PercentLayoutInfo getPercentLayoutInfo(Context context, AttributeSet attrs) { PercentLayoutInfo info = null; TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.PercentLayout_Layout); int index = R.styleable.PercentLayout_Layout_layout_widthPercent; String sizeStr = array.getString(index); PercentLayoutInfo.PercentVal percentVal = getPercentVal(sizeStr, true); if (percentVal != null) { if (Log.isLoggable(TAG, Log.VERBOSE)) { Log.v(TAG, "percent width: " + percentVal.percent); } info = checkForInfoExists(info); info.widthPercent = percentVal; } sizeStr = array.getString(R.styleable.PercentLayout_Layout_layout_heightPercent); percentVal = getPercentVal(sizeStr, false); if (sizeStr != null) { if (Log.isLoggable(TAG, Log.VERBOSE)) { Log.v(TAG, "percent height: " + percentVal.percent); } info = checkForInfoExists(info); info.heightPercent = percentVal; } // value = array.getFraction(R.styleable.PercentLayout_Layout_layout_marginPercent, 1, 1, -1f); sizeStr = array.getString(R.styleable.PercentLayout_Layout_layout_marginPercent); // just for judge percentVal = getPercentVal(sizeStr, false); if (percentVal != null) { if (Log.isLoggable(TAG, Log.VERBOSE)) { Log.v(TAG, "percent margin: " + percentVal.percent); } info = checkForInfoExists(info); info.leftMarginPercent = getPercentVal(sizeStr, true); info.topMarginPercent = getPercentVal(sizeStr, false); info.rightMarginPercent = getPercentVal(sizeStr, true); info.bottomMarginPercent = getPercentVal(sizeStr, false); } //value = array.getFraction(R.styleable.PercentLayout_Layout_layout_marginLeftPercent, 1, 1, // -1f); sizeStr = array.getString(R.styleable.PercentLayout_Layout_layout_marginLeftPercent); percentVal = getPercentVal(sizeStr, true); if (percentVal != null) { if (Log.isLoggable(TAG, Log.VERBOSE)) { Log.v(TAG, "percent left margin: " + percentVal.percent); } info = checkForInfoExists(info); info.leftMarginPercent = percentVal; } // value = array.getFraction(R.styleable.PercentLayout_Layout_layout_marginTopPercent, 1, 1, // -1f); sizeStr = array.getString(R.styleable.PercentLayout_Layout_layout_marginTopPercent); percentVal = getPercentVal(sizeStr, false); if (percentVal != null) { if (Log.isLoggable(TAG, Log.VERBOSE)) { Log.v(TAG, "percent top margin: " + percentVal.percent); } info = checkForInfoExists(info); info.topMarginPercent = percentVal; } // value = array.getFraction(R.styleable.PercentLayout_Layout_layout_marginRightPercent, 1, 1, // -1f); sizeStr = array.getString(R.styleable.PercentLayout_Layout_layout_marginRightPercent); percentVal = getPercentVal(sizeStr, true); if (percentVal != null) { if (Log.isLoggable(TAG, Log.VERBOSE)) { Log.v(TAG, "percent right margin: " + percentVal.percent); } info = checkForInfoExists(info); info.rightMarginPercent = percentVal; } //value = array.getFraction(R.styleable.PercentLayout_Layout_layout_marginBottomPercent, 1, 1, // -1f); sizeStr = array.getString(R.styleable.PercentLayout_Layout_layout_marginBottomPercent); percentVal = getPercentVal(sizeStr, false); if (percentVal != null) { if (Log.isLoggable(TAG, Log.VERBOSE)) { Log.v(TAG, "percent bottom margin: " + percentVal.percent); } info = checkForInfoExists(info); info.bottomMarginPercent = percentVal; } // value = array.getFraction(R.styleable.PercentLayout_Layout_layout_marginStartPercent, 1, 1, // -1f); sizeStr = array.getString(R.styleable.PercentLayout_Layout_layout_marginStartPercent); percentVal = getPercentVal(sizeStr, true); if (percentVal != null) { if (Log.isLoggable(TAG, Log.VERBOSE)) { Log.v(TAG, "percent start margin: " + percentVal.percent); } info = checkForInfoExists(info); info.startMarginPercent = percentVal; } //value = array.getFraction(R.styleable.PercentLayout_Layout_layout_marginEndPercent, 1, 1, // -1f); sizeStr = array.getString(R.styleable.PercentLayout_Layout_layout_marginEndPercent); percentVal = getPercentVal(sizeStr, true); if (percentVal != null) { if (Log.isLoggable(TAG, Log.VERBOSE)) { Log.v(TAG, "percent end margin: " + percentVal.percent); } info = checkForInfoExists(info); info.endMarginPercent = percentVal; } //textSizePercent sizeStr = array.getString(R.styleable.PercentLayout_Layout_layout_textSizePercent); percentVal = getPercentVal(sizeStr, false); if (percentVal != null) { if (Log.isLoggable(TAG, Log.VERBOSE)) { Log.v(TAG, "percent text size: " + percentVal.percent); } info = checkForInfoExists(info); info.textSizePercent = percentVal; } //maxWidth percentVal = getPercentVal(array, R.styleable.PercentLayout_Layout_layout_maxWidthPercent, true); if (percentVal != null) { checkForInfoExists(info); info.maxWidthPercent = percentVal; } //maxHeight percentVal = getPercentVal(array, R.styleable.PercentLayout_Layout_layout_maxHeightPercent, false); if (percentVal != null) { checkForInfoExists(info); info.maxHeightPercent = percentVal; } //minWidth percentVal = getPercentVal(array, R.styleable.PercentLayout_Layout_layout_minWidthPercent, true); if (percentVal != null) { checkForInfoExists(info); info.minWidthPercent = percentVal; } //minHeight percentVal = getPercentVal(array, R.styleable.PercentLayout_Layout_layout_minHeightPercent, false); LogUtil.d(TAG, "minHeight = " + percentVal); if (percentVal != null) { checkForInfoExists(info); info.minHeightPercent = percentVal; } array.recycle(); if (Log.isLoggable(TAG, Log.DEBUG)) { LogUtil.d(TAG, "constructed: " + info); } return info; }
From source file:org.andstatus.app.util.MyLog.java
/** * /*from w w w . ja va 2s . c om*/ * @param tag If tag is empty then {@link #APPTAG} is used * @param level {@link android.util.Log#INFO} ... * @return */ public static boolean isLoggable(Object objTag, int level) { boolean is = false; checkInit(); if (level < VERBOSE) { is = false; } else if (level >= minLogLevel) { is = true; } else { String tag = objTagToString(objTag); if (TextUtils.isEmpty(tag)) { tag = APPTAG; } if (tag.length() > 23) { tag = tag.substring(0, 22); } is = Log.isLoggable(tag, level); } return is; }
From source file:com.hitomi.basic.view.percentlayout.PercentLayoutHelper.java
private static PercentLayoutInfo setMarginRelatedVal(TypedArray array, PercentLayoutInfo info) { //margin?// www . j av a 2 s . c o m PercentLayoutInfo.PercentVal percentVal = getPercentVal(array, R.styleable.PercentLayout_Layout_layout_marginPercent, true); if (percentVal != null) { if (Log.isLoggable(TAG, Log.VERBOSE)) { Log.v(TAG, "percent margin: " + percentVal.percent); } info = checkForInfoExists(info); info.leftMarginPercent = percentVal; info.topMarginPercent = percentVal; info.rightMarginPercent = percentVal; info.bottomMarginPercent = percentVal; } percentVal = getPercentVal(array, R.styleable.PercentLayout_Layout_layout_marginLeftPercent, true); if (percentVal != null) { if (Log.isLoggable(TAG, Log.VERBOSE)) { Log.v(TAG, "percent left margin: " + percentVal.percent); } info = checkForInfoExists(info); info.leftMarginPercent = percentVal; } percentVal = getPercentVal(array, R.styleable.PercentLayout_Layout_layout_marginTopPercent, false); if (percentVal != null) { if (Log.isLoggable(TAG, Log.VERBOSE)) { Log.v(TAG, "percent top margin: " + percentVal.percent); } info = checkForInfoExists(info); info.topMarginPercent = percentVal; } percentVal = getPercentVal(array, R.styleable.PercentLayout_Layout_layout_marginRightPercent, true); if (percentVal != null) { if (Log.isLoggable(TAG, Log.VERBOSE)) { Log.v(TAG, "percent right margin: " + percentVal.percent); } info = checkForInfoExists(info); info.rightMarginPercent = percentVal; } percentVal = getPercentVal(array, R.styleable.PercentLayout_Layout_layout_marginBottomPercent, false); if (percentVal != null) { if (Log.isLoggable(TAG, Log.VERBOSE)) { Log.v(TAG, "percent bottom margin: " + percentVal.percent); } info = checkForInfoExists(info); info.bottomMarginPercent = percentVal; } percentVal = getPercentVal(array, R.styleable.PercentLayout_Layout_layout_marginStartPercent, true); if (percentVal != null) { if (Log.isLoggable(TAG, Log.VERBOSE)) { Log.v(TAG, "percent start margin: " + percentVal.percent); } info = checkForInfoExists(info); info.startMarginPercent = percentVal; } percentVal = getPercentVal(array, R.styleable.PercentLayout_Layout_layout_marginEndPercent, true); if (percentVal != null) { if (Log.isLoggable(TAG, Log.VERBOSE)) { Log.v(TAG, "percent end margin: " + percentVal.percent); } info = checkForInfoExists(info); info.endMarginPercent = percentVal; } return info; }
From source file:com.example.percentlayout.view.PercentLayoutHelper.java
/** * Constructs a PercentLayoutInfo from attributes associated with a View. Call this method from * {@code LayoutParams(Context c, AttributeSet attrs)} constructor. *//*w w w .java 2s.c o m*/ public static PercentLayoutInfo getPercentLayoutInfo(Context context, AttributeSet attrs) { PercentLayoutInfo info = null; TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.PercentLayout_Layout); int index = R.styleable.PercentLayout_Layout_layout_widthPercent; String sizeStr = array.getString(index); PercentLayoutInfo.PercentVal percentVal = getPercentVal(sizeStr, true); if (percentVal != null) { if (Log.isLoggable(TAG, Log.VERBOSE)) { Log.v(TAG, "percent width: " + percentVal.percent); } info = checkForInfoExists(info); info.widthPercent = percentVal; } sizeStr = array.getString(R.styleable.PercentLayout_Layout_layout_heightPercent); percentVal = getPercentVal(sizeStr, false); if (sizeStr != null) { if (Log.isLoggable(TAG, Log.VERBOSE)) { Log.v(TAG, "percent height: " + percentVal.percent); } info = checkForInfoExists(info); info.heightPercent = percentVal; } // value = array.getFraction(R.styleable.PercentLayout_Layout_layout_marginPercent, 1, 1, -1f); sizeStr = array.getString(R.styleable.PercentLayout_Layout_layout_marginPercent); // just for judge percentVal = getPercentVal(sizeStr, false); if (percentVal != null) { if (Log.isLoggable(TAG, Log.VERBOSE)) { Log.v(TAG, "percent margin: " + percentVal.percent); } info = checkForInfoExists(info); info.leftMarginPercent = getPercentVal(sizeStr, true); info.topMarginPercent = getPercentVal(sizeStr, false); info.rightMarginPercent = getPercentVal(sizeStr, true); info.bottomMarginPercent = getPercentVal(sizeStr, false); } //value = array.getFraction(R.styleable.PercentLayout_Layout_layout_marginLeftPercent, 1, 1, // -1f); sizeStr = array.getString(R.styleable.PercentLayout_Layout_layout_marginLeftPercent); percentVal = getPercentVal(sizeStr, true); if (percentVal != null) { if (Log.isLoggable(TAG, Log.VERBOSE)) { Log.v(TAG, "percent left margin: " + percentVal.percent); } info = checkForInfoExists(info); info.leftMarginPercent = percentVal; } // value = array.getFraction(R.styleable.PercentLayout_Layout_layout_marginTopPercent, 1, 1, // -1f); sizeStr = array.getString(R.styleable.PercentLayout_Layout_layout_marginTopPercent); percentVal = getPercentVal(sizeStr, false); if (percentVal != null) { if (Log.isLoggable(TAG, Log.VERBOSE)) { Log.v(TAG, "percent top margin: " + percentVal.percent); } info = checkForInfoExists(info); info.topMarginPercent = percentVal; } // value = array.getFraction(R.styleable.PercentLayout_Layout_layout_marginRightPercent, 1, 1, // -1f); sizeStr = array.getString(R.styleable.PercentLayout_Layout_layout_marginRightPercent); percentVal = getPercentVal(sizeStr, true); if (percentVal != null) { if (Log.isLoggable(TAG, Log.VERBOSE)) { Log.v(TAG, "percent right margin: " + percentVal.percent); } info = checkForInfoExists(info); info.rightMarginPercent = percentVal; } //value = array.getFraction(R.styleable.PercentLayout_Layout_layout_marginBottomPercent, 1, 1, // -1f); sizeStr = array.getString(R.styleable.PercentLayout_Layout_layout_marginBottomPercent); percentVal = getPercentVal(sizeStr, false); if (percentVal != null) { if (Log.isLoggable(TAG, Log.VERBOSE)) { Log.v(TAG, "percent bottom margin: " + percentVal.percent); } info = checkForInfoExists(info); info.bottomMarginPercent = percentVal; } // value = array.getFraction(R.styleable.PercentLayout_Layout_layout_marginStartPercent, 1, 1, // -1f); sizeStr = array.getString(R.styleable.PercentLayout_Layout_layout_marginStartPercent); percentVal = getPercentVal(sizeStr, true); if (percentVal != null) { if (Log.isLoggable(TAG, Log.VERBOSE)) { Log.v(TAG, "percent start margin: " + percentVal.percent); } info = checkForInfoExists(info); info.startMarginPercent = percentVal; } //value = array.getFraction(R.styleable.PercentLayout_Layout_layout_marginEndPercent, 1, 1, // -1f); sizeStr = array.getString(R.styleable.PercentLayout_Layout_layout_marginEndPercent); percentVal = getPercentVal(sizeStr, true); if (percentVal != null) { if (Log.isLoggable(TAG, Log.VERBOSE)) { Log.v(TAG, "percent end margin: " + percentVal.percent); } info = checkForInfoExists(info); info.endMarginPercent = percentVal; } //textSizePercent sizeStr = array.getString(R.styleable.PercentLayout_Layout_layout_textSizePercent); percentVal = getPercentVal(sizeStr, false); if (percentVal != null) { if (Log.isLoggable(TAG, Log.VERBOSE)) { Log.v(TAG, "percent text size: " + percentVal.percent); } info = checkForInfoExists(info); info.textSizePercent = percentVal; } //maxWidth percentVal = getPercentVal(array, R.styleable.PercentLayout_Layout_layout_maxWidthPercent, true); if (percentVal != null) { checkForInfoExists(info); info.maxWidthPercent = percentVal; } //maxHeight percentVal = getPercentVal(array, R.styleable.PercentLayout_Layout_layout_maxHeightPercent, false); if (percentVal != null) { checkForInfoExists(info); info.maxHeightPercent = percentVal; } //minWidth percentVal = getPercentVal(array, R.styleable.PercentLayout_Layout_layout_minWidthPercent, true); if (percentVal != null) { checkForInfoExists(info); info.minWidthPercent = percentVal; } //minHeight percentVal = getPercentVal(array, R.styleable.PercentLayout_Layout_layout_minHeightPercent, false); Log.d(TAG, "minHeight = " + percentVal); if (percentVal != null) { checkForInfoExists(info); info.minHeightPercent = percentVal; } array.recycle(); if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "constructed: " + info); } return info; }
From source file:carbon.internal.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)}. */// w ww . j a va 2 s.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.calendar.month.MonthByWeekFragment.java
private void stopLoader() { synchronized (mUpdateLoader) { mHandler.removeCallbacks(mUpdateLoader); if (mLoader != null) { mLoader.stopLoading();/*from w w w .ja va2s.co m*/ if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "Stopped loader from loading"); } } } }
From source file:com.magicmod.mmweather.engine.YahooWeatherProvider.java
private LocationResult parsePlace(JSONObject place) throws JSONException { LocationResult result = new LocationResult(); JSONObject country = place.getJSONObject("country"); result.id = place.getString("woeid"); result.country = country.getString("content"); result.countryId = country.getString("code"); if (!place.isNull("postal")) { result.postal = place.getJSONObject("postal").getString("content"); }/*from ww w. j a v a 2 s . c o m*/ for (String name : LOCALITY_NAMES) { if (!place.isNull(name)) { result.city = place.getJSONObject(name).getString("content"); break; } } if (Log.isLoggable(TAG, Log.VERBOSE)) { Log.v(TAG, "JSON data " + place.toString() + " -> id=" + result.id + ", city=" + result.city + ", country=" + result.countryId); } if (result.id == null || result.city == null || result.countryId == null) { return null; } return result; }
From source file:com.ty.highway.frameworklibrary.support.percent.PercentLayoutHelper.java
/** * Constructs a PercentLayoutInfo from attributes associated with a View. * Call this method from {@code LayoutParams(Context c, AttributeSet attrs)} * constructor.//from ww w . j a v a 2 s .c o m */ public static PercentLayoutInfo getPercentLayoutInfo(Context context, AttributeSet attrs) { PercentLayoutInfo info = null; TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.PercentLayout_Layout); int index = R.styleable.PercentLayout_Layout_layout_widthPercent; String sizeStr = array.getString(index); PercentLayoutInfo.PercentVal percentVal = getPercentVal(sizeStr, true); if (percentVal != null) { if (Log.isLoggable(TAG, Log.VERBOSE)) { Log.v(TAG, "percent width: " + percentVal.percent); } info = checkForInfoExists(info); info.widthPercent = percentVal; } sizeStr = array.getString(R.styleable.PercentLayout_Layout_layout_heightPercent); percentVal = getPercentVal(sizeStr, false); if (sizeStr != null) { if (Log.isLoggable(TAG, Log.VERBOSE)) { Log.v(TAG, "percent height: " + percentVal.percent); } info = checkForInfoExists(info); info.heightPercent = percentVal; } // value = // array.getFraction(R.styleable.PercentLayout_Layout_layout_marginPercent, // 1, 1, -1f); sizeStr = array.getString(R.styleable.PercentLayout_Layout_layout_marginPercent); // just for judge percentVal = getPercentVal(sizeStr, false); if (percentVal != null) { if (Log.isLoggable(TAG, Log.VERBOSE)) { Log.v(TAG, "percent margin: " + percentVal.percent); } info = checkForInfoExists(info); info.leftMarginPercent = getPercentVal(sizeStr, true); info.topMarginPercent = getPercentVal(sizeStr, false); info.rightMarginPercent = getPercentVal(sizeStr, true); info.bottomMarginPercent = getPercentVal(sizeStr, false); } // value = // array.getFraction(R.styleable.PercentLayout_Layout_layout_marginLeftPercent, // 1, 1, // -1f); sizeStr = array.getString(R.styleable.PercentLayout_Layout_layout_marginLeftPercent); percentVal = getPercentVal(sizeStr, true); if (percentVal != null) { if (Log.isLoggable(TAG, Log.VERBOSE)) { Log.v(TAG, "percent left margin: " + percentVal.percent); } info = checkForInfoExists(info); info.leftMarginPercent = percentVal; } // value = // array.getFraction(R.styleable.PercentLayout_Layout_layout_marginTopPercent, // 1, 1, // -1f); sizeStr = array.getString(R.styleable.PercentLayout_Layout_layout_marginTopPercent); percentVal = getPercentVal(sizeStr, false); if (percentVal != null) { if (Log.isLoggable(TAG, Log.VERBOSE)) { Log.v(TAG, "percent top margin: " + percentVal.percent); } info = checkForInfoExists(info); info.topMarginPercent = percentVal; } // value = // array.getFraction(R.styleable.PercentLayout_Layout_layout_marginRightPercent, // 1, 1, // -1f); sizeStr = array.getString(R.styleable.PercentLayout_Layout_layout_marginRightPercent); percentVal = getPercentVal(sizeStr, true); if (percentVal != null) { if (Log.isLoggable(TAG, Log.VERBOSE)) { Log.v(TAG, "percent right margin: " + percentVal.percent); } info = checkForInfoExists(info); info.rightMarginPercent = percentVal; } // value = // array.getFraction(R.styleable.PercentLayout_Layout_layout_marginBottomPercent, // 1, 1, // -1f); sizeStr = array.getString(R.styleable.PercentLayout_Layout_layout_marginBottomPercent); percentVal = getPercentVal(sizeStr, false); if (percentVal != null) { if (Log.isLoggable(TAG, Log.VERBOSE)) { Log.v(TAG, "percent bottom margin: " + percentVal.percent); } info = checkForInfoExists(info); info.bottomMarginPercent = percentVal; } // value = // array.getFraction(R.styleable.PercentLayout_Layout_layout_marginStartPercent, // 1, 1, // -1f); sizeStr = array.getString(R.styleable.PercentLayout_Layout_layout_marginStartPercent); percentVal = getPercentVal(sizeStr, true); if (percentVal != null) { if (Log.isLoggable(TAG, Log.VERBOSE)) { Log.v(TAG, "percent start margin: " + percentVal.percent); } info = checkForInfoExists(info); info.startMarginPercent = percentVal; } // value = // array.getFraction(R.styleable.PercentLayout_Layout_layout_marginEndPercent, // 1, 1, // -1f); sizeStr = array.getString(R.styleable.PercentLayout_Layout_layout_marginEndPercent); percentVal = getPercentVal(sizeStr, true); if (percentVal != null) { if (Log.isLoggable(TAG, Log.VERBOSE)) { Log.v(TAG, "percent end margin: " + percentVal.percent); } info = checkForInfoExists(info); info.endMarginPercent = percentVal; } // textSizePercent sizeStr = array.getString(R.styleable.PercentLayout_Layout_layout_textSizePercent); percentVal = getPercentVal(sizeStr, false); if (percentVal != null) { if (Log.isLoggable(TAG, Log.VERBOSE)) { Log.v(TAG, "percent text size: " + percentVal.percent); } info = checkForInfoExists(info); info.textSizePercent = percentVal; } // maxWidth percentVal = getPercentVal(array, R.styleable.PercentLayout_Layout_layout_maxWidthPercent, true); if (percentVal != null) { checkForInfoExists(info); info.maxWidthPercent = percentVal; } // maxHeight percentVal = getPercentVal(array, R.styleable.PercentLayout_Layout_layout_maxHeightPercent, false); if (percentVal != null) { checkForInfoExists(info); info.maxHeightPercent = percentVal; } // minWidth percentVal = getPercentVal(array, R.styleable.PercentLayout_Layout_layout_minWidthPercent, true); if (percentVal != null) { checkForInfoExists(info); info.minWidthPercent = percentVal; } // minHeight percentVal = getPercentVal(array, R.styleable.PercentLayout_Layout_layout_minHeightPercent, false); Log.d(TAG, "minHeight = " + percentVal); if (percentVal != null) { checkForInfoExists(info); info.minHeightPercent = percentVal; } array.recycle(); if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "constructed: " + info); } return info; }
From source file:com.samsung.richnotification.RichNotification.java
/** * This function will send a new notification or will update the notification sent. * * @param data// w w w .java 2s . co m * The JSONArray with parameters required for sending the notification. * @param callbackContext * The callback id used when calling back into JavaScript. * @return true if the notification is sent or false if the notification is not sent. * */ private boolean sendRichNotification(JSONArray data, CallbackContext callbackContext) throws JSONException { RichNotificationOptions options = null; SrnPrimaryTemplate primaryTemplate = null; SrnSecondaryTemplate secondaryTemplate = null; // This function takes care of error callbacks if (!initRichNotification(callbackContext)) { Log.e(TAG, "Initialization failed."); return false; } if (Log.isLoggable(RICHNOTI, Log.DEBUG)) Log.d(TAG, "Creating the notification."); // Fetch options from the data object options = new RichNotificationOptions(data); options.printLogs(); SrnRichNotification noti = null; UUID uuid = null; try { uuid = UUID.fromString(options.uuid); } catch (IllegalArgumentException invalidUUID) { Log.e(TAG, "Invalid UUID supplied. Creating a new notification."); options.uuid = null; } if (options.uuid == null) noti = new SrnRichNotification(mContext); else noti = new SrnRichNotification(mContext, uuid); // Set notification icon if (!options.notificationIcon.isEmpty()) { Bitmap notiIconBit = RichNotificationHelper.getIconBitmap(mContext, "file://" + options.notificationIcon); SrnImageAsset notiIconAsst = new SrnImageAsset(mContext, "notiIcon", notiIconBit); noti.setIcon(notiIconAsst); } noti.setAlertType(options.alertType, options.popupType); noti.setReadout(options.readoutTitle, options.readout); noti.setTitle(options.notificationTitle); primaryTemplate = RichNotificationHelper.createPrimaryTemplate(mContext, options); secondaryTemplate = RichNotificationHelper.createSecondaryTemplate(mContext, options); noti.setPrimaryTemplate(primaryTemplate); if (secondaryTemplate != null) noti.setSecondaryTemplate(secondaryTemplate); // Action related List<SrnAction> actionList = RichNotificationHelper.createActions(mContext, callbackContext, options); if (actionList != null) { noti.addActions(actionList); } else { if (Log.isLoggable(RICHNOTI, Log.DEBUG)) Log.d(TAG, "Actions not defined"); } try { options.uuid = mRichNotificationManager.notify(noti).toString(); JSONObject successMsg = new JSONObject(); successMsg.put("returnType", RichNotificationHelper.RETURN_TYPE_NOTIFICATION_SENT); successMsg.put("returnValue", options.uuid); if (Log.isLoggable(RICHNOTI, Log.DEBUG)) Log.d(TAG, "Notification sent. UUID: " + options.uuid); PluginResult sentResult = new PluginResult(PluginResult.Status.OK, successMsg); sentResult.setKeepCallback(true); callbackContext.sendPluginResult(sentResult); return true; } catch (SecurityException secEx) { Log.e(TAG, "Permission denied"); callbackContext.error(RichNotificationHelper.PERMISSION_DENIED); return false; } }
From source file:info.guardianproject.otr.app.im.app.AddContactActivity.java
void inviteBuddies() { Rfc822Token[] recipients = Rfc822Tokenizer.tokenize(mAddressList.getText()); try {// w ww . j a v a2s. c o m IImConnection conn = mApp.getConnection(mProviderId); IContactList list = getContactList(conn); if (list == null) { // Log.e(ImApp.LOG_TAG, "<AddContactActivity> can't find given contact list:" // + getSelectedListName()); finish(); } else { boolean fail = false; String username = null; for (Rfc822Token recipient : recipients) { username = recipient.getAddress(); if (username.indexOf('@') == -1) { username = username + "@" + getDomain(mProviderId); } if (Log.isLoggable(ImApp.LOG_TAG, Log.DEBUG)) { log("addContact:" + username); } int res = list.addContact(username); if (res != ImErrorInfo.NO_ERROR) { fail = true; mHandler.showAlert(R.string.error, ErrorResUtils.getErrorRes(getResources(), res, username)); } } // close the screen if there's no error. if (!fail) { if (username != null) { Intent intent = new Intent(); intent.putExtra(ContactsPickerActivity.EXTRA_RESULT_USERNAME, username); intent.putExtra(ContactsPickerActivity.EXTRA_RESULT_PROVIDER, mProviderId); setResult(RESULT_OK, intent); finish(); } } } } catch (RemoteException ex) { Log.e(ImApp.LOG_TAG, "<AddContactActivity> inviteBuddies: caught " + ex); } }