コード例 #1
0
ファイル: Remote.java プロジェクト: WilliamRen/IR-Remote
 // 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);
     }
   }
 }
コード例 #2
0
ファイル: Remote.java プロジェクト: WilliamRen/IR-Remote
 /** Save this remote to the file system */
 public void save(Context c) {
   Gson gson = new GsonBuilder().setPrettyPrinting().create();
   File dir = getRemoteDir(c);
   FileUtils.clear(dir);
   for (Button b : buttons) {
     if (b.id != 0 && b.code != null && !b.code.isEmpty()) {
       // File f = getNextFile(dir, BUTTON_PREFIX, BUTTON_EXTENSION);
       File f = new File(dir, BUTTON_PREFIX + b.id + BUTTON_EXTENSION);
       FileUtils.write(f, gson.toJson(b));
     }
   }
   File f = new File(dir, OPTIONS_FILE);
   FileUtils.write(f, gson.toJson(options));
 }
コード例 #3
0
ファイル: Remote.java プロジェクト: WilliamRen/IR-Remote
 public static boolean exists(Context c, String name) {
   return FileUtils.exists(getRemoteDir(c, name));
 }
コード例 #4
0
ファイル: Remote.java プロジェクト: WilliamRen/IR-Remote
 public static void rename(Context c, String oldName, String newName) {
   if (oldName.equals(newName) || newName.trim().isEmpty()) {
     return;
   }
   FileUtils.rename(getRemoteDir(c, oldName), getRemoteDir(c, newName));
 }
コード例 #5
0
ファイル: Remote.java プロジェクト: WilliamRen/IR-Remote
 public static void remove(Context c, String name) {
   FileUtils.remove(getRemoteDir(c, name));
 }