4801fa6f
wutaian
添加资源文件,类文件
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
package com.sunvote.xpadapp.widget;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import com.sunvote.statusbar.view.BarItem;
import com.sunvote.xpadapp.R;
public class StatusBarView extends LinearLayout {
Context mContext;
|
263bab00
wutaian
修改bar wifi图标位置
|
18
19
|
//信号图标,基站编号,CH,终端ID,电池电量图标,系统时间,wifi
BarItem barSignal,barBasestation,barCh,barTerminalId,barBattery,barSystemtime,barWifi;
|
4801fa6f
wutaian
添加资源文件,类文件
|
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
|
public StatusBarView(Context context) {
this(context, null);
}
public StatusBarView(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
View view;
@SuppressLint("NewApi")
public StatusBarView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
init(context, attrs, defStyle);
}
private void init(Context ctx, AttributeSet attrs, int defStyle){
mContext=ctx;
LayoutInflater ll = (LayoutInflater)ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
ViewGroup.LayoutParams lp = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,ViewGroup.LayoutParams.WRAP_CONTENT);
view = ll.inflate(R.layout.status_icon_view, null);
view.setLayoutParams(lp);
barSignal = (BarItem)view.findViewById(R.id.bar_signal);
barBasestation = (BarItem) view.findViewById(R.id.bar_basestation);
barCh = (BarItem) view.findViewById(R.id.bar_ch);
barTerminalId = (BarItem) view.findViewById(R.id.bar_terminalId);
barBattery = (BarItem) view.findViewById(R.id.bar_battery);
barSystemtime = (BarItem) view.findViewById(R.id.bar_systemtime);
|
263bab00
wutaian
修改bar wifi图标位置
|
49
|
barWifi= (BarItem) view.findViewById(R.id.bar_wifi);
|
4801fa6f
wutaian
添加资源文件,类文件
|
50
51
52
53
54
55
56
57
58
59
60
|
addView(view);
}
public void setBackgroundColor(int color){
view.setBackgroundColor(color);
}
/**
* 设置信号图标
* @param rssi
*/
public void setStatusSignal(int rssi){
|
263bab00
wutaian
修改bar wifi图标位置
|
61
|
barSignal.setIcon(R.mipmap.signal);
|
4801fa6f
wutaian
添加资源文件,类文件
|
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
if (rssi < 95){
barSignal.setIcon(R.mipmap.signal_1);
}
if (rssi < 85){
barSignal.setIcon(R.mipmap.signal_2);
}
if (rssi < 75) {
barSignal.setIcon(R.mipmap.signal_3);
}
if (rssi < 65) {
barSignal.setIcon(R.mipmap.signal_4);
}
if (rssi < 55) {
barSignal.setIcon(R.mipmap.signal_5);
|
263bab00
wutaian
修改bar wifi图标位置
|
76
77
|
}
}
|
566e1fea
wutaian
修改bar图标
|
78
|
|
263bab00
wutaian
修改bar wifi图标位置
|
79
80
81
82
83
84
85
|
public void setStatusWifi(int wifi){
if(wifi > -100) {
barWifi.setVisibility(VISIBLE);
barWifi.setIcon(R.mipmap.wifi);
}else {
barWifi.setVisibility(GONE);
}
|
4801fa6f
wutaian
添加资源文件,类文件
|
86
87
|
}
|
263bab00
wutaian
修改bar wifi图标位置
|
88
|
|
4801fa6f
wutaian
添加资源文件,类文件
|
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
|
/**
* 设置基站编号
* @param value
*/
public void setStatusBarBaseId(int value){
barBasestation.setText(String.format("基站编号:%s",value+""));
}
/**
* 设置CH
* @param value
*/
public void setStatusCH(int value){
barCh.setText(String.format("CH:%s",value));
}
/**
* 设置终端编号
* @param value
*/
public void setStatusKeyId(int value){
barTerminalId.setText(String.format("终端编号:%s",value));
}
/**
* 设置电量
* @param battery
*/
public void setStatusBattery(int battery, String BatteryPercent){
if(battery > 0 && battery <= 10){
barBattery.setIcon(R.mipmap.battery);
}else if(battery > 10 && battery <= 40){
barBattery.setIcon(R.mipmap.battery_1);
}else if(battery > 40 && battery <= 60){
barBattery.setIcon(R.mipmap.battery_2);
}else if(battery > 60 && battery <= 80){
barBattery.setIcon(R.mipmap.battery_3);
}else if(battery > 80 && battery <= 100){
barBattery.setIcon(R.mipmap.battery_4);
}else{
barBattery.setIcon(R.mipmap.battery);
}
barBattery.setText(BatteryPercent);
}
/**
* 返回时间控件
* @param
*/
public BarItem getTimeCtl(){
return barSystemtime;
}
}
|