mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-15 18:28:00 +00:00
prevent NPE
This commit is contained in:
@@ -170,7 +170,7 @@ public class Main extends AndroidApplication {
|
||||
}
|
||||
|
||||
private void crossfade(View contentView, View previousView) {
|
||||
activeView = contentView;
|
||||
activeView = contentView;
|
||||
// Set the content view to 0% opacity but visible, so that it is visible
|
||||
// (but fully transparent) during the animation.
|
||||
contentView.setAlpha(0f);
|
||||
@@ -178,25 +178,18 @@ public class Main extends AndroidApplication {
|
||||
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT);
|
||||
addContentView(contentView, params);
|
||||
|
||||
// Animate the content view to 100% opacity, and clear any animation
|
||||
// listener set on the view.
|
||||
contentView.animate()
|
||||
.alpha(1f)
|
||||
.setDuration(mShortAnimationDuration)
|
||||
.setListener(null);
|
||||
|
||||
// Animate the loading view to 0% opacity. After the animation ends,
|
||||
// set its visibility to GONE as an optimization step (it won't
|
||||
// participate in layout passes, etc.)
|
||||
previousView.animate()
|
||||
.alpha(0f)
|
||||
.setDuration(mShortAnimationDuration)
|
||||
.setListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
previousView.setVisibility(View.GONE);
|
||||
}
|
||||
});
|
||||
Animator ac = ObjectAnimator.ofFloat(contentView, "alpha", 0f, 1f).setDuration(mShortAnimationDuration);
|
||||
Animator ap = ObjectAnimator.ofFloat(previousView, "alpha", 1f, 0f).setDuration(mShortAnimationDuration);
|
||||
AnimatorSet animatorSet = new AnimatorSet();
|
||||
animatorSet.playTogether(ac, ap);
|
||||
animatorSet.addListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
super.onAnimationEnd(animation);
|
||||
previousView.setVisibility(View.GONE);
|
||||
}
|
||||
});
|
||||
animatorSet.start();
|
||||
}
|
||||
|
||||
private static boolean isTabletDevice(Context activityContext) {
|
||||
|
||||
@@ -15,6 +15,7 @@ import forge.card.CardRenderer.CardStackPosition;
|
||||
import forge.card.CardZoom;
|
||||
import forge.card.CardZoom.ActivateHandler;
|
||||
import forge.game.card.CardView;
|
||||
import forge.game.player.PlayerView;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.gui.FThreads;
|
||||
import forge.gui.GuiBase;
|
||||
@@ -352,12 +353,23 @@ public abstract class VCardDisplayArea extends VDisplayArea implements ActivateH
|
||||
}
|
||||
|
||||
public boolean selectCard(boolean selectEntireStack) {
|
||||
if (!getCard().getController().equals(MatchController.instance.getCurrentPlayer()) && ZoneType.Hand.equals(getCard().getZone())) {
|
||||
if (getCard().mayPlayerLook(MatchController.instance.getCurrentPlayer())) { // can see the card, check if can play...
|
||||
if (!getCard().getMayPlayPlayers(MatchController.instance.getCurrentPlayer()))
|
||||
return false;
|
||||
} else {
|
||||
return false;
|
||||
CardView cardView = getCard();
|
||||
if (cardView != null) {
|
||||
PlayerView cardController = cardView.getController();
|
||||
PlayerView currentPlayer = MatchController.instance.getCurrentPlayer();
|
||||
if (cardController != null) {
|
||||
/* TODO:
|
||||
IIRC this check is for mobile UI BUG that can cast nonland card as long as you can view it
|
||||
on any hand. Seems ridiculous, Investigate further. Should be rule based and this isn't needed.
|
||||
To reproduce omit this check and select nonland card on opponent hand while you have
|
||||
Telepathy card in play. */
|
||||
if (!cardController.equals(currentPlayer) && ZoneType.Hand.equals(cardView.getZone()))
|
||||
if (cardView.mayPlayerLook(currentPlayer)) { // can see the card, check if can play...
|
||||
if (!cardView.getMayPlayPlayers(currentPlayer))
|
||||
return false;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (MatchController.instance.getGameController().selectCard(getCard(), getOtherCardsToSelect(selectEntireStack), null)) {
|
||||
|
||||
Reference in New Issue
Block a user