add 昊华两个入口
parent
e0b6e04e55
commit
b6ddf680b9
@ -0,0 +1,59 @@
|
||||
package com.example.writeepc;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.KeyEvent;
|
||||
import android.widget.RadioButton;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.example.writeepc.base.BaseActivity;
|
||||
import com.example.writeepc.base.MyApplication;
|
||||
import com.handheld.uhfr.UHFRManager;
|
||||
|
||||
public class HomeActivity2 extends BaseActivity {
|
||||
private UHFRManager uhfrManager;
|
||||
private long exitTime = 0L;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_home2);
|
||||
uhfrManager = UHFRManager.getInstance();
|
||||
MyApplication.getApplication().setUhfrManager(uhfrManager);
|
||||
|
||||
RadioButton button4 = this.findViewById(R.id.home2_4);
|
||||
RadioButton button3 = this.findViewById(R.id.home2_3);
|
||||
button4.setOnClickListener(v -> {
|
||||
startActivity(new Intent(this, SettingsActivity2.class));
|
||||
});
|
||||
|
||||
button3.setOnClickListener(v -> {
|
||||
startActivity(new Intent(this, IntentSelectActivity.class));
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||
if (keyCode == 4) {
|
||||
if ((System.currentTimeMillis() - exitTime) > 2000) {
|
||||
Toast.makeText(getApplicationContext(), "再按一次退出程序", Toast.LENGTH_SHORT).show();
|
||||
exitTime = System.currentTimeMillis();
|
||||
return true;
|
||||
} else {
|
||||
finish();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
if (uhfrManager != null) {
|
||||
uhfrManager.close();
|
||||
uhfrManager = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,45 @@
|
||||
package com.example.writeepc;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
import android.widget.Spinner;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.databinding.DataBindingUtil;
|
||||
|
||||
import com.example.writeepc.databinding.SettingsActivity2Binding;
|
||||
import com.example.writeepc.databinding.SettingsActivityBinding;
|
||||
import com.example.writeepc.utils.SharedPreferencesUtils;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class SettingsActivity2 extends AppCompatActivity {
|
||||
|
||||
private Spinner powerTrace;
|
||||
private EditText settingIp;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
SettingsActivity2Binding binding =
|
||||
DataBindingUtil.setContentView(this, R.layout.settings_activity2);
|
||||
|
||||
powerTrace = binding.selectPowerTrace;
|
||||
settingIp = binding.settingIp;
|
||||
|
||||
String tracePower = SharedPreferencesUtils.getstring("powerTrace2", "22");
|
||||
List<String> powerList = Arrays.asList(getResources().getStringArray(R.array.power));
|
||||
|
||||
powerTrace.setSelection(powerList.indexOf(tracePower));
|
||||
settingIp.setText(SharedPreferencesUtils.getstring("ip", "https://rfidpub.haohuatire.com:7443"));
|
||||
}
|
||||
|
||||
public void saveInfo(View view) {
|
||||
|
||||
SharedPreferencesUtils.putstring("powerTrace2", powerTrace.getSelectedItem().toString());
|
||||
SharedPreferencesUtils.putstring("ip", settingIp.getText().toString());
|
||||
finish();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,58 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
tools:context=".HomeActivity2">
|
||||
|
||||
<TextView
|
||||
|
||||
style="@style/info_text"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="55dp"
|
||||
android:background="#6750A4"
|
||||
android:letterSpacing="0.2"
|
||||
android:text="主页"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="22sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
|
||||
|
||||
<RadioGroup
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="20dp"
|
||||
android:orientation="horizontal">
|
||||
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/home2_3"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:button="@null"
|
||||
android:drawableTop="@mipmap/ic_info"
|
||||
android:drawablePadding="10dp"
|
||||
android:gravity="center"
|
||||
android:text="轮胎信息查询"
|
||||
android:textSize="20sp" />
|
||||
<RadioButton
|
||||
android:id="@+id/home2_4"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:button="@null"
|
||||
android:drawableTop="@mipmap/home_setting"
|
||||
android:drawablePadding="10dp"
|
||||
android:gravity="center"
|
||||
android:text="设置"
|
||||
android:textSize="20sp" />
|
||||
|
||||
</RadioGroup>
|
||||
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
@ -0,0 +1,85 @@
|
||||
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<data>
|
||||
|
||||
</data>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
tools:context=".SettingsActivity2">
|
||||
|
||||
<TextView
|
||||
|
||||
style="@style/info_text"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="55dp"
|
||||
android:layout_gravity="center"
|
||||
android:background="#6750A4"
|
||||
android:letterSpacing="1"
|
||||
android:text="设置"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="22sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="45dp"
|
||||
android:layout_marginTop="20dp"
|
||||
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
style="@style/info_text"
|
||||
android:layout_width="110dp"
|
||||
android:layout_height="45dp"
|
||||
android:layout_gravity="center"
|
||||
android:text="追溯功率:" />
|
||||
|
||||
<Spinner
|
||||
android:id="@+id/select_power_trace"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="45dp"
|
||||
android:layout_gravity="center"
|
||||
android:entries="@array/power"
|
||||
android:textAlignment="center" />
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
|
||||
<TextView
|
||||
style="@style/info_text"
|
||||
android:layout_width="110dp"
|
||||
android:layout_height="45dp"
|
||||
android:layout_gravity="center|left"
|
||||
android:text="请求地址:" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/setting_ip"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="45dp"
|
||||
android:layout_gravity="center"
|
||||
android:entries="@array/power"
|
||||
android:lines="1"
|
||||
android:textAlignment="center" />
|
||||
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1" />
|
||||
|
||||
<Button
|
||||
style="@style/button_style"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="20dp"
|
||||
android:onClick="saveInfo"
|
||||
android:text="保存并退出" />
|
||||
</LinearLayout>
|
||||
</layout>
|
||||
Loading…
Reference in New Issue