Example usage for android.widget ImageView getParent

List of usage examples for android.widget ImageView getParent

Introduction

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

Prototype

public final ViewParent getParent() 

Source Link

Document

Gets the parent of this view.

Usage

From source file:org.alfresco.mobile.android.application.managers.RenditionManagerImpl.java

private void displayErrorMessage(ImageView iv) {
    if (iv != null && ((ViewGroup) iv.getParent()).findViewById(R.id.preview_message) != null) {
        ((ViewGroup) iv.getParent()).findViewById(R.id.preview_message).setVisibility(View.VISIBLE);
    }//from  w  w  w . ja  va 2 s .  c  o  m
}

From source file:com.ndn.menurandom.ImageDownloader.java

private void hideLoadingProgress(ImageView imageView) {
    FrameLayout frameLayout = (FrameLayout) imageView.getParent();
    ProgressBar progressBar = (ProgressBar) frameLayout.findViewWithTag("pb_imagedownloader");
    progressBar.setVisibility(View.INVISIBLE);
}

From source file:com.ndn.menurandom.ImageDownloader.java

private void showLoadingProgress(ImageView imageView) {
    if (mUseLoadingProgress) {
        FrameLayout frameLayout = (FrameLayout) imageView.getParent();
        ProgressBar progressBar = (ProgressBar) frameLayout.findViewWithTag("pb_imagedownloader");
        progressBar.setVisibility(View.VISIBLE);
    }/*from   ww  w.j a v a2  s. co m*/
}

From source file:pum.android.project.tools.displayingbitmaps.ImageWorker.java

/**
 * Called when the processing is complete and the final drawable should be
 * set on the ImageView./* ww w. j  av  a2 s .  c o  m*/
 *
 * @param imageView
 * @param drawable
 */
private void setImageDrawable(ImageView imageView, Drawable drawable) {
    try {
        ViewGroup viewGroup = (ViewGroup) imageView.getParent();
        if (viewGroup instanceof FrameLayout) {
            FrameLayout parent = (FrameLayout) viewGroup;
            View view;
            if ((view = parent.getChildAt(1)) instanceof ProgressBar)
                parent.removeView(view);
        }
    } catch (Exception e) {
        Log.e(getClass().getSimpleName(), "onPostExecute, progressBar not found", e);
    }

    if (mFadeInBitmap) {
        // Transition drawable with a transparent drawable and the final drawable
        final TransitionDrawable td = new TransitionDrawable(
                new Drawable[] { new ColorDrawable(android.R.color.transparent), drawable });
        // Set background to loading bitmap
        imageView.setBackgroundDrawable(new BitmapDrawable(mResources, mLoadingBitmap));

        imageView.setImageDrawable(td);
        td.startTransition(FADE_IN_TIME);
    } else {
        imageView.setImageDrawable(drawable);
    }
}

From source file:com.ndn.menurandom.ImageDownloader.java

private void makeFrameLayout(ImageView imageView) {
    boolean isExist = false;
    ViewGroup vg = (ViewGroup) imageView.getParent();
    if (vg instanceof FrameLayout) {
        FrameLayout frameLayout = (FrameLayout) vg;
        String tag = (String) frameLayout.getTag();
        if (tag != null && tag.equals("fl_imagedownloader")) {
            isExist = true;// ww  w  .java2s  .c o m
        }
    }

    if (!isExist) {
        int childCount = vg.getChildCount();
        int index = 0;
        while (index < childCount) {
            if (imageView == vg.getChildAt(index)) {
                break;
            }
            index++;
        }
        vg.removeViewAt(index);

        FrameLayout frameLayout = new FrameLayout(vg.getContext().getApplicationContext());
        frameLayout.setTag("fl_imagedownloader");
        ViewGroup.LayoutParams lpImageView = (ViewGroup.LayoutParams) imageView.getLayoutParams();
        frameLayout.setLayoutParams(lpImageView);
        imageView.setLayoutParams(new LayoutParams(lpImageView.width, lpImageView.height));
        frameLayout.setPadding(imageView.getPaddingLeft(), imageView.getPaddingTop(),
                imageView.getPaddingRight(), imageView.getPaddingBottom());
        imageView.setPadding(0, 0, 0, 0);
        frameLayout.addView(imageView);
        vg.addView(frameLayout, index);

        ProgressBar progressBar = new ProgressBar(frameLayout.getContext());
        progressBar.setTag("pb_imagedownloader");
        int leftRightPadding = (imageView.getLayoutParams().width - 50) / 2;
        int topBottomPadding = (imageView.getLayoutParams().height - 50) / 2;
        progressBar.setPadding(leftRightPadding, topBottomPadding, leftRightPadding, topBottomPadding);
        frameLayout.addView(progressBar);

    }
}

