Example usage for android.util Log WARN

List of usage examples for android.util Log WARN

Introduction

In this page you can find the example usage for android.util Log WARN.

Prototype

int WARN

To view the source code for android.util Log WARN.

Click Source Link

Document

Priority constant for the println method; use Log.w.

Usage

From source file:com.irccloud.android.fragment.BuffersListFragment.java

public void onIRCEvent(int what, Object obj) {
    BuffersDataSource.Buffer b;//from  w ww. ja v  a 2  s  . co m
    IRCCloudJSONObject object = null;
    try {
        object = (IRCCloudJSONObject) obj;
    } catch (ClassCastException e) {
    }
    EventsDataSource.Event event = null;
    try {
        event = (EventsDataSource.Event) obj;
    } catch (ClassCastException e) {
    }
    switch (what) {
    case NetworkConnection.EVENT_CHANNELMODE:
        b = BuffersDataSource.getInstance().getBuffer(object.bid());
        if (b != null && adapter != null)
            adapter.updateBuffer(b);
        break;
    case NetworkConnection.EVENT_STATUSCHANGED:
        if (adapter != null) {
            ArrayList<BuffersDataSource.Buffer> buffers = BuffersDataSource.getInstance()
                    .getBuffersForServer(object.cid());
            for (BuffersDataSource.Buffer buffer : buffers) {
                adapter.updateBuffer(buffer);
            }
        }
        break;
    case NetworkConnection.EVENT_BUFFERMSG:
        if (adapter != null) {
            if (event.bid != selected_bid) {
                b = BuffersDataSource.getInstance().getBuffer(event.bid);
                if (b != null && event.isImportant(b.type))
                    adapter.updateBuffer(b);
            }
        }
        break;
    case NetworkConnection.EVENT_HEARTBEATECHO:
        if (adapter != null) {
            JsonNode seenEids = object.getJsonNode("seenEids");
            Iterator<Map.Entry<String, JsonNode>> iterator = seenEids.fields();
            int count = 0;
            while (iterator.hasNext()) {
                Map.Entry<String, JsonNode> entry = iterator.next();
                JsonNode eids = entry.getValue();
                Iterator<Map.Entry<String, JsonNode>> j = eids.fields();
                while (j.hasNext()) {
                    Map.Entry<String, JsonNode> eidentry = j.next();
                    Integer bid = Integer.valueOf(eidentry.getKey());
                    b = BuffersDataSource.getInstance().getBuffer(bid);
                    if (b != null)
                        adapter.updateBuffer(b);
                    count++;
                }
            }
            if (count > 1) {
                getActivity().runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        refresh();
                    }
                });
            }
        }
        break;
    case NetworkConnection.EVENT_JOIN:
    case NetworkConnection.EVENT_PART:
    case NetworkConnection.EVENT_QUIT:
    case NetworkConnection.EVENT_KICK:
        if (object.type().startsWith("you_") && getActivity() != null) {
            getActivity().runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    refresh();
                }
            });
        }
        break;
    case NetworkConnection.EVENT_USERINFO:
    case NetworkConnection.EVENT_CHANNELTOPIC:
    case NetworkConnection.EVENT_NICKCHANGE:
    case NetworkConnection.EVENT_MEMBERUPDATES:
    case NetworkConnection.EVENT_USERCHANNELMODE:
    case NetworkConnection.EVENT_AWAY:
    case NetworkConnection.EVENT_SELFBACK:
    case NetworkConnection.EVENT_CHANNELTIMESTAMP:
    case NetworkConnection.EVENT_SELFDETAILS:
    case NetworkConnection.EVENT_USERMODE:
    case NetworkConnection.EVENT_SETIGNORES:
    case NetworkConnection.EVENT_BADCHANNELKEY:
    case NetworkConnection.EVENT_OPENBUFFER:
    case NetworkConnection.EVENT_INVALIDNICK:
    case NetworkConnection.EVENT_BANLIST:
    case NetworkConnection.EVENT_WHOLIST:
    case NetworkConnection.EVENT_WHOIS:
    case NetworkConnection.EVENT_LINKCHANNEL:
    case NetworkConnection.EVENT_LISTRESPONSEFETCHING:
    case NetworkConnection.EVENT_LISTRESPONSE:
    case NetworkConnection.EVENT_LISTRESPONSETOOMANY:
    case NetworkConnection.EVENT_CONNECTIONLAG:
    case NetworkConnection.EVENT_GLOBALMSG:
    case NetworkConnection.EVENT_ACCEPTLIST:
    case NetworkConnection.EVENT_NAMESLIST:
    case NetworkConnection.EVENT_CHANNELTOPICIS:
    case NetworkConnection.EVENT_BACKLOG_FAILED:
    case NetworkConnection.EVENT_FAILURE_MSG:
    case NetworkConnection.EVENT_SUCCESS:
    case NetworkConnection.EVENT_PROGRESS:
    case NetworkConnection.EVENT_ALERT:
    case NetworkConnection.EVENT_DEBUG:
        break;
    case NetworkConnection.EVENT_CONNECTIVITY:
        if (getActivity() != null) {
            getActivity().runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    if (adapter != null)
                        adapter.notifyDataSetChanged();
                }
            });
        }
        break;
    case NetworkConnection.EVENT_BACKLOG_START:
        if (refreshTask != null)
            refreshTask.cancel(true);
        break;
    case NetworkConnection.EVENT_BACKLOG_END:
        ready = true;
        if (obj != null && adapter != null) {
            Integer bid = (Integer) obj;
            b = BuffersDataSource.getInstance().getBuffer(bid);
            if (b != null) {
                adapter.updateBuffer(b);
                break;
            }
        } else {
            if (getActivity() != null) {
                getActivity().runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        if (refreshTask != null)
                            refreshTask.cancel(true);
                        Crashlytics.log(Log.DEBUG, "IRCCloud", "Refreshing buffers list");
                        RefreshTask t = new RefreshTask();
                        t.doInBackground((Void) null);
                        t.onPostExecute(null);
                        Crashlytics.log(Log.DEBUG, "IRCCloud", "Done");
                    }
                });
            }
        }
        break;
    default:
        Crashlytics.log(Log.WARN, "IRCCloud", "Slow event: " + what);
        if (getActivity() != null) {
            getActivity().runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    refresh();
                }
            });
        }
        break;
    }
}

