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:com.frostwire.android.gui.adapters.FileListAdapter.java

private View getListItemView(int position, View view, ViewGroup parent) {
    view = super.getView(position, view, parent);
    final FileDescriptorItem item = getItem(position);
    if (item.fd.fileType == Constants.FILE_TYPE_AUDIO || item.fd.fileType == Constants.FILE_TYPE_RINGTONES) {
        initPlaybackStatusOverlayTouchFeedback(view, item);
    }//from ww  w  .ja  v  a 2  s. c  o m
    ImageView thumbnailView = findView(view,
            R.id.view_my_files_thumbnail_list_item_browse_thumbnail_image_button);
    if (thumbnailView != null) {
        thumbnailView.setTag(item);
        thumbnailView.setOnClickListener(v -> {
            if (!selectAllMode) {
                if (getShowMenuOnClick()) {
                    if (showMenu(v)) {
                        return;
                    }
                }
                LOG.info("AbstractListAdapter.ViewOnClickListener.onClick()");
                onItemClicked(v);
            } else {
                onItemClicked(v);
            }
        });
    }
    return view;
}

From source file:at.alladin.rmbt.android.adapter.result.RMBTResultPagerAdapter.java

public void addResultListItem(String title, String value, LinearLayout netLayout) {
    final float scale = activity.getResources().getDisplayMetrics().density;
    final int leftRightDiv = Helperfunctions.dpToPx(0, scale);
    final int topBottomDiv = Helperfunctions.dpToPx(0, scale);
    final int heightDiv = Helperfunctions.dpToPx(1, scale);

    LayoutInflater inflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    final View measurementItemView = inflater.inflate(R.layout.classification_list_item, netLayout, false);

    final TextView itemTitle = (TextView) measurementItemView.findViewById(R.id.classification_item_title);
    itemTitle.setText(title);/*from  w  w  w  . java2  s .co  m*/

    final ImageView itemClassification = (ImageView) measurementItemView
            .findViewById(R.id.classification_item_color);
    itemClassification.setImageResource(Helperfunctions.getClassificationColor(-1));

    itemClassification.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            activity.showHelp(R.string.url_help_result, false);
        }
    });

    final TextView itemValue = (TextView) measurementItemView.findViewById(R.id.classification_item_value);
    itemValue.setText(value);

    netLayout.addView(measurementItemView);

    final View divider = new View(activity);
    divider.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, heightDiv, 1));
    divider.setPadding(leftRightDiv, topBottomDiv, leftRightDiv, topBottomDiv);

    divider.setBackgroundResource(R.drawable.bg_trans_light_10);

    netLayout.addView(divider);

    netLayout.invalidate();
}

From source file:com.gcssloop.diycode.activity.MainActivity.java

private void loadMenuData() {
    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    View headerView = navigationView.getHeaderView(0);
    ImageView avatar = (ImageView) headerView.findViewById(R.id.nav_header_image);
    TextView username = (TextView) headerView.findViewById(R.id.nav_header_name);
    TextView tagline = (TextView) headerView.findViewById(R.id.nav_header_tagline);

    if (mDiycode.isLogin()) {
        UserDetail me = mCache.getMe();//from www  . ja v  a 2  s  .c  o m
        if (me == null) {
            Logger.e("?");
            mDiycode.getMe(); // ?
            return;
        }

        username.setText(me.getLogin());
        tagline.setText(me.getTagline());
        Glide.with(this).load(me.getAvatar_url()).into(avatar);
        avatar.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                UserDetail me = mCache.getMe();
                if (me == null) {
                    try {
                        me = mDiycode.getMeNow();
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }

                if (me != null) {
                    User user = new User();
                    user.setId(me.getId());
                    user.setName(me.getName());
                    user.setLogin(me.getLogin());
                    user.setAvatar_url(me.getAvatar_url());
                    UserActivity.newInstance(MainActivity.this, user);
                }
            }
        });
    } else {
        mCache.removeMe();
        username.setText("()");
        tagline.setText("?");
        avatar.setImageResource(R.mipmap.ic_launcher);
        avatar.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                openActivity(LoginActivity.class);
            }
        });
    }
}

From source file:com.hxqc.mall.auto.fragment.CenterEditAutoFragment.java

/**
 * ?//from w  ww . java 2s  .  c om
 */
