Example usage for android.widget ImageView setOnClickListener

List of usage examples for android.widget ImageView setOnClickListener

Introduction

In this page you can find the example usage for android.widget ImageView setOnClickListener.

Prototype

public void setOnClickListener(@Nullable OnClickListener l) 

Source Link

Document

Register a callback to be invoked when this view is clicked.

Usage

From source file:de.baumann.browser.popups.Popup_bookmarks.java

private void setBookmarksList() {

    //display data
    final int layoutstyle = R.layout.list_item;
    int[] xml_id = new int[] { R.id.textView_title_notes, R.id.textView_des_notes, R.id.textView_create_notes };
    String[] column = new String[] { "bookmarks_title", "bookmarks_content", "bookmarks_creation" };
    final Cursor row = db.fetchAllData(this);
    adapter = new SimpleCursorAdapter(this, layoutstyle, row, column, xml_id, 0) {
        @Override/*www. j  ava 2s  . com*/
        public View getView(final int position, View convertView, ViewGroup parent) {

            Cursor row2 = (Cursor) listView.getItemAtPosition(position);
            final String _id = row2.getString(row2.getColumnIndexOrThrow("_id"));
            final String bookmarks_title = row2.getString(row2.getColumnIndexOrThrow("bookmarks_title"));
            final String bookmarks_content = row2.getString(row2.getColumnIndexOrThrow("bookmarks_content"));
            final String bookmarks_icon = row2.getString(row2.getColumnIndexOrThrow("bookmarks_icon"));
            final String bookmarks_attachment = row2
                    .getString(row2.getColumnIndexOrThrow("bookmarks_attachment"));
            final String bookmarks_creation = row2.getString(row2.getColumnIndexOrThrow("bookmarks_creation"));

            View v = super.getView(position, convertView, parent);
            final ImageView iv_attachment = (ImageView) v.findViewById(R.id.att_notes);

            switch (bookmarks_attachment) {
            case "":
                iv_attachment.setVisibility(View.VISIBLE);
                iv_attachment.setImageResource(R.drawable.star_outline);
                break;
            default:
                iv_attachment.setVisibility(View.VISIBLE);
                iv_attachment.setImageResource(R.drawable.star_grey);
                break;
            }

            iv_attachment.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View arg0) {
                    if (bookmarks_attachment.equals("")) {

                        if (db.isExistFav("true")) {
                            Snackbar.make(listView, R.string.bookmark_setFav_not, Snackbar.LENGTH_LONG).show();
                        } else {
                            iv_attachment.setImageResource(R.drawable.star_grey);
                            db.update(Integer.parseInt(_id), bookmarks_title, bookmarks_content, bookmarks_icon,
                                    "true", bookmarks_creation);
                            setBookmarksList();
                            sharedPref.edit().putString("startURL", bookmarks_content).apply();
                            Snackbar.make(listView, R.string.bookmark_setFav, Snackbar.LENGTH_LONG).show();
                        }
                    } else {
                        iv_attachment.setImageResource(R.drawable.star_outline);
                        db.update(Integer.parseInt(_id), bookmarks_title, bookmarks_content, bookmarks_icon, "",
                                bookmarks_creation);
                        setBookmarksList();
                    }
                }
            });
            return v;
        }
    };

    //display data by filter
    final String note_search = sharedPref.getString("filter_bookmarksBY", "bookmarks_title");
    sharedPref.edit().putString("filter_bookmarksBY", "bookmarks_title").apply();
    editText.addTextChangedListener(new TextWatcher() {
        public void afterTextChanged(Editable s) {
        }

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

        public void onTextChanged(CharSequence s, int start, int before, int count) {
            adapter.getFilter().filter(s.toString());
        }
    });
    adapter.setFilterQueryProvider(new FilterQueryProvider() {
        public Cursor runQuery(CharSequence constraint) {
            return db.fetchDataByFilter(constraint.toString(), note_search);
        }
    });

    listView.setAdapter(adapter);
    //onClick function
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapterview, View view, int position, long id) {

            Cursor row = (Cursor) listView.getItemAtPosition(position);
            final String bookmarks_content = row.getString(row.getColumnIndexOrThrow("bookmarks_content"));

            sharedPref.edit().putString("openURL", bookmarks_content).apply();
            finish();
        }
    });

    listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
        public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {

            Cursor row2 = (Cursor) listView.getItemAtPosition(position);
            final String _id = row2.getString(row2.getColumnIndexOrThrow("_id"));
            final String bookmarks_title = row2.getString(row2.getColumnIndexOrThrow("bookmarks_title"));
            final String bookmarks_content = row2.getString(row2.getColumnIndexOrThrow("bookmarks_content"));
            final String bookmarks_icon = row2.getString(row2.getColumnIndexOrThrow("bookmarks_icon"));
            final String bookmarks_attachment = row2
                    .getString(row2.getColumnIndexOrThrow("bookmarks_attachment"));
            final String bookmarks_creation = row2.getString(row2.getColumnIndexOrThrow("bookmarks_creation"));

            final CharSequence[] options = { getString(R.string.menu_share), getString(R.string.menu_save),
                    getString(R.string.bookmark_edit_title), getString(R.string.bookmark_remove_bookmark) };
            new AlertDialog.Builder(Popup_bookmarks.this)
                    .setPositiveButton(R.string.toast_cancel, new DialogInterface.OnClickListener() {

                        public void onClick(DialogInterface dialog, int whichButton) {
                            dialog.cancel();
                        }
                    }).setItems(options, new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int item) {
                            if (options[item].equals(getString(R.string.bookmark_edit_title))) {
                                sharedPref.edit().putString("edit_id", _id).apply();
                                sharedPref.edit().putString("edit_content", bookmarks_content).apply();
                                sharedPref.edit().putString("edit_icon", bookmarks_icon).apply();
                                sharedPref.edit().putString("edit_attachment", bookmarks_attachment).apply();
                                sharedPref.edit().putString("edit_creation", bookmarks_creation).apply();
                                editText.setVisibility(View.VISIBLE);
                                helper_editText.showKeyboard(Popup_bookmarks.this, editText, 2, bookmarks_title,
                                        getString(R.string.bookmark_edit_title));
                            }

                            if (options[item].equals(getString(R.string.bookmark_remove_bookmark))) {
                                Snackbar snackbar = Snackbar
                                        .make(listView, R.string.bookmark_remove_confirmation,
                                                Snackbar.LENGTH_LONG)
                                        .setAction(R.string.toast_yes, new View.OnClickListener() {
                                            @Override
                                            public void onClick(View view) {
                                                db.delete(Integer.parseInt(_id));
                                                setBookmarksList();
                                            }
                                        });
                                snackbar.show();
                            }
                            if (options[item].equals(getString(R.string.menu_share))) {
                                final CharSequence[] options = { getString(R.string.menu_share_link),
                                        getString(R.string.menu_share_link_copy) };
                                new AlertDialog.Builder(Popup_bookmarks.this)
                                        .setPositiveButton(R.string.toast_cancel,
                                                new DialogInterface.OnClickListener() {

                                                    public void onClick(DialogInterface dialog,
                                                            int whichButton) {
                                                        dialog.cancel();
                                                    }
                                                })
                                        .setItems(options, new DialogInterface.OnClickListener() {
                                            @Override
                                            public void onClick(DialogInterface dialog, int item) {
                                                if (options[item].equals(getString(R.string.menu_share_link))) {
                                                    Intent sharingIntent = new Intent(Intent.ACTION_SEND);
                                                    sharingIntent.setType("text/plain");
                                                    sharingIntent.putExtra(Intent.EXTRA_SUBJECT,
                                                            bookmarks_title);
                                                    sharingIntent.putExtra(Intent.EXTRA_TEXT,
                                                            bookmarks_content);
                                                    startActivity(Intent.createChooser(sharingIntent,
                                                            (getString(R.string.app_share_link))));
                                                }
                                                if (options[item]
                                                        .equals(getString(R.string.menu_share_link_copy))) {
                                                    ClipboardManager clipboard = (ClipboardManager) Popup_bookmarks.this
                                                            .getSystemService(Context.CLIPBOARD_SERVICE);
                                                    clipboard.setPrimaryClip(
                                                            ClipData.newPlainText("text", bookmarks_content));
                                                    Snackbar.make(listView, R.string.context_linkCopy_toast,
                                                            Snackbar.LENGTH_SHORT).show();
                                                }
                                            }
                                        }).show();
                            }
                            if (options[item].equals(getString(R.string.menu_save))) {
                                final CharSequence[] options = { getString(R.string.menu_save_readLater),
                                        getString(R.string.menu_save_pass),
                                        getString(R.string.menu_createShortcut) };
                                new AlertDialog.Builder(Popup_bookmarks.this)
                                        .setPositiveButton(R.string.toast_cancel,
                                                new DialogInterface.OnClickListener() {

                                                    public void onClick(DialogInterface dialog,
                                                            int whichButton) {
                                                        dialog.cancel();
                                                    }
                                                })
                                        .setItems(options, new DialogInterface.OnClickListener() {
                                            @Override
                                            public void onClick(DialogInterface dialog, int item) {
                                                if (options[item].equals(getString(R.string.menu_save_pass))) {
                                                    helper_editText.editText_savePass(Popup_bookmarks.this,
                                                            listView, bookmarks_title, bookmarks_content);
                                                }
                                                if (options[item]
                                                        .equals(getString(R.string.menu_save_readLater))) {
                                                    DbAdapter_ReadLater db = new DbAdapter_ReadLater(
                                                            Popup_bookmarks.this);
                                                    db.open();
                                                    if (db.isExist(bookmarks_content)) {
                                                        Snackbar.make(editText,
                                                                getString(R.string.toast_newTitle),
                                                                Snackbar.LENGTH_LONG).show();
                                                    } else {
                                                        db.insert(bookmarks_title, bookmarks_content, "", "",
                                                                helper_main.createDate());
                                                        Snackbar.make(listView, R.string.bookmark_added,
                                                                Snackbar.LENGTH_LONG).show();
                                                    }
                                                }
                                                if (options[item]
                                                        .equals(getString(R.string.menu_createShortcut))) {
                                                    Intent i = new Intent();
                                                    i.setAction(Intent.ACTION_VIEW);
                                                    i.setClassName(Popup_bookmarks.this,
                                                            "de.baumann.browser.Browser_left");
                                                    i.setData(Uri.parse(bookmarks_content));

                                                    Intent shortcut = new Intent();
                                                    shortcut.putExtra("android.intent.extra.shortcut.INTENT",
                                                            i);
                                                    shortcut.putExtra("android.intent.extra.shortcut.NAME",
                                                            "THE NAME OF SHORTCUT TO BE SHOWN");
                                                    shortcut.putExtra(Intent.EXTRA_SHORTCUT_NAME,
                                                            bookmarks_title);
                                                    shortcut.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE,
                                                            Intent.ShortcutIconResource.fromContext(
                                                                    Popup_bookmarks.this
                                                                            .getApplicationContext(),
                                                                    R.mipmap.ic_launcher));
                                                    shortcut.setAction(
                                                            "com.android.launcher.action.INSTALL_SHORTCUT");
                                                    Popup_bookmarks.this.sendBroadcast(shortcut);
                                                    Snackbar.make(listView,
                                                            R.string.menu_createShortcut_success,
                                                            Snackbar.LENGTH_SHORT).show();
                                                }
                                            }
                                        }).show();
                            }

                        }
                    }).show();
            return true;
        }
    });
}

