Java Code Examples for com.android.gallery3d.filtershow.category.Action

Following code examples demonstrate how to use com.android.gallery3d.filtershow.category.Actionfrom android. These examples are extracted from various highly rated open source projects. You can directly use these code snippets or view their entire linked source code. These snippets are extracted to provide contextual information about how to use this class in the real world. These samples also let you understand some good practices on how to use com.android.gallery3d.filtershow.category.Actionand various code implementation of this class.

    private void updateActionFromEditText(EditText editText) {
        Action action = (Action) editText.getTag();
        String newName = editText.getText().toString();
        if (newName.length() > 0) {
            action.setName(editText.getText().toString());
            changePreset(action);
        }
    } 


    public View getView(int position, View convertView, ViewGroup parent) {
        UserPresetViewHolder viewHolder;
        if (convertView == null) {
            convertView = mInflater.inflate(R.layout.filtershow_presets_management_row, null);
            viewHolder = new UserPresetViewHolder();
            viewHolder.imageView = (ImageView) convertView.findViewById(R.id.imageView);
            viewHolder.editText = (EditText) convertView.findViewById(R.id.editView);
            viewHolder.deleteButton = (ImageButton) convertView.findViewById(R.id.deleteUserPreset);
            viewHolder.editText.setOnClickListener(this);
            viewHolder.editText.setOnFocusChangeListener(this);
            viewHolder.deleteButton.setOnClickListener(this);
            convertView.setTag(viewHolder);
        } else {
            viewHolder = (UserPresetViewHolder) convertView.getTag();
        }
        Action action = getItem(position);
        viewHolder.imageView.setImageBitmap(action.getImage());
        if (action.getImage() == null) {
            action.setImageFrame(new Rect(0, 0, mIconSize, mIconSize), CategoryView.VERTICAL);
        }
        viewHolder.deleteButton.setTag(action);
        viewHolder.editText.setTag(action);
        viewHolder.editText.setHint(action.getName());

        return convertView;
    } 

    public void add(Action action) {
        super.add(action);
        action.setAdapter(this);
    } 

    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.editView:
                v.requestFocus();
                break;
            case R.id.deleteUserPreset:
                Action action = (Action) v.getTag();
                deletePreset(action);
                break;
        }
    } 

    private void changePreset(Action action) {
        FilterRepresentation rep = action.getRepresentation();
        rep.setName(action.getName());
        if (rep instanceof FilterUserPresetRepresentation) {
            mChangedRepresentations.add((FilterUserPresetRepresentation) rep);
        }
    } 

    private void deletePreset(Action action) {
        FilterRepresentation rep = action.getRepresentation();
        if (rep instanceof FilterUserPresetRepresentation) {
            mDeletedRepresentations.add((FilterUserPresetRepresentation) rep);
        }
        remove(action);
        notifyDataSetChanged();
    } 

Advertisement
Advertisement