logout, индикатор загрузки на экране регистрации
This commit is contained in:
@@ -37,14 +37,15 @@ import net.sourceforge.zbar.Symbol;
|
||||
import net.sourceforge.zbar.SymbolSet;
|
||||
import net.sourceforge.zbar.Config;
|
||||
import android.graphics.YuvImage;
|
||||
import android.view.MenuItem;
|
||||
|
||||
import com.dinect.checker.R;
|
||||
|
||||
public class CameraActivity extends AppCompatActivity {
|
||||
|
||||
private Camera mCamera;
|
||||
private Handler mAutoFocusHandler;
|
||||
private ImageScanner mScanner;
|
||||
private Handler mAutoFocusHandler = new Handler();
|
||||
private ImageScanner mScanner = new ImageScanner();
|
||||
private HashMap<String, Integer> mContours = new HashMap<>();
|
||||
|
||||
private boolean mBarcodeScanned = false;
|
||||
@@ -56,13 +57,7 @@ public class CameraActivity extends AppCompatActivity {
|
||||
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
setContentView(R.layout.a_scanner);
|
||||
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
|
||||
|
||||
mAutoFocusHandler = new Handler();
|
||||
mCamera = getCameraInstance();
|
||||
mScanner = new ImageScanner();
|
||||
|
||||
SurfaceView preview = (SurfaceView) findViewById(R.id.cameraPreview);
|
||||
SurfaceHolder holder = preview.getHolder();
|
||||
@@ -71,16 +66,18 @@ public class CameraActivity extends AppCompatActivity {
|
||||
setSupportActionBar(toolbar);
|
||||
|
||||
ActionBar actionBar = getSupportActionBar();
|
||||
|
||||
if (actionBar != null) {
|
||||
actionBar.setTitle(getString(R.string.scanner_title));
|
||||
actionBar.setDisplayHomeAsUpEnabled(true);
|
||||
}
|
||||
|
||||
|
||||
holder.addCallback(new SurfaceHolder.Callback() {
|
||||
@Override
|
||||
public void surfaceCreated(SurfaceHolder holder) {
|
||||
try {
|
||||
|
||||
mCamera = getCameraInstance();
|
||||
mCamera.setPreviewDisplay(holder);
|
||||
mCamera.startPreview();
|
||||
mCamera.setPreviewCallback(previewCallback);
|
||||
@@ -98,7 +95,7 @@ public class CameraActivity extends AppCompatActivity {
|
||||
|
||||
@Override
|
||||
public void surfaceDestroyed(SurfaceHolder holder) {
|
||||
|
||||
mCamera = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -109,6 +106,16 @@ public class CameraActivity extends AppCompatActivity {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
if (item.getItemId() == R.id.logout) {
|
||||
setResult(RESULT_OK);
|
||||
finish();
|
||||
return true;
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
|
||||
private void initCountours() {
|
||||
|
||||
|
||||
@@ -7,72 +7,73 @@ import android.util.Log;
|
||||
import android.content.SharedPreferences;
|
||||
import com.dinect.checker.activity.CameraActivity;
|
||||
import com.dinect.checker.service.RegistrationIntentService;
|
||||
|
||||
import io.flutter.app.FlutterActivity;
|
||||
import io.flutter.plugins.GeneratedPluginRegistrant;
|
||||
|
||||
import io.flutter.plugin.common.MethodCall;
|
||||
import io.flutter.plugin.common.MethodChannel;
|
||||
import io.flutter.plugin.common.MethodChannel.MethodCallHandler;
|
||||
import io.flutter.plugin.common.MethodChannel.Result;
|
||||
|
||||
import com.google.android.gms.iid.InstanceID;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class MainActivity extends FlutterActivity {
|
||||
|
||||
private static final String INSTANCE_ID_CHANNEL = "com.dinect.checker/instance_id";
|
||||
private static final String PREF_POS_TOKEN = "pref_pos_token";
|
||||
private static final int START_SCANNER_REQUEST_CODE = 2017;
|
||||
|
||||
private MethodChannel mChannel;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
GeneratedPluginRegistrant.registerWith(this);
|
||||
|
||||
final String INSTANCE_ID_CHANNEL = "com.dinect.checker/instance_id";
|
||||
final String PREF_POS_TOKEN = "pref_pos_token";
|
||||
final SharedPreferences preferences = getPreferences(Context.MODE_PRIVATE);
|
||||
|
||||
new MethodChannel(getFlutterView(), INSTANCE_ID_CHANNEL).setMethodCallHandler(
|
||||
new MethodCallHandler() {
|
||||
@Override
|
||||
public void onMethodCall(MethodCall call, Result result) {
|
||||
switch (call.method) {
|
||||
|
||||
case "getInstanceID":
|
||||
|
||||
InstanceID instanceID = InstanceID.getInstance(MainActivity.this);
|
||||
String id = instanceID.getId();
|
||||
|
||||
if (id != null) {
|
||||
result.success(id);
|
||||
} else {
|
||||
result.error("UNAVAILABLE", "Can't get instanceID.", null);
|
||||
}
|
||||
break;
|
||||
|
||||
case "saveToken":
|
||||
Map arguments = call.arguments();
|
||||
String token = (String) arguments.get("token");
|
||||
Log.d("kifio", token);
|
||||
preferences.edit().putString(PREF_POS_TOKEN, token).apply();
|
||||
break;
|
||||
|
||||
case "getToken":
|
||||
result.success(preferences.getString(PREF_POS_TOKEN, null));
|
||||
break;
|
||||
|
||||
case "startScanner":
|
||||
startActivity(new Intent(MainActivity.this, CameraActivity.class));
|
||||
break;
|
||||
|
||||
default:
|
||||
result.notImplemented();
|
||||
break;
|
||||
}
|
||||
mChannel = new MethodChannel(getFlutterView(), INSTANCE_ID_CHANNEL);
|
||||
mChannel.setMethodCallHandler(
|
||||
new MethodCallHandler() {
|
||||
@Override
|
||||
public void onMethodCall(MethodCall call, Result result) {
|
||||
switch (call.method) {
|
||||
case "getInstanceID":
|
||||
InstanceID instanceID = InstanceID.getInstance(MainActivity.this);
|
||||
String id = instanceID.getId();
|
||||
if (id != null) {
|
||||
result.success(id);
|
||||
} else {
|
||||
result.error("UNAVAILABLE", "Can't get instanceID.", null);
|
||||
}
|
||||
break;
|
||||
case "saveToken":
|
||||
Map arguments = call.arguments();
|
||||
String token = (String) arguments.get("token");
|
||||
Log.d("kifio", token);
|
||||
preferences.edit().putString(PREF_POS_TOKEN, token).apply();
|
||||
break;
|
||||
case "getToken":
|
||||
result.success(preferences.getString(PREF_POS_TOKEN, null));
|
||||
break;
|
||||
case "startScanner":
|
||||
Intent cameraIntent = new Intent(MainActivity.this, CameraActivity.class);
|
||||
startActivityForResult(cameraIntent, START_SCANNER_REQUEST_CODE);
|
||||
break;
|
||||
default:
|
||||
result.notImplemented();
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
if (requestCode == START_SCANNER_REQUEST_CODE && resultCode == RESULT_OK) {
|
||||
mChannel.invokeMethod("foo", null);
|
||||
}
|
||||
}
|
||||
|
||||
public void startScanner() {
|
||||
|
||||
}
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 413 B |
Binary file not shown.
|
Before Width: | Height: | Size: 394 B |
Binary file not shown.
|
Before Width: | Height: | Size: 419 B |
Binary file not shown.
|
Before Width: | Height: | Size: 385 B |
@@ -1,17 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||
<item android:state_pressed="true"><shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<corners android:radius="4dp"/>
|
||||
<solid android:color="#3078c0"/>
|
||||
</shape>
|
||||
</item>
|
||||
<item>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<corners android:radius="4dp"/>
|
||||
<solid android:color="#4272e7"/>
|
||||
</shape>
|
||||
</item>
|
||||
</selector>
|
||||
|
||||
Reference in New Issue
Block a user