forked from cuongquangnam/CZ2002-Project
-
Notifications
You must be signed in to change notification settings - Fork 0
/
View.java
36 lines (31 loc) · 1 KB
/
View.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package com.views;
/**
* This is the base class for all other View classes.
*/
public abstract class View {
/** The {@code View} before this. */
public View prevView; // NULL by default
/** This method is the first method to be called when transition using intent. */
public abstract void start();
/** This method is to destroy the current {@code View} by going back to the start of the last {@code View}. */
protected void destroy() {
if (prevView == null) System.exit(1); // exit when nowhere to return
else prevView.start();
}
/**
* This method is used to transit from one {@code View} to another.
* @param v the prevView of u
* @param u the {@code View} to be started
*/
protected void intent(View v, View u) {
u.prevView = v;
u.start();
}
/**
* This method is to get the last {@code View} before this.
* @return the last {@code View}
*/
protected View getPrevView() {
return prevView;
}
}