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)
continue;
Date feedDate = atomDate.parse(entry.updated);
if (buildDateOriginal != null && feedDate.before(buildDateOriginal))
if (buildDateOriginal != null && feedDate.toInstant().isBefore(buildDateOriginal.toInstant()))
continue;
if (maxDate != null && feedDate.after(maxDate))
if (maxDate != null && feedDate.toInstant().isAfter(maxDate.toInstant()))
continue;
logs.append(simpleDate.format(feedDate)).append(" | ").append(StringEscapeUtils.unescapeXml(title).replace("\n", "").replace(" ", "")).append("\n\n");
if (c >= 15)

View File

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

View File

@@ -72,11 +72,7 @@ public class AssetsDownloader {
final String releaseTag = Forge.getDeviceAdapter().getReleaseTag(GITHUB_RELEASES_ATOM);
try {
URL versionUrl = new URL(versionText);
String version = "";
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 version = isSnapshots ? FileUtil.readFileToString(versionUrl) : releaseTag.replace("forge-", "");
String filename = "";
String installerURL = "";
if (GuiBase.isAndroid()) {
@@ -121,7 +117,8 @@ public class AssetsDownloader {
if (!Forge.getDeviceAdapter().isConnectedToWifi()) {
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
if (!isSnapshots && releaseTag.isEmpty()) {
if (!GuiBase.isAndroid())

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,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)) {