CommonActivity.java
1.74 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
package com.lijinji.scan.util;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.lijinji.scan.R;
import butterknife.BindView;
import butterknife.OnClick;
/**
* Created by youjie on 2018/6/14.
*/
public class CommonActivity extends Activity {
@BindView(R.id.backImage)
ImageView backImage;
@BindView(R.id.commonTitle)
TextView commonTitle;
private ViewGroup viewGroup;
private Context mContext;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.setContentView(R.layout.activity_common);
mContext = this;
viewGroup = (ViewGroup) this.findViewById(R.id.basePageContainer);
initActivityOnCreate(savedInstanceState);
}
/**
* 页面初始化
*/
protected void initActivityOnCreate(Bundle savedInstanceState) {
}
@Override
public void setContentView(int layoutResID) {
LayoutInflater.from(this).inflate(layoutResID, viewGroup, true);
}
public void setBackImageVisible(int visible) {
if (backImage != null) {
backImage.setVisibility(visible);
}
}
public void setTitle(String message) {
if (commonTitle != null) {
commonTitle.setText(message);
}
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
return super.onKeyDown(keyCode, event);
}
@OnClick(R.id.backImage)
public void onClick() {
onBackPressed();
}
}