Skip to content

Commit

Permalink
小修小补
Browse files Browse the repository at this point in the history
  • Loading branch information
SplashCodes committed Dec 30, 2017
1 parent ba61ce0 commit 6111ca2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 17 deletions.
15 changes: 0 additions & 15 deletions app/src/main/java/io/github/javiewer/activity/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -213,22 +213,7 @@ private void setFragment(Fragment fragment, CharSequence title) {
return;
}

/*
FragmentTransaction transaction = fragmentManager.beginTransaction();
if (old != null) {
transaction.hide(old);
}
if (!fragment.isAdded()) {
transaction.add(R.id.content, fragment);
} else {
transaction.show(fragment);
}*/
FragmentTransaction transaction = fragmentManager.beginTransaction();
/*for (Fragment f : fragmentManager.getFragments()) {
transaction.hide(f);
}*/
if (old != null) {
transaction.hide(old);
}
Expand Down
20 changes: 18 additions & 2 deletions app/src/main/java/io/github/javiewer/activity/StartActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,20 +85,36 @@ public void handleProperties(Properties properties) {
message += "\n\n更新日志:\n\n" + properties.getChangelog() + "\n";
}

AlertDialog dialog = new AlertDialog.Builder(this)
final boolean[] update = {false};
final AlertDialog dialog = new AlertDialog.Builder(this)
.setTitle("发现更新")
.setMessage(message)
.setNegativeButton("忽略更新", null)
.setPositiveButton("更新", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/SplashCodes/JAViewer/releases")));
update[0] = true;
}
})
.create();
dialog.show();

dialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialogInterface) {
start();
if (update[0]) {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/SplashCodes/JAViewer/releases")));
}
}
});
} else {
start();
}

}

public void start() {
startActivity(new Intent(StartActivity.this, MainActivity.class));
finish();
}
Expand Down

0 comments on commit 6111ca2

Please sign in to comment.