Example usage for android.widget ImageView post

List of usage examples for android.widget ImageView post

Introduction

In this page you can find the example usage for android.widget ImageView post.

Prototype

public boolean post(Runnable action) 

Source Link

Document

Causes the Runnable to be added to the message queue.

Usage

From source file:io.intue.kamu.BestNearbyFragment.java

@Override
public void bindCollectionItemView(Context context, View view, int groupId, int indexInGroup, int dataIndex,
        Object tag) {/*from  ww  w  .j a  v a2  s  . c o  m*/
    //        if (mCursor == null || !mCursor.moveToPosition(dataIndex)) {
    //            LOGW(TAG, "Can't bind collection view item, dataIndex=" + dataIndex +
    //                    (mCursor == null ? ": cursor is null" : ": bad data index."));
    //            return;
    //        }

    if (mresult == null) {
        return;
    }
    Venue result = mresult.get(dataIndex);

    final String sessionId = result.getId();
    if (sessionId == null) {
        return;
    }

    // first, read session info from cursor and put it in convenience variables
    final String sessionTitle = result.getName();
    //final String speakerNames = "SessionsQuery.SPEAKER_NAMES";
    //final String sessionAbstract = "SessionsQuery.ABSTRACT";
    //final long sessionStart = 44454544;
    //final long sessionEnd = 334343433;
    //final String roomName = "SessionsQuery.ROOM_NAME";
    int sessionColor = 0;
    sessionColor = sessionColor == 0 ? getResources().getColor(R.color.transparent) : sessionColor;
    //final String snippet = "SessionsQuery.SNIPPET";
    final Spannable styledSnippet = null;
    final boolean starred = false;
    //final String[] tags = "A,B,C".split(",");

    // now let's compute a few pieces of information from the data, which we will use
    // later to decide what to render where
    final boolean hasLivestream = false;
    final long now = UIUtils.getCurrentTime(context);
    final boolean happeningNow = false;

    // text that says "LIVE" if session is live, or empty if session is not live
    //final String liveNowText =  "";

    // get reference to all the views in the layout we will need
    final TextView titleView = (TextView) view.findViewById(R.id.session_title);
    final TextView subtitleView = (TextView) view.findViewById(R.id.session_subtitle);
    final TextView shortSubtitleView = (TextView) view.findViewById(R.id.session_subtitle_short);
    final TextView snippetView = (TextView) view.findViewById(R.id.session_snippet);
    //final TextView abstractView = (TextView) view.findViewById(R.id.session_abstract);
    //final TextView categoryView = (TextView) view.findViewById(R.id.session_category);
    final View boxView = view.findViewById(R.id.info_box);
    final View sessionTargetView = view.findViewById(R.id.session_target);

    if (sessionColor == 0) {
        // use default
        sessionColor = getResources().getColor(R.color.transparent);
    }
    sessionColor = UIUtils.scaleSessionColorToDefaultBG(sessionColor);

    ImageView photoView = (ImageView) view.findViewById(R.id.session_photo_colored);
    if (photoView != null) {
        if (!mPreloader.isDimensSet()) {
            final ImageView finalPhotoView = photoView;
            photoView.post(new Runnable() {
                @Override
                public void run() {
                    mPreloader.setDimens(finalPhotoView.getWidth(), finalPhotoView.getHeight());
                }
            });
        }
        // colored
        photoView.setColorFilter(UIUtils.setColorAlpha(sessionColor, UIUtils.SESSION_PHOTO_SCRIM_ALPHA));
    } else {
        photoView = (ImageView) view.findViewById(R.id.session_photo);
    }
    ((BaseActivity) getActivity()).getLPreviewUtils().setViewName(photoView, "photo_" + sessionId);

    // when we load a photo, it will fade in from transparent so the
    // background of the container must be the session color to avoid a white flash
    ViewParent parent = photoView.getParent();
    if (parent != null && parent instanceof View) {
        ((View) parent).setBackgroundColor(sessionColor);
    } else {
        photoView.setBackgroundColor(sessionColor);
    }

    String photo = result.getPhotoUrl();
    if (!TextUtils.isEmpty(photo)) {
        mImageLoader.loadImage(photo, photoView, true /*crop*/);
    } else {
        // cleaning the (potentially) recycled photoView, in case this session has no photo:
        photoView.setImageDrawable(null);
    }

    // render title
    titleView.setText(sessionTitle == null ? "?" : sessionTitle);

    // render subtitle into either the subtitle view, or the short subtitle view, as available
    if (subtitleView != null) {
        subtitleView.setText(result.getAddress());
    } else if (shortSubtitleView != null) {
        shortSubtitleView.setText(result.getAddress());
    }

    // render category
    //        if (categoryView != null) {
    //            TagMetadata.Tag groupTag = mTagMetadata.getSessionGroupTag(tags);
    //            if (groupTag != null && !Config.Tags.SESSIONS.equals(groupTag.getId())) {
    //                categoryView.setText(groupTag.getName());
    //                categoryView.setVisibility(View.VISIBLE);
    //            } else {
    //                categoryView.setVisibility(View.GONE);
    //            }
    //        }

    // if a snippet view is available, render the session snippet there.
    if (snippetView != null) {
        //if (mIsSearchCursor) {
        // render the search snippet into the snippet view
        snippetView.setText(styledSnippet);
        //            } else {
        //                // render speaker names and abstracts into the snippet view
        //                mBuffer.setLength(0);
        //                if (!TextUtils.isEmpty(speakerNames)) {
        //                    mBuffer.append(speakerNames).append(". ");
        //                }
        //                if (!TextUtils.isEmpty(sessionAbstract)) {
        //                    mBuffer.append(sessionAbstract);
        //                }
        //                snippetView.setText(mBuffer.toString());
        //            }
    }

    //        if (abstractView != null && !mIsSearchCursor) {
    //            // render speaker names and abstracts into the abstract view
    //            mBuffer.setLength(0);
    //            if (!TextUtils.isEmpty(speakerNames)) {
    //                mBuffer.append(speakerNames).append("\n\n");
    //            }
    //            if (!TextUtils.isEmpty(sessionAbstract)) {
    //                mBuffer.append(sessionAbstract);
    //            }
    //            abstractView.setText(mBuffer.toString());
    //        }

    // in expanded mode, the box background color follows the session color
    //if (useExpandedMode()) {
    boxView.setBackgroundColor(sessionColor);
    //}

    // show or hide the "in my schedule" indicator
    view.findViewById(R.id.indicator_in_schedule).setVisibility(starred ? View.VISIBLE : View.INVISIBLE);

    // if we are in condensed mode and this card is the hero card (big card at the top
    // of the screen), set up the message card if necessary.
    if (groupId == HERO_GROUP_ID) {
        // this is the hero view, so we might want to show a message card
        final boolean cardShown = setupMessageCard(view);

        // if this is the wide hero layout, show or hide the card or the session abstract
        // view, as appropriate (they are mutually exclusive).
        final View cardContainer = view.findViewById(R.id.message_card_container_wide);
        final View abstractContainer = view.findViewById(R.id.session_abstract);
        if (cardContainer != null && abstractContainer != null) {
            cardContainer.setVisibility(cardShown ? View.VISIBLE : View.GONE);
            abstractContainer.setVisibility(cardShown ? View.GONE : View.VISIBLE);
            abstractContainer.setBackgroundColor(sessionColor);
        }
    }

    // if this session is live right now, display the "LIVE NOW" icon on top of it
    View liveNowBadge = view.findViewById(R.id.live_now_badge);
    if (liveNowBadge != null) {
        liveNowBadge.setVisibility(happeningNow && hasLivestream ? View.VISIBLE : View.GONE);
    }

    // if this view is clicked, open the session details view
    final View finalPhotoView = photoView;
    sessionTargetView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mCallbacks.onSessionSelected(sessionId, finalPhotoView);
        }
    });

    // animate this card
    //        if (dataIndex > mMaxDataIndexAnimated) {
    //            mMaxDataIndexAnimated = dataIndex;
    //        }
}

