Example usage for android.util Log isLoggable

List of usage examples for android.util Log isLoggable

Introduction

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

Prototype

public static native boolean isLoggable(String tag, int level);

Source Link

Document

Checks to see whether or not a log for the specified tag is loggable at the specified level.

Usage

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

void scheduleRequery(long interval) {
    if (mRequeryCallback == null) {
        mRequeryCallback = new RequeryCallback();
    } else {/*from   ww w. j  a v a 2 s .co m*/
        mHandler.removeCallbacks(mRequeryCallback);
    }

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

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

void cancelRequery() {
    if (mRequeryCallback != null) {
        if (Log.isLoggable(ImApp.LOG_TAG, Log.DEBUG)) {
            log("cancelRequery");
        }//  ww w .  j a  va2  s. co  m
        mHandler.removeCallbacks(mRequeryCallback);
        mRequeryCallback = null;
    }
}

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

public void bindChat(long chatId, String address, String name) {
    //log("bind " + this + " " + chatId);

    mLastChatId = chatId;//  w ww .j ava  2 s.c  o m

    setViewType(VIEW_TYPE_CHAT);

    Uri contactUri = ContentUris.withAppendedId(Imps.Contacts.CONTENT_URI, chatId);
    Cursor c = mActivity.getContentResolver().query(contactUri, CHAT_PROJECTION, null, null, null);

    if (c == null)
        return;

    if (!c.moveToFirst()) {
        if (Log.isLoggable(ImApp.LOG_TAG, Log.DEBUG)) {
            log("Failed to query chat: " + chatId);
        }
        mLastChatId = -1;

        c.close();

    } else {

        updateSessionInfo(c);

        if (mRemoteAvatar == null) {
            try {
                mRemoteAvatar = DatabaseUtils.getAvatarFromCursor(c, AVATAR_COLUMN, ImApp.DEFAULT_AVATAR_WIDTH,
                        ImApp.DEFAULT_AVATAR_HEIGHT);
            } catch (Exception e) {
            }

            if (mRemoteAvatar == null) {
                mRemoteAvatar = new RoundedAvatarDrawable(
                        BitmapFactory.decodeResource(mActivity.getResources(), R.drawable.avatar_unknown));

            }

            updatePresenceDisplay();

        }

        if (mRemoteHeader == null) {
            try {
                mRemoteHeader = DatabaseUtils.getHeaderImageFromCursor(c, AVATAR_COLUMN,
                        ImApp.DEFAULT_AVATAR_WIDTH, ImApp.DEFAULT_AVATAR_HEIGHT);
            } catch (Exception e) {
            }
        }

        c.close();

        mCurrentChatSession = getChatSession();

        if (mCurrentChatSession == null)
            mCurrentChatSession = createChatSession();

        if (mCurrentChatSession != null) {
            isServiceUp = true;

        }

        updateChat();

        if (mRemoteNickname == null)
            if (TextUtils.isEmpty(name))
                setGroupTitle();
            else
                mRemoteNickname = name;

        try {
            mRemoteNickname = mRemoteNickname.split("@")[0].split("\\.")[0];
        } catch (Exception e) {
            //handle glitches in unicode nicknames
        }
    }

}

From source file:com.android.providers.contacts.ContactsSyncAdapter.java

protected void savePhoto(long person, InputStream photoInput, String photoVersion) throws IOException {
    try {/*  ww w.  ja  v a 2  s  . c  o m*/
        ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
        byte[] data = new byte[1024];
        while (true) {
            int bytesRead = photoInput.read(data);
            if (bytesRead < 0)
                break;
            byteStream.write(data, 0, bytesRead);
        }

        ContentValues values = new ContentValues();
        // we have to include this here otherwise the provider will set it to 1
        values.put(Photos._SYNC_DIRTY, 0);
        values.put(Photos.LOCAL_VERSION, photoVersion);
        values.put(Photos.DATA, byteStream.toByteArray());
        Uri photoUri = Uri.withAppendedPath(People.CONTENT_URI, "" + person + "/" + Photos.CONTENT_DIRECTORY);
        if (getContext().getContentResolver().update(photoUri, values, "_sync_dirty=0", null) > 0) {
            if (Log.isLoggable(TAG, Log.VERBOSE)) {
                Log.v(TAG, "savePhoto: updated " + photoUri + " with values " + values);
            }
        } else {
            Log.e(TAG, "savePhoto: update of " + photoUri + " with values " + values + " affected no rows");
        }
    } finally {
        try {
            if (photoInput != null)
                photoInput.close();
        } catch (IOException e) {
            // we don't care about exceptions here
        }
    }
}

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

public void bindInvitation(long invitationId) {
    Uri uri = ContentUris.withAppendedId(Imps.Invitation.CONTENT_URI, invitationId);
    ContentResolver cr = mActivity.getContentResolver();
    Cursor cursor = cr.query(uri, INVITATION_PROJECT, null, null, null);
    try {/*  w  w  w.  j  a v a2  s.c  o  m*/
        if (!cursor.moveToFirst()) {
            if (Log.isLoggable(ImApp.LOG_TAG, Log.DEBUG)) {
                log("Failed to query invitation: " + invitationId);
            }
            //  mNewChatActivity.finish();
        } else {
            setViewType(VIEW_TYPE_INVITATION);

            mInvitationId = cursor.getLong(INVITATION_ID_COLUMN);
            mProviderId = cursor.getLong(INVITATION_PROVIDER_COLUMN);
            String sender = cursor.getString(INVITATION_SENDER_COLUMN);

            TextView mInvitationText = (TextView) mActivity.findViewById(R.id.txtInvitation);
            mInvitationText.setText(mContext.getString(R.string.invitation_prompt, sender));
            //  mNewChatActivity.setTitle(mContext.getString(R.string.chat_with, sender));
        }
    } finally {
        cursor.close();
    }

}

From source file:com.android.providers.contacts.ContactsSyncAdapter.java

public static void updateSubscribedFeeds(ContentResolver cr, String account) {
    Set<String> feedsToSync = Sets.newHashSet();
    feedsToSync.add(getGroupsFeedForAccount(account));
    addContactsFeedsToSync(cr, account, feedsToSync);

    Cursor c = SubscribedFeeds.Feeds.query(cr, sSubscriptionProjection,
            SubscribedFeeds.Feeds.AUTHORITY + "=? AND " + SubscribedFeeds.Feeds._SYNC_ACCOUNT + "=?",
            new String[] { Contacts.AUTHORITY, account }, null);
    try {/*w w  w  .j a  va 2s  .  c  om*/
        if (Log.isLoggable(TAG, Log.VERBOSE)) {
            Log.v(TAG, "scanning over subscriptions with authority " + Contacts.AUTHORITY + " and account "
                    + account);
        }
        c.moveToNext();
        while (!c.isAfterLast()) {
            String feedInCursor = c.getString(1);
            if (feedsToSync.contains(feedInCursor)) {
                feedsToSync.remove(feedInCursor);
                c.moveToNext();
            } else {
                c.deleteRow();
            }
        }
        c.commitUpdates();
    } finally {
        c.close();
    }

    // any feeds remaining in feedsToSync need a subscription
    for (String feed : feedsToSync) {
        SubscribedFeeds.addFeed(cr, feed, account, Contacts.AUTHORITY, ContactsClient.SERVICE);

        // request a sync of this feed
        Bundle extras = new Bundle();
        extras.putString(ContentResolver.SYNC_EXTRAS_ACCOUNT, account);
        extras.putString("feed", feed);
        cr.startSync(Contacts.CONTENT_URI, extras);
    }
}

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

void scheduleRequery(long interval) {

    if (mRequeryCallback == null) {
        mRequeryCallback = new RequeryCallback();
    } else {//w ww.j  a  va  2s. 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 ww w.  j  a v  a 2 s.  c om*/
        mHandler.removeCallbacks(mRequeryCallback);
        mRequeryCallback = null;
    }
}

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.//w ww  . j av a2  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 w  w . ja va 2  s. c  o 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());
    }
}