Search in sources :

Example 46 with RIGHT

use of android.support.v7.widget.helper.ItemTouchHelper.RIGHT in project android_packages_apps_Settings by LineageOS.

the class SearchFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final View view = inflater.inflate(R.layout.search_panel, container, false);
    mResultsRecyclerView = view.findViewById(R.id.list_results);
    mResultsRecyclerView.setAdapter(mSearchAdapter);
    mResultsRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
    mResultsRecyclerView.addOnScrollListener(mScrollListener);
    mNoResultsView = view.findViewById(R.id.no_results_layout);
    Toolbar toolbar = view.findViewById(R.id.search_toolbar);
    getActivity().setActionBar(toolbar);
    getActivity().getActionBar().setDisplayHomeAsUpEnabled(true);
    mSearchView = toolbar.findViewById(R.id.search_view);
    mSearchView.setQuery(mQuery, false);
    mSearchView.setOnQueryTextListener(this);
    mSearchView.requestFocus();
    // Updating internal views inside SearchView was the easiest way to get this too look right.
    // Instead of grabbing the TextView directly, we grab it as a view and do an instanceof
    // check. This ensures if we return, say, a LinearLayout in the tests, they won't fail.
    View searchText = mSearchView.findViewById(com.android.internal.R.id.search_src_text);
    if (searchText instanceof TextView) {
        TextView searchTextView = (TextView) searchText;
        searchTextView.setTextColor(getContext().getColorStateList(com.android.internal.R.color.text_color_primary));
        searchTextView.setTextSize(TypedValue.COMPLEX_UNIT_PX, getResources().getDimension(R.dimen.search_bar_text_size));
    }
    View editFrame = mSearchView.findViewById(com.android.internal.R.id.search_edit_frame);
    if (editFrame != null) {
        ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) editFrame.getLayoutParams();
        params.setMarginStart(0);
        editFrame.setLayoutParams(params);
    }
    ActionBarShadowController.attachToRecyclerView(view.findViewById(R.id.search_bar_container), getLifecycle(), mResultsRecyclerView);
    return view;
}
Also used : ViewGroup(android.view.ViewGroup) TextView(android.widget.TextView) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) View(android.view.View) SearchView(android.widget.SearchView) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) Toolbar(android.widget.Toolbar)

Example 47 with RIGHT

use of android.support.v7.widget.helper.ItemTouchHelper.RIGHT in project NiceMusic by lizixian18.

the class BannerLayoutManager method scrollBy.

private int scrollBy(int dy, RecyclerView.Recycler recycler, RecyclerView.State state) {
    if (getChildCount() == 0 || dy == 0) {
        return 0;
    }
    ensureLayoutState();
    int willScroll = dy;
    float realDx = dy / getDistanceRatio();
    if (Math.abs(realDx) < 0.00000001f) {
        return 0;
    }
    float targetOffset = mOffset + realDx;
    // handle the boundary
    if (!mInfinite && targetOffset < getMinOffset()) {
        willScroll -= (targetOffset - getMinOffset()) * getDistanceRatio();
    } else if (!mInfinite && targetOffset > getMaxOffset()) {
        willScroll = (int) ((getMaxOffset() - mOffset) * getDistanceRatio());
    }
    if (mIntegerDy) {
        realDx = (int) (willScroll / getDistanceRatio());
    } else {
        realDx = willScroll / getDistanceRatio();
    }
    mOffset += realDx;
    // we re-layout all current views in the right place
    for (int i = 0; i < getChildCount(); i++) {
        final View scrap = getChildAt(i);
        final float delta = propertyChangeWhenScroll(scrap) - realDx;
        layoutScrap(scrap, delta);
    }
    // handle recycle
    layoutItems(recycler);
    return willScroll;
}
Also used : RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View)

Example 48 with RIGHT

use of android.support.v7.widget.helper.ItemTouchHelper.RIGHT in project AmazeFileManager by TeamAmaze.

the class DividerItemDecoration method drawVertical.

/**
 * Draws the divider on the canvas provided by RecyclerView
 * Be advised - divider will be drawn before the views, hence it'll be below the views of adapter
 * @param c
 * @param parent
 */
