コード例 #1
0
  /** Populated the listview with discovered devices, and the spinner with those that are open */
  private void PopulateListView() {
    m_lvDevices.post(
        new Runnable() {
          public void run() {
            m_lvDevices.setAdapter(null);
            ArrayList<ListViewItem> m_Devices = new ArrayList<ListViewItem>();
            for (InputDevice idev : events.m_Devs) {
              ListViewItem device =
                  new ListViewItem(
                      idev.getName(), idev.getPath(), idev.getOpen(), idLVFirstItem + idev.getId());
              m_Devices.add(device);
            }
            CustomAdapter m_lvAdapter = new CustomAdapter(MainActivity.this, m_Devices);
            if (m_lvDevices != null) m_lvDevices.setAdapter(m_lvAdapter);
          }
        });
    m_selDevSpinner.post(
        new Runnable() {
          public void run() {
            ArrayList<String> openDevs = new ArrayList<String>();

            for (InputDevice idev : events.m_Devs) {
              if (idev.getOpen()) openDevs.add(idev.getName());
            }
            // populate spinner
            ArrayAdapter<String> adapter =
                new ArrayAdapter<String>(
                    MainActivity.this, android.R.layout.simple_spinner_item, openDevs);
            adapter.setDropDownViewResource(android.R.layout.select_dialog_singlechoice);
            // changes spin size and popup box size/color
            m_selDevSpinner.setAdapter(adapter);
          }
        });
  }
コード例 #2
0
 private void initPresetSpinner() {
   mPresetSpinner = (Spinner) findViewById(R.id.preset_spinner);
   mPresetSpinner.setAdapter(
       new NamedPresetSpinnerArrayAdapter(this, NotificationPresets.PRESETS));
   mPresetSpinner.post(
       new Runnable() {
         @Override
         public void run() {
           mPresetSpinner.setOnItemSelectedListener(new PresetSpinnerListener());
         }
       });
 }
コード例 #3
0
 private void initActionsSpinner() {
   mActionsSpinner = (Spinner) findViewById(R.id.actions_spinner);
   mActionsSpinner.setAdapter(new NamedPresetSpinnerArrayAdapter(this, ActionsPresets.PRESETS));
   mActionsSpinner.post(
       new Runnable() {
         @Override
         public void run() {
           mActionsSpinner.setOnItemSelectedListener(
               new UpdateNotificationsOnItemSelectedListener(false /* cancelExisting */));
         }
       });
 }
コード例 #4
0
 private void initPrioritySpinner() {
   mPrioritySpinner = (Spinner) findViewById(R.id.priority_spinner);
   mPrioritySpinner.setAdapter(new NamedPresetSpinnerArrayAdapter(this, PriorityPresets.PRESETS));
   mPrioritySpinner.setSelection(
       Arrays.asList(PriorityPresets.PRESETS).indexOf(PriorityPresets.DEFAULT));
   mPrioritySpinner.post(
       new Runnable() {
         @Override
         public void run() {
           mPrioritySpinner.setOnItemSelectedListener(
               new UpdateNotificationsOnItemSelectedListener(true /* cancelExisting */));
         }
       });
 }
  private void setAdapterForSP2(int index) {
    System.out.println(index);
    List list = CityCodeReadUtils.procity.get(CityCodeReadUtils.pro.get(index));
    ArrayAdapter adapter = new ArrayAdapter(context, android.R.layout.simple_spinner_item, list);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    sp_city.setAdapter(adapter);
    sp_city.post(
        new Runnable() {

          @Override
          public void run() {
            // TODO Auto-generated method stub
            sp_city.setSelection(Integer.valueOf(DataShare.get(context, Data.city_index, "0")));
          }
        });
  }
