Example #1
0
 @Override
 public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
   if (mAppAdapter != null) {
     String restrictionName = XRestriction.getRestrictions().get(pos);
     mAppAdapter.setRestrictionName(restrictionName);
   }
 }
Example #2
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // Set layout
    String sTheme = XRestriction.getSetting(null, this, XRestriction.cSettingTheme, null, false);
    mThemeId = (sTheme == null ? android.R.style.Theme_Holo_Light : Integer.parseInt(sTheme));
    setTheme(mThemeId);
    setContentView(R.layout.xmainlist);

    // Get localized restriction name
    List<String> listRestriction = XRestriction.getRestrictions();
    List<String> listLocalizedRestriction = new ArrayList<String>();
    for (String restrictionName : listRestriction)
      listLocalizedRestriction.add(XRestriction.getLocalizedName(this, restrictionName));

    // Build spinner adapter
    ArrayAdapter<String> spAdapter =
        new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item);
    spAdapter.addAll(listLocalizedRestriction);

    // Setup search
    final EditText etFilter = (EditText) findViewById(R.id.etFilter);
    etFilter.addTextChangedListener(
        new TextWatcher() {
          @Override
          public void onTextChanged(CharSequence s, int start, int before, int count) {
            if (mAppAdapter != null) mAppAdapter.getFilter().filter(etFilter.getText().toString());
          }

          @Override
          public void beforeTextChanged(CharSequence s, int start, int count, int after) {}

          @Override
          public void afterTextChanged(Editable s) {}
        });

    // Setup spinner
    spRestriction = (Spinner) findViewById(R.id.spRestriction);
    spRestriction.setAdapter(spAdapter);
    spRestriction.setOnItemSelectedListener(this);

    // Handle help
    ImageView ivHelp = (ImageView) findViewById(R.id.ivHelp);
    ivHelp.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            Dialog dialog = new Dialog(ActivityMain.this);
            dialog.requestWindowFeature(Window.FEATURE_LEFT_ICON);
            dialog.setTitle(getString(R.string.help_application));
            dialog.setContentView(R.layout.xhelp);
            dialog.setFeatureDrawableResource(Window.FEATURE_LEFT_ICON, R.drawable.ic_launcher);
            dialog.setCancelable(true);
            dialog.show();
          }
        });

    // Start task to get app list
    AppListTask appListTask = new AppListTask();
    appListTask.execute(listRestriction.get(0));

    // Check environment
    checkRequirements();
  }