Merge pull request #6487 from kevlahnota/master2

prevent NPE
This commit is contained in:
kevlahnota
2024-11-01 08:36:21 +08:00
committed by GitHub
4 changed files with 36 additions and 34 deletions

View File

@@ -29,9 +29,9 @@ public class GitLogs {
if (entry.updated == null) if (entry.updated == null)
continue; continue;
Date feedDate = atomDate.parse(entry.updated); Date feedDate = atomDate.parse(entry.updated);
if (buildDateOriginal != null && feedDate.before(buildDateOriginal)) if (buildDateOriginal != null && feedDate.toInstant().isBefore(buildDateOriginal.toInstant()))
continue; continue;
if (maxDate != null && feedDate.after(maxDate)) if (maxDate != null && feedDate.toInstant().isAfter(maxDate.toInstant()))
continue; continue;
logs.append(simpleDate.format(feedDate)).append(" | ").append(StringEscapeUtils.unescapeXml(title).replace("\n", "").replace(" ", "")).append("\n\n"); logs.append(simpleDate.format(feedDate)).append(" | ").append(StringEscapeUtils.unescapeXml(title).replace("\n", "").replace(" ", "")).append("\n\n");
if (c >= 15) if (c >= 15)

View File

@@ -170,7 +170,7 @@ public class Main extends AndroidApplication {
} }
private void crossfade(View contentView, View previousView) { 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 // Set the content view to 0% opacity but visible, so that it is visible
// (but fully transparent) during the animation. // (but fully transparent) during the animation.
contentView.setAlpha(0f); 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); 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); @Override
public void onAnimationEnd(Animator animation) {
// Animate the loading view to 0% opacity. After the animation ends, super.onAnimationEnd(animation);
// set its visibility to GONE as an optimization step (it won't previousView.setVisibility(View.GONE);
// participate in layout passes, etc.) }
previousView.animate() });
.alpha(0f) animatorSet.start();
.setDuration(mShortAnimationDuration)
.setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
previousView.setVisibility(View.GONE);
}
});
} }
private static boolean isTabletDevice(Context activityContext) { private static boolean isTabletDevice(Context activityContext) {

View File

@@ -72,11 +72,7 @@ public class AssetsDownloader {
final String releaseTag = Forge.getDeviceAdapter().getReleaseTag(GITHUB_RELEASES_ATOM); final String releaseTag = Forge.getDeviceAdapter().getReleaseTag(GITHUB_RELEASES_ATOM);
try { try {
URL versionUrl = new URL(versionText); URL versionUrl = new URL(versionText);
String version = ""; String version = isSnapshots ? FileUtil.readFileToString(versionUrl) : releaseTag.replace("forge-", "");
if (GuiBase.isAndroid())
version = FileUtil.readFileToString(versionUrl);
else //instead of parsing xml from earlier releases, get the latest github release tag
version = releaseTag.replace("forge-", "");
String filename = ""; String filename = "";
String installerURL = ""; String installerURL = "";
if (GuiBase.isAndroid()) { if (GuiBase.isAndroid()) {
@@ -121,7 +117,8 @@ public class AssetsDownloader {
if (!Forge.getDeviceAdapter().isConnectedToWifi()) { if (!Forge.getDeviceAdapter().isConnectedToWifi()) {
message += " If so, you may want to connect to wifi first. The download is around " + (GuiBase.isAndroid() ? apkSize : packageSize) + "."; message += " If so, you may want to connect to wifi first. The download is around " + (GuiBase.isAndroid() ? apkSize : packageSize) + ".";
} }
message += Forge.getDeviceAdapter().getLatestChanges(GITHUB_COMMITS_ATOM, buildTimeStamp, snapsTimestamp); if (isSnapshots) // this is for snaps initial info
message += Forge.getDeviceAdapter().getLatestChanges(GITHUB_COMMITS_ATOM, buildTimeStamp, snapsTimestamp);
//failed to grab latest github tag //failed to grab latest github tag
if (!isSnapshots && releaseTag.isEmpty()) { if (!isSnapshots && releaseTag.isEmpty()) {
if (!GuiBase.isAndroid()) if (!GuiBase.isAndroid())

View File

@@ -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,12 +353,23 @@ 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();
return false; PlayerView currentPlayer = MatchController.instance.getCurrentPlayer();
} else { if (cardController != null) {
return false; /* 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)) { if (MatchController.instance.getGameController().selectCard(getCard(), getOtherCardsToSelect(selectEntireStack), null)) {