List of usage examples for android.util Log wtf
public static int wtf(String tag, Throwable tr)
From source file:com.appsimobile.appsii.module.weather.WeatherLoadingService.java
/** * Downloads the header images for the given woeid and weather-data. Failure is considered * non-fatal.//from w w w. j av a2 s . c om * * @throws VolleyError */ public static void downloadWeatherImages(Context context, BitmapUtils bitmapUtils, String woeid, WeatherData weatherData, String timezone) throws VolleyError { WindowManager windowManager = AppInjector.provideWindowManager(); // first we need to determine if it is day or night. // TODO: this needs the timezone if (timezone == null) { timezone = TimeZone.getDefault().getID(); } WeatherUtils weatherUtils = AppInjector.provideWeatherUtils(); boolean isDay = weatherUtils.isDay(timezone, weatherData); ImageDownloadHelper downloadHelper = ImageDownloadHelper.getInstance(context); // call into the download-helper this will return a json object with // city photos matching the current weather condition. JSONObject photos = downloadHelper.searchCityWeatherPhotos(woeid, weatherData.nowConditionCode, isDay); // Now we need the screen dimension to know which photos have a usable size. int dimen = getMaxScreenDimension(windowManager); // determine the photos that can be used. List<ImageDownloadHelper.PhotoInfo> result = new ArrayList<>(); ImageDownloadHelper.getEligiblePhotosFromResponse(photos, result, dimen); // when no usable photos have been found try photos at the city level with // no weather condition info. if (result.isEmpty()) { photos = downloadHelper.searchCityImage(woeid); ImageDownloadHelper.getEligiblePhotosFromResponse(photos, result, dimen); // when still no photo was found, clear the existing photos and return if (result.isEmpty()) { weatherUtils.clearCityPhotos(context, woeid, 0); return; } } // Now determine the amount of photos we should download int N = Math.min(MAX_PHOTO_COUNT, result.size()); // idx keeps the index of the actually downloaded photo count int idx = 0; // note the idx < N instead of i < N. // this loop must continue until the amount is satisfied. for (int i = 0; idx < N; i++) { // quit when the end of the list is reached if (i >= result.size()) break; // try to download the photo details from the webservice. ImageDownloadHelper.PhotoInfo info = result.get(i); JSONObject photoInfo = downloadHelper.loadPhotoInfo(context, info.id); if (photoInfo != null) { // we need to know if the photo is rotated. If so, we need to apply this // rotation after download. int rotation = ImageDownloadHelper.getRotationFromJson(photoInfo); if (downloadFile(context, info, woeid, idx)) { // Apply rotation when non zero if (rotation != 0) { File cacheDir = weatherUtils.getWeatherPhotoCacheDir(context); String fileName = weatherUtils.createPhotoFileName(woeid, idx); File photoImage = new File(cacheDir, fileName); Bitmap bitmap = bitmapUtils.decodeSampledBitmapFromFile(photoImage, dimen, dimen); if (bitmap == null) { Log.wtf("WeatherLoadingService", "error decoding bitmap"); continue; } Matrix matrix = new Matrix(); matrix.postRotate(rotation); bitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, false); weatherUtils.saveBitmap(context, bitmap, woeid, idx); } // success, handle the next one. idx++; } } } // remove photos at higher indexes than the amount downloaded. weatherUtils.clearCityPhotos(context, woeid, idx + 1); }
From source file:com.skalski.raspberrycontrol.Custom_WebSocketClient.java
@Override public void onBinaryMessage(byte[] payload) { Log.wtf(LOGTAG, LOGPREFIX + "we didn't expect 'BinaryMessage' Message"); }
From source file:com.seamusdawkins.autocomplete.MainActivity.java
/** * This method will results show the autocomplete addresses * * @param input/*w w w. j av a 2 s .c o m*/ * @return list */ public ArrayList autocomplete(String input) { ArrayList resultList = null; resultListReference = null; HttpURLConnection conn = null; StringBuilder jsonResults = new StringBuilder(); try { StringBuilder sb = new StringBuilder(PLACES_API_BASE + TYPE_AUTOCOMPLETE + OUT_JSON); sb.append("?key=" + activity.getString(R.string.google_server_key)); //sb.append("&components=country:br"); sb.append("&input=" + URLEncoder.encode(input, "utf8")); URL url = new URL(sb.toString()); conn = (HttpURLConnection) url.openConnection(); InputStreamReader in = new InputStreamReader(conn.getInputStream()); // Load the results into a StringBuilder int read; char[] buff = new char[1024]; while ((read = in.read(buff)) != -1) { jsonResults.append(buff, 0, read); } } catch (MalformedURLException e) { Log.wtf(LOG_TAG, "Error processing Places API URL: " + e); return resultList; } catch (IOException e) { Log.wtf(LOG_TAG, "Error connecting to Places API: " + e); return resultList; } finally { if (conn != null) { conn.disconnect(); } } try { // Create a JSON object hierarchy from the results JSONObject jsonObj = new JSONObject(jsonResults.toString()); JSONArray predsJsonArray = jsonObj.getJSONArray("predictions"); // Extract the Place descriptions from the results resultList = new ArrayList(predsJsonArray.length()); resultListReference = new ArrayList(); for (int i = 0; i < predsJsonArray.length(); i++) { System.out.println(predsJsonArray.getJSONObject(i).getString("description")); System.out.println(predsJsonArray.getJSONObject(i).getString("reference")); System.out.println("--------------------------------------------------------"); resultList.add(predsJsonArray.getJSONObject(i).getString("description")); resultListReference.add(predsJsonArray.getJSONObject(i).getString("reference")); } } catch (JSONException e) { Log.wtf(LOG_TAG, "Cannot process JSON results: " + e); } return resultList; }
From source file:conexionSiabra.Oauth.java
public boolean obtainAccessToken(String verifier) { String baseString = ""; String parameters;/*www.java2s . c o m*/ String complement; String signature = ""; String get = ""; try {// Builds a baseString, makes the signature and construct the get baseString = "GET&" + URLEncoder.encode(ACCESS_TOKEN_URL, "UTF-8") + "&"; parameters = "oauth_consumer_key=" + CONSUMER_KEY + "&oauth_nonce=" + getNonce() + "&oauth_signature_method=HMAC-SHA1" + "&oauth_timestamp=" + setTimeStamp() + "&oauth_token=" + TOKEN + "&oauth_verifier=" + verifier + "&oauth_version=1.0"; complement = URLEncoder.encode(parameters, "UTF-8"); baseString += complement; signature = URLEncoder.encode(hmac_sha1(baseString, CONSUMER_SECRET + "&" + TOKEN_SECRET), "UTF-8"); get = ACCESS_TOKEN_URL + "?oauth_version=1.0&oauth_nonce=" + getNonce() + "&oauth_timestamp=" + timeStamp + "&oauth_consumer_key=" + CONSUMER_KEY + "&oauth_token=" + TOKEN + "&oauth_verifier=" + verifier + "&oauth_signature_method=HMAC-SHA1&oauth_signature=" + signature; } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } String result; Log.wtf("Envio", get); Peticion peticion = new PeticionGet(get); result = peticion.Ejecutar(); Log.wtf("Resultado Access Token", result); return setTokens(result, "Access"); }
From source file:com.example.android.recyclingbanks.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (savedInstanceState != null) { Log.wtf("restoring state?", "should have cam pos"); cameraPosition = savedInstanceState.getParcelable("STATE_CAMERA_POSITION"); //mBankLatLng = bundle.getParcelable("bankLatLng"); } else if (savedInstanceState == null) { Log.wtf("onCreate", "state not restored"); }//from w w w.ja v a 2 s . com Log.i("onCreate", "seting up variable, UI etc."); setContentView(R.layout.bottombar_constraint_layout); setTitle("Recycle Banks"); //setContentView(R.layout.earthquake_activity); // TODO ask for postcode and house number on first login, tell them you can change this using [icon] later //DownloadTask task = new DownloadTask(); //task.execute(REQUEST_URL); // load preference defaults for buttons press, // false means we won't ever read this again after first app boot PreferenceManager.setDefaultValues(this, R.xml.default_preferences, true); // preferences contains booleans to record click status of bottom bar preferences = getPreferences(MODE_PRIVATE); mSharedPrefs = getDefaultSharedPreferences(getBaseContext()); // Find a reference to the {@link ListView} in the layout ListView earthquakeListView = (ListView) findViewById(R.id.list); mProgressBar = (ProgressBar) findViewById(R.id.loading_spinner); mSpinnerLayout = (LinearLayout) findViewById(R.id.linearLayoutSpinner); // WANT TO create a message if the list is empty mEmptyView = (TextView) findViewById(R.id.emptyView); // by attaching this to listView, it only shows if listView is empty Log.i(LOG_TAG, "!!!!! launching a new LoaderManager"); usesGPS = mSharedPrefs.getBoolean("usesGPS", false); if (!usesGPS) { // TODO // setup home marker mUserLatitude = Double.valueOf(mSharedPrefs.getString("manualLatitude", "55.9532520")); mUserLongitude = Double.valueOf(mSharedPrefs.getString("manualLongitude", "-3.1882670")); String homeAddress = mSharedPrefs.getString("homeAddress", "Edinburgh"); Log.w("onCreate", "manual address: " + homeAddress); // alert user that using saved home location Toast.makeText(this, homeAddress + "as home, change in settings", Toast.LENGTH_SHORT); } Log.wtf("onConnected", "all prefs: " + String.valueOf(mSharedPrefs.getAll())); Log.wtf("onConnected", "contain usesGPS key? " + String.valueOf(mSharedPrefs.contains("usesGPS"))); Log.wtf("onConnected", "using gps? " + String.valueOf(usesGPS)); // Create an instance of GoogleAPIClient. Used for getting users location // also used for geocoding their location to Toast their street. if (mGoogleApiClient == null) { mGoogleApiClient = new Builder(this).addConnectionCallbacks(this).addOnConnectionFailedListener(this) .addApi(LocationServices.API).build(); } }
From source file:com.meetingninja.csse.meetings.MeetingsFragment.java
@Override public boolean onContextItemSelected(MenuItem item) { int position = item.getItemId(); boolean handled = false; AdapterContextMenuInfo aInfo = (AdapterContextMenuInfo) item.getMenuInfo(); if (item.getGroupId() == MainActivity.DrawerLabel.MEETINGS.getPosition()) { switch (item.getOrder()) { case 1: // Edit Toast.makeText(getActivity(), item.getTitle(), Toast.LENGTH_SHORT).show(); handled = true;//from www.j ava 2 s.co m break; case 2: // Delete Meeting meeting = meetingAdpt.getItem(position); // mySQLiteAdapter.deleteMeeting(meeting); Need to implement MeetingVolleyAdapter.deleteMeeting(meeting.getID()); meetings.remove(position); meetingAdpt.notifyDataSetChanged(); handled = true; break; default: Log.wtf(TAG, "Invalid context menu option selected"); break; } } else { Log.wtf(TAG, "What happened here?"); } return handled; }
From source file:com.example.bluetooth.RFduinoService.java
private void broadcastUpdate(final String action, final BluetoothGattCharacteristic characteristic) { if (UUID_RECEIVE.equals(characteristic.getUuid())) { final Intent intent = new Intent(action); intent.putExtra(EXTRA_DATA, characteristic.getValue()); //sendBroadcast(intent, Manifest.permission.BLUETOOTH); // Left it, to avoid modify BluetoothActivty due to time constraints mServiceStart = true;// www .ja va2 s. c o m intent.putExtra(ACTION_DATA_TAG, true); sendOrderedBroadcast(intent, Manifest.permission.BLUETOOTH, new BroadcastReceiver() { @Override public void onReceive(Context pContext, Intent pIntent) { //String pResultData = getResultData(); if (getResultData() != null && getResultData().equals("Tag_Activity")) { mServiceStart = false; Log.wtf(TAG, "StartService false"); } // Trigger Reminder Service if (mServiceStart) { final Intent mReminderIntent = new Intent(getApplicationContext(), ReminderService.class); mReminderIntent.putExtra(ACTION_DATA_SERVICE, true); mReminderIntent.putExtra(EXTRA_DATA, characteristic.getValue()); getApplicationContext().startService(mReminderIntent); } } }, null, Activity.RESULT_OK, null, null); Log.w(TAG, "BTLE Data received and Broadcasted"); // // Trigger Reminder Service // if(mServiceStart) { // final Intent mReminderIntent = new Intent(getApplicationContext(), ReminderService.class); // mReminderIntent.putExtra(ACTION_DATA_SERVICE, true); // mReminderIntent.putExtra(EXTRA_DATA, characteristic.getValue()); // getApplicationContext().startService(mReminderIntent); // } } }
From source file:com.scvngr.levelup.core.util.LogManager.java
/** * Logs a message to the Android log.// w w w. ja v a2 s. co m * * @param logLevel {@link Log#VERBOSE}, {@link Log#DEBUG}, {@link Log#INFO}, {@link Log#WARN}, * or {@link Log#ERROR}. * @param message the message to be logged. This message is expected to be a format string if * messageFormatArgs is not null. * @param messageFormatArgs formatting arguments for the message, or null if the string is to be * handled without formatting. * @param err an optional error to log with a stacktrace. */ private static void logMessage(final int logLevel, @NonNull final String message, @Nullable final Object[] messageFormatArgs, @Nullable final Throwable err) { final String preppedMessage = formatMessage(message, messageFormatArgs); final StackTraceElement[] trace = Thread.currentThread().getStackTrace(); final String sourceClass = trace[STACKTRACE_SOURCE_FRAME_INDEX].getClassName(); final String sourceMethod = trace[STACKTRACE_SOURCE_FRAME_INDEX].getMethodName(); final String logcatLogLine = String.format(Locale.US, FORMAT, Thread.currentThread().getName(), sourceClass, sourceMethod, preppedMessage); switch (logLevel) { case Log.VERBOSE: { if (null == err) { Log.v(sLogTag, logcatLogLine); } else { Log.v(sLogTag, logcatLogLine, err); } break; } case Log.DEBUG: { if (null == err) { Log.d(sLogTag, logcatLogLine); } else { Log.d(sLogTag, logcatLogLine, err); } break; } case Log.INFO: { if (null == err) { Log.i(sLogTag, logcatLogLine); } else { Log.i(sLogTag, logcatLogLine, err); } break; } case Log.WARN: { if (null == err) { Log.w(sLogTag, logcatLogLine); } else { Log.w(sLogTag, logcatLogLine, err); } break; } case Log.ERROR: { if (null == err) { Log.e(sLogTag, logcatLogLine); } else { Log.e(sLogTag, logcatLogLine, err); } break; } case Log.ASSERT: { if (null == err) { Log.wtf(sLogTag, logcatLogLine); } else { Log.wtf(sLogTag, logcatLogLine, err); } break; } default: { throw new AssertionError(); } } }
From source file:com.trellmor.berrytube.BerryTubeIOCallback.java
/** * @see io.socket.IOCallback#onError(io.socket.SocketIOException) */ public void onError(SocketIOException socketIOException) { Log.wtf(TAG, socketIOException); }
From source file:com.meetingninja.csse.notes.NotesFragment.java
@Override public boolean onContextItemSelected(MenuItem item) { int position = item.getItemId(); boolean handled = false; AdapterContextMenuInfo aInfo = (AdapterContextMenuInfo) item.getMenuInfo(); if (item.getGroupId() == MainActivity.DrawerLabel.NOTES.getPosition()) { switch (item.getOrder()) { case 1: // Add Content Toast.makeText(getActivity(), String.format("%s", item.getTitle()), Toast.LENGTH_SHORT).show(); handled = true;//from w ww. ja va 2 s. c o m break; case 2: // Delete delete(noteAdpt.getItem(position)); handled = true; break; case 3: Intent versionControl = new Intent(getActivity(), VersionControlActivity.class); startActivity(versionControl); handled = true; break; case 4: Note n = noteAdpt.getItem(position); if (mergeNote == null) { Log.d("MERGE", "merge_a: " + n.getID()); mergeNote = n; Toast.makeText(getActivity(), String.format("Select second note to merge."), Toast.LENGTH_LONG) .show(); } else if (mergeNote.getID().equalsIgnoreCase(n.getID())) { Log.d("MERGE", "merge_b: " + n.getID() + " : " + mergeNote.getID()); mergeNote = null; Toast.makeText(getActivity(), String.format("Error: Same note selected twice. Please reselect notes to merge."), Toast.LENGTH_LONG).show(); } else { Log.d("MERGE", "merge_c: " + n.getID() + " : " + mergeNote.getID()); Toast.makeText(getActivity(), String.format("Merging " + n.getTitle() + " into " + mergeNote.getTitle()), Toast.LENGTH_LONG).show(); mergeNote.setContent(mergeNote.getContent() + "\n" + n.getContent()); delete(n); updateNote(mergeNote); mergeNote = null; populateList(); } break; default: Log.wtf(TAG, "Invalid context menu option selected"); break; } } else { Log.wtf(TAG, "What happened here?"); } return handled; }