Java Code Examples for android.widget.ImageView.setContentDescription()

The following are Jave code examples for showing how to use setContentDescription() of the android.widget.ImageView class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: LaunchEnr   File: PopupPopulator.java   View Source Code Vote up 7 votes
public static void initializeSystemShortcut(Context context, View view, SystemShortcut info) {
    if (view instanceof DeepShortcutView) {
        // Expanded system shortcut, with both icon and text shown on white background.
        final DeepShortcutView shortcutView = (DeepShortcutView) view;
        shortcutView.getIconView().setBackground(info.getIcon(context,
                android.R.attr.textColorTertiary));
        shortcutView.getBubbleText().setText(info.getLabel(context));
    } else if (view instanceof ImageView) {
        // Only the system shortcut icon shows on a gray background header.
        final ImageView shortcutIcon = (ImageView) view;
        shortcutIcon.setImageDrawable(info.getIcon(context,
                android.R.attr.textColorHint));
        shortcutIcon.setContentDescription(info.getLabel(context));
    }
    view.setTag(info);
}
 
Example 2
Project: MiPushFramework   File: EntityHeaderController.java   View Source Code Vote up 7 votes
/**
 * Done mutating entity header, rebinds everything (optionally skip rebinding buttons).
 */
public View done(AppCompatActivity activity, boolean rebindActions) {
    styleActionBar(activity);
    ImageView iconView = mHeader.findViewById(R.id.entity_header_icon);
    if (iconView != null) {
        iconView.setImageDrawable(mIcon);
        iconView.setContentDescription(mIconContentDescription);
    }
    setText(R.id.entity_header_title, mLabel);
    setText(R.id.entity_header_summary, mSummary);

    if (rebindActions) {
        bindHeaderButtons();
    }

    return mHeader;
}
 
Example 3
Project: Pilem   File: MovieDetailFragment.java   View Source Code Vote up 7 votes
private void setUpBackdrop(View view) {
    Context context = view.getContext();

    ImageView imgBackdrop = (ImageView) view.findViewById(R.id.iv_movie_backdrop);
    View viewOverlay = view.findViewById(R.id.view_backdrop_overlay);
    TextView tvTitle = (TextView) view.findViewById(R.id.tv_movie_detail_title);

    Picasso.with(context)
            .load(R.mipmap.civil_war_backdrop)
            .transform(new GrayscaleTransformation(Picasso.with(context)))
            .into(imgBackdrop);

    imgBackdrop.setContentDescription(mTitle);
    viewOverlay.setAlpha((float) 0.8);
}
 
Example 4
Project: iosched-reader   File: SessionDetailFragment.java   View Source Code Vote up 7 votes
/**
 * 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.
 */
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
                );
            }
        });
    }
}
 
Example 5
Project: EsperantoRadio   File: PagerSlidingTabStrip.java   View Source Code Vote up 6 votes
private void addIconTabBådeTekstOgBillede(final int position, int resId, String url, String title) {
  FrameLayout tabfl = new FrameLayout(getContext());
  ImageView tabi = new ImageView(getContext());
  tabi.setContentDescription(title);
  //Log.d(title+" "+resId + " Kanallogo URL="+url);
  if (resId==0) {
    Picasso.with(tabi.getContext())
            .load(url).placeholder(null)
            .into(tabi);

    tabi.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
    tabi.setAdjustViewBounds(true);
    tabi.setVisibility(View.GONE);
  } else {
    tabi.setImageResource(resId);
    tabi.setVisibility(View.INVISIBLE);
  }
  TextView tabt = new TextView(getContext());
  tabt.setText(title);
  tabt.setTypeface(App.skrift_gibson);
  tabt.setGravity(Gravity.CENTER);
  tabt.setSingleLine();

  tabfl.addView(tabi);
  tabfl.addView(tabt);

  LayoutParams lp = (LayoutParams) tabi.getLayoutParams();
  lp.gravity=Gravity.CENTER;
  lp.width=lp.height=ViewGroup.LayoutParams.MATCH_PARENT;
  lp = (LayoutParams) tabt.getLayoutParams();
  lp.width=lp.height=ViewGroup.LayoutParams.MATCH_PARENT;
  lp.gravity=Gravity.CENTER;

  addTab(position, tabfl);
}
 
