1

I have written a functionality where onClick of CardView item in Recyclerview, it starts an intent and goes to another activity. It works fine but the problem is the RecyclerView flickers/ Blinks for a short period, which I find it odd.

I tried multiple solutions and none worked.

I have attached one solution I tried but it did not work for me. By the way, I dont use notifyDataSetChanged() as I dont need it in my case. RecyclerView blinking after notifyDatasetChanged()

holder.listitemCard.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View view) {
        final Model gridItem = someList.get(position);
        setCurrentSomething(gridItem);
        Intent intent = new Intent(view.getContext(), SomeClass.class);
        view.getContext().startActivity(intent);

    }
});
Boken
  • 4,825
  • 10
  • 32
  • 42
user9683713
  • 185
  • 2
  • 13
  • 2
    Please take a moment to review the following how-to resources: [How to Ask](https://stackoverflow.com/help/how-to-ask) and [How to create complete examples](https://stackoverflow.com/help/mcve). **You did not add any code**, exception, stack trace. You also forgot tag language which you are using. – Boken May 19 '20 at 11:12
  • I have now added example @Boken – user9683713 May 19 '20 at 11:26
  • Please add video how it works, because base on current code it should works. What are you doing in `setCurrentSomething()` - maybe this method has some impact for this? You can try also comment all of the lines and uncomment one-by-one to find which if them is causing problem. – Boken May 19 '20 at 11:32
  • I fixed the issue – user9683713 May 19 '20 at 12:01
  • Would you add information what was wrong? :) – Boken May 19 '20 at 12:03
  • Yes @Boken. I added it. Thanks for giving hint by the way. It helped me to narrow down the issue by looking into setCurrentSomething() method. Sorry for naming convention, it is not my personal project and I had to change it into an example code. Check my answer – user9683713 May 19 '20 at 12:06

1 Answers1

0

The real issue was with setCurrentSomething(). I didnt look into this method as it was a maintenance code and not originally written by me. notifychanged was not needed here as we are using it for getting it into anyther activity and not for Search functionality or something like that. The issue is fixed now. Removing notifychanged () helped me. If not I should used that solution which I used at the appropriate place there

user9683713
  • 185
  • 2
  • 13