卡片联动效果
This commit is contained in:
@@ -7,6 +7,7 @@ import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.mogo.commons.mvp.MvpFragment;
|
||||
@@ -19,7 +20,6 @@ import com.mogo.service.cardmanager.IMogoCardChangedListener;
|
||||
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.DiscreteScrollView;
|
||||
import java.util.ArrayList;
|
||||
@@ -179,7 +179,13 @@ public class AppNavigatorFragment extends MvpFragment<AppNavigatorView, AppNavig
|
||||
|
||||
@Override
|
||||
public void onCurrentItemChanged(@Nullable RecyclerView.ViewHolder viewHolder, int i) {
|
||||
//AppServiceHandler.getMogoCardManager().invoke(i%CARD_SIZE,"");
|
||||
Logger.d(TAG, "onCurrentItemChanged--position--" + i % CARD_SIZE);
|
||||
int currentPosition = i % CARD_SIZE - 2;
|
||||
if (currentPosition < 0) {
|
||||
currentPosition += CARD_SIZE;
|
||||
}
|
||||
this.currentPosition=currentPosition;
|
||||
AppServiceHandler.getMogoCardManager().invoke(currentPosition, "");
|
||||
}
|
||||
|
||||
@Override public void onScrollStart(@NonNull RecyclerView.ViewHolder viewHolder, int i) {
|
||||
@@ -196,15 +202,33 @@ public class AppNavigatorFragment extends MvpFragment<AppNavigatorView, AppNavig
|
||||
|
||||
}
|
||||
|
||||
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;
|
||||
//DiscreteScrollLayoutManager layoutManager =
|
||||
// (DiscreteScrollLayoutManager) scroller.getLayoutManager();
|
||||
//int index = (position - scroller.getCurrentItem() % CARD_SIZE + 2) % CARD_SIZE;
|
||||
//int i = scroller.getCurrentItem() + index;
|
||||
//LinearLayoutManager layoutManager =
|
||||
// (LinearLayoutManager) scroller.getLayoutManager();
|
||||
//
|
||||
//layoutManager.smoothScrollToPosition();
|
||||
|
||||
Logger.d(TAG, "position" + index + "scroll" + i);
|
||||
scroller.smoothScrollToPosition(i);
|
||||
int index = position - currentPosition;
|
||||
|
||||
if (index == 0) {
|
||||
return;
|
||||
}
|
||||
if (index < -2) {
|
||||
index = 1;
|
||||
} else if (index > 2) {
|
||||
index = -1;
|
||||
}
|
||||
//很奇怪,但是位置就是相差
|
||||
if (index == -1) {
|
||||
index = -3;
|
||||
}
|
||||
|
||||
Logger.d(TAG, "position--" + position + "index--" + index);
|
||||
scroller.smoothScrollToPosition(scroller.getCurrentItem() + index);
|
||||
currentPosition = position;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user