From source file:ac.robinson.ticqr.TicQRActivity.java

private void addTickHighlight(TickBoxHolder tickBox) {
    int tickIcon = R.drawable.ic_highlight_tick;
    Drawable tickDrawable = getResources().getDrawable(tickIcon);

    ImageView tickHighlight = new ImageView(TicQRActivity.this);
    tickHighlight.setImageResource(tickIcon);
    RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    layoutParams.leftMargin = mImageView.getLeft() + Math.round(tickBox.imagePosition.x)
            - (tickDrawable.getIntrinsicWidth() / 2);
    layoutParams.topMargin = mImageView.getTop() + Math.round(tickBox.imagePosition.y)
            - (tickDrawable.getIntrinsicHeight() / 2);

    ((RelativeLayout) findViewById(R.id.tick_highlight_holder)).addView(tickHighlight, layoutParams);
    tickHighlight.startAnimation(AnimationUtils.loadAnimation(this, R.anim.pulse));

    tickHighlight.setOnClickListener(mTickClickListener);
    tickHighlight.setTag(tickBox);//from  www  .  j a v  a  2 s . c o  m
}

From source file:eu.inmite.apps.smsjizdenka.framework.about.BaseAboutFragment.java

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    FrameLayout vCustomPart = (FrameLayout) view.findViewById(R.id.part_custom);
    ImageView vAppIcon = (ImageView) view.findViewById(R.id.part_app_icon);
    TextView vVersion = (TextView) view.findViewById(R.id.part_version);
    TextView vOpensource = (TextView) view.findViewById(R.id.part_opensource);
    TextView vAppName = (TextView) view.findViewById(R.id.part_app_name);

    if (isVisible(PART_CUSTOM)) {
        View customView = getCustomPart();
        if (customView != null) {
            vCustomPart.setVisibility(View.VISIBLE);
            vCustomPart.addView(customView);
        }/*from  ww  w .  j  ava 2 s.co m*/
    } else {
        vCustomPart.setVisibility(View.GONE);
    }

    if (isVisible(PART_APP_NAME)) {
        vAppName.setText(
                getActivity().getApplicationInfo().loadLabel(getActivity().getPackageManager()).toString());
    } else {
        vAppName.setVisibility(View.GONE);
    }

    if (isVisible(PART_APP_ICON)) {
        if (getAppIcon() != 0) {
            vAppIcon.setImageResource(getAppIcon());
        }
        vAppIcon.setVisibility(View.VISIBLE);
        vAppIcon.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                IntentUtils.openBrowser(getActivity(), "http://www.avast.com");
            }
        });
    } else {
        vAppIcon.setVisibility(View.GONE);
    }

    if (isVisible(PART_VERSION)) {
        vVersion.setVisibility(View.VISIBLE);
        setupVersion(vVersion);
    } else {
        vVersion.setVisibility(View.GONE);
    }

    if (isVisible(PART_OPENSOURCE)) {
        vOpensource.setVisibility(View.VISIBLE);
        setupLink(vOpensource, new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                openOpenSourceDialog();
            }
        });
    } else {
        vOpensource.setVisibility(View.GONE);
    }

}

