Java Code Examples for android.widget.ImageView.getParent()

The following are Jave code examples for showing how to use getParent() of the android.widget.ImageView class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: UiLib   File: PhotoViewAttacher.java   View Source Code Vote up 7 votes
public void onDrag(float dx, float dy) {
    if(!this.mScaleDragDetector.isScaling()) {
        if(DEBUG) {
            LogManager.getLogger().d("PhotoViewAttacher", String.format("onDrag: dx: %.2f. dy: %.2f", new Object[]{Float.valueOf(dx), Float.valueOf(dy)}));
        }

        ImageView imageView = this.getImageView();
        this.mSuppMatrix.postTranslate(dx, dy);
        this.checkAndDisplayMatrix();
        ViewParent parent = imageView.getParent();
        if(this.mAllowParentInterceptOnEdge && !this.mScaleDragDetector.isScaling() && !this.mBlockParentIntercept) {
            if((this.mScrollEdge == 2 || this.mScrollEdge == 0 && dx >= 1.0F || this.mScrollEdge == 1 && dx <= -1.0F) && null != parent) {
                parent.requestDisallowInterceptTouchEvent(false);
            }
        } else if(null != parent) {
            parent.requestDisallowInterceptTouchEvent(true);
        }

    }
}
 
Example 2
Project: gravity-view   File: GravityView.java   View Source Code Vote up 7 votes
public GravityView setImage(ImageView image, int drawable) {
    image_view = image;
    Bitmap bmp = resizeBitmap(Common.getDeviceHeight(mContext), drawable);
    image_view.setLayoutParams(new HorizontalScrollView.LayoutParams(bmp.getWidth(), bmp.getHeight()));
    image_view.setImageBitmap(bmp);
    mMaxScroll = bmp.getWidth();
    if (image.getParent() instanceof HorizontalScrollView) {
            ((HorizontalScrollView) image.getParent()).setOnTouchListener(new View.OnTouchListener() {
                @Override
                public boolean onTouch(View view, MotionEvent motionEvent) {
                    return true;
                }
            });
    }
    return gravityView;
}
 
Example 3
Project: gravity-view   File: GravityView.java   View Source Code Vote up 7 votes
public GravityView setImage(ImageView image, Bitmap bitmap) {
    image_view = image;
    Bitmap bmp = resizeBitmap(Common.getDeviceHeight(mContext), bitmap);
    image_view.setLayoutParams(new HorizontalScrollView.LayoutParams(bmp.getWidth(), bmp.getHeight()));
    image_view.setImageBitmap(bmp);
    mMaxScroll = bmp.getWidth();
    if (image.getParent() instanceof HorizontalScrollView) {
        ((HorizontalScrollView) image.getParent()).setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View view, MotionEvent motionEvent) {
                return true;
            }
        });
    }
    return gravityView;
}
 
Example 4
Project: boohee_v5.6   File: PhotoViewAttacher.java   View Source Code Vote up 7 votes
public void onDrag(float dx, float dy) {
    if (!this.mScaleDragDetector.isScaling()) {
        if (DEBUG) {
            LogManager.getLogger().d(LOG_TAG, String.format("onDrag: dx: %.2f. dy: %.2f", new Object[]{Float.valueOf(dx), Float.valueOf(dy)}));
        }
        ImageView imageView = getImageView();
        this.mSuppMatrix.postTranslate(dx, dy);
        checkAndDisplayMatrix();
        ViewParent parent = imageView.getParent();
        if (!this.mAllowParentInterceptOnEdge || this.mScaleDragDetector.isScaling()) {
            if (parent != null) {
                parent.requestDisallowInterceptTouchEvent(true);
            }
        } else if ((this.mScrollEdge == 2 || ((this.mScrollEdge == 0 && dx >= 1.0f) || (this.mScrollEdge == 1 && dx <= -1.0f))) && parent != null) {
            parent.requestDisallowInterceptTouchEvent(false);
        }
    }
}
 
Example 5
Project: HeroVideo-master   File: BannerAdapter.java   View Source Code Vote up 6 votes
@Override
public Object instantiateItem(ViewGroup container, int position)
{

    //对ViewPager页号求模取出View列表中要显示的项
    position %= mList.size();
    if (position < 0)
    {
        position = mList.size() + position;
    }
    ImageView v = mList.get(position);
    pos = position;
    v.setScaleType(ImageView.ScaleType.CENTER);
    //如果View已经在之前添加到了一个父组件,则必须先remove,否则会抛出IllegalStateException。
    ViewParent vp = v.getParent();
    if (vp != null)
    {
        ViewGroup parent = (ViewGroup) vp;
        parent.removeView(v);
    }
    v.setOnClickListener(v1 -> {

        if (mViewPagerOnItemClickListener != null)
        {
            mViewPagerOnItemClickListener.onItemClick();
        }
    });


    container.addView(v);
    return v;
}
 
Example 6
Project: ClouldReader   File: PhotoViewAttacher.java   View Source Code Vote up 6 votes
@Override
public void onDrag(float dx, float dy) {
    if (mScaleDragDetector.isScaling()) {
        return; // Do not drag if we are already scaling
    }

    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() && !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);
        }
    }
}
 
Example 7
Project: GitHub   File: PhotoViewAttacher.java   View Source Code Vote up 6 votes
@Override
public void onDrag(float dx, float dy) {
    if (mScaleDragDetector.isScaling()) {
        return; // Do not drag if we are already scaling
    }

    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() && !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);
        }
    }
}
 
