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:de.madvertise.android.sdk.MadvertiseView.java
@Override public void onWindowFocusChanged(boolean hasWindowFocus) { MadvertiseUtil.logMessage(null, Log.DEBUG, "#### onWindowFocusChanged fired ####"); onViewCallback(hasWindowFocus);/* ww w .ja v a 2 s . c om*/ super.onWindowFocusChanged(hasWindowFocus); this.getParent(); }
From source file:de.madvertise.android.sdk.MadvertiseView.java
@Override protected void onAttachedToWindow() { MadvertiseUtil.logMessage(null, Log.DEBUG, "#### onAttachedToWindow fired ####"); onViewCallback(true); super.onAttachedToWindow(); }
From source file:de.madvertise.android.sdk.MadvertiseView.java
@Override protected void onDetachedFromWindow() { MadvertiseUtil.logMessage(null, Log.DEBUG, "#### onDetachedFromWindow fired ####"); onViewCallback(false); super.onDetachedFromWindow(); }
From source file:com.irccloud.android.NetworkConnection.java
public synchronized void connect(String sk) { Context ctx = IRCCloudApplication.getInstance().getApplicationContext(); session = sk;//from w ww.j a va2 s. c om String host = null; int port = -1; if (sk == null || sk.length() == 0) return; if (ctx != null) { ConnectivityManager cm = (ConnectivityManager) ctx.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo ni = cm.getActiveNetworkInfo(); if (ni == null || !ni.isConnected()) { cancel_idle_timer(); state = STATE_DISCONNECTED; reconnect_timestamp = 0; notifyHandlers(EVENT_CONNECTIVITY, null); return; } } if (state == STATE_CONNECTING || state == STATE_CONNECTED) { Log.w(TAG, "Ignoring duplicate connect request"); return; } state = STATE_CONNECTING; if (oobTasks.size() > 0) { Log.d("IRCCloud", "Clearing OOB tasks before connecting"); } for (Integer bid : oobTasks.keySet()) { try { oobTasks.get(bid).cancel(true); } catch (Exception e) { e.printStackTrace(); } } oobTasks.clear(); if (Build.VERSION.SDK_INT < 11) { if (ctx != null) { host = android.net.Proxy.getHost(ctx); port = android.net.Proxy.getPort(ctx); } } else { host = System.getProperty("http.proxyHost", null); try { port = Integer.parseInt(System.getProperty("http.proxyPort", "8080")); } catch (NumberFormatException e) { port = -1; } } if (!wifiLock.isHeld()) wifiLock.acquire(); List<BasicNameValuePair> extraHeaders = Arrays.asList( new BasicNameValuePair("Cookie", "session=" + session), new BasicNameValuePair("User-Agent", useragent)); String url = "wss://" + IRCCLOUD_HOST + IRCCLOUD_PATH; if (mEvents.highest_eid > 0) { url += "?since_id=" + mEvents.highest_eid; if (streamId != null && streamId.length() > 0) url += "&stream_id=" + streamId; } if (host != null && host.length() > 0 && !host.equalsIgnoreCase("localhost") && !host.equalsIgnoreCase("127.0.0.1") && port > 0) { Crashlytics.log(Log.DEBUG, TAG, "Connecting: " + url + " via proxy: " + host); } else { Crashlytics.log(Log.DEBUG, TAG, "Connecting: " + url); } Crashlytics.log(Log.DEBUG, TAG, "Attempt: " + failCount); client = new WebSocketClient(URI.create(url), new WebSocketClient.Listener() { @Override public void onConnect() { Crashlytics.log(Log.DEBUG, TAG, "WebSocket connected"); state = STATE_CONNECTED; notifyHandlers(EVENT_CONNECTIVITY, null); fetchConfig(); } @Override public void onMessage(String message) { if (client != null && client.getListener() == this && message.length() > 0) { try { synchronized (parserLock) { parse_object(new IRCCloudJSONObject(mapper.readValue(message, JsonNode.class))); } } catch (Exception e) { Log.e(TAG, "Unable to parse: " + message); Crashlytics.logException(e); e.printStackTrace(); } } } @Override public void onMessage(byte[] data) { //Log.d(TAG, String.format("Got binary message! %s", toHexString(data)); } @Override public void onDisconnect(int code, String reason) { Crashlytics.log(Log.DEBUG, TAG, "WebSocket disconnected"); ConnectivityManager cm = (ConnectivityManager) IRCCloudApplication.getInstance() .getApplicationContext().getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo ni = cm.getActiveNetworkInfo(); if (state == STATE_DISCONNECTING || ni == null || !ni.isConnected()) cancel_idle_timer(); else { failCount++; if (failCount < 4) idle_interval = failCount * 1000; else if (failCount < 10) idle_interval = 10000; else idle_interval = 30000; schedule_idle_timer(); Crashlytics.log(Log.DEBUG, TAG, "Reconnecting in " + idle_interval / 1000 + " seconds"); } state = STATE_DISCONNECTED; notifyHandlers(EVENT_CONNECTIVITY, null); if (reason != null && reason.equals("SSL")) { Crashlytics.log(Log.ERROR, TAG, "The socket was disconnected due to an SSL error"); try { JSONObject o = new JSONObject(); o.put("message", "Unable to establish a secure connection to the IRCCloud servers."); notifyHandlers(EVENT_FAILURE_MSG, new IRCCloudJSONObject(o)); } catch (JSONException e) { e.printStackTrace(); } } client = null; } @Override public void onError(Exception error) { Crashlytics.log(Log.ERROR, TAG, "The WebSocket encountered an error: " + error.toString()); if (state == STATE_DISCONNECTING) cancel_idle_timer(); else { failCount++; if (failCount < 4) idle_interval = failCount * 1000; else if (failCount < 10) idle_interval = 10000; else idle_interval = 30000; schedule_idle_timer(); Crashlytics.log(Log.DEBUG, TAG, "Reconnecting in " + idle_interval / 1000 + " seconds"); } state = STATE_DISCONNECTED; notifyHandlers(EVENT_CONNECTIVITY, null); client = null; } }, extraHeaders); Log.d("IRCCloud", "Creating websocket"); reconnect_timestamp = 0; idle_interval = 0; accrued = 0; notifyHandlers(EVENT_CONNECTIVITY, null); if (client != null) { client.setSocketTag(WEBSOCKET_TAG); if (host != null && host.length() > 0 && !host.equalsIgnoreCase("localhost") && !host.equalsIgnoreCase("127.0.0.1") && port > 0) client.setProxy(host, port); else client.setProxy(null, -1); client.connect(); } }
From source file:com.irccloud.android.fragment.BuffersListFragment.java
public void setSelectedBid(int bid) { int last_bid = selected_bid; selected_bid = bid;//ww w.j av a 2 s. co m if (adapter != null) { BuffersDataSource.Buffer b = BuffersDataSource.getInstance().getBuffer(last_bid); if (b != null) adapter.updateBuffer(b); b = BuffersDataSource.getInstance().getBuffer(bid); if (b != null) adapter.updateBuffer(b); adapter.showProgress(adapter.positionForBid(bid)); } else { Crashlytics.log(Log.WARN, "IRCCloud", "BufferListFragment: Request to set BID but I don't have an adapter yet, refreshing"); RefreshTask t = new RefreshTask(); t.doInBackground((Void) null); t.onPostExecute(null); Crashlytics.log(Log.DEBUG, "IRCCloud", "Done"); } }
From source file:com.android.ex.chips.RecipientEditTextView.java
/** * Remove any characters after the last valid chip. *//*from w w w . j av a2s. co m*/ // Visible for testing. /* package */void sanitizeEnd() { // Don't sanitize while we are waiting for pending chips to complete. if (mPendingChipsCount > 0) return; // Find the last chip; eliminate any commit characters after it. final DrawableRecipientChip[] chips = getSortedRecipients(); final Spannable spannable = getSpannable(); if (chips != null && chips.length > 0) { int end; mMoreChip = getMoreChip(); if (mMoreChip != null) end = spannable.getSpanEnd(mMoreChip); else end = getSpannable().getSpanEnd(getLastChip()); final Editable editable = getText(); final int length = editable.length(); if (length > end) { // See what characters occur after that and eliminate them. if (Log.isLoggable(TAG, Log.DEBUG)) Log.d(TAG, "There were extra characters after the last tokenizable entry." + editable); editable.delete(end + 1, length); } } }
From source file:de.madvertise.android.sdk.MadvertiseView.java
/** * Handles the refresh timer, initiates the stopping of the request thread * and caching of ads./*from w w w .j a v a 2 s. c om*/ * * @param starting */ private void onViewCallback(final boolean starting) { synchronized (this) { if (starting) { if (mAdTimer == null) { mAdTimer = new Timer(); mAdTimer.schedule(new TimerTask() { public void run() { MadvertiseUtil.logMessage(null, Log.DEBUG, "Refreshing ad ..."); requestNewAd(true); } }, (long) mSecondsToRefreshAd * 1000, (long) mSecondsToRefreshAd * 1000); } } else { if (mAdTimer != null) { MadvertiseUtil.logMessage(null, Log.DEBUG, "Stopping refresh timer ..."); mAdTimer.cancel(); mAdTimer = null; // When there is no timer needed, the current request can be // stopped stopRequestThread(); } } } }
From source file:com.irccloud.android.fragment.MessageViewFragment.java
@Override public void setArguments(Bundle args) { ready = false;//from ww w . j a v a2 s . c om if (heartbeatTask != null) heartbeatTask.cancel(true); heartbeatTask = null; if (tapTimerTask != null) tapTimerTask.cancel(); tapTimerTask = null; if (buffer != null && buffer.bid != args.getInt("bid", -1) && adapter != null) adapter.clearLastSeenEIDMarker(); buffer = BuffersDataSource.getInstance().getBuffer(args.getInt("bid", -1)); if (buffer != null) { server = ServersDataSource.getInstance().getServer(buffer.cid); Crashlytics.log(Log.DEBUG, "IRCCloud", "MessageViewFragment: switched to bid: " + buffer.bid); } else { Crashlytics.log(Log.WARN, "IRCCloud", "MessageViewFragment: couldn't find buffer to switch to"); } requestingBacklog = false; avgInsertTime = 0; newMsgs = 0; newMsgTime = 0; newHighlights = 0; earliest_eid = 0; backlog_eid = 0; currentCollapsedEid = -1; lastCollapsedDay = -1; if (server != null) { ignore.setIgnores(server.ignores); if (server.away != null && server.away.length() > 0) { awayTxt.setText(ColorFormatter .html_to_spanned( ColorFormatter.irc_to_html(TextUtils.htmlEncode("Away (" + server.away + ")"))) .toString()); awayView.setVisibility(View.VISIBLE); } else { awayView.setVisibility(View.GONE); } collapsedEvents.setServer(server); update_status(server.status, server.fail_info); } if (unreadTopView != null) unreadTopView.setVisibility(View.GONE); backlogFailed.setVisibility(View.GONE); loadBacklogButton.setVisibility(View.GONE); try { if (getListView().getHeaderViewsCount() == 0) { getListView().addHeaderView(headerViewContainer); } } catch (IllegalStateException e) { } ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) headerView.getLayoutParams(); lp.topMargin = 0; headerView.setLayoutParams(lp); lp = (ViewGroup.MarginLayoutParams) backlogFailed.getLayoutParams(); lp.topMargin = 0; backlogFailed.setLayoutParams(lp); if (buffer != null && EventsDataSource.getInstance().getEventsForBuffer(buffer.bid) != null) { requestingBacklog = true; if (refreshTask != null) refreshTask.cancel(true); refreshTask = new RefreshTask(); if (args.getBoolean("fade")) { Crashlytics.log(Log.DEBUG, "IRCCloud", "MessageViewFragment: Loading message contents in the background"); refreshTask.execute((Void) null); } else { Crashlytics.log(Log.DEBUG, "IRCCloud", "MessageViewFragment: Loading message contents"); refreshTask.onPreExecute(); refreshTask.onPostExecute(refreshTask.doInBackground()); } } else { if (buffer == null || buffer.min_eid == 0 || earliest_eid == buffer.min_eid || conn.getState() != NetworkConnection.STATE_CONNECTED || !conn.ready) { headerView.setVisibility(View.GONE); } else { headerView.setVisibility(View.VISIBLE); } if (adapter != null) { adapter.clear(); adapter.notifyDataSetInvalidated(); } mListener.onMessageViewReady(); ready = true; } }
From source file:com.irccloud.android.data.collection.NotificationsList.java
private void showMessageNotifications(String ticker) { SharedPreferences prefs = PreferenceManager .getDefaultSharedPreferences(IRCCloudApplication.getInstance().getApplicationContext()); String text = ""; final List<Notification> notifications = getMessageNotifications(); int notify_type = Integer.parseInt(prefs.getString("notify_type", "1")); boolean notify = false; if (notify_type == 1 || (notify_type == 2 && NetworkConnection.getInstance().isVisible())) notify = true;//w w w. j a v a 2 s .co m if (notifications.size() > 0 && notify) { int lastbid = notifications.get(0).bid; int count = 0; long[] eids = new long[notifications.size()]; ArrayList<Notification> messages = new ArrayList<>(notifications.size()); Notification last = notifications.get(0); boolean show = false; for (Notification n : notifications) { if (n.bid != lastbid) { if (show) { String title = last.chan; if (title == null || title.length() == 0) title = last.nick; if (title == null || title.length() == 0) title = last.network; Intent replyIntent = new Intent(RemoteInputService.ACTION_REPLY); replyIntent.putExtra("bid", last.bid); replyIntent.putExtra("cid", last.cid); replyIntent.putExtra("eids", eids); replyIntent.putExtra("network", last.network); replyIntent.putExtra("chan", last.chan); replyIntent.putExtra("buffer_type", last.buffer_type); replyIntent.putExtra("to", last.chan); String body; if (last.buffer_type.equals("channel")) { if (last.message_type.equals("buffer_me_msg")) body = "<b> " + ((last.nick != null) ? last.nick : getServerNick(last.cid)) + "</b> " + last.message; else body = "<b><" + ((last.nick != null) ? last.nick : getServerNick(last.cid)) + "></b> " + last.message; } else { if (last.message_type.equals("buffer_me_msg")) body = " " + ((last.nick != null) ? last.nick : getServerNick(last.cid)) + " " + last.message; else body = last.message; } ArrayList<String> lines = new ArrayList<>(Arrays.asList(text.split("<br/>"))); while (lines.size() > 3) lines.remove(0); try { Crashlytics.log(Log.DEBUG, "IRCCloud", "Posting notification for type " + last.message_type); NotificationManagerCompat .from(IRCCloudApplication.getInstance().getApplicationContext()) .notify(lastbid, buildNotification(ticker, last.cid, lastbid, eids, title, body, count, replyIntent, last.network, messages, null, AvatarsList.getInstance().getAvatar(last.cid, last.nick).getBitmap( false, (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 64, IRCCloudApplication.getInstance() .getApplicationContext().getResources() .getDisplayMetrics()), false, Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP), AvatarsList.getInstance().getAvatar(last.cid, last.nick) .getBitmap(false, 400, false, false))); } catch (Exception e) { Crashlytics.logException(e); } } lastbid = n.bid; text = ""; count = 0; eids = new long[notifications.size()]; show = false; messages.clear(); } if (text.length() > 0) text += "<br/>"; if (n.buffer_type.equals("conversation") && n.message_type.equals("buffer_me_msg")) text += " " + n.message; else if (n.buffer_type.equals("conversation")) text += n.message; else if (n.message_type.equals("buffer_me_msg")) text += "<b> " + ((n.nick != null) ? n.nick : getServerNick(n.cid)) + "</b> " + n.message; else text += "<b>" + ((n.nick != null) ? n.nick : getServerNick(n.cid)) + "</b> " + n.message; if (!n.shown) { n.shown = true; show = true; if (n.nick != null && prefs.getBoolean("notify_sony", false)) { long time = System.currentTimeMillis(); long sourceId = NotificationUtil.getSourceId( IRCCloudApplication.getInstance().getApplicationContext(), SonyExtensionService.EXTENSION_SPECIFIC_ID); if (sourceId == NotificationUtil.INVALID_ID) { Crashlytics.log(Log.ERROR, "IRCCloud", "Sony LiveWare Manager not configured, disabling Sony notifications"); SharedPreferences.Editor editor = prefs.edit(); editor.putBoolean("notify_sony", false); editor.commit(); } else { ContentValues eventValues = new ContentValues(); eventValues.put( com.sonyericsson.extras.liveware.aef.notification.Notification.EventColumns.EVENT_READ_STATUS, false); eventValues.put( com.sonyericsson.extras.liveware.aef.notification.Notification.EventColumns.DISPLAY_NAME, n.nick); if (n.buffer_type.equals("channel") && n.chan != null && n.chan.length() > 0) eventValues.put( com.sonyericsson.extras.liveware.aef.notification.Notification.EventColumns.TITLE, n.chan); else eventValues.put( com.sonyericsson.extras.liveware.aef.notification.Notification.EventColumns.TITLE, n.network); if (n.message_type.equals("buffer_me_msg")) eventValues.put( com.sonyericsson.extras.liveware.aef.notification.Notification.EventColumns.MESSAGE, " " + Html.fromHtml(n.message).toString()); else eventValues.put( com.sonyericsson.extras.liveware.aef.notification.Notification.EventColumns.MESSAGE, Html.fromHtml(n.message).toString()); eventValues.put( com.sonyericsson.extras.liveware.aef.notification.Notification.EventColumns.PERSONAL, 1); eventValues.put( com.sonyericsson.extras.liveware.aef.notification.Notification.EventColumns.PUBLISHED_TIME, time); eventValues.put( com.sonyericsson.extras.liveware.aef.notification.Notification.EventColumns.SOURCE_ID, sourceId); eventValues.put( com.sonyericsson.extras.liveware.aef.notification.Notification.EventColumns.FRIEND_KEY, String.valueOf(n.bid)); try { IRCCloudApplication.getInstance().getApplicationContext().getContentResolver() .insert(com.sonyericsson.extras.liveware.aef.notification.Notification.Event.URI, eventValues); } catch (IllegalArgumentException e) { Log.e("IRCCloud", "Failed to insert event", e); } catch (SecurityException e) { Log.e("IRCCloud", "Failed to insert event, is Live Ware Manager installed?", e); } catch (SQLException e) { Log.e("IRCCloud", "Failed to insert event", e); } } } if (prefs.getBoolean("notify_pebble", false) && n.nick != null) { String pebbleTitle = n.network + ":\n"; String pebbleBody = ""; if (n.buffer_type.equals("channel") && n.chan != null && n.chan.length() > 0) pebbleTitle = n.chan + ":\n"; if (n.message_type.equals("buffer_me_msg")) pebbleBody = " " + n.message; else pebbleBody = n.message; if (n.chan != null && n.nick != null && n.nick.length() > 0) notifyPebble(n.nick, pebbleTitle + Html.fromHtml(pebbleBody).toString()); else notifyPebble(n.network, pebbleTitle + Html.fromHtml(pebbleBody).toString()); } } messages.add(n); eids[count++] = n.eid; if (n.nick != null) last = n; } if (show) { String title = last.chan; if (title == null || title.length() == 0) title = last.network; Intent replyIntent = new Intent(RemoteInputService.ACTION_REPLY); replyIntent.putExtra("bid", last.bid); replyIntent.putExtra("cid", last.cid); replyIntent.putExtra("network", last.network); replyIntent.putExtra("eids", eids); replyIntent.putExtra("chan", last.chan); replyIntent.putExtra("buffer_type", last.buffer_type); replyIntent.putExtra("to", last.chan); String body = ""; if (last.buffer_type.equals("channel")) { if (last.message_type.equals("buffer_me_msg")) body = "<b> " + ((last.nick != null) ? last.nick : getServerNick(last.cid)) + "</b> " + last.message; else body = "<b><" + ((last.nick != null) ? last.nick : getServerNick(last.cid)) + "></b> " + last.message; } else { if (last.message_type.equals("buffer_me_msg")) body = " " + ((last.nick != null) ? last.nick : getServerNick(last.cid)) + " " + last.message; else body = last.message; } ArrayList<String> lines = new ArrayList<>(Arrays.asList(text.split("<br/>"))); while (lines.size() > 3) lines.remove(0); try { Crashlytics.log(Log.DEBUG, "IRCCloud", "Posting notification for type " + last.message_type); NotificationManagerCompat.from(IRCCloudApplication.getInstance().getApplicationContext()) .notify(last.bid, buildNotification(ticker, last.cid, last.bid, eids, title, body, count, replyIntent, last.network, messages, null, AvatarsList.getInstance().getAvatar(last.cid, last.nick).getBitmap(false, (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 64, IRCCloudApplication.getInstance().getApplicationContext() .getResources().getDisplayMetrics()), false, Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP), AvatarsList.getInstance().getAvatar(last.cid, last.nick).getBitmap(false, 400, false, false))); } catch (Exception e) { Crashlytics.logException(e); } } TransactionManager.transact(IRCCloudDatabase.NAME, new Runnable() { @Override public void run() { for (Notification n : notifications) { n.save(); } } }); } }
From source file:de.madvertise.android.sdk.MadvertiseView.java
/** * Enable/disable the loading of new ads. Default is true. * * @param isEnabled/*from w w w .j ava2s.c o m*/ */ public void setFetchingAdsEnabled(final boolean isEnabled) { mFetchAdsEnabled = isEnabled; MadvertiseUtil.logMessage(null, Log.DEBUG, "Set Fetching Ads to " + isEnabled); if (!isEnabled) { stopRequestThread(); if (mAdTimer != null) { mAdTimer.cancel(); mAdTimer = null; } } else { onViewCallback(true); } }