Closed ThirupathiMukkera closed 3 years ago
Do you mean you understand there is a Kotlin example on this, but you want a Java version?
Do you mean you understand there is a Kotlin example on this, but you want a Java version?
Yes, I need Java example for this.
I tried this, its working for me.
mPager = findViewById(R.id.viewPager);
pagerIndicator = findViewById(R.id.indicator);
mPager.setAdapter(new InfiniteSlideAdapter(this));
pagerIndicator.setHighlighterViewDelegate(new Function1<FrameLayout, View>() {
@Override
public View invoke(FrameLayout frameLayout) {
View selected = new View(HomeActivity.this);
selected.setLayoutParams(new LinearLayout.LayoutParams(DisplayUtils.convertDpToPx(16), DisplayUtils.convertDpToPx(2)));
selected.setBackgroundColor(Color.GRAY);
return selected;
}
});
pagerIndicator.setUnselectedViewDelegate(new Function1<LinearLayout, View>() {
@Override
public View invoke(LinearLayout linearLayout) {
View unselected = new View(HomeActivity.this);
unselected.setLayoutParams(new LinearLayout.LayoutParams(DisplayUtils.convertDpToPx(16), DisplayUtils.convertDpToPx(2)));
unselected.setBackgroundColor(Color.GRAY);
unselected.setAlpha(0.4F);
return unselected;
}
});
mPager.setOnIndicatorProgress(new Function2<Integer, Float, Unit>() {
@Override
public Unit invoke(Integer integer, Float aFloat) {
this.invoke(((Number)integer).intValue(), ((Number)aFloat).floatValue());
return Unit.INSTANCE;
}
public void invoke(int selectingPosition, float progress) {
pagerIndicator.onPageScrolled(selectingPosition, progress);
}
});
pagerIndicator.updateIndicatorCounts(mPager.getIndicatorCount());`
Could you write a code snippet on java to integrate this.