use of android.support.v7.widget.RecyclerView.LayoutParams in project SuperSLiM by TonicArtos.
the class LayoutManager method binarySearchForLastPosition.
private int binarySearchForLastPosition(int min, int max, int sfp) {
if (max < min) {
return -1;
}
int mid = min + (max - min) / 2;
View candidate = getChildAt(mid);
LayoutParams params = (LayoutParams) candidate.getLayoutParams();
if (params.getTestedFirstPosition() < sfp) {
return binarySearchForLastPosition(mid + 1, max, sfp);
}
if (params.getTestedFirstPosition() > sfp || params.isHeader) {
return binarySearchForLastPosition(min, mid - 1, sfp);
}
if (mid == getChildCount() - 1) {
return mid;
}
View next = getChildAt(mid + 1);
LayoutParams lp = (LayoutParams) next.getLayoutParams();
if (lp.getTestedFirstPosition() != sfp) {
return mid;
}
if (lp.isHeader) {
if (mid + 1 == getChildCount() - 1) {
return mid;
}
next = getChildAt(mid + 2);
lp = (LayoutParams) next.getLayoutParams();
if (lp.getTestedFirstPosition() != sfp) {
return mid;
}
}
return binarySearchForLastPosition(mid + 1, max, sfp);
}
use of android.support.v7.widget.RecyclerView.LayoutParams in project Small by wequick.
the class WebActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
int theme = Small.getWebActivityTheme();
if (theme != 0)
setTheme(theme);
boolean fullscreen = false;
CharSequence queryTitle;
Uri uri = Small.getUri(this);
if (uri != null) {
String param = uri.getQueryParameter("_fullscreen");
if (param != null) {
fullscreen = param.equals("1");
}
queryTitle = uri.getQueryParameter("_title");
if (queryTitle != null) {
super.setTitle(queryTitle);
mCanSetTitle = false;
}
}
// Init actionBar
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
if (fullscreen) {
actionBar.hide();
} else {
actionBar.show();
Activity parent = getParent();
if (parent == null) {
// If is created by a LocalActivityManager, parent is not null
actionBar.setDisplayHomeAsUpEnabled(true);
}
}
}
mFullscreen = fullscreen;
// Initialize content wrapper
RelativeLayout wrapper = new RelativeLayout(this);
wrapper.setGravity(Gravity.CENTER);
setContentView(wrapper);
// Initialize webView
mWebView = new WebView(this);
ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
wrapper.addView(mWebView, 0, layoutParams);
// Try to load title from cache
mUrl = getIntent().getStringExtra("url");
if (mCanSetTitle) {
CharSequence title = getCacheTitle(mUrl);
if (title != null) {
super.setTitle(title);
}
}
}
use of android.support.v7.widget.RecyclerView.LayoutParams in project MagicaSakura by Bilibili.
the class MainActivity method onCreate.
@Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setTitle(null);
RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recycler);
LinearLayoutManager layoutManager = new LinearLayoutManager(this);
layoutManager.setSmoothScrollbarEnabled(true);
assert recyclerView != null;
recyclerView.addItemDecoration(new RecyclerView.ItemDecoration() {
@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
final int padding = getResources().getDimensionPixelOffset(R.dimen.padding_half);
RecyclerView.LayoutParams layoutParams = (RecyclerView.LayoutParams) view.getLayoutParams();
final int position = layoutParams.getViewLayoutPosition();
if (position == 0) {
outRect.left = outRect.top = outRect.right = padding;
outRect.bottom = padding >> 1;
} else if (position == state.getItemCount() - 1) {
outRect.left = outRect.bottom = outRect.right = padding;
outRect.top = padding >> 1;
} else {
outRect.left = outRect.right = padding;
outRect.top = outRect.bottom = padding >> 1;
}
}
});
recyclerView.setLayoutManager(layoutManager);
Adapter adapter = new Adapter();
recyclerView.setAdapter(adapter);
adapter.addViewHolderType(ViewHolder.VIEW_HOLDER_HEADER, ViewHolder.VIEW_HOLDER_LABEL, ViewHolder.VIEW_HOLDER_HEADER, ViewHolder.VIEW_HOLDER_LOGIN, ViewHolder.VIEW_HOLDER_HEADER, ViewHolder.VIEW_HOLDER_DOWNLOAD);
}
use of android.support.v7.widget.RecyclerView.LayoutParams in project Atom_Android by Rogrand-Dev.
the class ShowImageAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(final ViewHolder holder, int position) {
//动态计算照片的宽度进行显示
RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) holder.imageView.getLayoutParams();
layoutParams.width = (DensityUtils.getScreenWidth(mContext) - DensityUtils.dp2px(mContext, 6) * 2) / 3;
layoutParams.height = layoutParams.width;
holder.imageView.setLayoutParams(layoutParams);
if (getItemViewType(position) == TYPE_SELECT) {
holder.imageView.setImageResource(R.drawable.ic_add_service_pic);
holder.imageView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (onItemControlListener != null) {
onItemControlListener.onItemControl(TYPE_SELECT, holder.getAdapterPosition());
}
}
});
holder.mDelete.setVisibility(View.GONE);
} else {
holder.mDelete.setVisibility(View.VISIBLE);
holder.mDelete.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (onItemControlListener != null) {
onItemControlListener.onItemControl(TYPE_SHOW, holder.getAdapterPosition());
}
}
});
LocalMedia media = mAllDatas.get(position);
String path = "";
if (media.isCut() && !media.isCompressed()) {
//裁剪过
path = media.getCutPath();
} else if (media.isCompressed() || (media.isCut() && media.isCompressed())) {
//压缩过,或者裁剪过后压缩过,以是否压缩为准
path = media.getCompressPath();
} else {
//原图
path = media.getPath();
}
int type = media.getType();
switch(type) {
case 1:
//图片
Glide.with(mContext).load(path).centerCrop().placeholder(R.drawable.ic_add_service_pic).diskCacheStrategy(DiskCacheStrategy.ALL).into(holder.imageView);
break;
case 2:
//视频
Glide.with(mContext).load(path).thumbnail(0.5f).into(holder.imageView);
break;
}
}
}
use of android.support.v7.widget.RecyclerView.LayoutParams in project HoloEverywhere by Prototik.
the class ActionBarContextView method initForMode.
public void initForMode(final ActionMode mode) {
if (mClose == null) {
LayoutInflater inflater = LayoutInflater.from(getContext());
mClose = inflater.inflate(R.layout.abc_action_mode_close_item, this, false);
addView(mClose);
} else if (mClose.getParent() == null) {
addView(mClose);
}
View closeButton = mClose.findViewById(R.id.action_mode_close_button);
closeButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
mode.finish();
}
});
final MenuBuilder menu = (MenuBuilder) mode.getMenu();
if (mActionMenuPresenter != null) {
mActionMenuPresenter.dismissPopupMenus();
}
mActionMenuPresenter = new ActionMenuPresenter(getContext());
mActionMenuPresenter.setReserveOverflow(true);
final ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.FILL_PARENT);
if (!mSplitActionBar) {
menu.addMenuPresenter(mActionMenuPresenter);
mMenuView = (ActionMenuView) mActionMenuPresenter.getMenuView(this);
mMenuView.setBackgroundDrawable(null);
addView(mMenuView, layoutParams);
} else {
// Allow full screen width in split mode.
mActionMenuPresenter.setWidthLimit(getContext().getResources().getDisplayMetrics().widthPixels, true);
// No limit to the item count; use whatever will fit.
mActionMenuPresenter.setItemLimit(Integer.MAX_VALUE);
// Span the whole width
layoutParams.width = ViewGroup.LayoutParams.FILL_PARENT;
layoutParams.height = mContentHeight;
menu.addMenuPresenter(mActionMenuPresenter);
mMenuView = (ActionMenuView) mActionMenuPresenter.getMenuView(this);
mMenuView.setBackgroundDrawable(mSplitBackground);
mSplitView.addView(mMenuView, layoutParams);
}
}
Aggregations