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:joshuatee.wx.ImagesFragment.java

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

    View view = inflater.inflate(R.layout.fragment_images, container, false);

    DisplayMetrics dm = new DisplayMetrics();
    getActivity().getWindowManager().getDefaultDisplay().getMetrics(dm);

    ImageView iv_1 = (ImageView) view.findViewById(R.id.iv_1);
    iv_1.setOnClickListener(this);
    ImageView iv_2 = (ImageView) view.findViewById(R.id.iv_2);
    iv_2.setOnClickListener(this);
    ImageView iv_3 = (ImageView) view.findViewById(R.id.iv_3);
    iv_3.setOnClickListener(this);
    ImageView iv_4 = (ImageView) view.findViewById(R.id.iv_4);
    iv_4.setOnClickListener(this);
    ImageView iv_5 = (ImageView) view.findViewById(R.id.iv_5);
    iv_5.setOnClickListener(this);
    ImageView iv_6 = (ImageView) view.findViewById(R.id.iv_6);
    iv_6.setOnClickListener(this);

    ImageView iv_7 = (ImageView) view.findViewById(R.id.iv_7);
    ImageView iv_8 = (ImageView) view.findViewById(R.id.iv_8);
    ImageView iv_9 = (ImageView) view.findViewById(R.id.iv_9);
    ImageView iv_10 = (ImageView) view.findViewById(R.id.iv_10);
    ImageView iv_11 = (ImageView) view.findViewById(R.id.iv_11);
    ImageView iv_12 = (ImageView) view.findViewById(R.id.iv_12);
    ImageView iv_13 = (ImageView) view.findViewById(R.id.iv_13);
    ImageView iv_14 = (ImageView) view.findViewById(R.id.iv_14);
    ImageView iv_15 = (ImageView) view.findViewById(R.id.iv_15);
    ImageView iv_16 = (ImageView) view.findViewById(R.id.iv_16);
    ImageView iv_17 = (ImageView) view.findViewById(R.id.iv_17);
    ImageView iv_18 = (ImageView) view.findViewById(R.id.iv_18);

    iv_7.setOnClickListener(this);
    iv_8.setOnClickListener(this);
    iv_9.setOnClickListener(this);
    iv_10.setOnClickListener(this);
    iv_11.setOnClickListener(this);
    iv_12.setOnClickListener(this);
    iv_13.setOnClickListener(this);
    iv_14.setOnClickListener(this);
    iv_15.setOnClickListener(this);
    iv_16.setOnClickListener(this);
    iv_17.setOnClickListener(this);
    iv_18.setOnClickListener(this);

    LayoutParams params_iv = null;//from   w ww .  j  a  v a 2 s.  c  o m
    UtilityImg.ResizeViewSetImgTile(dm, UtilityImg.LoadBM(getActivity(), R.drawable.usa_map), iv_1, 3,
            params_iv);
    UtilityImg.ResizeViewSetImgTile(dm, UtilityImg.LoadBM(getActivity(), R.drawable.k2), iv_2, 3, params_iv);
    UtilityImg.ResizeViewSetImgTile(dm, UtilityImg.LoadBM(getActivity(), R.drawable.k1), iv_3, 3, params_iv);
    UtilityImg.ResizeViewSetImgTile(dm, UtilityImg.LoadBM(getActivity(), R.drawable.northwest_map), iv_4, 3,
            params_iv);
    UtilityImg.ResizeViewSetImgTile(dm, UtilityImg.LoadBM(getActivity(), R.drawable.northcentral_map), iv_5, 3,
            params_iv);
    UtilityImg.ResizeViewSetImgTile(dm, UtilityImg.LoadBM(getActivity(), R.drawable.northeast_map), iv_6, 3,
            params_iv);
    UtilityImg.ResizeViewSetImgTile(dm, UtilityImg.LoadBM(getActivity(), R.drawable.southwest_map), iv_7, 3,
            params_iv);
    UtilityImg.ResizeViewSetImgTile(dm, UtilityImg.LoadBM(getActivity(), R.drawable.southcentral_map), iv_8, 3,
            params_iv);
    UtilityImg.ResizeViewSetImgTile(dm, UtilityImg.LoadBM(getActivity(), R.drawable.southeast_map), iv_9, 3,
            params_iv);
    UtilityImg.ResizeViewSetImgTile(dm, UtilityImg.LoadBM(getActivity(), R.drawable.alaska_map), iv_10, 3,
            params_iv);
    UtilityImg.ResizeViewSetImgTile(dm, UtilityImg.LoadBM(getActivity(), R.drawable.hawaii_map), iv_11, 3,
            params_iv);
    UtilityImg.ResizeViewSetImgTile(dm, UtilityImg.LoadBM(getActivity(), R.drawable.canada_map), iv_12, 3,
            params_iv);
    UtilityImg.ResizeViewSetImgTile(dm, UtilityImg.LoadBM(getActivity(), R.drawable.n_pacific_map), iv_13, 3,
            params_iv);
    UtilityImg.ResizeViewSetImgTile(dm, UtilityImg.LoadBM(getActivity(), R.drawable.polar_map), iv_14, 3,
            params_iv);
    UtilityImg.ResizeViewSetImgTile(dm, UtilityImg.LoadBM(getActivity(), R.drawable.n_atlantic_map), iv_15, 3,
            params_iv);
    UtilityImg.ResizeViewSetImgTile(dm, UtilityImg.LoadBM(getActivity(), R.drawable.s_pacific_map), iv_16, 3,
            params_iv);
    UtilityImg.ResizeViewSetImgTile(dm, UtilityImg.LoadBM(getActivity(), R.drawable.hemi_map), iv_17, 3,
            params_iv);
    UtilityImg.ResizeViewSetImgTile(dm, UtilityImg.LoadBM(getActivity(), R.drawable.s_atlantic_map), iv_18, 3,
            params_iv);

    //iv_1.setImageResource(R.drawable.usa_map);

    spinner1 = (Spinner) view.findViewById(R.id.spinner1);

    ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(getActivity(),
            android.R.layout.simple_spinner_item, cod_label);
    dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner1.setAdapter(dataAdapter);
    spinner1.setOnItemSelectedListener(this);

    return view;
}

