Java Code Examples for android.widget.ImageView#getLayoutParams()

The following examples show how to use android.widget.ImageView#getLayoutParams() . 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: FloatingCameraWindow.java    From android-hpe with MIT License 6 votes vote down vote up
public FloatCamView(FloatingCameraWindow window) {
    super(window.mContext);
    mWeakRef = new WeakReference<FloatingCameraWindow>(window);

    mLayoutInflater = (LayoutInflater) window.mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    FrameLayout body = (FrameLayout) this;
    body.setOnTouchListener(new OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            return false;
        }
    });

    View floatView = mLayoutInflater.inflate(R.layout.cam_window_view, body, true);
    mColorView = (ImageView) findViewById(R.id.imageView_c);

    int colorMaxWidth = (int) (mWindowWidth * window.mScaleWidthRatio);
    int colorMaxHeight = (int) (mWindowHeight * window.mScaleHeightRatio);

    mColorView.getLayoutParams().width = colorMaxWidth;
    mColorView.getLayoutParams().height = colorMaxHeight;
}
 
Example 2
Source File: Patio.java    From Patio with MIT License 6 votes vote down vote up
public void addThumbnail(String thumbnailPath) {
    LayoutInflater inflater = LayoutInflater.from(mContext);
    ImageView imageView = (ImageView) inflater.inflate(THUMBNAIL_LAYOUT_RES_ID, mThumbnailsContainer, false);

    int resizeDimension = mThumbnailWidth > mThumbnailHeight ?
            Float.valueOf(mThumbnailWidth).intValue() :
            Float.valueOf(mThumbnailHeight).intValue();
    Picasso.with(mContext)
            .load(new File(thumbnailPath))
            .resize(resizeDimension, resizeDimension)
            .centerCrop()
            .into(imageView);

    ViewGroup.LayoutParams layoutParams = imageView.getLayoutParams();
    layoutParams.width = Float.valueOf(mThumbnailWidth).intValue();
    layoutParams.height = Float.valueOf(mThumbnailHeight).intValue();
    mThumbnailsContainer.addView(imageView, 0, layoutParams);
    imageView.setOnClickListener(this);


    mPatioThumbnails.add(new PatioThumbnail(thumbnailPath, imageView));
    showOrHideThumbnails();
    updateThumbnailsMessage();
}
 
Example 3
Source File: EffectsGalleryAdapter.java    From cloudinary_android with MIT License 6 votes vote down vote up
@Override
public EffectsGalleryAdapter.ImageViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    ViewGroup viewGroup = (ViewGroup) LayoutInflater.from(parent.getContext()).inflate(R.layout.item_effects_gallery, parent, false);
    viewGroup.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            selected = (EffectData) v.getTag();
            if (listener != null) {
                listener.onClick(selected);
            }

            notifyDataSetChanged();
        }
    });

    ImageView imageView = (ImageView) viewGroup.findViewById(R.id.image_view);
    imageView.getLayoutParams().height = requiredSize;
    return new EffectsGalleryAdapter.ImageViewHolder(viewGroup, imageView, viewGroup.findViewById(R.id.selected_indicator), (TextView) viewGroup.findViewById(R.id.effectName));
}
 
Example 4
Source File: MsgListAdapter.java    From jmessage-android-uikit with MIT License 6 votes vote down vote up
/**
 * 设置图片最小宽高
 *
 * @param path      图片路径
 * @param imageView 显示图片的View
 */
private void setPictureScale(String path, ImageView imageView) {
    BitmapFactory.Options opts = new BitmapFactory.Options();
    opts.inJustDecodeBounds = true;
    BitmapFactory.decodeFile(path, opts);
    //计算图片缩放比例
    double imageWidth = opts.outWidth;
    double imageHeight = opts.outHeight;
    if (imageWidth < 100 * mDensity) {
        imageHeight = imageHeight * (100 * mDensity / imageWidth);
        imageWidth = 100 * mDensity;
    }
    ViewGroup.LayoutParams params = imageView.getLayoutParams();
    params.width = (int) imageWidth;
    params.height = (int) imageHeight;
    imageView.setLayoutParams(params);
}
 
Example 5
Source File: ImageViewHelper.java    From XImageLoader with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 * <p/>
 * Width is defined by target {@link ImageView view} parameters,
 * configuration parameters or device display dimensions.<br />
 * Size computing algorithm:<br />
 * 1) Get the actual drawn <b>getWidth()</b> of the View. If view haven't
 * drawn yet then go to step #2.<br />
 * 2) Get <b>layout_width</b>. If it hasn't exact value then go to step #3.<br />
 * 3) Get <b>maxWidth</b>.
 */