From source file:dev.datvt.cloudtracks.sound_cloud.LocalTracksFragment.java

public void setUpListPlaylist() {
    menus = new ArrayList<>();
    mm.removeAllViews();/*from ww w  . java 2s .  c  o m*/
    LayoutInflater lf = LayoutInflater.from(ctx);

    if (true) {
        LinearLayout con;
        con = (LinearLayout) lf.inflate(R.layout.fragment_local_main, null);
        ImageView art = (ImageView) con.findViewById(R.id.artM);
        ImageView shuf = (ImageView) con.findViewById(R.id.shuffleM);
        ImageView del = (ImageView) con.findViewById(R.id.delM);
        TextView mn = (TextView) con.findViewById(R.id.nameM);
        TextView sn = (TextView) con.findViewById(R.id.noM);

        con.setGravity(Gravity.CENTER);
        art.setImageResource(R.drawable.icon_add_press);
        mn.setText(getString(R.string.create_new));

        art.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                showChangeLangDialog();
            }
        });
        mm.addView(con);
    }

    final ArrayList<String> names = ToolsHelper.getListPlaylist();

    if (names.size() > 0) {
        for (int i = 0; i < ToolsHelper.getListPlaylist().size(); i++) {
            View con;

            con = lf.inflate(R.layout.fragment_local_main, null);
            ImageView art = (ImageView) con.findViewById(R.id.artM);
            ImageView shuf = (ImageView) con.findViewById(R.id.shuffleM);
            ImageView del = (ImageView) con.findViewById(R.id.delM);
            TextView mn = (TextView) con.findViewById(R.id.nameM);
            TextView sn = (TextView) con.findViewById(R.id.noM);

            Menu m;

            art.setImageResource(R.drawable.default_nhaccuatui);
            shuf.setImageResource(R.drawable.ic_shuffle);
            shuf.setVisibility(View.VISIBLE);
            del.setImageResource(R.drawable.ic_delete);
            del.setVisibility(View.VISIBLE);
            mn.setText(names.get(i).replace(".lst", ""));
            sn.setText(
                    "" + ToolsHelper.getPlayList(ctx, names.get(i)).size() + " " + getString(R.string.songs));
            sn.setVisibility(View.VISIBLE);

            final String playlistname = names.get(i);

            con.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    mm.setVisibility(View.GONE);
                    lnBack.setVisibility(View.VISIBLE);
                    ref.setVisibility(View.VISIBLE);
                    ExecuterU ex = new ExecuterU(ctx, getString(R.string.scanning)) {

                        @Override
                        public void doIt() {
                            baseLocal = ToolsHelper.getPlayList(ctx, playlistname);
                        }

                        @Override
                        public void doNe() {
                            setUpList(baseLocal);
                        }
                    };
                    ex.execute();
                }
            });

            del.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    File f = new File(MainActivity.folder + "/Playlist/" + playlistname);
                    f.delete();
                    setUpListPlaylist();
                }
            });

            shuf.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    ExecuterU ex = new ExecuterU(ctx, getString(R.string.scanning)) {
                        @Override
                        public void doIt() {
                            ArrayList<Track> tracks = ToolsHelper.getPlayList(ctx, playlistname);
                            localTracks = tracks;
                        }

                        @Override
                        public void doNe() {
                            ArrayList<Track> tracks = localTracks;
                            Collections.shuffle(tracks);
                            if (tracks.size() > 0) {
                                if (tracks.get(0).bpm == ToolsHelper.IS_LOCAL)
                                    mListener.onListFragmentInteraction(tracks, tracks.get(0), 0,
                                            ToolsHelper.IS_LOCAL);
                                else {
                                    mListener.onListFragmentInteraction(tracks, tracks.get(0), 0,
                                            ToolsHelper.DOWNLOAD_CODE);
                                }
                            } else {
                                ToolsHelper.toast(ctx, getString(R.string.empty_playlist));
                            }
                        }
                    };
                    ex.execute();
                }
            });

            m = new Menu(con, art, mn, sn);
            menus.add(m);
            mm.addView(con);
        }
    }
}

