List of usage examples for android.content.res Resources getDimensionPixelSize
public int getDimensionPixelSize(@DimenRes int id) throws NotFoundException
From source file:org.devtcg.five.provider.FiveSyncAdapter.java
private void getImageData(SyncContext context, AbstractSyncProvider serverDiffs, String feedType, long modifiedSince) { if (context.hasError() == true || context.hasCanceled() == true) return;/* w w w . j a v a 2 s .co m*/ Uri localFeedUri = getLocalFeedUri(feedType); String tablePrefix = (feedType.equals(FEED_ALBUMS) ? "a." : ""); Cursor newRecords = serverDiffs.query(localFeedUri, new String[] { AbstractTableMerger.SyncableColumns._ID, AbstractTableMerger.SyncableColumns._SYNC_ID }, tablePrefix + AbstractTableMerger.SyncableColumns._SYNC_TIME + " > " + modifiedSince, null, null); Resources res = getContext().getResources(); int thumbWidth = res.getDimensionPixelSize(R.dimen.image_thumb_width); int thumbHeight = res.getDimensionPixelSize(R.dimen.image_thumb_height); int fullWidth = res.getDimensionPixelSize(R.dimen.large_artwork_width); int fullHeight = res.getDimensionPixelSize(R.dimen.large_artwork_height); try { while (newRecords.moveToNext() && !context.hasError() && !context.hasCanceled()) { long id = newRecords.getLong(0); long syncId = newRecords.getLong(1); try { Uri localFeedItemUri = ContentUris.withAppendedId(localFeedUri, id); if (feedType.equals(FEED_ARTISTS)) { downloadFileAndUpdateProvider(context, serverDiffs, mSource.getImageUrl(feedType, syncId, thumbWidth, thumbHeight), Five.makeArtistPhotoUri(id), localFeedItemUri, Five.Music.Artists.PHOTO); } else if (feedType.equals(FEED_ALBUMS)) { downloadFileAndUpdateProvider(context, serverDiffs, mSource.getImageUrl(feedType, syncId, thumbWidth, thumbHeight), Five.makeAlbumArtworkUri(id), localFeedItemUri, Five.Music.Albums.ARTWORK); downloadFileAndUpdateProvider(context, serverDiffs, mSource.getImageUrl(feedType, syncId, fullWidth, fullHeight), Five.makeAlbumArtworkBigUri(id), localFeedItemUri, Five.Music.Albums.ARTWORK_BIG); } } catch (IOException e) { markErrorUnlessCanceled(context, e); } } } finally { newRecords.close(); } }
From source file:org.xbmc.kore.ui.sections.video.TVShowEpisodeDetailsFragment.java
@Override protected View createView(LayoutInflater inflater, ViewGroup container) { tvshowId = getArguments().getInt(TVSHOWID, -1); episodeId = getArguments().getInt(EPISODEID, -1); if (episodeId == -1) { // There's nothing to show return null; }//from www .j a v a 2 s . co m ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_episode_details, container, false); ButterKnife.inject(this, root); //UIUtils.setSwipeRefreshLayoutColorScheme(swipeRefreshLayout); // Setup dim the fanart when scroll changes. Full dim on 4 * iconSize dp Resources resources = getActivity().getResources(); final int pixelsToTransparent = 4 * resources.getDimensionPixelSize(R.dimen.default_icon_size); mediaPanel.getViewTreeObserver().addOnScrollChangedListener(new ViewTreeObserver.OnScrollChangedListener() { @Override public void onScrollChanged() { float y = mediaPanel.getScrollY(); float newAlpha = Math.min(1, Math.max(0, 1 - (y / pixelsToTransparent))); mediaArt.setAlpha(newAlpha); } }); FloatingActionButton fab = (FloatingActionButton) fabButton; fab.attachToScrollView((ObservableScrollView) mediaPanel); // Pad main content view to overlap with bottom system bar // UIUtils.setPaddingForSystemBars(getActivity(), mediaPanel, false, false, true); // mediaPanel.setClipToPadding(false); return root; }
From source file:com.dwdesign.tweetings.adapter.CursorStatusesAdapter.java
@Override public void bindView(final View view, final Context context, final Cursor cursor) { final int position = cursor.getPosition(); StatusViewHolder holder = (StatusViewHolder) view.getTag(); // Clear images in prder to prevent images in recycled view shown. holder.profile_image.setImageDrawable(null); holder.image_preview.setImageDrawable(null); final boolean is_gap = cursor.getShort(mIndices.is_gap) == 1; final boolean show_gap = is_gap && !mGapDisallowed; holder.setShowAsGap(show_gap);//from w ww .ja va2 s . c o m final long account_id = cursor.getLong(mIndices.account_id); holder.setAccountColorEnabled(mShowAccountColor); if (mShowAccountColor) { holder.setAccountColor(getAccountColor(mContext, account_id)); } if (!show_gap) { final String retweeted_by = mDisplayName ? cursor.getString(mIndices.retweeted_by_name) : cursor.getString(mIndices.retweeted_by_screen_name); final String text = cursor.getString(mIndices.text); final String screen_name = cursor.getString(mIndices.screen_name); final String display_name = mDisplayName ? cursor.getString(mIndices.name) : screen_name; final String name = cursor.getString(mIndices.name); final String in_reply_to_screen_name = cursor.getString(mIndices.in_reply_to_screen_name); final long user_id = cursor.getLong(mIndices.user_id); final long status_id = cursor.getLong(mIndices.status_id); final long status_timestamp = cursor.getLong(mIndices.status_timestamp); final long retweet_count = cursor.getLong(mIndices.retweet_count); final boolean is_favorite = cursor.getShort(mIndices.is_favorite) == 1; final boolean is_protected = cursor.getShort(mIndices.is_protected) == 1; final boolean is_verified = cursor.getShort(mIndices.is_verified) == 1; final boolean has_location = !isNullOrEmpty(cursor.getString(mIndices.location)); final boolean is_retweet = !isNullOrEmpty(retweeted_by) && cursor.getShort(mIndices.is_retweet) == 1; final boolean is_reply = !isNullOrEmpty(in_reply_to_screen_name) && cursor.getLong(mIndices.in_reply_to_status_id) > 0; if (mMultiSelectEnabled) { holder.setSelected(mSelectedStatusIds.contains(status_id)); } else { holder.setSelected(false); } if (!mFastProcessingEnabled) { boolean is_mine = false; if (account_id > 0 && screen_name != null && mContext != null && getAccountUsername(mContext, account_id) != null && getAccountUsername(mContext, account_id).equals(screen_name)) { is_mine = true; } holder.setUserColor(getUserColor(mContext, user_id)); if (text != null) { holder.setHighlightColor( getStatusBackground( mMentionsHighlightDisabled ? false : text.toLowerCase().contains( '@' + getAccountUsername(mContext, account_id).toLowerCase()), is_favorite, is_retweet, is_mine)); } } else { holder.setUserColor(Color.TRANSPARENT); holder.setHighlightColor(Color.TRANSPARENT); } final PreviewImage preview = getPreviewImage(text, mInlineImagePreviewDisplayOption); //final PreviewImage preview = !mFastProcessingEnabled || mDisplayImagePreview ? getPreviewImage(text, //mDisplayImagePreview) : null; final boolean has_media = preview != null ? preview.has_image : false; holder.setTextSize(mTextSize); if (mShowLinks) { holder.text.setText(Html.fromHtml(text)); final TwidereLinkify linkify = new TwidereLinkify(holder.text); linkify.setOnLinkClickListener(new OnLinkClickHandler(context, account_id)); linkify.addAllLinks(); } else { holder.text.setText(unescape(text)); } holder.text.setMovementMethod(null); /*if (mShowLinks) { holder.text.setText(TwidereLinkify.twitterifyText(account_id, mContext, text)); holder.text.setMovementMethod(LinkMovementMethod.getInstance()); holder.text.setLinksClickable(false); holder.text.setTag(position); holder.text.setOnClickListener(this); holder.text.setOnLongClickListener(this); } else { holder.text.setText(unescape(text)); }*/ //holder.name.setCompoundDrawablesWithIntrinsicBounds(getUserTypeIconRes(is_verified, is_protected), 0, 0, 0); if (mDisplayNameBoth) { holder.name.setText(name); if (holder.name2 != null) { holder.name2.setText("@" + screen_name); } } else { holder.name.setText(display_name); } if (holder.name2 != null) { holder.name2.setVisibility(mDisplayNameBoth ? View.VISIBLE : View.GONE); } if (mShowAbsoluteTime) { holder.time.setText(formatSameDayTime(context, status_timestamp)); } else { holder.time.setText(getRelativeTimeSpanString(status_timestamp)); } holder.time.setCompoundDrawablesWithIntrinsicBounds(0, 0, getStatusTypeIconRes(is_favorite, has_location, has_media), 0); holder.reply_retweet_status.setVisibility(is_retweet || is_reply ? View.VISIBLE : View.GONE); if (is_retweet) { holder.reply_retweet_status.setText(retweet_count > 1 ? mContext.getString(R.string.retweeted_by_with_count, retweeted_by, retweet_count - 1) : mContext.getString(R.string.retweeted_by, retweeted_by)); holder.reply_retweet_status.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_indicator_retweet, 0, 0, 0); } else if (is_reply) { holder.reply_retweet_status .setText(mContext.getString(R.string.in_reply_to, in_reply_to_screen_name)); holder.reply_retweet_status.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_indicator_reply, 0, 0, 0); } holder.profile_image.setVisibility(mDisplayProfileImage ? View.VISIBLE : View.GONE); if (mDisplayProfileImage) { final String profile_image_url_string = cursor.getString(mIndices.profile_image_url); if (mDisplayHiResProfileImage) { mLazyImageLoader.displayProfileImage(holder.profile_image, getBiggerTwitterProfileImage(profile_image_url_string)); } else { mLazyImageLoader.displayProfileImage(holder.profile_image, profile_image_url_string); } holder.profile_image.setTag(position); } final boolean has_preview = mInlineImagePreviewDisplayOption != INLINE_IMAGE_PREVIEW_DISPLAY_OPTION_CODE_NONE && has_media && preview.matched_url != null; holder.image_preview_frame.setVisibility(has_preview ? View.VISIBLE : View.GONE); if (has_preview) { final MarginLayoutParams lp = (MarginLayoutParams) holder.image_preview_frame.getLayoutParams(); if (mInlineImagePreviewDisplayOption == INLINE_IMAGE_PREVIEW_DISPLAY_OPTION_CODE_LARGE || mInlineImagePreviewDisplayOption == INLINE_IMAGE_PREVIEW_DISPLAY_OPTION_CODE_LARGE_HIGH) { lp.width = LayoutParams.MATCH_PARENT; lp.leftMargin = 0; holder.image_preview_frame.setLayoutParams(lp); } else if (mInlineImagePreviewDisplayOption == INLINE_IMAGE_PREVIEW_DISPLAY_OPTION_CODE_SMALL) { final Resources res = mContext.getResources(); lp.width = res.getDimensionPixelSize(R.dimen.image_preview_width); lp.leftMargin = (int) (mDensity * 16); holder.image_preview_frame.setLayoutParams(lp); } final boolean is_possibly_sensitive = cursor.getInt(mIndices.is_possibly_sensitive) == 1; if (is_possibly_sensitive && !mDisplaySensitiveContents) { holder.image_preview.setImageResource(R.drawable.image_preview_nsfw); } else { mLazyImageLoader.displayPreviewImage(holder.image_preview, preview.matched_url); } holder.image_preview_frame.setTag(position); } } super.bindView(view, context, cursor); }
From source file:org.tomahawk.tomahawk_android.fragments.ContentHeaderFragment.java
private void setupFancyDropDownAnimation(final View view) { if (view != null) { final FancyDropDown fancyDropDown = (FancyDropDown) view.findViewById(R.id.fancydropdown); if (fancyDropDown != null) { final Runnable r = new Runnable() { @Override/* w w w . j av a2s.c o m*/ public void run() { // get resources first Resources resources = TomahawkApp.getContext().getResources(); int dropDownHeight = resources.getDimensionPixelSize(R.dimen.show_context_menu_icon_height); int actionBarHeight = resources .getDimensionPixelSize(R.dimen.abc_action_bar_default_height_material); int smallPadding = resources.getDimensionPixelSize(R.dimen.padding_small); int superLargePadding = resources.getDimensionPixelSize(R.dimen.padding_superlarge); // now calculate the animation goal and instantiate the animation int initialX = view.getWidth() / 2 - fancyDropDown.getWidth() / 2; int initialY = view.getHeight() / 2 - dropDownHeight / 2; PropertyValuesHolder pvhX = PropertyValuesHolder.ofFloat("x", initialX, superLargePadding); PropertyValuesHolder pvhY = PropertyValuesHolder.ofFloat("y", initialY, actionBarHeight + smallPadding); ValueAnimator animator = ObjectAnimator.ofPropertyValuesHolder(fancyDropDown, pvhX, pvhY) .setDuration(10000); animator.setInterpolator(new LinearInterpolator()); addAnimator(ANIM_FANCYDROPDOWN_ID, animator); refreshAnimations(); } }; r.run(); fancyDropDown.setOnSizeChangedListener(new OnSizeChangedListener() { @Override public void onSizeChanged(int w, int h, int oldw, int oldh) { r.run(); } }); } } }
From source file:com.example.mapsample.view.ActionSheet.java
public int getNavBarHeight(Context context) { int navigationBarHeight = 0; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { Resources rs = context.getResources(); int id = rs.getIdentifier("navigation_bar_height", "dimen", "android"); if (id > 0 && checkDeviceHasNavigationBar(context)) { navigationBarHeight = rs.getDimensionPixelSize(id); }//from w w w . j a v a2 s .co m } return navigationBarHeight; }
From source file:org.catnut.adapter.TweetAdapter.java
/** * used for a specific user' s timeline. * * @param context//from www .j ava 2s .co m * @param screenName user' s timeline' s screen name, * may null if no user specific or the current user */ public TweetAdapter(Context context, @Nullable String screenName) { super(context, null, 0); CatnutApp app = CatnutApp.getTingtingApp(); mContext = context; mInflater = LayoutInflater.from(context); mRequestQueue = app.getRequestQueue(); SharedPreferences preferences = app.getPreferences(); mImageSpan = new TweetImageSpan(context); mScreenWidth = CatnutUtils.getScreenWidth(context); Resources resources = context.getResources(); int maxThumbsWidth = resources.getDimensionPixelSize(R.dimen.max_thumb_width); if (mScreenWidth < maxThumbsWidth) { mScreenWidth = maxThumbsWidth; } ThumbsOption.injectAliases(resources); mThumbsOption = ThumbsOption.obtainOption(preferences.getString( resources.getString(R.string.pref_thumbs_options), resources.getString(R.string.thumb_small))); mCustomizedFontSize = CatnutUtils.resolveListPrefInt(preferences, context.getString(R.string.pref_tweet_font_size), resources.getInteger(R.integer.default_tweet_font_size)); mCustomizedFont = CatnutUtils.getTypeface(preferences, context.getString(R.string.pref_customize_tweet_font), context.getString(R.string.default_typeface)); mStayInLatest = preferences.getBoolean(context.getString(R.string.pref_keep_latest), true); mCustomizedLineSpacing = CatnutUtils.getLineSpacing(preferences, context.getString(R.string.pref_line_spacing), context.getString(R.string.default_line_spacing)); this.mScreenName = screenName; // register preference changed listener // todo: unregister? preferences.registerOnSharedPreferenceChangeListener(this); }
From source file:org.xbmc.kore.ui.AbstractInfoFragment.java
@TargetApi(21) @Nullable// w w w .ja va2s.c om @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (container == null) { // We're not being shown or there's nothing to show return null; } ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_info, container, false); ButterKnife.inject(this, root); // Setup dim the fanart when scroll changes. Full dim on 4 * iconSize dp Resources resources = getActivity().getResources(); final int pixelsToTransparent = 4 * resources.getDimensionPixelSize(R.dimen.default_icon_size); panelScrollView.getViewTreeObserver() .addOnScrollChangedListener(new ViewTreeObserver.OnScrollChangedListener() { @Override public void onScrollChanged() { float y = panelScrollView.getScrollY(); float newAlpha = Math.min(1, Math.max(0, 1 - (y / pixelsToTransparent))); artImageView.setAlpha(newAlpha); } }); DataHolder dataHolder = getDataHolder(); if (!dataHolder.getSquarePoster()) { posterImageView.getLayoutParams().width = resources .getDimensionPixelSize(R.dimen.detail_poster_width_nonsquare); posterImageView.getLayoutParams().height = resources .getDimensionPixelSize(R.dimen.detail_poster_height_nonsquare); } if (getRefreshItem() != null) { swipeRefreshLayout.setOnRefreshListener(this); } else { swipeRefreshLayout.setEnabled(false); } FloatingActionButton fab = (FloatingActionButton) fabButton; fab.attachToScrollView((ObservableScrollView) panelScrollView); if (Utils.isLollipopOrLater()) { posterImageView.setTransitionName(dataHolder.getPosterTransitionName()); } if (savedInstanceState == null) { FragmentManager fragmentManager = getChildFragmentManager(); Fragment fragment = fragmentManager.findFragmentById(R.id.media_additional_info); if (fragment == null) { fragment = getAdditionalInfoFragment(); if (fragment != null) { fragmentManager.beginTransaction().add(R.id.media_additional_info, fragment).commit(); } } } if (setupMediaActionBar()) { mediaActionsBar.setVisibility(View.VISIBLE); } if (setupFAB(fabButton)) { fabButton.setVisibility(View.VISIBLE); } updateView(dataHolder); return root; }
From source file:com.google.android.apps.gutenberg.ScannerActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_scanner); // Resources//from w ww . j a v a 2 s. c o m final Resources resources = getResources(); mColorTabSelected = resources.getColor(R.color.tab_selected); mColorTabUnselected = resources.getColor(R.color.tab_unselected); mColorTabIndicator = resources.getColor(R.color.primary_dark); mToolbarElevation = resources.getDimensionPixelSize(R.dimen.toolbar_elevation); GutenbergApplication app = GutenbergApplication.from(this); mImageLoader = new ImageLoader(app.getRequestQueue(), app.getBitmapCache()); // Set up the Toolbar Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); // Set up the Fragments if (savedInstanceState == null) { getSupportFragmentManager().beginTransaction().replace(R.id.scanner, ScannerFragment.newInstance()) .replace(R.id.event_selector, EventSelectionFragment.newInstance()).commit(); } // Set up the ViewPager mPanelLayout = (RecyclerViewSlidingUpPanelLayout) findViewById(R.id.layout); mTabLayout = (TabLayout) findViewById(R.id.tabs); mTabLayout.getViewTreeObserver().addOnGlobalLayoutListener(mTabLayoutListener); mViewPager = (DrawerViewPager) findViewById(R.id.pager); mAdapter = new ScannerPagerAdapter(getSupportFragmentManager(), this); mViewPager.setAdapter(mAdapter); mTabLayout.addTabsFromPagerAdapter(mAdapter); int tabCount = mAdapter.getCount(); mTabs = new AppCompatTextView[tabCount]; LayoutInflater inflater = LayoutInflater.from(this); for (int i = 0; i < tabCount; i++) { mTabs[i] = (AppCompatTextView) inflater.inflate(R.layout.tab, mTabLayout, false); mTabs[i].setText(mAdapter.getPageTitle(i)); mTabLayout.getTabAt(i).setCustomView(mTabs[i]); } mTabLayout.setOnTabSelectedListener(new TabLayout.OnTabSelectedListener() { @Override public void onTabSelected(TabLayout.Tab tab) { mViewPager.setCurrentItem(tab.getPosition(), true); mTabs[tab.getPosition()].setTextColor(mColorTabSelected); } @Override public void onTabUnselected(TabLayout.Tab tab) { mTabs[tab.getPosition()].setTextColor(mColorTabUnselected); } @Override public void onTabReselected(TabLayout.Tab tab) { } }); mPanelLayout.setPanelSlideListener(mPanelSlideListener); mViewPager.setPageMargin((int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, VIEW_PAGER_PAGE_MARGIN, resources.getDisplayMetrics())); mViewPager.setPageMarginDrawable(resources.getDrawable(R.drawable.page_margin)); final ViewPager.OnPageChangeListener onPageChangeListener = mTabLayout.createOnPageChangeListener(); mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { onPageChangeListener.onPageScrolled(position, positionOffset, positionOffsetPixels); } @Override public void onPageSelected(int position) { onPageChangeListener.onPageSelected(position); mPanelLayout.setRecyclerView(mAdapter.getItem(position).getRecyclerView()); } }); mAdapter.getItem(mViewPager.getCurrentItem()) .setOnRecyclerViewReadyListener(new RecyclerViewFragment.OnRecyclerViewReadyListener() { @Override public void onRecyclerViewReady(RecyclerView rv) { mPanelLayout.setRecyclerView(rv); } }); mViewPager.setOnClickListenerWhenClosed(new View.OnClickListener() { @Override public void onClick(View v) { mPanelLayout.setPanelState(SlidingUpPanelLayout.PanelState.EXPANDED); } }); }
From source file:org.indonesiax.mobile.view.custom.popup.menu.MenuPopupHelper.java
public MenuPopupHelper(Context context, MenuBuilder menu, View anchorView, boolean overflowOnly, int popupStyleAttr, int popupStyleRes) { mContext = context;/* ww w .j av a 2 s .c om*/ mInflater = LayoutInflater.from(context); mMenu = menu; mAdapter = new MenuAdapter(); mOverflowOnly = overflowOnly; mPopupStyleAttr = popupStyleAttr; mPopupStyleRes = popupStyleRes; final Resources res = context.getResources(); mPopupMaxWidth = Math.max(res.getDisplayMetrics().widthPixels / 2, res.getDimensionPixelSize(android.support.v7.appcompat.R.dimen.abc_config_prefDialogWidth)); TypedArray a = context.obtainStyledAttributes(null, R.styleable.PopupMenu, mPopupStyleAttr, mPopupStyleRes); mPopupMinWidth = a.getDimensionPixelSize(R.styleable.PopupMenu_android_minWidth, 0); int popupPadding = a.getDimensionPixelSize(R.styleable.PopupMenu_android_padding, -1); if (popupPadding >= 0) { mPopupPaddingStart = popupPadding; mPopupPaddingEnd = popupPadding; mPopupPaddingTop = popupPadding; mPopupPaddingBottom = popupPadding; } else { mPopupPaddingStart = a.getDimensionPixelSize(R.styleable.PopupMenu_android_paddingStart, a.getDimensionPixelOffset(R.styleable.PopupMenu_android_paddingLeft, 0)); mPopupPaddingEnd = a.getDimensionPixelSize(R.styleable.PopupMenu_android_paddingEnd, a.getDimensionPixelOffset(R.styleable.PopupMenu_android_paddingRight, 0)); mPopupPaddingTop = a.getDimensionPixelSize(R.styleable.PopupMenu_android_paddingTop, 0); mPopupPaddingBottom = a.getDimensionPixelSize(R.styleable.PopupMenu_android_paddingBottom, 0); } mPopupItemVerticalPadding = a.getDimensionPixelSize(R.styleable.PopupMenu_itemVerticalPadding, 0); mPopupIconPadding = a.getDimensionPixelSize(R.styleable.PopupMenu_iconPadding, 0); mPopupIconDefaultSize = a.getDimensionPixelSize(R.styleable.PopupMenu_iconDefaultSize, 0); mPopupHeaderTextAppearance = a.getResourceId(R.styleable.PopupMenu_headerTextAppearance, -1); mPopupRowTextAppearance = a.getResourceId(R.styleable.PopupMenu_rowTextAppearance, -1); a.recycle(); mAnchorView = anchorView; // Present the menu using our context, not the menu builder's context. menu.addMenuPresenter(this, context); }
From source file:com.syncedsynapse.kore2.ui.TVShowEpisodeDetailsFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { tvshowId = getArguments().getInt(TVSHOWID, -1); episodeId = getArguments().getInt(EPISODEID, -1); if ((container == null) || (episodeId == -1)) { // We're not being shown or there's nothing to show return null; }/*from w w w .j a va2 s . co m*/ ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_episode_details, container, false); ButterKnife.inject(this, root); bus = EventBus.getDefault(); hostManager = HostManager.getInstance(getActivity()); hostInfo = hostManager.getHostInfo(); swipeRefreshLayout.setOnRefreshListener(this); //UIUtils.setSwipeRefreshLayoutColorScheme(swipeRefreshLayout); // Setup dim the fanart when scroll changes. Full dim on 4 * iconSize dp Resources resources = getActivity().getResources(); final int pixelsToTransparent = 4 * resources.getDimensionPixelSize(R.dimen.default_icon_size); mediaPanel.getViewTreeObserver().addOnScrollChangedListener(new ViewTreeObserver.OnScrollChangedListener() { @Override public void onScrollChanged() { float y = mediaPanel.getScrollY(); float newAlpha = Math.min(1, Math.max(0, 1 - (y / pixelsToTransparent))); mediaArt.setAlpha(newAlpha); } }); FloatingActionButton fab = (FloatingActionButton) fabButton; fab.attachToScrollView((ObservableScrollView) mediaPanel); // Pad main content view to overlap with bottom system bar // UIUtils.setPaddingForSystemBars(getActivity(), mediaPanel, false, false, true); // mediaPanel.setClipToPadding(false); return root; }