diff --git a/README.md b/README.md index 4950532..9a3dbf8 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,8 @@ -# MyBehaviorDemo -高德首页 +#高德首页 -![image](https://github.com/dalong982242260/MyBehaviorDemo/blob/dev/mp4/show.gif?raw=true) + +![image](https://github.com/yixiaolunhui/FGaoDeIndexDemo/blob/master/gif/gaode.gif?raw=true) + +#实现的效果 + +![image](https://github.com/yixiaolunhui/FGaoDeIndexDemo/blob/master/gif/fgaode.gif?raw=true) diff --git a/app/build.gradle b/app/build.gradle index 25867db..19f3b06 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -4,22 +4,6 @@ android { compileSdkVersion 30 buildToolsVersion "30.0.2" - //签名配置 - signingConfigs { - debugConfig { - keyAlias "key" - keyPassword "123456" - storeFile file("./key/key.jks") - storePassword "123456" - } - - releaseConfig { - keyAlias "zhiyunduo" - keyPassword "key" - storeFile file("./key/key.jks") - storePassword "123456" - } - } defaultConfig { applicationId "com.zwl.mybehaviordemo" minSdkVersion 16 @@ -31,18 +15,16 @@ android { ndk { //设置支持的SO库架构(开发者可以根据需要,选择一个或多个平台的so) - abiFilters "armeabi", "armeabi-v7a", "arm64-v8a", "x86","x86_64" + abiFilters "armeabi", "armeabi-v7a", "arm64-v8a", "x86", "x86_64" } } buildTypes { debug { - signingConfig signingConfigs.debugConfig } release { minifyEnabled false - signingConfig signingConfigs.releaseConfig proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } } @@ -61,7 +43,6 @@ dependencies { androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' - implementation "io.reactivex.rxjava2:rxandroid:2.1.0" implementation "io.reactivex.rxjava2:rxjava:2.2.3" diff --git a/app/src/main/java/com/zwl/mybehaviordemo/gaode/GaoDeBottomSheetBehavior.java b/app/src/main/java/com/zwl/mybehaviordemo/gaode/GaoDeBottomSheetBehavior.java index 26afaab..698bfc5 100644 --- a/app/src/main/java/com/zwl/mybehaviordemo/gaode/GaoDeBottomSheetBehavior.java +++ b/app/src/main/java/com/zwl/mybehaviordemo/gaode/GaoDeBottomSheetBehavior.java @@ -12,7 +12,6 @@ import android.os.Parcel; import android.os.Parcelable; import android.util.AttributeSet; -import android.util.Log; import android.util.TypedValue; import android.view.MotionEvent; import android.view.VelocityTracker; @@ -45,7 +44,7 @@ /** * 高德首页滑动效果 * - * @author zhouweilong + * @author yixiaolunhui */ public class GaoDeBottomSheetBehavior extends CoordinatorLayout.Behavior { public static final int STATE_DRAGGING = 1; @@ -104,9 +103,9 @@ public GaoDeBottomSheetBehavior(Context context, AttributeSet attrs) { this.setPeekHeight(a.getDimensionPixelSize(R.styleable.BottomSheetBehavior_Layout_behavior_peekHeight, -1)); } - this.setHideable(a.getBoolean(R.styleable.BottomSheetBehavior_Layout_behavior_hideable, false)); + this.setHideable(a.getBoolean(R.styleable.BottomSheetBehavior_Layout_behavior_hideAble, false)); this.setFitToContents(a.getBoolean(R.styleable.BottomSheetBehavior_Layout_behavior_fitToContents, true)); - this.setSkipCollapsed(a.getBoolean(R.styleable.BottomSheetBehavior_Layout_behavior_skipCollapsed, false)); + this.setSkipCollapsed(a.getBoolean(R.styleable.BottomSheetBehavior_Layout_behavior_skipCollapse, false)); setMiddleHeight(a.getDimensionPixelSize(R.styleable.BottomSheetBehavior_Layout_behavior_middleHeight, MIDDLE_HEIGHT_AUTO)); a.recycle(); @@ -151,12 +150,10 @@ public void onViewDragStateChanged(int state) { @Override public void onViewReleased(@NonNull View releasedChild, float xvel, float yvel) { - Log.e("888888888", "------------onViewReleased-----------yvel=" + yvel); int top; byte targetState; int currentTop; if (yvel < 0.0F) { - Log.e("888888888", "------------onViewReleased------if-----"); if (GaoDeBottomSheetBehavior.this.fitToContents) { currentTop = releasedChild.getTop(); @@ -179,10 +176,16 @@ public void onViewReleased(@NonNull View releasedChild, float xvel, float yvel) } } } else if (!GaoDeBottomSheetBehavior.this.hideable || !GaoDeBottomSheetBehavior.this.shouldHide(releasedChild, yvel) || releasedChild.getTop() <= GaoDeBottomSheetBehavior.this.collapsedOffset && Math.abs(xvel) >= Math.abs(yvel)) { - Log.e("888888888", "------------onViewReleased------else if-----"); if (yvel != 0.0F && Math.abs(xvel) <= Math.abs(yvel)) { - top = GaoDeBottomSheetBehavior.this.collapsedOffset; - targetState = STATE_COLLAPSED; + currentTop = releasedChild.getTop(); + if (currentTop < halfExpandedOffset) { + top = GaoDeBottomSheetBehavior.this.halfExpandedOffset; + targetState = STATE_HALF_EXPANDED; + } else { + top = GaoDeBottomSheetBehavior.this.collapsedOffset; + targetState = STATE_COLLAPSED; + } + } else { currentTop = releasedChild.getTop(); if (GaoDeBottomSheetBehavior.this.fitToContents) { @@ -210,7 +213,6 @@ public void onViewReleased(@NonNull View releasedChild, float xvel, float yvel) } } } else { - Log.e("888888888", "------------onViewReleased------else -----"); top = GaoDeBottomSheetBehavior.this.parentHeight; targetState = STATE_HIDDEN; } @@ -475,7 +477,6 @@ public void onStopNestedScroll(@NonNull CoordinatorLayout coordinatorLayout, @No if (currentTop <= halfExpandedOffset + HIDE_THRESHOLD && currentTop > HIDE_THRESHOLD) { top = this.halfExpandedOffset; targetState = STATE_HALF_EXPANDED; - } else { top = this.collapsedOffset; targetState = STATE_COLLAPSED; diff --git a/app/src/main/java/com/zwl/mybehaviordemo/gaode/GaoDeBtnBehavior.java b/app/src/main/java/com/zwl/mybehaviordemo/gaode/GaoDeBtnBehavior.java index c7a365a..a5cc242 100644 --- a/app/src/main/java/com/zwl/mybehaviordemo/gaode/GaoDeBtnBehavior.java +++ b/app/src/main/java/com/zwl/mybehaviordemo/gaode/GaoDeBtnBehavior.java @@ -11,7 +11,11 @@ import com.zwl.mybehaviordemo.R; - +/** + * 高德首页按钮处理 + * + * @author yixiaolunhui + */ public class GaoDeBtnBehavior extends CoordinatorLayout.Behavior { private View rightActions; diff --git a/app/src/main/java/com/zwl/mybehaviordemo/gaode/GaoDeDetailActivity.java b/app/src/main/java/com/zwl/mybehaviordemo/gaode/GaoDeDetailActivity.java index 4ee9dc9..956701b 100644 --- a/app/src/main/java/com/zwl/mybehaviordemo/gaode/GaoDeDetailActivity.java +++ b/app/src/main/java/com/zwl/mybehaviordemo/gaode/GaoDeDetailActivity.java @@ -15,6 +15,7 @@ /** * 高德地址详情滑动效果 + * */ public class GaoDeDetailActivity extends AppCompatActivity { private static final String TAG = "GaoDeDetailActivity"; diff --git a/app/src/main/res/values/attrs.xml b/app/src/main/res/values/attrs.xml index bab3609..d9c4959 100644 --- a/app/src/main/res/values/attrs.xml +++ b/app/src/main/res/values/attrs.xml @@ -3,8 +3,8 @@ - - + + diff --git a/gif/fgaode.gif b/gif/fgaode.gif new file mode 100644 index 0000000..4a98cc4 Binary files /dev/null and b/gif/fgaode.gif differ diff --git a/gif/gaode.gif b/gif/gaode.gif new file mode 100644 index 0000000..4ba176c Binary files /dev/null and b/gif/gaode.gif differ diff --git a/mp4/show.gif b/mp4/show.gif deleted file mode 100644 index e1eaa1c..0000000 Binary files a/mp4/show.gif and /dev/null differ diff --git a/mp4/show.mp4 b/mp4/show.mp4 deleted file mode 100644 index b6c4760..0000000 Binary files a/mp4/show.mp4 and /dev/null differ diff --git a/settings.gradle b/settings.gradle index e4edd3f..7a553fb 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,2 +1,2 @@ include ':app' -rootProject.name = "MyBehaviorDemo" \ No newline at end of file +rootProject.name = "FGaoDeIndexDemo" \ No newline at end of file