Esempio n. 1
0
  private void updateLocalVersions() {
    if (NavigineApp.Navigation == null) return;

    for (int i = 0; i < mInfoList.size(); ++i) {
      LocationInfo info = mInfoList.get(i);
      String versionStr = LocationLoader.getLocalVersion(NavigineApp.AppContext, info.title);
      if (versionStr != null) {
        // Log.d(TAG, info.title + ": " + versionStr);
        info.localModified = versionStr.endsWith("+");
        if (info.localModified) versionStr = versionStr.substring(0, versionStr.length() - 1);
        try {
          info.localVersion = Integer.parseInt(versionStr);
        } catch (Throwable e) {
        }
      } else {
        info.localVersion = -1;

        String mapFile = NavigineApp.Settings.getString("map_file", "");
        if (mapFile.equals(info.archiveFile)) {
          NavigineApp.Navigation.loadArchive(null);
          SharedPreferences.Editor editor = NavigineApp.Settings.edit();
          editor.putString("map_file", "");
          editor.commit();
        }
      }
    }
    mAdapter.updateList();
  }
Esempio n. 2
0
  public void getFilesFromFolder(List filesAndFolders, String savePath) {
    // create a File object for the parent directory
    File downloadsDirectory = new File(savePath);
    // create the folder if needed.
    downloadsDirectory.mkdir();

    for (int i = 0; i < filesAndFolders.size(); i++) {
      Object links = filesAndFolders.get(i);
      List linksArray = (ArrayList) links;
      if (i == 0) {
        for (int j = 0; j < linksArray.size(); j += 2) {
          // We've got an array of file urls so download each one to a directory with the folder
          // name
          String fileURL = linksArray.get(j).toString();
          String fileName = linksArray.get(j + 1).toString();
          downloadFile(fileURL, savePath, fileName);
          progress++;
          Message msg = mHandler.obtainMessage();
          msg.arg1 = progress;
          mHandler.sendMessage(msg);
        }
      } else if (i == 1) {
        // we've got an array of folders so recurse down the levels, extracting subfolders and files
        // until we've downloaded everything.
        for (int j = 0; j < linksArray.size(); j += 2) {
          String folderURL = linksArray.get(j).toString();
          String folderName = linksArray.get(j + 1).toString();

          String page = getData(folderURL);
          List newFilesAndFolders = parsePage(page);
          String dlDirPath = savePath + folderName + "/";

          getFilesFromFolder(newFilesAndFolders, dlDirPath);
        }
      }
    }
  }
Esempio n. 3
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    c = this;
    preferences = PreferenceManager.getDefaultSharedPreferences(c);

    super.onCreate(savedInstanceState);

    setContentView(R.layout.gpu_sgx540);

    gpuCurrent = readFile(Constants.GPU_SGX540);
    seekGpu = (SeekBar) findViewById(R.id.seek_gpu);

    gpu = Arrays.asList(153, 307, 384);
    seekBar(gpu.size() - 1, gpu.indexOf(gpuCurrent));

    /*else{
    seekGpu.setEnabled(false);
    seekIva.setEnabled(false);
    TextView ns = (TextView)findViewById(R.id.not_supported);
    ns.setVisibility(View.VISIBLE);
    }*/
    preferences = PreferenceManager.getDefaultSharedPreferences(getBaseContext());

    curGpuTxt = (TextView) findViewById(R.id.current_gpu);
    maxGpuTxt = (TextView) findViewById(R.id.max_gpu);
    minGpuTxt = (TextView) findViewById(R.id.min_gpu);

    mhz = getResources().getString(R.string.mhz);
    current = getResources().getString(R.string.current);
    max = getResources().getString(R.string._max);
    min = getResources().getString(R.string._min);
    curGpuTxt.setText(current + ": " + (gpuCurrent) + mhz);
    maxGpuTxt.setText(max + ": " + gpu.get(2) + mhz);
    minGpuTxt.setText(min + ": " + gpu.get(0) + mhz);

    Button cancel = (Button) findViewById(R.id.cancel);
    cancel.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View arg0) {
            finish();
          }
        });
  }