private void drawVertical(Canvas c, RecyclerView parent) {
    final int left = parent.getPaddingLeft() + leftPaddingPx;
    final int right = parent.getWidth() - parent.getPaddingRight() - rightPaddingPx;
    final int childCount = parent.getChildCount();
    for (int i = showtopbottomdividers ? 0 : 1; i < childCount - 1; i++) {
        final View child = parent.getChildAt(i);
        int viewType = parent.getChildViewHolder(child).getItemViewType();
        if (viewType == RecyclerAdapter.TYPE_HEADER_FILES || viewType == RecyclerAdapter.TYPE_HEADER_FOLDERS) {
            // no need to decorate header views
            continue;
        }
        final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();
        final int top = child.getBottom() + params.bottomMargin;
        final int bottom = top + mDivider.getIntrinsicHeight();
        mDivider.setBounds(left, top, right, bottom);
        mDivider.draw(c);
    }
}
Also used : RecyclerView(android.support.v7.widget.RecyclerView) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View)

Example 49 with RIGHT

use of android.support.v7.widget.helper.ItemTouchHelper.RIGHT in project weiui by kuaifan.

the class RecycleViewDivider method drawHorizontal.

// 绘制横向 item 分割线
private void drawHorizontal(Canvas canvas, RecyclerView parent) {
    final int left = parent.getPaddingLeft();
    final int right = parent.getMeasuredWidth() - parent.getPaddingRight();
    final int childSize = parent.getChildCount();
    for (int i = 0; i < childSize; i++) {
        final View child = parent.getChildAt(i);
        RecyclerView.LayoutParams layoutParams = (RecyclerView.LayoutParams) child.getLayoutParams();
        final int top = child.getBottom() + layoutParams.bottomMargin;
        final int bottom = top + mDividerHeight;
        if (mDivider != null) {
            mDivider.setBounds(left, top, right, bottom);
            mDivider.draw(canvas);
        }
        if (mPaint != null) {
            canvas.drawRect(left, top, right, bottom, mPaint);
        }
    }
}
Also used : RecyclerView(android.support.v7.widget.RecyclerView) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) Paint(android.graphics.Paint)

Example 50 with RIGHT

use of android.support.v7.widget.helper.ItemTouchHelper.RIGHT in project weiui by kuaifan.

the class RecycleViewDivider method drawVertical.

// 绘制纵向 item 分割线
private void drawVertical(Canvas canvas, RecyclerView parent) {
    final int top = parent.getPaddingTop();
    final int bottom = parent.getMeasuredHeight() - parent.getPaddingBottom();
    final int childSize = parent.getChildCount();
    for (int i = 0; i < childSize; i++) {
        final View child = parent.getChildAt(i);
        RecyclerView.LayoutParams layoutParams = (RecyclerView.LayoutParams) child.getLayoutParams();
        final int left = child.getRight() + layoutParams.rightMargin;
        final int right = left + mDividerHeight;
        if (mDivider != null) {
            mDivider.setBounds(left, top, right, bottom);
            mDivider.draw(canvas);
        }
        if (mPaint != null) {
            canvas.drawRect(left, top, right, bottom, mPaint);
        }
    }
}
Also used : RecyclerView(android.support.v7.widget.RecyclerView) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) Paint(android.graphics.Paint)

Aggregations

View (android.view.View)315 RecyclerView (android.support.v7.widget.RecyclerView)294 Paint (android.graphics.Paint)47 TextView (android.widget.TextView)46 ImageView (android.widget.ImageView)29 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)27 ViewGroup (android.view.ViewGroup)15 Intent (android.content.Intent)13 Rect (android.graphics.Rect)12 Preference (android.support.v7.preference.Preference)12 GridLayoutManager (android.support.v7.widget.GridLayoutManager)11 SuppressLint (android.annotation.SuppressLint)10 AlertDialog (android.support.v7.app.AlertDialog)10 Bundle (android.os.Bundle)9 Bitmap (android.graphics.Bitmap)8 OnLayoutChangeListener (android.view.View.OnLayoutChangeListener)8 Button (android.widget.Button)8 PreferenceScreen (android.support.v7.preference.PreferenceScreen)7 ArrayList (java.util.ArrayList)7 Animator (android.animation.Animator)6