forked from Tencent/Hippy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(android): add
nestedScrollPriority
for ListView and ScrollView
* feat(android): squash branch scroll_conflict (Tencent#6) * fix(android): nested scroll feature - edit priority api - scrollview prevent nested scroll when enabled paging - fix viewpager vertical issue - viewpager nested scroll - translate comments * fix(android): Eltonqin/netscroll bugfix (#3) * fix(android):HorizonScrollView may throw exception when handle onInterceptTouchEvent * fix(android):post task still run after remove * fix(android):post task still run after remove,modify format Co-authored-by: eltonqin <[email protected]> * fix(android): nested scroll feature - viewpager nested scroll issue * feat(docs): update docs Co-authored-by: HOHOHOTangoDown <[email protected]> Co-authored-by: eltonqin <[email protected]> * fix(android): nested scroll conflicts with pull refresh * feat(docs, demo): update docs and demos Co-authored-by: HOHOHOTangoDown <[email protected]> Co-authored-by: eltonqin <[email protected]>
- Loading branch information
Showing
19 changed files
with
931 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
android/sdk/src/main/java/com/tencent/mtt/hippy/views/common/HippyNestedScrollComponent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* Tencent is pleased to support the open source community by making Hippy available. | ||
* Copyright (C) 2018 THL A29 Limited, a Tencent company. All rights reserved. | ||
* | ||
* 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. | ||
*/ | ||
|
||
package com.tencent.mtt.hippy.views.common; | ||
|
||
import androidx.core.view.NestedScrollingChild; | ||
import androidx.core.view.NestedScrollingChild2; | ||
import androidx.core.view.NestedScrollingParent; | ||
import androidx.core.view.NestedScrollingParent2; | ||
|
||
public interface HippyNestedScrollComponent { | ||
|
||
String PROP_PRIORITY = "nestedScrollPriority"; | ||
String PROP_LEFT_PRIORITY = "nestedScrollLeftPriority"; | ||
String PROP_TOP_PRIORITY = "nestedScrollTopPriority"; | ||
String PROP_RIGHT_PRIORITY = "nestedScrollRightPriority"; | ||
String PROP_BOTTOM_PRIORITY = "nestedScrollBottomPriority"; | ||
|
||
String PRIORITY_PARENT = "parent"; | ||
String PRIORITY_SELF = "self"; | ||
String PRIORITY_NONE = "none"; | ||
|
||
int DIRECTION_INVALID = -1; | ||
int DIRECTION_ALL = 0; | ||
int DIRECTION_LEFT = 1; | ||
int DIRECTION_TOP = 2; | ||
int DIRECTION_RIGHT = 3; | ||
int DIRECTION_BOTTOM = 4; | ||
|
||
void setNestedScrollPriority(int direction, Priority priority); | ||
|
||
Priority getNestedScrollPriority(int direction); | ||
|
||
enum Priority { | ||
NOT_SET, | ||
PARENT, | ||
SELF, | ||
NONE, | ||
} | ||
|
||
/** | ||
* Nested scroll interface declaration | ||
*/ | ||
interface HippyNestedScrollTarget extends HippyNestedScrollComponent, NestedScrollingParent, | ||
NestedScrollingChild { | ||
|
||
} | ||
|
||
/** | ||
* Added non-touch scrolling type than {@link HippyNestedScrollTarget} | ||
*/ | ||
interface HippyNestedScrollTarget2 extends HippyNestedScrollTarget, NestedScrollingParent2, | ||
NestedScrollingChild2 { | ||
|
||
} | ||
} |
73 changes: 73 additions & 0 deletions
73
android/sdk/src/main/java/com/tencent/mtt/hippy/views/common/HippyNestedScrollHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/* Tencent is pleased to support the open source community by making Hippy available. | ||
* Copyright (C) 2018 THL A29 Limited, a Tencent company. All rights reserved. | ||
* | ||
* 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. | ||
*/ | ||
|
||
package com.tencent.mtt.hippy.views.common; | ||
|
||
import static com.tencent.mtt.hippy.views.common.HippyNestedScrollComponent.DIRECTION_BOTTOM; | ||
import static com.tencent.mtt.hippy.views.common.HippyNestedScrollComponent.DIRECTION_LEFT; | ||
import static com.tencent.mtt.hippy.views.common.HippyNestedScrollComponent.DIRECTION_RIGHT; | ||
import static com.tencent.mtt.hippy.views.common.HippyNestedScrollComponent.DIRECTION_TOP; | ||
import static com.tencent.mtt.hippy.views.common.HippyNestedScrollComponent.PRIORITY_NONE; | ||
import static com.tencent.mtt.hippy.views.common.HippyNestedScrollComponent.PRIORITY_PARENT; | ||
import static com.tencent.mtt.hippy.views.common.HippyNestedScrollComponent.PRIORITY_SELF; | ||
import static com.tencent.mtt.hippy.views.common.HippyNestedScrollComponent.Priority; | ||
|
||
import android.view.View; | ||
import com.tencent.mtt.hippy.views.common.HippyNestedScrollComponent.HippyNestedScrollTarget; | ||
|
||
public class HippyNestedScrollHelper { | ||
|
||
public static Priority priorityOf(String name) { | ||
switch (name) { | ||
case PRIORITY_SELF: | ||
return Priority.SELF; | ||
case PRIORITY_PARENT: | ||
return Priority.PARENT; | ||
case PRIORITY_NONE: | ||
return Priority.NONE; | ||
default: | ||
throw new RuntimeException("Invalid priority: " + name); | ||
} | ||
} | ||
|
||
public static Priority priorityOfX(View target, int dx) { | ||
// not scrolling, priority is NONE | ||
if (dx == 0) { | ||
return Priority.NONE; | ||
} | ||
// non-HippyNestedScrollTarget View, priority is SELF | ||
if (!(target instanceof HippyNestedScrollTarget)) { | ||
return Priority.SELF; | ||
} | ||
// get priority from target by direction | ||
return ((HippyNestedScrollTarget) target).getNestedScrollPriority( | ||
dx > 0 ? DIRECTION_LEFT : DIRECTION_RIGHT); | ||
} | ||
|
||
public static Priority priorityOfY(View target, int dy) { | ||
// not scrolling, priority is NONE | ||
if (dy == 0) { | ||
return Priority.NONE; | ||
} | ||
// non-HippyNestedScrollTarget View, priority is SELF | ||
if (!(target instanceof HippyNestedScrollTarget)) { | ||
return Priority.SELF; | ||
} | ||
// get priority from target by direction | ||
return ((HippyNestedScrollTarget) target).getNestedScrollPriority( | ||
dy > 0 ? DIRECTION_TOP : DIRECTION_BOTTOM); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.