Example usage for android.widget ImageView setTag

List of usage examples for android.widget ImageView setTag

Introduction

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

Prototype

public void setTag(final Object tag) 

Source Link

Document

Sets the tag associated with this view.

Usage

From source file:galilei.kelimekavanozu.view.ImageAdapter.java

@Override
public Object instantiateItem(ViewGroup container, final int position) {
    if (context.get() != null) {
        final int drawableId = theme.getImageList().get(position + 1);
        final ImageView view = new ImageView(context.get());
        view.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.MATCH_PARENT));
        view.setContentDescription(context.get().getResources().getString(R.string.content_desc_poempic));
        view.setScaleType(ImageView.ScaleType.CENTER_CROP);
        view.setAdjustViewBounds(true);/*from   w  w w.j  a v a 2  s  . c  o m*/
        view.setTag(drawableId);
        container.addView(view, 0);
        view.post(new Runnable() {
            @Override
            public void run() {
                ImageLoader.getImageLoader().load(drawableId, view);
            }
        });
        return view;
    }
    return null;
}

From source file:org.digitalcampus.oppia.widgets.FeedbackWidget.java

public void showQuestion() {
    QuizQuestion q = null;//from  w w w  .jav  a 2 s.  c o  m
    try {
        q = this.feedback.getCurrentQuestion();
    } catch (InvalidQuizException e) {
        Toast.makeText(super.getActivity(), super.getActivity().getString(R.string.error_quiz_no_questions),
                Toast.LENGTH_LONG).show();
        e.printStackTrace();
        return;
    }
    qText.setVisibility(View.VISIBLE);
    // convert in case has any html special chars
    qText.setText(Html.fromHtml(
            q.getTitle(prefs.getString(PrefsActivity.PREF_LANGUAGE, Locale.getDefault().getLanguage()))
                    .toString()));

    if (q.getProp("image") == null) {
        questionImage.setVisibility(View.GONE);
    } else {
        String fileUrl = course.getLocation() + q.getProp("image");
        // File file = new File(fileUrl);
        Bitmap myBitmap = BitmapFactory.decodeFile(fileUrl);
        File file = new File(fileUrl);
        ImageView iv = (ImageView) getView().findViewById(R.id.question_image_image);
        iv.setImageBitmap(myBitmap);
        iv.setTag(file);
    }

    if (q instanceof MultiChoice) {
        qw = new MultiChoiceWidget(super.getActivity(), getView(), container);
    } else if (q instanceof Essay) {
        qw = new EssayWidget(super.getActivity(), getView(), container);
    } else if (q instanceof ShortAnswer) {
        qw = new ShortAnswerWidget(super.getActivity(), getView(), container);
    } else if (q instanceof Numerical) {
        qw = new NumericalWidget(super.getActivity(), getView(), container);
    } else if (q instanceof MultiSelect) {
        qw = new MultiSelectWidget(super.getActivity(), getView(), container);
    } else {
        return;
    }
    qw.setQuestionResponses(q.getResponseOptions(), q.getUserResponses());
    this.setProgress();
    this.setNav();
}

From source file:me.albinmathew.celluloid.ui.fragments.MovieDetailFragment.java

public void showTrailers(@NonNull List<VideoResponseBean> trailers) {
    if (trailers.isEmpty()) {
        mTrailerLabel.setVisibility(View.GONE);
        mTrailersView.setVisibility(View.GONE);
        mTrailersScrollView.setVisibility(View.GONE);

    } else {/*from   w  w w .ja v  a2 s  .co m*/
        mTrailerLabel.setVisibility(View.VISIBLE);
        mTrailersView.setVisibility(View.VISIBLE);
        mTrailersScrollView.setVisibility(View.VISIBLE);
        mTrailersView.removeAllViews();
        if (mContext != null && isAdded()) {
            LayoutInflater inflater = getActivity().getLayoutInflater();
            Picasso picasso = Picasso.with(getContext());
            shareVideos();
            for (VideoResponseBean trailer : trailers) {
                ViewGroup thumbContainer = (ViewGroup) inflater.inflate(R.layout.video, mTrailersView, false);
                ImageView thumbView = (ImageView) thumbContainer.findViewById(R.id.video_thumb);
                thumbView.setTag(CommonUtil.getUrl(trailer));
                thumbView.requestLayout();
                thumbView.setOnClickListener(this);
                picasso.load(CommonUtil.getThumbnailUrl(trailer))
                        .resizeDimen(R.dimen.video_width, R.dimen.video_height).centerCrop()
                        .placeholder(R.color.cardview_shadow_start_color).into(thumbView);
                mTrailersView.addView(thumbContainer);
            }
        }
    }
}

