Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scroll To Position #97

Open
TasTugberk opened this issue Mar 19, 2018 · 1 comment
Open

Scroll To Position #97

TasTugberk opened this issue Mar 19, 2018 · 1 comment
Labels
can't reproduce Include please a sample project where I can reproduce the issue.

Comments

@TasTugberk
Copy link

TasTugberk commented Mar 19, 2018

Hi, I have an scroll item which have edit text,which is gravity set to center, inside it. Whenever I set inputType of this edit text to something, text,number or etc. it scrolls to next item when edit text is focused. To avoid that I write an focus change listener to onBindViewHolder method of adapter;
holder.textView.setOnFocusChangeListener(new View.OnFocusChangeListener() { @Override public void onFocusChange(View view, boolean b) { //textView.setGravity(Gravity.LEFT); if(b){ holder.textView.setTextColor(getResources().getColor(R.color.TabYellow)); discreteScrollView.scrollToPosition(infiniteAdapter.getClosestPosition(position)); } else { Toast.makeText(getActivity(),"Input lose focus",Toast.LENGTH_SHORT).show(); InputMethodManager imm = (InputMethodManager)context.getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(view.getWindowToken(), 0); holder.textView.setTextColor(getResources().getColor(R.color.white)); } } });

This piece of code works well in API 21,25 and 26, but it does not scroll back to current position in API 22 and 23.

@ketanmakwana
Copy link

Hi,
i am getting issue on scrollToPosition it says null object reference

java.lang.NullPointerException: Attempt to invoke virtual method 'void com.yarolegovich.discretescrollview.DiscreteScrollLayoutManager.scrollToPosition(int)' on a null object reference
at com.yarolegovich.discretescrollview.InfiniteScrollAdapter.resetRange(InfiniteScrollAdapter.java:132)
at com.yarolegovich.discretescrollview.InfiniteScrollAdapter.mapPositionToReal(InfiniteScrollAdapter.java:118)
at com.yarolegovich.discretescrollview.InfiniteScrollAdapter.getRealPosition(InfiniteScrollAdapter.java:83)
at com.bi.pizza2nite.ProductDetails.onCurrentItemChanged(ProductDetails.java:83)
at com.yarolegovich.discretescrollview.DiscreteScrollView.notifyCurrentItemChanged(DiscreteScrollView.java:187)
at com.yarolegovich.discretescrollview.DiscreteScrollView.access$700(DiscreteScrollView.java:22)
at com.yarolegovich.discretescrollview.DiscreteScrollView$ScrollStateListener.onScrollEnd(DiscreteScrollView.java:230)
at com.yarolegovich.discretescrollview.DiscreteScrollLayoutManager.onScrollStateChanged(DiscreteScrollLayoutManager.java:388)
at android.support.v7.widget.RecyclerView.dispatchOnScrollStateChanged(RecyclerView.java:4868)
at android.support.v7.widget.RecyclerView.setScrollState(RecyclerView.java:1467)
at android.support.v7.widget.RecyclerView$ViewFlinger.run(RecyclerView.java:5030)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:911)
at android.view.Choreographer.doCallbacks(Choreographer.java:713)
at android.view.Choreographer.doFrame(Choreographer.java:645)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:897)
at android.os.Handler.handleCallback(Handler.java:815)
at android.os.Handler.dispatchMessage(Handler.java:104)
at android.os.Looper.loop(Looper.java:207)
at android.app.ActivityThread.main(ActivityThread.java:5790)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1015)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:876)

@yarolegovich yarolegovich added the can't reproduce Include please a sample project where I can reproduce the issue. label Jul 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
can't reproduce Include please a sample project where I can reproduce the issue.
Projects
None yet
Development

No branches or pull requests

3 participants