From source file:com.irccloud.android.activity.MainActivity.java

private void setFromIntent(Intent intent) {
    launchBid = -1;/*from  w  ww .ja  v a  2 s  .  c o  m*/
    launchURI = null;

    if (NetworkConnection.getInstance().ready)
        setIntent(new Intent(this, MainActivity.class));

    if (intent.hasExtra("bid")) {
        int new_bid = intent.getIntExtra("bid", 0);
        if (NetworkConnection.getInstance().ready
                && NetworkConnection.getInstance().getState() == NetworkConnection.STATE_CONNECTED
                && BuffersDataSource.getInstance().getBuffer(new_bid) == null) {
            Crashlytics.log(Log.WARN, "IRCCloud", "Invalid bid requested by launch intent: " + new_bid);
            Notifications.getInstance().deleteNotificationsForBid(new_bid);
            if (excludeBIDTask != null)
                excludeBIDTask.cancel(true);
            excludeBIDTask = new ExcludeBIDTask();
            excludeBIDTask.execute(new_bid);
            return;
        } else if (BuffersDataSource.getInstance().getBuffer(new_bid) != null) {
            Crashlytics.log(Log.DEBUG, "IRCCloud", "Found BID, switching buffers");
            if (buffer != null && buffer.bid != new_bid)
                backStack.add(0, buffer.bid);
            buffer = BuffersDataSource.getInstance().getBuffer(new_bid);
            server = ServersDataSource.getInstance().getServer(buffer.cid);
        } else {
            Crashlytics.log(Log.DEBUG, "IRCCloud", "BID not found, will try after reconnecting");
            launchBid = new_bid;
        }
    }

    if (intent.getData() != null && intent.getData().getScheme() != null
            && intent.getData().getScheme().startsWith("irc")) {
        if (open_uri(intent.getData())) {
            return;
        } else {
            launchURI = intent.getData();
            buffer = null;
            server = null;
        }
    } else if (intent.hasExtra("cid")) {
        if (buffer == null) {
            buffer = BuffersDataSource.getInstance().getBufferByName(intent.getIntExtra("cid", 0),
                    intent.getStringExtra("name"));
            if (buffer != null) {
                server = ServersDataSource.getInstance().getServer(intent.getIntExtra("cid", 0));
            }
        }
    }

    if (buffer == null) {
        server = null;
    } else {
        if (intent.hasExtra(Intent.EXTRA_STREAM)) {
            String type = getContentResolver().getType((Uri) intent.getParcelableExtra(Intent.EXTRA_STREAM));
            if (type != null && type.startsWith("image/")
                    && (!NetworkConnection.getInstance().uploadsAvailable()
                            || PreferenceManager.getDefaultSharedPreferences(this)
                                    .getString("image_service", "IRCCloud").equals("imgur"))) {
                new ImgurRefreshTask((Uri) intent.getParcelableExtra(Intent.EXTRA_STREAM)).execute((Void) null);
            } else {
                fileUploadTask = new FileUploadTask((Uri) intent.getParcelableExtra(Intent.EXTRA_STREAM), this);
                fileUploadTask.execute((Void) null);
            }
        }

        if (intent.hasExtra(Intent.EXTRA_TEXT)) {
            if (intent.hasExtra(Intent.EXTRA_SUBJECT))
                buffer.draft = intent.getStringExtra(Intent.EXTRA_SUBJECT) + " ("
                        + intent.getStringExtra(Intent.EXTRA_TEXT) + ")";
            else
                buffer.draft = intent.getStringExtra(Intent.EXTRA_TEXT);
        }
    }

    if (buffer == null) {
        launchBid = intent.getIntExtra("bid", -1);
    } else {
        onBufferSelected(buffer.bid);
    }
}

