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:pum.android.project.tools.displayingbitmaps.ImageWorker.java

/**
 * Load an image specified by the data parameter into an ImageView (override
 * {@link pum.android.project.tools.displayingbitmaps.ImageWorker#processBitmap(Object)} to define the processing logic). A memory and
 * disk cache will be used if an {@link ImageCache} has been added using
 * {@link pum.android.project.tools.displayingbitmaps.ImageWorker#addImageCache(android.support.v4.app.FragmentManager, ImageCache.ImageCacheParams)}. If the
 * image is found in the memory cache, it is set immediately, otherwise an {@link AsyncTask}
 * will be created to asynchronously load the bitmap.
 *
 * @param data      The URL of the image to download.
 * @param imageView The ImageView to bind the downloaded image to.
 *//*from w  w w  . j  av  a  2s . com*/
public void loadImage(Object data, ImageView imageView) {
    if (data == null) {
        return;
    }

    BitmapDrawable value = null;

    if (mImageCache != null) {
        value = mImageCache.getBitmapFromMemCache(String.valueOf(data));
    }

    if (value != null) {
        // Bitmap found in memory cache
        imageView.setImageDrawable(value);
    } else if (cancelPotentialWork(data, imageView)) {
        try {
            ViewGroup viewGroup = (ViewGroup) imageView.getParent();
            if (viewGroup instanceof FrameLayout) {
                FrameLayout parent = (FrameLayout) viewGroup;
                View view;
                if ((view = parent.getChildAt(1)) instanceof ProgressBar)
                    view.setVisibility(View.VISIBLE);
            }
        } catch (Exception e) {
            Log.e(getClass().getSimpleName(), "onPostExecute, progressBar not found", e);
        }
        //BEGIN_INCLUDE(execute_background_task)
        final BitmapWorkerTask task = new BitmapWorkerTask(data, imageView);
        final AsyncDrawable asyncDrawable = new AsyncDrawable(mResources, mLoadingBitmap, task);
        imageView.setImageDrawable(asyncDrawable);

        // NOTE: This uses a custom version of AsyncTask that has been pulled from the
        // framework and slightly modified. Refer to the docs at the top of the class
        // for more info on what was changed.
        task.executeOnExecutor(AsyncTask.DUAL_THREAD_EXECUTOR);
        //END_INCLUDE(execute_background_task)
    }
}

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

/**
 * Load an image specified by the data parameter into an ImageView (override
 * {@link ImageWorker#processBitmap(Object)} to define the processing logic). A memory and
 * disk cache will be used if an {@link ImageCache} has been added using
 * {@link ImageWorker#addImageCache(android.support.v4.app.FragmentManager, ImageCache.ImageCacheParams)}. If the
 * image is found in the memory cache, it is set immediately, otherwise an {@link AsyncTask}
 * will be created to asynchronously load the bitmap.
 *
 * @param data      The URL of the image to download.
 * @param imageView The ImageView to bind the downloaded image to.
 */// w  ww.  j av  a2 s.  c o  m
public void loadImage(Object data, ImageView imageView) {
    if (data == null) {
        return;
    }

    BitmapDrawable value = null;

    if (mImageCache != null) {
        value = mImageCache.getBitmapFromMemCache(String.valueOf(data));
    }

    if (value != null) {
        // Bitmap found in memory cache
        imageView.setImageDrawable(value);
    } else if (cancelPotentialWork(data, imageView)) {
        try {
            ViewGroup viewGroup = (ViewGroup) imageView.getParent();
            if (viewGroup instanceof FrameLayout) {
                FrameLayout parent = (FrameLayout) viewGroup;
                View view;
                if ((view = parent.getChildAt(0)) instanceof ProgressBar)
                    view.setVisibility(View.VISIBLE);
            }
        } catch (Exception e) {
            Log.e(getClass().getSimpleName(), "onPostExecute, progressBar not found", e);
        }
        //BEGIN_INCLUDE(execute_background_task)
        final BitmapWorkerTask task = new BitmapWorkerTask(data, imageView);
        final AsyncDrawable asyncDrawable = new AsyncDrawable(mResources, mLoadingBitmap, task);
        imageView.setImageDrawable(asyncDrawable);

        // NOTE: This uses a custom version of AsyncTask that has been pulled from the
        // framework and slightly modified. Refer to the docs at the top of the class
        // for more info on what was changed.
        task.executeOnExecutor(AsyncTask.DUAL_THREAD_EXECUTOR);
        //END_INCLUDE(execute_background_task)
    }
}

From source file:com.retroteam.studio.retrostudio.MeasureEditor.java

/**
 * Assign a note visually and in the project.
 * @param view//from  www .  jav a2  s  . co m
 */