public static int getImageViewWidth(ImageView imageView) {
    if (imageView != null) {
        final ViewGroup.LayoutParams params = imageView.getLayoutParams();
        int width = 0;
        if (params != null && params.width != ViewGroup.LayoutParams.WRAP_CONTENT) {
            width = imageView.getWidth(); // Get actual image width
        }
        if (width <= 0 && params != null) {
            width = params.width; // Get layout width parameter
        }
        if (width <= 0) {
            width = getImageViewFieldValue(imageView, "mMaxWidth");
        }
        return width;
    }
    return DEFAULT_WIDTH;
}
 
Example 6
Source File: LessonA.java    From SchoolQuest with GNU General Public License v3.0 6 votes vote down vote up
public void resetBars() {
    skill = 0;
    tempSkill = 0;
    attn = 0;
    time = 0;
    ImageView attnBar = GameActivity.getInstance().findViewById(R.id.lesson_a_attn_bar_fill);
    ViewGroup.LayoutParams attnParams = attnBar.getLayoutParams();
    attnParams.width = 1;
    attnBar.setLayoutParams(attnParams);

    ImageView skillBar = GameActivity.getInstance().findViewById(R.id.lesson_a_skill_bar_fill);
    ViewGroup.LayoutParams skillParams = skillBar.getLayoutParams();
    skillParams.width = 1;
    skillBar.setLayoutParams(skillParams);

    ImageView tempSkillBar =
            GameActivity.getInstance().findViewById(R.id.lesson_a_skill_temp_bar_fill);
    ViewGroup.LayoutParams tempSkillParams = tempSkillBar.getLayoutParams();
    tempSkillParams.width = 1;
    tempSkillBar.setLayoutParams(tempSkillParams);

    ImageView timeBar = GameActivity.getInstance().findViewById(R.id.lesson_a_time_bar_fill);
    ViewGroup.LayoutParams timeParams = timeBar.getLayoutParams();
    timeParams.width = 1;
    timeBar.setLayoutParams(timeParams);
}
 
Example 7
Source File: TVCastsOfPersonAdapter.java    From PopCorn with Apache License 2.0 6 votes vote down vote up
public TVShowViewHolder(View itemView) {
    super(itemView);
    tvShowCard = (CardView) itemView.findViewById(R.id.card_view_show_cast);
    tvShowPosterImageView = (ImageView) itemView.findViewById(R.id.image_view_show_cast);
    tvShowTitleTextView = (TextView) itemView.findViewById(R.id.text_view_title_show_cast);
    castCharacterTextView = (TextView) itemView.findViewById(R.id.text_view_cast_character_show_cast);

    tvShowPosterImageView.getLayoutParams().width = (int) (mContext.getResources().getDisplayMetrics().widthPixels * 0.31);
    tvShowPosterImageView.getLayoutParams().height = (int) ((mContext.getResources().getDisplayMetrics().widthPixels * 0.31) / 0.66);

    tvShowCard.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Intent intent = new Intent(mContext, TVShowDetailActivity.class);
            intent.putExtra(Constants.TV_SHOW_ID, mTVCasts.get(getAdapterPosition()).getId());
            mContext.startActivity(intent);
        }
    });
}
 
Example 8
Source File: RhythmAdapter.java    From MousePaint with MIT License 6 votes vote down vote up
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    RelativeLayout relativeLayout = (RelativeLayout) this.mInflater.inflate(R.layout.adapter_rhythm_icon, null);
    //set item layout size and y postion
    relativeLayout.setLayoutParams(new RelativeLayout.LayoutParams((int) itemWidth, mContext.getResources().getDimensionPixelSize(R.dimen.rhythm_item_height)));
    relativeLayout.setTranslationY(itemWidth);

    //set second RelativeLayout width and height
    RelativeLayout childRelativeLayout = (RelativeLayout) relativeLayout.getChildAt(0);
    int relativeLayoutWidth = (int) itemWidth - 2 * mContext.getResources().getDimensionPixelSize(R.dimen.rhythm_icon_margin);
    childRelativeLayout.setLayoutParams(new RelativeLayout.LayoutParams(relativeLayoutWidth, mContext.getResources().getDimensionPixelSize(R.dimen.rhythm_item_height) - 2 * mContext.getResources().getDimensionPixelSize(R.dimen.rhythm_icon_margin)));

    ImageView imageIcon = (ImageView) relativeLayout.findViewById(R.id.image_icon);
    //cul ImageView size
    int iconSize = (relativeLayoutWidth - 2 * mContext.getResources().getDimensionPixelSize(R.dimen.rhythm_icon_margin));
    ViewGroup.LayoutParams iconParams = imageIcon.getLayoutParams();
    iconParams.width = iconSize;
    iconParams.height = iconSize;
    imageIcon.setLayoutParams(iconParams);
    //set bg img
    Glide.with(mContext).load(mCardList.get(position).getIconUrl()).fitCenter().into(imageIcon);
    return relativeLayout;
}
 
