Bug fixes and improvements.

parent 5c780a61
...@@ -20,12 +20,15 @@ import android.view.View; ...@@ -20,12 +20,15 @@ import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.ImageView; import android.widget.ImageView;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.davemorrissey.labs.subscaleview.ImageSource; import com.davemorrissey.labs.subscaleview.ImageSource;
import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView; import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import static com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions.withCrossFade;
public class ImageActivity extends AppCompatActivity { public class ImageActivity extends AppCompatActivity {
ArrayList<String> list_of_images = new ArrayList<>(); ArrayList<String> list_of_images = new ArrayList<>();
...@@ -187,38 +190,47 @@ public class ImageActivity extends AppCompatActivity { ...@@ -187,38 +190,47 @@ public class ImageActivity extends AppCompatActivity {
// Inflate layout // Inflate layout
LayoutInflater inflater = getLayoutInflater(); LayoutInflater inflater = getLayoutInflater();
View layout = inflater.inflate(R.layout.view_pager_item, container, false); View layout = inflater.inflate(R.layout.view_pager_item, container, false);
// Get views // Get overlay ImageView
SubsamplingScaleImageView imageView = findViewById(R.id.inside_imageview);
ImageView overlay = layout.findViewById(R.id.outside_imageview); ImageView overlay = layout.findViewById(R.id.outside_imageview);
//Set image // Video/gif thumbnail
imageView.setImage(ImageSource.uri(Uri.fromFile(image))); if(Utils.isVideoOrGif(image.getName())){
ImageView imageView = layout.findViewById(R.id.inside_imageview);
// If it's a video, add overlay GlideApp
if(Utils.isVideo(image.getName())){ .with(getApplicationContext())
overlay.setVisibility(View.VISIBLE); .load(image)
.transition(withCrossFade())
.diskCacheStrategy(DiskCacheStrategy.AUTOMATIC)
.into(imageView);
if(!Utils.isGif(image.getName())) {
// If it's a video, add overlay
overlay.setVisibility(View.VISIBLE);
}
// Set up the user interaction to manually show or hide the system UI.
imageView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
toggle();
}
});
// Full image display
}else{ }else{
// Get subSampling view
SubsamplingScaleImageView imageView = layout.findViewById(R.id.inside_imageview_sub);
// Set image
imageView.setImage(ImageSource.uri(image.getPath()));
overlay.setVisibility(View.INVISIBLE); overlay.setVisibility(View.INVISIBLE);
// Set up the user interaction to manually show or hide the system UI.
imageView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
toggle();
}
});
} }
//GlideApp
// .with(getApplicationContext())
// .load(image)
// .transition(withCrossFade())
// .diskCacheStrategy(DiskCacheStrategy.AUTOMATIC)
// .into(imageView);
container.addView(layout); container.addView(layout);
// Set up the user interaction to manually show or hide the system UI.
imageView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
toggle();
}
});
return layout; return layout;
//TODO: set title on page change //TODO: set title on page change
......
...@@ -67,4 +67,12 @@ class Utils { ...@@ -67,4 +67,12 @@ class Utils {
static boolean isVideo(String file){ static boolean isVideo(String file){
return(file.endsWith(".mp4") || file.endsWith(".3gp")); return(file.endsWith(".mp4") || file.endsWith(".3gp"));
} }
static boolean isVideoOrGif(String file){
return(file.endsWith(".mp4") || file.endsWith(".3gp") || file.endsWith(".gif"));
}
static boolean isGif(String file){
return(file.endsWith(".gif"));
}
} }
...@@ -8,7 +8,6 @@ import android.support.v7.app.AppCompatActivity; ...@@ -8,7 +8,6 @@ import android.support.v7.app.AppCompatActivity;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.support.v7.widget.Toolbar; import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.MotionEvent; import android.view.MotionEvent;
import android.view.View; import android.view.View;
...@@ -81,6 +80,7 @@ public class VideoActivity extends AppCompatActivity { ...@@ -81,6 +80,7 @@ public class VideoActivity extends AppCompatActivity {
mVisible = true; mVisible = true;
playerView = findViewById(R.id.video_view); playerView = findViewById(R.id.video_view);
playerView.hideController();
Intent intent = getIntent(); Intent intent = getIntent();
// Get all the images in the folder // Get all the images in the folder
...@@ -139,6 +139,7 @@ public class VideoActivity extends AppCompatActivity { ...@@ -139,6 +139,7 @@ public class VideoActivity extends AppCompatActivity {
} }
public void exoPlayer(){ public void exoPlayer(){
// 1. Create a default TrackSelector // 1. Create a default TrackSelector
BandwidthMeter bandwidthMeter = new DefaultBandwidthMeter(); BandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();
TrackSelection.Factory videoTrackSelectionFactory = TrackSelection.Factory videoTrackSelectionFactory =
...@@ -179,6 +180,7 @@ public class VideoActivity extends AppCompatActivity { ...@@ -179,6 +180,7 @@ public class VideoActivity extends AppCompatActivity {
} }
private void hide() { private void hide() {
playerView.hideController();
// Hide UI first // Hide UI first
ActionBar actionBar = getSupportActionBar(); ActionBar actionBar = getSupportActionBar();
if (actionBar != null) { if (actionBar != null) {
...@@ -193,6 +195,7 @@ public class VideoActivity extends AppCompatActivity { ...@@ -193,6 +195,7 @@ public class VideoActivity extends AppCompatActivity {
@SuppressLint("InlinedApi") @SuppressLint("InlinedApi")
private void show() { private void show() {
playerView.showController();
// Show the system bar // Show the system bar
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION); | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);
......
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2016 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layoutDirection="ltr"
android:background="@android:color/transparent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:paddingTop="4dp"
android:orientation="horizontal">
<ImageButton android:id="@id/exo_prev"
style="@style/ExoMediaButton.Previous"/>
<ImageButton android:id="@id/exo_rew"
style="@style/ExoMediaButton.Rewind"/>
<ImageButton android:id="@id/exo_repeat_toggle"
style="@style/ExoMediaButton"/>
<ImageButton android:id="@id/exo_play"
style="@style/ExoMediaButton.Play"/>
<ImageButton android:id="@id/exo_pause"
style="@style/ExoMediaButton.Pause"/>
<ImageButton android:id="@id/exo_ffwd"
style="@style/ExoMediaButton.FastForward"/>
<ImageButton android:id="@id/exo_next"
style="@style/ExoMediaButton.Next"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView android:id="@id/exo_position"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14sp"
android:textStyle="bold"
android:paddingLeft="4dp"
android:paddingRight="4dp"
android:includeFontPadding="false"
android:textColor="#FFBEBEBE"/>
<com.google.android.exoplayer2.ui.DefaultTimeBar
android:id="@id/exo_progress"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="26dp"/>
<TextView android:id="@id/exo_duration"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14sp"
android:textStyle="bold"
android:paddingLeft="4dp"
android:paddingRight="4dp"
android:includeFontPadding="false"
android:textColor="#FFBEBEBE"/>
</LinearLayout>
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2016 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<merge xmlns:android="http://schemas.android.com/apk/res/android">
<com.google.android.exoplayer2.ui.AspectRatioFrameLayout android:id="@id/exo_content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center">
<!-- Video surface will be inserted as the first child of the content frame. -->
<View android:id="@id/exo_shutter"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/black"/>
<ImageView android:id="@id/exo_artwork"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="fitXY"/>
<com.google.android.exoplayer2.ui.SubtitleView android:id="@id/exo_subtitles"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</com.google.android.exoplayer2.ui.AspectRatioFrameLayout>
<View android:id="@id/exo_controller_placeholder"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="48dp"/>
<FrameLayout android:id="@id/exo_overlay"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</merge>
\ No newline at end of file
...@@ -4,11 +4,16 @@ ...@@ -4,11 +4,16 @@
android:orientation="vertical"> android:orientation="vertical">
<com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView <com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView
android:id="@+id/inside_imageview_sub"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerVertical="true"/>
<ImageView
android:id="@+id/inside_imageview" android:id="@+id/inside_imageview"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_centerVertical="true" android:contentDescription="@string/desc_full_image"/>
android:contentDescription="@string/desc_image"/>
<ImageView <ImageView
android:id="@+id/outside_imageview" android:id="@+id/outside_imageview"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment