Skip to content

Commit

Permalink
Add method exit the program
Browse files Browse the repository at this point in the history
  • Loading branch information
Hitomis committed Nov 9, 2016
1 parent 5b210ff commit 308c675
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,16 @@ protected void onCreate(Bundle savedInstanceState) {
tvPage.setText("当前第" + (tag + 1) + "页" );

if (index == totalCount - 1) {
btnNext.setVisibility(View.GONE);
btnNext.setText("退出程序");
}
btnNext.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (++index > totalCount - 1) return;
startActivity(new Intent(MainActivity.this, MainActivity.class));
if (++index > totalCount - 1) {
activitySwitcher.exit();
} else {
startActivity(new Intent(MainActivity.this, MainActivity.class));
}
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ public void processTouchEvent(MotionEvent event) {
}
}

public void exit() {
switcherHelper.exit();
}

/**
* 关闭 ActivitySwitcher 切换视图
* @param activity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,18 @@ public boolean isActivityControllerDisplayed() {
return actControllerLayout.getFlag() == ActivityControllerLayout.FLAG_DISPLAYED;
}

public void exit() {
if (preActivities == null) {
preActivities = actManager.getPreActivies();
} else {
preActivities.addAll(flingActivities);
}
for (Activity activity : preActivities) {
finishActivityByNoAnimation(activity);
}
android.os.Process.killProcess(android.os.Process.myPid());
}

/**
* End of the Activity switch
* @param selectedIndex
Expand Down

0 comments on commit 308c675

Please sign in to comment.