-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAbstractFragmentActivity.java
More file actions
99 lines (83 loc) · 2.39 KB
/
AbstractFragmentActivity.java
File metadata and controls
99 lines (83 loc) · 2.39 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
package com.administrator.abstractviewsample.AbstractView;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TextView;
/**
* Created by huangxy on 2016/3/3.
* https://github.com/GitSmark/AbstractView
*/
public abstract class AbstractFragmentActivity extends FragmentActivity implements OnClickListener {
protected abstract int getLayoutResId();
protected abstract void initView();
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(getLayoutResId());
beforeInitView();
initView();
getData();
Other();
}
@SuppressWarnings("uncheckedz")
protected <T extends View> T $find(int Resid) {
return (T) findViewById(Resid);
}
@SuppressWarnings("uncheckedz")
protected <T extends View> T $find(View v, int Resid) {
return (T) v.findViewById(Resid);
}
@SuppressWarnings("uncheckedz")
protected <T extends View> T $click(int Resid) {
T t = (T) findViewById(Resid);
try {t.setOnClickListener(this);
}catch (Exception e){}
return t;
}
@SuppressWarnings("uncheckedz")
protected <T extends View> T $click(View v, int Resid) {
T t = (T) v.findViewById(Resid);
try {t.setOnClickListener(this);
}catch (Exception e){}
return t;
}
@SuppressWarnings("uncheckedz")
protected <T extends View> T $onClick(int Resid, OnClickListener listener) {
T t = (T) findViewById(Resid);
try {t.setOnClickListener(listener);
}catch (Exception e){}
return t;
}
@SuppressWarnings("uncheckedz")
protected <T extends View> T $onClick(View v, int Resid, OnClickListener listener) {
T t = (T) v.findViewById(Resid);
try {t.setOnClickListener(listener);
}catch (Exception e){}
return t;
}
protected void $Title(int id, String text){
try {
TextView tv = (TextView) findViewById(id);
tv.setText(text);
}catch (Exception e){
}
}
protected void $Finish(int id){
try {
findViewById(id).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
beforeFinish();
finish();
}
});
}catch (Exception e){
}
}
public void beforeInitView() {}
public void beforeFinish() {}
public void getData() {}
public void Other() {}
}