コード例 #6
0
ファイル: HomeFragment.java プロジェクト: ndphu/cm-w
 @Override
 public View onCreateView(
     LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
   View view = inflater.inflate(R.layout.fragment_homepage, container, false);
   // Spinner
   mSpinner = (Spinner) view.findViewById(R.id.fragment_homepage_spinner_category);
   mSpinner.setAdapter(mSpinnerAdapter);
   mSpinner.setSelection(mCurrentSpinnerPosition);
   mSpinner.post(
       new Runnable() {
         @Override
         public void run() {
           mSpinner.setOnItemSelectedListener(HomeFragment.this);
           if (mGridAdapter.getCount() == 0) {
             new LoadDataTask().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
           }
         }
       });
   // Grid view
   Log.i(TAG, "Init Gridview");
   mGridView = (GridView) view.findViewById(R.id.fragment_homepage_gridview);
   if (mGridAdapter == null) {
     mGridAdapter = new HomePageItemAdapter(getActivity(), 0);
   }
   mGridView.setAdapter(mGridAdapter);
   mGridView.post(
       new Runnable() {
         @Override
         public void run() {
           mGridView.setOnItemClickListener(HomeFragment.this);
           mGridView.setOnScrollListener(HomeFragment.this);
         }
       });
   // Progressbar indicator
   mProgressIndicator =
       (ProgressBar) view.findViewById(R.id.fragment_homepage_progressbar_loading_indicator);
   mProgressIndicator.setVisibility(View.GONE);
   return view;
 }
コード例 #7
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    View rootView = inflater.inflate(R.layout.fragment_cell_number_config, container, false);

    louRange = rootView.findViewById(R.id.lou_range);

    sprItems = (Spinner) rootView.findViewById(R.id.spr_items);
    sprItems.setOnItemSelectedListener(
        new AdapterView.OnItemSelectedListener() {
          @Override
          public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            ItemDB item = mItems.get(position);
            if (item != null) {
              item.save();

              if (item.getType().equals(ItemDB.TYPE_NUMBER)
                  || item.getType().equals(ItemDB.TYPE_GROUP)) {
                louRange.setVisibility(View.VISIBLE);
              } else {
                louRange.setVisibility(View.GONE);
              }

              numberCell.setItem(item);
              numberCell.save();
            }
          }

          @Override
          public void onNothingSelected(AdapterView<?> parent) {}
        });
    mItemAdapter =
        new ArrayAdapter<>(getActivity(), android.R.layout.simple_spinner_dropdown_item, mItems);
    sprItems.post(
        new Runnable() {
          @Override
          public void run() {
            sprItems.setAdapter(mItemAdapter);
          }
        });
    Communicator communicator = Communicator.instance(getActivity());
    List<ServerDB> servers = ServerDB.getServers();
    mItems.clear();
    if (numberCell.getItem() != null) {
      mItems.add(numberCell.getItem());
    }
    for (ServerDB server : servers) {
      communicator.requestItems(
          server,
          new Communicator.ItemsRequestListener() {
            @Override
            public void onSuccess(List<ItemDB> items) {
              items = filterItems(items);
              mItems.addAll(items);
              mItemAdapter.notifyDataSetChanged();
            }

            @Override
            public void onFailure(String message) {
              Log.d("Get Items", "Failure " + message);
            }
          });
    }

    btnSetIcon = (ImageButton) rootView.findViewById(R.id.btn_set_icon);
    updateIconImage();
    btnSetIcon.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            Intent intent = new Intent(getActivity(), IconPickerActivity.class);
            startActivityForResult(intent, REQUEST_ICON);
          }
        });

    txtMax = (TextView) rootView.findViewById(R.id.txt_max);
    if (numberCell != null) {
      txtMax.setText("" + numberCell.getMax());
    } else {
      txtMax.setText("" + 100);
    }

    return rootView;
  }
