Example usage for android.util Log DEBUG

List of usage examples for android.util Log DEBUG

Introduction

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

Prototype

int DEBUG

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

Click Source Link

Document

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

Usage

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

public void onIRCEvent(int what, Object obj) {
    BuffersDataSource.Buffer b;/*from w ww . j  a  va2s  . c o  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:org.awesomeapp.messenger.ui.ConversationView.java

void scheduleRequery(long interval) {

    if (mRequeryCallback == null) {
        mRequeryCallback = new RequeryCallback();
    } else {// www  .  j  av  a2 s . c o m
        mHandler.removeCallbacks(mRequeryCallback);
    }

    if (Log.isLoggable(ImApp.LOG_TAG, Log.DEBUG)) {
        log("scheduleRequery");
    }
    mHandler.postDelayed(mRequeryCallback, interval);

}

From source file:org.awesomeapp.messenger.ui.ConversationView.java

void cancelRequery() {

    if (mRequeryCallback != null) {
        if (Log.isLoggable(ImApp.LOG_TAG, Log.DEBUG)) {
            log("cancelRequery");
        }//from  w w w . j a  va 2  s  .  c  om
        mHandler.removeCallbacks(mRequeryCallback);
        mRequeryCallback = null;
    }
}

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

private void setFromIntent(Intent intent) {
    launchBid = -1;// w w w .  j ava  2s.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:com.android.calendar.event.EditEventView.java

/**
 * Configures the Calendars spinner. This is only done for new events,
 * because only new events allow you to select a calendar while editing an
 * event./*from w  w  w  .j a v  a 2 s.c  o  m*/
 * <p>
 * We tuck a reference to a Cursor with calendar database data into the
 * spinner, so that we can easily extract calendar-specific values when the
 * value changes (the spinner's onItemSelected callback is configured).
 */
public void setCalendarsCursor(Cursor cursor, boolean userVisible, long selectedCalendarId) {
    // If there are no syncable calendars, then we cannot allow
    // creating a new event.
    mCalendarsCursor = cursor;
    if (cursor == null || cursor.getCount() == 0) {
        // Cancel the "loading calendars" dialog if it exists
        if (mSaveAfterQueryComplete) {
            mLoadingCalendarsDialog.cancel();
        }
        if (!userVisible) {
            return;
        }
        // Create an error message for the user that, when clicked,
        // will exit this activity without saving the event.
        AlertDialog.Builder builder = new AlertDialog.Builder(mActivity);
        builder.setTitle(R.string.no_syncable_calendars).setIconAttribute(android.R.attr.alertDialogIcon)
                .setMessage(R.string.no_calendars_found).setPositiveButton(R.string.add_account, this)
                .setNegativeButton(android.R.string.no, this).setOnCancelListener(this);
        mNoCalendarsDialog = builder.show();
        return;
    }

    int selection;
    if (selectedCalendarId != -1) {
        selection = findSelectedCalendarPosition(cursor, selectedCalendarId);
    } else {
        selection = findDefaultCalendarPosition(cursor);
    }

    // populate the calendars spinner
    CalendarsAdapter adapter = new CalendarsAdapter(mActivity, R.layout.calendars_spinner_item, cursor);
    mCalendarsSpinner.setAdapter(adapter);
    mCalendarsSpinner.setOnItemSelectedListener(this);
    mCalendarsSpinner.setSelection(selection);

    if (mSaveAfterQueryComplete) {
        mLoadingCalendarsDialog.cancel();
        if (prepareForSave() && fillModelFromUI()) {
            int exit = userVisible ? Utils.DONE_EXIT : 0;
            mDone.setDoneCode(Utils.DONE_SAVE | exit);
            mDone.run();
        } else if (userVisible) {
            mDone.setDoneCode(Utils.DONE_EXIT);
            mDone.run();
        } else if (Log.isLoggable(TAG, Log.DEBUG)) {
            Log.d(TAG, "SetCalendarsCursor:Save failed and unable to exit view");
        }
        return;
    }
}

From source file:info.guardianproject.otr.app.im.app.ChatView.java

void registerChatListener() {
    if (Log.isLoggable(ImApp.LOG_TAG, Log.DEBUG)) {
        log("registerChatListener " + mLastChatId);
    }/*  w ww.  j  a v  a2s .  co  m*/
    try {
        if (getChatSession() != null) {
            getChatSession().registerChatListener(mChatListener);
        }

        checkConnection();

        if (mConn != null) {
            IContactListManager listMgr = mConn.getContactListManager();
            listMgr.registerContactListListener(mContactListListener);
        }

    } catch (Exception e) {
        Log.w(ImApp.LOG_TAG, "<ChatView> registerChatListener fail:" + e.getMessage());
    }
}

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

@Override
protected void onNewIntent(Intent intent) {
    if (intent != null) {
        Crashlytics.log(Log.DEBUG, "IRCCloud", "Got new launch intent");
        setFromIntent(intent);/*from w  w w.  j a va 2 s .  c  o  m*/
    }
}

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

@SuppressLint("NewApi")
@Override//w  ww .j  a v  a2  s  .  c  o  m
public void onResume() {
    Crashlytics.log(Log.DEBUG, "IRCCloud", "Resuming app");
    conn = NetworkConnection.getInstance();
    conn.addHandler(this);

    super.onResume();
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
    if (prefs.getBoolean("screenlock", false)) {
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    } else {
        getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    }

    if (conn.getState() != NetworkConnection.STATE_CONNECTED) {
        if (drawerLayout != null && !NetworkConnection.getInstance().ready) {
            drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
            getSupportActionBar().setHomeButtonEnabled(false);
        }
        sendBtn.setEnabled(false);
        if (Build.VERSION.SDK_INT >= 11)
            sendBtn.setAlpha(0.5f);
        if (conn.config == null) {
            photoBtn.setEnabled(false);
            if (Build.VERSION.SDK_INT >= 11)
                photoBtn.setAlpha(0.5f);
        }
        conn.connect(getSharedPreferences("prefs", 0).getString("session_key", ""));
    } else {
        if (drawerLayout != null) {
            drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED);
            getSupportActionBar().setHomeButtonEnabled(true);
        }
        if (messageTxt.getText() != null && messageTxt.getText().length() > 0) {
            sendBtn.setEnabled(true);
            if (Build.VERSION.SDK_INT >= 11)
                sendBtn.setAlpha(1);
        }
        photoBtn.setEnabled(true);
        if (Build.VERSION.SDK_INT >= 11)
            photoBtn.setAlpha(1);
    }

    if (server == null || launchURI != null
            || (getIntent() != null && (getIntent().hasExtra("bid") || getIntent().getData() != null))) {
        if (getIntent() != null && (getIntent().hasExtra("bid") || getIntent().getData() != null)) {
            Crashlytics.log(Log.DEBUG, "IRCCloud", "Launch intent contains a BID or URL");
            setFromIntent(getIntent());
        } else if (conn.getState() == NetworkConnection.STATE_CONNECTED && conn.getUserInfo() != null
                && conn.ready) {
            if (launchURI == null || !open_uri(launchURI)) {
                if (!open_bid(conn.getUserInfo().last_selected_bid)) {
                    if (!open_bid(BuffersDataSource.getInstance().firstBid())) {
                        if (drawerLayout != null && NetworkConnection.getInstance().ready
                                && findViewById(R.id.usersListFragment2) == null)
                            drawerLayout.openDrawer(Gravity.LEFT);
                    }
                }
            }
        }
    } else if (buffer != null) {
        int bid = buffer.bid;
        onBufferSelected(bid);
    }

    updateUsersListFragmentVisibility();
    update_subtitle();

    suggestions = ((MessageViewFragment) getSupportFragmentManager()
            .findFragmentById(R.id.messageViewFragment)).suggestions;
    suggestions.setAdapter(suggestionsAdapter);
    suggestions.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            String nick = suggestionsAdapter.getItem(position);
            String text = messageTxt.getText().toString();

            if (text.lastIndexOf(' ') > 0) {
                messageTxt.setText(text.substring(0, text.lastIndexOf(' ') + 1) + nick + " ");
            } else {
                if (nick.startsWith("#") || text.startsWith(":"))
                    messageTxt.setText(nick + " ");
                else
                    messageTxt.setText(nick + ": ");
            }
            messageTxt.setSelection(messageTxt.getText().length());
        }
    });
    suggestionsContainer = ((MessageViewFragment) getSupportFragmentManager()
            .findFragmentById(R.id.messageViewFragment)).suggestionsContainer;
    update_suggestions(false);

    if (refreshUpIndicatorTask != null)
        refreshUpIndicatorTask.cancel(true);
    refreshUpIndicatorTask = new RefreshUpIndicatorTask();
    refreshUpIndicatorTask.execute((Void) null);

    supportInvalidateOptionsMenu();

    if (NetworkConnection.getInstance().ready && buffer != null) {
        try {
            if (excludeBIDTask != null)
                excludeBIDTask.cancel(true);
            excludeBIDTask = new ExcludeBIDTask();
            excludeBIDTask.execute(buffer.bid);
        } catch (Exception e) {
        }
    }
    sendBtn.setEnabled(messageTxt.getText().length() > 0);
    if (Build.VERSION.SDK_INT >= 11 && messageTxt.getText().length() == 0)
        sendBtn.setAlpha(0.5f);

    if (drawerLayout != null)
        drawerLayout.closeDrawers();

    updateReconnecting();

    if (imgurTask != null)
        imgurTask.setActivity(this);

    if (fileUploadTask != null) {
        fileUploadTask.setActivity(this);
        if (fileUploadTask.metadataDialog == null && !fileUploadTask.filenameSet)
            fileUploadTask.show_dialog();
    }
    messageTxt.clearFocus();
    messageTxt.setEnabled(true);

    if (pastebinResult != null) {
        String text = "";
        String url = pastebinResult.getStringExtra("url");
        String message = pastebinResult.getStringExtra("message");
        if (url != null && url.length() > 0) {
            if (message != null && message.length() > 0)
                text += message + " ";
            text += url;
        } else {
            text = pastebinResult.getStringExtra("paste_contents");
        }
        messageTxt.setText(text);
        SendTask t = new SendTask();
        t.forceText = true;
        t.execute((Void) null);
        pastebinResult = null;
    }
}

