启动时通道2主动拍一张照片并抛弃

hdrplus
Matthew 11 months ago
parent 2e736d81c0
commit 81d46306ee

@ -38,11 +38,15 @@ import android.widget.Toast;
import com.dev.devapi.api.SysApi; import com.dev.devapi.api.SysApi;
import com.xypower.common.CameraUtils; import com.xypower.common.CameraUtils;
import com.xypower.common.FilesUtils;
import com.xypower.common.JSONUtils;
import com.xypower.common.MicroPhotoContext; import com.xypower.common.MicroPhotoContext;
import com.xypower.mpapp.databinding.ActivityMainBinding; import com.xypower.mpapp.databinding.ActivityMainBinding;
import com.xypower.mpapp.utils.RandomReader; import com.xypower.mpapp.utils.RandomReader;
import org.json.JSONObject;
import java.io.File; import java.io.File;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
@ -245,6 +249,13 @@ public class MainActivity extends AppCompatActivity {
binding.logs.setText(""); binding.logs.setText("");
MicroPhotoContext.AppConfig curAppConfig = retrieveAndSaveAppConfig(); MicroPhotoContext.AppConfig curAppConfig = retrieveAndSaveAppConfig();
TakeAndThrowPhoto(2, 0xFF);
try {
Thread.sleep(20);
} catch (Exception ex) {
ex.printStackTrace();
}
startMicroPhotoService(MainActivity.this.getApplicationContext(), appConfig, mMessenger); startMicroPhotoService(MainActivity.this.getApplicationContext(), appConfig, mMessenger);
binding.btnStartServ.setEnabled(false); binding.btnStartServ.setEnabled(false);
@ -602,6 +613,26 @@ public class MainActivity extends AppCompatActivity {
} }
} }
protected void TakeAndThrowPhoto(int channel, int preset) {
String appPath = MicroPhotoContext.buildMpAppDir(getApplicationContext());
File configFile = new File(appPath);
configFile = new File(configFile, "data/channels/" + Integer.toString(channel) + ".json");
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
Date dt = new Date();
File tmpPath = new File(appPath, "tmp");
if (!tmpPath.exists()) {
tmpPath.mkdirs();
}
File photoFile = new File(tmpPath, "IMG-" + Integer.toString(channel) + "-" + sdf.format(dt) + ".jpg");
if (photoFile.exists()) {
photoFile.delete();
}
MicroPhotoService.takePhoto(channel, preset, true, configFile.getAbsolutePath(), photoFile.getAbsolutePath());
}
@Override @Override
protected void onResume() { protected void onResume() {
// call the superclass method first // call the superclass method first

Loading…
Cancel
Save