Created
July 27, 2015 11:35
-
-
Save vaibhav-jani/3ba1d83f9e6d73d0a2dc to your computer and use it in GitHub Desktop.
This file contains hidden or 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
/** | |
* Created by vaibhav.jani on 15-Jul-15. | |
*/ | |
public abstract class BaseFragment extends Fragment { | |
protected View rootView; | |
protected HomeActivity activity; | |
@Override | |
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { | |
rootView = inflater.inflate(getContentView(), container, false); | |
initViews(rootView); | |
return rootView; | |
} | |
protected abstract int getContentView(); | |
protected abstract void initViews(View rootView); | |
@Override | |
public void onAttach(Activity activity) { | |
super.onAttach(activity); | |
this.activity = (HomeActivity) activity; | |
} | |
@Override | |
public void onActivityCreated(Bundle savedInstanceState) { | |
super.onActivityCreated(savedInstanceState); | |
loadData(); | |
} | |
protected abstract void loadData(); | |
protected boolean finish(){ | |
/*if(activity instanceof HomeActivity) { | |
HomeActivity homeActivity = (HomeActivity) activity; | |
homeActivity.popFragment(); | |
}*/ | |
activity.popFragment(true); | |
return true; | |
} | |
public void showProgressDialog(String title, String message) { | |
if(isAdded()){ | |
activity.showProgressDialog(title, message); | |
} | |
} | |
public void dismissProgressDialog() { | |
if(isAdded()){ | |
activity.dismissProgressDialog(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment