package com.ntp.base;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;
import org.xutils.x;
/**
* 基类Fragment
* Created by lishuangxiang on 2015/12/13.
*/
public class BaseFragment extends Fragment {
private boolean injected = false;
/**
* 使用子类包名+类名打印日志,如果只用类名getClass().getSimpleName()
*/
protected String TAG = getClass().getName();
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
injected = true;
return x.view().inject(this, inflater, container);
}
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
if (!injected) {
x.view().inject(this, this.getView());
}
}
/**
* 提示
*/
protected void showToast(String msg) {
if (getActivity()!=null){
Toast.makeText(getActivity(), msg, Toast.LENGTH_LONG).show();
}
}
}