|
|
|
|
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);
|
|
|
|
|
button1.setOnClickListener(v -> {
|
|
|
|
|
intent.putExtra("type",true);
|
|
|
|
|
startActivity(intent);
|
|
|
|
|
});
|
|
|
|
|
button1_1.setOnClickListener(v -> {
|
|
|
|
|
intent.putExtra("type",false);
|
|
|
|
|
startActivity(intent);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
button2.setOnClickListener(v -> {
|
|
|
|
|
startActivity(new Intent(this, ShuangqianActivity2.class));
|
|
|
|
|
});
|
|
|
|
|
button4.setOnClickListener(v -> {
|
|
|
|
|
startActivity(new Intent(this, SettingsActivity.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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|