Improved visibility change animation in videoplayer

This commit is contained in:
daniel oeh 2012-10-10 17:36:14 +02:00
parent 2d2102b7ab
commit 6f4cf5fbdc
4 changed files with 39 additions and 4 deletions

View File

@ -25,7 +25,7 @@
<application
android:name="de.danoeh.antennapod.PodcastApp"
android:debuggable="true"
android:debuggable="false"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:logo="@drawable/ic_launcher"

9
res/anim/fade_in.xml Normal file
View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" >
<alpha
android:duration="500"
android:fromAlpha="0.0"
android:interpolator="@android:anim/accelerate_interpolator"
android:toAlpha="1.0" />
</set>

10
res/anim/fade_out.xml Normal file
View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<alpha
android:duration="500"
android:fromAlpha="1.0"
android:interpolator="@android:anim/accelerate_interpolator"
android:toAlpha="0.0" />
</set>

View File

@ -1,5 +1,7 @@
package de.danoeh.antennapod.activity;
import com.actionbarsherlock.view.Window;
import android.annotation.SuppressLint;
import android.content.Intent;
import android.os.AsyncTask;
@ -9,6 +11,7 @@ import android.view.MotionEvent;
import android.view.SurfaceHolder;
import android.view.View;
import android.view.WindowManager;
import android.view.animation.AnimationUtils;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.SeekBar;
@ -34,6 +37,7 @@ public class VideoplayerActivity extends MediaplayerActivity implements
@Override
protected void onCreate(Bundle savedInstanceState) {
requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
super.onCreate(savedInstanceState);
}
@ -121,10 +125,10 @@ public class VideoplayerActivity extends MediaplayerActivity implements
private void toggleVideoControlsVisibility() {
if (videoControlsShowing) {
getSupportActionBar().hide();
videoOverlay.setVisibility(View.GONE);
hideVideoControls();
} else {
getSupportActionBar().show();
videoOverlay.setVisibility(View.VISIBLE);
showVideoControls();
}
videoControlsShowing = !videoControlsShowing;
}
@ -150,7 +154,7 @@ public class VideoplayerActivity extends MediaplayerActivity implements
if (AppConfig.DEBUG)
Log.d(TAG, "Hiding video controls");
getSupportActionBar().hide();
videoOverlay.setVisibility(View.GONE);
hideVideoControls();
videoControlsShowing = false;
}
}
@ -232,4 +236,16 @@ public class VideoplayerActivity extends MediaplayerActivity implements
progressIndicator.setVisibility(View.INVISIBLE);
}
private void showVideoControls() {
videoOverlay.setVisibility(View.VISIBLE);
videoOverlay.startAnimation(AnimationUtils.loadAnimation(this,
R.anim.fade_in));
}
private void hideVideoControls() {
videoOverlay.startAnimation(AnimationUtils.loadAnimation(this,
R.anim.fade_out));
videoOverlay.setVisibility(View.GONE);
}
}