From source file:com.givon.anhao.activity.ContactlistFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    inputMethodManager = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
    listView = (ListView) getView().findViewById(R.id.list);
    sidebar = (Sidebar) getView().findViewById(R.id.sidebar);
    sidebar.setListView(listView);//from  w w  w. ja  va2  s .  c  om
    contactList = new ArrayList<UserBean>();
    // ?contactlist
    getContactList();
    // adapter
    adapter = new ContactAdapter(getActivity(), R.layout.row_contact, contactList, sidebar);
    listView.setAdapter(adapter);
    listView.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            String username = adapter.getItem(position).getUsername();
            if (Constant.NEW_FRIENDS_USERNAME.equals(username)) {
                // ?
                UserBean user = AnhaoApplication.getInstance().getContactList()
                        .get(Constant.NEW_FRIENDS_USERNAME);
                user.setUnreadMsgCount(0);
                startActivity(new Intent(getActivity(), NewFriendsMsgActivity.class));
            } else if (Constant.GROUP_USERNAME.equals(username)) {
                // ??
                startActivity(new Intent(getActivity(), GroupsActivity.class));
            } else {
                // demo??
                startActivity(new Intent(getActivity(), ChatActivity.class).putExtra("userId",
                        adapter.getItem(position).getUsername()));
            }
        }
    });
    listView.setOnTouchListener(new OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            // ??
            if (getActivity().getWindow()
                    .getAttributes().softInputMode != WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN) {
                if (getActivity().getCurrentFocus() != null)
                    inputMethodManager.hideSoftInputFromWindow(getActivity().getCurrentFocus().getWindowToken(),
                            InputMethodManager.HIDE_NOT_ALWAYS);
            }
            return false;
        }
    });

    ImageView addContactView = (ImageView) getView().findViewById(R.id.iv_new_contact);
    // ?
    addContactView.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            startActivity(new Intent(getActivity(), AddContactActivity.class));
        }
    });
    registerForContextMenu(listView);

}

From source file:com.quran.labs.androidquran.widgets.IconPageIndicator.java

public void notifyDataSetChanged() {
    mIconsLayout.removeAllViews();/*  w w w .j a v  a 2s  .c  om*/
    IconPagerAdapter iconAdapter = (IconPagerAdapter) mViewPager.getAdapter();
    int count = iconAdapter.getCount();
    for (int i = 0; i < count; i++) {
        ImageView view = new ImageView(getContext(), null, R.attr.actionButtonStyle);
        view.setImageResource(iconAdapter.getIconResId(i));
        view.setTag(i);
        view.setOnClickListener(this);
        mIconsLayout.addView(view, new LayoutParams(WRAP_CONTENT, MATCH_PARENT));
    }
    if (mSelectedIndex > count) {
        mSelectedIndex = count - 1;
    }
    setCurrentItem(mSelectedIndex);
    requestLayout();
}

From source file:com.QuarkLabs.BTCeClient.adapters.OrdersAdapter.java

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    View v = null;/*from   www .j  a v  a  2  s . c o m*/
    TextView timestamp;
    final JSONObject dataToDisplay = getItem(position);
    TextView orderID;
    TextView type;
    TextView amount;
    TextView pair;
    TextView rate;
    switch (mListType) {
    case Transactions:
        if (convertView == null) {
            v = mInflater.inflate(R.layout.fragment_trans_history_item, parent, false);
        } else {
            v = convertView;
        }
        TextView description = (TextView) v.findViewById(R.id.TransHistoryDesc);
        timestamp = (TextView) v.findViewById(R.id.TransHistoryTimestamp);
        amount = (TextView) v.findViewById(R.id.TransHistoryAmount);
        try {
            Calendar calendar = Calendar.getInstance(TimeZone.getDefault(), Locale.getDefault());
            description.setText(dataToDisplay.getString("desc"));
            calendar.setTimeInMillis(Long.parseLong(dataToDisplay.getString("timestamp")) * 1000L);
            timestamp.setText(mDateFormat.format(calendar.getTime()));
            amount.setText(dataToDisplay.getString("amount") + dataToDisplay.getString("currency"));

        } catch (JSONException e) {
            e.printStackTrace();
        }
        break;
    case Trades:
        if (convertView == null) {
            v = mInflater.inflate(R.layout.fragment_trade_history_item, parent, false);
        } else {
            v = convertView;
        }
        pair = (TextView) v.findViewById(R.id.TradeHistoryPair);
        rate = (TextView) v.findViewById(R.id.TradeHistoryRate);
        amount = (TextView) v.findViewById(R.id.TradeHistoryAmount);
        type = (TextView) v.findViewById(R.id.TradeHistoryType);
        orderID = (TextView) v.findViewById(R.id.TradeHistoryOrderID);
        timestamp = (TextView) v.findViewById(R.id.TradeHistoryTimestamp);

        try {
            String pairValue = dataToDisplay.getString("pair");
            Calendar calendar = Calendar.getInstance(TimeZone.getDefault(), Locale.getDefault());
            orderID.setText(dataToDisplay.getString("order_id"));
            calendar.setTimeInMillis(Long.parseLong(dataToDisplay.getString("timestamp")) * 1000L);
            timestamp.setText(mDateFormat.format(calendar.getTime()));
            pair.setText(pairValue.replace("_", "/").toUpperCase(Locale.US));
            rate.setText(dataToDisplay.getString("rate") + " " + pairValue.substring(4).toUpperCase(Locale.US));
            amount.setText(
                    dataToDisplay.getString("amount") + " " + pairValue.substring(0, 3).toUpperCase(Locale.US));
            type.setText(dataToDisplay.getString("type"));
        } catch (JSONException e) {
            e.printStackTrace();
        }
        break;
    case ActiveOrders:
        if (convertView == null) {
            v = mInflater.inflate(R.layout.fragment_active_orders_item, parent, false);
        } else {
            v = convertView;
        }

        pair = (TextView) v.findViewById(R.id.ActiveOrderPair);
        type = (TextView) v.findViewById(R.id.ActiveOrderType);
        amount = (TextView) v.findViewById(R.id.ActiveOrderAmount);
        rate = (TextView) v.findViewById(R.id.ActiveOrderRate);
        timestamp = (TextView) v.findViewById(R.id.ActiveOrderTimestamp);
        orderID = (TextView) v.findViewById(R.id.ActiveOrderID);
        ImageView remove = (ImageView) v.findViewById(R.id.removeOrder);
        remove.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                final int order_id = dataToDisplay.optInt("id");
                new AlertDialog.Builder(mContext).setTitle("Remove confirmation")
                        .setPositiveButton("Yes", new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                new CancelActiveOrder().execute(order_id);
                            }
                        }).setNegativeButton("No", null).setMessage("Are you sure you want to delete OrderID="
                                + dataToDisplay.optString("id") + "?")
                        .show();
            }
        });

        try {
            String pairValue = dataToDisplay.getString("pair");
            Calendar calendar = Calendar.getInstance(TimeZone.getDefault(), Locale.getDefault());
            pair.setText(pairValue.replace("_", "/").toUpperCase(Locale.US));
            type.setText(dataToDisplay.getString("type"));
            amount.setText(
                    dataToDisplay.getString("amount") + " " + pairValue.substring(0, 3).toUpperCase(Locale.US));
            rate.setText(dataToDisplay.getString("rate") + " " + pairValue.substring(4).toUpperCase(Locale.US));
            calendar.setTimeInMillis(Long.parseLong(dataToDisplay.getString("timestamp_created")) * 1000L);
            timestamp.setText(mDateFormat.format(calendar.getTime()));
            orderID.setText(String.valueOf(mData.get(position).optInt("id")));
        } catch (JSONException e) {
            e.printStackTrace();
        }
    default:
        break;
    }

    return v;
}

