Search in sources :

Example 21 with UiThread

use of android.support.annotation.UiThread in project Signal-Android by WhisperSystems.

the class IdentityUtil method getRemoteIdentityKey.

@UiThread
public static ListenableFuture<Optional<IdentityKey>> getRemoteIdentityKey(final Context context, final MasterSecret masterSecret, final Recipient recipient) {
    final SettableFuture<Optional<IdentityKey>> future = new SettableFuture<>();
    new AsyncTask<Recipient, Void, Optional<IdentityKey>>() {

        @Override
        protected Optional<IdentityKey> doInBackground(Recipient... recipient) {
            SessionStore sessionStore = new TextSecureSessionStore(context, masterSecret);
            SignalProtocolAddress axolotlAddress = new SignalProtocolAddress(recipient[0].getNumber(), SignalServiceAddress.DEFAULT_DEVICE_ID);
            SessionRecord record = sessionStore.loadSession(axolotlAddress);
            if (record == null) {
                return Optional.absent();
            }
            return Optional.fromNullable(record.getSessionState().getRemoteIdentityKey());
        }

        @Override
        protected void onPostExecute(Optional<IdentityKey> result) {
            future.set(result);
        }
    }.execute(recipient);
    return future;
}
Also used : SettableFuture(org.thoughtcrime.securesms.util.concurrent.SettableFuture) IdentityKey(org.whispersystems.libsignal.IdentityKey) Optional(org.whispersystems.libsignal.util.guava.Optional) Recipient(org.thoughtcrime.securesms.recipients.Recipient) TextSecureSessionStore(org.thoughtcrime.securesms.crypto.storage.TextSecureSessionStore) SessionStore(org.whispersystems.libsignal.state.SessionStore) TextSecureSessionStore(org.thoughtcrime.securesms.crypto.storage.TextSecureSessionStore) SignalProtocolAddress(org.whispersystems.libsignal.SignalProtocolAddress) SessionRecord(org.whispersystems.libsignal.state.SessionRecord) UiThread(android.support.annotation.UiThread)

Example 22 with UiThread

use of android.support.annotation.UiThread in project butterknife by JakeWharton.

the class Utils method getTintedDrawable.

// Implicit synchronization for use of shared resource VALUE.
@UiThread
public static Drawable getTintedDrawable(Context context, @DrawableRes int id, @AttrRes int tintAttrId) {
    boolean attributeFound = context.getTheme().resolveAttribute(tintAttrId, VALUE, true);
    if (!attributeFound) {
        throw new Resources.NotFoundException("Required tint color attribute with name " + context.getResources().getResourceEntryName(tintAttrId) + " and attribute ID " + tintAttrId + " was not found.");
    }
    Drawable drawable = ContextCompat.getDrawable(context, id);
    drawable = DrawableCompat.wrap(drawable.mutate());
    int color = ContextCompat.getColor(context, VALUE.resourceId);
    DrawableCompat.setTint(drawable, color);
    return drawable;
}
Also used : Drawable(android.graphics.drawable.Drawable) UiThread(android.support.annotation.UiThread)

Example 23 with UiThread

use of android.support.annotation.UiThread in project butterknife by JakeWharton.

the class Utils method getFloat.

// Implicit synchronization for use of shared resource VALUE.
@UiThread
public static float getFloat(Context context, @DimenRes int id) {
    TypedValue value = VALUE;
    context.getResources().getValue(id, value, true);
    if (value.type == TypedValue.TYPE_FLOAT) {
        return value.getFloat();
    }
    throw new Resources.NotFoundException("Resource ID #0x" + Integer.toHexString(id) + " type #0x" + Integer.toHexString(value.type) + " is not valid");
}
Also used : TypedValue(android.util.TypedValue) UiThread(android.support.annotation.UiThread)

Example 24 with UiThread

use of android.support.annotation.UiThread in project bugzy by cpunq.

the class CaseDetailsFragment method showCaseDetails.

