@Override
  protected void onCreate(Bundle savedInstanceState) {
    setTheme(PodcastApp.getThemeResourceId());
    super.onCreate(savedInstanceState);

    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    setContentView(R.layout.greader_import);

    lstvGoogleAccount = (ListView) findViewById(R.id.lstvGoogleAccount);
    butStart = (Button) findViewById(R.id.butStartImport);
    txtvNoGoogleAccount = (TextView) findViewById(R.id.txtvNoGoogleAccount);

    greader = new GoogleReader(this);

    if (greader.getGoogleAccountNames().length == 0) {
      txtvNoGoogleAccount.setVisibility(View.VISIBLE);
      butStart.setEnabled(false);
      return;
    } else {
      lstvGoogleAccount.setAdapter(
          new ArrayAdapter<String>(
              this,
              android.R.layout.simple_list_item_single_choice,
              greader.getGoogleAccountNames()));
      lstvGoogleAccount.setChoiceMode(ListView.CHOICE_MODE_SINGLE);

      butStart.setOnClickListener(
          new OnClickListener() {
            @Override
            public void onClick(View v) {
              int checkPosition = lstvGoogleAccount.getCheckedItemPosition();
              if (checkPosition == -1) {
                return;
              }
              Log.d(TAG, "getSelectedItemPosition:" + lstvGoogleAccount.getCheckedItemPosition());
              greader.setSelectedAccount(checkPosition);
              GoogleReaderImportWorker importWorker =
                  new GoogleReaderImportWorker(GoogleReaderImportActivity.this, greader) {
                    @Override
                    protected void handleResult(ArrayList<OpmlElement> result) {
                      if (result != null) {
                        if (AppConfig.DEBUG) Log.d(TAG, "Parsing was successful");
                        OpmlImportHolder.setReadElements(result);
                        startActivityForResult(
                            new Intent(
                                GoogleReaderImportActivity.this, OpmlFeedChooserActivity.class),
                            0);
                      } else {
                        if (AppConfig.DEBUG) Log.d(TAG, "Parser error occurred");
                      }
                    }
                  };
              importWorker.executeAsync();
            }
          });
    }
  }
Esempio n. 2
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    setTheme(PodcastApp.getThemeResourceId());
    super.onCreate(savedInstanceState);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    StorageUtils.checkStorageAvailability(this);
    setContentView(R.layout.addfeed);

    requester = DownloadRequester.getInstance();
    progDialog = new ProgressDialog(this);

    etxtFeedurl = (EditText) findViewById(R.id.etxtFeedurl);
    butBrowseMiroGuide = (Button) findViewById(R.id.butBrowseMiroguide);
    butOpmlImport = (Button) findViewById(R.id.butOpmlImport);
    butGreaderImport = (Button) findViewById(R.id.butGreaderImport);
    butConfirm = (Button) findViewById(R.id.butConfirm);
    butCancel = (Button) findViewById(R.id.butCancel);

    butBrowseMiroGuide.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            startActivity(new Intent(AddFeedActivity.this, MiroGuideMainActivity.class));
          }
        });

    butOpmlImport.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            startActivity(new Intent(AddFeedActivity.this, OpmlImportFromPathActivity.class));
          }
        });

    butGreaderImport.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            startActivity(new Intent(AddFeedActivity.this, GoogleReaderImportActivity.class));
          }
        });

    butConfirm.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            addNewFeed();
          }
        });

    butCancel.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            setResult(RESULT_CANCELED);
            finish();
          }
        });
  }