From source file:app.view.chat.ContactListFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    inputMethodManager = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
    listView = (ListView) getView().findViewById(R.id.list);
    sideBar = (SideBar) getView().findViewById(R.id.sidebar);
    sideBar.setListView(listView);//  w ww  . ja v a2  s .  c o  m
    contactList = new ArrayList<User>();
    // ?contactlist
    getContactList();
    // adapter
    adapter = new ContactAdapter(getActivity(), R.layout.row_contact, contactList, sideBar);
    listView.setAdapter(adapter);
    listView.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            String username = adapter.getItem(position).getUsername();
            if (Constant.NEW_FRIENDS_USERNAME.equals(username)) {
                // ?
                User user = DemoApplication.getInstance().getContactList().get(Constant.NEW_FRIENDS_USERNAME);
                user.setUnreadMsgCount(0);
                startActivity(new Intent(getActivity(), NewFriendsMsgActivity.class));
            } else if (Constant.GROUP_USERNAME.equals(username)) {
                // ??
                startActivity(new Intent(getActivity(), GroupsActivity.class));
            } else {
                // demo??
                startActivity(new Intent(getActivity(), ChatActivity.class).putExtra("userId",
                        adapter.getItem(position).getUsername()));
            }
        }
    });
    listView.setOnTouchListener(new OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            // ??
            if (getActivity().getWindow()
                    .getAttributes().softInputMode != WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN) {
                if (getActivity().getCurrentFocus() != null)
                    inputMethodManager.hideSoftInputFromWindow(getActivity().getCurrentFocus().getWindowToken(),
                            InputMethodManager.HIDE_NOT_ALWAYS);
            }
            return false;
        }
    });

    ImageView addContactView = (ImageView) getView().findViewById(R.id.iv_new_contact);
    // ?
    addContactView.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            startActivity(new Intent(getActivity(), AddContactActivity.class));
        }
    });
    registerForContextMenu(listView);

}

From source file:net.potterpcs.recipebook.RecipeViewer.java

@SuppressWarnings("deprecation")
@Override//from   ww  w . j  a  va  2 s  .  com
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.recipeviewer);

    app = (RecipeBook) getApplication();
    data = app.getData();
    preferences = PreferenceManager.getDefaultSharedPreferences(this);
    photoPref = preferences.getBoolean(getResources().getString(R.string.prefphotokey), true);
    dirPhotoPref = preferences.getBoolean(getResources().getString(R.string.prefdirphotokey), true);

    // Fill in the UI
    rvname = (TextView) findViewById(R.id.rvname);
    rvcreator = (TextView) findViewById(R.id.rvcreator);
    rvserving = (TextView) findViewById(R.id.rvserving);
    rvtime = (TextView) findViewById(R.id.rvtime);
    rvrating = (RatingBar) findViewById(R.id.rvrating);

    lvingredients = (GridView) findViewById(R.id.ingredients);
    lvdirections = (ListView) findViewById(R.id.directions);

    rid = Long.parseLong(getIntent().getData().getLastPathSegment());

    RecipeData.Recipe r = data.getSingleRecipeObject(rid);

    rvname.setText(r.name);
    rvcreator.setText(r.creator);
    rvserving.setText(Integer.toString(r.serving));
    rvtime.setText(DateUtils.formatElapsedTime(r.time));
    rvrating.setRating(r.rating);

    photoUri = r.photo;
    if (photoPref && photoUri != null && !photoUri.equals("")) {
        rvphoto = (FrameLayout) findViewById(R.id.photofragment);
        ImageView iv = new ImageView(this);
        setOrDownloadImage(iv, photoUri);
        iv.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
                PhotoDialog pd = PhotoDialog.newInstance(photoUri);
                pd.show(ft, "dialog");
            }
        });
        rvphoto.addView(iv);
    }

    directionsAdapter = new SimpleCursorAdapter(this, R.layout.recipedirectionrow, null, DIRECTIONS_FIELDS,
            DIRECTIONS_IDS, 0);
    directionsAdapter.setViewBinder(new DirectionViewBinder(this));

    lvdirections.setAdapter(directionsAdapter);
    lvdirections.setDividerHeight(0);

    ingredientsAdapter = new SimpleCursorAdapter(this, android.R.layout.simple_list_item_1, null,
            INGREDIENTS_FIELDS, INGREDIENTS_IDS, 0);
    lvingredients.setAdapter(ingredientsAdapter);

    // Set up sharing intent
    shareIntent = ShareCompat.IntentBuilder.from(this).setSubject(r.name).setText(r.toText(this))
            .setType("text/plain");
}

