Skip to content

Commit

Permalink
优化
Browse files Browse the repository at this point in the history
  • Loading branch information
周为龙 committed May 30, 2021
1 parent ea1da43 commit 87f4ffd
Show file tree
Hide file tree
Showing 11 changed files with 29 additions and 38 deletions.
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -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)
21 changes: 1 addition & 20 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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'
}
}
Expand All @@ -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"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -45,7 +44,7 @@
/**
* 高德首页滑动效果
*
* @author zhouweilong
* @author yixiaolunhui
*/
public class GaoDeBottomSheetBehavior<V extends View> extends CoordinatorLayout.Behavior<V> {
public static final int STATE_DRAGGING = 1;
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();

Expand All @@ -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) {
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@

import com.zwl.mybehaviordemo.R;


/**
* 高德首页按钮处理
*
* @author yixiaolunhui
*/
public class GaoDeBtnBehavior extends CoordinatorLayout.Behavior {

private View rightActions;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

/**
* 高德地址详情滑动效果
*
*/
public class GaoDeDetailActivity extends AppCompatActivity {
private static final String TAG = "GaoDeDetailActivity";
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

<declare-styleable name="BottomSheetBehavior_Layout">
<attr name="behavior_peekHeight" format="dimension" />
<attr name="behavior_hideable" format="boolean" />
<attr name="behavior_skipCollapsed" format="dimension" />
<attr name="behavior_hideAble" format="boolean" />
<attr name="behavior_skipCollapse" format="dimension" />
<attr name="behavior_middleHeight" format="dimension" />
<attr name="behavior_fitToContents" format="boolean" />
</declare-styleable>
Expand Down
Binary file added gif/fgaode.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added gif/gaode.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed mp4/show.gif
Binary file not shown.
Binary file removed mp4/show.mp4
Binary file not shown.
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
include ':app'
rootProject.name = "MyBehaviorDemo"
rootProject.name = "FGaoDeIndexDemo"

0 comments on commit 87f4ffd

Please sign in to comment.