From source file:com.teitsmch.hearthmaker.MainActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.navigation_drawer, menu);

    final MenuItem item = menu.findItem(R.id.action_search);
    //item.setActionView(R.layout.iv_rotate);
    //ImageView refresh = (ImageView) item.getActionView();
    final ImageView image = new ImageView(this);
    ViewGroup.MarginLayoutParams layoutParams = new ViewGroup.MarginLayoutParams(
            ViewGroup.MarginLayoutParams.WRAP_CONTENT, ViewGroup.MarginLayoutParams.WRAP_CONTENT);
    image.setLayoutParams(layoutParams);
    image.setImageResource(R.drawable.ic_filter_list_24dp);
    int padding_in_dp = 16;
    final float scale = getResources().getDisplayMetrics().density;
    int padding_in_px = (int) (padding_in_dp * scale + 0.5f);
    image.setPadding(padding_in_px, 0, padding_in_px, 0);

    image.setOnClickListener(new View.OnClickListener() {
        @Override//from w  w  w  .ja  va  2 s.  c om
        public void onClick(View v) {
            if (mSpinnerView.getVisibility() == View.VISIBLE)
                image.setImageResource(R.drawable.rev_ic_filter_list_24dp);
            else
                image.setImageResource(R.drawable.ic_filter_list_24dp);

            onOptionsItemSelected(item);
        }
    });
    item.setActionView(image);

    if (mFragment.getClass() == CardViewFragment.class) {
        menu.findItem(MENU_ITEM_RENAME).setVisible(false);
        menu.findItem(MENU_ITEM_CLEAR).setVisible(false);
        menu.findItem(MENU_ITEM_DELETE).setVisible(false);
        menu.findItem(R.id.class_icon).setVisible(false);
    } else {
        menu.findItem(MENU_ITEM_RENAME).setVisible(true);
        menu.findItem(MENU_ITEM_CLEAR).setVisible(true);
        menu.findItem(MENU_ITEM_DELETE).setVisible(true);
        menu.findItem(R.id.class_icon).setVisible(true);
        menu.findItem(R.id.class_icon).setIcon(classIcon);
    }

    return super.onCreateOptionsMenu(menu);
}