private void paintNote(View view) {
    com.getbase.floatingactionbutton.FloatingActionButton ptool = (com.getbase.floatingactionbutton.FloatingActionButton) findViewById(
            R.id.pencilTool);
    ImageView iview = (ImageView) view;
    Drawable notestatus = iview.getDrawable();
    if (pencil) {
        if (notestatus.getConstantState().equals(ContextCompat
                .getDrawable(getApplicationContext(), R.drawable.note_filled).getConstantState())) {

            //blank all other notes in the column
            TableRow parent = (TableRow) iview.getParent();
            TableLayout layoutparent = (TableLayout) parent.getParent();
            int notedrawlen = layoutparent.getChildCount();
            for (int x = 0; x < notedrawlen; x++) {
                TableRow noterow = (TableRow) layoutparent.getChildAt(x);
                for (int i = 0; i < noterow.getChildCount(); i++) {
                    ImageView note = (ImageView) noterow.getChildAt(i);
                    if (note.getTag(R.id.TAG_COLUMN) == iview.getTag(R.id.TAG_COLUMN)) {
                        note.setImageDrawable(
                                ContextCompat.getDrawable(getApplicationContext(), R.drawable.measure_outline));
                        for (int n = 0; n < filledNotes.size(); n++) {
                            int[] comp = filledNotes.get(n);
                            if (comp[0] == (int) note.getTag(R.id.TAG_ROW)
                                    && comp[1] == (int) note.getTag(R.id.TAG_COLUMN)) {
                                filledNotes.remove(n);
                            }
                        }
                    }
                }
            }
            //set the drawable
            iview.setImageDrawable(
                    ContextCompat.getDrawable(getApplicationContext(), R.drawable.measure_outline));
            filledNotes.remove(
                    new int[] { (int) iview.getTag(R.id.TAG_ROW), (int) iview.getTag(R.id.TAG_COLUMN) });

            // set the other notes to rests
            List<Integer> guiSNAPRange = (List<Integer>) iview.getTag(R.id.TAG_GUISNAPRANGE);
            for (int z = guiSNAPRange.get(0); z <= guiSNAPRange.get(guiSNAPRange.size() - 1); z++) {
                theproject.track(trackNum).measure(measureNum).replace(z, new Note(Note.REST, noteSUB));
            }
        } else {
            //blank all other notes in the column
            TableRow parent = (TableRow) iview.getParent();
            TableLayout layoutparent = (TableLayout) parent.getParent();
            int notedrawlen = layoutparent.getChildCount();
            for (int x = 0; x < notedrawlen; x++) {
                TableRow noterow = (TableRow) layoutparent.getChildAt(x);
                for (int i = 0; i < noterow.getChildCount(); i++) {
                    ImageView note = (ImageView) noterow.getChildAt(i);
                    if (note.getTag(R.id.TAG_COLUMN) == iview.getTag(R.id.TAG_COLUMN)) {
                        note.setImageDrawable(
                                ContextCompat.getDrawable(getApplicationContext(), R.drawable.measure_outline));
                        for (int n = 0; n < filledNotes.size(); n++) {
                            int[] comp = filledNotes.get(n);
                            if (comp[0] == (int) note.getTag(R.id.TAG_ROW)
                                    && comp[1] == (int) note.getTag(R.id.TAG_COLUMN)) {
                                filledNotes.remove(n);
                            }
                        }
                    }
                }
            }
            //set the drawable
            iview.setImageDrawable(ContextCompat.getDrawable(getApplicationContext(), R.drawable.note_filled));
            filledNotes
                    .add(new int[] { (int) iview.getTag(R.id.TAG_ROW), (int) iview.getTag(R.id.TAG_COLUMN) });

            //set the note in the data structure
            double notetype = stringToNoteDouble((String) iview.getTag(R.id.TAG_NOTE));
            List<Integer> guiSNAPRange = (List<Integer>) iview.getTag(R.id.TAG_GUISNAPRANGE);
            for (int z = guiSNAPRange.get(0); z <= guiSNAPRange.get(guiSNAPRange.size() - 1); z++) {
                theproject.track(trackNum).measure(measureNum).replace(z, new Note(notetype, noteSUB));
            }
        }
    }
}

From source file:com.binomed.showtime.android.screen.results.CineShowTimeResultsFragment.java