From source file:it.configure.imageloader.zoom.PhotoViewAttacher.java

@Override
public final void onFling(float startX, float startY, float velocityX, float velocityY) {
    if (DEBUG) {//from   ww  w .j av  a  2s. co  m
        Log.d(LOG_TAG, "onFling. sX: " + startX + " sY: " + startY + " Vx: " + velocityX + " Vy: " + velocityY);
    }

    ImageView imageView = getImageView();
    if (hasDrawable(imageView)) {
        mCurrentFlingRunnable = new FlingRunnable(imageView.getContext());
        mCurrentFlingRunnable.fling(imageView.getWidth(), imageView.getHeight(), (int) velocityX,
                (int) velocityY);
        imageView.post(mCurrentFlingRunnable);
    }
}

From source file:koma.movieapp.ui.MoviesFragment.java

@Override
public void bindCollectionItemView(Context context, View view, int groupId, int indexInGroup, int dataIndex,
        Object tag) {//  w  w  w  . ja va 2  s.  c  o  m

    if (mMovieList.isEmpty() || mMovieList.get(dataIndex) == null) {
        return;
    }

    Movie movie = mMovieList.get(dataIndex);

    final String movieId = movie.id.toString();

    if (movieId == null)
        return;

    final String movieTitle = movie.title;
    final String movieRating = movie.vote_average.toString();
    final String movieBackdrop = movie.backdrop_path;

    System.out.println("Movie title in BindCollectionItemView: " + movieTitle);

    int movieColor = getResources().getColor(R.color.default_movie_color);
    int darkMovieColor = 0;

    final TextView titleView = (TextView) view.findViewById(R.id.movie_title);

    final View movieTargetView = view.findViewById(R.id.movie_target);

    if (movieColor == 0) {
        movieColor = mDefaultMovieColor;
    }

    darkMovieColor = UIUtils.scaleMovieColorToDefaultBG(movieColor);

    ImageView photoView = (ImageView) view.findViewById(R.id.session_photo_colored);

    if (photoView != null) {
        if (!mPreloader.isDimensSet()) {
            final ImageView finalPhotoView = photoView;
            photoView.post(new Runnable() {
                @Override
                public void run() {
                    mPreloader.setDimens(finalPhotoView.getWidth(), finalPhotoView.getHeight());
                }
            });
        }
        //            // colored filter on the images
        //            photoView.setColorFilter(mNoTrackBranding
        //                    ? new PorterDuffColorFilter(
        //                    getResources().getColor(R.color.no_track_branding_session_tile_overlay),
        //                    PorterDuff.Mode.SRC_ATOP)
        //                    : UIUtils.makeSessionImageScrimColorFilter(darkMovieColor));
    } else {
        photoView = (ImageView) view.findViewById(R.id.session_photo_colored);
    }
    ViewCompat.setTransitionName(photoView, "photo_" + movieId);

    // when we load a photo, it will fade in from transparent so the
    // background of the container must be the session color to avoid a white flash
    ViewParent parent = photoView.getParent();
    if (parent != null && parent instanceof View) {
        ((View) parent).setBackgroundColor(darkMovieColor);
    } else {
        photoView.setBackgroundColor(darkMovieColor);
    }

    // render title

    //titleView.setTextColor(getResources().getColor(R.color.body_text_1_inverse));
    //titleView.setTextColor(getResources().getColor(R.color.body_text_1_inverse));
    //titleView.setBackgroundColor(getResources().getColor(R.color.material_blue_grey_800));
    //titleView.setBackgroundColor(getResources().getColor(R.color.theme_primary));

    titleView.setText(movieTitle == null ? "?" : movieTitle);

    //photoView.setColorFilter(new PorterDuffColorFilter(getResources().getColor(R.color.data_item_background_with_alpha),PorterDuff.Mode.SCREEN));

    // set the images
    if (movieBackdrop != null) {
        mImageLoader.loadImage(Config.TMDB_IMAGE_BASE_URL + "w780" + movieBackdrop, photoView);
    }

    final View finalPhotoView = photoView;
    movieTargetView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mCallbacks.onMovieSelected(movieId, finalPhotoView);
        }
    });

    // animate this card
    if (dataIndex > mMaxDataIndexAnimated) {
        mMaxDataIndexAnimated = dataIndex;
    }

}

From source file:com.homechart.app.commont.imagedetail.PhotoViewAttacher.java

@Override
public void setScale(float scale, float focalX, float focalY, boolean animate) {
    ImageView imageView = getImageView();

    if (null != imageView) {

        if (animate) {
            imageView.post(new AnimatedZoomRunnable(getScale(), scale, focalX, focalY));
        } else {/*from  ww w .j a v a2s .com*/
            mSuppMatrix.setScale(scale, scale, focalX, focalY);
            checkAndDisplayMatrix();
        }
    }
}

From source file:com.yanzhenjie.album.widget.photoview.PhotoViewAttacher.java

@Override
public void setScale(float scale, float focalX, float focalY, boolean animate) {
    ImageView imageView = getImageView();

    if (null != imageView) {
        if (scale < mMinScale || scale > mMaxScale) {
            return;
        }/* w  w  w . ja  v a  2 s. c o  m*/

        if (animate) {
            imageView.post(new AnimatedZoomRunnable(getScale(), scale, focalX, focalY));
        } else {
            mSuppMatrix.setScale(scale, scale, focalX, focalY);
            checkAndDisplayMatrix();
        }
    }
}

From source file:org.thor.base.view.photoView.PhotoViewAttacher.java

@Override
public void onFling(float startX, float startY, float velocityX, float velocityY) {

    ImageView imageView = getImageView();
    mCurrentFlingRunnable = new FlingRunnable(imageView.getContext());
    mCurrentFlingRunnable.fling(getImageViewWidth(imageView), getImageViewHeight(imageView), (int) velocityX,
            (int) velocityY);
    imageView.post(mCurrentFlingRunnable);
}

From source file:com.homechart.app.commont.imagedetail.PhotoViewAttacher.java

@Override
public void onFling(float startX, float startY, float velocityX, float velocityY) {
    ImageView imageView = getImageView();
    mCurrentFlingRunnable = new FlingRunnable(imageView.getContext());
    mCurrentFlingRunnable.fling(getImageViewWidth(imageView), getImageViewHeight(imageView), (int) velocityX,
            (int) velocityY);
    imageView.post(mCurrentFlingRunnable);
}

From source file:com.example.imagegallerydemo.photoview.PhotoViewAttacher.java

@Override
public void onFling(float startX, float startY, float velocityX, float velocityY) {
    if (DEBUG) {/*from www.j  a v  a2  s.  c om*/
        Log.d(LOG_TAG, "onFling. sX: " + startX + " sY: " + startY + " Vx: " + velocityX + " Vy: " + velocityY);
    }
    ImageView imageView = getImageView();
    mCurrentFlingRunnable = new FlingRunnable(imageView.getContext());
    mCurrentFlingRunnable.fling(getImageViewWidth(imageView), getImageViewHeight(imageView), (int) velocityX,
            (int) velocityY);
    imageView.post(mCurrentFlingRunnable);
}

From source file:com.zxj.androidmvvm.common.view.photoview.PhotoViewAttacher.java

@Override
public void onFling(float startX, float startY, float velocityX, float velocityY) {
    if (DEBUG) {/*  ww  w  .  java2  s .  c  o m*/
        ILog.d("onFling. sX: " + startX + " sY: " + startY + " Vx: " + velocityX + " Vy: " + velocityY);
    }
    ImageView imageView = getImageView();
    mCurrentFlingRunnable = new FlingRunnable(imageView.getContext());
    mCurrentFlingRunnable.fling(getImageViewWidth(imageView), getImageViewHeight(imageView), (int) velocityX,
            (int) velocityY);
    imageView.post(mCurrentFlingRunnable);
}

From source file:com.sflib.CustomView.photoview.PhotoViewAttacher.java

@Override
public void onFling(float startX, float startY, float velocityX, float velocityY) {
    if (DEBUG) {/* w  ww  .jav a  2  s  .c  om*/
        L.debug(LOG_TAG,
                "onFling. sX: " + startX + " sY: " + startY + " Vx: " + velocityX + " Vy: " + velocityY);
    }
    ImageView imageView = getImageView();
    mCurrentFlingRunnable = new FlingRunnable(imageView.getContext());
    mCurrentFlingRunnable.fling(getImageViewWidth(imageView), getImageViewHeight(imageView), (int) velocityX,
            (int) velocityY);
    imageView.post(mCurrentFlingRunnable);
}