List of usage examples for android.util Log DEBUG
int DEBUG
To view the source code for android.util Log DEBUG.
Click Source Link
From source file:com.loopj.android.http.RdHttpClient.java
public String post(String url, RequestParams params) throws Exception { if (!Utils.checkNetworkAvailable(MyOwnMVCApp.app)) { throw new Exception(MyOwnMVCApp.app.getString(R.string.no_network)); }// w w w. j ava 2s . co m MyLog.log(Log.DEBUG, getClass(), "block post:" + url + " ps:" + params.toString()); HttpEntity entity = paramsToEntity(params); HttpEntityEnclosingRequestBase base = addEntityToRequestBase(new HttpPost(url), entity); RdHttpRequest request = new RdHttpRequest(httpClient, httpContext, base); String res = request.run(); MyLog.log(Log.DEBUG, getClass(), "block post:" + url + " ps:" + params.toString() + " res:" + res); return res; }
From source file:com.luorrak.ouroboros.catalog.CatalogFragment.java
private void getCatalogJson(final Context context, final String boardName) { String catalogJsonUrl = ChanUrls.getCatalogUrl(boardName); progressBar.setVisibility(View.VISIBLE); Ion.with(context).load(catalogJsonUrl).setLogging(LOG_TAG, Log.DEBUG).asJsonArray() .setCallback(new FutureCallback<JsonArray>() { @Override/* w ww . j a v a2 s . com*/ public void onCompleted(Exception e, JsonArray jsonArray) { if (e == null) { networkFragment.beginTask(jsonArray, infiniteDbHelper, boardName, catalogAdapter); } else { progressBar.setVisibility(View.INVISIBLE); swipeRefreshLayout.setRefreshing(false); if (getActivity() != null) { Snackbar.make(getView(), "Error retrieving catalog", Snackbar.LENGTH_LONG).show(); } } catalogAdapter.changeCursor(getSortedCursor()); } }); }
From source file:com.gosuncn.core.percentlayout.PercentLayoutHelper.java
/** * Constructs a PercentLayoutInfo from attributes associated with a View. * Call this method from {@code LayoutParams(Context c, AttributeSet attrs)} * constructor.//www . ja v a 2 s.co m */ public static PercentLayoutInfo getPercentLayoutInfo(Context context, AttributeSet attrs) { PercentLayoutInfo info = null; TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.PercentLayout_Layout); // float value = // array.getFraction(R.styleable.PercentLayout_Layout_layout_widthPercent, // 1, 1, // -1f); String sizeStr = array.getString(R.styleable.PercentLayout_Layout_layout_widthPercent); PercentLayoutInfo.PercentVal percentVal = getPercentVal(sizeStr, true); if (percentVal != null) { if (Log.isLoggable(TAG, Log.VERBOSE)) { Log.v(TAG, "percent width: " + percentVal.percent); } info = info != null ? info : new PercentLayoutInfo(); info.widthPercent = percentVal; } // value = // array.getFraction(R.styleable.PercentLayout_Layout_layout_heightPercent, // 1, 1, -1f); 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 = info != null ? info : new PercentLayoutInfo(); 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 = info != null ? info : new PercentLayoutInfo(); 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 = info != null ? info : new PercentLayoutInfo(); 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 = info != null ? info : new PercentLayoutInfo(); 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 = info != null ? info : new PercentLayoutInfo(); 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 = info != null ? info : new PercentLayoutInfo(); 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 = info != null ? info : new PercentLayoutInfo(); 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 = info != null ? info : new PercentLayoutInfo(); 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 = info != null ? info : new PercentLayoutInfo(); info.textSizePercent = percentVal; } array.recycle(); if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "constructed: " + info); } return info; }
From source file:com.android.contacts.activities.PeopleActivity.java
/** * Resolve the intent and initialize {@link #mRequest}, and launch another activity if redirect * is needed./* w w w. j a va 2s .c o m*/ * * @param forNewIntent set true if it's called from {@link #onNewIntent(Intent)}. * @return {@code true} if {@link PeopleActivity} should continue running. {@code false} * if it shouldn't, in which case the caller should finish() itself and shouldn't do * farther initialization. */ private boolean processIntent(boolean forNewIntent) { // Extract relevant information from the intent mRequest = mIntentResolver.resolveIntent(getIntent()); if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, this + " processIntent: forNewIntent=" + forNewIntent + " intent=" + getIntent() + " request=" + mRequest); } if (!mRequest.isValid()) { setResult(RESULT_CANCELED); return false; } if (mRequest.getActionCode() == ContactsRequest.ACTION_VIEW_CONTACT) { final Intent intent = ImplicitIntentsUtil.composeQuickContactIntent(mRequest.getContactUri(), QuickContactActivity.MODE_FULLY_EXPANDED); intent.putExtra(QuickContactActivity.EXTRA_PREVIOUS_SCREEN_TYPE, ScreenType.UNKNOWN); ImplicitIntentsUtil.startActivityInApp(this, intent); return false; } return true; }
From source file:com.loopj.android.http.RdHttpClient.java
public String post(String url, HttpEntity entity) throws Exception { MyLog.log(Log.DEBUG, getClass(), "block post:" + url + " ps:" + entity.toString()); if (!Utils.checkNetworkAvailable(MyOwnMVCApp.app)) { throw new Exception(MyOwnMVCApp.app.getString(R.string.no_network)); }//from w w w . j a v a 2 s . co m HttpEntityEnclosingRequestBase base = addEntityToRequestBase(new HttpPost(url), entity); RdHttpRequest request = new RdHttpRequest(httpClient, httpContext, base); String res = request.run(); MyLog.log(Log.DEBUG, getClass(), "block post:" + url + " ps:" + entity.toString() + " res:" + res); return res; }
From source file:net.vleu.par.android.rpc.Transceiver.java
/** * Invalidates the {@link GoogleAuthToken} stored in the * {@link AccountManager}// ww w .j a v a 2 s . co m */ private void invalidatesGoogleAuthToken(final GoogleAuthToken token) { if (token != null) { final AccountManager am = AccountManager.get(this.context); if (Log.isLoggable(TAG, Log.DEBUG)) Log.d(TAG, "Invalidating GoogleAuthToken : " + token.value); am.invalidateAuthToken(GOOGLE_ACCOUNT_TYPE, token.value); } }
From source file:com.kth.common.utils.etc.LogUtil.java
/** * DEBUG ? ? ?. */ public static boolean isDebugEnabled() { return Log.isLoggable(TAG, Log.DEBUG); }
From source file:com.philliphsu.bottomsheetpickers.date.PagingDayPickerView.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. * * @param day The time to move to//from ww w .j a va2s.c o m * @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 */ public boolean goTo(CalendarDay day, boolean animate, boolean setSelected, boolean forceScroll) { final int selectedPosition = getPosition(mSelectedDay); // Set the selected day if (setSelected) { mSelectedDay.set(day); } mTempDay.set(day); final int position = getPosition(day); 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) { setMonthAndYearDisplayed(mTempDay); if (animate) { mViewPager.setCurrentItem(position, true); if (setSelected) { setSelectedDay(mSelectedDay); } return true; } else { postSetSelection(position, setSelected); } } else if (setSelected) { setMonthAndYearDisplayed(mSelectedDay); setSelectedDay(mSelectedDay); } return false; }
From source file:com.irccloud.android.IRCCloudApplicationBase.java
public void onPause(final Activity context) { final ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); if (notifierSockerTimerTask != null) notifierSockerTimerTask.cancel(); notifierSockerTimerTask = new TimerTask() { @Override/*from w w w . j av a 2 s. c o m*/ public void run() { notifierSockerTimerTask = null; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { ActivityManager am = (ActivityManager) getSystemService(ACTIVITY_SERVICE); for (ActivityManager.RunningAppProcessInfo info : am.getRunningAppProcesses()) { if (info.processName.equals(context.getPackageName()) && info.importance == ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND) return; } } if (!conn.notifier && conn.getState() == NetworkConnection.STATE_CONNECTED) { conn.disconnect(); if (ServersList.getInstance().count() < 1) { Crashlytics.log(Log.DEBUG, "IRCCloud", "No servers configured, not connecting notifier socket"); return; } if (!(Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && cm.isActiveNetworkMetered() && cm .getRestrictBackgroundStatus() == ConnectivityManager.RESTRICT_BACKGROUND_STATUS_ENABLED)) { try { Thread.sleep(1000); conn.notifier = true; conn.connect(); } catch (Exception e) { } } } } }; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && cm.isActiveNetworkMetered() && cm.getRestrictBackgroundStatus() == ConnectivityManager.RESTRICT_BACKGROUND_STATUS_ENABLED) { notifierTimer.schedule(notifierSockerTimerTask, 5000); } else { notifierTimer.schedule(notifierSockerTimerTask, 300000); } }
From source file:com.dh.perfectoffer.event.framework.net.network.NetworkConnectionImpl.java
/** * Call the webservice using the given parameters to construct the request * and return the result.// ww w . jav a2s .c o m * * @param context * The context to use for this operation. Used to generate the * user agent if needed. * @param urlValue * The webservice URL. * @param method * The request method to use. * @param parameterList * The parameters to add to the request. * @param headerMap * The headers to add to the request. * @param isGzipEnabled * Whether the request will use gzip compression if available on * the server. * @param userAgent * The user agent to set in the request. If null, a default * Android one will be created. * @param postText * The POSTDATA text to add in the request. * @param credentials * The credentials to use for authentication. * @param isSslValidationEnabled * Whether the request will validate the SSL certificates. * @return The result of the webservice call. */ public static ConnectionResult execute(Context context, String urlValue, Method method, ArrayList<BasicNameValuePair> parameterList, HashMap<String, String> headerMap, boolean isGzipEnabled, String userAgent, String postText, UsernamePasswordCredentials credentials, boolean isSslValidationEnabled, String contentType, List<byte[]> fileByteDates, List<String> fileMimeTypes, int httpErrorResCodeFilte, boolean isMulFiles) throws ConnectionException { HttpURLConnection connection = null; try { // Prepare the request information if (userAgent == null) { userAgent = UserAgentUtils.get(context); } if (headerMap == null) { headerMap = new HashMap<String, String>(); } headerMap.put(HTTP.USER_AGENT, userAgent); if (isGzipEnabled) { headerMap.put(ACCEPT_ENCODING_HEADER, "gzip"); } headerMap.put(ACCEPT_CHARSET_HEADER, UTF8_CHARSET); if (credentials != null) { headerMap.put(AUTHORIZATION_HEADER, createAuthenticationHeader(credentials)); } StringBuilder paramBuilder = new StringBuilder(); if (parameterList != null && !parameterList.isEmpty()) { for (int i = 0, size = parameterList.size(); i < size; i++) { BasicNameValuePair parameter = parameterList.get(i); String name = parameter.getName(); String value = parameter.getValue(); if (TextUtils.isEmpty(name)) { // Empty parameter name. Check the next one. continue; } if (value == null) { value = ""; } paramBuilder.append(URLEncoder.encode(name, UTF8_CHARSET)); paramBuilder.append("="); paramBuilder.append(URLEncoder.encode(value, UTF8_CHARSET)); paramBuilder.append("&"); } } // ? ByteArrayOutputStream bos = new ByteArrayOutputStream(); // Create the connection object URL url = null; String outputText = null; switch (method) { case GET: case DELETE: String fullUrlValue = urlValue; if (paramBuilder.length() > 0) { fullUrlValue += "?" + paramBuilder.toString(); } url = new URL(fullUrlValue); connection = HttpUrlConnectionHelper.openUrlConnection(url); break; case PUT: case POST: url = new URL(urlValue); connection = HttpUrlConnectionHelper.openUrlConnection(url); connection.setDoOutput(true); if (paramBuilder.length() > 0 && NetworkConnection.CT_DEFALUT.equals(contentType)) { // form // ? // headerMap.put(HTTP.CONTENT_TYPE, // "application/x-www-form-urlencoded"); outputText = paramBuilder.toString(); headerMap.put(HTTP.CONTENT_TYPE, contentType); headerMap.put(HTTP.CONTENT_LEN, String.valueOf(outputText.getBytes().length)); } else if (postText != null && (NetworkConnection.CT_JSON.equals(contentType) || NetworkConnection.CT_XML.equals(contentType))) { // body // ? // headerMap.put(HTTP.CONTENT_TYPE, "application/json"); // //add ?json??? headerMap.put(HTTP.CONTENT_TYPE, contentType); // add // ?json??? headerMap.put(HTTP.CONTENT_LEN, String.valueOf(postText.getBytes().length)); outputText = postText; // Log.e("newtewewerew", // "1111application/json------------------outputText222222:::"+outputText+"-------method::"+method+"----paramBuilder.length() :"+paramBuilder.length()+"----postText:"+postText // ); } else if (NetworkConnection.CT_MULTIPART.equals(contentType)) { // String[] Array = urlValue.split("/"); /*Boolean isFiles = false; if (Array[Array.length - 1].equals("clientRemarkPic")) { isFiles = true; }*/ if (null == fileByteDates || fileByteDates.size() <= 0) { throw new ConnectionException("file formdata no bytes data", NetworkConnection.EXCEPTION_CODE_FORMDATA_NOBYTEDATE); } headerMap.put(HTTP.CONTENT_TYPE, contentType + ";boundary=" + BOUNDARY); String bulidFormText = bulidFormText(parameterList); bos.write(bulidFormText.getBytes()); for (int i = 0; i < fileByteDates.size(); i++) { long currentTimeMillis = System.currentTimeMillis(); StringBuffer sb = new StringBuffer(""); sb.append(PREFIX).append(BOUNDARY).append(LINEND); // sb.append("Content-Type:application/octet-stream" + // LINEND); // sb.append("Content-Disposition: form-data; name=\""+nextInt+"\"; filename=\""+nextInt+".png\"").append(LINEND);; if (isMulFiles) sb.append("Content-Disposition: form-data; name=\"files\";filename=\"pic" + currentTimeMillis + ".png\"").append(LINEND); else sb.append("Content-Disposition: form-data; name=\"file\";filename=\"pic" + currentTimeMillis + ".png\"").append(LINEND); // sb.append("Content-Type:image/png" + LINEND); sb.append("Content-Type:" + fileMimeTypes.get(i) + LINEND); // sb.append("Content-Type:image/png" + LINEND); sb.append(LINEND); bos.write(sb.toString().getBytes()); bos.write(fileByteDates.get(i)); bos.write(LINEND.getBytes()); } byte[] end_data = (PREFIX + BOUNDARY + PREFIX + LINEND).getBytes(); bos.write(end_data); bos.flush(); headerMap.put(HTTP.CONTENT_LEN, bos.size() + ""); } // L.e("newtewewerew", // "2222------------------outputText222222:::"+outputText+"-------method::"+method+"----paramBuilder.length() :"+paramBuilder.length()+"----postText:"+postText // ); break; } // Set the request method connection.setRequestMethod(method.toString()); // If it's an HTTPS request and the SSL Validation is disabled if (url.getProtocol().equals("https") && !isSslValidationEnabled) { HttpsURLConnection httpsConnection = (HttpsURLConnection) connection; httpsConnection.setSSLSocketFactory(getAllHostsValidSocketFactory()); httpsConnection.setHostnameVerifier(getAllHostsValidVerifier()); } // Add the headers if (!headerMap.isEmpty()) { for (Entry<String, String> header : headerMap.entrySet()) { connection.addRequestProperty(header.getKey(), header.getValue()); } } // Set the connection and read timeout connection.setConnectTimeout(OPERATION_TIMEOUT); connection.setReadTimeout(OPERATION_TIMEOUT); // Set the outputStream content for POST and PUT requests if ((method == Method.POST || method == Method.PUT)) { OutputStream output = null; try { if (NetworkConnection.CT_MULTIPART.equals(contentType)) { output = connection.getOutputStream(); output.write(bos.toByteArray()); } else { if (null != outputText) { L.e("newtewewerew", method + "------------------outputText:::" + outputText); output = connection.getOutputStream(); output.write(outputText.getBytes()); } } } finally { if (output != null) { try { output.close(); } catch (IOException e) { // Already catching the first IOException so nothing // to do here. } } } } // Log the request if (L.canLog(Log.DEBUG)) { L.d(TAG, "Request url: " + urlValue); L.d(TAG, "Method: " + method.toString()); if (parameterList != null && !parameterList.isEmpty()) { L.d(TAG, "Parameters:"); for (int i = 0, size = parameterList.size(); i < size; i++) { BasicNameValuePair parameter = parameterList.get(i); String message = "- \"" + parameter.getName() + "\" = \"" + parameter.getValue() + "\""; L.d(TAG, message); } L.d(TAG, "Parameters String: \"" + paramBuilder.toString() + "\""); } if (postText != null) { L.d(TAG, "Post data: " + postText); } if (headerMap != null && !headerMap.isEmpty()) { L.d(TAG, "Headers:"); for (Entry<String, String> header : headerMap.entrySet()) { L.d(TAG, "- " + header.getKey() + " = " + header.getValue()); } } } String contentEncoding = connection.getHeaderField(HTTP.CONTENT_ENCODING); int responseCode = connection.getResponseCode(); boolean isGzip = contentEncoding != null && contentEncoding.equalsIgnoreCase("gzip"); L.d(TAG, "Response code: " + responseCode); if (responseCode == HttpStatus.SC_MOVED_PERMANENTLY) { String redirectionUrl = connection.getHeaderField(LOCATION_HEADER); throw new ConnectionException("New location : " + redirectionUrl, redirectionUrl); } InputStream errorStream = connection.getErrorStream(); if (errorStream != null) { String error = convertStreamToString(errorStream, isGzip); // L.e("responseCode:"+responseCode+" httpErrorResCodeFilte:"+httpErrorResCodeFilte+" responseCode==httpErrorResCodeFilte:"+(responseCode==httpErrorResCodeFilte)); if (responseCode == httpErrorResCodeFilte) { // 400???... logResBodyAndHeader(connection, error); return new ConnectionResult(connection.getHeaderFields(), error, responseCode); } else { throw new ConnectionException(error, responseCode); } } String body = convertStreamToString(connection.getInputStream(), isGzip); // ?? ? if (null != body && body.contains("\r")) { body = body.replace("\r", ""); } if (null != body && body.contains("\n")) { body = body.replace("\n", ""); } logResBodyAndHeader(connection, body); return new ConnectionResult(connection.getHeaderFields(), body, responseCode); } catch (IOException e) { L.e(TAG, "IOException", e); throw new ConnectionException(e); } catch (KeyManagementException e) { L.e(TAG, "KeyManagementException", e); throw new ConnectionException(e); } catch (NoSuchAlgorithmException e) { L.e(TAG, "NoSuchAlgorithmException", e); throw new ConnectionException(e); } finally { if (connection != null) { connection.disconnect(); } } }