|
|
|
@ -16,17 +16,21 @@ import android.nfc.tech.NfcF;
|
|
|
|
import android.nfc.tech.NfcV;
|
|
|
|
import android.nfc.tech.NfcV;
|
|
|
|
import android.os.Bundle;
|
|
|
|
import android.os.Bundle;
|
|
|
|
import android.os.Parcelable;
|
|
|
|
import android.os.Parcelable;
|
|
|
|
|
|
|
|
import android.util.Log;
|
|
|
|
import android.view.View;
|
|
|
|
import android.view.View;
|
|
|
|
import android.view.WindowManager;
|
|
|
|
import android.view.WindowManager;
|
|
|
|
import android.widget.TextView;
|
|
|
|
import android.widget.TextView;
|
|
|
|
import android.widget.Toast;
|
|
|
|
import android.widget.Toast;
|
|
|
|
|
|
|
|
|
|
|
|
import com.rehome.sgbaxj.R;
|
|
|
|
import com.rehome.sgbaxj.R;
|
|
|
|
import com.rehome.sgbaxj.utils.ControllerActivity;
|
|
|
|
import com.rehome.sgbaxj.utils.ControllerActivity;
|
|
|
|
import com.zhy.autolayout.AutoLayoutActivity;
|
|
|
|
import com.zhy.autolayout.AutoLayoutActivity;
|
|
|
|
|
|
|
|
|
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
|
|
|
|
|
|
|
|
|
import androidx.annotation.LayoutRes;
|
|
|
|
import androidx.annotation.LayoutRes;
|
|
|
|
import androidx.appcompat.widget.Toolbar;
|
|
|
|
import androidx.appcompat.widget.Toolbar;
|
|
|
|
|
|
|
|
import com.rehome.sgbaxj.BuildConfig;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
@ -43,7 +47,9 @@ public abstract class BaseActivity extends AutoLayoutActivity {
|
|
|
|
private String[][] mTechLists;
|
|
|
|
private String[][] mTechLists;
|
|
|
|
private boolean isFirst = true;
|
|
|
|
private boolean isFirst = true;
|
|
|
|
private IntentFilter ndef;
|
|
|
|
private IntentFilter ndef;
|
|
|
|
|
|
|
|
|
|
|
|
public abstract int getContentViewID();
|
|
|
|
public abstract int getContentViewID();
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
|
super.onCreate(savedInstanceState);
|
|
|
|
super.onCreate(savedInstanceState);
|
|
|
|
@ -58,30 +64,38 @@ public abstract class BaseActivity extends AutoLayoutActivity {
|
|
|
|
initView();
|
|
|
|
initView();
|
|
|
|
initData();
|
|
|
|
initData();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void setContentView(@LayoutRes int layoutResID) {
|
|
|
|
public void setContentView(@LayoutRes int layoutResID) {
|
|
|
|
super.setContentView(layoutResID);
|
|
|
|
super.setContentView(layoutResID);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected abstract void initView();
|
|
|
|
protected abstract void initView();
|
|
|
|
|
|
|
|
|
|
|
|
public void initData() {
|
|
|
|
public void initData() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
protected void onDestroy() {
|
|
|
|
protected void onDestroy() {
|
|
|
|
super.onDestroy();
|
|
|
|
super.onDestroy();
|
|
|
|
ControllerActivity.getAppManager().finishActivity(this);
|
|
|
|
ControllerActivity.getAppManager().finishActivity(this);
|
|
|
|
context = null;
|
|
|
|
context = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void showToast(String text) {
|
|
|
|
public void showToast(String text) {
|
|
|
|
if (text != null && !text.trim().equals("")) {
|
|
|
|
if (text != null && !text.trim().equals("")) {
|
|
|
|
Toast.makeText(this, text, Toast.LENGTH_SHORT).show();
|
|
|
|
Toast.makeText(this, text, Toast.LENGTH_SHORT).show();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void showToast(int id) {
|
|
|
|
public void showToast(int id) {
|
|
|
|
Toast.makeText(this, id, Toast.LENGTH_SHORT).show();
|
|
|
|
Toast.makeText(this, id, Toast.LENGTH_SHORT).show();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void setTitle(String title) {
|
|
|
|
public void setTitle(String title) {
|
|
|
|
this.title.setText(title);
|
|
|
|
this.title.setText(title);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void setBack() {
|
|
|
|
public void setBack() {
|
|
|
|
mToolbar.setNavigationIcon(R.mipmap.back);
|
|
|
|
mToolbar.setNavigationIcon(R.mipmap.back);
|
|
|
|
mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
|
|
|
|
mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
|
|
|
|
@ -91,6 +105,7 @@ public abstract class BaseActivity extends AutoLayoutActivity {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private Boolean ifNFCUse() {
|
|
|
|
private Boolean ifNFCUse() {
|
|
|
|
if (nfcAdapter == null) {
|
|
|
|
if (nfcAdapter == null) {
|
|
|
|
// Toast.makeText(this, "设备不支持NFC!", Toast.LENGTH_SHORT).show();
|
|
|
|
// Toast.makeText(this, "设备不支持NFC!", Toast.LENGTH_SHORT).show();
|
|
|
|
@ -102,6 +117,7 @@ public abstract class BaseActivity extends AutoLayoutActivity {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void initNFC() {
|
|
|
|
public void initNFC() {
|
|
|
|
|
|
|
|
|
|
|
|
//NFC适配器,所有的关于NFC的操作从该适配器进行
|
|
|
|
//NFC适配器,所有的关于NFC的操作从该适配器进行
|
|
|
|
@ -140,6 +156,7 @@ public abstract class BaseActivity extends AutoLayoutActivity {
|
|
|
|
isFirst = false;
|
|
|
|
isFirst = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private String ByteArrayToHexString(byte[] inarray) { //converts byte arrays to string
|
|
|
|
private String ByteArrayToHexString(byte[] inarray) { //converts byte arrays to string
|
|
|
|
int i, j, in;
|
|
|
|
int i, j, in;
|
|
|
|
String[] hex = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F"};
|
|
|
|
String[] hex = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F"};
|
|
|
|
@ -153,6 +170,7 @@ public abstract class BaseActivity extends AutoLayoutActivity {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return out;
|
|
|
|
return out;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
protected void onPause() {
|
|
|
|
protected void onPause() {
|
|
|
|
super.onPause();
|
|
|
|
super.onPause();
|
|
|
|
@ -160,6 +178,7 @@ public abstract class BaseActivity extends AutoLayoutActivity {
|
|
|
|
nfcAdapter.disableForegroundDispatch(this);
|
|
|
|
nfcAdapter.disableForegroundDispatch(this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
protected void onResume() {
|
|
|
|
protected void onResume() {
|
|
|
|
super.onResume();
|
|
|
|
super.onResume();
|
|
|
|
@ -168,6 +187,7 @@ public abstract class BaseActivity extends AutoLayoutActivity {
|
|
|
|
mTechLists);
|
|
|
|
mTechLists);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
protected void onNewIntent(Intent intent) {
|
|
|
|
protected void onNewIntent(Intent intent) {
|
|
|
|
super.onNewIntent(intent);
|
|
|
|
super.onNewIntent(intent);
|
|
|
|
@ -179,6 +199,7 @@ public abstract class BaseActivity extends AutoLayoutActivity {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private boolean readFromTag(Intent intent) {
|
|
|
|
private boolean readFromTag(Intent intent) {
|
|
|
|
if (NfcAdapter.ACTION_NDEF_DISCOVERED.equals(intent.getAction())) {
|
|
|
|
if (NfcAdapter.ACTION_NDEF_DISCOVERED.equals(intent.getAction())) {
|
|
|
|
Parcelable[] rawArray = intent
|
|
|
|
Parcelable[] rawArray = intent
|
|
|
|
@ -195,6 +216,13 @@ public abstract class BaseActivity extends AutoLayoutActivity {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void handleNfc(String result) {
|
|
|
|
public void handleNfc(String result) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void showLog(String logText) {
|
|
|
|
|
|
|
|
if (BuildConfig.LOG_ERROR) {
|
|
|
|
|
|
|
|
Log.i("app", logText);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|