Skip to content

Commit

Permalink
Refactored the initOtherMediaFileOptions to support both audio and file.
Browse files Browse the repository at this point in the history
  • Loading branch information
jd-alexander committed Jan 7, 2021
1 parent 408cf6d commit e4039c0
Showing 1 changed file with 6 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -538,26 +538,14 @@ private ArrayList<MediaOption> initOtherMediaImageOptions() {
}

private ArrayList<MediaOption> initOtherMediaFileOptions() {
ArrayList<MediaOption> otherMediaOptions = new ArrayList<>();

FragmentActivity activity = getActivity();
if (activity == null) {
AppLog.e(T.EDITOR,
"Failed to initialize other media options because the activity is null");
return otherMediaOptions;
}

String packageName = activity.getApplication().getPackageName();

int chooseFileResourceId =
getResources().getIdentifier("photo_picker_choose_file", "string", packageName);

otherMediaOptions.add(new MediaOption(MEDIA_SOURCE_FILE, getString(chooseFileResourceId)));

return otherMediaOptions;
return initOtherMediaFileOptions(MEDIA_SOURCE_FILE);
}

private ArrayList<MediaOption> initOtherMediaAudioFileOptions() {
return initOtherMediaFileOptions(MEDIA_SOURCE_AUDIO_FILE);
}

private ArrayList<MediaOption> initOtherMediaFileOptions(String mediaOptionId) {
ArrayList<MediaOption> otherMediaOptions = new ArrayList<>();

FragmentActivity activity = getActivity();
Expand All @@ -572,7 +560,7 @@ private ArrayList<MediaOption> initOtherMediaAudioFileOptions() {
int chooseAudioFileResourceId =
getResources().getIdentifier("photo_picker_choose_file", "string", packageName);

otherMediaOptions.add(new MediaOption(MEDIA_SOURCE_AUDIO_FILE, getString(chooseAudioFileResourceId)));
otherMediaOptions.add(new MediaOption(mediaOptionId, getString(chooseAudioFileResourceId)));

return otherMediaOptions;
}
Expand Down

0 comments on commit e4039c0

Please sign in to comment.