use of android.support.v7.app.ActionBar.LayoutParams in project Tusky by Vavassor.
the class ComposeActivity method addMediaToQueue.
private void addMediaToQueue(QueuedMedia.Type type, Bitmap preview, Uri uri, long mediaSize) {
final QueuedMedia item = new QueuedMedia(type, uri, new ImageView(this), mediaSize);
ImageView view = item.preview;
Resources resources = getResources();
int side = resources.getDimensionPixelSize(R.dimen.compose_media_preview_side);
int margin = resources.getDimensionPixelSize(R.dimen.compose_media_preview_margin);
int marginBottom = resources.getDimensionPixelSize(R.dimen.compose_media_preview_margin_bottom);
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(side, side);
layoutParams.setMargins(margin, 0, margin, marginBottom);
view.setLayoutParams(layoutParams);
view.setScaleType(ImageView.ScaleType.CENTER_CROP);
view.setImageBitmap(preview);
view.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
removeMediaFromQueue(item);
}
});
mediaPreviewBar.addView(view);
mediaQueued.add(item);
int queuedCount = mediaQueued.size();
if (queuedCount == 1) {
/* The media preview bar is actually not inset in the EditText, it just overlays it and
* is aligned to the bottom. But, so that text doesn't get hidden under it, extra
* padding is added at the bottom of the EditText. */
int totalHeight = side + margin + marginBottom;
textEditor.setPadding(textEditor.getPaddingLeft(), textEditor.getPaddingTop(), textEditor.getPaddingRight(), totalHeight);
// If there's one video in the queue it is full, so disable the button to queue more.
if (item.type == QueuedMedia.Type.VIDEO) {
disableMediaButtons();
}
} else if (queuedCount >= Status.MAX_MEDIA_ATTACHMENTS) {
// Limit the total media attachments, also.
disableMediaButtons();
}
if (queuedCount >= 1) {
showMarkSensitive(true);
}
waitForMediaLatch.countUp();
if (mediaSize > STATUS_MEDIA_SIZE_LIMIT && type == QueuedMedia.Type.IMAGE) {
downsizeMedia(item);
} else {
uploadMedia(item);
}
}
use of android.support.v7.app.ActionBar.LayoutParams in project BaseRecyclerViewAdapterHelper by CymChad.
the class BaseQuickAdapter method addHeaderView.
/**
* @param header
* @param index
* @param orientation
*/
public int addHeaderView(View header, int index, int orientation) {
if (mHeaderLayout == null) {
mHeaderLayout = new LinearLayout(header.getContext());
if (orientation == LinearLayout.VERTICAL) {
mHeaderLayout.setOrientation(LinearLayout.VERTICAL);
mHeaderLayout.setLayoutParams(new LayoutParams(MATCH_PARENT, WRAP_CONTENT));
} else {
mHeaderLayout.setOrientation(LinearLayout.HORIZONTAL);
mHeaderLayout.setLayoutParams(new LayoutParams(WRAP_CONTENT, MATCH_PARENT));
}
}
final int childCount = mHeaderLayout.getChildCount();
if (index < 0 || index > childCount) {
index = childCount;
}
mHeaderLayout.addView(header, index);
if (mHeaderLayout.getChildCount() == 1) {
int position = getHeaderViewPosition();
if (position != -1) {
notifyItemInserted(position);
}
}
return index;
}
use of android.support.v7.app.ActionBar.LayoutParams in project BaseRecyclerViewAdapterHelper by CymChad.
the class BaseQuickAdapter method setEmptyView.
public void setEmptyView(View emptyView) {
boolean insert = false;
if (mEmptyLayout == null) {
mEmptyLayout = new FrameLayout(emptyView.getContext());
final LayoutParams layoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
final ViewGroup.LayoutParams lp = emptyView.getLayoutParams();
if (lp != null) {
layoutParams.width = lp.width;
layoutParams.height = lp.height;
}
mEmptyLayout.setLayoutParams(layoutParams);
insert = true;
}
mEmptyLayout.removeAllViews();
mEmptyLayout.addView(emptyView);
mIsUseEmpty = true;
if (insert) {
if (getEmptyViewCount() == 1) {
int position = 0;
if (mHeadAndEmptyEnable && getHeaderLayoutCount() != 0) {
position++;
}
notifyItemInserted(position);
}
}
}
use of android.support.v7.app.ActionBar.LayoutParams in project AndroidChromium by JackyAndroid.
the class NewTabPageView method initialize.
/**
* Initializes the NTP. This must be called immediately after inflation, before this object is
* used in any other way.
*
* @param manager NewTabPageManager used to perform various actions when the user interacts
* with the page.
* @param searchProviderHasLogo Whether the search provider has a logo.
* @param scrollPosition The adapter scroll position to initialize to.
*/
public void initialize(NewTabPageManager manager, boolean searchProviderHasLogo, int scrollPosition) {
mManager = manager;
mUiConfig = new UiConfig(this);
ViewStub stub = (ViewStub) findViewById(R.id.new_tab_page_layout_stub);
mUseCardsUi = manager.getSuggestionsSource() != null;
if (mUseCardsUi) {
stub.setLayoutResource(R.layout.new_tab_page_recycler_view);
mRecyclerView = (NewTabPageRecyclerView) stub.inflate();
// Don't attach now, the recyclerView itself will determine when to do it.
mNewTabPageLayout = (NewTabPageLayout) LayoutInflater.from(getContext()).inflate(R.layout.new_tab_page_layout, mRecyclerView, false);
mNewTabPageLayout.setUseCardsUiEnabled(mUseCardsUi);
mRecyclerView.setAboveTheFoldView(mNewTabPageLayout);
// Tailor the LayoutParams for the snippets UI, as the configuration in the XML is
// made for the ScrollView UI.
ViewGroup.LayoutParams params = mNewTabPageLayout.getLayoutParams();
params.height = ViewGroup.LayoutParams.WRAP_CONTENT;
mRecyclerView.setItemAnimator(new DefaultItemAnimator() {
@Override
public void onAnimationFinished(ViewHolder viewHolder) {
super.onAnimationFinished(viewHolder);
// When removing sections, because the animations are all translations, the
// scroll events don't fire and we can get in the situation where the toolbar
// buttons disappear.
updateSearchBoxOnScroll();
}
});
} else {
stub.setLayoutResource(R.layout.new_tab_page_scroll_view);
mScrollView = (NewTabPageScrollView) stub.inflate();
mScrollView.setBackgroundColor(NtpStyleUtils.getBackgroundColorResource(getResources(), false));
mScrollView.enableBottomShadow(SHADOW_COLOR);
mNewTabPageLayout = (NewTabPageLayout) findViewById(R.id.ntp_content);
}
mMostVisitedDesign = new MostVisitedDesign(getContext());
mMostVisitedLayout = (MostVisitedLayout) mNewTabPageLayout.findViewById(R.id.most_visited_layout);
mMostVisitedDesign.initMostVisitedLayout(searchProviderHasLogo);
mSearchProviderLogoView = (LogoView) mNewTabPageLayout.findViewById(R.id.search_provider_logo);
mSearchBoxView = (ViewGroup) mNewTabPageLayout.findViewById(R.id.search_box);
mNoSearchLogoSpacer = mNewTabPageLayout.findViewById(R.id.no_search_logo_spacer);
initializeSearchBoxTextView();
initializeVoiceSearchButton();
initializeBottomToolbar();
mNewTabPageLayout.addOnLayoutChangeListener(this);
setSearchProviderHasLogo(searchProviderHasLogo);
mPendingLoadTasks++;
mManager.setMostVisitedURLsObserver(this, mMostVisitedDesign.getNumberOfTiles(searchProviderHasLogo));
// Set up snippets
if (mUseCardsUi) {
mNewTabPageAdapter = NewTabPageAdapter.create(mManager, mNewTabPageLayout, mUiConfig);
mRecyclerView.setAdapter(mNewTabPageAdapter);
mRecyclerView.scrollToPosition(scrollPosition);
if (CardsVariationParameters.isScrollBelowTheFoldEnabled()) {
int searchBoxHeight = NtpStyleUtils.getSearchBoxHeight(getResources());
mRecyclerView.getLinearLayoutManager().scrollToPositionWithOffset(mNewTabPageAdapter.getFirstHeaderPosition(), searchBoxHeight);
}
// Set up swipe-to-dismiss
ItemTouchHelper helper = new ItemTouchHelper(mNewTabPageAdapter.getItemTouchCallbacks());
helper.attachToRecyclerView(mRecyclerView);
mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
private boolean mScrolledOnce = false;
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
if (newState != RecyclerView.SCROLL_STATE_DRAGGING)
return;
RecordUserAction.record("MobileNTP.Snippets.Scrolled");
if (mScrolledOnce)
return;
mScrolledOnce = true;
NewTabPageUma.recordSnippetAction(NewTabPageUma.SNIPPETS_ACTION_SCROLLED);
}
});
initializeSearchBoxRecyclerViewScrollHandling();
} else {
initializeSearchBoxScrollHandling();
}
}
use of android.support.v7.app.ActionBar.LayoutParams in project android_frameworks_base by DirtyUnicorns.
the class NavBarTuner method inflatePreview.
private void inflatePreview(ViewGroup view) {
Display display = getActivity().getWindowManager().getDefaultDisplay();
boolean isRotated = display.getRotation() == Surface.ROTATION_90 || display.getRotation() == Surface.ROTATION_270;
Configuration config = new Configuration(getContext().getResources().getConfiguration());
boolean isPhoneLandscape = isRotated && (config.smallestScreenWidthDp < 600);
final float scale = isPhoneLandscape ? PREVIEW_SCALE_LANDSCAPE : PREVIEW_SCALE;
config.densityDpi = (int) (config.densityDpi * scale);
mPreview = (PreviewNavInflater) LayoutInflater.from(getContext().createConfigurationContext(config)).inflate(R.layout.nav_bar_tuner_inflater, view, false);
final ViewGroup.LayoutParams layoutParams = mPreview.getLayoutParams();
layoutParams.width = (int) ((isPhoneLandscape ? display.getHeight() : display.getWidth()) * scale);
// Not sure why, but the height dimen is not being scaled with the dp, set it manually
// for now.
layoutParams.height = (int) (layoutParams.height * scale);
if (isPhoneLandscape) {
int width = layoutParams.width;
layoutParams.width = layoutParams.height;
layoutParams.height = width;
}
view.addView(mPreview);
if (isRotated) {
mPreview.findViewById(R.id.rot0).setVisibility(View.GONE);
final View rot90 = mPreview.findViewById(R.id.rot90);
} else {
mPreview.findViewById(R.id.rot90).setVisibility(View.GONE);
final View rot0 = mPreview.findViewById(R.id.rot0);
}
}
Aggregations