private void dialogAutoInfoComplete(final MyAuto myAuto) {
    View view = LayoutInflater.from(getActivity()).inflate(R.layout.view_auto_info_complete, null);
    final AlertDialog imAlertDialog = new AlertDialog.Builder(getActivity()).setView(view).create();
    imAlertDialog.setCanceledOnTouchOutside(false);
    imAlertDialog.show();
    ImageView cancelView = (ImageView) view.findViewById(R.id.dialog_cancel);
    Button completeView = (Button) view.findViewById(R.id.dialog_complete);
    cancelView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            imAlertDialog.dismiss();

        }
    });

    completeView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (UserInfoHelper.getInstance().isLogin(getActivity())) {
                //                    ActivitySwitchAutoInfo.toAutoInfo(getActivity());
                //                    ActivitySwitchBase.toAutoInfo(getActivity(), "", AutoInfoContants.AUTO_DETAIL);
                ActivitySwitchAutoInfo.toChooseBrandActivity(getActivity(), myAuto,
                        AutoInfoContants.AUTO_DETAIL, false);
                imAlertDialog.dismiss();
                getActivity().finish();
            }
        }
    });
}

From source file:cw.kop.autobackground.tutorial.ButtonFragment.java

@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
        @Nullable Bundle savedInstanceState) {

    View view = AppSettings.getTheme().equals(AppSettings.APP_LIGHT_THEME)
            ? inflater.inflate(R.layout.tutorial_button_fragment, container, false)
            : inflater.inflate(R.layout.tutorial_button_fragment_dark, container, false);
    int colorFilterInt = AppSettings.getColorFilterInt(appContext);

    ImageView deleteButton = (ImageView) view.findViewById(R.id.source_delete_button);
    ImageView viewButton = (ImageView) view.findViewById(R.id.source_view_image_button);
    ImageView editButton = (ImageView) view.findViewById(R.id.source_edit_button);

    Drawable deleteDrawable = getResources().getDrawable(R.drawable.ic_delete_white_24dp);
    Drawable viewDrawable = getResources().getDrawable(R.drawable.ic_photo_white_24dp);
    Drawable editDrawable = getResources().getDrawable(R.drawable.ic_edit_white_24dp);

    deleteDrawable.setColorFilter(colorFilterInt, PorterDuff.Mode.MULTIPLY);
    viewDrawable.setColorFilter(colorFilterInt, PorterDuff.Mode.MULTIPLY);
    editDrawable.setColorFilter(colorFilterInt, PorterDuff.Mode.MULTIPLY);

    deleteButton.setImageDrawable(deleteDrawable);
    viewButton.setImageDrawable(viewDrawable);
    editButton.setImageDrawable(editDrawable);

    deleteButton.setOnClickListener(null);
    viewButton.setOnClickListener(null);
    editButton.setOnClickListener(null);

    TextView addTitleText = (TextView) view.findViewById(R.id.add_title_text);
    addTitleText.setTextColor(colorFilterInt);
    addTitleText.setText("Adding new sources");

    TextView addTutorialText = (TextView) view.findViewById(R.id.add_tutorial_text);
    addTutorialText.setTextColor(colorFilterInt);
    addTutorialText.setText("Easily add a new source from a variety of different places.");

    TextView buttonTitleText = (TextView) view.findViewById(R.id.button_title_text);
    buttonTitleText.setTextColor(colorFilterInt);
    buttonTitleText.setText("Source actions");

    TextView buttonTutorialText = (TextView) view.findViewById(R.id.button_tutorial_text);
    buttonTutorialText.setTextColor(colorFilterInt);
    buttonTutorialText.setText("Delete, view, and edit each source.");

    return view;/*from   w  ww .j a  va2 s.c  o  m*/
}

From source file:com.mycompany.popularmovies.DetailActivity.DetailFragment.java

