From d367373d8ea26b2358a926d2c2ac7144d4ab3b33 Mon Sep 17 00:00:00 2001 From: Severiano Jaramillo Date: Mon, 15 Oct 2018 14:17:21 -0500 Subject: [PATCH] Make improvements to Crystal's toolbar animation to avoud memory leaks. --- .../activities/AccountSettingsActivity.java | 2 + .../activities/BoardActivity.java | 47 +------------------ .../activities/IntroActivity.java | 3 ++ .../activities/SettingsActivity.java | 2 + 4 files changed, 9 insertions(+), 45 deletions(-) diff --git a/app/src/main/java/cy/agorise/crystalwallet/activities/AccountSettingsActivity.java b/app/src/main/java/cy/agorise/crystalwallet/activities/AccountSettingsActivity.java index 3331777..33e547b 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/activities/AccountSettingsActivity.java +++ b/app/src/main/java/cy/agorise/crystalwallet/activities/AccountSettingsActivity.java @@ -79,6 +79,8 @@ public class AccountSettingsActivity extends AppCompatActivity{ @Override public void surfaceDestroyed(SurfaceHolder surfaceHolder) { //Log.d(TAG,"surfaceDestroyed"); + mediaPlayer.stop(); + mediaPlayer.release(); } }); diff --git a/app/src/main/java/cy/agorise/crystalwallet/activities/BoardActivity.java b/app/src/main/java/cy/agorise/crystalwallet/activities/BoardActivity.java index 4a8a2de..560b78f 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/activities/BoardActivity.java +++ b/app/src/main/java/cy/agorise/crystalwallet/activities/BoardActivity.java @@ -127,51 +127,6 @@ public class BoardActivity extends CustomActivity { /* * Listener tabLayout to resalt text when clicked * */ - final TabLayout tabLayoutFinal = tabLayout; -// tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() { -// @Override -// public void onTabSelected(final TabLayout.Tab tab) { -// -// globalActivity.runOnUiThread(new Runnable() { -// @Override -// public void run() { -// -// LinearLayout tabLayout = (LinearLayout)((ViewGroup) tabLayoutFinal.getChildAt(0)).getChildAt(tab.getPosition()); -// tabLayout.setBackgroundColor(Color.TRANSPARENT); -// TextView tabTextView = (TextView) tabLayout.getChildAt(1); -// //tabTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP ,50); -// Spannable WordtoSpan = new SpannableString(tabTextView.getText()); -// WordtoSpan.setSpan(new ForegroundColorSpan(Color.WHITE), 0, tabTextView.getText().length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); -// tabTextView.setText(WordtoSpan); -// tabTextView.setTypeface(tabTextView.getTypeface(), Typeface.BOLD); -// } -// }); -// } -// -// @Override -// public void onTabUnselected(final TabLayout.Tab tab) { -// -// globalActivity.runOnUiThread(new Runnable() { -// @Override -// public void run() { -// -// LinearLayout tabLayout = (LinearLayout)((ViewGroup) tabLayoutFinal.getChildAt(0)).getChildAt(tab.getPosition()); -// TextView tabTextView = (TextView) tabLayout.getChildAt(1); -// //tabTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP ,50); -// Spannable WordtoSpan = new SpannableString(tabTextView.getText()); -// WordtoSpan.setSpan(new ForegroundColorSpan(globalActivity.getResources().getColor(R.color.lightGrayClear)), 0, tabTextView.getText().length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); -// tabTextView.setText(WordtoSpan); -// tabTextView.setTypeface(tabTextView.getTypeface(), Typeface.NORMAL); -// } -// }); -// } -// -// @Override -// public void onTabReselected(TabLayout.Tab tab) { -// -// -// } -// }); // Appbar animation mSurfaceView.getHolder().addCallback(new SurfaceHolder.Callback() { @@ -192,6 +147,8 @@ public class BoardActivity extends CustomActivity { @Override public void surfaceDestroyed(SurfaceHolder surfaceHolder) { //Log.d(TAG,"surfaceDestroyed"); + mediaPlayer.stop(); + mediaPlayer.release(); } }); diff --git a/app/src/main/java/cy/agorise/crystalwallet/activities/IntroActivity.java b/app/src/main/java/cy/agorise/crystalwallet/activities/IntroActivity.java index 1d76247..5da0a81 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/activities/IntroActivity.java +++ b/app/src/main/java/cy/agorise/crystalwallet/activities/IntroActivity.java @@ -108,6 +108,9 @@ public class IntroActivity extends CustomActivity { @Override public void surfaceDestroyed(SurfaceHolder surfaceHolder) { //Log.d(TAG,"surfaceDestroyed"); + //Log.d(TAG,"surfaceDestroyed"); + mediaPlayer.stop(); + mediaPlayer.release(); } }); diff --git a/app/src/main/java/cy/agorise/crystalwallet/activities/SettingsActivity.java b/app/src/main/java/cy/agorise/crystalwallet/activities/SettingsActivity.java index a17931c..4280f64 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/activities/SettingsActivity.java +++ b/app/src/main/java/cy/agorise/crystalwallet/activities/SettingsActivity.java @@ -86,6 +86,8 @@ public class SettingsActivity extends AppCompatActivity{ @Override public void surfaceDestroyed(SurfaceHolder surfaceHolder) { //Log.d(TAG,"surfaceDestroyed"); + mediaPlayer.stop(); + mediaPlayer.release(); } });