Esempio n. 1
0
 // Constructor from a file
 private Remote(Context c, String remoteName) {
   this();
   if (remoteName == null) throw new IllegalArgumentException("Name cannot be null");
   this.name = remoteName;
   final Gson gson = new Gson();
   File optfile = new File(getRemoteDir(c), OPTIONS_FILE);
   options = gson.fromJson(FileUtils.read(optfile), Options.class);
   for (final File f : getRemoteDir(c, remoteName).listFiles()) {
     if (f.getName().endsWith(BUTTON_EXTENSION)) {
       Button b = gson.fromJson(FileUtils.read(f), Button.class);
       addButton(b);
     }
   }
 }
Esempio n. 2
0
 /**
  * Add a button to a remote and save it to disk If you call save on another remote with the same
  * name which was loaded earlier, you will overwrite this changes<br>
  * Please note that this is highly inefficient for adding multiple buttons. Load the remote, and
  * add the buttons manually instead of using this.
  *
  * @param c
  * @param remote
  * @param b
  */
 public static void addButton(Context c, String remote, Button b) {
   Remote r = Remote.load(c, remote);
   r.addButton(b);
   r.save(c);
 }