From source file:com.flipzu.flipzu.Profile.java

@Override
public void onUserReceived(FlipUser user) {
    this.mUser = user;
    ((TextView) findViewById(R.id.username)).setText(user.getUsername());
    ((TextView) findViewById(R.id.full_name)).setText(user.getFullname());
    ImageView bg = (ImageView) findViewById(R.id.user_avatar);
    bg.setOnClickListener(new OnClickListener() {

        @Override/* w  w w .  j  a va  2  s . c om*/
        public void onClick(View v) {
            Intent i = new Intent(Profile.this, ProfileImage.class);
            i.putExtra("imageUrl", mUser.getAvatarUrl());
            startActivity(i);
        }
    });
    UrlImageViewHelper.setUrlDrawable(bg, user.getAvatarUrl(), R.drawable.icon_sq);
    frag.setUser(user);
    if (mMenu != null) {
        MenuItem item = mMenu.findItem(MENU_ITEM_FOLLOW);

        if (user.isFollowing()) {
            item.setIcon(R.drawable.friends_active);
            item.setTitle(R.string.unfollow);
        } else {
            item.setIcon(R.drawable.friends);
            item.setTitle(R.string.follow);
        }
    }
}

From source file:com.dolbik.pavel.translater.fragments.translate.TranslateFragment.java

@Nullable
@Override/*ww  w  .ja v a  2 s  .co  m*/
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
        @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_translate, container, false);

    Toolbar toolbar = (Toolbar) view.findViewById(R.id.toolbar);
    ((AppCompatActivity) getActivity()).setSupportActionBar(toolbar);
    progressBar = (ProgressBar) toolbar.findViewById(R.id.progressBar);
    toolbarView = (LinearLayout) toolbar.findViewById(R.id.toolbar_view);
    fromDirection = (TextView) toolbar.findViewById(R.id.from);
    toDirection = (TextView) toolbar.findViewById(R.id.to);
    ImageView swap = (ImageView) toolbar.findViewById(R.id.swap);

    fromDirection.setOnClickListener(this);
    toDirection.setOnClickListener(this);
    swap.setOnClickListener(this);

    coordinatorLayout = (CoordinatorLayout) view.findViewById(R.id.coordinatorLayout);
    translateContainer = (RelativeLayout) view.findViewById(R.id.translate_container);
    translate = (EditText) view.findViewById(R.id.translate);

    translate.setOnFocusChangeListener((v, hasFocus) -> {
        if (hasFocus) {
            translateContainer.setBackground(
                    ContextCompat.getDrawable(getContext(), R.drawable.translate_container_focus_shape));
        } else {
            translateContainer.setBackground(
                    ContextCompat.getDrawable(getContext(), R.drawable.translate_container_shape));
        }
    });

    translateSbs = RxTextView.textChanges(translate).debounce(1000, TimeUnit.MILLISECONDS)
            .map(charSequence -> charSequence.toString().replaceAll("[\r\n]+", "\r").trim())
            .observeOn(AndroidSchedulers.mainThread()).subscribe(s -> presenter.translateText(s, false));

    license = (TextView) view.findViewById(R.id.license);
    clear = (ImageView) view.findViewById(R.id.clear);
    clear.setOnClickListener(this);

    resultPrg = (ProgressBar) view.findViewById(R.id.resultPrg);
    resultTranslate = (TextView) view.findViewById(R.id.resultTranslate);
    resultError = (TextView) view.findViewById(R.id.resultError);
    favorite = (ImageView) view.findViewById(R.id.favorite);
    favorite.setOnClickListener(this);

    return view;
}