From source file:com.google.android.apps.santatracker.dasherdancer.CharacterAdapter.java

@Override
public Object instantiateItem(ViewGroup container, int position) {
    ImageView view = null;

    if (position < mCharacters.length) {
        if (mViews.get(position) != null) {
            view = mViews.get(position);
        } else {/*from   w  w  w  .  j a  v  a2  s. c om*/
            view = new FrameAnimationView(container.getContext());
            view.setScaleType(ImageView.ScaleType.CENTER_CROP);
            //Load the first idle frame.
            view.setBackgroundResource(mBackgrounds[position]);
            view.setTag(position);
            mViews.put(position, view);
        }

        LayoutParams lp = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
        container.addView(view, lp);
    }

    return view;
}

From source file:org.xbmc.kore.ui.sections.video.TVShowProgressFragment.java

/**
 * Display next episode list//from  ww w  . j a v  a  2  s.co m
 *
 * @param cursor Cursor with the data
 */
@TargetApi(21)
private void displayNextEpisodeList(Cursor cursor) {
    TextView nextEpisodeTitle = (TextView) getActivity().findViewById(R.id.next_episode_title);
    GridLayout nextEpisodeList = (GridLayout) getActivity().findViewById(R.id.next_episode_list);

    if (cursor.moveToFirst()) {
        nextEpisodeTitle.setVisibility(View.VISIBLE);
        nextEpisodeList.setVisibility(View.VISIBLE);

        HostManager hostManager = HostManager.getInstance(getActivity());

        View.OnClickListener episodeClickListener = new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                AbstractInfoFragment.DataHolder vh = (AbstractInfoFragment.DataHolder) v.getTag();
                listenerActivity.onNextEpisodeSelected(itemId, vh);
            }
        };

        // Get the art dimensions
        Resources resources = getActivity().getResources();
        int artWidth = (int) (resources.getDimension(R.dimen.detail_poster_width_square)
                / UIUtils.IMAGE_RESIZE_FACTOR);
        int artHeight = (int) (resources.getDimension(R.dimen.detail_poster_height_square)
                / UIUtils.IMAGE_RESIZE_FACTOR);

        nextEpisodeList.removeAllViews();
        do {
            int episodeId = cursor.getInt(NextEpisodesListQuery.EPISODEID);
            String title = cursor.getString(NextEpisodesListQuery.TITLE);
            String seasonEpisode = String.format(getString(R.string.season_episode),
                    cursor.getInt(NextEpisodesListQuery.SEASON), cursor.getInt(NextEpisodesListQuery.EPISODE));
            int runtime = cursor.getInt(NextEpisodesListQuery.RUNTIME) / 60;
            String duration = runtime > 0
                    ? String.format(getString(R.string.minutes_abbrev), String.valueOf(runtime)) + "  |  "
                            + cursor.getString(NextEpisodesListQuery.FIRSTAIRED)
                    : cursor.getString(NextEpisodesListQuery.FIRSTAIRED);
            String thumbnail = cursor.getString(NextEpisodesListQuery.THUMBNAIL);

            View episodeView = LayoutInflater.from(getActivity()).inflate(R.layout.list_item_next_episode,
                    nextEpisodeList, false);

            ImageView artView = (ImageView) episodeView.findViewById(R.id.art);
            TextView titleView = (TextView) episodeView.findViewById(R.id.title);
            TextView detailsView = (TextView) episodeView.findViewById(R.id.details);
            TextView durationView = (TextView) episodeView.findViewById(R.id.duration);

            titleView.setText(title);
            detailsView.setText(seasonEpisode);
            durationView.setText(duration);

            UIUtils.loadImageWithCharacterAvatar(getActivity(), hostManager, thumbnail, title, artView,
                    artWidth, artHeight);

            AbstractInfoFragment.DataHolder vh = new AbstractInfoFragment.DataHolder(episodeId);
            vh.setTitle(title);
            vh.setUndertitle(seasonEpisode);
            episodeView.setTag(vh);
            episodeView.setOnClickListener(episodeClickListener);

            // For the popupmenu
            ImageView contextMenu = (ImageView) episodeView.findViewById(R.id.list_context_menu);
            contextMenu.setTag(episodeId);
            contextMenu.setOnClickListener(contextlistItemMenuClickListener);

            nextEpisodeList.addView(episodeView);
        } while (cursor.moveToNext());
    } else {
        // No episodes, hide views
        nextEpisodeTitle.setVisibility(View.GONE);
        nextEpisodeList.setVisibility(View.GONE);
    }
}

