Removed Toolbar animation in all the other activities it was being used and changed to use the GIF version instead. It provides a much cleaner and safer implementation that works fine on all tested devices (Android L, M, O & P).

This commit is contained in:
Severiano Jaramillo 2018-10-25 13:40:45 -05:00
parent 36d97e8166
commit 4cd304d732
11 changed files with 48 additions and 255 deletions

View file

@ -122,8 +122,8 @@ dependencies {
kapt "android.arch.persistence.room:compiler:1.1.0"
// Glide dependencies
implementation 'com.github.bumptech.glide:glide:4.7.1'
annotationProcessor 'com.github.bumptech.glide:compiler:4.7.1'
implementation 'com.github.bumptech.glide:glide:4.8.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.8.0'
debugImplementation 'com.amitshekhar.android:debug-db:1.0.4'
}

View file

@ -14,6 +14,9 @@ import android.view.SurfaceView;
import android.widget.ImageView;
import android.widget.TextView;
import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
@ -37,18 +40,11 @@ public class AccountSettingsActivity extends AppCompatActivity{
public SettingsPagerAdapter settingsPagerAdapter;
@BindView(R.id.surface_view)
public SurfaceView mSurfaceView;
@BindView(R.id.tvBuildVersion)
public TextView tvBuildVersion;
/*
* For the window animation
* */
private MediaPlayer mediaPlayer;
@BindView(R.id.ivAppBarAnimation)
ImageView ivAppBarAnimation;
@Override
@ -60,29 +56,11 @@ public class AccountSettingsActivity extends AppCompatActivity{
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
// Appbar animation
mSurfaceView.getHolder().addCallback(new SurfaceHolder.Callback() {
@Override
public void surfaceCreated(SurfaceHolder surfaceHolder) {
//Log.d(TAG,"surfaceCreated");
mediaPlayer = MediaPlayer.create(AccountSettingsActivity.this, R.raw.appbar_background);
mediaPlayer.setDisplay(mSurfaceView.getHolder());
mediaPlayer.setLooping(true);
mediaPlayer.start();
}
@Override
public void surfaceChanged(SurfaceHolder surfaceHolder, int i, int i1, int i2) {
//Log.d(TAG,"surfaceChanged");
}
@Override
public void surfaceDestroyed(SurfaceHolder surfaceHolder) {
//Log.d(TAG,"surfaceDestroyed");
mediaPlayer.stop();
mediaPlayer.release();
}
});
// Sets AppBar animation
Glide.with(this)
.load(R.drawable.appbar_background)
.apply(new RequestOptions().centerCrop())
.into(ivAppBarAnimation);
settingsPagerAdapter = new SettingsPagerAdapter(getSupportFragmentManager());
mPager.setAdapter(settingsPagerAdapter);
@ -93,19 +71,6 @@ public class AccountSettingsActivity extends AppCompatActivity{
tabLayout.addOnTabSelectedListener(new TabLayout.ViewPagerOnTabSelectedListener(mPager));
}
@Override
protected void onDestroy() {
super.onDestroy();
//Release the media player
if(mediaPlayer!=null){
mediaPlayer.release();
mediaPlayer = null;
}
}
private class SettingsPagerAdapter extends FragmentStatePagerAdapter {
SettingsPagerAdapter(FragmentManager fm) {
super(fm);

View file

@ -8,9 +8,6 @@ import android.content.Intent;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.graphics.Typeface;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.TabLayout;
@ -20,18 +17,10 @@ import android.support.v4.app.FragmentStatePagerAdapter;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.view.ViewPager;
import android.support.v7.widget.Toolbar;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.style.ForegroundColorSpan;
import android.util.Pair;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.LinearInterpolator;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
@ -48,7 +37,6 @@ import cy.agorise.crystalwallet.fragments.MerchantsFragment;
import cy.agorise.crystalwallet.fragments.ReceiveTransactionFragment;
import cy.agorise.crystalwallet.fragments.SendTransactionFragment;
import cy.agorise.crystalwallet.fragments.TransactionsFragment;
import cy.agorise.crystalwallet.views.natives.GIFView;
import de.hdodenhof.circleimageview.CircleImageView;
import cy.agorise.crystalwallet.viewmodels.CryptoNetBalanceListViewModel;
@ -73,8 +61,8 @@ public class BoardActivity extends CustomActivity {
@BindView(R.id.fabAddContact)
public FloatingActionButton fabAddContact;
@BindView(R.id.imagevieGIF)
public GIFView imagevieGIF;
@BindView(R.id.ivAppBarAnimation)
ImageView ivAppBarAnimation;
public BoardPagerAdapter boardAdapter;
@ -84,9 +72,6 @@ public class BoardActivity extends CustomActivity {
*/
long cryptoNetAccountId;
@BindView(R.id.surface_view)
public SurfaceView mSurfaceView;
@BindView(R.id.toolbar_user_img)
public CircleImageView userImage;
@ -98,14 +83,6 @@ public class BoardActivity extends CustomActivity {
File photoDirectory;
/*
* For the window animation
* */
private MediaPlayer mediaPlayer;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@ -118,39 +95,11 @@ public class BoardActivity extends CustomActivity {
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
/*
* Set the bubbles animation
* */
//imagevieGIF.centerCrop();
//imagevieGIF.load(R.raw.burbujas);
/*
* Listener tabLayout to resalt text when clicked
* */
// Appbar animation
mSurfaceView.getHolder().addCallback(new SurfaceHolder.Callback() {
@Override
public void surfaceCreated(SurfaceHolder surfaceHolder) {
//Log.d(TAG,"surfaceCreated");
mediaPlayer = MediaPlayer.create(BoardActivity.this, R.raw.appbar_background);
mediaPlayer.setDisplay(mSurfaceView.getHolder());
mediaPlayer.setLooping(true);
mediaPlayer.start();
}
@Override
public void surfaceChanged(SurfaceHolder surfaceHolder, int i, int i1, int i2) {
//Log.d(TAG,"surfaceChanged");
}
@Override
public void surfaceDestroyed(SurfaceHolder surfaceHolder) {
//Log.d(TAG,"surfaceDestroyed");
mediaPlayer.stop();
mediaPlayer.release();
}
});
// Sets AppBar animation
Glide.with(this)
.load(R.drawable.appbar_background)
.apply(new RequestOptions().centerCrop())
.into(ivAppBarAnimation);
boardAdapter = new BoardPagerAdapter(getSupportFragmentManager());
mPager.setAdapter(boardAdapter);
@ -236,17 +185,6 @@ public class BoardActivity extends CustomActivity {
loadUserImage();
}
@Override
protected void onDestroy() {
super.onDestroy();
//Release the media player
if(mediaPlayer!=null){
mediaPlayer.release();
mediaPlayer = null;
}
}
public void loadUserImage(){
//Search for a existing photo
File photoFile = new File(photoDirectory + File.separator + "photo.png");

View file

@ -18,6 +18,9 @@ import android.view.SurfaceView;
import android.widget.ImageView;
import android.widget.TextView;
import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
@ -45,8 +48,6 @@ public class CryptoNetAccountSettingsActivity extends AppCompatActivity{
public SettingsPagerAdapter settingsPagerAdapter;
@BindView(R.id.surface_view)
public SurfaceView mSurfaceView;
@BindView(R.id.tvBuildVersion)
public TextView tvBuildVersion;
@ -56,13 +57,8 @@ public class CryptoNetAccountSettingsActivity extends AppCompatActivity{
private CryptoNetAccount cryptoNetAccount;
/*
* For the window animation
* */
private MediaPlayer mediaPlayer;
@BindView(R.id.ivAppBarAnimation)
ImageView ivAppBarAnimation;
@Override
protected void onCreate(Bundle savedInstanceState) {
@ -101,27 +97,11 @@ public class CryptoNetAccountSettingsActivity extends AppCompatActivity{
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
// Appbar animation
mSurfaceView.getHolder().addCallback(new SurfaceHolder.Callback() {
@Override
public void surfaceCreated(SurfaceHolder surfaceHolder) {
//Log.d(TAG,"surfaceCreated");
mediaPlayer = MediaPlayer.create(CryptoNetAccountSettingsActivity.this, R.raw.appbar_background);
mediaPlayer.setDisplay(mSurfaceView.getHolder());
mediaPlayer.setLooping(true);
mediaPlayer.start();
}
@Override
public void surfaceChanged(SurfaceHolder surfaceHolder, int i, int i1, int i2) {
//Log.d(TAG,"surfaceChanged");
}
@Override
public void surfaceDestroyed(SurfaceHolder surfaceHolder) {
//Log.d(TAG,"surfaceDestroyed");
}
});
// Sets AppBar animation
Glide.with(this)
.load(R.drawable.appbar_background)
.apply(new RequestOptions().centerCrop())
.into(ivAppBarAnimation);
} else {
@ -129,19 +109,6 @@ public class CryptoNetAccountSettingsActivity extends AppCompatActivity{
}
}
@Override
protected void onDestroy() {
super.onDestroy();
//Release the media player
if(mediaPlayer!=null){
mediaPlayer.release();
mediaPlayer = null;
}
}
private class SettingsPagerAdapter extends FragmentStatePagerAdapter {
SettingsPagerAdapter(FragmentManager fm) {
super(fm);

View file

@ -14,6 +14,8 @@ import android.view.SurfaceView;
import android.widget.ImageView;
import android.widget.TextView;
import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.sjaramillo10.animatedtablayout.AnimatedTabLayout;
import butterknife.BindView;
@ -42,20 +44,13 @@ public class SettingsActivity extends AppCompatActivity{
public SettingsPagerAdapter settingsPagerAdapter;
@BindView(R.id.surface_view)
public SurfaceView mSurfaceView;
@BindView(R.id.tvBuildVersion)
public TextView tvBuildVersion;
private SecuritySettingsFragment securitySettingsFragment;
/*
* For the window animation
* */
private MediaPlayer mediaPlayer;
@BindView(R.id.ivAppBarAnimation)
ImageView ivAppBarAnimation;
@Override
@ -67,29 +62,11 @@ public class SettingsActivity extends AppCompatActivity{
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
// Appbar animation
mSurfaceView.getHolder().addCallback(new SurfaceHolder.Callback() {
@Override
public void surfaceCreated(SurfaceHolder surfaceHolder) {
//Log.d(TAG,"surfaceCreated");
mediaPlayer = MediaPlayer.create(SettingsActivity.this, R.raw.appbar_background);
mediaPlayer.setDisplay(mSurfaceView.getHolder());
mediaPlayer.setLooping(true);
mediaPlayer.start();
}
@Override
public void surfaceChanged(SurfaceHolder surfaceHolder, int i, int i1, int i2) {
//Log.d(TAG,"surfaceChanged");
}
@Override
public void surfaceDestroyed(SurfaceHolder surfaceHolder) {
//Log.d(TAG,"surfaceDestroyed");
mediaPlayer.stop();
mediaPlayer.release();
}
});
// Sets AppBar animation
Glide.with(this)
.load(R.drawable.appbar_background)
.apply(new RequestOptions().centerCrop())
.into(ivAppBarAnimation);
settingsPagerAdapter = new SettingsPagerAdapter(getSupportFragmentManager());
mPager.setAdapter(settingsPagerAdapter);
@ -133,17 +110,6 @@ public class SettingsActivity extends AppCompatActivity{
}
}
@Override
protected void onDestroy() {
super.onDestroy();
//Release the media player
if(mediaPlayer != null){
mediaPlayer.release();
mediaPlayer = null;
}
}
@OnClick(R.id.ivGoBack)
public void goBack(){
onBackPressed();

View file

@ -1,34 +0,0 @@
package cy.agorise.crystalwallet.views.natives
import android.content.Context
import android.net.Uri
import android.util.AttributeSet
import android.widget.VideoView
import cy.agorise.crystalwallet.R
import kotlinx.android.synthetic.main.empty_activity.*
/*
* Extensión for videoview
* */
class VideoExView(context: Context?, attrs: AttributeSet?) : VideoView(context, attrs) {
/*
* Set the path based on raw, this should be called first to set the video path
* */
fun setVideoRaw(rawID:Int){
val uriPath = "android.resource://" + context.packageName + "/" + R.raw.appbar_background
val uri = Uri.parse(uriPath)
this.setVideoURI(uri)
}
/*
* With this method the video play continues
* */
fun playContinius(){
start()
this.setOnCompletionListener {
start()
}
}
}

View file

@ -19,8 +19,8 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
<SurfaceView
android:id="@+id/surface_view"
<ImageView
android:id="@+id/ivAppBarAnimation"
android:layout_width="match_parent"
android:layout_height="match_parent" />

View file

@ -20,21 +20,19 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:background="@color/red"
app:contentScrim="@color/transparent"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
app:toolbarId="@+id/toolbar">
<SurfaceView
android:id="@+id/surface_view"
<ImageView
android:id="@+id/ivAppBarAnimation"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<cy.agorise.crystalwallet.views.natives.GIFView
android:id="@+id/imagevieGIF"
<View
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
android:background="@color/colorPrimaryTransparent"/>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"

View file

@ -19,8 +19,8 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
<SurfaceView
android:id="@+id/surface_view"
<ImageView
android:id="@+id/ivAppBarAnimation"
android:layout_width="match_parent"
android:layout_height="match_parent" />

View file

@ -10,11 +10,4 @@
android:layout_height="200px"
android:layout_centerInParent="true"/>
<cy.agorise.crystalwallet.views.natives.VideoExView
android:layout_width="match_parent"
android:layout_height="200px"
android:layout_centerInParent="true"
android:visibility="gone"
android:id="@+id/video"/>
</RelativeLayout>