当前位置: 首页>>代码示例>>Java>>正文


Java Utils.getRelativeTop方法代码示例

本文整理汇总了Java中com.gc.materialdesign.utils.Utils.getRelativeTop方法的典型用法代码示例。如果您正苦于以下问题:Java Utils.getRelativeTop方法的具体用法?Java Utils.getRelativeTop怎么用?Java Utils.getRelativeTop使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.gc.materialdesign.utils.Utils的用法示例。


在下文中一共展示了Utils.getRelativeTop方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onTouchEvent

import com.gc.materialdesign.utils.Utils; //导入方法依赖的package包/类
@Override
public boolean onTouchEvent(MotionEvent event) {
    isLastTouch = true;
    if (isEnabled()) {
        if (event.getAction() == MotionEvent.ACTION_DOWN
                || event.getAction() == MotionEvent.ACTION_MOVE) {
            if (numberIndicator != null
                    && numberIndicator.isShowing() == false)
                numberIndicator.show();
            if ((event.getX() <= getWidth() && event.getX() >= 0)) {
                press = true;
                // calculate value
                int newValue = 0;
                float division = (ball.xFin - ball.xIni) / (max - min);
                if (event.getX() > ball.xFin) {
                    newValue = max;
                } else if (event.getX() < ball.xIni) {
                    newValue = min;
                } else {
                    newValue = min + (int) ((event.getX() - ball.xIni) / division);
                }
                if (value != newValue) {
                    value = newValue;
                    if (onValueChangedListener != null)
                        onValueChangedListener.onValueChanged(newValue);
                }
                // move ball indicator
                float x = event.getX();

                x = (x < ball.xIni) ? ball.xIni : x;
                x = (x > ball.xFin) ? ball.xFin : x;
                ViewHelper.setX(ball, x);
                ball.changeBackground();

                // If slider has number indicator
                if (numberIndicator != null) {
                    // move number indicator
                    numberIndicator.indicator.x = x;
                    numberIndicator.indicator.finalY = Utils
                            .getRelativeTop(this) - getHeight() / 2;
                    numberIndicator.indicator.finalSize = getHeight() / 2;
                    numberIndicator.numberIndicator.setText("");
                }

            } else {
                press = false;
                isLastTouch = false;
                if (numberIndicator != null)
                    numberIndicator.dismiss();

            }

        } else if (event.getAction() == MotionEvent.ACTION_UP ||
                event.getAction() == MotionEvent.ACTION_CANCEL) {
            if (numberIndicator != null)
                numberIndicator.dismiss();
            isLastTouch = false;
            press = false;
        }
    }
    return true;
}
 
开发者ID:shegang,项目名称:meishiDemo,代码行数:63,代码来源:Slider.java

示例2: onTouchEvent

import com.gc.materialdesign.utils.Utils; //导入方法依赖的package包/类
@Override
public boolean onTouchEvent(MotionEvent event) {
    isLastTouch = true;
    if (isEnabled()) {
        if (event.getAction() == MotionEvent.ACTION_DOWN
                || event.getAction() == MotionEvent.ACTION_MOVE) {
            if (numberIndicator != null
                    && numberIndicator.isShowing() == false)
                numberIndicator.show();
            if ((event.getX() <= getWidth() && event.getX() >= 0)) {
                press = true;
                // calculate value
                int newValue = 0;
                float division = (ball.xFin - ball.xIni) / (max - min);
                if (event.getX() > ball.xFin) {
                    newValue = max;
                } else if (event.getX() < ball.xIni) {
                    newValue = min;
                } else {
                    newValue = min + (int) ((event.getX() - ball.xIni) / division);
                }
                if (value != newValue) {
                    value = newValue;
                    if (onValueChangedListener != null)
                        onValueChangedListener.onValueChanged(newValue);
                }
                // move ball indicator
                float x = event.getX();
                x = (x < ball.xIni) ? ball.xIni : x;
                x = (x > ball.xFin) ? ball.xFin : x;
                ViewHelper.setX(ball, x);
                ball.changeBackground();

                // If slider has number indicator
                if (numberIndicator != null) {
                    // move number indicator
                    numberIndicator.indicator.x = x;
                    numberIndicator.indicator.finalY = Utils
                            .getRelativeTop(this) - getHeight() / 2;
                    numberIndicator.indicator.finalSize = getHeight() / 2;
                    numberIndicator.numberIndicator.setText("");
                }

            } else {
                press = false;
                isLastTouch = false;
                if (numberIndicator != null)
                    numberIndicator.dismiss();

            }

        } else if (event.getAction() == MotionEvent.ACTION_UP ||
                event.getAction() == MotionEvent.ACTION_CANCEL) {
            if (numberIndicator != null)
                numberIndicator.dismiss();
            isLastTouch = false;
            press = false;
        }
    }
    return true;
}
 
