Вынес работу с сетью и общие методы в отдельные файлы
This commit is contained in:
@@ -47,6 +47,10 @@ import android.view.SurfaceView;
|
||||
import java.io.IOException;
|
||||
import java.lang.Exception;
|
||||
import java.util.List;
|
||||
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.dinect.checker.R;
|
||||
|
||||
public class CameraActivity extends AppCompatActivity implements SurfaceHolder.Callback {
|
||||
@@ -57,7 +61,7 @@ public class CameraActivity extends AppCompatActivity implements SurfaceHolder.C
|
||||
private HashMap<String, Integer> mContours = new HashMap<>();
|
||||
|
||||
private boolean mBarcodeScanned = false;
|
||||
private boolean previewing = true;
|
||||
private boolean previewing = false;
|
||||
private Handler autoFocusHandler;
|
||||
private int mOffset;
|
||||
|
||||
@@ -117,12 +121,14 @@ public class CameraActivity extends AppCompatActivity implements SurfaceHolder.C
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
mCamera.startPreview();
|
||||
previewing = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
mCamera.stopPreview();
|
||||
previewing = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -138,6 +144,7 @@ public class CameraActivity extends AppCompatActivity implements SurfaceHolder.C
|
||||
try {
|
||||
mCamera.setPreviewDisplay(holder);
|
||||
mCamera.startPreview();
|
||||
previewing = true;
|
||||
try {
|
||||
mCamera.autoFocus(autoFocusCallback);
|
||||
} catch(Exception e) {
|
||||
@@ -207,8 +214,15 @@ public class CameraActivity extends AppCompatActivity implements SurfaceHolder.C
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
Intent intent = new Intent();
|
||||
if (item.getItemId() == R.id.logout) {
|
||||
setResult(RESULT_OK);
|
||||
intent.putExtra("item", "logout");
|
||||
setResult(RESULT_OK, intent);
|
||||
finish();
|
||||
return true;
|
||||
} else if (item.getItemId() == R.id.faq) {
|
||||
intent.putExtra("item", "faq");
|
||||
setResult(RESULT_OK, intent);
|
||||
finish();
|
||||
return true;
|
||||
}
|
||||
@@ -253,8 +267,9 @@ public class CameraActivity extends AppCompatActivity implements SurfaceHolder.C
|
||||
|
||||
private Runnable doAutoFocus = new Runnable() {
|
||||
public void run() {
|
||||
if (previewing)
|
||||
if (previewing) {
|
||||
mCamera.autoFocus(autoFocusCallback);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -108,19 +108,25 @@ public class MainActivity extends FlutterActivity {
|
||||
if (requestCode == START_SCANNER_REQUEST_CODE && resultCode == RESULT_CANCELED) {
|
||||
finish();
|
||||
} else if (requestCode == START_SCANNER_REQUEST_CODE && resultCode == RESULT_OK) {
|
||||
if (data == null) {
|
||||
mChannel.invokeMethod("foo", null);
|
||||
} else {
|
||||
if (data != null) {
|
||||
String code = data.getExtras().getString("code", null);
|
||||
if (code == null) {
|
||||
mChannel.invokeMethod("foo", null);
|
||||
} else {
|
||||
mChannel.invokeMethod("purchase", code);
|
||||
if (code != null) {
|
||||
mChannel.invokeMethod("purchase", code);
|
||||
} else {
|
||||
String menuItem = data.getExtras().getString("item", null);
|
||||
Log.d("item", menuItem);
|
||||
if (menuItem != null) {
|
||||
mChannel.invokeMethod(menuItem, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void handleItemClick() {
|
||||
|
||||
}
|
||||
|
||||
private void getDocID() {
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user