Tidy handling of package not found exception in demo
PiperOrigin-RevId: 546900066
This commit is contained in:
parent
7441c1f083
commit
22b7a7dc39
@ -229,15 +229,11 @@ public final class TransformerActivity extends AppCompatActivity {
|
|||||||
String filePath = externalCacheFile.getAbsolutePath();
|
String filePath = externalCacheFile.getAbsolutePath();
|
||||||
@Nullable Bundle bundle = intent.getExtras();
|
@Nullable Bundle bundle = intent.getExtras();
|
||||||
MediaItem mediaItem = createMediaItem(bundle, inputUri);
|
MediaItem mediaItem = createMediaItem(bundle, inputUri);
|
||||||
try {
|
Transformer transformer = createTransformer(bundle, inputUri, filePath);
|
||||||
Transformer transformer = createTransformer(bundle, inputUri, filePath);
|
Composition composition = createComposition(mediaItem, bundle);
|
||||||
Composition composition = createComposition(mediaItem, bundle);
|
exportStopwatch.start();
|
||||||
exportStopwatch.start();
|
transformer.start(composition, filePath);
|
||||||
transformer.start(composition, filePath);
|
this.transformer = transformer;
|
||||||
this.transformer = transformer;
|
|
||||||
} catch (PackageManager.NameNotFoundException e) {
|
|
||||||
throw new IllegalStateException(e);
|
|
||||||
}
|
|
||||||
displayInputButton.setVisibility(View.GONE);
|
displayInputButton.setVisibility(View.GONE);
|
||||||
inputCardView.setVisibility(View.GONE);
|
inputCardView.setVisibility(View.GONE);
|
||||||
outputPlayerView.setVisibility(View.GONE);
|
outputPlayerView.setVisibility(View.GONE);
|
||||||
@ -358,8 +354,7 @@ public final class TransformerActivity extends AppCompatActivity {
|
|||||||
"exportStopwatch",
|
"exportStopwatch",
|
||||||
"progressViewGroup",
|
"progressViewGroup",
|
||||||
})
|
})
|
||||||
private Composition createComposition(MediaItem mediaItem, @Nullable Bundle bundle)
|
private Composition createComposition(MediaItem mediaItem, @Nullable Bundle bundle) {
|
||||||
throws PackageManager.NameNotFoundException {
|
|
||||||
EditedMediaItem.Builder editedMediaItemBuilder = new EditedMediaItem.Builder(mediaItem);
|
EditedMediaItem.Builder editedMediaItemBuilder = new EditedMediaItem.Builder(mediaItem);
|
||||||
// For image inputs. Automatically ignored if input is audio/video.
|
// For image inputs. Automatically ignored if input is audio/video.
|
||||||
editedMediaItemBuilder.setDurationUs(5_000_000).setFrameRate(30);
|
editedMediaItemBuilder.setDurationUs(5_000_000).setFrameRate(30);
|
||||||
@ -419,8 +414,7 @@ public final class TransformerActivity extends AppCompatActivity {
|
|||||||
return processors.build();
|
return processors.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
private ImmutableList<Effect> createVideoEffectsFromBundle(Bundle bundle)
|
private ImmutableList<Effect> createVideoEffectsFromBundle(Bundle bundle) {
|
||||||
throws PackageManager.NameNotFoundException {
|
|
||||||
boolean[] selectedEffects =
|
boolean[] selectedEffects =
|
||||||
checkStateNotNull(bundle.getBooleanArray(ConfigurationActivity.VIDEO_EFFECTS_SELECTIONS));
|
checkStateNotNull(bundle.getBooleanArray(ConfigurationActivity.VIDEO_EFFECTS_SELECTIONS));
|
||||||
ImmutableList.Builder<Effect> effects = new ImmutableList.Builder<>();
|
ImmutableList.Builder<Effect> effects = new ImmutableList.Builder<>();
|
||||||
@ -568,8 +562,7 @@ public final class TransformerActivity extends AppCompatActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private OverlayEffect createOverlayEffectFromBundle(Bundle bundle, boolean[] selectedEffects)
|
private OverlayEffect createOverlayEffectFromBundle(Bundle bundle, boolean[] selectedEffects) {
|
||||||
throws PackageManager.NameNotFoundException {
|
|
||||||
ImmutableList.Builder<TextureOverlay> overlaysBuilder = new ImmutableList.Builder<>();
|
ImmutableList.Builder<TextureOverlay> overlaysBuilder = new ImmutableList.Builder<>();
|
||||||
if (selectedEffects[ConfigurationActivity.OVERLAY_LOGO_AND_TIMER_INDEX]) {
|
if (selectedEffects[ConfigurationActivity.OVERLAY_LOGO_AND_TIMER_INDEX]) {
|
||||||
float[] logoPositioningMatrix = GlUtil.create4x4IdentityMatrix();
|
float[] logoPositioningMatrix = GlUtil.create4x4IdentityMatrix();
|
||||||
@ -580,7 +573,12 @@ public final class TransformerActivity extends AppCompatActivity {
|
|||||||
.setMatrix(logoPositioningMatrix)
|
.setMatrix(logoPositioningMatrix)
|
||||||
.setAnchor(/* x= */ -1f, /* y= */ -1f)
|
.setAnchor(/* x= */ -1f, /* y= */ -1f)
|
||||||
.build();
|
.build();
|
||||||
Drawable logo = getPackageManager().getApplicationIcon(getPackageName());
|
Drawable logo;
|
||||||
|
try {
|
||||||
|
logo = getPackageManager().getApplicationIcon(getPackageName());
|
||||||
|
} catch (PackageManager.NameNotFoundException e) {
|
||||||
|
throw new IllegalStateException(e);
|
||||||
|
}
|
||||||
logo.setBounds(
|
logo.setBounds(
|
||||||
/* left= */ 0, /* top= */ 0, logo.getIntrinsicWidth(), logo.getIntrinsicHeight());
|
/* left= */ 0, /* top= */ 0, logo.getIntrinsicWidth(), logo.getIntrinsicHeight());
|
||||||
TextureOverlay logoOverlay = DrawableOverlay.createStaticDrawableOverlay(logo, logoSettings);
|
TextureOverlay logoOverlay = DrawableOverlay.createStaticDrawableOverlay(logo, logoSettings);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user