From source file:kuta.adrian.cv.displayingbitmaps.ImageWorker.java

/**
 * Called when the processing is complete and the final drawable should be
 * set on the ImageView./*from  www.  ja v a 2  s  .c om*/
 *
 * @param imageView
 * @param drawable
 */
private void setImageDrawable(ImageView imageView, Drawable drawable) {
    try {
        ViewGroup viewGroup = (ViewGroup) imageView.getParent();
        if (viewGroup instanceof FrameLayout) {
            FrameLayout parent = (FrameLayout) viewGroup;
            View view;
            if ((view = parent.getChildAt(0)) instanceof ProgressBar)
                parent.removeView(view);
        }
    } catch (Exception e) {
        Log.e(getClass().getSimpleName(), "onPostExecute, progressBar not found", e);
    }

    if (mFadeInBitmap) {
        // Transition drawable with a transparent drawable and the final drawable
        final TransitionDrawable td = new TransitionDrawable(new Drawable[] {
                new ColorDrawable(ContextCompat.getColor(imageView.getContext(), android.R.color.transparent)),
                drawable });
        // Set background to loading bitmap
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN)
            imageView.setBackgroundDrawable(new BitmapDrawable(mResources, mLoadingBitmap));
        else
            imageView.setBackground(new BitmapDrawable(mResources, mLoadingBitmap));

        imageView.setImageDrawable(td);
        td.startTransition(FADE_IN_TIME);
    } else {
        imageView.setImageDrawable(drawable);
    }
}

From source file:com.tomeokin.lspush.biz.home.CollectionListAdapter.java

private void setExplorers(ViewGroup container, @Nullable List<User> explorers) {
    final Context context = container.getContext();
    // // TODO: 2016/10/8 performance improve
    //container.removeAllViews();
    //for (User explorer : explorers) {
    //    final ImageView avatar =
    //        (ImageView) LayoutInflater.from(context).inflate(R.layout.layout_item_explorer, container, false);
    //    ImageLoader.loadAvatar(context, avatar, explorer.getImage());
    //    container.addView(avatar);
    //}//from   w ww  .  j a  v  a2 s  . co  m

    final int count = container.getChildCount();
    int targetCount = explorers == null ? 0 : explorers.size();
    targetCount = targetCount >= 5 ? 5 : targetCount;
    final LayoutInflater inflater = LayoutInflater.from(context);
    if (count > targetCount) {
        container.removeViews(targetCount, count - targetCount);
    }
    ImageView avatar;
    for (int i = 0; i < targetCount; i++) {
        if (i > count - 1) { // no cache
            avatar = (ImageView) inflater.inflate(R.layout.layout_item_explorer, container, false);
        } else {
            avatar = (ImageView) container.getChildAt(i);
        }
        ImageLoader.loadAvatar(context, avatar, explorers.get(i).getImage());
        if (avatar.getParent() == null) {
            container.addView(avatar);
        }
        avatar.setTag(R.id.avatar_tag_uid, explorers.get(i).getUid());
        avatar.setOnClickListener(mExplorerListener);
    }
}

