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.bt.download.android.gui.adapters.TransferListAdapter.java

private void populatePeerDownload(View view, PeerHttpDownload download) {
    TextView title = findView(view, R.id.view_transfer_list_item_title);
    ProgressBar progress = findView(view, R.id.view_transfer_list_item_progress);
    TextView status = findView(view, R.id.view_transfer_list_item_status);
    TextView speed = findView(view, R.id.view_transfer_list_item_speed);
    TextView size = findView(view, R.id.view_transfer_list_item_size);
    TextView seeds = findView(view, R.id.view_transfer_list_item_seeds);
    TextView peers = findView(view, R.id.view_transfer_list_item_peers);
    ImageView buttonAction = findView(view, R.id.view_transfer_list_item_button_action);

    seeds.setText("");
    peers.setText("");
    title.setText(download.getDisplayName());
    progress.setProgress(download.getProgress());
    status.setText(getStatusFromResId(download.getStatus()));
    speed.setText(UIUtils.getBytesInHuman(download.getDownloadSpeed()) + "/s");
    size.setText(UIUtils.getBytesInHuman(download.getSize()));

    buttonAction.setTag(download);//from  w  w  w  . j av  a  2 s . co m
    buttonAction.setOnClickListener(viewOnClickListener);
}

From source file:com.bt.download.android.gui.adapters.TransferListAdapter.java

private void populateHttpDownload(View view, HttpDownload download) {
    TextView title = findView(view, R.id.view_transfer_list_item_title);
    ProgressBar progress = findView(view, R.id.view_transfer_list_item_progress);
    TextView status = findView(view, R.id.view_transfer_list_item_status);
    TextView speed = findView(view, R.id.view_transfer_list_item_speed);
    TextView size = findView(view, R.id.view_transfer_list_item_size);
    TextView seeds = findView(view, R.id.view_transfer_list_item_seeds);
    TextView peers = findView(view, R.id.view_transfer_list_item_peers);
    ImageView buttonAction = findView(view, R.id.view_transfer_list_item_button_action);

    seeds.setText("");
    peers.setText("");
    title.setText(download.getDisplayName());
    progress.setProgress(download.getProgress());
    status.setText(getStatusFromResId(download.getStatus()));
    speed.setText(UIUtils.getBytesInHuman(download.getDownloadSpeed()) + "/s");
    size.setText(UIUtils.getBytesInHuman(download.getSize()));

    buttonAction.setTag(download);/* w w  w  .java 2 s. co  m*/
    buttonAction.setOnClickListener(viewOnClickListener);
}

From source file:com.bt.download.android.gui.adapters.TransferListAdapter.java

private void populateYouTubeDownload(View view, YouTubeDownload download) {
    TextView title = findView(view, R.id.view_transfer_list_item_title);
    ProgressBar progress = findView(view, R.id.view_transfer_list_item_progress);
    TextView status = findView(view, R.id.view_transfer_list_item_status);
    TextView speed = findView(view, R.id.view_transfer_list_item_speed);
    TextView size = findView(view, R.id.view_transfer_list_item_size);
    TextView seeds = findView(view, R.id.view_transfer_list_item_seeds);
    TextView peers = findView(view, R.id.view_transfer_list_item_peers);
    ImageView buttonAction = findView(view, R.id.view_transfer_list_item_button_action);

    seeds.setText("");
    peers.setText("");
    title.setText(download.getDisplayName());
    progress.setProgress(download.getProgress());
    status.setText(getStatusFromResId(download.getStatus()));
    speed.setText(UIUtils.getBytesInHuman(download.getDownloadSpeed()) + "/s");
    size.setText(UIUtils.getBytesInHuman(download.getSize()));

    buttonAction.setTag(download);/*  www  . jav a  2 s .  com*/
    buttonAction.setOnClickListener(viewOnClickListener);
}

From source file:com.bt.download.android.gui.adapters.TransferListAdapter.java

private void populateSoundcloudDownload(View view, SoundcloudDownload download) {
    TextView title = findView(view, R.id.view_transfer_list_item_title);
    ProgressBar progress = findView(view, R.id.view_transfer_list_item_progress);
    TextView status = findView(view, R.id.view_transfer_list_item_status);
    TextView speed = findView(view, R.id.view_transfer_list_item_speed);
    TextView size = findView(view, R.id.view_transfer_list_item_size);
    TextView seeds = findView(view, R.id.view_transfer_list_item_seeds);
    TextView peers = findView(view, R.id.view_transfer_list_item_peers);
    ImageView buttonAction = findView(view, R.id.view_transfer_list_item_button_action);

    seeds.setText("");
    peers.setText("");
    title.setText(download.getDisplayName());
    progress.setProgress(download.getProgress());
    status.setText(getStatusFromResId(download.getStatus()));
    speed.setText(UIUtils.getBytesInHuman(download.getDownloadSpeed()) + "/s");
    size.setText(UIUtils.getBytesInHuman(download.getSize()));

    buttonAction.setTag(download);//w  ww . j  a va  2s  .c om
    buttonAction.setOnClickListener(viewOnClickListener);
}

