6 Star 2 Fork 0

HarmonyOS-TPC / GestureLock

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
Apache-2.0

demo

how to user?

dependencies{
    implementation 'io.openharmony.tpc.thirdlib:GestureLock:1.0.1'
}
<com.sevenheaven.gesturelock.GestureLock
        ohos:margin="20vp"
        GestureLock:line_width="2vp"
        GestureLock:line_normal_color="#ffffaa"
        ohos:id="$+id:gesturelock"
        ohos:height="match_parent"
        ohos:width="match_parent"/>
gestureLock.setAdapter(new GestureLock.GestureLockAdapter() {
            @Override
            public int getDepth() {
                return 3;
                //解锁点属性返回3为3X3,返回4为4X4
            }

            @Override
            public int[] getCorrectGestures() {
                return int[]{0,1,2};
                //解锁正确手势
            }

            @Override
            public int getUnmatchedBoundary() {
                return 3;
                //最大错误数
            }

            @Override
            public int getBlockGapSize() {
                return 30;
                //解锁点间距PX
            }

            @Override
            public GestureLockView getGestureLockViewInstance(Context context, int position) {
                return new MyStyleLockView(gestureLock);
                //解锁点样式
            }
        });
        gestureLock.setOnGestureEventListener(new GestureLock.OnGestureEventListener() {
            @Override
            public void onBlockSelected(int position) {
                 //结果的解锁点
            }

            @Override
            public void onGestureEvent(boolean matched,int errorTime) {
                //matched是否正确 ,errorTime错误次数
            }

            @Override
            public void onUnmatchedExceedBoundary() {
                //错误次数超过限制
            }

            @Override
            public void onGesturesFinish(int[] gestures) {
                //返回的解锁手势
            }
        });

API:

class GestrueLock

public void setAdapter(GestureLockAdapter adapter)

  • description: set gesture lock attr values with adapter

public void setUnmatchedBoundary(int unmatchedBoundary)

  • description: set unmatched boundary

public int getUnmatchedBoundary()

  • description: get unmatched boundary

public void setCorrectGestures(int[] gesturesContainer)

  • description: set correct gestures

public int[] getCorrectGestures()

  • description: get correct gestures

public void notifyDataChanged()

  • description: refresh data

public void setEditMode(int mode)

  • description: set edit mode

public int getEditMode()

  • description: get edit mode

public void setTouchable(boolean touchable)

  • description: set touchable

public void resetUnmatchedCount()

  • description: reset unmatched count

public void setOnGestureEventListener(OnGestureEventListener onGestureEventListener)

  • description: set gesture event listener

public void clear()

  • description: clear gestrues

abstract class GestureLockView

public void setLockerState(LockerState state)

  • description: set locker state

public LockerState getLockerState()

  • description: get locker state

public void setArrow(int arrow)

  • description: set arrow angle

public int getArrow()

  • description: get arrow angle

AttrSet:

name format description
line_width dimension set line width
line_normal_color color set line default color
line_error_color color set line error color
Copyright 2016 7heaven Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

简介

暂无描述 展开 收起
Java
Apache-2.0
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/HarmonyOS-tpc/GestureLock.git
git@gitee.com:HarmonyOS-tpc/GestureLock.git
HarmonyOS-tpc
GestureLock
GestureLock
master

搜索帮助

344bd9b3 5694891 D2dac590 5694891