开发者ID:JianxunRao,项目名称:FangYanShuo,代码行数:62,代码来源:Slider.java

示例3: onTouchEvent

import com.gc.materialdesign.utils.Utils; //导入方法依赖的package包/类
@Override
public boolean onTouchEvent(MotionEvent event) {
	isLastTouch = true;
	if (isEnabled()) {
		if (event.getAction() == MotionEvent.ACTION_DOWN || event.getAction() == MotionEvent.ACTION_MOVE) {
			if (numberIndicator != null && numberIndicator.isShowing() == false)
				numberIndicator.show();// 只要一按下就会冒出指示器
			if ((event.getX() <= getWidth() && event.getX() >= 0)) {
				press = true;
				// calculate value
				int newValue = 0;
				float division = (ball.xFin - ball.xIni) / (max - min);
				if (event.getX() > ball.xFin) {
					newValue = max;
				} else if (event.getX() < ball.xIni) {
					newValue = min;
				} else {
					newValue = min + (int) ((event.getX() - ball.xIni) / division);
				}
				if (value != newValue) {
					value = newValue;
					if (onValueChangedListener != null)
						onValueChangedListener.onValueChanged(newValue);
				}
				// move ball indicator
				float x = event.getX();
				x = (x < ball.xIni) ? ball.xIni : x;
				x = (x > ball.xFin) ? ball.xFin : x;
				ViewHelper.setX(ball, x);
				ball.changeBackground();

				// If slider has number indicator
				if (numberIndicator != null) {
					// move number indicator
					numberIndicator.indicator.x = x;
					// 指示器起始的y坐标是当前控件的顶部Y坐标-当前控件高度的一半,就等于从空间的垂直中心开始。
					numberIndicator.indicator.finalY = Utils.getRelativeTop(this) - getHeight() ;
					numberIndicator.indicator.finalSize = getHeight() / 2;
					numberIndicator.numberIndicator.setText("");
				}

			} else {
				press = false;
				isLastTouch = false;
				if (numberIndicator != null)
					numberIndicator.dismiss();

			}

		} else if (event.getAction() == MotionEvent.ACTION_UP) {
			if (numberIndicator != null)
				numberIndicator.dismiss();
			isLastTouch = false;
			press = false;
			if ((event.getX() <= getWidth() && event.getX() >= 0)) {

			}
		}
	}
	return true;
}
 
开发者ID:zubiix,项目名称:nearby-places,代码行数:62,代码来源:Slider.java

示例4: onTouchEvent