From source file:com.linkedin.android.eventsapp.ProfileActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_profile);

    Bundle extras = getIntent() != null ? getIntent().getExtras() : new Bundle();
    final Person person = extras.getParcelable("person");
    final Activity currentActivity = this;
    final ActionBar bar = getActionBar();
    View viewActionBar = getLayoutInflater().inflate(R.layout.layout_action_bar, null);

    ImageView backView = (ImageView) viewActionBar.findViewById(R.id.actionbar_left);
    backView.setImageResource(R.drawable.arrow_left);
    backView.setVisibility(View.VISIBLE);
    backView.setClickable(true);//from   www . j  av a2 s  .  c  o  m
    backView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            currentActivity.finish();
        }
    });

    ActionBar.LayoutParams params = new ActionBar.LayoutParams(ActionBar.LayoutParams.WRAP_CONTENT,
            ActionBar.LayoutParams.MATCH_PARENT);
    bar.setCustomView(viewActionBar, params);
    bar.setDisplayShowCustomEnabled(true);
    bar.setDisplayShowTitleEnabled(false);
    bar.setIcon(new ColorDrawable(Color.TRANSPARENT));
    bar.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#F15153")));

    TextView attendeeNameView = (TextView) findViewById(R.id.attendeeName);
    attendeeNameView.setText(person.getFirstName() + " " + person.getLastName());

    final ImageView attendeeImageView = (ImageView) findViewById(R.id.attendeeImage);
    final TextView attendeeHeadlineView = (TextView) findViewById(R.id.attendeeHeadline);
    final TextView attendeeLocationView = (TextView) findViewById(R.id.attendeeLocation);

    boolean isAccessTokenValid = LISessionManager.getInstance(currentActivity).getSession().isValid();
    if (isAccessTokenValid) {
        String url = Constants.personByIdBaseUrl + person.getLinkedinId() + Constants.personProjection;
        APIHelper.getInstance(currentActivity).getRequest(currentActivity, url, new ApiListener() {
            @Override
            public void onApiSuccess(ApiResponse apiResponse) {
                try {
                    JSONObject s = apiResponse.getResponseDataAsJson();
                    String headline = s.has("headline") ? s.getString("headline") : "";
                    String pictureUrl = s.has("pictureUrl") ? s.getString("pictureUrl") : null;
                    JSONObject location = s.getJSONObject("location");
                    String locationName = location != null && location.has("name") ? location.getString("name")
                            : "";

                    attendeeHeadlineView.setText(headline);
                    attendeeLocationView.setText(locationName);
                    if (pictureUrl != null) {
                        new FetchImageTask(attendeeImageView).execute(pictureUrl);
                    } else {
                        attendeeImageView.setImageResource(R.drawable.ghost_person);
                    }
                } catch (JSONException e) {

                }

            }

            @Override
            public void onApiError(LIApiError apiError) {

            }
        });

        ViewStub viewOnLIStub = (ViewStub) findViewById(R.id.viewOnLIStub);
        View viewOnLI = viewOnLIStub.inflate();
        Button viewOnLIButton = (Button) viewOnLI.findViewById(R.id.viewOnLinkedInButton);
        viewOnLIButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                DeepLinkHelper.getInstance().openOtherProfile(currentActivity, person.getLinkedinId(),
                        new DeepLinkListener() {
                            @Override
                            public void onDeepLinkSuccess() {

                            }

                            @Override
                            public void onDeepLinkError(LIDeepLinkError error) {

                            }
                        });
            }
        });
    } else {
        attendeeImageView.setImageResource(R.drawable.ghost_person);
    }
}

From source file:com.github.pockethub.ui.comment.CommentListAdapter.java

protected void updateComment(final GithubComment comment) {
    imageGetter.bind(textView(0), comment.body, comment.id);
    avatars.bind(imageView(3), comment.user);

    setText(1, comment.user.login);/*  w ww  .ja v  a  2  s .  co m*/
    setText(2, TimeUtils.getRelativeTime(comment.updated_at));

    final boolean canEdit = (isOwner || comment.user.login.equals(userName)) && editCommentListener != null;

    final boolean canDelete = (isOwner || comment.user.login.equals(userName)) && deleteCommentListener != null;

    final ImageView ivMore = view(4);

    if (!canEdit && !canDelete)
        ivMore.setVisibility(View.INVISIBLE);
    else
        ivMore.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                showMorePopup(ivMore, comment, canEdit, canDelete);
            }
        });
}