Example 8
Project: BilibiliClient   File: BannerAdapter.java   View Source Code Vote up 6 votes
@Override
public Object instantiateItem(ViewGroup container, int position) {

  //对ViewPager页号求模取出View列表中要显示的项
  position %= mList.size();
  if (position < 0) {
    position = mList.size() + position;
  }
  ImageView v = mList.get(position);
  pos = position;
  v.setScaleType(ImageView.ScaleType.CENTER);
  //如果View已经在之前添加到了一个父组件,则必须先remove,否则会抛出IllegalStateException。
  ViewParent vp = v.getParent();
  if (vp != null) {
    ViewGroup parent = (ViewGroup) vp;
    parent.removeView(v);
  }
  v.setOnClickListener(v1 -> {

    if (mViewPagerOnItemClickListener != null) {
      mViewPagerOnItemClickListener.onItemClick();
    }
  });

  container.addView(v);
  return v;
}
 
Example 9
Project: BilibiliClient   File: BannerAdapter.java   View Source Code Vote up 6 votes
@Override
public Object instantiateItem(ViewGroup container, int position) {

  //对ViewPager页号求模取出View列表中要显示的项
  position %= mList.size();
  if (position < 0) {
    position = mList.size() + position;
  }
  ImageView v = mList.get(position);
  pos = position;
  v.setScaleType(ImageView.ScaleType.CENTER);
  //如果View已经在之前添加到了一个父组件,则必须先remove,否则会抛出IllegalStateException。
  ViewParent vp = v.getParent();
  if (vp != null) {
    ViewGroup parent = (ViewGroup) vp;
    parent.removeView(v);
  }
  v.setOnClickListener(v1 -> {

    if (mViewPagerOnItemClickListener != null) {
      mViewPagerOnItemClickListener.onItemClick();
    }
  });

  container.addView(v);
  return v;
}
 
Example 10
Project: lrs_android   File: AutoScrollViewPager.java   View Source Code Vote up 6 votes
@Override
        public Object instantiateItem(ViewGroup container, int position) {
//            position = position % bannerMap.size() == 0 ? bannerMap.size() - 1 : position % bannerMap.size() - 1;
            position %= imgList.size();
            ImageView iv = imgList.get(position);
            ViewParent vp = iv.getParent();
            if (vp != null) {
                ViewGroup parent = (ViewGroup) vp;
                parent.removeView(iv);
            }
            container.addView(iv);
            return iv;
        }
 
Example 11
Project: Watermark   File: PhotoViewAttacher.java   View Source Code Vote up 6 votes
@Override
public void onDrag(float dx, float dy) {
    if (mScaleDragDetector.isScaling()) {
        return; // Do not drag if we are already scaling
    }

    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);
        }
    }
}
 
Example 12
Project: SliderImageLayout   File: SliderImageLayout.java   View Source Code Vote up 6 votes
@Override
public Object instantiateItem(ViewGroup container, int position)
{
    //对ViewPager页号求模取出View列表中要显示的项
    position %= mListImgView.size();
    if (position<0){
        position = mListImgView.size()+position;
    }
    final ImageView view = mListImgView.get(position);
    //如果View已经在之前添加到了一个父组件,则必须先remove,否则会抛出IllegalStateException。
    ViewGroup vp = (ViewGroup) view.getParent();
    if (vp!=null)
    {
        vp.removeView(view);
    }
    container.addView(view);
    final int newPosition = position;
    view.setOnClickListener(new OnClickListener()
    {
        @Override
        public void onClick(View v)
        {
            if (mOnSliderItemClickListener != null)
            {
                mOnSliderItemClickListener.onSliderItemClick(newPosition);
            }
        }
    });
    return view;
}
 
Example 13
Project: tvConnect_android   File: PhotoViewAttacher.java   View Source Code Vote up 6 votes
@Override
public void onDrag(float dx, float dy) {
    if (mScaleDragDetector.isScaling()) {
        return; // Do not drag if we are already scaling
    }

    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);
        }
    }
}
 
Example 14
Project: DailyStudy   File: PhotoViewAttacher.java   View Source Code Vote up 6 votes
@Override
public void onDrag(float dx, float dy) {
    if (mScaleDragDetector.isScaling()) {
        return; // Do not drag if we are already scaling
    }

    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() && !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);
        }
    }
}
 
Example 15
Project: PicShow-zhaipin   File: PhotoViewAttacher.java   View Source Code Vote up 6 votes
@Override
public void onDrag(float dx, float dy) {
    if (mScaleDragDetector.isScaling()) {
        return; // Do not drag if we are already scaling
    }

    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) {
        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);
        }
    }
}
 
Example 16
Project: android-project-gallery   File: PhotoViewAttacher.java   View Source Code Vote up 6 votes
@Override
public final void onDrag(float dx, float dy) {
    if (mScaleDragDetector.isScaling()) {
        return; // Do not drag if we are already scaling
    }

    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();
    // Modify: 2014年6月21日 18:56:10
    //if (mAllowParentInterceptOnEdge) {
	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);
        }
    }
}
 
Example 17
Project: Recognize-it   File: PhotoViewAttacher.java   View Source Code Vote up 6 votes
@Override
public void onDrag(float dx, float dy) {
    if (mScaleDragDetector.isScaling()) {
        return; // Do not drag if we are already scaling
    }

    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);
        }
    }
}