package cn.sdjzu.xg12.view;
import cn.sdjzu.xg12.R;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.Region;
import android.graphics.RegionIterator;
import android.graphics.drawable.Drawable;
import android.view.View;
public class HighlightView {
@SuppressWarnings("unused")
private static final String TAG = "HighlightView";
View mContext; // The View displaying the image.
public static final int GROW_NONE = (1 << 0);
public static final int GROW_LEFT_EDGE = (1 << 1);
public static final int GROW_RIGHT_EDGE = (1 << 2);
public static final int GROW_TOP_EDGE = (1 << 3);
public static final int GROW_BOTTOM_EDGE = (1 << 4);
public static final int MOVE = (1 << 5);
public HighlightView(View ctx) {
mContext = ctx;
}
private void init() {
android.content.res.Resources resources = mContext.getResources();
mResizeDrawableDiagonal = resources.getDrawable(R.drawable.gl_indicator_autocrop);
mResizeDrawableDiagonal2 = resources.getDrawable(R.drawable.gl_indicator_autocrop2);
}
public boolean mIsFocused;
boolean mHidden;
public boolean hasFocus() {
return mIsFocused;
}
public void setFocus(boolean f) {
mIsFocused = f;
}
public void setHidden(boolean hidden) {
mHidden = hidden;
}
public void draw(Canvas canvas) {
if (mHidden) {
return;
}
canvas.save();
Path path = new Path();
if (!hasFocus()) {
mOutlinePaint.setColor(0xFF000000);
canvas.drawRect(mDrawRect, mOutlinePaint);
} else {
Rect viewDrawingRect = new Rect();
mContext.getDrawingRect(viewDrawingRect);
if (mCircle) {
float width = mDrawRect.width();
float height = mDrawRect.height();
path.addCircle(mDrawRect.left + (width / 2), mDrawRect.top + (height / 2), width / 2, Path.Direction.CW);
mOutlinePaint.setColor(0xFFEF04D6);
} else {
path.addRect(new RectF(mDrawRect), Path.Direction.CW);
mOutlinePaint.setColor(0xFFFF8A00);
}
Region region = new Region();
region.set(viewDrawingRect);
region.op(mDrawRect, Region.Op.DIFFERENCE);
RegionIterator iter = new RegionIterator(region);
Rect r = new Rect();
while (iter.next(r)) {
canvas.drawRect(r, hasFocus() ? mFocusPaint : mNoFocusPaint);
}
// canvas.clipPath(path, Region.Op.DIFFERENCE);//android 4.0 Support bad.java.lang.UnsupportedOperationException
// canvas.drawRect(viewDrawingRect, hasFocus() ? mFocusPaint : mNoFocusPaint);
canvas.restore();
canvas.drawPath(path, mOutlinePaint);
if (mMode == ModifyMode.Grow) {
if (mCircle) {
int width = mResizeDrawableDiagonal.getIntrinsicWidth();
int height = mResizeDrawableDiagonal.getIntrinsicHeight();
int d = (int) Math.round(Math.cos(/* 45deg */Math.PI / 4D) * (mDrawRect.width() / 2D));
int x = mDrawRect.left + (mDrawRect.width() / 2) + d - width / 2;
int y = mDrawRect.top + (mDrawRect.height() / 2) - d - height / 2;
mResizeDrawableDiagonal.setBounds(x, y, x + mResizeDrawableDiagonal.getIntrinsicWidth(), y
+ mResizeDrawableDiagonal.getIntrinsicHeight());
mResizeDrawableDiagonal.draw(canvas);
} else {
}
}
if (mCircle) {
}else{
int left = mDrawRect.left + 1;
int right = mDrawRect.right + 1;
int top = mDrawRect.top + 4;
int bottom = mDrawRect.bottom + 3;
int widthWidth = mResizeDrawableDiagonal.getIntrinsicWidth() / 2;
int widthHeight = mResizeDrawableDiagonal.getIntrinsicHeight() / 2;
mResizeDrawableDiagonal2.setBounds(left - widthWidth, top - widthHeight, left + widthWidth, top+ widthHeight);
mResizeDrawableDiagonal2.draw(canvas);
mResizeDrawableDiagonal.setBounds(right - widthWidth, top - widthHeight, right + widthWidth, top+ widthHeight);
mResizeDrawableDiagonal.draw(canvas);
mResizeDrawableDiagonal.setBounds(left - widthWidth, bottom - widthHeight, left + widthWidth, bottom+ widthHeight);
mResizeDrawableDiagonal.draw(canvas);
mResizeDrawableDiagonal2.setBounds(right - widthWidth, bottom - widthHeight, right + widthWidth, bottom+ widthHeight);
mResizeDrawableDiagonal2.draw(canvas);
}
}
}
public void setMode(ModifyMode mode) {
if (mode != mMode) {
mMode = mode;
mContext.invalidate();
}
}
// Determines which edges are hit by touching at (x, y).
public int getHit(float x, float y) {
Rect r = computeLayout();
final float hysteresis = 20F;
int retval = GROW_NONE;
if (mCircle) {
float distX = x - r.centerX();
float distY = y - r.centerY();
int distanceFromCenter = (int) Math.sqrt(distX * distX + distY * distY);
int radius = mDrawRect.width() / 2;
int delta = distanceFromCenter - radius;
if (Math.abs(delta) <= hysteresis) {
if (Math.abs(distY) > Math.abs(distX)) {
if (distY < 0) {
retval = GROW_TOP_EDGE;
} else {
retval = GROW_BOTTOM_EDGE;
}
} else {
if (distX < 0) {
retval = GROW_LEFT_EDGE;
} else {
retval = GROW_RIGHT_EDGE;
}
}
} else
if (distanceFromCenter < radius) {
retval = MOVE;
} else {
retval = GROW_NONE;
}
} else {
// verticalCheck makes sure the position is between the top and
// the bottom edge (with some tolerance). Similar for horizCheck.
boolean verticalCheck = (y >= r.top - hysteresis) && (y < r.bottom + hysteresis);
boolean horizCheck = (x >= r.left - hysteresis) && (x < r.right + hysteresis);
// Check whether the position is near some edge(s).
if ((Math.abs(r.left - x) < hysteresis) && verticalCheck) {
retval |= GROW_LEFT_EDGE;
}
if ((Math.abs(r.right - x) < hysteresis) && verticalCheck) {
retval |= GROW_RIGHT_EDGE;
}
if ((Math.abs(r.top - y) < hysteresis) && horizCheck) {
retval |= GROW_TOP_EDGE;
}
if ((Math.abs(r.bottom - y) < hysteresis) && horizCheck) {
retval |= GROW_BOTTOM_EDGE;
}
// Not near any edge but inside the rectangle: move.
if (retval == GROW_NONE && r.contains((int) x, (int) y)) {
retval = MOVE;
}
}
return retval;
}
// Handles motion (dx, dy) in screen space.
// The "edge" parameter specifies which edges the user is dragging.
public void handleMotion(int edge, float dx, float dy) {
Rect r = computeLayout();
if (edge == GROW_NONE) {
return;
} else if (edge == MOVE) {
// Convert to image space before sending to moveBy().
moveBy(dx * (mCropRect.width() / r.width()), dy * (mCropRect.height() / r.height()));
} else {
if (((GROW_LEFT_EDGE | GRO
没有合适的资源?快使用搜索试试~ 我知道了~
android登录注册界面设计demo
共113个文件
class:35个
png:33个
xml:25个
4星 · 超过85%的资源 需积分: 46 257 下载量 124 浏览量
2015-03-09
21:20:00
上传
评论 7
收藏 745KB ZIP 举报
温馨提示
一个android登录,注册带有选择头像功能的demo
资源推荐
资源详情
资源评论
收起资源包目录
android登录注册界面设计demo (113个子文件)
resources.ap_ 160KB
miniTwitterLoginDemo.apk 189KB
jarlist.cache 120B
HighlightView.class 9KB
ImageViewTouchBase.class 9KB
CropImageView.class 8KB
CropImageActivity.class 6KB
SignActivity.class 6KB
CropImage.class 6KB
CropImage$1.class 4KB
SignActivity$SelectImageBtnListener$1.class 3KB
SignActivity$SelectImageBtnListener.class 2KB
CropImage$2$1.class 2KB
RotateBitmap.class 2KB
ModifyAvatarDialog.class 2KB
CropImage$BackgroundJob.class 2KB
CropImage$3.class 2KB
CropImage$3$1.class 2KB
R$drawable.class 2KB
CropImage$2.class 1KB
CropImage$1$1.class 1KB
LoginActivity$TextViewOnClickListener.class 1KB
ImageViewTouchBase$2.class 1KB
LoginActivity.class 1KB
HighlightView$ModifyMode.class 1KB
CropImage$BackgroundJob$1.class 1KB
CropImageActivity$1.class 1KB
R$id.class 1KB
ImageViewTouchBase$1.class 885B
R$string.class 869B
SignActivity$1.class 760B
R.class 582B
R$layout.class 545B
R$color.class 463B
R$style.class 419B
BuildConfig.class 335B
R$attr.class 325B
ImageViewTouchBase$Recycler.class 279B
.classpath 475B
classes.dex 56KB
annotations-62715ab68464df237609ba55406cab6a.jar 943B
HighlightView.java 13KB
ImageViewTouchBase.java 12KB
CropImage.java 11KB
CropImageView.java 9KB
SignActivity.java 7KB
CropImageActivity.java 6KB
R.java 5KB
RotateBitmap.java 2KB
ModifyAvatarDialog.java 2KB
LoginActivity.java 1KB
BuildConfig.java 155B
login_bg.png 138KB
login_bg.png 111KB
icon.png 4KB
gl_indicator_autocrop2.png 4KB
icon.png 4KB
gl_indicator_autocrop.png 4KB
gl_indicator_autocrop2.png 4KB
gl_indicator_autocrop.png 4KB
icon.png 3KB
icon.png 2KB
gl_rotate_left_normal.png 2KB
gl_rotate_right_normal.png 2KB
gl_rotate_left_click.png 2KB
icon.png 2KB
gl_rotate_left_normal.png 2KB
gl_rotate_right_normal.png 2KB
gl_rotate_left_click.png 2KB
gl_rotate_right_click.png 2KB
icon.png 2KB
gl_rotate_right_click.png 1KB
btn_style_one_normal.9.png 1KB
btn_style_one_pressed.9.png 1KB
btn_style_one_focused.9.png 1KB
btn_style_one_normal.9.png 1KB
btn_style_one_focused.9.png 1KB
btn_style_one_pressed.9.png 1KB
btn_style_one_disabled.9.png 1KB
btn_style_one_disabled.9.png 1KB
login_edit_pressed.9.png 806B
login_edit_normal.9.png 762B
login_edit_pressed.9.png 531B
login_edit_normal.9.png 496B
hpj.9.png 462B
org.eclipse.jdt.core.prefs 177B
.project 851B
project.properties 647B
login_layout.xml 4KB
login.xml 3KB
sign_layout.xml 3KB
gl_modify_avatar.xml 2KB
AndroidManifest.xml 1KB
AndroidManifest.xml 1KB
gl_modify_avatar_choose_dialog.xml 1KB
strings.xml 839B
style.xml 781B
btn_style_green.xml 656B
login_editbox.xml 429B
gl_rotate_right.xml 421B
共 113 条
- 1
- 2
资源评论
- ydong20122015-12-14看了一下,感觉代码挺好的
- w29981253062017-03-05很强势的,可以的
- 浪子燕清Andy2018-04-14看看 希望不错
- lastqingren2016-12-16很老的一个页面了,不建议2017年下载
菜鸟在奋斗
- 粉丝: 12
- 资源: 2
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功