Example usage for android.widget ImageView getContext

List of usage examples for android.widget ImageView getContext

Introduction

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

Prototype

@ViewDebug.CapturedViewProperty
public final Context getContext() 

Source Link

Document

Returns the context the view is running in, through which it can access the current theme, resources, etc.

Usage

From source file:com.huyn.demogroup.freechild.FixedViewAttacher.java

public FixedViewAttacher(ImageView imageView) {
    mImageView = imageView;/*from  w w w  . ja  v  a 2 s.c om*/

    if (imageView.isInEditMode()) {
        return;
    }

    View parent = (View) mImageView.getParent();
    parent.setOnTouchListener(this);
    parent.addOnLayoutChangeListener(this);

    // Create Gesture Detectors...
    mScaleDragDetector = new CustomGestureDetector(imageView.getContext(), this);

    mGestureDetector = new GestureDetector(imageView.getContext(),
            new GestureDetector.SimpleOnGestureListener() {

                @Override
                public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
                    if (mSingleFlingListener != null) {
                        if (getScale() > DEFAULT_MIN_SCALE) {
                            return false;
                        }

                        if (MotionEventCompat.getPointerCount(e1) > SINGLE_TOUCH
                                || MotionEventCompat.getPointerCount(e2) > SINGLE_TOUCH) {
                            return false;
                        }

                        return mSingleFlingListener.onFling(e1, e2, velocityX, velocityY);
                    }
                    return false;
                }
            });
}

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  a va  2 s .  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:com.benefit.buy.library.http.query.callback.BitmapAjaxCallback.java

private void presetBitmap(String url, ImageView v) {
    if (!url.equals(v.getTag(Constants.TAG_URL)) || (preset != null)) {
        v.setTag(Constants.TAG_URL, url);
        if ((preset != null) && !cacheAvailable(v.getContext())) {
            setBitmap(url, v, preset, true);
        } else {/*from  www.  ja va 2  s . c o m*/
            setBitmap(url, v, null, true);
        }
    }
}

From source file:com.appbase.androidquery.callback.BitmapAjaxCallback.java

private static void setBmAnimate(ImageView iv, Bitmap bm, Bitmap preset, int fallback, int animation,
        float ratio, float anchor, int source) {

    bm = filter(iv, bm, fallback);/*from www.  ja  v a 2 s. c  o m*/
    if (bm == null) {
        iv.setImageBitmap(null);
        return;
    }

    Drawable d = makeDrawable(iv, bm, ratio, anchor);
    Animation anim = null;

    if (fadeIn(animation, source)) {
        if (preset == null) {
            anim = new AlphaAnimation(0, 1);
            anim.setInterpolator(new DecelerateInterpolator());
            anim.setDuration(FADE_DUR);
        } else {

            Drawable pd = makeDrawable(iv, preset, ratio, anchor);
            Drawable[] ds = new Drawable[] { pd, d };
            TransitionDrawable td = new TransitionDrawable(ds);
            td.setCrossFadeEnabled(true);
            td.startTransition(FADE_DUR);
            d = td;
        }
    } else if (animation > 0) {
        anim = AnimationUtils.loadAnimation(iv.getContext(), animation);
    }

    iv.setImageDrawable(d);

    if (anim != null) {
        anim.setStartTime(AnimationUtils.currentAnimationTimeMillis());
        iv.startAnimation(anim);
    } else {
        iv.setAnimation(null);
    }
}

From source file:com.landenlabs.all_devtool.IconBaseFragment.java

/**
 * Show 'AnimationDrawable'  information
 *
 * @param imageView//from  www .j  a  v  a 2  s .  co  m
 * @param animationDrawable
 * @param row1
 * @param row2
 */
private void showAnimationBtns(final ImageView imageView, final AnimationDrawable animationDrawable,
        TableRow row1, TableRow row2) {

    int[] imageResIds = new int[] { android.R.drawable.ic_media_pause, android.R.drawable.ic_media_play
            // , android.R.drawable.ic_media_next
    };

    String[] descBtns = new String[] { "Pause", "Play"
            // , "Next"
    };

    ImageButton btnImage;
    TextView btnDesc;

    for (int idx = 0; idx < imageResIds.length; idx++) {

        btnImage = new ImageButton(imageView.getContext());
        btnImage.setTag(Integer.valueOf(idx));

        btnImage.setImageResource(imageResIds[idx]);
        btnImage.setPadding(10, 10, 10, 10);
        btnImage.setMinimumHeight(8);
        btnImage.setMinimumWidth(8);
        btnImage.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                int n = (Integer) v.getTag();
                switch (n) {
                case 0: // pause
                    animationDrawable.stop();
                    break;
                case 1: // play
                    animationDrawable.stop();
                    animationDrawable.start();
                    break;
                case 2: // next
                    break;
                }

            }
        });

        row1.addView(btnImage);

        btnDesc = new TextView(imageView.getContext());
        btnDesc.setText(descBtns[idx]);
        btnDesc.setTextSize(12);
        btnDesc.setGravity(Gravity.CENTER);
        row2.addView(btnDesc);
    }

    // Can't start now - icon not fully rendered, see onChangeFocus
    // animationDrawable.stop();
    // animationDrawable.start();

}

