my problem is the following : i have 2 animators xml files into android project :
bouceDown :
<?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/bounce_interpolator"> <translate android:fromYDelta="-100%p" android:toYDelta="0" android:duration="2500"/> </set> and bouceUp
<?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/bounce_interpolator"> <translate android:fromYDelta="0" android:toYDelta="-100%p" android:duration="2500"/> </set> they are triggering visibility of Recyclerview letters(a-z) with a nice boucing effect
i added them as following in my Java class :
public class FragmentResults extends Fragment implements Animation.AnimationListener { private Animation scrollUp, scrollDown; private boolean isAlreadyVisible = false; public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final View v = inflater.inflate(R.layout.fragment_results, container, false); .... buttonLetters.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { toggleRecycler(false); isAlreadyVisible = true; for (int i = 0; i < letters.size(); i++) { if (letters.get(i).getLetter().equals(buttonLetters.getText())) { ((MyGridlayout) recyclerViewLetters.getLayoutManager()).scrollToPositionWithOffset(i, 0); break; } } } }); ..... return v; } @Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); .... scrollDown.setAnimationListener(this); scrollUp.setAnimationListener(this); .... } private void toogleButtonLetterVisibility(View v) { if (entities.size() < 20) return; if (buttonLetters.getVisibility() == View.GONE) { buttonLetters.setVisibility(View.VISIBLE); v.postDelayed(new Runnable() { @Override public void run() { buttonLetters.setVisibility(View.GONE); } }, 4000); } } public void toggleRecycler(boolean isVisible) { if (isVisible) { if (isAlreadyVisible) recyclerViewLetters.startAnimation(scrollUp);//here i start animation scrollup isAlreadyVisible = false; } else { buttonLetters.setVisibility(View.GONE); recyclerViewLetters.startAnimation(scrollDown);//here i start animation scrolldown } } @Override public void onAnimationStart(Animation animation) { recyclerViewLetters.setFocusable(false);//here i try to remove recyclerview focusability if (isAlreadyVisible) { recyclerViewLetters.setVisibility(View.VISIBLE); Log.d("viewVisibility", "visible"); } } @Override public void onAnimationEnd(Animation animation) { if (!isAlreadyVisible) { recyclerViewLetters.setVisibility(View.GONE); } recyclerViewLetters.clearAnimation(); recyclerViewLetters.setFocusable(true);//here i try to make recyclerview focusable again } @Override public void onAnimationRepeat(Animation animation) { } } i wonder why this part isn't working :
@Override public void onAnimationStart(Animation animation) { recyclerViewLetters.setFocusable(false);//here i try to remove recyclerview focusability if (isAlreadyVisible) { recyclerViewLetters.setVisibility(View.VISIBLE); Log.d("viewVisibility", "visible"); } } @Override public void onAnimationEnd(Animation animation) { if (!isAlreadyVisible) { recyclerViewLetters.setVisibility(View.GONE); } recyclerViewLetters.clearAnimation(); recyclerViewLetters.setFocusable(true);//here i try to make recyclerview focusable again } @Override public void onAnimationRepeat(Animation animation) { } i tried also with setclickable(false/true) but it doesn't work, im still able to click my letters during animation effect, did someone encouter the same problem and find any solution?
No comments:
Post a Comment