Example 6
Project: Brevent   File: DonateTask.java   View Source Code Vote up 6 votes
@Override
protected void onProgressUpdate(DonateActivity.DonateItem... values) {
    if (mReference.get() != null) {
        DonateActivity.DonateItem item = values[0];
        ImageView donate = item.imageView;
        donate.setContentDescription(item.label);
        donate.setImageDrawable(item.icon);
        donate.setClickable(true);
        donate.setVisibility(View.VISIBLE);
    }
}
 
Example 7
Project: microbit   File: PairingActivity.java   View Source Code Vote up 6 votes
/**
 * Sets a clicked cell on/off.
 *
 * @param image An image of a clicked cell.
 * @param pos   Position of a clicked cell.
 * @return True, if cell is on and false otherwise.
 */
private boolean toggleLED(ImageView image, int pos) {
    boolean isOn;
    //Toast.makeText(this, "Pos :" +  pos, Toast.LENGTH_SHORT).show();
    int state = (Integer) image.getTag(R.id.ledState);
    if(state != 1) {
        DEVICE_CODE_ARRAY[pos] = 1;
        image.setBackground(getApplication().getResources().getDrawable(R.drawable.red_white_led_btn));
        image.setTag(R.id.ledState, 1);
        isOn = true;

    } else {
        DEVICE_CODE_ARRAY[pos] = 0;
        image.setBackground(getApplication().getResources().getDrawable(R.drawable.white_red_led_btn));
        image.setTag(R.id.ledState, 0);
        isOn = false;
        // Update the code to consider the still ON LED below the toggled one
        if(pos < 20) {
            DEVICE_CODE_ARRAY[pos + 5] = 1;
        }
    }

    image.setSelected(false);
    int position = (Integer) image.getTag(R.id.position);
    image.setContentDescription("" + position + getLEDStatus(pos));
    return isOn;
}
 
Example 8
Project: AOSP-Kayboard-7.1.2   File: EmojiPalettesView.java   View Source Code Vote up 6 votes
private void addTab(final TabHost host, final int categoryId) {
    final String tabId = EmojiCategory.getCategoryName(categoryId, 0 /* categoryPageId */);
    final TabHost.TabSpec tspec = host.newTabSpec(tabId);
    tspec.setContent(R.id.emoji_keyboard_dummy);
    final ImageView iconView = (ImageView)LayoutInflater.from(getContext()).inflate(
            R.layout.emoji_keyboard_tab_icon, null);
    // TODO: Replace background color with its own setting rather than using the
    //       category page indicator background as a workaround.
    iconView.setBackgroundColor(mCategoryPageIndicatorBackground);
    iconView.setImageResource(mEmojiCategory.getCategoryTabIcon(categoryId));
    iconView.setContentDescription(mEmojiCategory.getAccessibilityDescription(categoryId));
    tspec.setIndicator(iconView);
    host.addTab(tspec);
}
 
Example 9
Project: android-AutofillFramework   File: SettingsActivity.java   View Source Code Vote up 6 votes
private void setupSettingsButton(int containerId, int labelId, int imageViewId,
        final View.OnClickListener onClickListener) {
    ViewGroup container = findViewById(containerId);
    TextView buttonLabel = container.findViewById(labelId);
    String buttonLabelText = buttonLabel.getText().toString();
    ImageView imageView = container.findViewById(imageViewId);
    imageView.setContentDescription(buttonLabelText);
    container.setOnClickListener(onClickListener);
}
 