From source file:com.arkami.myidkey.activity.KeyCardEditActivity.java

/**
 * Adds a tag to the layout with tags;/* w  w w.ja va2s  .  c  o m*/
 *
 * @param tag
 */
private void addTagToView(final Tag tag) {
    final View tagItem = View.inflate(this, R.layout.tag_item_layout, null);
    TextView tagName = (TextView) tagItem.findViewById(R.id.tag_item_name);
    ImageView removeButton = (ImageView) tagItem.findViewById(R.id.tag_item_close_button);
    removeButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            selectedTags.removeView(tagItem);
            keyCard.setTagIds(KeyCard.removeId(tag.getId(), keyCard.getTagIds()));
            // keyCardDataSource.update(keyCard);
            if ((selectTagDialog != null) && (selectTagDialog.getAdapter() != null)) {
                selectTagDialog.getAdapter().removeSelected(tag.getId());
                selectTagDialog.getAdapter().notifyDataSetChanged();
            }
        }
    });
    tagName.setText(tag.getName());
    selectedTags.addView(tagItem);
}

From source file:net.inbox.InboxMessage.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (resultCode == 19091) {
        crypto_locked = true;/*from w w  w  . j  a v a 2s .c  om*/
        iv_gpg_crypto.setImageResource(R.drawable.padlock_open_inverse);
        msg_signature = data.getStringExtra("msg-signature");
        if (data.getIntExtra("ret-code", 0) == 92) {
            msg_contents = data.getStringExtra("message-crypto");

            // MIME parsing
            gpg_mime_parsing();
        }
        if (msg_signature != null && msg_signature.length() > 0) {
            final AppCompatActivity ct = this;
            ImageView iv_gpg_signature = (ImageView) findViewById(R.id.iv_gpg_signature);
            iv_gpg_signature.setVisibility(View.VISIBLE);
            iv_gpg_signature.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    Dialogs.dialog_server_ext(getString(R.string.open_pgp_message_signature), msg_signature,
                            ct);
                }
            });
        }
    }
}