Example 9
Source File: ImageLoader.java    From HttpRequest with Apache License 2.0 6 votes vote down vote up
/**
 * 重新设置宽高
 * @author leibing
 * @createTime 2017/2/28
 * @lastModify 2017/2/28
 * @param imageView 图片控件实例
 * @return
 */
public ImageView resetImgWidthHeight(ImageView imageView, int originWidth, int originHeight,
                                     int targetWidth){
    // 获取图片的布局
    ViewGroup.LayoutParams para = imageView.getLayoutParams();
    // 目标高度
    int targetHeight = (originHeight * targetWidth) / originWidth;
    if (para != null) {
        // 修改布局中的height,width属性
        // 修改宽度
        para.width = targetWidth;
        // 修改高度
        para.height = targetHeight;
        // 重新设置修改后的布局给控件
        imageView.setLayoutParams(para);
    }else {
        imageView.setLayoutParams(new ViewGroup.LayoutParams(targetWidth,targetHeight));
    }
    return imageView;
}
 
Example 10
Source File: ActionBarMenuItem.java    From KrGallery with GNU General Public License v2.0 5 votes vote down vote up
public ActionBarMenuItem(Context context, ActionBarMenu menu, int backgroundColor) {
    super(context);
    if (backgroundColor != 0) {
        setBackgroundDrawable(Theme.createBarSelectorDrawable(backgroundColor));
    }
    parentMenu = menu;

    iconView = new ImageView(context);
    iconView.setScaleType(ImageView.ScaleType.CENTER);
    addView(iconView);
    LayoutParams layoutParams = (LayoutParams) iconView.getLayoutParams();
    layoutParams.width = LayoutHelper.MATCH_PARENT;
    layoutParams.height = LayoutHelper.MATCH_PARENT;
    iconView.setLayoutParams(layoutParams);
}
 
Example 11
Source File: TextViewLinkActivity.java    From zone-sdk with MIT License 5 votes vote down vote up
private void roateSpan() {
        TextView tv_rotate_img_span = (TextView) findViewById(R.id.tv_rotate_img_span);
        ImageView img_rotate = (ImageView) findViewById(R.id.img_rotate);
        Drawable drawable = getResources().getDrawable(R.drawable.icon);
//        drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
        drawable.setBounds(0, 0, 200, 200);
        img_rotate.setImageDrawable(drawable);

        ViewGroup.LayoutParams lp = img_rotate.getLayoutParams();
        lp.width = 200;
        lp.height = 200;
        img_rotate.setLayoutParams(lp);

        //这个可以在oncreate的时候测量出来
        StaticLayout sl = new StaticLayout("aa", tv_rotate_img_span.getPaint(),
                100, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
        int lineHeight = sl.getLineBottom(0) - sl.getLineTop(0);// 比 tv_rotate_img_span.getLineHeight() 这个好 因为每行高刚度可能不一致

        int affectLine = 0;
        for (int i = 0; i < Integer.MAX_VALUE; i++) {
            if (i * lineHeight > 200 + 20) {
                affectLine = i - 1;
                break;
            }
        }

        SpannableString msp = new SpannableString("可是现在我已不是在天上翱翔的小鸟,在地上奔跑的动物了,因为我长大了,已经五年级了,大家都在努力地学习,谁都不想输给别人,每个人都在奋发图强,“学习如逆水行舟,不进则退”。这句话在我耳边回荡,难道我们就不应该有一个孩子应该有的童真吗?难道我已经失去了吗?难道现在我们所有的孩子都应该抓住学习这根攀山绳吗?为什么我们不?");
        tv_rotate_img_span.setText(msp);
        tv_rotate_img_span.setGravity(Gravity.LEFT);

        msp.setSpan(new ImageRotate(affectLine), 0, msp.length() - 1, Spanned.SPAN_INCLUSIVE_INCLUSIVE);
        tv_rotate_img_span.setText(msp);
    }
 
Example 12
Source File: KcaItemMultipleAdapter.java    From kcanotify_h5-master with GNU General Public License v3.0 5 votes vote down vote up
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    if (convertView==null)
        convertView = inf.inflate(layout, null);
    ImageView iv = (ImageView) convertView.findViewById(R.id.setting_image_pic);
    iv.setImageResource(item.get(position));
    if (selected.contains(position)) iv.setBackground(ContextCompat.getDrawable(context, R.drawable.imagebtn_on));
    else iv.setBackground(ContextCompat.getDrawable(context, R.drawable.imagebtn_off));
    if (rescale > 0) {
        iv.getLayoutParams().width = rescale;
        iv.getLayoutParams().height = rescale;
    }
    return convertView;
}
 
Example 13
Source File: BottomNavigationViewInner.java    From BottomNavigationViewEx with MIT License 5 votes vote down vote up
/**
 * set item ImageView size which at position
 *
 * @param position position start from 0
 * @param width    in dp
 * @param height   in dp
 */
public BottomNavigationViewInner setIconSizeAt(int position, float width, float height) {
    ImageView icon = getIconAt(position);
    // update size
    ViewGroup.LayoutParams layoutParams = icon.getLayoutParams();
    layoutParams.width = dp2px(getContext(), width);
    layoutParams.height = dp2px(getContext(), height);
    icon.setLayoutParams(layoutParams);

    mMenuView.updateMenuView();
    return this;
}
 
Example 14
Source File: MoviesAdapter.java    From AndroidSchool with Apache License 2.0 5 votes vote down vote up
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    View view = View.inflate(parent.getContext(), R.layout.image_item, null);
    ImageView imageView = (ImageView) view.findViewById(R.id.image);
    ViewGroup.LayoutParams layoutParams = imageView.getLayoutParams();
    layoutParams.height = mImageHeight;
    layoutParams.width = mImageWidth;
    imageView.requestLayout();
    return new ViewHolder(view);
}
 
Example 15
Source File: CustomAdapter.java    From emerald with GNU General Public License v3.0 5 votes vote down vote up
public void setImageViewLayoutParams(ImageView img) {
	if (null == imageViewLayoutParams) {
		imageViewLayoutParams = img.getLayoutParams();
		imageViewLayoutParams.width = iconSize;
		imageViewLayoutParams.height = iconSize;
	}
	img.setLayoutParams(imageViewLayoutParams);
}
 
Example 16
Source File: WelcomeActivity.java    From open-location-code with Apache License 2.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
    // Second argument is the default to use if the preference can't be found
    int savedVersionCode = prefs.getInt(WELCOME_VERSION_CODE_SHOWN_PREF, 0);
    int appVersionCode = 0;
    try {
        appVersionCode = getPackageManager().getPackageInfo(getPackageName(), 0).versionCode;
    } catch (NameNotFoundException nnfe) {
        Log.w(TAG, "Exception getting appVersionCode : " + nnfe);
    }

    final Intent intent = new Intent(this, MainActivity.class);
    final Activity activity = this;

    if (appVersionCode == savedVersionCode) {
        activity.startActivity(intent);
        activity.finish();
    } else {
        Log.i(TAG, "Starting welcome page");
        setContentView(R.layout.welcome);

        // Increase the margin on the image to account for the translucent status bar.
        ImageView welcomeImage = (ImageView) findViewById(R.id.welcome_image);
        LayoutParams layoutParams = (LayoutParams) welcomeImage.getLayoutParams();
        layoutParams.topMargin = layoutParams.topMargin + MainActivity.getStatusBarHeight(this);
        welcomeImage.setLayoutParams(layoutParams);

        Button button = (Button) findViewById(R.id.welcome_button);
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                activity.startActivity(intent);
                activity.finish();
            }
        });

        SharedPreferences.Editor editor = prefs.edit();
        editor.putInt(WELCOME_VERSION_CODE_SHOWN_PREF, appVersionCode);
        editor.apply();
    }
}
 
Example 17
Source File: InfoBarLayout.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
/**
 * Constructs a layout for the specified infobar. After calling this, be sure to set the
 * message, the buttons, and/or the custom content using setMessage(), setButtons(), and
 * setCustomContent().
 *
 * @param context The context used to render.
 * @param infoBarView InfoBarView that listens to events.
 * @param iconResourceId ID of the icon to use for the infobar.
 * @param iconBitmap Bitmap for the icon to use, if the resource ID wasn't passed through.
 * @param message The message to show in the infobar.
 */
public InfoBarLayout(Context context, InfoBarView infoBarView, int iconResourceId,
        Bitmap iconBitmap, CharSequence message) {
    super(context);
    mControlLayouts = new ArrayList<InfoBarControlLayout>();

    mInfoBarView = infoBarView;

    // Cache resource values.
    Resources res = getResources();
    mSmallIconSize = res.getDimensionPixelSize(R.dimen.infobar_small_icon_size);
    mSmallIconMargin = res.getDimensionPixelSize(R.dimen.infobar_small_icon_margin);
    mBigIconSize = res.getDimensionPixelSize(R.dimen.infobar_big_icon_size);
    mBigIconMargin = res.getDimensionPixelSize(R.dimen.infobar_big_icon_margin);
    mMarginAboveButtonGroup =
            res.getDimensionPixelSize(R.dimen.infobar_margin_above_button_row);
    mMarginAboveControlGroups =
            res.getDimensionPixelSize(R.dimen.infobar_margin_above_control_groups);
    mPadding = res.getDimensionPixelOffset(R.dimen.infobar_padding);
    mMinWidth = res.getDimensionPixelSize(R.dimen.infobar_min_width);
    mAccentColor = ApiCompatibilityUtils.getColor(res, R.color.infobar_accent_blue);

    // Set up the close button. Apply padding so it has a big touch target.
    mCloseButton = new ImageButton(context);
    mCloseButton.setId(R.id.infobar_close_button);
    mCloseButton.setImageResource(R.drawable.btn_close);
    TypedArray a = getContext().obtainStyledAttributes(
            new int [] {R.attr.selectableItemBackground});
    Drawable closeButtonBackground = a.getDrawable(0);
    a.recycle();
    mCloseButton.setBackground(closeButtonBackground);
    mCloseButton.setPadding(mPadding, mPadding, mPadding, mPadding);
    mCloseButton.setOnClickListener(this);
    mCloseButton.setContentDescription(res.getString(R.string.infobar_close));
    mCloseButton.setLayoutParams(new LayoutParams(0, -mPadding, -mPadding, -mPadding));

    // Set up the icon.
    if (iconResourceId != 0 || iconBitmap != null) {
        mIconView = new ImageView(context);
        if (iconResourceId != 0) {
            mIconView.setImageResource(iconResourceId);
        } else if (iconBitmap != null) {
            mIconView.setImageBitmap(iconBitmap);
        }
        mIconView.setLayoutParams(new LayoutParams(0, 0, mSmallIconMargin, 0));
        mIconView.getLayoutParams().width = mSmallIconSize;
        mIconView.getLayoutParams().height = mSmallIconSize;
        mIconView.setFocusable(false);
    }

    // Set up the message view.
    mMessageMainText = message;
    mMessageLayout = new InfoBarControlLayout(context);
    mMessageTextView = mMessageLayout.addMainMessage(prepareMainMessageString());
}
 
Example 18
Source File: InfoBarLayout.java    From delion with Apache License 2.0 4 votes vote down vote up
/**
 * Constructs a layout for the specified infobar. After calling this, be sure to set the
 * message, the buttons, and/or the custom content using setMessage(), setButtons(), and
 * setCustomContent().
 *
 * @param context The context used to render.
 * @param infoBarView InfoBarView that listens to events.
 * @param iconResourceId ID of the icon to use for the infobar.
 * @param iconBitmap Bitmap for the icon to use, if the resource ID wasn't passed through.
 * @param message The message to show in the infobar.
 */
public InfoBarLayout(Context context, InfoBarView infoBarView, int iconResourceId,
        Bitmap iconBitmap, CharSequence message) {
    super(context);
    mControlLayouts = new ArrayList<InfoBarControlLayout>();

    mInfoBarView = infoBarView;

    // Cache resource values.
    Resources res = getResources();
    mSmallIconSize = res.getDimensionPixelSize(R.dimen.infobar_small_icon_size);
    mSmallIconMargin = res.getDimensionPixelSize(R.dimen.infobar_small_icon_margin);
    mBigIconSize = res.getDimensionPixelSize(R.dimen.infobar_big_icon_size);
    mBigIconMargin = res.getDimensionPixelSize(R.dimen.infobar_big_icon_margin);
    mMarginAboveButtonGroup =
            res.getDimensionPixelSize(R.dimen.infobar_margin_above_button_row);
    mMarginAboveControlGroups =
            res.getDimensionPixelSize(R.dimen.infobar_margin_above_control_groups);
    mPadding = res.getDimensionPixelOffset(R.dimen.infobar_padding);
    mMinWidth = res.getDimensionPixelSize(R.dimen.infobar_min_width);
    mAccentColor = ApiCompatibilityUtils.getColor(res, R.color.infobar_accent_blue);

    // Set up the close button. Apply padding so it has a big touch target.
    mCloseButton = new ImageButton(context);
    mCloseButton.setId(R.id.infobar_close_button);
    mCloseButton.setImageResource(R.drawable.btn_close);
    TypedArray a = getContext().obtainStyledAttributes(
            new int [] {R.attr.selectableItemBackground});
    Drawable closeButtonBackground = a.getDrawable(0);
    a.recycle();
    mCloseButton.setBackground(closeButtonBackground);
    mCloseButton.setPadding(mPadding, mPadding, mPadding, mPadding);
    mCloseButton.setOnClickListener(this);
    mCloseButton.setContentDescription(res.getString(R.string.infobar_close));
    mCloseButton.setLayoutParams(new LayoutParams(0, -mPadding, -mPadding, -mPadding));

    // Set up the icon.
    if (iconResourceId != 0 || iconBitmap != null) {
        mIconView = new ImageView(context);
        if (iconResourceId != 0) {
            mIconView.setImageResource(iconResourceId);
        } else if (iconBitmap != null) {
            mIconView.setImageBitmap(iconBitmap);
        }
        mIconView.setLayoutParams(new LayoutParams(0, 0, mSmallIconMargin, 0));
        mIconView.getLayoutParams().width = mSmallIconSize;
        mIconView.getLayoutParams().height = mSmallIconSize;
        mIconView.setFocusable(false);
    }

    // Set up the message view.
    mMessageMainText = message;
    mMessageLayout = new InfoBarControlLayout(context);
    mMessageTextView = mMessageLayout.addMainMessage(prepareMainMessageString());
}
 
Example 19
Source File: TVShowDetailActivity.java    From PopCorn with Apache License 2.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_tvshow_detail);
    mToolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(mToolbar);

    setTitle("");

    Intent receivedIntent = getIntent();
    mTVShowId = receivedIntent.getIntExtra(Constants.TV_SHOW_ID, -1);

    if (mTVShowId == -1) finish();

    mCollapsingToolbarLayout = (CollapsingToolbarLayout) findViewById(R.id.toolbar_layout);
    mAppBarLayout = (AppBarLayout) findViewById(R.id.app_bar);

    mPosterWidth = (int) (getResources().getDisplayMetrics().widthPixels * 0.25);
    mPosterHeight = (int) (mPosterWidth / 0.66);
    mBackdropWidth = getResources().getDisplayMetrics().widthPixels;
    mBackdropHeight = (int) (mBackdropWidth / 1.77);

    mTVShowTabLayout = (ConstraintLayout) findViewById(R.id.layout_toolbar_tv_show);
    mTVShowTabLayout.getLayoutParams().height = mBackdropHeight + (int) (mPosterHeight * 0.9);

    mPosterImageView = (ImageView) findViewById(R.id.image_view_poster);
    mPosterImageView.getLayoutParams().width = mPosterWidth;
    mPosterImageView.getLayoutParams().height = mPosterHeight;
    mPosterProgressBar = (AVLoadingIndicatorView) findViewById(R.id.progress_bar_poster);
    mPosterProgressBar.setVisibility(View.GONE);

    mBackdropImageView = (ImageView) findViewById(R.id.image_view_backdrop);
    mBackdropImageView.getLayoutParams().height = mBackdropHeight;
    mBackdropProgressBar = (AVLoadingIndicatorView) findViewById(R.id.progress_bar_backdrop);
    mBackdropProgressBar.setVisibility(View.GONE);

    mTitleTextView = (TextView) findViewById(R.id.text_view_title_tv_show_detail);
    mGenreTextView = (TextView) findViewById(R.id.text_view_genre_tv_show_detail);
    mYearTextView = (TextView) findViewById(R.id.text_view_year_tv_show_detail);

    mBackImageButton = (ImageButton) findViewById(R.id.image_button_back_tv_show_detail);
    mBackImageButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            onBackPressed();
        }
    });
    mFavImageButton = (ImageButton) findViewById(R.id.image_button_fav_tv_show_detail);
    mShareImageButton = (ImageButton) findViewById(R.id.image_button_share_tv_show_detail);

    mRatingLayout = (LinearLayout) findViewById(R.id.layout_rating_tv_show_detail);
    mRatingTextView = (TextView) findViewById(R.id.text_view_rating_tv_show_detail);

    mOverviewTextView = (TextView) findViewById(R.id.text_view_overview_tv_show_detail);
    mOverviewReadMoreTextView = (TextView) findViewById(R.id.text_view_read_more_tv_show_detail);
    mDetailsLayout = (LinearLayout) findViewById(R.id.layout_details_tv_show_detail);
    mDetailsTextView = (TextView) findViewById(R.id.text_view_details_tv_show_detail);

    mVideosTextView = (TextView) findViewById(R.id.text_view_trailer_tv_show_detail);
    mVideosRecyclerView = (RecyclerView) findViewById(R.id.recycler_view_trailers_tv_show_detail);
    (new LinearSnapHelper()).attachToRecyclerView(mVideosRecyclerView);
    mVideos = new ArrayList<>();
    mVideosAdapter = new VideoAdapter(TVShowDetailActivity.this, mVideos);
    mVideosRecyclerView.setAdapter(mVideosAdapter);
    mVideosRecyclerView.setLayoutManager(new LinearLayoutManager(TVShowDetailActivity.this, LinearLayoutManager.HORIZONTAL, false));

    mHorizontalLine = (View) findViewById(R.id.view_horizontal_line);

    mCastTextView = (TextView) findViewById(R.id.text_view_cast_tv_show_detail);
    mCastRecyclerView = (RecyclerView) findViewById(R.id.recycler_view_cast_tv_show_detail);
    mCasts = new ArrayList<>();
    mCastAdapter = new TVShowCastAdapter(TVShowDetailActivity.this, mCasts);
    mCastRecyclerView.setAdapter(mCastAdapter);
    mCastRecyclerView.setLayoutManager(new LinearLayoutManager(TVShowDetailActivity.this, LinearLayoutManager.HORIZONTAL, false));

    mSimilarTVShowsTextView = (TextView) findViewById(R.id.text_view_similar_tv_show_detail);
    mSimilarTVShowsRecyclerView = (RecyclerView) findViewById(R.id.recycler_view_similar_tv_show_detail);
    mSimilarTVShows = new ArrayList<>();
    mSimilarTVShowsAdapter = new TVShowBriefsSmallAdapter(TVShowDetailActivity.this, mSimilarTVShows);
    mSimilarTVShowsRecyclerView.setAdapter(mSimilarTVShowsAdapter);
    mSimilarTVShowsRecyclerView.setLayoutManager(new LinearLayoutManager(TVShowDetailActivity.this, LinearLayoutManager.HORIZONTAL, false));

    if (NetworkConnection.isConnected(TVShowDetailActivity.this)) {
        isActivityLoaded = true;
        loadActivity();
    }

}
 
