Пример #1
0
  @Override
  protected void onStart() {
    super.onStart();
    setActionBarInfo(getString(R.string.programs_title));
    this.getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    SoulissDBHelper.open();
    opzioni.initializePrefs();
    if (!opzioni.isDbConfigured()) {
      AlertDialogHelper.dbNotInitedDialog(this);
    }
    if (!opzioni.isDataServiceEnabled()) {
      AlertDialogHelper.serviceNotActiveDialog(this);
    }
    // prendo comandi dal DB, setto adapter
    LinkedList<SoulissCommand> goer = datasource.getUnexecutedCommands(this);
    if (goer.size() == 0) tt.setText(getString(R.string.programs_no));
    programsArray = new SoulissCommand[goer.size()];
    programsArray = goer.toArray(programsArray);
    progsAdapter =
        new ProgramListAdapter(
            this.getApplicationContext(), programsArray, datasource.getTriggerMap(this), opzioni);
    // Adapter della lista
    listaProgrammiView.setAdapter(progsAdapter);
    listaProgrammiView.invalidateViews();
    // forza refresh drawer
    mDrawermAdapter =
        new NavDrawerAdapter(
            ProgramListActivity.this,
            R.layout.drawer_list_item,
            dmh.getStuff(),
            DrawerMenuHelper.PROGRAMS);
    mDrawerList.setAdapter(mDrawermAdapter);

    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.attachToListView(listaProgrammiView);
    // ADD NEW PROGRAM Listener
    fab.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            Intent myIntentt = new Intent(ProgramListActivity.this, AddProgramActivity.class);
            ProgramListActivity.this.startActivityForResult(myIntentt, 12);
          }
        });
  }
Пример #2
0
        @Override
        public void onReceive(Context context, Intent intent) {
          List<SoulissCommand> goer = datasource.getUnexecutedCommands(ProgramListActivity.this);
          programsArray = new SoulissCommand[goer.size()];
          int q = 0;
          for (SoulissCommand object : goer) {
            programsArray[q++] = object;
          }

          progsAdapter =
              new ProgramListAdapter(
                  ProgramListActivity.this.getApplicationContext(),
                  programsArray,
                  datasource.getTriggerMap(ProgramListActivity.this),
                  opzioni);
          // Adapter della lista
          listaProgrammiView.setAdapter(progsAdapter);
          listaProgrammiView.invalidateViews();
        }