Skip to content

Commit

Permalink
修复bug
Browse files Browse the repository at this point in the history
  • Loading branch information
chengzhicao committed Jul 29, 2019
1 parent d2a646b commit 45d6230
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 7 deletions.
Binary file modified .idea/caches/build_file_checksums.ser
Binary file not shown.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ dependencies {

**建议将compileSdkVersion改为28,低于28会出现编译问题**

# v1.0.9说明
> 1. 禁止多点触摸
> 2. 修复调整频道位置时频道之间不停切换bug
# v1.0.8说明
> 1. 优化频道删除
Expand Down
8 changes: 5 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
}
}
Expand Down
17 changes: 14 additions & 3 deletions channelview/src/main/java/com/cheng/channel/ChannelView.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -143,6 +144,8 @@ public class ChannelView extends ScrollView {

private List<TextView> otherSubTitles = new ArrayList<>();

private float density;

public ChannelView(Context context) {
this(context, null);
}
Expand Down Expand Up @@ -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;
}

/**
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -1450,5 +1455,11 @@ private void changeTip(boolean state) {
}
}
}

@Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
handler.removeCallbacksAndMessages(null);
}
}
}
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 45d6230

Please sign in to comment.