Пример #1
0
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
      View view;
      ViewHolder holder;

      if (null == convertView) {
        view = View.inflate(getApplicationContext(), R.layout.app_list, null);
        holder = new ViewHolder();
        holder.app_icon = (ImageView) view.findViewById(R.id.applock_icon);
        holder.app_status = (ImageView) view.findViewById(R.id.applock_status);
        holder.app_name = (TextView) view.findViewById(R.id.applock_name);
        view.setTag(holder);
      } else {
        view = convertView;
        holder = (ViewHolder) view.getTag();
      }

      AppInfo appInfo = appInfos.get(position);

      holder.app_icon.setImageDrawable(appInfo.getAppicon());
      holder.app_name.setText(appInfo.getAppname());
      if (lockedPacknames.contains(appInfo.getPackname())) {
        holder.app_status.setImageResource(R.drawable.lock);
      } else {
        holder.app_status.setImageResource(R.drawable.unlock);
      }

      return view;
    }
Пример #2
0
  @Override
  public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

    AppInfo appInfo = (AppInfo) app_listview.getItemAtPosition(position);
    String packagename = appInfo.getPackname();
    ImageView status_icon = (ImageView) view.findViewById(R.id.applock_status);

    if (lockedPacknames.contains(packagename)) {
      Uri uri = Uri.parse("content://lang.com.applocker.applock/DELETE");
      getContentResolver().delete(uri, null, new String[] {packagename});

      status_icon.setImageResource(R.drawable.unlock);
      lockedPacknames.remove(packagename);
    } else {
      Uri uri = Uri.parse("content://lang.com.applocker.applock/ADD");
      ContentValues values = new ContentValues();
      values.put("packname", packagename);
      getContentResolver().insert(uri, values);

      status_icon.setImageResource(R.drawable.lock);
      lockedPacknames.add(packagename);
    }
  }