From source file:im.neon.util.VectorUtils.java

/**
 * Set the call avatar in an imageView./*from   w w w  .  j a  va  2  s .  c o m*/
 *
 * @param context   the context
 * @param session   the session
 * @param imageView the image view
 * @param room      the room
 */
public static void loadCallAvatar(Context context, MXSession session, ImageView imageView, Room room) {
    // sanity check
    if ((null != room) && (null != session) && (null != imageView) && session.isAlive()) {
        // reset the imageView tag
        imageView.setTag(null);

        String callAvatarUrl = room.getCallAvatarUrl();
        String roomId = room.getRoomId();
        String displayName = VectorUtils.getRoomDisplayName(context, session, room);
        int pixelsSide = imageView.getLayoutParams().width;

        // when size < 0, it means that the render graph must compute it
        // so, we search the valid parent view with valid size
        if (pixelsSide < 0) {
            ViewParent parent = imageView.getParent();

            while ((pixelsSide < 0) && (null != parent)) {
                if (parent instanceof View) {
                    View parentAsView = (View) parent;
                    pixelsSide = parentAsView.getLayoutParams().width;
                }
                parent = parent.getParent();
            }
        }

        // if the avatar is already cached, use it
        if (session.getMediasCache().isAvatarThumbnailCached(callAvatarUrl,
                context.getResources().getDimensionPixelSize(R.dimen.profile_avatar_size))) {
            session.getMediasCache().loadAvatarThumbnail(session.getHomeserverConfig(), imageView,
                    callAvatarUrl, context.getResources().getDimensionPixelSize(R.dimen.profile_avatar_size));
        } else {
            Bitmap bitmap = null;

            if (pixelsSide > 0) {
                // get the avatar bitmap.
                bitmap = VectorUtils.createAvatar(VectorUtils.getAvatarColor(roomId),
                        getInitialLetter(displayName), pixelsSide);
            }

            // until the dedicated avatar is loaded.
            session.getMediasCache().loadAvatarThumbnail(session.getHomeserverConfig(), imageView,
                    callAvatarUrl, context.getResources().getDimensionPixelSize(R.dimen.profile_avatar_size),
                    bitmap);
        }
    }
}

From source file:io.v.android.apps.syncslides.NavigateFragment.java

private void setThumbNull(ImageView thumb) {
    thumb.setImageDrawable(null);/*from   www.j  ava2 s .com*/
    // In landscape, the height is dependent on the image size.  Because we don't have an
    // image, assume all of the images are 16:9.  The width is fixed, so we can calculate
    // the expected height.
    if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
        ViewGroup grandparent = (ViewGroup) thumb.getParent().getParent();
        ViewGroup.LayoutParams thumbParams = thumb.getLayoutParams();
        thumbParams.height = (int) ((9 / 16.0) * grandparent.getMeasuredWidth());
    }
}

From source file:dynamite.zafroshops.app.MainActivity.java

public void setRating(View view) {
    ImageView self = (ImageView) view;
    final View main = (View) self.getParent();
    ArrayList<ImageView> imageViews = new ArrayList<ImageView>() {
        {//w  w  w.  java 2  s. c om
            add((ImageView) main.findViewById(R.id.star_1));
            add((ImageView) main.findViewById(R.id.star_2));
            add((ImageView) main.findViewById(R.id.star_3));
            add((ImageView) main.findViewById(R.id.star_4));
            add((ImageView) main.findViewById(R.id.star_5));
        }
    };
    int score = Integer.parseInt((String) self.getTag());

    score = ReviewDialogFragment.rating == score ? 0 : score;
    ReviewDialogFragment.rating = score;
    for (int i = 0; i < imageViews.size(); i++) {
        imageViews.get(i).setImageResource(R.drawable.stare);
    }
    ReviewDialogFragment.rating = score;
    for (int i = 0; i < score; i++) {
        imageViews.get(i).setImageResource(R.drawable.star);
    }
}