The setViewPagerScroller method uses the kotlin anonymous inner class . This is part of an βobjectβ that has no real counterpart in Java syntax.
private void setViewPagerScroller() { try { Field scrollerField = ViewPager.class.getDeclaredField("mScroller"); scrollerField.setAccessible(true); Field interpolator = ViewPager.class.getDeclaredField("sInterpolator"); interpolator.setAccessible(true); Scroller scroller = new Scroller(this, (android.view.animation.Interpolator) interpolator.get(null)){ @Override public void startScroll(int startX, int startY, int dx, int dy, int duration) { super.startScroll(startX, startY, dx, dy, duration * 7); } } scrollerField.set(viewPager, scroller); } catch (NoSuchFieldException error) {
And the as keyword is like casting in java. Hope you can use this to translate fun generateFinalButtonBehaviour() , it contains more than one.
The Lazy construct unsurprisingly gets more details in java. You must use the discipline not to access the viewpager incorrectly if you decide to follow the structure below.
private LockableViewPager viewPager; private LockableViewPager getViewPager(){ if(viewPager == null){
You can also use the class to more accurately represent the lazy initialization of your fields. (So ββthat you cannot mistakenly access the field that you would like to lazily initialize). It gets even more detailed, but may be worth it.
source share