@UiThread
protected void showCaseDetails(Case aCase) {
    mCase = aCase;
    showContent();
    showActionButtons(mCase);
    List<CaseEvent> evs = mCase.getCaseevents();
    if (evs != null) {
        mAdapter.setData(evs);
        mAdapter.notifyDataSetChanged();
    }
    mBugId.setText(String.valueOf(mCase.getIxBug()));
    mBugTitle.setText(String.valueOf(mCase.getTitle()));
    mAssignedTo.setText(String.valueOf(mCase.getPersonAssignedTo()));
    mRequiredMerge.setText(mCase.getRequiredMergeIn());
    if (!TextUtils.isEmpty(mCase.getFixFor())) {
        mMileStone.setText(String.valueOf(mCase.getFixFor()));
    }
    mActiveStatus.setText(String.valueOf(mCase.getStatus()));
    Case bug = mCase;
    if (bug.getPriority() <= 3) {
        mPriorityIndicator.setBackgroundColor(Color.parseColor("#e74c3c"));
    } else if (bug.getPriority() == 4) {
        mPriorityIndicator.setBackgroundColor(Color.parseColor("#95a5a6"));
    } else if (bug.getPriority() == 5) {
        mPriorityIndicator.setBackgroundColor(Color.parseColor("#ddb65b"));
    } else if (bug.getPriority() <= 7) {
        mPriorityIndicator.setBackgroundColor(Color.parseColor("#bdc3c7"));
    } else {
        mPriorityIndicator.setBackgroundColor(Color.parseColor("#ecf0f1"));
    }
}
Also used : CaseEvent(com.bluestacks.bugzy.data.model.CaseEvent) Case(com.bluestacks.bugzy.data.model.Case) UiThread(android.support.annotation.UiThread)

Example 25 with UiThread

use of android.support.annotation.UiThread in project bugzy by cpunq.

the class HomeActivity method showFilters.

@UiThread
private void showFilters(List<Filter> filters) {
    showContent();
    if (mFilters != null) {
        // Filters already present, clear the list and add new
        removeFiltersFromNavigationView();
    // Removed
    }
    mFilters = filters;
    int defaultItemId = prepareNavHelperData(filters);
    mHomeNavItemId = defaultItemId;
    // Unlock the drawer
    mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED);
    if (mCurrentFragment != null) {
        /**
         * This can happen in case of an orientation change or when user navigates
         * back to this activity. The currently active fragment will call
         * {@link #onFragmentsActivityCreated(Fragment, String, String)} before the
         * filters get loaded.
         * And hence, we won't go forward to select the default fragment
         */
        String tag = mCurrentFragment.getTag();
        if (mNavItemTagMap.containsKey(tag)) {
            navigationView.getMenu().findItem(mNavItemTagMap.get(tag)).setChecked(true);
        }
        // If there already is a selected Fragment, don't select a new one
        return;
    }
    // Set default fragment
    MenuItem mi = navigationView.getMenu().findItem(defaultItemId);
    mHomeNavItemId = mi.getItemId();
    onNavigationItemSelected(mi.setChecked(true));
}
Also used : MenuItem(android.view.MenuItem) UiThread(android.support.annotation.UiThread)

Aggregations

UiThread (android.support.annotation.UiThread)48 View (android.view.View)9 ObjectAnimator (android.animation.ObjectAnimator)6 Animator (android.animation.Animator)5 Drawable (android.graphics.drawable.Drawable)5 ImageView (android.widget.ImageView)5 TextView (android.widget.TextView)5 ArrayList (java.util.ArrayList)5 Intent (android.content.Intent)4 Fragment (android.support.v4.app.Fragment)4 MenuItem (android.view.MenuItem)4 ViewPropertyAnimator (android.view.ViewPropertyAnimator)4 Paint (android.graphics.Paint)3 Rect (android.graphics.Rect)3 DialogFragment (android.support.v4.app.DialogFragment)3 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)2 Location (android.location.Location)2 Bundle (android.os.Bundle)2 AlertDialog (android.support.v7.app.AlertDialog)2 RecyclerView (android.support.v7.widget.RecyclerView)2