From source file:com.nnm.smsviet.MessageListActivity.java

/**
 * Show {@link Contact}'s photo.// ww w  . j av  a 2  s . c om
 * 
 * @param contact
 *            {@link Contact}
 */
private void setContactIcon(final Contact contact) {
    if (contact == null) {
        Log.w(TAG, "setContactIcon(null)");
        this.showContactItem = false;
        return;
    }

    final String name = contact.getName();
    this.showContactItem = this.showPhoto && name != null;

    if (this.contactItem == null) {
        Log.w(TAG, "setContactIcon: contactItem == null");
        return;
    }

    if (!this.needContactUpdate) {
        Log.i(TAG, "skip setContactIcon()");
        return;
    }

    if (this.showPhoto && name != null) {
        // photo
        ImageView ivPhoto = (ImageView) this.findViewById(R.id.photo);
        if (ivPhoto == null) {
            ivPhoto = (ImageView) this.contactItem.getActionView().findViewById(R.id.photo);
        }
        if (ivPhoto == null) {
            Log.w(TAG, "ivPhoto == null");
        } else {
            ivPhoto.setImageDrawable(contact.getAvatar(this, this.defaultContactAvatar));
            ivPhoto.setOnClickListener(WRAPPER.getQuickContact(this, ivPhoto,
                    contact.getLookUpUri(this.getContentResolver()), 2, null));
        }

        // presence
        ImageView ivPresence = (ImageView) this.findViewById(R.id.presence);
        if (ivPresence == null) {
            ivPresence = (ImageView) this.contactItem.getActionView().findViewById(R.id.presence);
        }
        if (ivPresence == null) {
            Log.w(TAG, "ivPresence == null");
        } else {
            if (contact.getPresenceState() > 0) {
                ivPresence.setImageResource(Contact.getPresenceRes(contact.getPresenceState()));
                ivPresence.setVisibility(View.VISIBLE);
            } else {
                ivPresence.setVisibility(View.INVISIBLE);
            }
        }
    }

    this.contactItem.setVisible(this.showContactItem);
    this.needContactUpdate = false;
}

