SetParamActivity.java
5.46 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
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
142
143
package com.vhall.guangfa;
import android.annotation.SuppressLint;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.view.View;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;
import com.vhall.business.VhallSDK;
import com.vhall.push.VHLivePushFormat;
import com.vhall.uilibs.Param;
/**
* 主界面的Activity
*/
public class SetParamActivity extends FragmentActivity {
Param param;
EditText et_bro_token, et_bro_id, et_video_bitrate, et_video_framerate, et_watch_id, et_key, et_buffersecond;
TextView et_userid, et_usernickname;
RadioGroup rg_type;
RadioButton rb_hdpi, rb_xhdpi, radioButtonHD, radioButtonSD, radioButtonUHD;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.set_activity);
param = VhallApplication.param;
et_bro_token = (EditText) this.findViewById(R.id.et_bro_token);
et_bro_id = (EditText) this.findViewById(R.id.et_bro_id);
et_video_bitrate = (EditText) this.findViewById(R.id.et_video_bitrate);
et_video_framerate = (EditText) this.findViewById(R.id.et_video_framerate);
et_watch_id = (EditText) this.findViewById(R.id.et_watch_id);
et_key = (EditText) this.findViewById(R.id.et_key);
et_buffersecond = (EditText) this.findViewById(R.id.et_buffersecond);
et_userid = (TextView) this.findViewById(R.id.et_userid);
et_usernickname = (TextView) this.findViewById(R.id.et_usernickname);
rg_type = (RadioGroup) this.findViewById(R.id.rg_type);
rb_hdpi = (RadioButton) this.findViewById(R.id.rb_hdpi);
rb_xhdpi = (RadioButton) this.findViewById(R.id.rb_xhdpi);
radioButtonHD = this.findViewById(R.id.interactive_param_hd);
radioButtonSD = this.findViewById(R.id.interactive_param_sd);
radioButtonUHD = this.findViewById(R.id.interactive_param_uhd);
radioButtonSD.isChecked();
}
@Override
protected void onResume() {
super.onResume();
param = VhallApplication.getParam("");
initData();
}
@SuppressLint("MissingPermission")
private void initData() {
et_bro_token.setText(param.broToken);
et_bro_id.setText(param.broId);
et_video_bitrate.setText(String.valueOf(param.videoBitrate));
et_video_framerate.setText(String.valueOf(param.videoFrameRate));
et_watch_id.setText(param.watchId);
et_key.setText(param.key);
et_buffersecond.setText(String.valueOf(param.bufferSecond));
TelephonyManager telephonyMgr = (TelephonyManager) this.getSystemService(TELEPHONY_SERVICE);
et_userid.setText(TextUtils.isEmpty(VhallSDK.getUserName()) ? telephonyMgr.getDeviceId() : VhallSDK.getUserName());
et_usernickname.setText(TextUtils.isEmpty(VhallSDK.getUserNickname()) ? Build.BRAND + getString(R.string.phone_user) : VhallSDK.getUserNickname());
if (param.pixel_type == VHLivePushFormat.PUSH_MODE_HD) {
rb_hdpi.setChecked(true);
} else if (param.pixel_type == VHLivePushFormat.PUSH_MODE_XXHD) {
rb_xhdpi.setChecked(true);
}
// try {
// PackageManager pm = getPackageManager();
// pm.getPackageInfo("com.vhall.appset", PackageManager.GET_ACTIVITIES);
// } catch (PackageManager.NameNotFoundException e) {
// e.printStackTrace();
// findViewById(R.id.app_set).setVisibility(View.GONE);
// }
}
public void backClick(View view) {
param.broToken = et_bro_token.getText().toString();
param.broId = et_bro_id.getText().toString();
int videoBitrate = 0;
try {
videoBitrate = Integer.parseInt(et_video_bitrate.getText().toString());
} catch (NumberFormatException e) {
e.printStackTrace();
}
param.videoBitrate = videoBitrate == 0 ? 500 : videoBitrate;
int videoFrameRate = 0;
try {
videoFrameRate = Integer.parseInt(et_video_framerate.getText().toString());
} catch (NumberFormatException e) {
e.printStackTrace();
}
param.videoFrameRate = videoFrameRate == 0 ? 20 : videoFrameRate;
param.watchId = et_watch_id.getText().toString();
param.key = et_key.getText().toString();
int bufferSeconds = -1;
try {
bufferSeconds = Integer.parseInt(et_buffersecond.getText().toString());
} catch (NumberFormatException e) {
e.printStackTrace();
}
param.bufferSecond = bufferSeconds;
if (rb_hdpi.isChecked()) {
param.pixel_type = VHLivePushFormat.PUSH_MODE_HD;
} else if (rb_xhdpi.isChecked()) {
param.pixel_type = VHLivePushFormat.PUSH_MODE_XXHD;
}
// if (radioButtonSD.isChecked()) {
// param.interactive_definition = VHILSS.SD;
// } else if (radioButtonHD.isChecked()) {
// param.interactive_definition = VHILSS.HD;
// } else if (radioButtonUHD.isChecked()) {
// param.interactive_definition = VHILSS.UHD;
// }
VhallApplication.setParam(param);
finish();
}
@Override
public void onBackPressed() {
backClick(null);
}
}