import com.gc.materialdesign.utils.Utils; //导入方法依赖的package包/类
@Override
public boolean onTouchEvent(MotionEvent event) {
	isLastTouch = true;
	if (isEnabled()) {
		if (event.getAction() == MotionEvent.ACTION_DOWN
				|| event.getAction() == MotionEvent.ACTION_MOVE) {
			if (numberIndicator != null
					&& numberIndicator.isShowing() == false)
				numberIndicator.show();
			if ((event.getX() <= getWidth() && event.getX() >= 0)) {
				press = true;
				// calculate value
				int newValue = 0;
				float division = (ball.xFin - ball.xIni) / (max-min);
				if (event.getX() > ball.xFin) {
					newValue = max;
				} else if (event.getX() < ball.xIni) {
					newValue = min;
				} else {
					newValue = min + (int) ((event.getX() - ball.xIni) / division);
				}
				if (value != newValue) {
					value = newValue;
					if (onValueChangedListener != null)
						onValueChangedListener.onValueChanged(newValue);
				}
				// move ball indicator
				float x = event.getX();
				x = (x < ball.xIni) ? ball.xIni : x;
				x = (x > ball.xFin) ? ball.xFin : x;
				ViewHelper.setX(ball, x);
				ball.changeBackground();

				// If slider has number indicator
				if (numberIndicator != null) {
					// move number indicator
					numberIndicator.indicator.x = x;
					numberIndicator.indicator.finalY = Utils
							.getRelativeTop(this) - getHeight() / 2;
					numberIndicator.indicator.finalSize = getHeight() / 2;
					numberIndicator.numberIndicator.setText("");
				}

			} else {
				press = false;
				isLastTouch = false;
				if (numberIndicator != null)
					numberIndicator.dismiss();

			}

		} else if (event.getAction() == MotionEvent.ACTION_UP ||
				event.getAction() == MotionEvent.ACTION_CANCEL) {
			if (numberIndicator != null)
				numberIndicator.dismiss();
			isLastTouch = false;
			press = false;
		}
	}
	return true;
}
 
开发者ID:callmesusheel,项目名称:yelli,代码行数:62,代码来源:Slider.java

示例5: onTouchEvent

import com.gc.materialdesign.utils.Utils; //导入方法依赖的package包/类
@Override
public boolean onTouchEvent(MotionEvent event) {
	isLastTouch = true;
	if (isEnabled()) {
		if (event.getAction() == MotionEvent.ACTION_DOWN
				|| event.getAction() == MotionEvent.ACTION_MOVE) {
			if (numberIndicator != null
					&& numberIndicator.isShowing() == false)
				numberIndicator.show();
			if ((event.getX() <= getWidth() && event.getX() >= 0)) {
				press = true;
				// calculate value
				int newValue = 0;
				float division = (ball.xFin - ball.xIni) / (max-min);
				if (event.getX() > ball.xFin) {
					newValue = max;
				} else if (event.getX() < ball.xIni) {
					newValue = min;
				} else {
					newValue = min + (int) ((event.getX() - ball.xIni) / division);
				}
				if (value != newValue) {
					value = newValue;
					if (onValueChangedListener != null)
						onValueChangedListener.onValueChanged(newValue);
				}
				// move ball indicator
				float x = event.getX();
				x = (x < ball.xIni) ? ball.xIni : x;
				x = (x > ball.xFin) ? ball.xFin : x;
				ViewHelper.setX(ball, x);
				ball.changeBackground();

				// If slider has number indicator
				if (numberIndicator != null) {
					// move number indicator
					numberIndicator.indicator.x = x;
					numberIndicator.indicator.finalY = Utils
							.getRelativeTop(this) - getHeight() / 2;
					numberIndicator.indicator.finalSize = getHeight() / 2;
					numberIndicator.numberIndicator.setText("");
				}

			} else {
				press = false;
				isLastTouch = false;
				if (numberIndicator != null)
					numberIndicator.dismiss();

			}

		} else if (event.getAction() == MotionEvent.ACTION_UP) {
			if (numberIndicator != null)
				numberIndicator.dismiss();
			isLastTouch = false;
			press = false;
			if ((event.getX() <= getWidth() && event.getX() >= 0)) {

			}
		}
	}
	return true;
}
 
开发者ID:LINKIWI,项目名称:mobile-manager-for-cloudflare,代码行数:64,代码来源:Slider.java


注:本文中的com.gc.materialdesign.utils.Utils.getRelativeTop方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。