Skip to content

Instantly share code, notes, and snippets.

View SerhatSurguvec's full-sized avatar
🎯
Focusing

Serhat Sürgüveç SerhatSurguvec

🎯
Focusing
View GitHub Profile
@SerhatSurguvec
SerhatSurguvec / FragmentStateAdapter.java
Last active April 10, 2019 08:55
ViewPager2 Individual Options Menu Support for FragmentStateAdapter
/**
* Similar in behavior to {@link FragmentStatePagerAdapter}
* <p>
* Lifecycle within {@link RecyclerView}:
* <ul>
* <li>{@link RecyclerView.ViewHolder} initially an empty {@link FrameLayout}, serves as a
* re-usable container for a {@link Fragment} in later stages.
* <li>{@link RecyclerView.Adapter#onBindViewHolder} we ask for a {@link Fragment} for the
* position. If we already have the fragment, or have previously saved its state, we use those.
* <li>{@link RecyclerView.Adapter#onAttachedToWindow} we attach the {@link Fragment} to a
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.AttributeSet;
import android.view.View;