From source file:galilei.kelimekavanozu.activity.ThemeChooserActivity.java

private void setUpHistory() {
    final ImageView history = (ImageView) findViewById(R.id.history);
    //        history.setOnClickListener(new View.OnClickListener() {
    //            @Override
    //            public void onClick(View v) {
    //                Crashlytics.log("ThemeChooser: clicked History button");
    //                Answers.getInstance().logCustom(new CustomEvent("clicked history"));
    //                final Intent intent = new Intent(ThemeChooserActivity.this,
    //                        PoemHistoryActivity.class);
    //                intent.putExtra(IS_NEW_POEM, false);
    //                startActivity(intent);
    //            }
    //        });
    history.setOnClickListener(new View.OnClickListener() {
        @Override/*from  ww w  .  jav a2  s .c o m*/
        public void onClick(View v) {
            final Intent intent = new Intent(ThemeChooserActivity.this, Settings.class);
            startActivity(intent);
        }
    });
}

From source file:com.google.samples.apps.iosched.session.SessionDetailFragment.java

/**
 * Determines visibility of a social icon, sets up a click listener to allow the user to
 * navigate to the social network associated with the icon, and sets up a content description
 * for the icon.//w  w  w. jav  a  2 s  .co  m
 */
private void setUpSpeakerSocialIcon(final SessionDetailModel.Speaker speaker, ImageView socialIcon,
        final String socialUrl, String socialNetworkName, final String packageName) {
    if (socialUrl == null || socialUrl.isEmpty()) {
        socialIcon.setVisibility(View.GONE);
    } else {
        socialIcon.setContentDescription(
                getString(R.string.speaker_social_page, socialNetworkName, speaker.getName()));
        socialIcon.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                UIUtils.fireSocialIntent(getActivity(), Uri.parse(socialUrl), packageName);
            }
        });
    }
}

From source file:com.example.angelina.travelapp.map.MapFragment.java

@Override
public void showRouteDetail(final int position) {
    // Remove the route header view,
    ////from ww  w  .j  a v  a  2 s  .c o m
    //since we're replacing it with a different header

    removeRouteHeaderView();
    // State  and stage flags
    mCurrentPosition = position;
    mShowingRouteDetail = true;

    // Hide action bar
    final ActionBar ab = ((AppCompatActivity) getActivity()).getSupportActionBar();
    if (ab != null) {
        ab.hide();
    }

    // Display route detail header
    final LayoutInflater inflater = (LayoutInflater) getActivity()
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    final LinearLayout.LayoutParams routeDetailLayout = new LinearLayout.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);

    if (mRouteHeaderDetail == null) {
        mRouteHeaderDetail = (LinearLayout) inflater.inflate(R.layout.route_detail_header, null);
        TextView title = (TextView) mRouteHeaderDetail.findViewById(R.id.route_txt_detail);
        title.setText("Route Detail");

        mRouteHeaderDetail.setBackgroundColor(Color.WHITE);
        mMapView.addView(mRouteHeaderDetail, routeDetailLayout);
        mMapView.requestLayout();

        // Attach a listener to the back arrow
        ImageView imageBtn = (ImageView) mRouteHeaderDetail.findViewById(R.id.btnDetailHeaderClose);
        imageBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                // Navigate back to directions list
                mShowingRouteDetail = false;
                ((MapActivity) getActivity()).showDirections(mRouteDirections);
            }
        });
    }

    // Display arrows to scroll through directions
    if (mSegmentNavigator == null) {
        mSegmentNavigator = (LinearLayout) inflater.inflate(R.layout.navigation_arrows, null);
        final FrameLayout navigatorLayout = (FrameLayout) getActivity()
                .findViewById(R.id.map_fragment_container);
        FrameLayout.LayoutParams frameLayoutParams = new FrameLayout.LayoutParams(
                ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT,
                Gravity.BOTTOM | Gravity.END);
        frameLayoutParams.setMargins(0, 0, 0, 80);
        navigatorLayout.addView(mSegmentNavigator, frameLayoutParams);
        navigatorLayout.requestLayout();
        // Add button click listeners
        Button btnPrev = (Button) getActivity().findViewById(R.id.btnBack);

        btnPrev.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (mCurrentPosition > 0) {
                    populateViewWithRouteDetail(mRouteDirections.get(mCurrentPosition - 1));
                    mCurrentPosition = mCurrentPosition - 1;
                }

            }
        });
        Button btnNext = (Button) getActivity().findViewById(R.id.btnNext);
        btnNext.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (mCurrentPosition < mRouteDirections.size() - 1) {
                    populateViewWithRouteDetail(mRouteDirections.get(mCurrentPosition + 1));
                    mCurrentPosition = mCurrentPosition + 1;
                }

            }
        });
    }

    // Populate with directions
    DirectionManeuver maneuver = mRouteDirections.get(position);
    populateViewWithRouteDetail(maneuver);

}

