From 45d6230d169390fc70c4990fc112df27ff7cbddb Mon Sep 17 00:00:00 2001 From: caochengzhi Date: Mon, 29 Jul 2019 08:40:54 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/caches/build_file_checksums.ser | Bin 590 -> 590 bytes README.md | 4 ++++ build.gradle | 8 +++++--- .../java/com/cheng/channel/ChannelView.java | 17 ++++++++++++++--- gradle/wrapper/gradle-wrapper.properties | 2 +- 5 files changed, 24 insertions(+), 7 deletions(-) diff --git a/.idea/caches/build_file_checksums.ser b/.idea/caches/build_file_checksums.ser index cbc376b05fa7590e829e40084c14eaee18c47263..d8feb1fe37a15b73d84e09fc56e8a511d0c2b296 100644 GIT binary patch delta 37 vcmV+=0NVe~1kMDImj!GsHpv>XoDl&KEksHe4UwGop3p=nH${V&lf40v1X~V9 delta 37 vcmV+=0NVe~1kMDImj!D5iXB(6oDl&KYJ(5TxIuhx%~oq}#!iR0lf40vE#?q_ diff --git a/README.md b/README.md index 81ebf03..ac7aae0 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,10 @@ dependencies { **建议将compileSdkVersion改为28,低于28会出现编译问题** +# v1.0.9说明 +> 1. 禁止多点触摸 +> 2. 修复调整频道位置时频道之间不停切换bug + # v1.0.8说明 > 1. 优化频道删除 diff --git a/build.gradle b/build.gradle index 43c0708..aef766c 100644 --- a/build.gradle +++ b/build.gradle @@ -3,11 +3,12 @@ buildscript { repositories { - google() + maven { url 'https://maven.aliyun.com/repository/public/' } + maven { url 'https://maven.aliyun.com/repository/google' } jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:3.1.3' + classpath 'com.android.tools.build:gradle:3.4.2' // NOTE: Do not place your application dependencies here; they belong @@ -17,7 +18,8 @@ buildscript { allprojects { repositories { - google() + maven { url 'https://maven.aliyun.com/repository/public/' } + maven { url 'https://maven.aliyun.com/repository/google' } jcenter() } } diff --git a/channelview/src/main/java/com/cheng/channel/ChannelView.java b/channelview/src/main/java/com/cheng/channel/ChannelView.java index 3224b7f..bc8de8e 100644 --- a/channelview/src/main/java/com/cheng/channel/ChannelView.java +++ b/channelview/src/main/java/com/cheng/channel/ChannelView.java @@ -9,6 +9,7 @@ import android.graphics.PointF; import android.graphics.Typeface; import android.os.Handler; +import android.os.Looper; import android.os.Message; import android.support.annotation.ColorInt; import android.support.annotation.DimenRes; @@ -143,6 +144,8 @@ public class ChannelView extends ScrollView { private List otherSubTitles = new ArrayList<>(); + private float density; + public ChannelView(Context context) { this(context, null); } @@ -202,7 +205,8 @@ public ChannelView(Context context, AttributeSet attrs, int defStyleAttr) { if (channelFixedCount < 0) { channelFixedCount = 0; } - maxAccessDrag = context.getResources().getDisplayMetrics().density * DRAG_THRESHOLD + 0.5f; + density = context.getResources().getDisplayMetrics().density; + maxAccessDrag = density * DRAG_THRESHOLD + 0.5f; } /** @@ -740,7 +744,7 @@ private class ChannelLayout extends GridLayout implements OnLongClickListener, O /** * 频道最小可拖动距离 */ - private final int RANGE = 100; + private int RANGE = 30; private final int DURATION_TIME = 200; @@ -870,6 +874,7 @@ protected void onLayout(boolean changed, int left, int top, int right, int botto } private void init() { + RANGE = (int) (density * RANGE + 0.5f); setColumnCount(channelColumn); setPadding(channelPadding, channelPadding, channelPadding, channelPadding); addChannelView(); @@ -1075,7 +1080,7 @@ public void run() { private Thread thread; - private Handler handler = new Handler() { + private Handler handler = new Handler(Looper.getMainLooper()) { @Override public void handleMessage(Message msg) { TextView v = (TextView) msg.obj; @@ -1450,5 +1455,11 @@ private void changeTip(boolean state) { } } } + + @Override + protected void onDetachedFromWindow() { + super.onDetachedFromWindow(); + handler.removeCallbacksAndMessages(null); + } } } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 8746656..00fca3e 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip