Java Code Examples for android.widget.ImageButton#setImageDrawable()

The following examples show how to use android.widget.ImageButton#setImageDrawable() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EmojiconsView.java    From EmojiChat with Apache License 2.0 6 votes vote down vote up
private void addTabIcon(EmojiconPage page, int index) {
    ImageButton icon = new ImageButton(getContext());
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.MATCH_PARENT);
    params.weight = 1;
    icon.setBackground(null);
    icon.setScaleType(ImageView.ScaleType.CENTER);
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        icon.setImageDrawable(getContext().getResources().getDrawable(page.getIcon()));
    } else {
        icon.setImageDrawable(getContext().getDrawable(page.getIcon()));
    }
    mTabsContainer.addView(icon, mTabsContainer.getChildCount() - 2, params);
    mTabs[index] = icon;
    final int indexToMove = index;
    icon.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            mViewPager.setCurrentItem(indexToMove, true);
        }
    });
}
 
Example 2
Source File: AdvancedShortcutActivity.java    From TvAppRepo with Apache License 2.0 6 votes vote down vote up
@Override
public void onIcons(PackedIcon[] icons) {
    if (getResources().getBoolean(R.bool.ENABLE_ICON_PACKS)) {
        Log.d(TAG, icons.length + "<<<");
        // Show all icons for the user to select (or let them do their own)
        LinearLayout iconDialogLayout = (LinearLayout) findViewById(R.id.icon_list);
        iconDialogLayout.requestFocus();
        iconDialogLayout.removeAllViews();
        for (final PackedIcon icon : icons) {
            ImageButton imageButton = new ImageButton(AdvancedShortcutActivity.this);
            imageButton.setImageDrawable(icon.icon);
            imageButton.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    if (icon.isBanner) {
                        advancedOptions.setBannerBitmap(icon.getBitmap());
                    } else {
                        advancedOptions.setIconBitmap(icon.getBitmap());
                    }
                    Log.d(TAG, advancedOptions.toString());
                }
            });
            iconDialogLayout.addView(imageButton);
        }
    }
}
 
Example 3
Source File: IncDecImageButton.java    From IncDec with Apache License 2.0 6 votes vote down vote up
private void setupRightButton(ImageButton rightButton, Drawable rightSrc,
                              int rightButtonTint, int rightDrawableTint, Drawable background) {
    if(rightSrc!=null) {
        if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            rightSrc.setTintList(new ColorStateList(new int[][]{new int[]{0}},
                    new int[]{rightDrawableTint}));
        }
        else
        {
            final Drawable wrappedDrawable = DrawableCompat.wrap(rightSrc);
            DrawableCompat.setTintList(wrappedDrawable, ColorStateList.valueOf(rightDrawableTint));
        }
        rightButton.setImageDrawable(rightSrc);
    }
    if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        rightButton.setBackgroundTintList(new ColorStateList(new int[][]{new int[]{0}},
                new int[]{rightButtonTint}));
    }
    else
    {
        ViewCompat.setBackgroundTintList(rightButton, ColorStateList.valueOf(rightButtonTint));
    }
    rightButton.setBackground(background);
}
 
Example 4
Source File: AppPickerPreference.java    From GravityBox with Apache License 2.0 6 votes vote down vote up
@Override
protected void onBindView(View view) {
    super.onBindView(view);

    LinearLayout widgetFrameView = ((LinearLayout) view.findViewById(android.R.id.widget_frame));
    mBtnAppIcon = new ImageButton(mContext);
    LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(mAppIconPreviewSizePx, mAppIconPreviewSizePx);
    lp.gravity = Gravity.CENTER;
    mBtnAppIcon.setLayoutParams(lp);
    mBtnAppIcon.setScaleType(ScaleType.CENTER_CROP);
    mBtnAppIcon.setImageDrawable(mAppInfo.icon);
    mBtnAppIcon.setFocusable(false);
    if (mIconPickerEnabled) {
        mBtnAppIcon.setOnClickListener(this);
        mBtnAppIcon.setOnLongClickListener(this);
    } else {
        mBtnAppIcon.setEnabled(false);
    }
    widgetFrameView.addView(mBtnAppIcon);
    widgetFrameView.setVisibility(View.VISIBLE);
}
 