From source file:info.guardianproject.otr.app.im.app.ChatView.java

void unregisterChatListener() {
    if (Log.isLoggable(ImApp.LOG_TAG, Log.DEBUG)) {
        log("unregisterChatListener " + mLastChatId);
    }// w w w.  j  a v a2 s.  c o m
    try {
        if (getChatSession() != null) {
            getChatSession().unregisterChatListener(mChatListener);
        }
        checkConnection();

        if (mConn != null) {
            IContactListManager listMgr = mConn.getContactListManager();
            listMgr.unregisterContactListListener(mContactListListener);
        }
    } catch (Exception e) {
        Log.w(ImApp.LOG_TAG, "<ChatView> unregisterChatListener fail:" + e.getMessage());
    }
}

From source file:org.awesomeapp.messenger.ui.ConversationView.java

void registerChatListener() {
    if (Log.isLoggable(ImApp.LOG_TAG, Log.DEBUG)) {
        log("registerChatListener " + mLastChatId);
    }/*from   w ww . j  a va2  s. com*/
    try {
        if (getChatSession() != null) {
            getChatSession().registerChatListener(mChatListener);
        }

        checkConnection();

        if (mConn != null) {
            IContactListManager listMgr = mConn.getContactListManager();
            listMgr.registerContactListListener(mContactListListener);

        }

    } catch (Exception e) {
        Log.w(ImApp.LOG_TAG, "<ChatView> registerChatListener fail:" + e.getMessage());
    }
}