com.hippo.yorozuya.LayoutUtils Java Examples
The following examples show how to use
com.hippo.yorozuya.LayoutUtils.
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: TypeSendFragment.java From Nimingban with Apache License 2.0 | 6 votes |
private boolean handleSelectedImageUri(Uri uri) { if (uri == null) { return false; } ContentResolver resolver = getContext().getContentResolver(); String type = resolver.getType(uri); if (type == null) { type = MimeTypeMap.getSingleton().getMimeTypeFromExtension( FileUtils.getExtensionFromFilename(uri.toString())); } int maxSize = LayoutUtils.dp2pix(getContext(), 256); Bitmap bitmap = BitmapUtils.decodeStream(new UriInputStreamPipe(getContext(), uri), maxSize, maxSize); if (bitmap != null) { setImagePreview(uri, type, bitmap); return true; } return false; }
Example #2
Source File: SortForumsActivity.java From Nimingban with Apache License 2.0 | 6 votes |
private void showEyeGuide() { new GuideHelper.Builder(this) .setColor(ResourcesUtils.getAttrColor(this, R.attr.colorPrimary)) .setPadding(LayoutUtils.dp2pix(this, 16)) .setPaddingTop(LayoutUtils.dp2pix(this, 56)) .setPaddingBottom(LayoutUtils.dp2pix(this, 56)) .setMessagePosition(Gravity.LEFT) .setMessage(getString(R.string.click_eye_icon)) .setButton(getString(R.string.get_it)) .setBackgroundColor(0x73000000) .setOnDissmisListener(new View.OnClickListener() { @Override public void onClick(View v) { tryShowSecondGuide(); Settings.putGuideSortForumsActivity(false); } }).show(); }
Example #3
Source File: SortForumsActivity.java From Nimingban with Apache License 2.0 | 6 votes |
private void showFourBarsGuide() { new GuideHelper.Builder(this) .setColor(ResourcesUtils.getAttrColor(this, R.attr.colorPrimary)) .setPadding(LayoutUtils.dp2pix(this, 16)) .setPaddingTop(LayoutUtils.dp2pix(this, 56)) .setPaddingBottom(LayoutUtils.dp2pix(this, 56)) .setMessagePosition(Gravity.RIGHT) .setMessage(getString(R.string.drag_four_bars_exchange)) .setButton(getString(R.string.get_it)) .setBackgroundColor(0x73000000) .setOnDissmisListener(new View.OnClickListener() { @Override public void onClick(View v) { Settings.putGuideSortingFourBars(false); } }).show(); }
Example #4
Source File: SortForumsActivity.java From Nimingban with Apache License 2.0 | 6 votes |
private void showStarGuide() { new GuideHelper.Builder(this) .setColor(ResourcesUtils.getAttrColor(this, R.attr.colorPrimary)) .setPadding(LayoutUtils.dp2pix(this, 16)) .setPaddingTop(LayoutUtils.dp2pix(this, 56)) .setPaddingBottom(LayoutUtils.dp2pix(this, 56)) .setMessagePosition(Gravity.RIGHT) .setMessage(getString(R.string.click_star_icon_pin)) .setButton(getString(R.string.get_it)) .setBackgroundColor(0x73000000) .setOnDissmisListener(new View.OnClickListener() { @Override public void onClick(View v) { Settings.putGuidePinningStar(false); } }).show(); }
Example #5
Source File: SettingsActivity.java From Nimingban with Apache License 2.0 | 6 votes |
@SuppressLint("InflateParams") public TextFormatDialogHelper() { mView = getActivity().getLayoutInflater().inflate(R.layout.dialog_text_format, null); mPreview = (FontTextView) mView.findViewById(R.id.preview); mFontSize = (Slider) mView.findViewById(R.id.font_size); mLineSpacing = (Slider) mView.findViewById(R.id.line_spacing); int fontSize = Settings.getFontSize(); int lineSpacing = Settings.getLineSpacing(); mPreview.setTextSize(fontSize); mPreview.setLineSpacing(LayoutUtils.dp2pix(getActivity(), lineSpacing), 1.0f); if (Settings.getFixEmojiDisplay()) { mPreview.useCustomTypeface(); } else { mPreview.useOriginalTypeface(); } mFontSize.setProgress(fontSize); mLineSpacing.setProgress(lineSpacing); mFontSize.setOnSetProgressListener(this); mLineSpacing.setOnSetProgressListener(this); }
Example #6
Source File: ContentLayout.java From Nimingban with Apache License 2.0 | 6 votes |
private void init(ContentLayout contentLayout) { mNextPageScrollSize = LayoutUtils.dp2pix(contentLayout.getContext(), 48); mProgressView = contentLayout.mProgressView; mTipView = contentLayout.mTipView; mContentView = contentLayout.mContentView; mRefreshLayout = contentLayout.mRefreshLayout; mRecyclerView = contentLayout.mRecyclerView; mImageView = contentLayout.mImageView; mTextView = contentLayout.mTextView; mViewTransition = new ViewTransition(mContentView, mProgressView, mTipView); mViewTransition.showView(2, false); mRecyclerView.addOnScrollListener(mOnScrollListener); mRefreshLayout.setOnRefreshListener(mOnRefreshListener); mTipView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { refresh(); } }); }
Example #7
Source File: DoodleView.java From Nimingban with Apache License 2.0 | 6 votes |
private void init(Context context) { mBitmapPaint = new Paint(Paint.DITHER_FLAG | Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG); mBgColor = ResourcesUtils.getAttrColor(context, R.attr.colorPure); mColor = ResourcesUtils.getAttrColor(context, R.attr.colorPureInverse); mWidth = LayoutUtils.dp2pix(context, 4); mPath = new Path(); mPaint = new Paint(); mPaint.setAntiAlias(true); mPaint.setDither(true); mPaint.setStyle(Paint.Style.STROKE); mPaint.setStrokeJoin(Paint.Join.ROUND); mPaint.setStrokeCap(Paint.Cap.ROUND); mRecycler = new Recycler(); }
Example #8
Source File: IconListPreference.java From Nimingban with Apache License 2.0 | 6 votes |
@Override public View getView(int position, View convertView, ViewGroup parent) { if (convertView == null) { convertView = LayoutInflater.from(getContext()) .inflate(android.R.layout.simple_list_item_single_choice, parent, false); } TextView textView = (TextView) convertView; textView.setText(getEntries()[position]); Drawable icon = getContext().getResources().getDrawable(mEntryIcons[position]); if (icon != null) { icon.setBounds(0, 0, icon.getIntrinsicWidth(), icon.getIntrinsicHeight()); } textView.setCompoundDrawablePadding(LayoutUtils.dp2pix(getContext(), 16)); textView.setCompoundDrawables(icon, null, null, null); return convertView; }
Example #9
Source File: Slider.java From Nimingban with Apache License 2.0 | 6 votes |
private void updateBubbleSize() { int oldWidth = mBubbleWidth; int oldHeight = mBubbleHeight; mBubbleWidth = (int) Math.max(mBubbleMinWidth, Integer.toString(mEnd).length() * mCharWidth + LayoutUtils.dp2pix(mContext, 8)); mBubbleHeight = (int) Math.max(mBubbleMinHeight, mCharHeight + LayoutUtils.dp2pix(mContext, 8)); if (oldWidth != mBubbleWidth && oldHeight != mBubbleHeight) { //noinspection deprecation AbsoluteLayout.LayoutParams lp = (AbsoluteLayout.LayoutParams) mBubble.getLayoutParams(); lp.width = mBubbleWidth; lp.height = mBubbleHeight; mBubble.setLayoutParams(lp); } }
Example #10
Source File: Slider.java From Nimingban with Apache License 2.0 | 6 votes |
private void updatePopup() { int width = getWidth(); int paddingTop = getPaddingTop(); int paddingBottom = getPaddingBottom(); getLocationInWindow(mTemp); mPopupWidth = (int) (width - mRadius - mRadius + mBubbleWidth); int popupHeight = mBubbleHeight; mPopupX = (int) (mTemp[0] + mRadius - (mBubbleWidth / 2)); mPopupY = (int) (mTemp[1] - popupHeight + paddingTop + ((getHeight() - paddingTop - paddingBottom) / 2) - mRadius -LayoutUtils.dp2pix(mContext, 2)); mPopup.update(mPopupX, mPopupY, mPopupWidth, popupHeight, false); }
Example #11
Source File: ContentLayout.java From MHViewer with Apache License 2.0 | 6 votes |
private void init(ContentLayout contentLayout) { mNextPageScrollSize = LayoutUtils.dp2pix(contentLayout.getContext(), 48); mProgressView = contentLayout.mProgressView; mTipView = contentLayout.mTipView; mContentView = contentLayout.mContentView; mRefreshLayout = contentLayout.mRefreshLayout; mRecyclerView = contentLayout.mRecyclerView; Drawable drawable = DrawableManager.getVectorDrawable(getContext(), R.drawable.big_sad_pandroid); drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight()); mTipView.setCompoundDrawables(null, drawable, null, null); mViewTransition = new ViewTransition(mContentView, mProgressView, mTipView); mViewTransition.setOnShowViewListener(this); mRecyclerView.addOnScrollListener(mOnScrollListener); mRefreshLayout.setOnRefreshListener(mOnRefreshListener); mTipView.setOnClickListener(refreshListener); }
Example #12
Source File: GalleryInfoScene.java From EhViewer with Apache License 2.0 | 6 votes |
@SuppressWarnings("deprecation") @Nullable @Override public View onCreateView3(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View view = inflater.inflate(R.layout.scene_gallery_info, container, false); Context context = getContext2(); AssertUtils.assertNotNull(context); mRecyclerView = (EasyRecyclerView) ViewUtils.$$(view, R.id.recycler_view); InfoAdapter adapter = new InfoAdapter(); mRecyclerView.setAdapter(adapter); mRecyclerView.setLayoutManager(new LinearLayoutManager(context, RecyclerView.VERTICAL, false)); LinearDividerItemDecoration decoration = new LinearDividerItemDecoration( LinearDividerItemDecoration.VERTICAL, AttrResources.getAttrColor(context, R.attr.dividerColor), LayoutUtils.dp2pix(context, 1)); decoration.setPadding(context.getResources().getDimensionPixelOffset(R.dimen.keyline_margin)); mRecyclerView.addItemDecoration(decoration); mRecyclerView.setSelector(Ripple.generateRippleDrawable(context, !AttrResources.getAttrBoolean(context, R.attr.isLightTheme), new ColorDrawable(Color.TRANSPARENT))); mRecyclerView.setClipToPadding(false); mRecyclerView.setHasFixedSize(true); mRecyclerView.setOnItemClickListener(this); return view; }
Example #13
Source File: GalleryInfoScene.java From MHViewer with Apache License 2.0 | 6 votes |
@SuppressWarnings("deprecation") @Nullable @Override public View onCreateView3(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View view = inflater.inflate(R.layout.scene_gallery_info, container, false); Context context = getContext2(); AssertUtils.assertNotNull(context); mRecyclerView = (EasyRecyclerView) ViewUtils.$$(view, R.id.recycler_view); InfoAdapter adapter = new InfoAdapter(); mRecyclerView.setAdapter(adapter); mRecyclerView.setLayoutManager(new LinearLayoutManager(context, RecyclerView.VERTICAL, false)); LinearDividerItemDecoration decoration = new LinearDividerItemDecoration( LinearDividerItemDecoration.VERTICAL, AttrResources.getAttrColor(context, R.attr.dividerColor), LayoutUtils.dp2pix(context, 1)); decoration.setPadding(context.getResources().getDimensionPixelOffset(R.dimen.keyline_margin)); mRecyclerView.addItemDecoration(decoration); mRecyclerView.setSelector(Ripple.generateRippleDrawable(context, !AttrResources.getAttrBoolean(context, R.attr.isLightTheme), new ColorDrawable(Color.TRANSPARENT))); mRecyclerView.setClipToPadding(false); mRecyclerView.setHasFixedSize(true); mRecyclerView.setOnItemClickListener(this); return view; }
Example #14
Source File: Slider.java From MHViewer with Apache License 2.0 | 6 votes |
private void updatePopup() { int width = getWidth(); int paddingTop = getPaddingTop(); int paddingBottom = getPaddingBottom(); getLocationInWindow(mTemp); mPopupWidth = (int) (width - mRadius - mRadius + mBubbleWidth); int popupHeight = mBubbleHeight; mPopupX = (int) (mTemp[0] + mRadius - (mBubbleWidth / 2)); mPopupY = (int) (mTemp[1] - popupHeight + paddingTop + ((getHeight() - paddingTop - paddingBottom) / 2) - mRadius -LayoutUtils.dp2pix(mContext, 2)); mPopup.update(mPopupX, mPopupY, mPopupWidth, popupHeight, false); }
Example #15
Source File: Slider.java From EhViewer with Apache License 2.0 | 6 votes |
private void updatePopup() { int width = getWidth(); int paddingTop = getPaddingTop(); int paddingBottom = getPaddingBottom(); getLocationInWindow(mTemp); mPopupWidth = (int) (width - mRadius - mRadius + mBubbleWidth); int popupHeight = mBubbleHeight; mPopupX = (int) (mTemp[0] + mRadius - (mBubbleWidth / 2)); mPopupY = (int) (mTemp[1] - popupHeight + paddingTop + ((getHeight() - paddingTop - paddingBottom) / 2) - mRadius -LayoutUtils.dp2pix(mContext, 2)); mPopup.update(mPopupX, mPopupY, mPopupWidth, popupHeight, false); }
Example #16
Source File: Slider.java From MHViewer with Apache License 2.0 | 6 votes |
private void updateBubbleSize() { int oldWidth = mBubbleWidth; int oldHeight = mBubbleHeight; mBubbleWidth = (int) Math.max(mBubbleMinWidth, Integer.toString(mEnd).length() * mCharWidth + LayoutUtils.dp2pix(mContext, 8)); mBubbleHeight = (int) Math.max(mBubbleMinHeight, mCharHeight + LayoutUtils.dp2pix(mContext, 8)); if (oldWidth != mBubbleWidth && oldHeight != mBubbleHeight) { //noinspection deprecation AbsoluteLayout.LayoutParams lp = (AbsoluteLayout.LayoutParams) mBubble.getLayoutParams(); lp.width = mBubbleWidth; lp.height = mBubbleHeight; mBubble.setLayoutParams(lp); } }
Example #17
Source File: Slider.java From EhViewer with Apache License 2.0 | 6 votes |
private void updateBubbleSize() { int oldWidth = mBubbleWidth; int oldHeight = mBubbleHeight; mBubbleWidth = (int) Math.max(mBubbleMinWidth, Integer.toString(mEnd).length() * mCharWidth + LayoutUtils.dp2pix(mContext, 8)); mBubbleHeight = (int) Math.max(mBubbleMinHeight, mCharHeight + LayoutUtils.dp2pix(mContext, 8)); if (oldWidth != mBubbleWidth && oldHeight != mBubbleHeight) { //noinspection deprecation AbsoluteLayout.LayoutParams lp = (AbsoluteLayout.LayoutParams) mBubble.getLayoutParams(); lp.width = mBubbleWidth; lp.height = mBubbleHeight; mBubble.setLayoutParams(lp); } }
Example #18
Source File: ShadowLinearLayout.java From EhViewer with Apache License 2.0 | 5 votes |
private void init(Context context) { // TODO not only 2dp if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { setOutlineProvider(ViewOutlineProvider.BOUNDS); setElevation(LayoutUtils.dp2pix(context, 2)); } else { setShadow((NinePatchDrawable) context.getResources().getDrawable(R.drawable.shadow_2dp)); // TODO draktheme } }
Example #19
Source File: ContentLayout.java From EhViewer with Apache License 2.0 | 5 votes |
private void init(ContentLayout contentLayout) { mNextPageScrollSize = LayoutUtils.dp2pix(contentLayout.getContext(), 48); mProgressView = contentLayout.mProgressView; mTipView = contentLayout.mTipView; mContentView = contentLayout.mContentView; mRefreshLayout = contentLayout.mRefreshLayout; mRecyclerView = contentLayout.mRecyclerView; Drawable drawable = DrawableManager.getVectorDrawable(getContext(), R.drawable.big_sad_pandroid); drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight()); mTipView.setCompoundDrawables(null, drawable, null, null); mViewTransition = new ViewTransition(mContentView, mProgressView, mTipView); mViewTransition.setOnShowViewListener(this); mRecyclerView.addOnScrollListener(mOnScrollListener); mRefreshLayout.setOnRefreshListener(mOnRefreshListener); mTipView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { refresh(); } }); }
Example #20
Source File: SearchActivity.java From Nimingban with Apache License 2.0 | 5 votes |
@Override public void onBindViewHolder(SearchHolder holder, int position) { ACSearchItem item = mSearchHelper.getDataAt(position); holder.leftText.setText(item.getNMBDisplayUsername()); holder.centerText.setText("No." + item.getNMBId()); holder.rightText.setText(ReadableTime.getDisplayTime(item.getNMBTime())); ACItemUtils.setContentText(holder.content, item.getNMBDisplayContent()); String thumbKey = item.getNMBThumbKey(); String thumbUrl = item.getNMBThumbUrl(); boolean showImage; boolean loadFromNetwork; int ils = Settings.getImageLoadingStrategy(); if (ils == Settings.IMAGE_LOADING_STRATEGY_ALL || (ils == Settings.IMAGE_LOADING_STRATEGY_WIFI && NMBApplication.isConnectedWifi(SearchActivity.this))) { showImage = true; loadFromNetwork = true; } else { showImage = Settings.getImageLoadingStrategy2(); loadFromNetwork = false; } if (!TextUtils.isEmpty(thumbKey) && !TextUtils.isEmpty(thumbUrl) && showImage) { holder.thumb.setVisibility(View.VISIBLE); holder.thumb.unload(); holder.thumb.load(thumbKey, thumbUrl, loadFromNetwork); } else { holder.thumb.setVisibility(View.GONE); holder.thumb.unload(); } holder.content.setTextSize(Settings.getFontSize()); holder.content.setLineSpacing(LayoutUtils.dp2pix(SearchActivity.this, Settings.getLineSpacing()), 1.0f); if (Settings.getFixEmojiDisplay()) { holder.content.useCustomTypeface(); } else { holder.content.useOriginalTypeface(); } }
Example #21
Source File: FeedActivity.java From Nimingban with Apache License 2.0 | 5 votes |
@Override public void onBindViewHolder(FeedHolder holder, int i) { Post post = mFeedHelper.getDataAt(i); holder.leftText.setText(post.getNMBDisplayUsername()); holder.centerText.setText("No." + post.getNMBId()); holder.rightText.setText(ReadableTime.getDisplayTime(post.getNMBTime())); ACItemUtils.setContentText(holder.content, post.getNMBDisplayContent()); String thumbKey = post.getNMBThumbKey(); String thumbUrl = post.getNMBThumbUrl(); boolean showImage; boolean loadFromNetwork; int ils = Settings.getImageLoadingStrategy(); if (ils == Settings.IMAGE_LOADING_STRATEGY_ALL || (ils == Settings.IMAGE_LOADING_STRATEGY_WIFI && NMBApplication.isConnectedWifi(FeedActivity.this))) { showImage = true; loadFromNetwork = true; } else { showImage = Settings.getImageLoadingStrategy2(); loadFromNetwork = false; } if (!TextUtils.isEmpty(thumbKey) && !TextUtils.isEmpty(thumbUrl) && showImage) { holder.thumb.setVisibility(View.VISIBLE); holder.thumb.unload(); holder.thumb.load(thumbKey, thumbUrl, loadFromNetwork); } else { holder.thumb.setVisibility(View.GONE); holder.thumb.unload(); } holder.content.setTextSize(Settings.getFontSize()); holder.content.setLineSpacing(LayoutUtils.dp2pix(FeedActivity.this, Settings.getLineSpacing()), 1.0f); if (Settings.getFixEmojiDisplay()) { holder.content.useCustomTypeface(); } else { holder.content.useOriginalTypeface(); } }
Example #22
Source File: SettingsActivity.java From Nimingban with Apache License 2.0 | 5 votes |
@Override public void onSetProgress(Slider slider, int newProgress, int oldProgress, boolean byUser, boolean confirm) { if (slider == mFontSize && byUser) { mPreview.setTextSize(newProgress); } else if (slider == mLineSpacing && byUser) { mPreview.setLineSpacing(LayoutUtils.dp2pix(getActivity(), newProgress), 1.0f); } }
Example #23
Source File: ThicknessPreviewView.java From Nimingban with Apache License 2.0 | 5 votes |
@Override protected void onSizeChanged(int w, int h, int oldw, int oldh) { super.onSizeChanged(w, h, oldw, oldh); if (!mInitPath) { mInitPath = true; int padding = LayoutUtils.dp2pix(getContext(), 16); Path path = mPath; path.reset(); path.moveTo(padding, h - padding); path.cubicTo(padding, h / 2, w - padding, h / 2, w - padding, padding); mIsDot = false; invalidate(); } }
Example #24
Source File: GuideView.java From Nimingban with Apache License 2.0 | 5 votes |
private void init(Context context) { setClickable(true); setSoundEffectsEnabled(false); LayoutInflater.from(context).inflate(R.layout.widget_guide, this); mMessage = (TextView) findViewById(R.id.guide_message); mButton = (TextView) findViewById(R.id.guide_button); mMessageBg = new RoundRectDrawable(Color.BLACK, LayoutUtils.dp2pix(context, 4)); mButtonBg = new ColorDrawable(Color.BLACK); mMessage.setBackgroundDrawable(mMessageBg); mButton.setBackgroundDrawable(mButtonBg); }
Example #25
Source File: ShadowLinearLayout.java From Nimingban with Apache License 2.0 | 5 votes |
private void init(Context context) { // TODO not only 2dp if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { setOutlineProvider(ViewOutlineProvider.BOUNDS); setElevation(LayoutUtils.dp2pix(context, 2)); } else { setShadow((NinePatchDrawable) context.getResources().getDrawable(R.drawable.shadow_2dp)); // TODO draktheme } }
Example #26
Source File: PluginsActivity.java From MHViewer with Apache License 2.0 | 5 votes |
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); data = MHPluginManager.Companion.getINSTANCE().plugins(); setContentView(R.layout.activity_plugins); setNavigationIcon(R.drawable.v_arrow_left_dark_x24); recyclerView = findViewById(R.id.recycler_view); tip = findViewById(R.id.tip); FloatingActionButton fab = findViewById(R.id.fab); adapter = new PluginsAdapter(); recyclerView.setAdapter(adapter); recyclerView.setLayoutManager(new LinearLayoutManager(this, RecyclerView.VERTICAL, false)); LinearDividerItemDecoration decoration = new LinearDividerItemDecoration( LinearDividerItemDecoration.VERTICAL, AttrResources.getAttrColor(this, R.attr.dividerColor), LayoutUtils.dp2pix(this, 1)); decoration.setShowLastDivider(true); recyclerView.addItemDecoration(decoration); recyclerView.setSelector(Ripple.generateRippleDrawable(this, !AttrResources.getAttrBoolean(this, R.attr.isLightTheme), new ColorDrawable(Color.TRANSPARENT))); recyclerView.setHasFixedSize(true); recyclerView.setOnItemClickListener(this); recyclerView.setPadding( recyclerView.getPaddingLeft(), recyclerView.getPaddingTop(), recyclerView.getPaddingRight(), recyclerView.getPaddingBottom() + getResources().getDimensionPixelOffset(R.dimen.gallery_padding_bottom_fab)); fab.setOnClickListener(this); recyclerView.setVisibility(data.isEmpty() ? View.GONE : View.VISIBLE); tip.setVisibility(data.isEmpty() ? View.VISIBLE : View.GONE); }
Example #27
Source File: GalleryPreviewsScene.java From EhViewer with Apache License 2.0 | 5 votes |
@Nullable @Override public View onCreateView3(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { ContentLayout contentLayout = (ContentLayout) inflater.inflate( R.layout.scene_gallery_previews, container, false); contentLayout.hideFastScroll(); mRecyclerView = contentLayout.getRecyclerView(); Context context = getContext2(); AssertUtils.assertNotNull(context); Resources resources = context.getResources(); mAdapter = new GalleryPreviewAdapter(); mRecyclerView.setAdapter(mAdapter); int columnWidth = resources.getDimensionPixelOffset(Settings.getThumbSizeResId()); AutoGridLayoutManager layoutManager = new AutoGridLayoutManager(context, columnWidth); layoutManager.setStrategy(AutoGridLayoutManager.STRATEGY_SUITABLE_SIZE); mRecyclerView.setLayoutManager(layoutManager); mRecyclerView.setClipToPadding(false); mRecyclerView.setOnItemClickListener(this); int padding = LayoutUtils.dp2pix(context, 4); MarginItemDecoration decoration = new MarginItemDecoration(padding, padding, padding, padding, padding); mRecyclerView.addItemDecoration(decoration); decoration.applyPaddings(mRecyclerView); mHelper = new GalleryPreviewHelper(); contentLayout.setHelper(mHelper); // Only refresh for the first time if (!mHasFirstRefresh) { mHasFirstRefresh = true; mHelper.firstRefresh(); } return contentLayout; }
Example #28
Source File: HostsActivity.java From EhViewer with Apache License 2.0 | 5 votes |
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); hosts = EhApplication.getHosts(this); data = hosts.getAll(); setContentView(R.layout.activity_hosts); setNavigationIcon(R.drawable.v_arrow_left_dark_x24); recyclerView = findViewById(R.id.recycler_view); tip = findViewById(R.id.tip); FloatingActionButton fab = findViewById(R.id.fab); adapter = new HostsAdapter(); recyclerView.setAdapter(adapter); recyclerView.setLayoutManager(new LinearLayoutManager(this, RecyclerView.VERTICAL, false)); LinearDividerItemDecoration decoration = new LinearDividerItemDecoration( LinearDividerItemDecoration.VERTICAL, AttrResources.getAttrColor(this, R.attr.dividerColor), LayoutUtils.dp2pix(this, 1)); decoration.setShowLastDivider(true); recyclerView.addItemDecoration(decoration); recyclerView.setSelector(Ripple.generateRippleDrawable(this, !AttrResources.getAttrBoolean(this, R.attr.isLightTheme), new ColorDrawable(Color.TRANSPARENT))); recyclerView.setHasFixedSize(true); recyclerView.setOnItemClickListener(this); recyclerView.setPadding( recyclerView.getPaddingLeft(), recyclerView.getPaddingTop(), recyclerView.getPaddingRight(), recyclerView.getPaddingBottom() + getResources().getDimensionPixelOffset(R.dimen.gallery_padding_bottom_fab)); fab.setOnClickListener(this); recyclerView.setVisibility(data.isEmpty() ? View.GONE : View.VISIBLE); tip.setVisibility(data.isEmpty() ? View.VISIBLE : View.GONE); }
Example #29
Source File: DraftActivity.java From Nimingban with Apache License 2.0 | 5 votes |
@Override public void onBindViewHolder(DraftHolder holder, int position) { DraftRaw draftRaw = mLazyList.get(position); holder.time.setText(ReadableTime.getDisplayTime(draftRaw.getTime())); holder.content.setText(draftRaw.getContent()); holder.content.setTextSize(Settings.getFontSize()); holder.content.setLineSpacing(LayoutUtils.dp2pix(DraftActivity.this, Settings.getLineSpacing()), 1.0f); if (Settings.getFixEmojiDisplay()) { holder.content.useCustomTypeface(); } else { holder.content.useOriginalTypeface(); } }
Example #30
Source File: ShadowLinearLayout.java From MHViewer with Apache License 2.0 | 5 votes |
private void init(Context context) { // TODO not only 2dp if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { setOutlineProvider(ViewOutlineProvider.BOUNDS); setElevation(LayoutUtils.dp2pix(context, 2)); } else { setShadow((NinePatchDrawable) context.getResources().getDrawable(R.drawable.shadow_2dp)); // TODO draktheme } }