Example 5
Source File: EmojiconsView.java    From emojicon with Apache License 2.0 6 votes vote down vote up
private void addTabIcon(EmojiconPage page, int index) {
    ImageButton icon = new ImageButton(getContext());
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.MATCH_PARENT);
    params.weight = 1;
    icon.setBackground(null);
    icon.setScaleType(ImageView.ScaleType.CENTER);
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        icon.setImageDrawable(getContext().getResources().getDrawable(page.getIcon()));
    } else {
        icon.setImageDrawable(getContext().getDrawable(page.getIcon()));
    }
    mTabsContainer.addView(icon, mTabsContainer.getChildCount() - 2, params);
    mTabs[index] = icon;
    final int indexToMove = index;
    icon.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            mViewPager.setCurrentItem(indexToMove, true);
        }
    });
}
 
Example 6
Source File: BreadcrumbsAdapter.java    From BreadcrumbsView with MIT License 6 votes vote down vote up
ArrowIconHolder(View itemView) {
	super(itemView);
	Drawable normalDrawable = getContext().getResources().getDrawable(R.drawable.ic_chevron_right_black_24dp);
	Drawable wrapDrawable = DrawableCompat.wrap(normalDrawable);
	// DrawableCompat.setTint(wrapDrawable, ViewUtils.getColorFromAttr(getContext(), android.R.attr.textColorSecondary));
	DrawableCompat.setTintList(wrapDrawable, parent.getTextColor());
	imageButton = (ImageButton) itemView;
	imageButton.setImageDrawable(wrapDrawable);
	imageButton.setOnClickListener(new View.OnClickListener() {
		@Override
		public void onClick(View view) {
			if (item.hasMoreSelect()) {
				try {
					popupWindow.show();
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		}
	});
	createPopupWindow();
}
 
Example 7
Source File: OnHeaderClicked.java    From kolabnotes-android with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void onClick(View view) {
    ImageButton button = (ImageButton)view.findViewById(R.id.drawer_openclose_button);

    final Drawable drawable = button.getDrawable();

    if(arrowDown){
        button.setImageDrawable(view.getContext().getResources().getDrawable(R.drawable.ic_arrow_drop_up_white_24dp));
        drawerAccountsService.displayAccounts();
        arrowDown = false;
    }else{
        button.setImageDrawable(view.getContext().getResources().getDrawable(R.drawable.ic_arrow_drop_down_white_24dp));
        drawerAccountsService.displayNavigation();
        arrowDown = true;
    }
}
 
Example 8
Source File: FilterMenu.java    From FilterMenu with Apache License 2.0 5 votes vote down vote up
public Builder addItem(Drawable icon) {
            ImageButton view = (ImageButton) inflater.inflate(R.layout.menu_item, null, false);
            view.setImageDrawable(icon);
//            TypedValue value = new TypedValue();
//            ctx.getTheme().resolveAttribute(R.attr.selectableItemBackgroundBorderless, value, true);
//            view.setBackgroundResource(value.resourceId);
            addItem(view);
            return this;
        }
 
Example 9
Source File: EmojiView.java    From Emoji with Apache License 2.0 5 votes vote down vote up
private ImageButton inflateButton(final Context context, @DrawableRes final int icon, @StringRes final int categoryName, final ViewGroup parent) {
  final ImageButton button = (ImageButton) LayoutInflater.from(context).inflate(R.layout.emoji_view_category, parent, false);

  button.setImageDrawable(AppCompatResources.getDrawable(context, icon));
  button.setColorFilter(themeIconColor, PorterDuff.Mode.SRC_IN);
  button.setContentDescription(context.getString(categoryName));

  parent.addView(button);

  return button;
}
 
Example 10
Source File: ShortcutLauncherFolderActivity.java    From FreezeYou with Apache License 2.0 5 votes vote down vote up
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (requestCode == 6 && resultCode == RESULT_OK && data != null && dialog != null) {
        Bitmap bm = data.getParcelableExtra("Icon");
        Window w = dialog.getWindow();
        if (w != null && bm != null) {
            ImageButton imageButton = w.findViewById(R.id.slfa_confirm_icon_name_dialog_imageButton);
            if (imageButton != null) {
                imageButton.setImageDrawable(new BitmapDrawable(bm));
            }
        }
    }
}
 
Example 11
Source File: BaseActivity.java    From android-audio-visualizer with Apache License 2.0 5 votes vote down vote up
public void playPauseBtnClicked(ImageButton btnPlayPause) {
    if (mediaPlayer != null) {
        if (mediaPlayer.isPlaying()) {
            mediaPlayer.pause();
            btnPlayPause.setImageDrawable(ContextCompat.getDrawable(
                    this,
                    R.drawable.ic_play_red_48dp));
        } else {
            mediaPlayer.start();
            btnPlayPause.setImageDrawable(ContextCompat.getDrawable(
                    this,
                    R.drawable.ic_pause_red_48dp));
        }
    }
}
 
Example 12
Source File: Util.java    From IslamicLibraryAndroid with GNU General Public License v3.0 5 votes vote down vote up
public static void setImageButtonEnabled(@NonNull Context ctxt, boolean enabled, @NonNull ImageButton item,
                                         int iconResId) {
    item.setEnabled(enabled);
    Drawable originalIcon = ctxt.getResources().getDrawable(iconResId);
    Drawable icon = enabled ? originalIcon : convertDrawableToGrayScale(originalIcon);
    item.setImageDrawable(icon);
}
 
Example 13
Source File: SuggestionStripView.java    From AOSP-Kayboard-7.1.2 with Apache License 2.0 4 votes vote down vote up
public SuggestionStripView(final Context context, final AttributeSet attrs,
        final int defStyle) {
    super(context, attrs, defStyle);

    final LayoutInflater inflater = LayoutInflater.from(context);
    inflater.inflate(R.layout.suggestions_strip, this);

    mSuggestionsStrip = (ViewGroup)findViewById(R.id.suggestions_strip);
    mVoiceKey = (ImageButton)findViewById(R.id.suggestions_strip_voice_key);
    mImportantNoticeStrip = findViewById(R.id.important_notice_strip);
    mStripVisibilityGroup = new StripVisibilityGroup(this, mSuggestionsStrip,
            mImportantNoticeStrip);

    for (int pos = 0; pos < SuggestedWords.MAX_SUGGESTIONS; pos++) {
        final TextView word = new TextView(context, null, R.attr.suggestionWordStyle);
        word.setContentDescription(getResources().getString(R.string.spoken_empty_suggestion));
        word.setOnClickListener(this);
        word.setOnLongClickListener(this);
        mWordViews.add(word);
        final View divider = inflater.inflate(R.layout.suggestion_divider, null);
        mDividerViews.add(divider);
        final TextView info = new TextView(context, null, R.attr.suggestionWordStyle);
        info.setTextColor(Color.WHITE);
        info.setTextSize(TypedValue.COMPLEX_UNIT_DIP, DEBUG_INFO_TEXT_SIZE_IN_DIP);
        mDebugInfoViews.add(info);
    }

    mLayoutHelper = new SuggestionStripLayoutHelper(
            context, attrs, defStyle, mWordViews, mDividerViews, mDebugInfoViews);

    mMoreSuggestionsContainer = inflater.inflate(R.layout.more_suggestions, null);
    mMoreSuggestionsView = (MoreSuggestionsView)mMoreSuggestionsContainer
            .findViewById(R.id.more_suggestions_view);
    mMoreSuggestionsBuilder = new MoreSuggestions.Builder(context, mMoreSuggestionsView);

    final Resources res = context.getResources();
    mMoreSuggestionsModalTolerance = res.getDimensionPixelOffset(
            R.dimen.config_more_suggestions_modal_tolerance);
    mMoreSuggestionsSlidingDetector = new GestureDetector(
            context, mMoreSuggestionsSlidingListener);

    final TypedArray keyboardAttr = context.obtainStyledAttributes(attrs,
            R.styleable.Keyboard, defStyle, R.style.SuggestionStripView);
    final Drawable iconVoice = keyboardAttr.getDrawable(R.styleable.Keyboard_iconShortcutKey);
    keyboardAttr.recycle();
    mVoiceKey.setImageDrawable(iconVoice);
    mVoiceKey.setOnClickListener(this);
}
 
Example 14
Source File: VidstaPlayer.java    From Vidsta with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected void onFinishInflate() {
    super.onFinishInflate();
    videoPlayer.setOnPreparedListener(this);
    videoPlayer.setOnBufferingUpdateListener(this);
    videoPlayer.setOnCompletionListener(this);
    videoPlayer.setOnErrorListener(this);
    videoPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
    textureView = new TextureView(getContext());
    addView(textureView, new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));

    LinearLayout rl = new LinearLayout(getContext());
    addView(rl, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    rl.setId(R.id.touchId);
    rl.setOnClickListener(this);

    LayoutInflater li = LayoutInflater.from(getContext());
    videoLoadingView = li.inflate(R.layout.layout_video_loading_view, this, false);
    addView(videoLoadingView);

    controlPlayPause = li.inflate(R.layout.layout_video_img_button_play_pause, this, false);
    controlSeekBar = li.inflate(R.layout.layout_video_seek_bar, this, false);
    FrameLayout.LayoutParams lp1 = (FrameLayout.LayoutParams) controlPlayPause.getLayoutParams();
    FrameLayout.LayoutParams lp2 = (FrameLayout.LayoutParams) controlSeekBar.getLayoutParams();

    lp1.gravity = Gravity.CENTER;
    lp2.gravity = Gravity.BOTTOM;

    addView(controlPlayPause, lp1);
    addView(controlSeekBar, lp2);

    imgBtnPlayPause = (ImageButton) controlPlayPause.findViewById(R.id.imageButtonPlayPauseRetry);
    imgBtnFullScreenToggle = (ImageButton) controlSeekBar.findViewById(R.id.imageButtonFullScreenToggle);
    tvPosition = (TextView) controlSeekBar.findViewById(R.id.textViewPosition);
    tvDuration = (TextView) controlSeekBar.findViewById(R.id.textViewDuration);
    proViewVideoLoading = (ProgressView) videoLoadingView.findViewById(R.id.proViewVideoLoading);
    seekBarDuration = (SeekBar) controlSeekBar.findViewById(R.id.seekBarDuration);
    imgBtnPlayPause.setImageDrawable(playVideoDrawable);

    imgBtnPlayPause.setOnClickListener(this);
    imgBtnFullScreenToggle.setOnClickListener(this);
    textureView.setSurfaceTextureListener(this);
    seekBarDuration.setOnSeekBarChangeListener(this);
    controlPlayPause.setVisibility(INVISIBLE);
    controlSeekBar.setVisibility(INVISIBLE);
    proViewVideoLoading.start();
    setUpVideoPlayer();
}
 
Example 15
Source File: SuggestionStripView.java    From Indic-Keyboard with Apache License 2.0 4 votes vote down vote up
public SuggestionStripView(final Context context, final AttributeSet attrs,
        final int defStyle) {
    super(context, attrs, defStyle);

    final LayoutInflater inflater = LayoutInflater.from(context);
    inflater.inflate(R.layout.suggestions_strip, this);

    mSuggestionsStrip = (ViewGroup)findViewById(R.id.suggestions_strip);
    mVoiceKey = (ImageButton)findViewById(R.id.suggestions_strip_voice_key);
    mImportantNoticeStrip = findViewById(R.id.important_notice_strip);
    mStripVisibilityGroup = new StripVisibilityGroup(this, mSuggestionsStrip,
            mImportantNoticeStrip);

    for (int pos = 0; pos < SuggestedWords.MAX_SUGGESTIONS; pos++) {
        final TextView word = new TextView(context, null, R.attr.suggestionWordStyle);
        word.setContentDescription(getResources().getString(R.string.spoken_empty_suggestion));
        word.setOnClickListener(this);
        word.setOnLongClickListener(this);
        mWordViews.add(word);
        final View divider = inflater.inflate(R.layout.suggestion_divider, null);
        mDividerViews.add(divider);
        final TextView info = new TextView(context, null, R.attr.suggestionWordStyle);
        info.setTextColor(Color.WHITE);
        info.setTextSize(TypedValue.COMPLEX_UNIT_DIP, DEBUG_INFO_TEXT_SIZE_IN_DIP);
        mDebugInfoViews.add(info);
    }

    mLayoutHelper = new SuggestionStripLayoutHelper(
            context, attrs, defStyle, mWordViews, mDividerViews, mDebugInfoViews);

    mMoreSuggestionsContainer = inflater.inflate(R.layout.more_suggestions, null);
    mMoreSuggestionsView = (MoreSuggestionsView)mMoreSuggestionsContainer
            .findViewById(R.id.more_suggestions_view);
    mMoreSuggestionsBuilder = new MoreSuggestions.Builder(context, mMoreSuggestionsView);

    final Resources res = context.getResources();
    mMoreSuggestionsModalTolerance = res.getDimensionPixelOffset(
            R.dimen.config_more_suggestions_modal_tolerance);
    mMoreSuggestionsSlidingDetector = new GestureDetector(
            context, mMoreSuggestionsSlidingListener);

    final TypedArray keyboardAttr = context.obtainStyledAttributes(attrs,
            R.styleable.Keyboard, defStyle, R.style.SuggestionStripView);
    final Drawable iconVoice = keyboardAttr.getDrawable(R.styleable.Keyboard_iconShortcutKey);
    keyboardAttr.recycle();
    mVoiceKey.setImageDrawable(iconVoice);
    mVoiceKey.setOnClickListener(this);
}
 
Example 16
Source File: ActivityMain.java    From fingen with Apache License 2.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    FGApplication.getAppComponent().inject(this);
    getIntent().putExtra("showHomeButton", false);

    switch (Integer.valueOf(mPreferences.getString("theme", "0"))) {
        case THEME_LIGHT:
            setTheme(R.style.AppThemeLight);
            break;
        case THEME_DARK:
            setTheme(R.style.AppThemeDark);
            break;
        default:
            setTheme(R.style.AppThemeLight);
            break;
    }

    super.onCreate(null);

    mUpdateUIHandler = new UpdateUIHandler(this);

    if (!BuildConfig.DEBUG) {
        Fabric.with(this, new Crashlytics());
    }

    mPreferences.edit().putBoolean(FgConst.PREF_SWITCH_TAB_ON_START, true).apply();

    ButterKnife.bind(this);

    setSupportActionBar(toolbar);
    if (getSupportActionBar() != null) {
        getSupportActionBar().setDisplayHomeAsUpEnabled(false);
    }

    mTextViewActiveSet.setBackgroundColor(ColorUtils.getBackgroundColor(this));

    buildDrawer();

    ImageButton drawerToggle = getNavButtonView(toolbar);
    if (drawerToggle != null) {
        drawerToggle.setImageDrawable(getDrawable(R.drawable.ic_menu_white));
    }
    addFragments();

    setupBottomBar();

    //<editor-fold desc="Setup fragments">
    fragmentPagerAdapter = new FgFragmentPagerAdapter(getSupportFragmentManager());
    viewPager.setAdapter(fragmentPagerAdapter);
    tabLayout.setupWithViewPager(viewPager);
    tabLayout.setOnDragListener((view, dragEvent) -> true);
    viewPager.setOffscreenPageLimit(2);
    //</editor-fold>


    //<editor-fold desc="Check version and show changelog if necessary">
    PackageInfo pInfo;
    int version;
    try {
        pInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
        version = pInfo.versionCode;
    } catch (PackageManager.NameNotFoundException e) {
        version = -1;
    }
    if (version > 0) {
        int prevVersion = mPreferences.getInt("version_code", -1);
        if (version != prevVersion) {
            onUpdateVersion(prevVersion, version);
        }
    }

    mPreferences.registerOnSharedPreferenceChangeListener(sharedPreferenceChangeListener);
    //</editor-fold>

    final View rootView = getWindow().getDecorView().getRootView();
    rootView.getViewTreeObserver().addOnGlobalLayoutListener(() -> {
        Rect rect = new Rect();
        rootView.getWindowVisibleDisplayFrame(rect);

        int screenHeight = rootView.getHeight();
        int keyboardHeight = screenHeight - (rect.bottom - rect.top);
        if (keyboardHeight > screenHeight / 3) {
            mButtonsBarContainer.setVisibility(View.GONE);
        } else {
            mButtonsBarContainer.setVisibility(View.VISIBLE);
        }
    });
}
 