Example 10
Project: quiz_helper   File: BigBangBottom.java   View Source Code Vote up 5 votes
private void initSubViews() {
    Context context = getContext();


    mDragSelect=new ImageView(context);
    mDragSelect.setImageResource(R.drawable.ic_drag_select_36dp_n);
    mDragSelect.setOnClickListener(this);
    mDragSelect.setContentDescription(getContext().getString(R.string.app_name));

    mDrag=new ImageView(context);
    mDrag.setImageResource(R.drawable.ic_sort_white_36dp);
    mDrag.setOnClickListener(this);
    mDrag.setContentDescription(getContext().getString(R.string.app_name));


    mType=new ImageView(context);
    mType.setImageResource(R.drawable.bigbang_action_cloud);
    mType.setOnClickListener(this);
    mType.setContentDescription(getContext().getString(R.string.app_name));

    mSelectOther=new ImageView(context);
    mSelectOther.setImageResource(R.drawable.bigbang_action_select_other);
    mSelectOther.setOnClickListener(this);
    mSelectOther.setContentDescription(getContext().getString(R.string.app_name));

    mSymbol=new ImageView(context);
    mSymbol.setImageResource(R.drawable.bigbang_action_symbol);
    mSymbol.setOnClickListener(this);
    mSymbol.setContentDescription(getContext().getString(R.string.app_name));

    mSection=new ImageView(context);
    mSection.setImageResource(R.drawable.bigbang_action_enter);
    mSection.setOnClickListener(this);
    mSection.setContentDescription(getContext().getString(R.string.app_name));

    addView(mDragSelect, createLayoutParams());
    addView(mDrag, createLayoutParams());
    addView(mType, createLayoutParams());
    addView(mSelectOther, createLayoutParams());
    addView(mSection, createLayoutParams());
    addView(mSymbol, createLayoutParams());

    setWillNotDraw(false);

    mActionGap = (int) ViewUtil.dp2px(5);
    mContentPadding = (int) ViewUtil.dp2px(10);
}
 
Example 11
Project: quiz_helper   File: BigBangHeader.java   View Source Code Vote up 5 votes
private void initSubViews() {
        Context context = getContext();

        mBorder = ContextCompat.getDrawable(context, R.drawable.bigbang_action_bar_bg);
        mBorder.setCallback(this);

        mSearch = new ImageView(context);
        mSearch.setImageResource(R.drawable.bigbang_action_search);
        mSearch.setOnClickListener(this);
        mSearch.setContentDescription(getContext().getString(R.string.app_name));
        mShare = new ImageView(context);
        mShare.setImageResource(R.drawable.bigbang_action_share);
        mShare.setOnClickListener(this);
        mShare.setContentDescription(getContext().getString(R.string.app_name));
        mCopy = new ImageView(context);
        mCopy.setImageResource(R.drawable.bigbang_action_copy);
        mCopy.setOnClickListener(this);
        mCopy.setContentDescription(getContext().getString(R.string.app_name));

//        mDrag=new ImageView(context);
//        mDrag.setImageResource(R.drawable.ic_sort_white_36dp);
//        mDrag.setOnClickListener(this);

        mTrans = new ImageView(context);
        mTrans.setImageResource(R.drawable.ic_compare_arrows_white_36dp);
        mTrans.setOnClickListener(this);
        mTrans.setContentDescription(getContext().getString(R.string.app_name));

//        mSelectAll=new ImageView(context);
//        mSelectAll.setImageResource(R.drawable.bigbang_action_select_all);
//        mSelectAll.setOnClickListener(this);
//
//        mSelectOther=new ImageView(context);
//        mSelectOther.setImageResource(R.drawable.bigbang_action_select_other);
//        mSelectOther.setOnClickListener(this);


        mClose = new ImageView(context);
        mClose.setImageResource(R.drawable.ic_close_capture);
        mClose.setOnClickListener(this);
        mClose.setContentDescription(getContext().getString(R.string.app_name));

        addView(mSearch, createLayoutParams());
        addView(mShare, createLayoutParams());
        addView(mCopy, createLayoutParams());
        addView(mTrans, createLayoutParams());
        addView(mClose, createLayoutParams());

//        addView(mDrag, createLayoutParams());
//        addView(mSelectAll, createLayoutParams());
//        addView(mSelectOther, createLayoutParams());

//        mSearch.setVisibility(VISIBLE);
//        mShare.setVisibility(VISIBLE);
//        mTrans.setVisibility(VISIBLE);
//        mSelectAll.setVisibility(GONE);
//        mSelectOther.setVisibility(GONE);

        setWillNotDraw(false);

        mActionGap = (int) ViewUtil.dp2px(5);
        mContentPadding = (int) ViewUtil.dp2px(10);
    }
 
