Search in sources :

Example 6 with UiThread

use of android.support.annotation.UiThread in project FastHub by k0shk0sh.

the class AnimHelper method startBeatsAnimation.

@UiThread
public static void startBeatsAnimation(@NonNull View view) {
    view.clearAnimation();
    if (view.getAnimation() != null) {
        view.getAnimation().cancel();
    }
    List<ObjectAnimator> animators = getBeats(view);
    for (ObjectAnimator anim : animators) {
        anim.setDuration(300).start();
        anim.setInterpolator(interpolator);
    }
}
Also used : ObjectAnimator(android.animation.ObjectAnimator) UiThread(android.support.annotation.UiThread)

Example 7 with UiThread

use of android.support.annotation.UiThread in project androidApp by InspectorIncognito.

the class UserFragment method updateUI.

@UiThread
private void updateUI() {
    final TranSappAccount account = TranSappAccountManager.getCurrentAccount();
    if (!TranSappAccountManager.isLoggedIn()) {
        getActivity().finish();
        return;
    }
    progressImage.setProgressValues(account.getScore(), account.getLevelMinScore(), account.getLevelMaxScore());
    progressImage.loadImage(account);
    userName.setText(account.getName());
    level.setText(String.format(Locale.getDefault(), "NIVEL %d", account.getLevelPosition()));
    score.setText(String.format(Locale.getDefault(), "%s de %s ptos", account.getFormattedScore(), account.getFormattedLevelMaxScore()));
    levelName.setText(account.getLevelName());
    levelBackground.setImageResource(account.getLevelBackgroundImage());
    rankingPosition.setText(String.format(Locale.getDefault(), "%d", account.currentUser.globalRankingPosition));
    rankingFrame.setImageResource(account.getLevelSimpleFrame());
    int id = account.getBusAvatarId();
    userBusAvatarView.setAvatarId(id);
    BusAvatar avatar = Avatar.getBusAvatarById(id);
    userBusAvatarTitle.setText(getString(avatar.titleId));
    rankingButton.setClickable(true);
    rankingPosition.setVisibility(View.VISIBLE);
    rankingProgressBar.setVisibility(View.GONE);
    rankingButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            rankingButton.setClickable(false);
            rankingPosition.setVisibility(View.GONE);
            rankingProgressBar.setVisibility(View.VISIBLE);
            RankingRequest request = new RankingRequest(new Request.RequestListener<Pair<ArrayList<TranSappUser>, ArrayList<TranSappUser>>>() {

                @Override
                public void onRequestError() {
                    if (getActivity() == null || getContext() == null) {
                        return;
                    }
                    Toast.makeText(getActivity(), "Ranking no disponible", Toast.LENGTH_SHORT).show();
                    rankingButton.setClickable(true);
                    rankingPosition.setVisibility(View.VISIBLE);
                    rankingProgressBar.setVisibility(View.GONE);
                }

                @Override
                public void onRequestResult(@NonNull Pair<ArrayList<TranSappUser>, ArrayList<TranSappUser>> response) {
                    if (getActivity() == null || getContext() == null) {
                        return;
                    }
                    Intent intent = new Intent(getActivity(), RankingActivity.class);
                    intent.putParcelableArrayListExtra(RankingActivity.TOP_RANKING_KEY, response.first);
                    intent.putParcelableArrayListExtra(RankingActivity.USER_RANKING_KEY, response.second);
                    startActivityForResult(intent, RANKING_ACTIVITY_CODE);
                }
            }, account);
            ServerController.sendRequest(request, null);
        }
    });
}
Also used : TranSappAccount(cl.smartcities.isci.transportinspector.gamification.transappUser.TranSappAccount) ArrayList(java.util.ArrayList) TranSappUser(cl.smartcities.isci.transportinspector.gamification.transappUser.TranSappUser) Intent(android.content.Intent) BusAvatar(cl.smartcities.isci.transportinspector.backend.BusAvatar) ImageView(android.widget.ImageView) View(android.view.View) ActiveBusView(cl.smartcities.isci.transportinspector.drawables.ActiveBusView) TextView(android.widget.TextView) NonNull(android.support.annotation.NonNull) RankingRequest(cl.smartcities.isci.transportinspector.serverConnection.requests.pullRequests.RankingRequest) Pair(android.support.v4.util.Pair) UiThread(android.support.annotation.UiThread)

Example 8 with UiThread

use of android.support.annotation.UiThread in project AndroidLife by CaMnter.

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 9 with UiThread

use of android.support.annotation.UiThread in project Osmand by osmandapp.

the class DownloadActivity method newDownloadIndexes.

@Override
@UiThread
public void newDownloadIndexes() {
    visibleBanner.updateBannerInProgress();
    for (WeakReference<Fragment> ref : fragSet) {
        Fragment f = ref.get();
        if (f instanceof DownloadEvents && f.isAdded()) {
            ((DownloadEvents) f).newDownloadIndexes();
        }
    }
    downloadHasFinished();
}
Also used : DownloadEvents(net.osmand.plus.download.DownloadIndexesThread.DownloadEvents) DialogFragment(android.support.v4.app.DialogFragment) FreeVersionDialogFragment(net.osmand.plus.download.ui.FreeVersionDialogFragment) ActiveDownloadsDialogFragment(net.osmand.plus.download.ui.ActiveDownloadsDialogFragment) Fragment(android.support.v4.app.Fragment) BottomSheetDialogFragment(net.osmand.plus.base.BottomSheetDialogFragment) UpdatesIndexFragment(net.osmand.plus.download.ui.UpdatesIndexFragment) DownloadResourceGroupFragment(net.osmand.plus.download.ui.DownloadResourceGroupFragment) LocalIndexesFragment(net.osmand.plus.download.ui.LocalIndexesFragment) UiThread(android.support.annotation.UiThread)

Example 10 with UiThread

use of android.support.annotation.UiThread in project XposedInstaller by rovo89.

the class StatusInstallerFragment method refreshZipViews.

@UiThread
private void refreshZipViews(View view) {
    LinearLayout zips = (LinearLayout) view.findViewById(R.id.zips);
    zips.removeAllViews();
    TextView tvError = (TextView) view.findViewById(R.id.zips_load_error);
    synchronized (FrameworkZips.class) {
        boolean hasZips = false;
        for (FrameworkZips.Type type : FrameworkZips.Type.values()) {
            hasZips |= addZipViews(getActivity().getLayoutInflater(), zips, type);
        }
        if (!FrameworkZips.hasLoadedOnlineZips()) {
            tvError.setText(R.string.framework_zip_load_failed);
            tvError.setVisibility(View.VISIBLE);
        } else if (!hasZips) {
            tvError.setText(R.string.framework_no_zips);
            tvError.setVisibility(View.VISIBLE);
        } else {
            tvError.setVisibility(View.GONE);
        }
    }
}
Also used : FrameworkZips(de.robv.android.xposed.installer.util.FrameworkZips) TextView(android.widget.TextView) LinearLayout(android.widget.LinearLayout) 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