Example 17
Source File: CustomTabBottomBarDelegate.java    From 365browser with Apache License 2.0 4 votes vote down vote up
/**
 * Updates the custom buttons on bottom bar area.
 * @param params The {@link CustomButtonParams} that describes the button to update.
 */
public void updateBottomBarButtons(CustomButtonParams params) {
    ImageButton button = (ImageButton) getBottomBarView().findViewById(params.getId());
    button.setContentDescription(params.getDescription());
    button.setImageDrawable(params.getIcon(mActivity.getResources()));
}
 
Example 18
Source File: ComplicationConfigActivity.java    From complications with Apache License 2.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_config);

    mDefaultAddComplicationDrawable = getDrawable(R.drawable.add_complication);

    // TODO: Step 3, initialize 1
    mSelectedComplicationId = -1;

    mLeftComplicationId =
            ComplicationWatchFaceService.getComplicationId(ComplicationLocation.LEFT);
    mRightComplicationId =
            ComplicationWatchFaceService.getComplicationId(ComplicationLocation.RIGHT);

    mWatchFaceComponentName =
            new ComponentName(getApplicationContext(), ComplicationWatchFaceService.class);

    // Sets up left complication preview.
    mLeftComplicationBackground = (ImageView) findViewById(R.id.left_complication_background);
    mLeftComplication = (ImageButton) findViewById(R.id.left_complication);
    mLeftComplication.setOnClickListener(this);

    // Sets default as "Add Complication" icon.
    mLeftComplication.setImageDrawable(mDefaultAddComplicationDrawable);
    mLeftComplicationBackground.setVisibility(View.INVISIBLE);

    // Sets up right complication preview.
    mRightComplicationBackground = (ImageView) findViewById(R.id.right_complication_background);
    mRightComplication = (ImageButton) findViewById(R.id.right_complication);
    mRightComplication.setOnClickListener(this);

    // Sets default as "Add Complication" icon.
    mRightComplication.setImageDrawable(mDefaultAddComplicationDrawable);
    mRightComplicationBackground.setVisibility(View.INVISIBLE);

    // TODO: Step 3, initialize 2
    mProviderInfoRetriever =
            new ProviderInfoRetriever(getApplicationContext(), Executors.newCachedThreadPool());
    mProviderInfoRetriever.init();

    retrieveInitialComplicationsData();
}
 