Example 12
Project: ankihelper   File: BigBangHeader.java   View Source Code Vote up 5 votes
private void initSubViews() {
        Context context = getContext();

        mBorder = ContextCompat.getDrawable(context, R.drawable.bigbang_action_bar_bg);
        mBorder.setCallback(this);

        mSearch = new ImageView(context);
        mSearch.setImageResource(R.drawable.bigbang_action_search);
        mSearch.setOnClickListener(this);
        mSearch.setContentDescription(getContext().getString(R.string.app_name));
        mShare = new ImageView(context);
        mShare.setImageResource(R.drawable.bigbang_action_share);
        mShare.setOnClickListener(this);
        mShare.setContentDescription(getContext().getString(R.string.app_name));
        mCopy = new ImageView(context);
        mCopy.setImageResource(R.drawable.bigbang_action_copy);
        mCopy.setOnClickListener(this);
        mCopy.setContentDescription(getContext().getString(R.string.app_name));

//        mDrag=new ImageView(context);
//        mDrag.setImageResource(R.drawable.ic_sort_white_36dp);
//        mDrag.setOnClickListener(this);

        mTrans = new ImageView(context);
        mTrans.setImageResource(R.drawable.ic_compare_arrows_white_36dp);
        mTrans.setOnClickListener(this);
        mTrans.setContentDescription(getContext().getString(R.string.app_name));

//        mSelectAll=new ImageView(context);
//        mSelectAll.setImageResource(R.drawable.bigbang_action_select_all);
//        mSelectAll.setOnClickListener(this);
//
//        mSelectOther=new ImageView(context);
//        mSelectOther.setImageResource(R.drawable.bigbang_action_select_other);
//        mSelectOther.setOnClickListener(this);


        mClose = new ImageView(context);
        mClose.setImageResource(R.drawable.ic_close_capture);
        mClose.setOnClickListener(this);
        mClose.setContentDescription(getContext().getString(R.string.app_name));

        addView(mSearch, createLayoutParams());
        addView(mShare, createLayoutParams());
        addView(mCopy, createLayoutParams());
        addView(mTrans, createLayoutParams());
        addView(mClose, createLayoutParams());

//        addView(mDrag, createLayoutParams());
//        addView(mSelectAll, createLayoutParams());
//        addView(mSelectOther, createLayoutParams());

//        mSearch.setVisibility(VISIBLE);
//        mShare.setVisibility(VISIBLE);
//        mTrans.setVisibility(VISIBLE);
//        mSelectAll.setVisibility(GONE);
//        mSelectOther.setVisibility(GONE);

        setWillNotDraw(false);

        mActionGap = (int) ViewUtil.dp2px(5);
        mContentPadding = (int) ViewUtil.dp2px(10);
    }
 
Example 13
Project: Bailan   File: AppIntroduceFragment.java   View Source Code Vote up 5 votes
@Override
protected View cretaeSuccessView() {
    View view = UIUtils.inflate(R.layout.fragment_app_introduction);
    ButterKnife.bind(this, view);

    /*应用截图数据*/
    for (int i = 0; i < mIntroductionBean.getImageCompressList().size(); i++) {
        String url = mIntroductionBean.getImageCompressList().get(i);
        View screenView = View.inflate(getContext(), R.layout.appdetail_item_screen_image, null);
        ImageView screenImageView = (ImageView) screenView.findViewById(R.id.appdetail_screen_img_imageview);
        //设置图片描述(一般用户是看不到的)
        screenImageView.setContentDescription(screenImageView.getResources().getString(R.string.appdetail_screenshot));
        //设置图片的放大模式
        screenImageView.setScaleType(ImageView.ScaleType.FIT_XY);
        screenView.setOnClickListener(this);
        screenView.setTag(i);
        Glide.with(UIUtils.getContext()).load(url).into(screenImageView);
        app_detail_gallery_container.addView(screenView);
    }

    /*应用信息描述*/
    appInfoTariff.setText(mIntroductionBean.getAppInfoBean().getTariffDesc());
    appInfoSize.setText(Formatter.formatFileSize(getContext(), Long.parseLong(mIntroductionBean.getAppInfoBean().getSize())));
    appInfoDate.setText(mIntroductionBean.getAppInfoBean().getReleaseDate());
    appInfoVersion.setText(mIntroductionBean.getAppInfoBean().getVersion());
    appInfoDeveloper.setText(mIntroductionBean.getAppInfoBean().getDeveloper());

    for (int i = 0; i < mIntroductionBean.getAppDetailInfoBeanList().size(); i++) {
        FoldingTextView foldingTextView = new FoldingTextView(getContext());
        foldingTextView.setTitle(mIntroductionBean.getAppDetailInfoBeanList().get(i).getTitle());
        foldingTextView.setContent(mIntroductionBean.getAppDetailInfoBeanList().get(i).getBody());
        appInfoDes.addView(foldingTextView);
    }

    //应用标签数据
    List<String> tagList = mIntroductionBean.getTagList();
    for (int i = 0; i < tagList.size(); i++) {
        View labView = UIUtils.inflate(R.layout.appdetail_item_label_item);
        TextView tv = (TextView) labView.findViewById(R.id.appdetail_label_content_textview);
        tv.setText(tagList.get(i));
        flowLayout.addView(labView);
    }

    return view;
}
 