コード例 #8
0
  private void fillViews() {
    SharedPreferences preferences =
        PreferenceManager.getDefaultSharedPreferences(VLCApplication.getAppContext());
    float[] bands = null;
    String[] presets = null;
    try {
      libVlc = VLCInstance.getLibVlcInstance();
      bands = libVlc.getBands();
      presets = libVlc.getPresets();
      if (equalizer == null) equalizer = Preferences.getFloatArray(preferences, "equalizer_values");
      if (equalizer == null) equalizer = new float[bands.length + 1];
    } catch (LibVlcException e) {
      e.printStackTrace();
      return;
    }

    // on/off
    button.setChecked(libVlc.getEqualizer() != null);
    button.setOnCheckedChangeListener(
        new OnCheckedChangeListener() {
          @Override
          public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (libVlc == null) return;
            libVlc.setEqualizer(isChecked ? equalizer : null);
          }
        });

    // presets
    equalizer_presets.setAdapter(
        new ArrayAdapter<String>(
            getActivity(), android.R.layout.simple_spinner_dropdown_item, presets));

    // Set the default selection asynchronously to prevent a layout initialization bug.
    final int equalizer_preset_pref = preferences.getInt("equalizer_preset", 0);
    equalizer_presets.post(
        new Runnable() {
          @Override
          public void run() {
            equalizer_presets.setSelection(equalizer_preset_pref, false);
            equalizer_presets.setOnItemSelectedListener(mPresetListener);
          }
        });

    // preamp
    preamp.setMax(40);
    preamp.setProgress((int) equalizer[0] + 20);
    preamp.setOnSeekBarChangeListener(mPreampListener);

    // bands
    for (int i = 0; i < bands.length; i++) {
      float band = bands[i];

      EqualizerBar bar = new EqualizerBar(getActivity(), band);
      bar.setValue(equalizer[i + 1]);
      bar.setListener(new BandListener(i + 1));

      bands_layout.addView(bar);
      LinearLayout.LayoutParams params =
          new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT, 1);
      bar.setLayoutParams(params);
    }
  }
コード例 #9
0
  /**
   * Metoda, u osnovi, inicira GUI u modu za azuriranje postojećeg cilja. To se koknretnije odnosi
   * na popunjavanje odgovarajucih polja za input sa trenutnim atributima cilja koji se azurira.
   * Takodjer se postavljaju vrijednosti teksta podnaslova Activity - a i Button - a za potvru, na
   * odgovarajucu vrijednost.
   */
  private void initUpdateForm() {
    toolbar.setSubtitle(getString(R.string.updateExistingGoal));
    Intent intent = getIntent();
    int goalId = intent.getIntExtra(getResources().getString(R.string.extraGoalIdTag), -1);

    if (goalId == -1) {
      Toast.makeText(ctx, getResources().getString(R.string.errorMessage), Toast.LENGTH_SHORT)
          .show();
      onBackPressed();
      return;
    }
    ArrayList<Goal> goals = dbc.getGoals();
    updatingGoal = new Goal();
    int i = 0;
    for (; i < goals.size(); i++) {
      if (goals.get(i).getId() == goalId) {
        updatingGoal = goals.get(i);
        break;
      }
    }
    txtName.setText(updatingGoal.getName());
    txtComment.setText(updatingGoal.getComment());

    int temp = -1;
    if (updatingGoal.getHigherGoal() == null) temp = -1;
    else {
      Goal higherGoal = HigherGoalGenerator.getHigherGoal(updatingGoal);

      for (int j = 0; j < goals.size(); j++) {
        try {
          if (goals.get(j).getId() == higherGoal.getId()) {
            temp = j;
            break;
          }
        } catch (Exception e) {

        }
      }
    }
    final int higherGoalIndex = temp + 1;
    spnHigherGoal.post(
        new Runnable() {
          @Override
          public void run() {
            spnHigherGoal.setSelection(higherGoalIndex);
          }
        });

    btnChooseDate.setText(DataParser.dateToString(updatingGoal.getDeadline()));
    rbPriority.setRating(updatingGoal.getPriority());

    ArrayList<Category> categories = dbc.getCategories();
    i = 0;
    for (; i < categories.size(); i++) {
      if (categories.get(i).getId() == updatingGoal.getCategory().getId()) {
        final int categoryIndex = i;

        spnCategory.post(
            new Runnable() {
              @Override
              public void run() {
                spnCategory.setSelection(categoryIndex);
              }
            });
        break;
      }
    }
  }