]> gitweb.fperrin.net Git - GpsPrune.git/blob - tim/prune/tips/TipManager.java
Version 16, February 2014
[GpsPrune.git] / tim / prune / tips / TipManager.java
1 package tim.prune.tips;
2
3 /**
4  * Class to manage the showing of tips according
5  * to the fixed TipDefinitions
6  */
7 public abstract class TipManager
8 {
9         public static final int Tip_UseAMapCache    = 0;
10         public static final int Tip_LearnTimeParams = 1;
11         public static final int Tip_DownloadSrtm    = 2;
12         public static final int Tip_UseSrtmFor3d    = 3;
13         public static final int Tip_ManuallyCorrelateOne = 4;
14         private static final int Number_Tips = Tip_ManuallyCorrelateOne + 1;
15
16         /** Array of tip definitions */
17         private static TipDefinition[] TIPDEFS = new TipDefinition[Number_Tips];
18
19         /** Static block to initialise tip definitions */
20         static
21         {
22                 TIPDEFS[Tip_UseAMapCache] = new TipDefinition("tip.useamapcache", 150);
23                 TIPDEFS[Tip_LearnTimeParams] = new TipDefinition("tip.learntimeparams");
24                 TIPDEFS[Tip_DownloadSrtm] = new TipDefinition("tip.downloadsrtm", 5);
25                 TIPDEFS[Tip_UseSrtmFor3d] = new TipDefinition("tip.usesrtmfor3d");
26                 TIPDEFS[Tip_ManuallyCorrelateOne] = new TipDefinition("tip.manuallycorrelateone");
27         }
28
29         /**
30          * Fire a trigger for the specified tip and get the message key if tip should be shown
31          * @param inTipNumber number of tip from constants
32          * @return message key if a message should be shown, or null otherwise
33          */
34         public static String fireTipTrigger(int inTipNumber)
35         {
36                 try {
37                         TipDefinition tip = TIPDEFS[inTipNumber];
38                         if (tip.shouldShowMessage()) {
39                                 return tip.getMessageKey();
40                         }
41                 }
42                 catch (ArrayIndexOutOfBoundsException obe) {} // unrecognised tip given
43                 return null;
44         }
45 }