@Override
public void onLoadFinished(Loader<Cursor> cursorLoader, Cursor cursor) {
    if (cursorLoader == mGeneralInfoLoader) {
        if (cursor != null && cursor.moveToFirst()) {
            int columnIndexPosterPath = cursor.getColumnIndex(MovieContract.MovieTable.COLUMN_POSTER_PATH);
            String posterPath = MovieAdapter.POSTER_BASE_URL_W185 + cursor.getString(columnIndexPosterPath);
            Picasso picasso = Picasso.with(getActivity());
            picasso.load(posterPath).into(mPosterImageView);

            int columnIndexTitle = cursor.getColumnIndex(MovieContract.MovieTable.COLUMN_TITLE);
            String title = cursor.getString(columnIndexTitle);
            mTitleTextView.setText(title);

            int columnIndexIsFavorite = cursor.getColumnIndex(MovieContract.MovieTable.COLUMN_FAVORITED);
            int isFavorite = cursor.getInt(columnIndexIsFavorite);
            mHeartImageView/* w  w w. j a va 2  s .c om*/
                    .setImageResource(isFavorite == 1 ? R.drawable.heart_active : R.drawable.heart_inactive);
            mHeartImageView.setOnClickListener(this);

            int columnIndexReleaseDate = cursor.getColumnIndex(MovieContract.MovieTable.COLUMN_RELEASE_DATE);
            String releaseDateText = cursor.getString(columnIndexReleaseDate);
            String releaseYearText = releaseDateText.substring(0, Math.min(releaseDateText.length(), 4));
            mReleaseYearTextView.setText(releaseYearText);

            int columnIndexVoteAverage = cursor.getColumnIndex(MovieContract.MovieTable.COLUMN_VOTE_AVERAGE);
            float vote_average = cursor.getFloat(columnIndexVoteAverage);
            mRatingBar.setRating(vote_average);

            int columnIndexSynopsis = cursor.getColumnIndex(MovieContract.MovieTable.COLUMN_SYNOPSIS);
            mSynopsisTextView.setText(cursor.getString(columnIndexSynopsis));

            // If onCreateOptionsMenu has already happened, we need to update the share intent now.
            if (mShareActionProvider != null) {
                mShareText = title;
                mShareActionProvider.setShareIntent(createShareIntent());
            }
        } else {
            Log.e(LOG_TAG, "Cursor to populate general info was empty or null!");
        }
    } else if (cursorLoader == mTrailerLoader) {
        if (cursor == null || !cursor.moveToFirst()) {
            mTrailerListTitle.setVisibility(View.INVISIBLE);
        } else {
            mTrailerListTitle.setVisibility(View.VISIBLE);
            for (cursor.moveToFirst(); cursor.getPosition() < cursor.getCount(); cursor.moveToNext()) {
                int columnIndexName = cursor.getColumnIndex(MovieContract.TrailersTable.COLUMN_NAME);
                String trailerName = cursor.getString(columnIndexName);

                int columnIndexLanguageCode = cursor
                        .getColumnIndex(MovieContract.TrailersTable.COLUMN_LANGUAGE_CODE);
                String trailerLanguageCode = cursor.getString(columnIndexLanguageCode);

                String trailer_summary = String.format("%s (%s)", trailerName,
                        trailerLanguageCode.toUpperCase());

                int columnIndexSite = cursor.getColumnIndex(MovieContract.TrailersTable.COLUMN_SITE);
                String site = cursor.getString(columnIndexSite);

                int columnIndexKey = cursor.getColumnIndex(MovieContract.TrailersTable.COLUMN_KEY);
                String key = cursor.getString(columnIndexKey);

                String link = null;
                if (site.compareTo("YouTube") == 0) {
                    link = "https://www.youtube.com/watch?v=" + key;
                } else {
                    Log.e(LOG_TAG, "Unsupported site: " + site);
                }

                ImageView trailerThumbnail = (ImageView) mActivity.getLayoutInflater()
                        .inflate(R.layout.detail_fragment_trailer_item, null, false);
                if (site.compareTo("YouTube") == 0) {
                    Picasso picasso = Picasso.with(mActivity);
                    String youtubeThumbnailPath = String.format("http://img.youtube.com/vi/%s/mqdefault.jpg",
                            key);
                    picasso.load(youtubeThumbnailPath).into(trailerThumbnail);
                    trailerThumbnail.setTag(link);
                    trailerThumbnail.setOnClickListener(this);
                }

                mTrailerList.addView(trailerThumbnail);
            }
        }
    } else if (cursorLoader == mReviewLoader) {
        if (cursor == null || !cursor.moveToFirst()) {
            mReviewListTitle.setVisibility(View.INVISIBLE);
        } else {
            mReviewListTitle.setVisibility(View.VISIBLE);
            String colors[] = { "#00BFFF", "#00CED1", "#FF8C00", "#00FA9A", "#9400D3" };
            for (cursor.moveToFirst(); cursor.getPosition() < cursor.getCount(); cursor.moveToNext()) {
                int columnIndexAuthor = cursor.getColumnIndex(MovieContract.ReviewsTable.COLUMN_AUTHOR);
                String author = cursor.getString(columnIndexAuthor);
                String authorAbbreviation = author != null && author.length() >= 1 ? author.substring(0, 1)
                        : "?";

                int columnIndexReviewText = cursor
                        .getColumnIndex(MovieContract.ReviewsTable.COLUMN_REVIEW_TEXT);
                String reviewText = cursor.getString(columnIndexReviewText);

                RelativeLayout review = (RelativeLayout) mActivity.getLayoutInflater()
                        .inflate(R.layout.detail_fragment_review_item, null, false);
                review.setOnClickListener(this);
                review.setTag(TAG_REVIEW_COLLAPSED);

                TextView authorIcon = (TextView) review.findViewById(R.id.author_icon);
                authorIcon.setText(authorAbbreviation);
                int color = Color.parseColor(colors[cursor.getPosition() % colors.length]);
                authorIcon.getBackground().setColorFilter(color, PorterDuff.Mode.MULTIPLY);

                TextView authorFullName = (TextView) review.findViewById(R.id.author_full_name);
                authorFullName.setText(author);

                TextView reviewTextView = (TextView) review.findViewById(R.id.review_text);
                reviewTextView.setText(reviewText);

                mReviewList.addView(review);
            }
        }
    }
}