From source file:gr.scify.newsum.ui.ViewActivity.java

protected void initGestures() {
    GestureOverlayView gestureOverlayView = new GestureOverlayView(this);
    View inflate = getLayoutInflater().inflate(R.layout.view, null);
    gestureOverlayView.addView(inflate);
    gestureOverlayView.addOnGesturePerformedListener(this);
    gestureOverlayView.setGestureColor(Color.TRANSPARENT);
    gestureOverlayView.setUncertainGestureColor(Color.TRANSPARENT);
    gestureLib = GestureLibraries.fromRawResource(this, R.raw.gestures);
    if (!gestureLib.load()) {
        finish();/*from   w  w w . j a  v a2 s . c  o  m*/
    }
    setContentView(gestureOverlayView);
    getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.custom_title);

    ImageView title_image = (ImageView) findViewById(R.id.title_image);
    title_image.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent browse = new Intent(Intent.ACTION_VIEW, Uri.parse(getResources().getString(R.string.scify)));
            startActivity(browse);
        }

    });

    // Allow links to be followed into browser
    final TextView tx = (TextView) findViewById(R.id.textView1);
    tx.setMovementMethod(LinkMovementMethod.getInstance());
}

From source file:com.google.android.apps.forscience.whistlepunk.EditNoteDialog.java

@Override
public AlertDialog onCreateDialog(Bundle savedInstanceState) {
    mLabel = getArguments().getParcelable(KEY_SAVED_LABEL);
    String timeText = getArguments().getString(KEY_SAVED_TIME_TEXT, "");
    String timeTextContentDescription = getArguments().getString(KEY_SAVED_TIME_TEXT_DESCRIPTION);
    mTimestamp = getArguments().getLong(KEY_SAVED_TIMESTAMP);
    try {/*from  w  ww .  j av a 2s . c  om*/
        mSelectedValue = GoosciLabelValue.LabelValue.parseFrom(getArguments().getByteArray(KEY_SELECTED_VALUE));
    } catch (InvalidProtocolBufferNanoException ex) {
        Log.wtf(TAG, "Couldn't parse label value");
    }
    AlertDialog.Builder alertDialog = new AlertDialog.Builder(getActivity());

    LinearLayout rootView = (LinearLayout) LayoutInflater.from(getActivity())
            .inflate(R.layout.run_review_label_edit, null);
    alertDialog.setView(rootView);

    ImageView imageView = (ImageView) rootView.findViewById(R.id.picture_note_preview_image);
    final EditText editText = (EditText) rootView.findViewById(R.id.edit_note_text);
    TextView autoTextView = (TextView) rootView.findViewById(R.id.auto_note_text);

    // Use mSelectedValue to load content, because the user may have changed the value since
    // it was stored in the label. Note that picture labels can't be edited at this time,
    // but in the future this will apply to picture labels as well.
    if (mLabel instanceof PictureLabel) {
        imageView.setVisibility(View.VISIBLE);
        autoTextView.setVisibility(View.GONE);
        editText.setText(PictureLabel.getCaption(mSelectedValue));
        editText.setHint(R.string.picture_note_caption_hint);
        Glide.with(getActivity()).load(PictureLabel.getFilePath(mSelectedValue)).into(imageView);
        imageView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                PictureUtils.launchExternalViewer(getActivity(), (PictureLabel.getFilePath(mSelectedValue)));
            }
        });
    } else if (mLabel instanceof TextLabel) {
        imageView.setVisibility(View.GONE);
        autoTextView.setVisibility(View.GONE);
        editText.setText(TextLabel.getText(mSelectedValue));
    } else if (mLabel instanceof SensorTriggerLabel) {
        imageView.setVisibility(View.GONE);
        autoTextView.setVisibility(View.VISIBLE);
        editText.setText(SensorTriggerLabel.getCustomText(mSelectedValue));
        String autoText = SensorTriggerLabel.getAutogenText(mSelectedValue);
        TriggerHelper.populateAutoTextViews(autoTextView, autoText, R.drawable.ic_label_black_24dp,
                getResources());
    }

    alertDialog.setPositiveButton(R.string.action_save, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            mLabel.setTimestamp(mTimestamp);
            if (mLabel instanceof TextLabel) {
                ((TextLabel) mLabel).setText(editText.getText().toString());
            } else if (mLabel instanceof PictureLabel) {
                ((PictureLabel) mLabel).setCaption(editText.getText().toString());
            } else if (mLabel instanceof SensorTriggerLabel) {
                ((SensorTriggerLabel) mLabel).setCustomText(editText.getText().toString());
            }
            getDataController().editLabel(mLabel,
                    ((EditNoteDialogListener) getParentFragment()).onLabelEdit(mLabel));
        }
    });
    alertDialog.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.cancel();
        }
    });
    alertDialog.setCancelable(true);

    TextView timeTextView = (TextView) rootView.findViewById(R.id.edit_note_time);
    timeTextView.setText(timeText);
    timeTextView.setContentDescription(timeTextContentDescription);
    if (labelBelongsToRun() && mLabel.canEditTimestamp()) {
        timeTextView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                GoosciLabelValue.LabelValue value = new GoosciLabelValue.LabelValue();
                if (mLabel instanceof PictureLabel) {
                    // Captions can be edited, but the picture path cannot be edited at this
                    // time.
                    PictureLabel.populateStorageValue(value, ((PictureLabel) mLabel).getFilePath(),
                            editText.getText().toString());
                    ((EditNoteDialogListener) getParentFragment()).onEditNoteTimestampClicked(mLabel, value,
                            mTimestamp);
                } else if (mLabel instanceof TextLabel) {
                    TextLabel.populateStorageValue(value, editText.getText().toString());
                    ((EditNoteDialogListener) getParentFragment()).onEditNoteTimestampClicked(mLabel, value,
                            mTimestamp);
                }
            }
        });
    } else if (labelBelongsToRun()) {
        Drawable lockDrawable = getResources().getDrawable(R.drawable.ic_lock_black_18dp);
        DrawableCompat.setTint(lockDrawable, getResources().getColor(R.color.text_color_light_grey));
        // There is already a start drawable. Use it again.
        Drawable[] drawables = timeTextView.getCompoundDrawablesRelative();
        timeTextView.setCompoundDrawablesRelativeWithIntrinsicBounds(drawables[0], null, lockDrawable, null);
    }

    AlertDialog dialog = alertDialog.create();
    if (mLabel instanceof TextLabel || mLabel instanceof SensorTriggerLabel) {
        dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
    }
    return dialog;
}