From source file:eu.pellerito.popularmoviesproject2.fragment.DetailFragment.java

private void viewTrailer(@NonNull List<MovieTrailer> trailer) {

    if ((mContext != null) && (trailerArrayList != null)) {

        LayoutInflater layoutInflater = (LayoutInflater) mContext
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);

        final String[] strKey = new String[1];

        for (int i = 0; i < trailer.size(); i++) {

            strKey[0] = trailer.get(i).getKey();

            View view = layoutInflater.inflate(R.layout.layout_trailer, layoutWrapper, false);

            LinearLayout linearLayoutWrapper = ButterKnife.findById(view, R.id.trailer_wrapper);

            LinearLayout.LayoutParams layoutParamsImage = new LinearLayout.LayoutParams(
                    ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);

            layoutParamsImage.setMargins(8, 8, 8, 8);

            if (trailerTitle != null) {
                separatorTrailer.setVisibility(View.VISIBLE);
                trailerTitle.setVisibility(View.VISIBLE);
            }/* w w w . ja  v a  2  s  .c om*/

            final ImageView image = new ImageView(mContext);
            image.setTag(trailer.get(i).getName());
            image.setImageDrawable(ContextCompat.getDrawable(mContext, R.drawable.youtube));

            image.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    playTrailer(strKey[0]);
                }
            });

            LinearLayout.LayoutParams layoutParamsTextView = new LinearLayout.LayoutParams(
                    LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);

            layoutParamsTextView.setMargins(8, 8, 8, 8);

            TextView textView = new TextView(mContext);
            textView.setText(trailer.get(i).getName());
            textView.setGravity(Gravity.CENTER_VERTICAL);
            textView.setLines(2);

            linearLayoutWrapper.addView(image, layoutParamsImage);
            linearLayoutWrapper.addView(textView, layoutParamsTextView);

            if (layoutBaseTrailer != null) {
                layoutBaseTrailer.addView(linearLayoutWrapper);
            }

        }
    }
}

From source file:org.chaos.fx.cnbeta.details.DetailsFragment.java

@Override
public void addImageToContent(String link) {
    final ImageView view = (ImageView) getActivity().getLayoutInflater()
            .inflate(R.layout.article_content_img_item, mContentLayout, false);
    mContentLayout.addView(view);// ww w .  j a v  a2s .  c  o  m
    view.setTag(link);

    final ImageListener l = new ImageListener(view, link);
    view.setOnClickListener(l);

    RequestCreator r = Picasso.get().load(link).placeholder(R.drawable.default_content_image_loading);
    if (PreferenceHelper.getInstance().inSafeDataMode()) {
        l.setLoadCacheForFirst(true);
        r.networkPolicy(NetworkPolicy.OFFLINE);
    }
    r.into(view, l);
}

From source file:org.digitalcampus.oppia.widgets.ResourceWidget.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    LinearLayout ll = (LinearLayout) getView().findViewById(R.id.widget_resource_object);
    String fileUrl = course.getLocation() + activity
            .getLocation(prefs.getString(PrefsActivity.PREF_LANGUAGE, Locale.getDefault().getLanguage()));
    // show description if any
    String desc = activity//from   w  w  w. j a va2 s.  co  m
            .getDescription(prefs.getString(PrefsActivity.PREF_LANGUAGE, Locale.getDefault().getLanguage()));

    TextView descTV = (TextView) getView().findViewById(R.id.widget_resource_description);
    if (desc.length() > 0) {
        descTV.setText(desc);
    } else {
        descTV.setVisibility(View.GONE);
    }

    File file = new File(fileUrl);
    setResourceFileName(file.getName());
    OnResourceClickListener orcl = new OnResourceClickListener(super.getActivity(), activity.getMimeType());
    // show image files
    if (activity.getMimeType().equals("image/jpeg") || activity.getMimeType().equals("image/png")) {
        ImageView iv = new ImageView(super.getActivity());
        Bitmap myBitmap = BitmapFactory.decodeFile(fileUrl);
        iv.setImageBitmap(myBitmap);
        LayoutParams lp = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
        ll.addView(iv, lp);
        iv.setTag(file);
        iv.setOnClickListener(orcl);
    } else {
        // add button to open other filetypes in whatever app the user has installed as default for that filetype
        Button btn = new Button(super.getActivity());
        btn.setText(super.getActivity().getString(R.string.widget_resource_open_file, file.getName()));
        btn.setTextAppearance(super.getActivity(), R.style.ButtonText);
        ll.addView(btn);
        btn.setTag(file);
        btn.setOnClickListener(orcl);
    }
}