From source file:edu.berkeley.boinc.attach.SelectionListAdapter.java

@Override
public View getView(int position, View convertView, ViewGroup parent) {

    View v = convertView;/*www .j a v  a2s. c o  m*/

    LayoutInflater vi = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    final ProjectListEntry listItem = entries.get(position);

    v = vi.inflate(R.layout.attach_project_list_layout_listitem, null);
    TextView name = (TextView) v.findViewById(R.id.name);
    TextView description = (TextView) v.findViewById(R.id.description);
    TextView summary = (TextView) v.findViewById(R.id.summary);
    CheckBox cb = (CheckBox) v.findViewById(R.id.cb);
    LinearLayout textWrapper = (LinearLayout) v.findViewById(R.id.text_wrapper);

    if (listItem.am) {
        // element is account manager
        name.setText(activity.getString(R.string.attachproject_acctmgr_header));
        description.setText(activity.getString(R.string.attachproject_acctmgr_list_desc));
        cb.setVisibility(View.GONE);
        summary.setVisibility(View.GONE);
        ImageView button = (ImageView) v.findViewById(R.id.am_button_image);
        button.setVisibility(View.VISIBLE);
        OnClickListener listener = new OnClickListener() {
            @Override
            public void onClick(View v) {
                if (Logging.DEBUG)
                    Log.d(Logging.TAG, "SelectionListAdapter: account manager clicked.");
                AcctMgrFragment dialog = new AcctMgrFragment();
                dialog.setReturnToMainActivity(); // configure, so dialog returns to main activity when finished
                dialog.show(activity.getSupportFragmentManager(),
                        activity.getString(R.string.attachproject_acctmgr_header));
            }
        };
        v.setOnClickListener(listener);
        name.setOnClickListener(listener);
        description.setOnClickListener(listener);
        button.setOnClickListener(listener);
    } else {
        // element is project option
        name.setText(listItem.info.name);
        description.setText(listItem.info.generalArea);
        summary.setText(listItem.info.summary);
        cb.setChecked(listItem.checked);
        cb.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                listItem.checked = !listItem.checked;
            }
        });
        textWrapper.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                if (Logging.DEBUG)
                    Log.d(Logging.TAG,
                            "SelectionListAdapter: onProjectClick open info for: " + listItem.info.name);

                ProjectInfoFragment dialog = ProjectInfoFragment.newInstance(listItem.info);
                dialog.show(activity.getSupportFragmentManager(), "ProjectInfoFragment");
            }
        });

    }
    return v;
}

From source file:com.mobicage.rogerthat.plugins.messaging.FriendsThreadActivity.java

private void configureAvatarOnClickListener(final String friendEmail, final ImageView avatar,
        final boolean isChat) {
    avatar.setOnClickListener(new SafeViewOnClickListener() {
        @Override//from   w  w  w .  j  a  va2 s. co m
        public void safeOnClick(View v) {
            T.UI();
            if (mService.getIdentityStore().getIdentity().getEmail().equals(friendEmail)) {
                Intent intent = new Intent(FriendsThreadActivity.this, ProfileActivity.class);
                startActivity(intent);
            } else if (isChat) {
                final int contactType = mFriendsPlugin.getContactType(friendEmail);
                if ((contactType & FriendsPlugin.FRIEND) == FriendsPlugin.FRIEND
                        && AppConstants.FRIENDS_ENABLED) {
                    mFriendsPlugin.launchDetailActivity(FriendsThreadActivity.this, friendEmail);
                } else {
                    Intent intent = new Intent(FriendsThreadActivity.this, FriendDetailOrInviteActivity.class);
                    intent.putExtra(FriendDetailOrInviteActivity.EMAIL, friendEmail);
                    startActivity(intent);
                }
            } else {
                final int contactType = mFriendsPlugin.getContactType(friendEmail);
                if ((contactType & FriendsPlugin.FRIEND) == FriendsPlugin.FRIEND) {
                    mFriendsPlugin.launchDetailActivity(FriendsThreadActivity.this, friendEmail);
                } else {
                    if ((contactType & FriendsPlugin.NON_FRIEND) == FriendsPlugin.NON_FRIEND) {
                        UIUtils.showNotConnectedToFriendDialog(mService, mFriendsPlugin, friendEmail);
                    }
                }
            }
        }
    });
}

