Search in sources :

Example 16 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)

Example 17 with UiThread

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

the class HomeActivity method showUserInfo.

@UiThread
protected void showUserInfo(Person p) {
    ImageView iv = navigationView.getHeaderView(0).findViewById(R.id.pro);
    String url = mUrlGenerator.getPersonImageUrl(p.getPersonid());
    Glide.with(this).load(url).apply(RequestOptions.circleCropTransform()).into(iv);
    mUserName.setText(p.getFullname());
    mUserEmail.setText(p.getEmail());
}
Also used : ImageView(android.widget.ImageView) UiThread(android.support.annotation.UiThread)

Example 18 with UiThread

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

the class LoginActivity method redirectToHome.

@UiThread
private void redirectToHome() {
    Intent mHome = new Intent(this, HomeActivity.class);
    startActivity(mHome);
    this.finish();
}
Also used : Intent(android.content.Intent) UiThread(android.support.annotation.UiThread)

Example 19 with UiThread

use of android.support.annotation.UiThread in project SmoothProgressBar by castorflex.

the class SmoothProgressDrawable method drawStrokes.

@UiThread
private void drawStrokes(Canvas canvas) {
    if (mReversed) {
        canvas.translate(mBounds.width(), 0);
        canvas.scale(-1, 1);
    }
    float prevValue = 0f;
    int boundsWidth = mBounds.width();
    if (mMirrorMode)
        boundsWidth /= 2;
    int width = boundsWidth + mSeparatorLength + mSectionsCount;
    int centerY = mBounds.centerY();
    float xSectionWidth = 1f / mSectionsCount;
    float startX;
    float endX;
    float firstX = 0;
    float lastX = 0;
    float prev;
    float end;
    float spaceLength;
    float xOffset;
    float ratioSectionWidth;
    float sectionWidth;
    float drawLength;
    int currentIndexColor = mColorsIndex;
    if (mStartSection == mCurrentSections && mCurrentSections == mSectionsCount) {
        firstX = canvas.getWidth();
    }
    for (int i = 0; i <= mCurrentSections; ++i) {
        xOffset = xSectionWidth * i + mCurrentOffset;
        prev = Math.max(0f, xOffset - xSectionWidth);
        ratioSectionWidth = Math.abs(mInterpolator.getInterpolation(prev) - mInterpolator.getInterpolation(Math.min(xOffset, 1f)));
        sectionWidth = (int) (width * ratioSectionWidth);
        if (sectionWidth + prev < width)
            spaceLength = Math.min(sectionWidth, mSeparatorLength);
        else
            spaceLength = 0f;
        drawLength = sectionWidth > spaceLength ? sectionWidth - spaceLength : 0;
        end = prevValue + drawLength;
        if (end > prevValue && i >= mStartSection) {
            float xFinishingOffset = mInterpolator.getInterpolation(Math.min(mFinishingOffset, 1f));
            startX = Math.max(xFinishingOffset * width, Math.min(boundsWidth, prevValue));
            endX = Math.min(boundsWidth, end);
            drawLine(canvas, boundsWidth, startX, centerY, endX, centerY, currentIndexColor);
            if (i == mStartSection) {
                // first loop
                firstX = startX - mSeparatorLength;
            }
        }
        if (i == mCurrentSections) {
            // because we want to keep the separator effect
            lastX = prevValue + sectionWidth;
        }
        prevValue = end + spaceLength;
        currentIndexColor = incrementColor(currentIndexColor);
    }
    drawBackgroundIfNeeded(canvas, firstX, lastX);
}
Also used : Paint(android.graphics.Paint) UiThread(android.support.annotation.UiThread)

Example 20 with UiThread

use of android.support.annotation.UiThread in project material-dialogs by afollestad.

the class MaterialDialog method setIconAttribute.

@SuppressWarnings("unused")
@UiThread
public void setIconAttribute(@AttrRes int attrId) {
    Drawable d = DialogUtils.resolveDrawable(builder.context, attrId);
    setIcon(d);
}
Also used : Drawable(android.graphics.drawable.Drawable) 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