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:
@@ -178,25 +178,18 @@ public class Main extends AndroidApplication {
|
|||||||
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT);
|
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT);
|
||||||
addContentView(contentView, params);
|
addContentView(contentView, params);
|
||||||
|
|
||||||
// Animate the content view to 100% opacity, and clear any animation
|
Animator ac = ObjectAnimator.ofFloat(contentView, "alpha", 0f, 1f).setDuration(mShortAnimationDuration);
|
||||||
// listener set on the view.
|
Animator ap = ObjectAnimator.ofFloat(previousView, "alpha", 1f, 0f).setDuration(mShortAnimationDuration);
|
||||||
contentView.animate()
|
AnimatorSet animatorSet = new AnimatorSet();
|
||||||
.alpha(1f)
|
animatorSet.playTogether(ac, ap);
|
||||||
.setDuration(mShortAnimationDuration)
|
animatorSet.addListener(new AnimatorListenerAdapter() {
|
||||||
.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
|
@Override
|
||||||
public void onAnimationEnd(Animator animation) {
|
public void onAnimationEnd(Animator animation) {
|
||||||
|
super.onAnimationEnd(animation);
|
||||||
previousView.setVisibility(View.GONE);
|
previousView.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
animatorSet.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isTabletDevice(Context activityContext) {
|
private static boolean isTabletDevice(Context activityContext) {
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import forge.card.CardRenderer.CardStackPosition;
|
|||||||
import forge.card.CardZoom;
|
import forge.card.CardZoom;
|
||||||
import forge.card.CardZoom.ActivateHandler;
|
import forge.card.CardZoom.ActivateHandler;
|
||||||
import forge.game.card.CardView;
|
import forge.game.card.CardView;
|
||||||
|
import forge.game.player.PlayerView;
|
||||||
import forge.game.zone.ZoneType;
|
import forge.game.zone.ZoneType;
|
||||||
import forge.gui.FThreads;
|
import forge.gui.FThreads;
|
||||||
import forge.gui.GuiBase;
|
import forge.gui.GuiBase;
|
||||||
@@ -352,14 +353,25 @@ public abstract class VCardDisplayArea extends VDisplayArea implements ActivateH
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean selectCard(boolean selectEntireStack) {
|
public boolean selectCard(boolean selectEntireStack) {
|
||||||
if (!getCard().getController().equals(MatchController.instance.getCurrentPlayer()) && ZoneType.Hand.equals(getCard().getZone())) {
|
CardView cardView = getCard();
|
||||||
if (getCard().mayPlayerLook(MatchController.instance.getCurrentPlayer())) { // can see the card, check if can play...
|
if (cardView != null) {
|
||||||
if (!getCard().getMayPlayPlayers(MatchController.instance.getCurrentPlayer()))
|
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;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (MatchController.instance.getGameController().selectCard(getCard(), getOtherCardsToSelect(selectEntireStack), null)) {
|
if (MatchController.instance.getGameController().selectCard(getCard(), getOtherCardsToSelect(selectEntireStack), null)) {
|
||||||
Gdx.graphics.requestRendering();
|
Gdx.graphics.requestRendering();
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Reference in New Issue
Block a user