From source file:eu.faircode.netguard.ServiceSinkhole.java

private void startNative(ParcelFileDescriptor vpn, List<Rule> listAllowed, List<Rule> listRule) {
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ServiceSinkhole.this);
    boolean log = prefs.getBoolean("log", false);
    boolean log_app = prefs.getBoolean("log_app", false);
    boolean filter = prefs.getBoolean("filter", false);

    Log.i(TAG, "Start native log=" + log + "/" + log_app + " filter=" + filter);

    // Prepare rules
    if (filter) {
        prepareUidAllowed(listAllowed, listRule);
        prepareHostsBlocked();/*from w  w w.j a  va  2  s  .  c  o  m*/
        prepareUidIPFilters(null);
        prepareForwarding();
    } else {
        lock.writeLock().lock();
        mapUidAllowed.clear();
        mapUidKnown.clear();
        mapHostsBlocked.clear();
        mapUidIPFilters.clear();
        mapForward.clear();
        lock.writeLock().unlock();
    }

    if (log_app)
        prepareNotify(listRule);
    else {
        lock.writeLock().lock();
        mapNoNotify.clear();
        lock.writeLock().unlock();
    }

    if (log || log_app || filter) {
        int prio = Integer.parseInt(prefs.getString("loglevel", Integer.toString(Log.WARN)));
        int rcode = Integer.parseInt(prefs.getString("rcode", "3"));
        if (prefs.getBoolean("socks5_enabled", false))
            jni_socks5(prefs.getString("socks5_addr", ""),
                    Integer.parseInt(prefs.getString("socks5_port", "0")),
                    prefs.getString("socks5_username", ""), prefs.getString("socks5_password", ""));
        else
            jni_socks5("", 0, "", "");
        jni_start(vpn.getFd(), mapForward.containsKey(53), rcode, prio);
    }
}

From source file:com.irccloud.android.NetworkConnection.java

public void request_backlog(int cid, int bid, long beforeId) {
    try {//from   w  ww . j a  v  a 2s  .co m
        if (oobTasks.containsKey(bid)) {
            Crashlytics.log(Log.WARN, TAG, "Ignoring duplicate backlog request for BID: " + bid);
            return;
        }
        if (session == null || session.length() == 0) {
            Crashlytics.log(Log.WARN, TAG, "Not fetching backlog before session is set");
            return;
        }
        if (Looper.myLooper() == null)
            Looper.prepare();

        OOBIncludeTask task = new OOBIncludeTask(bid);
        oobTasks.put(bid, task);

        if (beforeId > 0)
            task.execute(new URL("https://" + IRCCLOUD_HOST + "/chat/backlog?cid=" + cid + "&bid=" + bid
                    + "&beforeid=" + beforeId));
        else
            task.execute(new URL("https://" + IRCCLOUD_HOST + "/chat/backlog?cid=" + cid + "&bid=" + bid));
    } catch (MalformedURLException e) {
        e.printStackTrace();
    }
}

From source file:com.android.talkback.controller.CursorControllerApp.java

