导航语音的bugs
卡片切换
This commit is contained in:
@@ -26,6 +26,7 @@ import com.mogo.service.fragmentmanager.FragmentDescriptor;
|
||||
import com.mogo.service.fragmentmanager.IMogoFragmentManager;
|
||||
import com.mogo.service.module.IMogoModuleProvider;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
import com.yarolegovich.discretescrollview.DiscreteScrollLayoutManager;
|
||||
import com.yarolegovich.discretescrollview.DiscreteScrollView;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@@ -75,7 +76,7 @@ public class AppNavigatorFragment extends MvpFragment<AppNavigatorView, AppNavig
|
||||
|
||||
scroller = findViewById(R.id.module_apps_id_scroller);
|
||||
|
||||
scroller.setRatio(330/523F);
|
||||
scroller.setRatio(330 / 523F);
|
||||
//scroller.setRatio(176/279F);
|
||||
scroller.setSlideOnFling(true);
|
||||
scroller.addOnItemChangedListener(this);
|
||||
@@ -112,6 +113,10 @@ public class AppNavigatorFragment extends MvpFragment<AppNavigatorView, AppNavig
|
||||
//} );
|
||||
mApps.setOnClickListener(view -> {
|
||||
openAppsPanel();
|
||||
|
||||
//AppServiceHandler.getMogoCardManager()
|
||||
// .switch2(apps.get((int) (Math.random() * 6)).mModuleType);
|
||||
|
||||
trackNavigatorClickEvent(4);
|
||||
});
|
||||
AppServiceHandler.init(getContext());
|
||||
@@ -177,11 +182,9 @@ public class AppNavigatorFragment extends MvpFragment<AppNavigatorView, AppNavig
|
||||
@Override
|
||||
public void onCurrentItemChanged(@Nullable RecycleViewHolder viewHolder, int i) {
|
||||
Logger.d(TAG, "onCurrentItemChanged--position--" + i % CARD_SIZE);
|
||||
int currentPosition = i % CARD_SIZE - 2;
|
||||
if (currentPosition < 0) {
|
||||
currentPosition += CARD_SIZE;
|
||||
}
|
||||
this.currentPosition=currentPosition;
|
||||
int currentPosition = (i - 2) % CARD_SIZE;
|
||||
|
||||
//this.currentPosition=currentPosition;
|
||||
AppServiceHandler.getMogoCardManager().switch2(apps.get(i % CARD_SIZE).mModuleType);
|
||||
|
||||
//holder.showText();
|
||||
@@ -204,7 +207,6 @@ public class AppNavigatorFragment extends MvpFragment<AppNavigatorView, AppNavig
|
||||
//TextView tvTitle = viewHolder.getView(R.id.module_apps_id_app_name);
|
||||
//tvTitle.setTextColor(getResources().getColor(R.color.white_80));
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override public void onScrollEnd(@NonNull RecycleViewHolder viewHolder, int i) {
|
||||
@@ -217,33 +219,50 @@ public class AppNavigatorFragment extends MvpFragment<AppNavigatorView, AppNavig
|
||||
|
||||
}
|
||||
|
||||
private int currentPosition = 0;
|
||||
//private int currentPosition = 0;
|
||||
|
||||
@Override public void onSwitched(int position, String moduleName) {
|
||||
//int index = (position - scroller.getCurrentItem() % CARD_SIZE + 2) % CARD_SIZE;
|
||||
//int i = scroller.getCurrentItem() + index;
|
||||
//LinearLayoutManager layoutManager =
|
||||
// (LinearLayoutManager) scroller.getLayoutManager();
|
||||
//
|
||||
//layoutManager.smoothScrollToPosition();
|
||||
DiscreteScrollLayoutManager layoutManager =
|
||||
(DiscreteScrollLayoutManager) scroller.getLayoutManager();
|
||||
|
||||
int currentPosition = (scroller.getCurrentItem() - 2) % CARD_SIZE;
|
||||
|
||||
int index = position - currentPosition;
|
||||
|
||||
if (index == 0) {
|
||||
return;
|
||||
}
|
||||
if (index < -2) {
|
||||
if (index <= -5) {
|
||||
index = 1;
|
||||
} else if (index > 2) {
|
||||
} else if (index >= 5) {
|
||||
index = -1;
|
||||
}
|
||||
//很奇怪,但是位置就是相差
|
||||
if (index == -1) {
|
||||
index = -3;
|
||||
}
|
||||
//RecyclerView 的特性,如果是否在屏幕内
|
||||
//if (index < 0) {
|
||||
// index -= 2;
|
||||
//}
|
||||
|
||||
Logger.d(TAG, "position--" + position + "index--" + index);
|
||||
scroller.smoothScrollToPosition(scroller.getCurrentItem() + index);
|
||||
currentPosition = position;
|
||||
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);
|
||||
} else {
|
||||
layoutManager.startSmoothPendingScroll(layoutManager.getCurrentPosition() + index);
|
||||
}
|
||||
//layoutManager.smoothScrollToPosition(scroller.getCurrentItem() + index);
|
||||
//currentPosition = position;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user