Hello guys,
public class HomeFragment extends Fragment
{
private boolean isVisible;
private boolean isStarted;
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_home, container, false);
return view;
}
@Override
public void onStart() {
super.onStart();
isStarted = true;
if (isVisible)
{
// Do something
}
}
@Override
public void onStop() {
super.onStop();
isStarted = false;
}
@Override
public void setUserVisibleHint(boolean isVisibleToUser) {
super.setUserVisibleHint(isVisibleToUser);
isVisible = isVisibleToUser;
if (isVisible && isStarted)
{
// Do something
}
}
}
Thank you
No comments:
Post a Comment