-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBaseFragment.java
40 lines (33 loc) · 956 Bytes
/
BaseFragment.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package cn.lxw.us.fragments;
import android.app.Activity;
import android.support.v4.app.Fragment;
import android.widget.Toast;
import cn.lxw.us.BaseActivity;
/**
* Created by Lianxw on 2015/8/1.
*
*/
public class BaseFragment extends Fragment {
protected void showToast(CharSequence msg) {
Toast.makeText(getActivity(),msg, Toast.LENGTH_SHORT).show();
}
protected void showProgress() {
BaseActivity activity = getBaseActivity();
if (activity!=null) {
activity.showProgress();
}
}
protected void hideProgress() {
BaseActivity activity = getBaseActivity();
if (activity!=null) {
activity.hideProgress();
}
}
private BaseActivity getBaseActivity() {
Activity activity = getActivity();
if (activity!=null && activity instanceof BaseActivity) {
return (BaseActivity)activity;
}
return null;
}
}