use of android.support.v7.app.ActionBar.LayoutParams in project LeafPic by HoraApps.
the class SelectAlbumBuilder method setupDialog.
@Override
public void setupDialog(Dialog dialog, int style) {
super.setupDialog(dialog, style);
View contentView = View.inflate(getContext(), R.layout.select_folder_bottom_sheet, null);
final RecyclerView mRecyclerView = contentView.findViewById(R.id.folders);
final Spinner spinner = contentView.findViewById(R.id.storage_spinner);
currentFolderPath = contentView.findViewById(R.id.bottom_sheet_sub_title);
exploreModePanel = contentView.findViewById(R.id.ll_explore_mode_panel);
imgExploreMode = contentView.findViewById(R.id.toggle_hidden_icon);
theme = ThemeHelper.getInstanceLoaded(getContext());
sdCardPath = StorageHelper.getSdcardPath(getContext());
mRecyclerView.setLayoutManager(new GridLayoutManager(getContext(), 2));
mRecyclerView.addItemDecoration(new GridSpacingItemDecoration(2, Measure.pxToDp(3, getContext()), true));
adapter = new BottomSheetAlbumsAdapter();
mRecyclerView.setAdapter(adapter);
spinner.setAdapter(new VolumeSpinnerAdapter(contentView.getContext()));
spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> adapterView, View view, int pos, long l) {
switch(pos) {
case INTERNAL_STORAGE:
displayContentFolder(Environment.getExternalStorageDirectory());
break;
default:
// }
break;
}
}
@Override
public void onNothingSelected(AdapterView<?> adapterView) {
}
});
/**
*SET UP THEME*
*/
contentView.findViewById(R.id.rl_bottom_sheet_title).setBackgroundColor(theme.getPrimaryColor());
exploreModePanel.setBackgroundColor(theme.getPrimaryColor());
contentView.findViewById(R.id.ll_select_folder).setBackgroundColor(theme.getCardBackgroundColor());
theme.setColorScrollBarDrawable(ContextCompat.getDrawable(dialog.getContext(), R.drawable.ic_scrollbar));
mRecyclerView.setBackgroundColor(theme.getBackgroundColor());
fabDone = contentView.findViewById(R.id.fab_bottomsheet_done);
fabDone.setBackgroundTintList(ColorStateList.valueOf(theme.getAccentColor()));
fabDone.setImageDrawable(new IconicsDrawable(getContext()).icon(GoogleMaterial.Icon.gmd_done).color(Color.WHITE));
fabDone.setVisibility(exploreMode ? View.VISIBLE : View.GONE);
fabDone.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dismiss();
onFolderSelected.folderSelected(currentFolderPath.getText().toString());
}
});
((TextView) contentView.findViewById(R.id.bottom_sheet_title)).setText(title);
((ThemedIcon) contentView.findViewById(R.id.create_new_folder_icon)).setColor(theme.getIconColor());
contentView.findViewById(R.id.rl_create_new_folder).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
final EditText editText = new EditText(getContext());
AlertDialog insertTextDialog = AlertDialogsHelper.getInsertTextDialog(((ThemedActivity) getActivity()), editText, R.string.new_folder);
insertTextDialog.setButton(DialogInterface.BUTTON_POSITIVE, getString(R.string.ok_action).toUpperCase(), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
File folderPath = new File(currentFolderPath.getText().toString() + File.separator + editText.getText().toString());
if (folderPath.mkdir())
displayContentFolder(folderPath);
}
});
insertTextDialog.setButton(DialogInterface.BUTTON_NEGATIVE, getString(R.string.cancel).toUpperCase(), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
}
});
insertTextDialog.show();
}
});
contentView.findViewById(R.id.rl_bottom_sheet_title).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (!forzed) {
toggleExplorerMode(!exploreMode);
fabDone.setVisibility(exploreMode ? View.VISIBLE : View.GONE);
}
}
});
dialog.setContentView(contentView);
CoordinatorLayout.LayoutParams layoutParams = (CoordinatorLayout.LayoutParams) ((View) contentView.getParent()).getLayoutParams();
CoordinatorLayout.Behavior behavior = layoutParams.getBehavior();
if (behavior != null && behavior instanceof BottomSheetBehavior) {
((BottomSheetBehavior) behavior).setBottomSheetCallback(mBottomSheetBehaviorCallback);
}
adapter.notifyDataSetChanged();
toggleExplorerMode(exploreMode);
}
use of android.support.v7.app.ActionBar.LayoutParams in project RxTools by vondear.
the class AdapterRecyclerViewMain method onCreateViewHolder.
@Override
public AdapterRecyclerViewMain.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_recyclerview_main, parent, false);
context = view.getContext();
/* mScreenWidth = RxDeviceTool.getScreenWidth(context) > RxDeviceTool.getScreenHeight(context) ? RxDeviceTool.getScreenHeight(context) : RxDeviceTool.getScreenWidth(context);
mItemWidth = (mScreenWidth - 50) / 3;
mItemHeight = mItemWidth * 6 / 4;
GridLayoutManager.LayoutParams layoutParams = new GridLayoutManager.LayoutParams(mItemWidth, mItemHeight);
view.setLayoutParams(layoutParams);*/
return new ViewHolder(view);
}
use of android.support.v7.app.ActionBar.LayoutParams in project instructure-android by instructure.
the class CanvasEditTextView method initEditText.
// //////////////////////////////////////////////////////////////////////////////////////////////
// region View Layout Helpers
// //////////////////////////////////////////////////////////////////////////////////////////////
public static EditText initEditText(Context context, String hint, int hintColor, float textSize, int maxLines) {
final AppCompatEditText editText = new AppCompatEditText(context);
editText.setId(R.id.canvasEditText);
editText.setEnabled(true);
editText.setHint(hint);
editText.setHintTextColor(hintColor);
editText.setSingleLine(false);
editText.setMaxLines(maxLines);
editText.setVerticalScrollBarEnabled(true);
editText.setTextColor(context.getResources().getColor(R.color.canvasTextDark));
editText.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
editText.setRawInputType(editText.getInputType() | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES);
final int padding = context.getResources().getDimensionPixelOffset(R.dimen.canvas_edit_text_view_padding);
editText.setPadding(padding, 0, padding, 0);
ColorDrawable colorDrawable = new ColorDrawable(Color.TRANSPARENT);
editText.setBackgroundDrawable(colorDrawable);
RelativeLayout.LayoutParams editTextParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
editTextParams.addRule(RelativeLayout.END_OF, R.id.leftLayout);
editTextParams.addRule(RelativeLayout.START_OF, R.id.rightLayout);
editTextParams.addRule(RelativeLayout.CENTER_VERTICAL);
editText.setLayoutParams(editTextParams);
return editText;
}
use of android.support.v7.app.ActionBar.LayoutParams in project NiceMusic by lizixian18.
the class BannerLayout method initView.
protected void initView(Context context, AttributeSet attrs) {
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.RecyclerViewBannerBase);
showIndicator = a.getBoolean(R.styleable.RecyclerViewBannerBase_showIndicator, true);
autoPlayDuration = a.getInt(R.styleable.RecyclerViewBannerBase_interval, 10000);
isAutoPlaying = a.getBoolean(R.styleable.RecyclerViewBannerBase_autoPlaying, true);
mSelectedDrawable = a.getDrawable(R.styleable.RecyclerViewBannerBase_indicatorSelectedSrc);
mUnselectedDrawable = a.getDrawable(R.styleable.RecyclerViewBannerBase_indicatorUnselectedSrc);
if (mSelectedDrawable == null) {
// 绘制默认选中状态图形
GradientDrawable selectedGradientDrawable = new GradientDrawable();
selectedGradientDrawable.setShape(GradientDrawable.OVAL);
selectedGradientDrawable.setColor(getColor(R.color.colorAccent));
selectedGradientDrawable.setSize(dp2px(5), dp2px(5));
selectedGradientDrawable.setCornerRadius(dp2px(5) / 2);
mSelectedDrawable = new LayerDrawable(new Drawable[] { selectedGradientDrawable });
}
if (mUnselectedDrawable == null) {
// 绘制默认未选中状态图形
GradientDrawable unSelectedGradientDrawable = new GradientDrawable();
unSelectedGradientDrawable.setShape(GradientDrawable.OVAL);
unSelectedGradientDrawable.setColor(getColor(R.color.colorPrimaryDark));
unSelectedGradientDrawable.setSize(dp2px(5), dp2px(5));
unSelectedGradientDrawable.setCornerRadius(dp2px(5) / 2);
mUnselectedDrawable = new LayerDrawable(new Drawable[] { unSelectedGradientDrawable });
}
indicatorMargin = a.getDimensionPixelSize(R.styleable.RecyclerViewBannerBase_indicatorSpace, dp2px(4));
int marginLeft = a.getDimensionPixelSize(R.styleable.RecyclerViewBannerBase_indicatorMarginLeft, dp2px(16));
int marginRight = a.getDimensionPixelSize(R.styleable.RecyclerViewBannerBase_indicatorMarginRight, dp2px(0));
int marginBottom = a.getDimensionPixelSize(R.styleable.RecyclerViewBannerBase_indicatorMarginBottom, dp2px(11));
int g = a.getInt(R.styleable.RecyclerViewBannerBase_indicatorGravity, 0);
int gravity;
if (g == 0) {
gravity = GravityCompat.START;
} else if (g == 2) {
gravity = GravityCompat.END;
} else {
gravity = Gravity.CENTER;
}
int o = a.getInt(R.styleable.RecyclerViewBannerBase_orientation, 0);
int orientation = 0;
if (o == 0) {
orientation = OrientationHelper.HORIZONTAL;
} else if (o == 1) {
orientation = OrientationHelper.VERTICAL;
}
a.recycle();
// recyclerView部分
mRecyclerView = new RecyclerView(context);
LayoutParams vpLayoutParams = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
addView(mRecyclerView, vpLayoutParams);
mLayoutManager = new BannerLayoutManager(getContext(), orientation);
mRecyclerView.setLayoutManager(mLayoutManager);
new PagerSnapHelper().attachToRecyclerView(mRecyclerView);
// 指示器部分
indicatorContainer = new RecyclerView(context);
LinearLayoutManager indicatorLayoutManager = new LinearLayoutManager(context, orientation, false);
indicatorContainer.setLayoutManager(indicatorLayoutManager);
indicatorAdapter = new IndicatorAdapter();
indicatorContainer.setAdapter(indicatorAdapter);
LayoutParams params = new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
params.gravity = Gravity.BOTTOM | gravity;
params.setMargins(marginLeft, 0, marginRight, marginBottom);
addView(indicatorContainer, params);
if (!showIndicator) {
indicatorContainer.setVisibility(GONE);
}
}
use of android.support.v7.app.ActionBar.LayoutParams in project MTweaks-KernelAdiutorMOD by morogoku.
the class CardView method refresh.
@Override
protected void refresh() {
super.refresh();
if (mTitle != null) {
if (mTitleText != null) {
mTitle.setText(mTitleText);
mTitleParent.setVisibility(View.VISIBLE);
if (mLayoutParent != null) {
LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) mLayout.getLayoutParams();
layoutParams.topMargin = -mLayout.getPaddingLeft();
mLayout.requestLayout();
mLayout.setPadding(mLayout.getPaddingLeft(), 0, mLayout.getPaddingRight(), mLayout.getPaddingBottom());
}
} else {
mTitleParent.setVisibility(View.GONE);
}
}
if (mMenuButton != null && mOnMenuListener != null) {
mMenuButton.setVisibility(View.VISIBLE);
mPopupMenu = new PopupMenu(mMenuButton.getContext(), mMenuButton);
mOnMenuListener.onMenuReady(this, mPopupMenu);
}
if (mRootView != null && getOnItemClickListener() != null) {
mRootView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
getOnItemClickListener().onClick(CardView.this);
}
});
}
}
Aggregations