@Override
public void onClick(View v) {
    ImageView imageViewFav = (ImageView) v;

    ObjectMasterView objectMasterView = (ObjectMasterView) imageViewFav.getParent().getParent();

    boolean isFav = objectMasterView.isFav();
    TheaterBean theaterBean = objectMasterView.getTheaterBean();
    if (isFav) {//w  ww  . j a v a 2s . c  o m
        interaction.getTracker().trackEvent(CineShowtimeCst.ANALYTICS_CATEGORY_RESULT // Category
                , CineShowtimeCst.ANALYTICS_ACTION_INTERACTION // Action
                , CineShowtimeCst.ANALYTICS_LABEL_RESULTS_FAV + 0 // Label
                , 0 // Value
        );
        removeFavorite(theaterBean);
    } else {
        interaction.getTracker().trackEvent(CineShowtimeCst.ANALYTICS_CATEGORY_RESULT // Category
                , CineShowtimeCst.ANALYTICS_ACTION_INTERACTION // Action
                , CineShowtimeCst.ANALYTICS_LABEL_RESULTS_FAV + 1 // Label
                , 0 // Value
        );
        addFavorite(theaterBean);
    }
    objectMasterView.toggleFav();

}

From source file:com.luke.lukef.lukeapp.popups.SubmissionPopup.java

/**
 * Adds imageviews to the categories section of the popup, with the thumbnails of the categories.
 * Dimensions of the parent view can only be retreived once they are drawn, so a
 * GlobalLayoutListener is needed./*from  w w w . jav a  2 s .  c  o m*/
 *
 * @param categories list of categories whose images are to be added to the category list
 */
private void setCategories(List<Category> categories) {
    for (Category c : categories) {
        final ImageView categoryImg = new ImageView(this.mainActivity);
        categoryImg.setImageBitmap(c.getImage());
        final LinearLayout.LayoutParams[] layoutParams = new LinearLayout.LayoutParams[1];
        this.submissionCategoriesLinear.getViewTreeObserver()
                .addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
                    @Override
                    public void onGlobalLayout() {
                        layoutParams[0] = new LinearLayout.LayoutParams(new LinearLayout.LayoutParams(
                                SubmissionPopup.this.submissionCategoriesLinear.getHeight(),
                                SubmissionPopup.this.submissionCategoriesLinear.getHeight()));
                        categoryImg.setLayoutParams(layoutParams[0]);
                        if (categoryImg.getParent() != null) {
                            ((ViewGroup) categoryImg.getParent()).removeView(categoryImg);
                        }
                        SubmissionPopup.this.submissionCategoriesLinear.addView(categoryImg);
                    }
                });
    }
}

From source file:com.ycl.framework.photoview.PhotoViewAttacher.java

@Override
public void onDrag(float dx, float dy) {
    if (mScaleDragDetector.isScaling()) {
        return; // Do not drag if we are already scaling
    }// w w  w.  j a va2  s  . c  o m

    if (DEBUG) {
        LogManager.getLogger().d(LOG_TAG, String.format("onDrag: dx: %.2f. dy: %.2f", dx, dy));
    }

    ImageView imageView = getImageView();
    mSuppMatrix.postTranslate(dx, dy);
    checkAndDisplayMatrix();

    /**
     * Here we decide whether to let the ImageView's parent to start taking
     * over the touch event.
     *
     * First we check whether this function is enabled. We never want the
     * parent to take over if we're scaling. We then check the edge we're
     * on, and the direction of the scroll (i.e. if we're pulling against
     * the edge, aka 'overscrolling', let the parent take over).
     */
    ViewParent parent = imageView.getParent();
    if (mAllowParentInterceptOnEdge && !mScaleDragDetector.isScaling()) {
        if (mScrollEdge == EDGE_BOTH || (mScrollEdge == EDGE_LEFT && dx >= 1f)
                || (mScrollEdge == EDGE_RIGHT && dx <= -1f)) {
            if (null != parent)
                parent.requestDisallowInterceptTouchEvent(false);
        }
    } else {
        if (null != parent) {
            parent.requestDisallowInterceptTouchEvent(true);
        }
    }
}

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

@Override
public void onDrag(float dx, float dy) {
    if (mScaleDragDetector.isScaling()) {
        return; // Do not drag if we are already scaling
    }/*  w  ww. j a  v  a  2  s  . c  om*/

    ImageView imageView = getImageView();
    mSuppMatrix.postTranslate(dx, dy);
    checkAndDisplayMatrix();

    /**
     * Here we decide whether to let the ImageView's parent to start taking
     * over the touch event.
     *
     * First we check whether this function is enabled. We never want the
     * parent to take over if we're scaling. We then check the edge we're
     * on, and the direction of the scroll (i.e. if we're pulling against
     * the edge, aka 'overscrolling', let the parent take over).
     */
    ViewParent parent = imageView.getParent();
    if (mAllowParentInterceptOnEdge && !mScaleDragDetector.isScaling() && !mBlockParentIntercept) {
        if (mScrollEdge == EDGE_BOTH || (mScrollEdge == EDGE_LEFT && dx >= 1f)
                || (mScrollEdge == EDGE_RIGHT && dx <= -1f)) {
            if (null != parent) {
                parent.requestDisallowInterceptTouchEvent(false);
            }
        }
    } else {
        if (null != parent) {
            parent.requestDisallowInterceptTouchEvent(true);
        }
    }
}

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

