Search in sources :

Example 1 with ImageEditorFragment

use of org.thoughtcrime.securesms.scribbles.ImageEditorFragment in project Signal-Android by WhisperSystems.

the class AvatarSelectionActivity method handleSave.

private void handleSave() {
    ImageEditorFragment fragment = (ImageEditorFragment) getSupportFragmentManager().findFragmentByTag(IMAGE_EDITOR);
    if (fragment == null) {
        throw new AssertionError();
    }
    ImageEditorFragment.Data data = (ImageEditorFragment.Data) fragment.saveState();
    EditorModel model = data.readModel();
    if (model == null) {
        throw new AssertionError();
    }
    MediaRepository.transformMedia(this, Collections.singletonList(currentMedia), Collections.singletonMap(currentMedia, new ImageEditorModelRenderMediaTransform(model, AVATAR_DIMENSIONS)), output -> {
        Media transformed = output.get(currentMedia);
        Intent result = new Intent();
        result.putExtra(EXTRA_MEDIA, transformed);
        setResult(RESULT_OK, result);
        finish();
    });
}
Also used : EditorModel(org.signal.imageeditor.core.model.EditorModel) LiveData(androidx.lifecycle.LiveData) DefaultValueLiveData(org.thoughtcrime.securesms.util.DefaultValueLiveData) Intent(android.content.Intent) ImageEditorFragment(org.thoughtcrime.securesms.scribbles.ImageEditorFragment)

Example 2 with ImageEditorFragment

use of org.thoughtcrime.securesms.scribbles.ImageEditorFragment in project Signal-Android by signalapp.

the class AvatarSelectionActivity method handleSave.

private void handleSave() {
    ImageEditorFragment fragment = (ImageEditorFragment) getSupportFragmentManager().findFragmentByTag(IMAGE_EDITOR);
    if (fragment == null) {
        throw new AssertionError();
    }
    ImageEditorFragment.Data data = (ImageEditorFragment.Data) fragment.saveState();
    EditorModel model = data.readModel();
    if (model == null) {
        throw new AssertionError();
    }
    MediaRepository.transformMedia(this, Collections.singletonList(currentMedia), Collections.singletonMap(currentMedia, new ImageEditorModelRenderMediaTransform(model, AVATAR_DIMENSIONS)), output -> {
        Media transformed = output.get(currentMedia);
        Intent result = new Intent();
        result.putExtra(EXTRA_MEDIA, transformed);
        setResult(RESULT_OK, result);
        finish();
    });
}
Also used : EditorModel(org.signal.imageeditor.core.model.EditorModel) LiveData(androidx.lifecycle.LiveData) DefaultValueLiveData(org.thoughtcrime.securesms.util.DefaultValueLiveData) Intent(android.content.Intent) ImageEditorFragment(org.thoughtcrime.securesms.scribbles.ImageEditorFragment)

Aggregations

Intent (android.content.Intent)2 LiveData (androidx.lifecycle.LiveData)2 EditorModel (org.signal.imageeditor.core.model.EditorModel)2 ImageEditorFragment (org.thoughtcrime.securesms.scribbles.ImageEditorFragment)2 DefaultValueLiveData (org.thoughtcrime.securesms.util.DefaultValueLiveData)2