Example 19
Source File: StatusDetailDialogFragment.java    From SmileEssence with MIT License 4 votes vote down vote up
private View getTitleView(MainActivity activity, Account account, Status status) {
    View view = activity.getLayoutInflater().inflate(R.layout.dialog_status_detail, null);
    View statusHeader = view.findViewById(R.id.layout_status_header);
    StatusViewModel statusViewModel = new StatusViewModel(status, account);
    statusHeader = statusViewModel.getView(activity, activity.getLayoutInflater(), statusHeader);
    statusHeader.setClickable(false);
    int background = ((ColorDrawable) statusHeader.getBackground()).getColor();
    view.setBackgroundColor(background);
    ImageView favCountIcon = (ImageView) view.findViewById(R.id.image_status_detail_fav_count);
    ImageView rtCountIcon = (ImageView) view.findViewById(R.id.image_status_detail_rt_count);
    TextView favCountText = (TextView) view.findViewById(R.id.textview_status_detail_fav_count);
    TextView rtCountText = (TextView) view.findViewById(R.id.textview_status_detail_rt_count);
    int favoriteCount = TwitterUtils.getOriginalStatus(status).getFavoriteCount();
    if (favoriteCount == 0) {
        favCountIcon.setVisibility(View.GONE);
        favCountText.setVisibility(View.GONE);
    } else {
        favCountText.setText(Integer.toString(favoriteCount));
    }
    int retweetCount = TwitterUtils.getOriginalStatus(status).getRetweetCount();
    if (retweetCount == 0) {
        rtCountIcon.setVisibility(View.GONE);
        rtCountText.setVisibility(View.GONE);
    } else {
        rtCountText.setText(Integer.toString(retweetCount));
    }
    ImageButton menu = (ImageButton) view.findViewById(R.id.button_status_detail_menu);
    ImageButton message = (ImageButton) view.findViewById(R.id.button_status_detail_reply);
    ImageButton retweet = (ImageButton) view.findViewById(R.id.button_status_detail_retweet);
    ImageButton favorite = (ImageButton) view.findViewById(R.id.button_status_detail_favorite);
    ImageButton delete = (ImageButton) view.findViewById(R.id.button_status_detail_delete);
    menu.setOnClickListener(this);
    message.setOnClickListener(this);
    retweet.setOnClickListener(this);
    favorite.setOnClickListener(this);
    delete.setOnClickListener(this);
    if (isNotRetweetable(account, status)) {
        retweet.setVisibility(View.GONE);
    } else if (isRetweetDeletable(account, status)) {
        retweet.setImageDrawable(getResources().getDrawable(R.drawable.icon_retweet_on));
        retweet.setTag(status.getId());
    } else {
        retweet.setTag(-1L);
    }
    favorite.setTag(statusViewModel.isFavorited());
    if (statusViewModel.isFavorited()) {
        favorite.setImageDrawable(getResources().getDrawable(R.drawable.icon_favorite_on));
    }
    boolean deletable = isDeletable(account, status);
    delete.setVisibility(deletable ? View.VISIBLE : View.GONE);
    LinearLayout commandsLayout = (LinearLayout) view.findViewById(R.id.linearlayout_status_detail_menu);
    commandsLayout.setClickable(true);
    ArrayList<Command> commands = getCommands(activity, status, account);
    Command.filter(commands);
    for (final Command command : commands) {
        View commandView = command.getView(activity, activity.getLayoutInflater(), null);
        commandView.setBackgroundColor(getResources().getColor(R.color.transparent));
        commandView.setOnClickListener(new ListItemClickListener(activity, new Runnable() {
            @Override
            public void run() {
                command.execute();
                dismiss();
            }
        }));
        commandsLayout.addView(commandView);
    }
    return view;
}
 
Example 20
Source File: CustomTabBottomBarDelegate.java    From delion with Apache License 2.0 4 votes vote down vote up
/**
 * Updates the custom buttons on bottom bar area.
 * @param params The {@link CustomButtonParams} that describes the button to update.
 */
public void updateBottomBarButtons(CustomButtonParams params) {
    ImageButton button = (ImageButton) getBottomBarView().findViewById(params.getId());
    button.setContentDescription(params.getDescription());
    button.setImageDrawable(params.getIcon(mActivity.getResources()));
}