From source file:cn.flyrise.android3.test.graphic.DrawerArrowSample.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.home_view);/*from w  w  w. j  a  v  a  2  s  .  c  o  m*/

    final DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    final ImageView imageView = (ImageView) findViewById(R.id.drawer_indicator);
    final Resources resources = getResources();

    drawerArrowDrawable = new DrawerArrowDrawable(resources);
    drawerArrowDrawable.setStrokeColor(resources.getColor(R.color.light_gray));
    imageView.setImageDrawable(drawerArrowDrawable);

    drawer.setDrawerListener(new DrawerLayout.SimpleDrawerListener() {
        @Override
        public void onDrawerSlide(View drawerView, float slideOffset) {
            Log.e("Test", "slideOffset==" + slideOffset);
            offset = slideOffset;

            // Sometimes slideOffset ends up so close to but not quite 1 or 0.
            if (slideOffset >= .995) {
                flipped = true;
                drawerArrowDrawable.setFlip(flipped);
            } else if (slideOffset <= .005) {
                flipped = false;
                drawerArrowDrawable.setFlip(flipped);
            }

            drawerArrowDrawable.setParameter(offset);
        }
    });

    imageView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (drawer.isDrawerVisible(START)) {
                drawer.closeDrawer(START);
            } else {
                drawer.openDrawer(START);
            }
        }
    });

    final TextView styleButton = (TextView) findViewById(R.id.indicator_style);
    styleButton.setOnClickListener(new View.OnClickListener() {
        boolean rounded = false;

        @Override
        public void onClick(View v) {
            styleButton.setText(rounded //
                    ? resources.getString(R.string.rounded) //
                    : resources.getString(R.string.squared));

            rounded = !rounded;

            drawerArrowDrawable = new DrawerArrowDrawable(resources, rounded);
            drawerArrowDrawable.setParameter(offset);
            drawerArrowDrawable.setFlip(flipped);
            drawerArrowDrawable.setStrokeColor(resources.getColor(R.color.light_gray));

            imageView.setImageDrawable(drawerArrowDrawable);
        }
    });
}