Example 14
Project: Quran   File: TranslationsAdapter.java   View Source Code Vote up 5 votes
@Override
public void onBindViewHolder(TranslationViewHolder holder, int position) {
  TranslationRowData rowItem = translations.get(position);
  switch (holder.getItemViewType()) {
    case R.layout.translation_row:
      TranslationItem item = (TranslationItem) rowItem;
      holder.getTranslationTitle().setText(item.name());
      if (TextUtils.isEmpty(item.translation.translatorNameLocalized)) {
        holder.getTranslationInfo().setText(item.translation.translator);
      } else {
        holder.getTranslationInfo().setText(item.translation.translatorNameLocalized);
      }

      ImageView leftImage = holder.getLeftImage();
      ImageView rightImage = holder.getRightImage();

      if (item.exists()) {
        if (item.needsUpgrade()) {
          leftImage.setImageResource(R.drawable.ic_download);
          leftImage.setVisibility(View.VISIBLE);
          holder.getTranslationInfo().setText(R.string.update_available);
        } else {
          leftImage.setVisibility(View.GONE);
        }
        rightImage.setImageResource(R.drawable.ic_cancel);
        rightImage.setVisibility(View.VISIBLE);
        rightImage.setContentDescription(context.getString(R.string.remove_button));
      } else {
        leftImage.setVisibility(View.GONE);
        rightImage.setImageResource(R.drawable.ic_download);
        rightImage.setVisibility(View.VISIBLE);
        rightImage.setOnClickListener(null);
        rightImage.setClickable(false);
        rightImage.setContentDescription(null);
      }
      break;
    case R.layout.translation_sep:
      holder.getSeparatorText().setText(rowItem.name());
      break;
  }
}
 
Example 15
Project: Bigbang   File: BigBangBottom.java   View Source Code Vote up 5 votes
private void initSubViews() {
    Context context = getContext();


    mDragSelect=new ImageView(context);
    mDragSelect.setImageResource(R.mipmap.ic_drag_select_36dp_n);
    mDragSelect.setOnClickListener(this);
    mDragSelect.setContentDescription(getContext().getString(R.string.drag_select_mode));

    mDrag=new ImageView(context);
    mDrag.setImageResource(R.mipmap.ic_sort_white_36dp);
    mDrag.setOnClickListener(this);
    mDrag.setContentDescription(getContext().getString(R.string.drag_mode));


    mType=new ImageView(context);
    mType.setImageResource(R.mipmap.bigbang_action_cloud);
    mType.setOnClickListener(this);
    mType.setContentDescription(getContext().getString(R.string.offline_segment));

    mSelectOther=new ImageView(context);
    mSelectOther.setImageResource(R.mipmap.bigbang_action_select_other);
    mSelectOther.setOnClickListener(this);
    mSelectOther.setContentDescription(getContext().getString(R.string.select_other));

    mSymbol=new ImageView(context);
    mSymbol.setImageResource(R.mipmap.bigbang_action_symbol);
    mSymbol.setOnClickListener(this);
    mSymbol.setContentDescription(getContext().getString(R.string.no_symbol));

    mSection=new ImageView(context);
    mSection.setImageResource(R.mipmap.bigbang_action_enter);
    mSection.setOnClickListener(this);
    mSection.setContentDescription(getContext().getString(R.string.no_section));

    addView(mDragSelect, createLayoutParams());
    addView(mDrag, createLayoutParams());
    addView(mType, createLayoutParams());
    addView(mSelectOther, createLayoutParams());
    addView(mSection, createLayoutParams());
    addView(mSymbol, createLayoutParams());

    setWillNotDraw(false);

    mActionGap = (int) ViewUtil.dp2px(5);
    mContentPadding = (int) ViewUtil.dp2px(10);
}
 