Example 20
Source File: MyRapidFloatingActionContentLabelList.java    From nono-android with GNU General Public License v3.0 4 votes vote down vote up
private void refreshItems() {
    if(ABTextUtil.isEmpty(this.items)) {
        throw new RuntimeException(this.getClass().getSimpleName() + "[items] can not be empty!");
    } else {
        this.contentView.removeAllViews();
        int i = 0;

        for(int size = this.items.size(); i < size; ++i) {
            RFACLabelItem item = (RFACLabelItem)this.items.get(i);
            View itemView = LayoutInflater.from(this.getContext()).inflate(com.wangjie.rapidfloatingactionbutton.R.layout.rfab__content_label_list_item, (ViewGroup)null);
            View rootView = (ABViewUtil.obtainView(itemView, com.wangjie.rapidfloatingactionbutton.R.id.rfab__content_label_list_root_view));
            TextView labelTv = (TextView)ABViewUtil.obtainView(itemView, com.wangjie.rapidfloatingactionbutton.R.id.rfab__content_label_list_label_tv);
            ImageView iconIv = (ImageView)ABViewUtil.obtainView(itemView, com.wangjie.rapidfloatingactionbutton.R.id.rfab__content_label_list_icon_iv);
            rootView.setOnClickListener(this);
            labelTv.setOnClickListener(this);
            iconIv.setOnClickListener(this);
            rootView.setTag(com.wangjie.rapidfloatingactionbutton.R.id.rfab__id_content_label_list_item_position, Integer.valueOf(i));
            labelTv.setTag(com.wangjie.rapidfloatingactionbutton.R.id.rfab__id_content_label_list_item_position, Integer.valueOf(i));
            iconIv.setTag(com.wangjie.rapidfloatingactionbutton.R.id.rfab__id_content_label_list_item_position, Integer.valueOf(i));
            CircleButtonProperties circleButtonProperties = (new CircleButtonProperties()).setStandardSize(RFABSize.MINI).setShadowColor(this.iconShadowColor).setShadowRadius(this.iconShadowRadius).setShadowDx(this.iconShadowDx).setShadowDy(this.iconShadowDy);
            int shadowOffsetHalf = circleButtonProperties.getShadowOffsetHalf();
            int minPadding = ABTextUtil.dip2px(this.getContext(), 8.0F);
            int realItemSize;
            if(shadowOffsetHalf < minPadding) {
                realItemSize = minPadding - shadowOffsetHalf;
                rootView.setPadding(0, realItemSize, 0, realItemSize);
            }

            realItemSize = circleButtonProperties.getRealSizePx(this.getContext());
            android.widget.LinearLayout.LayoutParams lp = (android.widget.LinearLayout.LayoutParams)iconIv.getLayoutParams();
            if(null == lp) {
                lp = new android.widget.LinearLayout.LayoutParams(-2, -2);
            }

            int rfabRealSize = this.onRapidFloatingActionListener.obtainRFAButton().getRfabProperties().getRealSizePx(this.getContext());
            lp.rightMargin = (rfabRealSize - realItemSize) / 2;
            lp.width = realItemSize;
            lp.height = realItemSize;
            iconIv.setLayoutParams(lp);
            Integer normalColor = item.getIconNormalColor();
            Integer pressedColor = item.getIconPressedColor();
            CircleButtonDrawable rfacNormalDrawable = new CircleButtonDrawable(this.getContext(), circleButtonProperties, null == normalColor?this.getResources().getColor(com.wangjie.rapidfloatingactionbutton.R.color.rfab__color_background_normal):normalColor.intValue());
            CircleButtonDrawable rfacPressedDrawable = new CircleButtonDrawable(this.getContext(), circleButtonProperties, null == pressedColor?this.getResources().getColor(com.wangjie.rapidfloatingactionbutton.R.color.rfab__color_background_pressed):pressedColor.intValue());
            if(Build.VERSION.SDK_INT > 11) {
                iconIv.setLayerType(1, rfacNormalDrawable.getPaint());
            }

            ABViewUtil.setBackgroundDrawable(iconIv, ABShape.selectorClickSimple(rfacNormalDrawable, rfacPressedDrawable));
            int padding = ABTextUtil.dip2px(this.getContext(), 8.0F) + shadowOffsetHalf;
            iconIv.setPadding(padding, padding, padding, padding);
            String label = item.getLabel();
            if(ABTextUtil.isEmpty(label)) {
                labelTv.setVisibility(GONE);
            } else {
                if(item.isLabelTextBold()) {
                    labelTv.getPaint().setFakeBoldText(true);
                }

                labelTv.setVisibility(VISIBLE);
                labelTv.setText(label);
                Drawable resId = item.getLabelBackgroundDrawable();
                if(null != resId) {
                    ABViewUtil.setBackgroundDrawable(labelTv, resId);
                }

                Integer drawable = item.getLabelColor();
                if(null != drawable) {
                    labelTv.setTextColor(drawable.intValue());
                }

                Integer labelSize = item.getLabelSizeSp();
                if(null != labelSize) {
                    labelTv.setTextSize(2, (float)labelSize.intValue());
                }
            }

            Drawable var23 = item.getDrawable();
            if(null != var23) {
                iconIv.setVisibility(VISIBLE);
                var23.setBounds(0, 0, this.rfacItemDrawableSizePx, this.rfacItemDrawableSizePx);
                iconIv.setImageDrawable(var23);
            } else {
                int var24;
                if((var24 = item.getResId()) > 0) {
                    iconIv.setVisibility(VISIBLE);
                    iconIv.setImageDrawable(ABImageProcess.getResourceDrawableBounded(this.getContext(), var24, this.rfacItemDrawableSizePx));
                } else {
                    iconIv.setVisibility(GONE);
                }
            }

            this.contentView.addView(itemView);
        }

    }
}