Created
January 13, 2017 10:33
-
-
Save cthulhuplush/629125a8227ee8ab700a3ef7168301fd to your computer and use it in GitHub Desktop.
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
public class SimpleFragment extends Fragment implements ViewWithSharedElements | |
{ | |
private static final String RESOURCE_LAYOUT = "RESOURCE_LAYOUT"; | |
private int mLayoutResourceId; | |
@Nullable @BindView(R.id.logo) ImageView mLogo; | |
@Nullable @BindView(R.id.button) ImageButton mButton; | |
public SimpleFragment() | |
{ | |
// Required empty public constructor | |
} | |
/** | |
* Use this factory method to create a new instance of | |
* this fragment using the provided parameters. | |
* | |
* @return A new instance of fragment Step1Fragment. | |
*/ | |
public static SimpleFragment newInstance(int resource) | |
{ | |
SimpleFragment fragment = new SimpleFragment(); | |
Bundle args = new Bundle(); | |
args.putInt(RESOURCE_LAYOUT, resource); | |
fragment.setArguments(args); | |
return fragment; | |
} | |
@Override | |
public void onCreate(Bundle savedInstanceState) | |
{ | |
super.onCreate(savedInstanceState); | |
if (getArguments() != null) | |
{ | |
mLayoutResourceId = getArguments().getInt(RESOURCE_LAYOUT); | |
} | |
} | |
@Override | |
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) | |
{ | |
View v = inflater.inflate(mLayoutResourceId, container, false); | |
if (v != null) | |
{ | |
ButterKnife.bind(this, v); | |
} | |
return v; | |
} | |
@Override | |
public List<View> getSharedElements() | |
{ | |
List<View> elements = new ArrayList<>(); | |
if (mLogo != null) elements.add(mLogo); | |
if (mButton != null) elements.add(mButton); | |
return elements; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment