My app has a tabbed screen with three fragments, two of which are the same but with different data.
Clicking the comment down the bottom brings up the full list of comments and clicking the [x] closes the comments. This is done through animations and .setVisibility().
The problem is I can only do this once as clicking the comment after closing it does nothing.
Bringing up the comments is shown here - from debugging, the onClick fires if I don't mess with the visibilities so they must be causing a problem somewhere
comment_overview.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
handleCommentOverviewClick(v);
}
});
...
private void handleCommentOverviewClick(View v) {
Log.d("OPEN", "open");
scrollView.fullScroll(ScrollView.FOCUS_UP);
Animation bottomUp = AnimationUtils.loadAnimation(getContext(),
R.anim.slide_in_bottom);
bottomUp.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
bottom_info_section.setVisibility(View.GONE);
// animation.cancel();
}
@Override
public void onAnimationRepeat(Animation animation) {
}
});
comment_section.startAnimation(bottomUp);
comment_section.setVisibility(View.VISIBLE);
}
Closing the comments is similar and shown below
private void handleCommentsClose(View v) {
Log.d("CLOSE", "cls");
Animation topDown = AnimationUtils.loadAnimation(getContext(),
R.anim.slide_out_bottom);
topDown.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {}
@Override
public void onAnimationEnd(Animation animation) {
comment_section.setVisibility(View.GONE);
}
@Override
public void onAnimationRepeat(Animation animation) {}
});
comment_section.startAnimation(topDown);
bottom_info_section.setVisibility(View.VISIBLE);
}
I've tried following advice of making the fragment implement OnClickListener and handling each clickable in a switch but I got the same behaviour - it would work once but not again unless I navigated away and came back.
Would love any suggestions as I'm kinda stuck