A mobile app for thmmy.gr
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

81 lines
2.2 KiB

package gr.thmmy.mthmmy.base;
8 years ago
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import mthmmy.utils.Report;
import okhttp3.OkHttpClient;
public abstract class BaseFragment extends Fragment {
protected static final String ARG_SECTION_NUMBER = "SectionNumber";
protected static final String ARG_TAG = "FragmentTAG";
protected FragmentInteractionListener fragmentInteractionListener;
private String TAG;
protected int sectionNumber;
protected static OkHttpClient client;
8 years ago
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
TAG = getArguments().getString(ARG_TAG);
sectionNumber = getArguments().getInt(ARG_SECTION_NUMBER);
if(client==null)
client = BaseApplication.getInstance().getClient(); //must check every time - e.g.
// becomes null when app restarts after crash
8 years ago
Report.d(TAG, "onCreate");
}
@Override
public void onStart() {
super.onStart();
Report.d(TAG, "onStart");
}
@Override
public void onResume() {
super.onResume();
Report.d(TAG, "onResume");
}
@Override
public void onPause() {
super.onPause();
Report.d(TAG, "onPause");
}
@Override
public void onStop() {
super.onStop();
Report.d(TAG, "onStop");
}
@Override
public void onAttach(Context context) {
super.onAttach(context);
if (context instanceof FragmentInteractionListener) {
fragmentInteractionListener = (FragmentInteractionListener) context;
} else {
throw new RuntimeException(context.toString()
+ " must implement OnFragmentInteractionListener");
}
}
@Override
public void onDetach() {
super.onDetach();
fragmentInteractionListener = null;
}
/**
* This interface MUST be extended by the fragment subclass AND implemented by
* the activity that contains it, to allow communication upon interaction,
* between the fragment and the activity/ other fragments
*/
public interface FragmentInteractionListener {}
}