Skip to content
This repository has been archived by the owner on Apr 12, 2022. It is now read-only.

Commit

Permalink
MediaPreviewer : finish cleaning files
Browse files Browse the repository at this point in the history
  • Loading branch information
ganfra committed Jul 19, 2018
1 parent cdd651b commit 5ff6ea4
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 15 deletions.
35 changes: 21 additions & 14 deletions vector/src/main/java/im/vector/activity/MediaPreviewerActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,20 +75,8 @@ public boolean onTouch(View v, MotionEvent event) {
configureToolbar();
final String roomTitle = getIntent().getExtras().getString(EXTRA_ROOM_TITLE);
getSupportActionBar().setTitle(roomTitle);
final List<RoomMediaMessage> sharedDataItems = RoomMediaMessage.listRoomMediaMessages(getIntent());
if (sharedDataItems.isEmpty()) {
final Uri roomMediaUri = Uri.parse(getIntent().getStringExtra(EXTRA_CAMERA_PICTURE_URI));
final RoomMediaMessage roomMediaMessage = new RoomMediaMessage(roomMediaUri);
sharedDataItems.add(roomMediaMessage);
}
final LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false);
mPreviewerRecyclerView.setLayoutManager(linearLayoutManager);
final MediaPreviewAdapter mediaPreviewAdapter = new MediaPreviewAdapter(sharedDataItems, this);
mPreviewerRecyclerView.setAdapter(mediaPreviewAdapter);

if (!sharedDataItems.isEmpty()) {
updatePreview(sharedDataItems.get(0));
}
final List<RoomMediaMessage> sharedDataItems = getSharedItems();
setupRecyclerView(sharedDataItems);
}

@OnClick(R.id.media_previewer_send_button)
Expand Down Expand Up @@ -137,6 +125,25 @@ private void updatePreview(final RoomMediaMessage roomMediaMessage) {
}
}

private void setupRecyclerView(@NonNull final List<RoomMediaMessage> sharedDataItems) {
final LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false);
mPreviewerRecyclerView.setLayoutManager(linearLayoutManager);
final MediaPreviewAdapter mediaPreviewAdapter = new MediaPreviewAdapter(sharedDataItems, this);
mPreviewerRecyclerView.setAdapter(mediaPreviewAdapter);
final RoomMediaMessage firstRoomMedia = sharedDataItems.get(0);
updatePreview(firstRoomMedia);
}

private List<RoomMediaMessage> getSharedItems() {
final List<RoomMediaMessage> sharedDataItems = RoomMediaMessage.listRoomMediaMessages(getIntent());
if (sharedDataItems.isEmpty()) {
final Uri roomMediaUri = Uri.parse(getIntent().getStringExtra(EXTRA_CAMERA_PICTURE_URI));
final RoomMediaMessage roomMediaMessage = new RoomMediaMessage(roomMediaUri);
sharedDataItems.add(roomMediaMessage);
}
return sharedDataItems;
}

private void onVideoPreviewClicked() {
if (!mPreviewerVideoView.isPlaying()) {
mPreviewerVideoView.start();
Expand Down
3 changes: 2 additions & 1 deletion vector/src/main/res/layout/activity_media_previewer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
<ImageView
android:id="@+id/media_previewer_image_view"
android:layout_width="match_parent"
android:layout_height="match_parent" />
android:layout_height="match_parent"
android:scaleType="centerInside" />

<VideoView
android:id="@+id/media_previewer_video_view"
Expand Down

0 comments on commit 5ff6ea4

Please sign in to comment.