101 lines
2.1 KiB
Java
101 lines
2.1 KiB
Java
package com.gh.base;
|
|
|
|
import android.os.Bundle;
|
|
import android.support.annotation.Nullable;
|
|
import android.support.v4.app.Fragment;
|
|
import android.view.LayoutInflater;
|
|
import android.view.View;
|
|
import android.view.ViewGroup;
|
|
import android.widget.Toast;
|
|
|
|
import com.gh.common.util.EntranceUtils;
|
|
import com.gh.gamecenter.listener.OnCallBackListener;
|
|
|
|
import org.greenrobot.eventbus.EventBus;
|
|
|
|
import butterknife.ButterKnife;
|
|
|
|
/**
|
|
* Created by LGT on 2016/9/4.
|
|
* Fragment 基类
|
|
*/
|
|
public class BaseFragment extends Fragment implements OnCallBackListener {
|
|
|
|
protected View view;
|
|
|
|
protected boolean isEverpause;
|
|
|
|
protected String mEntrance;
|
|
|
|
protected void init(int layout) {
|
|
view = View.inflate(getActivity(), layout, null);
|
|
|
|
ButterKnife.bind(this, view);
|
|
}
|
|
|
|
@Override
|
|
public void onCreate(@Nullable Bundle savedInstanceState) {
|
|
super.onCreate(savedInstanceState);
|
|
mEntrance = getActivity().getIntent().getStringExtra(EntranceUtils.KEY_ENTRANCE);
|
|
isEverpause = false;
|
|
EventBus.getDefault().register(this);
|
|
}
|
|
|
|
@Nullable
|
|
@Override
|
|
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
|
|
@Nullable Bundle savedInstanceState) {
|
|
if (container != null) {
|
|
container.removeView(view);
|
|
}
|
|
return view;
|
|
}
|
|
|
|
@Override
|
|
public void onResume() {
|
|
super.onResume();
|
|
isEverpause = false;
|
|
}
|
|
|
|
@Override
|
|
public void onPause() {
|
|
super.onPause();
|
|
isEverpause = true;
|
|
}
|
|
|
|
@Override
|
|
public void onDestroy() {
|
|
super.onDestroy();
|
|
EventBus.getDefault().unregister(this);
|
|
}
|
|
|
|
public void toast(String msg) {
|
|
Toast.makeText(getContext(), msg, Toast.LENGTH_SHORT).show();
|
|
}
|
|
|
|
public boolean isEverpause() {
|
|
return isEverpause;
|
|
}
|
|
|
|
@Override
|
|
public void loadDone() {
|
|
|
|
}
|
|
|
|
@Override
|
|
public void loadDone(Object obj) {
|
|
|
|
}
|
|
|
|
@Override
|
|
public void loadError() {
|
|
|
|
}
|
|
|
|
@Override
|
|
public void loadEmpty() {
|
|
|
|
}
|
|
|
|
}
|