mirror of https://github.com/ThmmyNoLife/mTHMMY
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.
51 lines
1.7 KiB
51 lines
1.7 KiB
package gr.thmmy.mthmmy.base;
|
|
|
|
import android.content.Context;
|
|
import android.os.Bundle;
|
|
import android.support.annotation.Nullable;
|
|
import android.support.v4.app.Fragment;
|
|
|
|
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;
|
|
|
|
protected static OkHttpClient client;
|
|
|
|
@Override
|
|
public void onCreate(@Nullable Bundle savedInstanceState) {
|
|
super.onCreate(savedInstanceState);
|
|
//int 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
|
|
}
|
|
|
|
@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 {}
|
|
}
|
|
|