This commit is contained in:
wangcongtao
2020-05-13 16:32:08 +08:00
parent 8bb106bd03
commit 448323e182
19 changed files with 352 additions and 234 deletions

View File

@@ -57,7 +57,7 @@ public class AppNavigatorFragment extends MvpFragment<AppNavigatorView, AppNavig
private IMogoModuleProvider mSearchProvider;
private IMogoAnalytics mMogoAnalytics;
private DiscreteScrollView scroller;
// private DiscreteScrollView scroller;
private static int CARD_SIZE = 6;
private AppIndicatorAdapter appIndicatorAdapter;
@@ -76,19 +76,19 @@ public class AppNavigatorFragment extends MvpFragment<AppNavigatorView, AppNavig
mApps = findViewById(R.id.module_apps_id_apps);
scroller = findViewById(R.id.module_apps_id_scroller);
scroller.setRatio(330 / 523F);
//scroller.setRatio(176/279F);
scroller.setSlideOnFling(true);
scroller.addOnItemChangedListener(this);
scroller.addScrollStateChangeListener(this);
//scroller.setItemTransitionTimeMillis(DiscreteScrollViewOptions.getTransitionTime());
apps = NavigatorApps.getApps();
CARD_SIZE = apps.size();
scroller.setItemTransformer(new CardScaleTransformer.Builder()
.setMinScale(0.84f)
.build());
// scroller = findViewById(R.id.module_apps_id_scroller);
//
// scroller.setRatio(330 / 523F);
// //scroller.setRatio(176/279F);
// scroller.setSlideOnFling(true);
// scroller.addOnItemChangedListener(this);
// scroller.addScrollStateChangeListener(this);
// //scroller.setItemTransitionTimeMillis(DiscreteScrollViewOptions.getTransitionTime());
// apps = NavigatorApps.getApps();
// CARD_SIZE = apps.size();
// scroller.setItemTransformer(new CardScaleTransformer.Builder()
// .setMinScale(0.84f)
// .build());
appIndicatorAdapter = new AppIndicatorAdapter(getContext(), apps);
@@ -99,8 +99,8 @@ public class AppNavigatorFragment extends MvpFragment<AppNavigatorView, AppNavig
}
});
scroller.setAdapter(appIndicatorAdapter);
scroller.scrollToPosition(Integer.MAX_VALUE / 2 - 1);
// scroller.setAdapter(appIndicatorAdapter);
// scroller.scrollToPosition(Integer.MAX_VALUE / 2 - 1);
//mNavigation.setOnClickListener( view -> {
// openSearchPanel();
// trackNavigatorClickEvent( 1 );
@@ -222,44 +222,44 @@ public class AppNavigatorFragment extends MvpFragment<AppNavigatorView, AppNavig
@Override public void onSwitched(int position, String moduleName) {
//int index = (position - scroller.getCurrentItem() % CARD_SIZE + 2) % CARD_SIZE;
//int i = scroller.getCurrentItem() + index;
DiscreteScrollLayoutManager layoutManager =
(DiscreteScrollLayoutManager) scroller.getLayoutManager();
int currentPosition = (scroller.getCurrentItem() - 2) % CARD_SIZE;
int index = position - currentPosition;
if (index == 0) {
return;
}
if (index <= -3) {
index += CARD_SIZE;
} else if (index >= 3) {
index = index - CARD_SIZE;
}
//RecyclerView 的特性,如果是否在屏幕内
//if (index < 0) {
// index -= 2;
//}
Logger.d(TAG, "position--"
+ position
+ "index--"
+ index
+ "scroll-->"
+ scroller.getCurrentItem()
+ index);
//scroller.setPendingScroll(getResources().getDimensionPixelSize(R.dimen.dp_137)*index);
//layoutManager.scrollToPositionWithOffset(scroller.getCurrentItem() + index,0);
//scroller.smoothScrollBy(getResources().getDimensionPixelSize(R.dimen.dp_137)*index,0);
if (Math.abs(index) == 1) {
scroller.smoothScrollBy(getResources().getDimensionPixelSize(R.dimen.dp_137) * index,
0, null, 10);
} else {
layoutManager.startSmoothPendingScroll(layoutManager.getCurrentPosition() + index);
}
// DiscreteScrollLayoutManager layoutManager =
// (DiscreteScrollLayoutManager) scroller.getLayoutManager();
//
// int currentPosition = (scroller.getCurrentItem() - 2) % CARD_SIZE;
//
// int index = position - currentPosition;
//
// if (index == 0) {
// return;
// }
// if (index <= -3) {
// index += CARD_SIZE;
// } else if (index >= 3) {
// index = index - CARD_SIZE;
// }
// //RecyclerView 的特性,如果是否在屏幕内
// //if (index < 0) {
// // index -= 2;
// //}
//
// Logger.d(TAG, "position--"
// + position
// + "index--"
// + index
// + "scroll-->"
// + scroller.getCurrentItem()
// + index);
//
// //scroller.setPendingScroll(getResources().getDimensionPixelSize(R.dimen.dp_137)*index);
// //layoutManager.scrollToPositionWithOffset(scroller.getCurrentItem() + index,0);
// //scroller.smoothScrollBy(getResources().getDimensionPixelSize(R.dimen.dp_137)*index,0);
//
// if (Math.abs(index) == 1) {
// scroller.smoothScrollBy(getResources().getDimensionPixelSize(R.dimen.dp_137) * index,
// 0, null, 10);
// } else {
// layoutManager.startSmoothPendingScroll(layoutManager.getCurrentPosition() + index);
// }
//layoutManager.smoothScrollToPosition(scroller.getCurrentItem() + index);
//currentPosition = position;
}