@Override
public void onAccessibilityEvent(AccessibilityEvent event) {
    int eventType = event.getEventType();
    if (eventType == AccessibilityEventCompat.TYPE_VIEW_ACCESSIBILITY_FOCUSED) {
        final AccessibilityNodeInfo node = event.getSource();
        if (node == null) {
            if (LogUtils.LOG_LEVEL <= Log.WARN) {
                Log.w(LOGTAG, "TYPE_VIEW_ACCESSIBILITY_FOCUSED event without a source.");
            }/* w  w w  .  j  av a2 s  . co  m*/
            return;
        }

        // When a new view gets focus, clear the state of the granularity
        // manager if this event came from a different node than the locked
        // node but from the same window.
        final AccessibilityNodeInfoCompat nodeCompat = new AccessibilityNodeInfoCompat(node);
        mGranularityManager.onNodeFocused(nodeCompat);
        if (mSwitchNodeWithGranularityDirection == AccessibilityNodeInfoCompat.ACTION_NEXT_AT_MOVEMENT_GRANULARITY) {
            mGranularityManager.navigate(AccessibilityNodeInfoCompat.ACTION_NEXT_AT_MOVEMENT_GRANULARITY);
        } else if (mSwitchNodeWithGranularityDirection == AccessibilityNodeInfoCompat.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY) {
            mGranularityManager.startFromLastNode();
            mGranularityManager.navigate(AccessibilityNodeInfoCompat.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY);
        }
        mSwitchNodeWithGranularityDirection = 0;
        nodeCompat.recycle();
        mReachedEdge = false;
        mGranularityNavigationReachedEdge = false;
    } else if (eventType == AccessibilityEvent.TYPE_VIEW_FOCUSED) {
        final AccessibilityNodeInfo node = event.getSource();
        if (node != null) {
            final AccessibilityNodeInfoCompat nodeCompat = new AccessibilityNodeInfoCompat(node);

            // Note: we also need to check ROLE_EDIT_TEXT for JB MR1 and lower and for
            // Chrome/WebView 51 and lower. We should check isEditable() first because it's
            // more semantically appropriate for what we want.
            if (nodeCompat.isEditable() || Role.getRole(nodeCompat) == Role.ROLE_EDIT_TEXT) {
                AccessibilityNodeInfoUtils.recycleNodes(mLastEditable);
                mLastEditable = nodeCompat;
            } else {
                nodeCompat.recycle();
            }
        }
    } else if (mIsWindowNavigationAvailable && eventType == AccessibilityEvent.TYPE_WINDOWS_CHANGED) {
        // Remove last focused nodes of non-existing windows.
        Set<Integer> windowIdsToBeRemoved = new HashSet(mLastFocusedNodeMap.keySet());
        for (AccessibilityWindowInfo window : mService.getWindows()) {
            windowIdsToBeRemoved.remove(window.getId());
        }
        for (Integer windowIdToBeRemoved : windowIdsToBeRemoved) {
            AccessibilityNodeInfoCompat removedNode = mLastFocusedNodeMap.remove(windowIdToBeRemoved);
            if (removedNode != null) {
                removedNode.recycle();
            }
        }
    }
}

From source file:com.irccloud.android.NetworkConnection.java

private synchronized void parse_object(IRCCloudJSONObject object) throws JSONException {
    cancel_idle_timer();/*from w w  w  .  j  a v  a2 s. c om*/
    //Log.d(TAG, "Backlog: " + backlog + " New event: " + object);
    if (!object.has("type")) {
        //Log.d(TAG, "Response: " + object);
        if (object.has("success") && !object.getBoolean("success") && object.has("message")) {
            Crashlytics.log(Log.ERROR, TAG, "Error: " + object);
            notifyHandlers(EVENT_FAILURE_MSG, object);
        } else if (object.has("success")) {
            notifyHandlers(EVENT_SUCCESS, object);
        }
        return;
    }
    String type = object.type();
    if (type != null && type.length() > 0) {
        //notifyHandlers(EVENT_DEBUG, "Type: " + type + " BID: " + object.bid() + " EID: " + object.eid());
        //Crashlytics.log("New event: " + type);
        //Log.d(TAG, "New event: " + type);
        Parser p = parserMap.get(type);
        if (p != null) {
            p.parse(object);
        } else if (!parserMap.containsKey(type)) {
            Crashlytics.log(Log.WARN, TAG, "Unhandled type: " + object.type());
            //Log.w(TAG, "Unhandled type: " + object);
        }

        if (backlog || type.equals("backlog_complete")) {
            if ((object.bid() > -1 || type.equals("backlog_complete")) && !type.equals("makebuffer")
                    && !type.equals("channel_init")) {
                currentcount++;
                if (object.bid() != currentBid) {
                    currentBid = object.bid();
                    firstEid = object.eid();
                    currentcount = 0;
                }
            }
            if (numbuffers > 0 && currentcount < 100) {
                notifyHandlers(EVENT_PROGRESS,
                        ((totalbuffers + ((float) currentcount / (float) 100)) / numbuffers) * 1000.0f);
            }
        } else if (accrued > 0) {
            notifyHandlers(EVENT_PROGRESS, ((float) currentcount++ / (float) accrued) * 1000.0f);
        }
    }

    if (!backlog && idle_interval > 0 && accrued < 1)
        schedule_idle_timer();
}