From source file:eu.nubomedia.nubomedia_kurento_health_communicator_android.kc_and_client.ui.activity.ItemListActivity.java

private void showPopup() {
    dialog.setVisibility(View.VISIBLE);
    dialogBackground.setVisibility(View.VISIBLE);

    dialog.startAnimation(myAnimationShowPopup);

    Button create_group = (Button) dialog.findViewById(R.id.create_button);
    create_group.setOnClickListener(new OnClickListener() {

        @Override/*w w w  . j  a  va 2  s  .co  m*/
        public void onClick(View v) {
            if (((EditText) ItemListActivity.this.findViewById(R.id.group_name_text)).getText().toString()
                    .length() == 0) {
                Toast.makeText(ItemListActivity.this, getString(R.string.creating_group_mandatory_name),
                        Toast.LENGTH_SHORT).show();
                return;
            }
            dialog.setVisibility(View.GONE);
            dialogBackground.setVisibility(View.GONE);

            imm.hideSoftInputFromWindow(
                    ((EditText) ItemListActivity.this.findViewById(R.id.group_name_text)).getWindowToken(), 0);
            imm.hideSoftInputFromWindow(
                    ((EditText) ItemListActivity.this.findViewById(R.id.group_phone_text)).getWindowToken(), 0);

            createGroup();
        }
    });

    Button cancel_group = (Button) dialog.findViewById(R.id.cancel_button);
    cancel_group.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            imm.hideSoftInputFromWindow(
                    ((EditText) ItemListActivity.this.findViewById(R.id.group_name_text)).getWindowToken(), 0);
            imm.hideSoftInputFromWindow(
                    ((EditText) ItemListActivity.this.findViewById(R.id.group_phone_text)).getWindowToken(), 0);

            dialog.setVisibility(View.GONE);
            dialogBackground.setVisibility(View.GONE);
            clearPopup();
        }
    });

    ImageView image = (ImageView) dialog.findViewById(R.id.group_image);
    image.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            imm.hideSoftInputFromWindow(((EditText) dialog.findViewById(R.id.group_name_text)).getWindowToken(),
                    0);
            new AsyncTask<Void, Void, Void>() {
                @Override
                protected Void doInBackground(Void... params) {
                    SystemClock.sleep(200);
                    return null;
                }

                @Override
                protected void onPostExecute(Void result) {
                    mQuickAction.show(((ImageView) dialog.findViewById(R.id.group_image)));
                }
            }.execute();
        }
    });

    dialogBackground.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            dialog.setVisibility(View.GONE);
            dialogBackground.setVisibility(View.GONE);
        }
    });
}

From source file:lu.fisch.canze.activities.MainActivity.java

@Override
public boolean onCreateOptionsMenu(final Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.menu_main, menu);

    // get a reference to the bluetooth action button
    bluetoothMenutItem = menu.findItem(R.id.action_bluetooth);
    // and put the right view on it
    bluetoothMenutItem.setActionView(R.layout.animated_menu_item);
    // set the correct initial state
    setBluetoothState(BLUETOOTH_DISCONNECTED);
    // get access to the image view
    ImageView imageView = (ImageView) bluetoothMenutItem.getActionView()
            .findViewById(R.id.animated_menu_item_action);
    // define an action
    imageView.setOnClickListener(new View.OnClickListener() {
        @Override/*from   www  . j av a2 s  .  c  o m*/
        public void onClick(View v) {
            (new Thread(new Runnable() {
                @Override
                public void run() {
                    toast(getStringSingle(R.string.toast_Reconnecting));
                    stopBluetooth();
                    reloadBluetooth();
                }
            })).start();
        }
    });

    return true;
}