You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

72 lines
2.2 KiB
Java

8 months ago
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 HomeActivity extends BaseActivity {
private UHFRManager uhfrManager;
private long exitTime = 0L;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home);
uhfrManager = UHFRManager.getInstance();
MyApplication.getApplication().setUhfrManager(uhfrManager);
RadioButton button1 = this.findViewById(R.id.home_1);
RadioButton button2 = this.findViewById(R.id.home_2);
RadioButton button1_1 = this.findViewById(R.id.home_1_1);
RadioButton button4 = this.findViewById(R.id.home_4);
Intent intent = new Intent(this, ShuangqianActivity.class);
8 months ago
button1.setOnClickListener(v -> {
intent.putExtra("type",true);
startActivity(intent);
8 months ago
});
button1_1.setOnClickListener(v -> {
intent.putExtra("type",false);
startActivity(intent);
});
8 months ago
button2.setOnClickListener(v -> {
startActivity(new Intent(this, ShuangqianActivity2.class));
});
button4.setOnClickListener(v -> {
startActivity(new Intent(this, SettingsActivity.class));
});
8 months ago
}
@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;
}
}
}