From source file:com.androidinspain.deskclock.timer.TimerFragment.java

@Override
public void onFabClick(@NonNull ImageView fab) {
    if (mCurrentView == mTimersView) {
        final Timer timer = getTimer();

        // If no timer is currently showing a fab action is meaningless.
        if (timer == null) {
            return;
        }/*from w  w w . j a v a  2  s  . co m*/

        final Context context = fab.getContext();
        final long currentTime = timer.getRemainingTime();

        switch (timer.getState()) {
        case RUNNING:
            DataModel.getDataModel().pauseTimer(timer);
            Events.sendTimerEvent(com.androidinspain.deskclock.R.string.action_stop,
                    com.androidinspain.deskclock.R.string.label_deskclock);
            if (currentTime > 0) {
                mTimersView.announceForAccessibility(TimerStringFormatter.formatString(context,
                        com.androidinspain.deskclock.R.string.timer_accessibility_stopped, currentTime, true));
            }
            break;
        case PAUSED:
        case RESET:
            DataModel.getDataModel().startTimer(timer);
            Events.sendTimerEvent(com.androidinspain.deskclock.R.string.action_start,
                    com.androidinspain.deskclock.R.string.label_deskclock);
            if (currentTime > 0) {
                mTimersView.announceForAccessibility(TimerStringFormatter.formatString(context,
                        com.androidinspain.deskclock.R.string.timer_accessibility_started, currentTime, true));
            }
            break;
        case MISSED:
        case EXPIRED:
            DataModel.getDataModel().resetOrDeleteTimer(timer,
                    com.androidinspain.deskclock.R.string.label_deskclock);
            break;
        }

    } else if (mCurrentView == mCreateTimerView) {
        mCreatingTimer = true;
        try {
            // Create the new timer.
            final long timerLength = mCreateTimerView.getTimeInMillis();
            final Timer timer = DataModel.getDataModel().addTimer(timerLength, "", false);
            Events.sendTimerEvent(com.androidinspain.deskclock.R.string.action_create,
                    com.androidinspain.deskclock.R.string.label_deskclock);

            // Start the new timer.
            DataModel.getDataModel().startTimer(timer);
            Events.sendTimerEvent(com.androidinspain.deskclock.R.string.action_start,
                    com.androidinspain.deskclock.R.string.label_deskclock);

            // Display the freshly created timer view.
            mViewPager.setCurrentItem(0);
        } finally {
            mCreatingTimer = false;
        }

        // Return to the list of timers.
        animateToView(mTimersView, null, true);
    }
}

From source file:com.huyn.demogroup.leaveblank.PhotoViewAttacher.java

public PhotoViewAttacher(ImageView imageView) {
    mImageView = imageView;//from w w w .java2s  . co  m
    imageView.setOnTouchListener(this);
    imageView.addOnLayoutChangeListener(this);

    if (imageView.isInEditMode()) {
        return;
    }

    mBaseRotation = 0.0f;

    // Create Gesture Detectors...
    mScaleDragDetector = new CustomGestureDetector(imageView.getContext(), this);

    mGestureDetector = new GestureDetector(imageView.getContext(),
            new GestureDetector.SimpleOnGestureListener() {

                // forward long click listener
                @Override
                public void onLongPress(MotionEvent e) {
                    if (mLongClickListener != null) {
                        mLongClickListener.onLongClick(mImageView);
                    }
                }

                @Override
                public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
                    if (mSingleFlingListener != null) {
                        if (getScale() > DEFAULT_MIN_SCALE) {
                            return false;
                        }

                        if (MotionEventCompat.getPointerCount(e1) > SINGLE_TOUCH
                                || MotionEventCompat.getPointerCount(e2) > SINGLE_TOUCH) {
                            return false;
                        }

                        return mSingleFlingListener.onFling(e1, e2, velocityX, velocityY);
                    }
                    return false;
                }
            });
}

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.appbase.androidquery.callback.BitmapAjaxCallback.java

private void presetBitmap(String url, ImageView v) {

    if (!url.equals(v.getTag(AQuery.TAG_URL)) || preset != null) {

        v.setTag(AQuery.TAG_URL, url);

        if (preset != null && !cacheAvailable(v.getContext())) {
            setBitmap(url, v, preset, true);
        } else {/*from ww w  .j  a  v  a 2s .  com*/

            setBitmap(url, v, null, true);
        }
    }

}