Browse Source

Fixed layout bug, fixed bug slowing down recyclerview animations

master
Anthony Restaino 9 years ago
parent
commit
97a64401e8
  1. 13
      app/src/main/java/acr/browser/lightning/activity/BrowserActivity.java
  2. 7
      app/src/main/java/acr/browser/lightning/fragment/anim/HorizontalItemAnimator.java
  3. 7
      app/src/main/java/acr/browser/lightning/fragment/anim/VerticalItemAnimator.java

13
app/src/main/java/acr/browser/lightning/activity/BrowserActivity.java

@ -131,9 +131,6 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements @@ -131,9 +131,6 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
private static final String INTENT_PANIC_TRIGGER = "info.guardianproject.panic.action.TRIGGER";
// Static Layout
@Bind(R.id.main_layout)
View mRootLayout;
@Bind(R.id.drawer_layout)
DrawerLayout mDrawerLayout;
@ -1044,7 +1041,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements @@ -1044,7 +1041,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
initializeTabHeight();
doOnLayout(mRootLayout, new Runnable() {
doOnLayout(mUiLayout, new Runnable() {
@Override
public void run() {
int toolbarSize;
@ -1849,7 +1846,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements @@ -1849,7 +1846,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
* first.
*/
private void initializeTabHeight() {
doOnLayout(mRootLayout, new Runnable() {
doOnLayout(mUiLayout, new Runnable() {
@Override
public void run() {
setTabHeight();
@ -1885,12 +1882,12 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements @@ -1885,12 +1882,12 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
* laid out in order to set the correct height.
*/
private void setTabHeight() {
if (mRootLayout.getHeight() == 0) {
mRootLayout.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);
if (mUiLayout.getHeight() == 0) {
mUiLayout.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);
}
if (mFullScreen) {
mBrowserFrame.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, mRootLayout.getHeight()));
mBrowserFrame.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, mUiLayout.getHeight()));
} else {
mBrowserFrame.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
}

7
app/src/main/java/acr/browser/lightning/fragment/anim/HorizontalItemAnimator.java

@ -22,7 +22,6 @@ import android.support.v4.view.ViewPropertyAnimatorListener; @@ -22,7 +22,6 @@ import android.support.v4.view.ViewPropertyAnimatorListener;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.RecyclerView.ViewHolder;
import android.support.v7.widget.SimpleItemAnimator;
import android.util.Log;
import android.view.View;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.DecelerateInterpolator;
@ -262,13 +261,13 @@ public class HorizontalItemAnimator extends SimpleItemAnimator { @@ -262,13 +261,13 @@ public class HorizontalItemAnimator extends SimpleItemAnimator {
final View view = holder.itemView;
fromX += ViewCompat.getTranslationX(holder.itemView);
fromY += ViewCompat.getTranslationY(holder.itemView);
resetAnimation(holder);
int deltaX = toX - fromX;
int deltaY = toY - fromY;
if (deltaX == 0 && deltaY == 0) {
dispatchMoveFinished(holder);
return false;
}
resetAnimation(holder);
if (deltaX != 0) {
ViewCompat.setTranslationX(view, -deltaX);
}
@ -337,6 +336,10 @@ public class HorizontalItemAnimator extends SimpleItemAnimator { @@ -337,6 +336,10 @@ public class HorizontalItemAnimator extends SimpleItemAnimator {
if (oldHolder == newHolder) {
// Don't know how to run change animations when the same view holder is re-used.
// run a move animation to handle position changes.
if ((fromX - toX) == 0 && (fromY - toY) == 0) {
dispatchMoveFinished(oldHolder);
return false;
}
return animateMove(oldHolder, fromX, fromY, toX, toY);
}
final float prevTranslationX = ViewCompat.getTranslationX(oldHolder.itemView);

7
app/src/main/java/acr/browser/lightning/fragment/anim/VerticalItemAnimator.java

@ -22,7 +22,6 @@ import android.support.v4.view.ViewPropertyAnimatorListener; @@ -22,7 +22,6 @@ import android.support.v4.view.ViewPropertyAnimatorListener;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.RecyclerView.ViewHolder;
import android.support.v7.widget.SimpleItemAnimator;
import android.util.Log;
import android.view.View;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.DecelerateInterpolator;
@ -261,13 +260,13 @@ public class VerticalItemAnimator extends SimpleItemAnimator { @@ -261,13 +260,13 @@ public class VerticalItemAnimator extends SimpleItemAnimator {
final View view = holder.itemView;
fromX += ViewCompat.getTranslationX(holder.itemView);
fromY += ViewCompat.getTranslationY(holder.itemView);
resetAnimation(holder);
int deltaX = toX - fromX;
int deltaY = toY - fromY;
if (deltaX == 0 && deltaY == 0) {
dispatchMoveFinished(holder);
return false;
}
resetAnimation(holder);
if (deltaX != 0) {
ViewCompat.setTranslationX(view, -deltaX);
}
@ -336,6 +335,10 @@ public class VerticalItemAnimator extends SimpleItemAnimator { @@ -336,6 +335,10 @@ public class VerticalItemAnimator extends SimpleItemAnimator {
if (oldHolder == newHolder) {
// Don't know how to run change animations when the same view holder is re-used.
// run a move animation to handle position changes.
if ((fromX - toX) == 0 && (fromY - toY) == 0) {
dispatchMoveFinished(oldHolder);
return false;
}
return animateMove(oldHolder, fromX, fromY, toX, toY);
}
final float prevTranslationX = ViewCompat.getTranslationX(oldHolder.itemView);

Loading…
Cancel
Save