You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
105 lines
3.2 KiB
Java
105 lines
3.2 KiB
Java
package com.xypower.mppreview;
|
|
|
|
import androidx.activity.result.ActivityResult;
|
|
import androidx.activity.result.ActivityResultCallback;
|
|
import androidx.activity.result.ActivityResultLauncher;
|
|
import androidx.activity.result.contract.ActivityResultContracts;
|
|
import androidx.appcompat.app.AppCompatActivity;
|
|
|
|
import android.content.Intent;
|
|
import android.os.Bundle;
|
|
import android.text.Editable;
|
|
import android.view.View;
|
|
import android.widget.AdapterView;
|
|
import android.widget.Button;
|
|
import android.widget.EditText;
|
|
import android.widget.Spinner;
|
|
|
|
import com.xypower.mppreview.bean.Contants;
|
|
|
|
public class MainActivity extends AppCompatActivity implements View.OnClickListener, AdapterView.OnItemSelectedListener {
|
|
|
|
public static int ExposureComp = 0;
|
|
private Button systakepic;
|
|
private Button hdrtakepic;
|
|
private ActivityResultLauncher<Intent> photoResultLauncher;
|
|
private int picsize = 0;
|
|
|
|
|
|
@Override
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
super.onCreate(savedInstanceState);
|
|
setContentView(R.layout.activity_main);
|
|
initView();
|
|
initActivityResult();
|
|
}
|
|
|
|
private void initView() {
|
|
hdrtakepic = findViewById(R.id.hdrtakepic);
|
|
systakepic = findViewById(R.id.systakepic);
|
|
Spinner spinner = findViewById(R.id.spinner);
|
|
hdrtakepic.setOnClickListener(this);
|
|
systakepic.setOnClickListener(this);
|
|
spinner.setOnItemSelectedListener(this);
|
|
}
|
|
|
|
private void initActivityResult() {
|
|
photoResultLauncher = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), new ActivityResultCallback<ActivityResult>() {
|
|
@Override
|
|
public void onActivityResult(ActivityResult result) {
|
|
|
|
}
|
|
});
|
|
}
|
|
|
|
@Override
|
|
protected void onResume() {
|
|
super.onResume();
|
|
// if (OpenCVLoader.initDebug()) {
|
|
// Log.d("dfsdfd", "成功");
|
|
// } else {
|
|
// Log.d("dfsdfd", "失败");
|
|
// }
|
|
}
|
|
|
|
private void restartFragment() {
|
|
getSupportFragmentManager().beginTransaction().replace(R.id.container, Camera2RawFragment.newInstance()).commit();
|
|
}
|
|
|
|
private void doFocus() {
|
|
Camera2RawFragment fragment = (Camera2RawFragment) getSupportFragmentManager().findFragmentById(R.id.container);
|
|
fragment.doFocus();
|
|
}
|
|
|
|
private void takePicture() {
|
|
Camera2RawFragment fragment = (Camera2RawFragment) getSupportFragmentManager().findFragmentById(R.id.container);
|
|
fragment.takePicture();
|
|
}
|
|
|
|
@Override
|
|
public void onClick(View view) {
|
|
int id = view.getId();
|
|
switch (id) {
|
|
case R.id.hdrtakepic:
|
|
Intent intent = new Intent(this, CameraActivity.class);
|
|
intent.putExtra(Contants.HDRNUM, picsize);
|
|
startActivity(intent);
|
|
break;
|
|
case R.id.systakepic:
|
|
PhotoUtil.openCamera(this, photoResultLauncher);
|
|
break;
|
|
}
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
|
picsize = position;
|
|
}
|
|
|
|
@Override
|
|
public void onNothingSelected(AdapterView<?> parent) {
|
|
|
|
}
|
|
} |