在用户开始编辑图像之前,已向用户显示图像的保存路径

时间:2018-12-15 09:14:55

标签: java android photoeditorsdk

我有一个照片编辑器应用程序,可以为用户显示图像保存的路径。但是在用户开始编辑图像之前,已显示给用户显示的路径。这是代码:

MainActivity:

buffer

}

HomeActivity:

package com.example.photoeditor;

import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.widget.ImageView;
import android.widget.Toast;

import com.adobe.creativesdk.aviary.AdobeImageIntent;

import java.io.File;
import java.io.IOException;
import java.text.DateFormat;
import java.util.Date;
import java.util.Objects;

public class MainActivity extends AppCompatActivity {

  public static final String IMAGE_URI = "IMAGE_URI_KEY";
  private static final String TAG = "MainActivity";
  private static final int IMAGE_EDITOR_RESULT = 1;
  private ImageView mEditedImageView;
  private String mCapturedImagePath;

  @Override protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    mEditedImageView = (ImageView) findViewById(R.id.edited_image_view);

    Bundle extras = getIntent().getExtras();
    if (extras != null) {
      Uri imageUri = Uri.parse(getIntent().getExtras().getString(IMAGE_URI));
      Intent imageEditorIntent = new AdobeImageIntent.Builder(this).setData(imageUri).build();
      startActivityForResult(imageEditorIntent, IMAGE_EDITOR_RESULT);
    }
  }

  private Bundle uriToBundle(Uri imageUri) {
    Bundle bundle = new Bundle();
    bundle.putString(IMAGE_URI, imageUri.toString());
    return bundle;
  }

  @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (resultCode == RESULT_OK) {
      switch (requestCode) {
        case IMAGE_EDITOR_RESULT:
          Uri editedImageUri = data.getParcelableExtra(AdobeImageIntent.EXTRA_OUTPUT_URI);
          Log.d(TAG, "editedImageUri: " + editedImageUri.toString());
          Bundle extra = data.getExtras();
          if (extra != null) {
            boolean changed = extra.getBoolean(AdobeImageIntent.EXTRA_OUT_BITMAP_CHANGED);
            Log.d(TAG, "Image edited: " + changed);
            if (changed) {
                mEditedImageView.setImageURI(editedImageUri);
            }
            startActivity(getIntent(this, uriToBundle(Objects.requireNonNull(editedImageUri))));
          }
          break;

        default:
          throw new IllegalArgumentException("Unexpected request code");
      }
    }
    finish();
  }

  public static Intent getIntent(Context context, Bundle bundle) {
    Intent intent = new Intent(context, MainActivity.class);
    if (bundle != null) {
      intent.putExtras(bundle);
    }
    return intent;
  }

所以我想要的只是在用户完成图像编辑之后,才应向用户显示路径。谁能告诉我我要去哪里错了?

请帮助。预先感谢

0 个答案:

没有答案