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;
}
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;
}
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");
}
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"));
}
}
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));
}
Aggregations