@Override
public void onDrag(float dx, float dy) {
    if (mScaleDragDetector.isScaling()) {
        return; // Do not drag if we are already scaling
    }//from   w ww  . ja  v  a  2  s  . c om

    if (DEBUG) {
        Log.d(LOG_TAG, String.format("onDrag: dx: %.2f. dy: %.2f", dx, dy));
    }

    ImageView imageView = getImageView();
    mSuppMatrix.postTranslate(dx, dy);
    checkAndDisplayMatrix();

    /**
     * Here we decide whether to let the ImageView's parent to start taking
     * over the touch event.
     *
     * First we check whether this function is enabled. We never want the
     * parent to take over if we're scaling. We then check the edge we're
     * on, and the direction of the scroll (i.e. if we're pulling against
     * the edge, aka 'overscrolling', let the parent take over).
     */
    ViewParent parent = imageView.getParent();
    if (mAllowParentInterceptOnEdge && !mScaleDragDetector.isScaling() && !mBlockParentIntercept) {
        if (mScrollEdge == EDGE_BOTH || (mScrollEdge == EDGE_LEFT && dx >= 1f)
                || (mScrollEdge == EDGE_RIGHT && dx <= -1f)) {
            if (null != parent) {
                parent.requestDisallowInterceptTouchEvent(false);
            }
        }
    } else {
        if (null != parent) {
            parent.requestDisallowInterceptTouchEvent(true);
        }
    }
}

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

@Override
public void onDrag(float dx, float dy) {
    if (mScaleDragDetector.isScaling()) {
        return; // Do not drag if we are already scaling
    }/* www .ja v a 2s  .  c o m*/

    if (DEBUG) {
        ILog.d(String.format("onDrag: dx: %.2f. dy: %.2f", dx, dy));
    }

    ImageView imageView = getImageView();
    mSuppMatrix.postTranslate(dx, dy);
    checkAndDisplayMatrix();

    /**
     * Here we decide whether to let the ImageView's parent to start taking
     * over the touch event.
     *
     * First we check whether this function is enabled. We never want the
     * parent to take over if we're scaling. We then check the edge we're
     * on, and the direction of the scroll (i.e. if we're pulling against
     * the edge, aka 'overscrolling', let the parent take over).
     */
    ViewParent parent = imageView.getParent();
    if (mAllowParentInterceptOnEdge && !mScaleDragDetector.isScaling() && !mBlockParentIntercept) {
        if (mScrollEdge == EDGE_BOTH || (mScrollEdge == EDGE_LEFT && dx >= 1f)
                || (mScrollEdge == EDGE_RIGHT && dx <= -1f)) {
            if (null != parent) {
                parent.requestDisallowInterceptTouchEvent(false);
            }
        }
    } else {
        if (null != parent) {
            parent.requestDisallowInterceptTouchEvent(true);
        }
    }
}

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

@Override
public void onDrag(float dx, float dy) {
    if (mScaleDragDetector.isScaling()) {
        return; // Do not drag if we are already scaling
    }/* w w  w  .  j av a2s  .c  om*/

    if (DEBUG) {
        L.debug(LOG_TAG, String.format("onDrag: dx: %.2f. dy: %.2f", dx, dy));
    }

    ImageView imageView = getImageView();
    mSuppMatrix.postTranslate(dx, dy);
    checkAndDisplayMatrix();

    /**
     * Here we decide whether to let the ImageView's parent to start taking
     * over the touch event.
     *
     * First we check whether this function is enabled. We never want the
     * parent to take over if we're scaling. We then check the edge we're
     * on, and the direction of the scroll (i.e. if we're pulling against
     * the edge, aka 'overscrolling', let the parent take over).
     */
    ViewParent parent = imageView.getParent();
    if (mAllowParentInterceptOnEdge && !mScaleDragDetector.isScaling() && !mBlockParentIntercept) {
        if (mScrollEdge == EDGE_BOTH || (mScrollEdge == EDGE_LEFT && dx >= 1f)
                || (mScrollEdge == EDGE_RIGHT && dx <= -1f)) {
            if (null != parent) {
                parent.requestDisallowInterceptTouchEvent(false);
            }
        }
    } else {
        if (null != parent) {
            parent.requestDisallowInterceptTouchEvent(true);
        }
    }
}