-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathAppActivity.java
More file actions
78 lines (64 loc) · 1.93 KB
/
Copy pathAppActivity.java
File metadata and controls
78 lines (64 loc) · 1.93 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
package com.miaoyi.work.activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.MenuItem;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import com.miaoyi.work.R;
import com.miaoyi.work.fragment.BaseFragment;
public abstract class AppActivity extends BaseActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//set content view
setContentView(getContentViewId());
if (null != getIntent()) {
handleIntent(getIntent());
}
if (null == getSupportFragmentManager().getFragments()) {
BaseFragment fragment = getFirstFragment();
if (null != fragment) {
addFragment(fragment, "首页");
}
}
((ImageView) findViewById(R.id.back)).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
removeFragment();
}
});
}
@Override
protected int getContentViewId() {
return R.layout.activity_app;
}
@Override
protected int getFragmentContentId() {
return R.id.activity_app_container;
}
@Override
protected TextView getTopView() {
return (TextView) findViewById(R.id.tx_title);
}
/**
* get the first fragment
*/
protected abstract BaseFragment getFirstFragment();
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
removeFragment();
break;
}
return super.onOptionsItemSelected(item);
}
/**
* Handler for data
*
* @param intent
*/
protected void handleIntent(Intent intent) {
}
}