From source file:com.retroteam.studio.retrostudio.EditorLandscape.java

/**
 * Create all the views associated with a measure.
 * @param v//ww w . java2 s. c  om
 * @param projectLoad
 */

private void addMeasure(View v, boolean projectLoad) {
    int whichtrack = (int) v.getTag(R.id.TAG_ROW);
    int whichmeasure = (int) v.getTag(R.id.TAG_COLUMN);

    if (!projectLoad) {
        theproject.track(whichtrack).addMeasure();
    }
    GridLayout myparent = (GridLayout) v.getParent();

    ImageView measure = new ImageView(getApplicationContext());
    measure.setImageResource(R.drawable.measure_new_empty);
    measure.setLayoutParams(new LinearLayout.LayoutParams((int) (displaysize.x / 3.32),
            LinearLayout.LayoutParams.MATCH_PARENT));
    measure.setTag(R.id.TAG_ROW, whichtrack);
    measure.setTag(R.id.TAG_COLUMN, whichmeasure);
    measure.setTag(R.bool.TAG_HASNOTES, false);
    measure.setTag(R.id.TAG_GUISNAP, 0);
    measure.setTag(R.id.TAG_FILLED_NOTES, new ArrayList<int[]>());
    measure.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            ///
            int whichtrack = (int) v.getTag(R.id.TAG_ROW);
            int whichmeasure = (int) v.getTag(R.id.TAG_COLUMN);
            editMeasure(v);
        }
    });
    myparent.addView(measure, whichmeasure + 1);

    v.setTag(R.id.TAG_COLUMN, whichmeasure + 1);
}

From source file:com.coinprism.wallet.fragment.BalanceTab.java

/**
 * Constructs the UI when the activity is first rendered.
 *
 * @param rootView the rootView of the fragment
 *///www  . jav  a  2s .  c o m
public void setupUI(final View rootView) {
    final WalletState state = WalletState.getState();

    final TextView addressText = (TextView) rootView.findViewById(R.id.address);
    final ImageView qrCode = (ImageView) rootView.findViewById(R.id.qrAddress);

    final ToggleButton addressTypeSelector = (ToggleButton) rootView.findViewById(R.id.addressTypeSelector);

    final View.OnClickListener enlarge = new View.OnClickListener() {
        // Enlarge the QR code
        @Override
        public void onClick(View view) {
            final QRCodeDialog dialog = new QRCodeDialog();
            if (addressTypeSelector.isChecked()) {
                dialog.configure(WalletState.getState().getConfiguration().getReceiveAssetAddress(),
                        getString(R.string.tab_wallet_dialog_qr_title_assets));
            } else {
                dialog.configure(WalletState.getState().getConfiguration().getAddress(),
                        getString(R.string.tab_wallet_dialog_qr_title_bitcoin));
            }

            dialog.show(BalanceTab.this.getActivity().getSupportFragmentManager(), "");
        }
    };

    LinearLayout addressPanel = (LinearLayout) rootView.findViewById(R.id.addressArea);
    addressPanel.setOnClickListener(enlarge);
    qrCode.setOnClickListener(enlarge);

    addressTypeSelector.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
            if (addressTypeSelector.isChecked()) {
                addressText.setText(state.getConfiguration().getReceiveAssetAddress());
                QRCodeEncoder.createQRCode(state.getConfiguration().getReceiveAssetAddress(), qrCode, 148, 148,
                        8, 0xFFFFFFFF);
            } else {
                addressText.setText(state.getConfiguration().getAddress());
                QRCodeEncoder.createQRCode(state.getConfiguration().getAddress(), qrCode, 148, 148, 8,
                        0xFFFFFFFF);
            }
        }
    });

    addressTypeSelector.setChecked(true);
}