prevent NPE

This commit is contained in:
Anthony Calosa
2024-11-01 06:52:18 +08:00
parent c55c07b8dd
commit 43912cbbb2
2 changed files with 31 additions and 26 deletions

View File

@@ -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() {
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) {

View File

@@ -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,14 +353,25 @@ 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()))
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)) {
Gdx.graphics.requestRendering();
return true;