Example 16
Project: Swift-Braille-Soft-keyboard   File: DotsLayoutActivity.java   View Source Code Vote up 5 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    try {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_settings_dots_layout);

        //Show back button
        ActionBar ab = getSupportActionBar();
        if (ab != null) {
            ab.setDisplayHomeAsUpEnabled(true);
            ab.setHomeAsUpIndicator(R.mipmap.ic_arrow_back_white_24dp);
        }

        //Speak the title of the activity
        Common.defaultTextSpeech.speechText(getString(R.string.dots_layout));

        //Declaration
        brailleCellCheckBox = (ImageView) findViewById(R.id.brailleCellCheckBox);
        perkinsLayoutCheckBox = (ImageView) findViewById(R.id.perkinsLayoutCheckBox);
        twoDotsLayoutCheckBox = (ImageView) findViewById(R.id.twoDotsLayoutCheckBox);

        //Check if multi-touch supported
        PackageManager pm = getPackageManager();
        hasSixMultiTouch = pm.hasSystemFeature(PackageManager.FEATURE_TOUCHSCREEN_MULTITOUCH_JAZZHAND);

        //Load default layout
        int selectedDotsLayout = Common.selectedDotsLayout;
        if (selectedDotsLayout == Common.BRAILLE_CELL_DOTS_LAYOUT) {
            brailleCellCheckBox.setImageResource(R.mipmap.ic_radio_button_checked_green_24dp);
            brailleCellCheckBox.setContentDescription(getString(R.string.braille_cell_layout_selected));

            perkinsLayoutCheckBox.setImageResource(R.mipmap.ic_radio_button_unchecked_green_24dp);
            perkinsLayoutCheckBox.setContentDescription(getString(R.string.perkins_layout_not_selected));

            twoDotsLayoutCheckBox.setImageResource(R.mipmap.ic_radio_button_unchecked_green_24dp);
            twoDotsLayoutCheckBox.setContentDescription(getString(R.string.two_rows_layout_not_selected));
        } else if (selectedDotsLayout == Common.PERKINS_DOTS_LAYOUT) {
            brailleCellCheckBox.setImageResource(R.mipmap.ic_radio_button_unchecked_green_24dp);
            brailleCellCheckBox.setContentDescription(getString(R.string.braille_cell_layout_not_selected));

            perkinsLayoutCheckBox.setImageResource(R.mipmap.ic_radio_button_checked_green_24dp);
            perkinsLayoutCheckBox.setContentDescription(getString(R.string.perkins_layout_selected));

            twoDotsLayoutCheckBox.setImageResource(R.mipmap.ic_radio_button_unchecked_green_24dp);
            twoDotsLayoutCheckBox.setContentDescription(getString(R.string.two_rows_layout_not_selected));
        } else if (selectedDotsLayout == Common.TWO_ROWS_DOTS_LAYOUT) {
            brailleCellCheckBox.setImageResource(R.mipmap.ic_radio_button_unchecked_green_24dp);
            brailleCellCheckBox.setContentDescription(getString(R.string.braille_cell_layout_not_selected));

            perkinsLayoutCheckBox.setImageResource(R.mipmap.ic_radio_button_unchecked_green_24dp);
            perkinsLayoutCheckBox.setContentDescription(getString(R.string.perkins_layout_not_selected));

            twoDotsLayoutCheckBox.setImageResource(R.mipmap.ic_radio_button_checked_green_24dp);
            twoDotsLayoutCheckBox.setContentDescription(getString(R.string.two_rows_layout_selected));
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example 17
Project: cwac-crossport   File: TabLayoutLite.java   View Source Code Vote up 5 votes
private void updateTextAndIcon(@Nullable final TextView textView,
            @Nullable final ImageView iconView) {
  final Drawable icon = mTab != null ? mTab.getIcon() : null;
  final CharSequence text = mTab != null ? mTab.getText() : null;
  final CharSequence contentDesc = mTab != null ? mTab.getContentDescription() : null;

  if (iconView != null) {
    if (icon != null) {
      iconView.setImageDrawable(icon);
      iconView.setVisibility(VISIBLE);
      setVisibility(VISIBLE);
    } else {
      iconView.setVisibility(GONE);
      iconView.setImageDrawable(null);
    }
    iconView.setContentDescription(contentDesc);
  }

  final boolean hasText = !TextUtils.isEmpty(text);
  if (textView != null) {
    if (hasText) {
      textView.setText(text);
      textView.setVisibility(VISIBLE);
      setVisibility(VISIBLE);
    } else {
      textView.setVisibility(GONE);
      textView.setText(null);
    }
    textView.setContentDescription(contentDesc);
  }

  if (iconView != null) {
    MarginLayoutParams lp = ((MarginLayoutParams) iconView.getLayoutParams());
    int bottomMargin = 0;
    if (hasText && iconView.getVisibility() == VISIBLE) {
      // If we're showing both text and icon, add some margin bottom to the icon
      bottomMargin = dpToPx(DEFAULT_GAP_TEXT_ICON);
    }
    if (bottomMargin != lp.bottomMargin) {
      lp.bottomMargin = bottomMargin;
      iconView.requestLayout();
    }
  }
        TooltipCompat.setTooltipText(this, hasText ? null : contentDesc);
}
 
Example 18
Project: cwac-crossport   File: TabLayout.java   View Source Code Vote up 5 votes
private void updateTextAndIcon(@Nullable final TextView textView,
            @Nullable final ImageView iconView) {
  final Drawable icon = mTab != null ? mTab.getIcon() : null;
  final CharSequence text = mTab != null ? mTab.getText() : null;
  final CharSequence contentDesc = mTab != null ? mTab.getContentDescription() : null;

  if (iconView != null) {
    if (icon != null) {
      iconView.setImageDrawable(icon);
      iconView.setVisibility(VISIBLE);
      setVisibility(VISIBLE);
    } else {
      iconView.setVisibility(GONE);
      iconView.setImageDrawable(null);
    }
    iconView.setContentDescription(contentDesc);
  }

  final boolean hasText = !TextUtils.isEmpty(text);
  if (textView != null) {
    if (hasText) {
      textView.setText(text);
      textView.setVisibility(VISIBLE);
      setVisibility(VISIBLE);
    } else {
      textView.setVisibility(GONE);
      textView.setText(null);
    }
    textView.setContentDescription(contentDesc);
  }

  if (iconView != null) {
    MarginLayoutParams lp = ((MarginLayoutParams) iconView.getLayoutParams());
    int bottomMargin = 0;
    if (hasText && iconView.getVisibility() == VISIBLE) {
      // If we're showing both text and icon, add some margin bottom to the icon
      bottomMargin = dpToPx(DEFAULT_GAP_TEXT_ICON);
    }
    if (bottomMargin != lp.bottomMargin) {
      lp.bottomMargin = bottomMargin;
      iconView.requestLayout();
    }
  }
        TooltipCompat.setTooltipText(this, hasText ? null : contentDesc);
}
 
Example 19
Project: iosched-reader   File: SessionDetailFragment.java   View Source Code Vote up 5 votes
private void displaySpeakersData(SessionDetailModel data) {
    final ViewGroup speakersGroup = (ViewGroup) getActivity()
            .findViewById(R.id.session_speakers_block);

    // Remove all existing speakers (everything but first child, which is the header)
    for (int i = speakersGroup.getChildCount() - 1; i >= 1; i--) {
        speakersGroup.removeViewAt(i);
    }

    final LayoutInflater inflater = getActivity().getLayoutInflater();

    boolean hasSpeakers = false;

    List<SessionDetailModel.Speaker> speakers = data.getSpeakers();

    for (final SessionDetailModel.Speaker speaker : speakers) {

        String speakerHeader = speaker.getName();
        if (!TextUtils.isEmpty(speaker.getCompany())) {
            speakerHeader += ", " + speaker.getCompany();
        }

        final View speakerView = inflater
                .inflate(R.layout.speaker_detail, speakersGroup, false);
        final TextView speakerHeaderView = (TextView) speakerView
                .findViewById(R.id.speaker_header);
        final ImageView speakerImageView = (ImageView) speakerView
                .findViewById(R.id.speaker_image);
        final TextView speakerAbstractView = (TextView) speakerView
                .findViewById(R.id.speaker_abstract);
        final ImageView plusOneIcon = (ImageView) speakerView.findViewById(R.id.gplus_icon_box);
        final ImageView twitterIcon = (ImageView) speakerView.findViewById(
                R.id.twitter_icon_box);

        setUpSpeakerSocialIcon(speaker, twitterIcon, speaker.getTwitterUrl(),
                UIUtils.TWITTER_COMMON_NAME, UIUtils.TWITTER_PACKAGE_NAME);

        setUpSpeakerSocialIcon(speaker, plusOneIcon, speaker.getPlusoneUrl(),
                UIUtils.GOOGLE_PLUS_COMMON_NAME, UIUtils.GOOGLE_PLUS_PACKAGE_NAME);

        // A speaker may have both a Twitter and GPlus page, only a Twitter page or only a
        // GPlus page, or neither. By default, align the Twitter icon to the right and the GPlus
        // icon to its left. If only a single icon is displayed, align it to the right.
        determineSocialIconPlacement(plusOneIcon, twitterIcon);

        if (!TextUtils.isEmpty(speaker.getImageUrl()) && mSpeakersImageLoader != null) {
            mSpeakersImageLoader.loadImage(speaker.getImageUrl(), speakerImageView);
        }

        speakerHeaderView.setText(speakerHeader);
        speakerImageView.setContentDescription(
                getString(R.string.speaker_googleplus_profile, speakerHeader));
        UIUtils.setTextMaybeHtml(speakerAbstractView, speaker.getAbstract());

        if (!TextUtils.isEmpty(speaker.getUrl())) {
            speakerImageView.setEnabled(true);
            speakerImageView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    Intent speakerProfileIntent = new Intent(Intent.ACTION_VIEW,
                            Uri.parse(speaker.getUrl()));
                    speakerProfileIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
                    UIUtils.preferPackageForIntent(getActivity(),
                            speakerProfileIntent,
                            UIUtils.GOOGLE_PLUS_PACKAGE_NAME);
                    startActivity(speakerProfileIntent);
                }
            });
        } else {
            speakerImageView.setEnabled(false);
            speakerImageView.setOnClickListener(null);
        }

        speakersGroup.addView(speakerView);
        hasSpeakers = true;
    }

    speakersGroup.setVisibility(hasSpeakers ? View.VISIBLE : View.GONE);
    updateEmptyView(data);
}
 