Esempio n. 4
0
 public Bundle store() {
   Bundle bundle = new Bundle();
   int n = items.size();
   int x[] = new int[n];
   int y[] = new int[n];
   long d[] = new long[n];
   n = 0;
   for (Item item : items) {
     x[n] = item.x;
     y[n] = item.y;
     d[n] = item.duration;
     ++n;
   }
   bundle.putIntArray("x", x);
   bundle.putIntArray("y", y);
   bundle.putLongArray("d", d);
   bundle.putLong("cost", cost);
   return bundle;
 }
  /** Initializes "select account" spinner with existing accounts. */
  private void initAccountSpinner() {
    Spinner accountsSpiner = (Spinner) findViewById(R.id.selectAccountSpinner);

    Iterator<ProtocolProviderService> providers = AccountUtils.getRegisteredProviders().iterator();

    List<AccountID> accounts = new ArrayList<AccountID>();

    int selectedIdx = -1;
    int idx = 0;

    while (providers.hasNext()) {
      ProtocolProviderService provider = providers.next();

      OperationSet opSet = provider.getOperationSet(OperationSetPresence.class);

      if (opSet == null) continue;

      AccountID account = provider.getAccountID();
      accounts.add(account);
      idx++;

      if (account.isPreferredProvider()) {
        selectedIdx = idx;
      }
    }

    AccountsListAdapter accountsAdapter =
        new AccountsListAdapter(
            this, R.layout.select_account_row, R.layout.select_account_dropdown, accounts, true);
    accountsSpiner.setAdapter(accountsAdapter);

    // if we have only select account option and only one account
    // select the available account
    if (accounts.size() == 1) accountsSpiner.setSelection(0);
    else accountsSpiner.setSelection(selectedIdx);
  }
  public void nextLevel() {
    boolean loaded = false;
    final GameBoard boardView = (GameBoard) this.findViewById(R.id.gameBoard);
    this.level++;

    AssetManager am = getResources().getAssets();

    try {
      List<String> allTutoLevels =
          new LinkedList<String>(Arrays.asList(am.list("levels/tutorial")));

      // if(addMsg){
      //    allTutoLevels.addAll(Arrays.asList(am.list("msg")));
      // }

      Log.d(TAG, allTutoLevels.toString());

      for (String name : allTutoLevels) {
        if (name.startsWith(this.level + ".")) {
          BufferedReader br =
              new BufferedReader(new InputStreamReader(am.open("levels/tutorial/" + name)));
          String line;
          String levelJSON = "";

          while ((line = br.readLine()) != null) {
            levelJSON += line + "\n";
          }

          br.close();

          game.initGame(
              levelJSON, boardView.getMeasuredWidth() / 60, boardView.getMeasuredHeight() / 60);
          loaded = true;
        }
      }
    } catch (IOException e) {
      e.printStackTrace();
    }

    if (!loaded) {
      Random r = new Random();

      List<String> allLevels = new ArrayList<>();

      try {
        allLevels = Arrays.asList(am.list("levels"));
      } catch (IOException e) {
      }

      if (r.nextBoolean() && !allLevels.isEmpty() && allLevels.size() != allDoneLevels.size()) {
        try {
          int nLevel;
          do {
            nLevel = r.nextInt(allLevels.size());
          } while (allDoneLevels.contains(allLevels.get(nLevel)));

          String name = allLevels.get(nLevel);
          BufferedReader br = new BufferedReader(new InputStreamReader(am.open("levels/" + name)));

          String line;
          String levelJSON = "";

          while ((line = br.readLine()) != null) {
            levelJSON += line + "\n";
          }

          br.close();

          allDoneLevels.add(name);

          game.initGame(
              levelJSON, boardView.getMeasuredWidth() / 60, boardView.getMeasuredHeight() / 60);
        } catch (IOException e) {
          this.game.initGame(
              level, boardView.getMeasuredWidth() / 60, boardView.getMeasuredHeight() / 60);
        }
      } else {
        this.game.initGame(
            level, boardView.getMeasuredWidth() / 60, boardView.getMeasuredHeight() / 60);
      }
    }

    // am.close();

    boardView.setGame(this.game);
    boardView.invalidate();
    boardView.getHowdyShadeView().invalidate();

    Toast.makeText(this, this.level + "", Toast.LENGTH_SHORT).show();

    Log.i(
        TAG,
        "Max tiles : "
            + (boardView.getMeasuredWidth() / 60) * (boardView.getMeasuredHeight() / 60));
  }
Esempio n. 7
0
 public final int getCount() {
   return myCurrentBook ? myBookmarks.size() + 1 : myBookmarks.size();
 }
Esempio n. 8
0
 public int getMoveSteps() {
   return items.size();
 }
Esempio n. 9
0
 @Override
 public final int getCount() {
   return myShowAddBookmarkItem ? myBookmarks.size() + 1 : myBookmarks.size();
 }