List of usage examples for android.util Log isLoggable
public static native boolean isLoggable(String tag, int level);
From source file:com.samsung.spen.SpenPlugin.java
private void initContextDetails(CallbackContext callbackContext) { if (Log.isLoggable(Utils.SPEN, Log.DEBUG)) { Log.d(TAG, "Inside initContextDetails"); }/* w ww .j a v a 2 s. c o m*/ if (mActivity == null) { mActivity = this.cordova.getActivity(); } if (mContextParams == null) { mContextParams = new SpenContextParams(); mContextParams.setSpenCustomDrawPlugin(this); } mContextParams.setCallbackContext(callbackContext); }
From source file:com.cerema.cloud2.lib.common.SingleSessionManager.java
@Override public void saveAllClients(Context context, String accountType) throws AccountNotFoundException, AuthenticatorException, IOException, OperationCanceledException { if (Log.isLoggable(TAG, Log.DEBUG)) { Log_OC.d(TAG, "Saving sessions... "); }//from ww w.j a va 2 s.c om Iterator<String> accountNames = mClientsWithKnownUsername.keySet().iterator(); String accountName = null; Account account = null; while (accountNames.hasNext()) { accountName = accountNames.next(); account = new Account(accountName, accountType); AccountUtils.saveClient(mClientsWithKnownUsername.get(accountName), account, context); } if (Log.isLoggable(TAG, Log.DEBUG)) { Log_OC.d(TAG, "All sessions saved"); } }
From source file:org.rti.rcd.ict.lgug.C2DMReceiver.java
protected void onReceive(Context context, Intent intent) { String accountName = intent.getExtras().getString(Config.C2DM_ACCOUNT_EXTRA); String message = intent.getExtras().getString(Config.C2DM_MESSAGE_EXTRA); if (Config.C2DM_MESSAGE_SYNC.equals(message)) { if (accountName != null) { if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "Messaging request received for account " + accountName); }// w w w. j a v a 2 s .c om // ContentResolver.requestSync( // new Account(accountName, SyncAdapter.GOOGLE_ACCOUNT_TYPE), // JumpNoteContract.AUTHORITY, new Bundle()); } } }
From source file:com.example.android.wearable.agendadata.MainActivity.java
public void onDeleteEventsClicked(View view) { if (mGoogleApiClient.isConnected()) { Wearable.DataApi.getDataItems(mGoogleApiClient).setResultCallback(new ResultCallback<DataItemBuffer>() { @Override//from w ww . java 2 s . co m public void onResult(DataItemBuffer result) { try { if (result.getStatus().isSuccess()) { deleteDataItems(result); } else { if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "onDeleteEventsClicked(): failed to get Data " + "Items"); } } } finally { result.release(); } } }); } else { Log.e(TAG, "Failed to delete data items" + " - Client disconnected from Google Play Services"); } }
From source file:com.redinput.datetimepickercompat.date.DayPickerView.java
/** * This moves to the specified time in the view. If the time is not already * in range it will move the list so that the first of the month containing * the time is at the top of the view. If the new time is already in view * the list will not be scrolled unless forceScroll is true. This time may * optionally be highlighted as selected as well. * /*from w ww . jav a2 s. c o m*/ * @param time * The time to move to * @param animate * Whether to scroll to the given time or just redraw at the * new location * @param setSelected * Whether to set the given time as selected * @param forceScroll * Whether to recenter even if the time is already * visible * @return Whether or not the view animated to the new location */ @SuppressLint("NewApi") public boolean goTo(CalendarDay day, boolean animate, boolean setSelected, boolean forceScroll) { // Set the selected day if (setSelected) { mSelectedDay.set(day); } mTempDay.set(day); final int position = (day.year - mController.getMinYear()) * SimpleMonthAdapter.MONTHS_IN_YEAR + day.month; View child; int i = 0; int top = 0; // Find a child that's completely in the view do { child = getChildAt(i++); if (child == null) { break; } top = child.getTop(); if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "child at " + (i - 1) + " has top " + top); } } while (top < 0); // Compute the first and last position visible int selectedPosition; if (child != null) { selectedPosition = getPositionForView(child); } else { selectedPosition = 0; } if (setSelected) { mAdapter.setSelectedDay(mSelectedDay); } if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "GoTo position " + position); } // Check if the selected day is now outside of our visible range // and if so scroll to the month that contains it if (position != selectedPosition || forceScroll) { setMonthDisplayed(mTempDay); mPreviousScrollState = OnScrollListener.SCROLL_STATE_FLING; if (animate) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { smoothScrollToPositionFromTop(position, LIST_TOP_OFFSET, GOTO_SCROLL_DURATION); } else { postSetSelection(position); } return true; } else { postSetSelection(position); } } else if (setSelected) { setMonthDisplayed(mSelectedDay); } return false; }
From source file:com.hemou.android.account.AccountUtils.java
/** * Get account used for authentication//from w w w . j ava2s .c om * * @param manager * @param act * @return account * @throws IOException * @throws AccountsException */ public static Account getAccount(final AccountManager manager, final Activity act) throws IOException, AccountsException { final String SUB_TAG = "acnt_get"; final boolean loggable = Log.isLoggable(SUB_TAG, DEBUG); if (loggable) Log.d(SUB_TAG, "Getting account"); if (act == null) throw new IllegalArgumentException("Activity cannot be null"); if (act.isFinishing()) { Log.v(SUB_TAG, act.getClass().getName() + "--->?finish()OperationCanceledException..."); throw new OperationCanceledException(); } Account[] accounts; try { if (!hasAuthenticator(manager)) { Log.e(SUB_TAG, "Current user is not under the authenticated environment...."); throw new AuthenticatorConflictException(); } while ((accounts = getAccounts(manager)).length == 0) { Bundle result = manager.addAccount(ACCOUNT_TYPE, AUTHTOKEN_TYPE, null, null, act, null, null) .getResult(); } } catch (OperationCanceledException e) { Log.d(SUB_TAG, "Excepting retrieving account", e); act.finish(); throw e; } catch (AccountsException e) { Log.d(SUB_TAG, "Excepting retrieving account", e); throw e; } catch (AuthenticatorConflictException e) { act.runOnUiThread(new Runnable() { public void run() { showConflictMessage(act); } }); throw e; } catch (IOException e) { Log.d(SUB_TAG, "Excepting retrieving account", e); throw e; } // if (loggable) Log.d(SUB_TAG, "Returning account " + accounts[0].name); return accounts[0]; }
From source file:com.example.android.jumpingjack.MainActivity.java
/** * Starts a timer to clear the flag FLAG_KEEP_SCREEN_ON. *//*from w w w . ja v a 2 s . co m*/ private void renewTimer() { if (null != mTimer) { mTimer.cancel(); } mTimerTask = new TimerTask() { @Override public void run() { if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "Removing the FLAG_KEEP_SCREEN_ON flag to allow going to background"); } resetFlag(); } }; mTimer = new Timer(); mTimer.schedule(mTimerTask, SCREEN_ON_TIMEOUT_MS); }
From source file:com.ibm.commerce.worklight.android.search.SearchSuggestionsProvider.java
/** * Retrieves the search suggestion JSON array and constructs the search suggestions list * For example, the JSON array would follow a similar structure, using a search on the * term 'dress'://from w ww . j av a 2 s.co m * * {'terms': * [ * {'dress':'766'}, * {'dress empire':'62'}, * {'dress empire waist':'62'}, * {'dress layered':'57'}, * ... * ] * } * * @param string The query term input into the search dialog * @return The list of search term suggestions */ private List<String> getSearchTermSuggestions(String query) { final String METHOD_NAME = CLASS_NAME + ".getSearchTermSuggestions"; boolean loggingEnabled = Log.isLoggable(LOG_TAG, Log.DEBUG); if (loggingEnabled) { Log.d(METHOD_NAME, "ENTRY"); } List<String> suggestionList = null; if (query == null || query.equals("")) { return suggestionList; } WCHybridApplication wcHybridApp = WCHybridApplication.getInstance(); String requestUrl = wcHybridApp.getSearchSuggestionUrl(query).toString(); String suggestionJsonString = null; HttpParams httpParams = new BasicHttpParams(); HttpConnectionParams.setConnectionTimeout(httpParams, HTTP_TIME_OUT); HttpClient httpClient = new DefaultHttpClient(httpParams); try { suggestionJsonString = httpClient.execute(new HttpGet(requestUrl), new BasicResponseHandler()); } catch (ClientProtocolException e) { Log.d(METHOD_NAME, "Error getting search suggestion JSON: " + e.getLocalizedMessage()); } catch (IOException e) { Log.d(METHOD_NAME, "Error getting search suggestion JSON: " + e.getLocalizedMessage()); } finally { httpClient.getConnectionManager().shutdown(); } if (suggestionJsonString != null && !suggestionJsonString.equals("")) { try { if (loggingEnabled) { Log.d(METHOD_NAME, "Suggestion JSON string: " + suggestionJsonString); } JSONObject json = new JSONObject(suggestionJsonString); JSONArray suggestions = json.getJSONArray("terms"); if (suggestions != null) { suggestionList = new ArrayList<String>(suggestions.length()); for (int i = 0; i < suggestions.length(); i++) { suggestionList.add(suggestions.getJSONObject(i).names().getString(0)); } } } catch (JSONException e) { Log.d(METHOD_NAME, "Error parsing search suggestion JSON: " + e.getLocalizedMessage()); } } if (loggingEnabled) { Log.d(METHOD_NAME, "EXIT"); } return suggestionList; }
From source file:com.samsung.spen.SpenPlugin.java
@Override public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException { if (Log.isLoggable(Utils.SPEN, Log.DEBUG)) { Log.d(TAG, "Inside execute"); }/* w w w . j av a 2 s .c o m*/ // sometimes, init is not called from initialize init(); // Do not allow apis if metadata is missing if (!pluginMetadata) { callbackContext.error("METADATA_MISSING"); Log.e(TAG, "Metadata is missing"); return false; } initContextDetails(callbackContext); final CallbackContext finalCallbackContext = callbackContext; mSpenState = isSpenFeatureEnabled(mActivity.getApplicationContext(), callbackContext); if (action.equals("isSupported")) { if (Log.isLoggable(Utils.SPEN, Log.DEBUG)) { Log.d(TAG, "Inside isSpenSupported"); } if (mSpenState == SPEN_AND_HAND_SUPPORTED) { callbackContext.success(SpenExceptionType.SPEN_AND_HAND_SUPPORTED.toString()); return true; } else if (mSpenState == ONLY_HAND_SUPPORTED) { callbackContext.success(SpenExceptionType.ONLY_HAND_SUPPORTED.toString()); // handled this in isSpenFeatureEnabled itself as it common // for many cases. } } else if (action.equals("launchSurfaceInline")) { if (Log.isLoggable(Utils.SPEN, Log.DEBUG)) { Log.d(TAG, "creating the spen surface inline"); } SpenTrayBarOptions options = createTrayBarOptions(args, Utils.SURFACE_INLINE, callbackContext); final SpenTrayBarOptions inlineOptions = options; if (inlineOptions != null && mSpenState != SPEN_INITILIZATION_ERROR) { mActivity.runOnUiThread(new Runnable() { @Override public void run() { String id = inlineOptions.getId(); if (mSpenSurfaceViews.getSurfaceView(id) == null) { if (surfaceCount >= SpenSurfaceViews.MAX_SURFACE_COUNT) { SpenException.sendPluginResult(SpenExceptionType.MAX_SURFACE_LIMIT_REACHED, finalCallbackContext); } else { SPenSurfaceWithTrayBar mPaintViewTrayBar = null; mPaintViewTrayBar = new SPenSurfaceWithTrayBar(mContextParams, inlineOptions); mSpenSurfaceViews.addSurfaceView(id, mPaintViewTrayBar); surfaceCount++; if (!mSpenSurfaceViews.getSurfaceView(id).createSPenSurfaceWithTrayBar()) { mSpenSurfaceViews.removeSurfaceView(id); surfaceCount--; SpenException.sendPluginResult(SpenExceptionType.FAILED_CREATE_SURFACE, finalCallbackContext); } else { // finalCallbackContext.success(); PluginResult pluginResult = new PluginResult(PluginResult.Status.OK, ""); pluginResult.setKeepCallback(true); finalCallbackContext.sendPluginResult(pluginResult); } } } else { SpenException.sendPluginResult(SpenExceptionType.SURFACE_ID_ALREADY_EXISTS, finalCallbackContext); } } }); } } else if (action.equals("launchSurfacePopup")) { if (Log.isLoggable(Utils.SPEN, Log.DEBUG)) { Log.d(TAG, "creating the spen surface popup"); } SpenTrayBarOptions options = createTrayBarOptions(args, Utils.SURFACE_POPUP, callbackContext); if (options != null && mSpenState != SPEN_INITILIZATION_ERROR) { String id = options.getId(); if (mSpenSurfaceViewsPopup.getSurfaceView(id) == null) { if (surfaceCount >= SpenSurfaceViews.MAX_SURFACE_COUNT) { SpenException.sendPluginResult(SpenExceptionType.MAX_SURFACE_LIMIT_REACHED, finalCallbackContext); } else { SPenSurfaceWithTrayBar mPaintViewTrayBar = null; mPaintViewTrayBar = new SPenSurfaceWithTrayBar(mContextParams, options); mSpenSurfaceViewsPopup.addSurfaceView(id, mPaintViewTrayBar); surfaceCount++; if (!mSpenSurfaceViewsPopup.getSurfaceView(id).createSPenSurfaceWithTrayBar()) { mSpenSurfaceViewsPopup.removeSurfaceView(id); surfaceCount--; SpenException.sendPluginResult(SpenExceptionType.FAILED_CREATE_SURFACE, finalCallbackContext); } else { PluginResult pluginResult = new PluginResult(PluginResult.Status.OK, ""); pluginResult.setKeepCallback(true); finalCallbackContext.sendPluginResult(pluginResult); } } } else { mSpenSurfaceViewsPopup.getSurfaceView(id).changeSPenTrayBarOptions(options, mContextParams); mSpenSurfaceViewsPopup.getSurfaceView(id).openSPenSurfaceWithTrayBar(); } } } else if (action.equals("removeSurfaceInline")) { if (Log.isLoggable(Utils.SPEN, Log.DEBUG)) { Log.d(TAG, "removing SpenSurface Inline"); } String tempId = args.getString(ID); if (tempId != null) { tempId = tempId.trim(); if (tempId.length() > MAX_ID_LENGTH) { tempId = tempId.substring(0, MAX_ID_LENGTH); } } final String id = tempId; if (id == null || id.equals("") || id.equals("null")) { SpenException.sendPluginResult(SpenExceptionType.INVALID_SURFACE_ID, callbackContext); return false; } if (mSpenState != SPEN_INITILIZATION_ERROR) { mActivity.runOnUiThread(new Runnable() { @Override public void run() { if (mSpenSurfaceViews.getSurfaceView(id) != null) { surfaceCount--; mSpenSurfaceViews.getSurfaceView(id).removeSurface(); mSpenSurfaceViews.removeSurfaceView(id); finalCallbackContext.success(id); } else { SpenException.sendPluginResult(SpenExceptionType.SURFACE_ID_NOT_EXISTS, finalCallbackContext); } } }); } } else if (action.equals("removeSurfacePopup")) { if (Log.isLoggable(Utils.SPEN, Log.DEBUG)) { Log.d(TAG, "removing SpenSurface Popup"); } String tempId = args.getString(ID); if (tempId != null) { tempId = tempId.trim(); if (tempId.length() > MAX_ID_LENGTH) { tempId = tempId.substring(0, MAX_ID_LENGTH); } } final String id = tempId; if (id == null || id.equals("") || id.equals("null")) { SpenException.sendPluginResult(SpenExceptionType.INVALID_SURFACE_ID, callbackContext); return false; } if (mSpenSurfaceViewsPopup.getSurfaceView(id) != null) { surfaceCount--; mSpenSurfaceViewsPopup.getSurfaceView(id).removeSurface(); mSpenSurfaceViewsPopup.removeSurfaceView(id); finalCallbackContext.success(id); } else { SpenException.sendPluginResult(SpenExceptionType.SURFACE_ID_NOT_EXISTS, finalCallbackContext); } } else { callbackContext.error(SpenExceptionType.ACTION_INVALID.toString()); return false; } return true; }
From source file:com.joptimizer.optimizers.BasicPhaseIPDM.java
public DoubleMatrix1D findFeasibleInitialPoint() throws Exception { Log.d(MainActivity.JOPTIMIZER_LOGTAG, "findFeasibleInitialPoint"); OptimizationRequest or = new OptimizationRequest(); //objective function: s DoubleMatrix1D C = F1.make(dim);//from ww w . j av a 2s. co m C.set(dim - 1, 1.); LinearMultivariateRealFunction objectiveFunction = new LinearMultivariateRealFunction(C.toArray(), 0); or.setF0(objectiveFunction); or.setToleranceFeas(originalProblem.getToleranceFeas()); or.setTolerance(originalProblem.getTolerance()); // Inquality constraints: fi(X)-s ConvexMultivariateRealFunction[] inequalities = new ConvexMultivariateRealFunction[originalProblem .getFi().length]; for (int i = 0; i < inequalities.length; i++) { final ConvexMultivariateRealFunction originalFi = originalProblem.getFi()[i]; ConvexMultivariateRealFunction fi = new ConvexMultivariateRealFunction() { public double value(double[] Y) { DoubleMatrix1D y = DoubleFactory1D.dense.make(Y); DoubleMatrix1D X = y.viewPart(0, originalDim); return originalFi.value(X.toArray()) - y.get(dim - 1); } public double[] gradient(double[] Y) { DoubleMatrix1D y = DoubleFactory1D.dense.make(Y); DoubleMatrix1D X = y.viewPart(0, originalDim); DoubleMatrix1D origGrad = F1.make(originalFi.gradient(X.toArray())); DoubleMatrix1D ret = F1.make(1, -1); ret = F1.append(origGrad, ret); return ret.toArray(); } public double[][] hessian(double[] Y) { DoubleMatrix1D y = DoubleFactory1D.dense.make(Y); DoubleMatrix1D X = y.viewPart(0, originalDim); double[][] originalFiHess = originalFi.hessian(X.toArray()); if (originalFiHess == FunctionsUtils.ZEROES_2D_ARRAY_PLACEHOLDER) { return FunctionsUtils.ZEROES_2D_ARRAY_PLACEHOLDER; } else { DoubleMatrix2D origHess = (originalFiHess != FunctionsUtils.ZEROES_2D_ARRAY_PLACEHOLDER) ? F2.make(originalFi.hessian(X.toArray())) : F2.make(X.size(), X.size()); DoubleMatrix2D[][] parts = new DoubleMatrix2D[][] { { origHess, null }, { null, F2.make(1, 1) } }; return F2.compose(parts).toArray(); } } public int getDim() { return dim; } }; inequalities[i] = fi; } or.setFi(inequalities); // Equality constraints: add a final zeroes column DoubleMatrix2D AEorig = originalProblem.getA(); DoubleMatrix1D BEorig = originalProblem.getB(); if (AEorig != null) { DoubleMatrix2D zeroCols = F2.make(AEorig.rows(), 1); DoubleMatrix2D[][] parts = new DoubleMatrix2D[][] { { AEorig, zeroCols } }; DoubleMatrix2D AE = F2.compose(parts); DoubleMatrix1D BE = BEorig.copy(); or.setA(AE.toArray()); or.setB(BE.toArray()); } //initial point DoubleMatrix1D X0 = originalProblem.getNotFeasibleInitialPoint(); if (X0 == null) { if (AEorig != null) { X0 = findOneRoot(AEorig.toArray(), BEorig.toArray()); } else { X0 = F1.make(originalProblem.getDim(), 1. / originalProblem.getDim()); } } //check primal norm if (AEorig != null) { DoubleMatrix1D originalRPriX0 = AEorig.zMult(X0, BEorig.copy(), 1., -1., false); double norm = Math.sqrt(ALG.norm2(originalRPriX0)); Log.d(MainActivity.JOPTIMIZER_LOGTAG, "norm: " + norm); if (norm > originalProblem.getToleranceFeas()) { throw new Exception("The initial point for Basic Phase I Method must be equalities-feasible"); } } DoubleMatrix1D originalFiX0 = originalProblem.getFi(X0); //lucky strike? int maxIneqIndex = Utils.getMaxIndex(originalFiX0.toArray()); if (originalFiX0.get(maxIneqIndex) + originalProblem.getTolerance() < 0) { //the given notFeasible starting point is in fact already feasible return X0; } //DoubleMatrix1D initialPoint = F1.make(1, -Double.MAX_VALUE); DoubleMatrix1D initialPoint = F1.make(1, Math.sqrt(originalProblem.getToleranceFeas())); initialPoint = F1.append(X0, initialPoint); for (int i = 0; i < originalFiX0.size(); i++) { //initialPoint.set(dim-1, Math.max(initialPoint.get(dim-1), originalFiX0.get(i)+Math.sqrt(originalProblem.getToleranceFeas()))); initialPoint.set(dim - 1, Math.max(initialPoint.get(dim - 1), originalFiX0.get(i) * Math.pow(originalProblem.getToleranceFeas(), -0.5))); } or.setInitialPoint(initialPoint.toArray()); //optimization PrimalDualMethod opt = new PhaseIPrimalDualMethod(); opt.setOptimizationRequest(or); if (opt.optimize() == OptimizationResponse.FAILED) { throw new Exception("Failed to find an initial feasible point"); } OptimizationResponse response = opt.getOptimizationResponse(); DoubleMatrix1D sol = F1.make(response.getSolution()); DoubleMatrix1D ret = sol.viewPart(0, originalDim); DoubleMatrix1D ineq = originalProblem.getFi(ret); maxIneqIndex = Utils.getMaxIndex(ineq.toArray()); if (Log.isLoggable(MainActivity.JOPTIMIZER_LOGTAG, Log.DEBUG)) { Log.d(MainActivity.JOPTIMIZER_LOGTAG, "ineq : " + ArrayUtils.toString(ineq.toArray())); Log.d(MainActivity.JOPTIMIZER_LOGTAG, "max ineq pos: " + maxIneqIndex); Log.d(MainActivity.JOPTIMIZER_LOGTAG, "max ineq val: " + ineq.get(maxIneqIndex)); } //if(sol[dim-1]>0){ if (ineq.get(maxIneqIndex) >= 0) { throw new Exception("Infeasible problem"); } return ret; }