-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
46 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
app/src/main/java/com/tananaev/giphy/ui/main/NpaGridLayoutManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package com.tananaev.giphy.ui.main; | ||
|
||
import android.content.Context; | ||
import android.util.AttributeSet; | ||
|
||
import androidx.recyclerview.widget.GridLayoutManager; | ||
|
||
/** | ||
* A workaround for crash: https://stackoverflow.com/q/30220771/2548565 | ||
*/ | ||
public class NpaGridLayoutManager extends GridLayoutManager { | ||
|
||
/** | ||
* Disable predictive animations. There is a bug in RecyclerView which causes views that | ||
* are being reloaded to pull invalid ViewHolders from the internal recycler stack if the | ||
* adapter size has decreased since the ViewHolder was recycled. | ||
*/ | ||
@Override | ||
public boolean supportsPredictiveItemAnimations() { | ||
return false; | ||
} | ||
|
||
public NpaGridLayoutManager(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { | ||
super(context, attrs, defStyleAttr, defStyleRes); | ||
} | ||
|
||
public NpaGridLayoutManager(Context context, int spanCount) { | ||
super(context, spanCount); | ||
} | ||
|
||
public NpaGridLayoutManager(Context context, int spanCount, int orientation, boolean reverseLayout) { | ||
super(context, spanCount, orientation, reverseLayout); | ||
} | ||
} |