• Stars
    star
    263
  • Rank 155,624 (Top 4 %)
  • Language
    Java
  • License
    Other
  • Created over 10 years ago
  • Updated over 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

a GestureLock that can customize length and style

Hex.pm Download

GestureLock

GestureLock是一个可以自定义数量、自定义样式的手势解锁控件

用法

gradle:

compile 'com.7heaven.widgets:gesturelock:1.3'

使用GestureLock类提供的Adapter来定制样式

    gestureView.setAdapter(new GestureLock.GestureLockAdapter() {

			@Override
			public int getDepth() {
				return 7;
			}

			@Override
			public int[] getCorrectGestures() {
				return new int[]{1, 2, 3, 4};
			}

			@Override
			public int getUnmatchedBoundary() {
				return 5;
			}

			@Override
			public int getBlockGapSize(){
				return 10;
			}

			@Override
			public GestureLockView getGestureLockViewInstance(Context context, int position) {
				return new NexusStyleLockView(context);
			}
		});	

getDepth() 手势解锁的宽高数量

getCorrectGestures() 正确的解锁手势

getUnmatchedBoundary() 最大可重试次数

getBlockGapSize() block之前的间隔大小

getGestureLockViewInstance(Context context, int position) block的样式

继承GestureLockView来实现自定义样式的block

  • 重写doArrowDraw绘制箭头(箭头角度0的时候为向上)
  • 重写onDraw实现Block内容样式的绘制

Block分为三种状态

  • LockerState.LOCKER_STATE_NORMAL 正常状态
  • LockerState.LOCKER_STATE_SELECTED 选中状态
  • LockerState.LOCKER_STATE_ERROR 错误状态
    @Override
    protected void doArrowDraw(Canvas canvas){
        mPaint.setStyle(Paint.Style.FILL);
        mPaint.setColor(COLOR_ERROR);
        canvas.drawPath(arrow, mPaint);
    }

    @Override
    protected void doDraw(LockerState state, Canvas canvas){
        switch(state){
            case LOCKER_STATE_NORMAL:
                mPaint.setStyle(Paint.Style.FILL);
                mPaint.setColor(COLOR_NORMAL);
			    canvas.drawCircle(mCenterX, mCenterY, mRadius * innerRate, mPaint);
			break;
            case LOCKER_STATE_SELECTED:
                mPaint.setStyle(Paint.Style.STROKE);
                mPaint.setColor(COLOR_NORMAL);
                mPaint.setStrokeWidth(mRadius * outerWidthRate);
			    canvas.drawCircle(mCenterX, mCenterY, mRadius * outerRate, mPaint);
                mPaint.setStrokeWidth(2);
			    canvas.drawCircle(mCenterX, mCenterY, mRadius * innerRate, mPaint);
			break;
            case LOCKER_STATE_ERROR:
                mPaint.setStyle(Paint.Style.STROKE);
                mPaint.setColor(COLOR_ERROR);
                mPaint.setStrokeWidth(mRadius * outerWidthRate);
			    canvas.drawCircle(mCenterX, mCenterY, mRadius * outerRate, mPaint);
                mPaint.setStrokeWidth(2);
			    canvas.drawCircle(mCenterX, mCenterY, mRadius * innerRate, mPaint);
			break;
		}
    }
    

More Repositories

1

SHSegmentControl

segmentcontrol widget for android
Java
613
star
2

bitmapMesh

bitmapMesh demo
Java
424
star
3

SHSwitchView

an iOS-7 Style Switch for android
Java
367
star
4

CurtainSlidingMenu

SlidingMenu With Curtain Effect
Java
317
star
5

UILibrary

平时项目开发中写的自定义Drawable、View和Shape
Java
261
star
6

PullRefresh

IOS-style PullRefresh
Java
61
star
7

md2tv

Java
40
star
8

SHSoftwareRasterizer

软光栅器的简单实现
C++
31
star
9

ElegantUnderlineSpan

better underline style span based on romain guy's article https://medium.com/@romainguy/a-better-underline-for-android-90ba3a2e4fb#.tyhk99ywj and repo https://github.com/romainguy/elegant-underline
Java
22
star
10

Bezier

绘制任意阶数的贝塞尔曲线
Java
19
star
11

docktest

mac dock scale style custom view demo
Java
14
star
12

SHZoomView

provide a scaled View for any content on the screen
Java
13
star
13

libgif_comment

给libgif的lib下的代码文件增加注释,方便大家理解libgif的编码解码原理
C
11
star
14

ConfirmView

Java
10
star
15

metaball

Java
10
star
16

SHJavascriptInterface

javascriptinterface for iOS
Objective-C
8
star
17

leetcode_solutions

my solutions to leetcode questions
Java
6
star
18

w3m_iterm

w3m web browser with iterm img protocol support
C
5
star
19

QQ-jump

Java
5
star
20

Compass

IOS7 Style compass
Java
4
star
21

PaintView

A simple Demo for implement a paint board
Java
4
star
22

FC_source

FC原理图
HTML
3
star
23

CameraEffect

camera effect
C
2
star
24

deletedetect

C
2
star
25

RecyclerViewTest

Java
2
star
26

PCF8833-modify

给网上的PCF8833显示屏芯片驱动增加 Bresenham直线 & 吴小林抗锯齿直线绘制方法
C
1
star
27

EasyBitmapMesh

Java
1
star
28

StickableListView

nothing
Java
1
star
29

Waker

it's nothing
Java
1
star
30

jekyll_theme_thinny

HTML
1
star
31

FlipView

nothing yet
Java
1
star
32

perspectiveProject

Objective-C
1
star