Example 20
Project: lighthouse   File: PodcastsAdapter.java   View Source Code Vote up 5 votes
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    if (convertView == null) {
        convertView = LayoutInflater.from(activity).inflate(R.layout.podcasts_item, parent, false);
    }
    Podcast podcast = getItem(position);

    TextView nameView = getNameView(convertView);
    nameView.setText(podcast.getName());
    nameView.setTypeface(activity.getLighthouseApplication().getFontBold());

    TextView lengthView = getLengthView(convertView);
    int length = podcast.getLength();
    int seen = podcast.getSeen();
    if (length > seen) {
        lengthView.setVisibility(View.VISIBLE);
        lengthView.setText(String.valueOf(length - seen));
        lengthView.setTypeface(activity.getLighthouseApplication().getFontLight());
    } else {
        lengthView.setVisibility(View.GONE);
    }

    ImageView iconView = getIconView(convertView);
    iconView.setContentDescription(podcast.getName());
    setIcon(iconView, podcast.getId());

    if (equalizerDrawable != null) {
        ImageView equalizerView = getEqualizerView(convertView);
        LighthouseTrack track = activity.getTrack();
        if (track == null || track.getPodcast().getId() != podcast.getId()) {
            equalizerView.setVisibility(View.GONE);
        } else if (activity.isPlaying()) {
            equalizerView.setImageDrawable(equalizerDrawable);
            equalizerView.setVisibility(View.VISIBLE);
            equalizerDrawable.start();
        } else {
            equalizerView.setImageResource(R.drawable.equalizer);
            equalizerView.setVisibility(View.VISIBLE);
            equalizerDrawable.stop();
        }
    }

    TextView descriptionView = getDescriptionView(convertView);
    if (podcast.getDescription() != null) {
        descriptionView.setVisibility(View.VISIBLE);
        descriptionView.setText(podcast.getDescription());
        descriptionView.setTypeface(activity.getLighthouseApplication().getFontNormal());
    } else {
        descriptionView.setVisibility(View.GONE);
    }

    return convertView;
}