From source file:itkach.aard2.SettingsListAdapter.java

private View getUserStylesView(View convertView, final ViewGroup parent) {
    View view;/*from w  w w.  j a  v  a  2 s  .  c o m*/
    LayoutInflater inflater = (LayoutInflater) parent.getContext()
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    if (convertView != null) {
        view = convertView;
    } else {
        this.userStyleData = userStylePrefs.getAll();
        this.userStyleNames = new ArrayList<String>(this.userStyleData.keySet());
        Collections.sort(this.userStyleNames);

        view = inflater.inflate(R.layout.settings_user_styles_item, parent, false);
        ImageView btnAdd = (ImageView) view.findViewById(R.id.setting_btn_add_user_style);
        btnAdd.setImageDrawable(FontIconDrawable.inflate(context, R.xml.ic_list_add));
        btnAdd.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent();
                intent.setAction(Intent.ACTION_GET_CONTENT);
                intent.setType("text/*");
                Intent chooser = Intent.createChooser(intent, "Select CSS file");
                try {
                    fragment.startActivityForResult(chooser, CSS_SELECT_REQUEST);
                } catch (ActivityNotFoundException e) {
                    Log.d(TAG, "Not activity to get content", e);
                    Toast.makeText(context, R.string.msg_no_activity_to_get_content, Toast.LENGTH_LONG).show();
                }
            }
        });
    }
    ;

    View emptyView = view.findViewById(R.id.setting_user_styles_empty);
    emptyView.setVisibility(userStyleNames.size() == 0 ? View.VISIBLE : View.GONE);

    LinearLayout userStyleListLayout = (LinearLayout) view.findViewById(R.id.setting_user_styles_list);
    userStyleListLayout.removeAllViews();
    for (int i = 0; i < userStyleNames.size(); i++) {
        View styleItemView = inflater.inflate(R.layout.user_styles_list_item, parent, false);
        ImageView btnDelete = (ImageView) styleItemView.findViewById(R.id.user_styles_list_btn_delete);
        btnDelete.setImageDrawable(FontIconDrawable.inflate(context, R.xml.ic_list_trash));
        btnDelete.setOnClickListener(onDeleteUserStyle);

        String name = userStyleNames.get(i);

        btnDelete.setTag(name);

        TextView nameView = (TextView) styleItemView.findViewById(R.id.user_styles_list_name);
        nameView.setText(name);

        userStyleListLayout.addView(styleItemView);
    }

    return view;
}

From source file:org.zywx.wbpalmstar.plugin.uexscrawl.PhotoScrawlActivity.java

private View getColorImageView(int color) {
    final ImageView imageView = new ImageView(this);
    int width = EUExUtil.dipToPixels(32);
    LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(width, width);
    int margin = EUExUtil.dipToPixels(4);
    lp.leftMargin = margin;//  ww  w.  j  a v  a  2 s.  co  m
    lp.rightMargin = margin;
    imageView.setLayoutParams(lp);
    imageView.setTag(color);
    GradientDrawable colorDrawable = new GradientDrawable();
    colorDrawable.setColor(color);
    colorDrawable.setCornerRadius(8);
    if (Build.VERSION.SDK_INT < 16) {
        imageView.setBackgroundDrawable(colorDrawable);
    } else {
        imageView.setBackground(colorDrawable);
    }
    imageView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mCurrnetColor = (int) imageView.getTag();
            mScrawlImageView.setPaintColor(mCurrnetColor);
            mPreviewView.setColor(mCurrnetColor);
        }
    });
    return imageView;
}