Search in sources :

Example 61 with GridLayoutManager

use of android.support.v7.widget.GridLayoutManager in project Atom_Android by Rogrand-Dev.

the class HomeTabFragment method initEventAndData.

@Override
protected void initEventAndData() {
    setToolBar(mToolbar, "界面");
    EventBus.getDefault().register(this);
    mRecyclerView.setLayoutManager(new GridLayoutManager(mContext, 2, GridLayoutManager.VERTICAL, false));
    initData();
    initAdapter();
}
Also used : GridLayoutManager(android.support.v7.widget.GridLayoutManager)

Example 62 with GridLayoutManager

use of android.support.v7.widget.GridLayoutManager in project Atom_Android by Rogrand-Dev.

the class ToolTabFragment method initEventAndData.

@Override
protected void initEventAndData() {
    setToolBar(mToolbar, "工具");
    EventBus.getDefault().register(this);
    mRecyclerView.setLayoutManager(new GridLayoutManager(mContext, 2, GridLayoutManager.VERTICAL, false));
    initData();
    initAdapter();
}
Also used : GridLayoutManager(android.support.v7.widget.GridLayoutManager)

Example 63 with GridLayoutManager

use of android.support.v7.widget.GridLayoutManager in project Atom_Android by Rogrand-Dev.

the class ImageResultActivity method initEventAndData.

@Override
protected void initEventAndData() {
    setSupportActionBar(mToolbar);
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setDisplayShowHomeEnabled(true);
    }
    GridLayoutManager gridLayoutManager = new GridLayoutManager(this, 3, GridLayoutManager.VERTICAL, false);
    mRecyclerView.setLayoutManager(gridLayoutManager);
    mAdapter = new ShowImageAdapter(this, mAllDatas, onItemControlListener);
    mAdapter.setMaxShow(9);
    mRecyclerView.setAdapter(mAdapter);
    mAdapter.setOnItemClickListener(new ShowImageAdapter.OnItemClickListener() {

        @Override
        public void onItemClick(View v, int position) {
            PictureConfig.getInstance().externalPicturePreview(mContext, position, mAllDatas);
        }
    });
}
Also used : GridLayoutManager(android.support.v7.widget.GridLayoutManager) BindView(butterknife.BindView) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) ActionBar(android.support.v7.app.ActionBar)

Example 64 with GridLayoutManager

use of android.support.v7.widget.GridLayoutManager in project Rocket.Chat.Android by RocketChat.

the class UsersOfRoomDialogFragment method setupView.

private void setupView(Optional<RocketChatAbsoluteUrl> rocketChatAbsoluteUrlOptional) {
    compositeDisposable.clear();
    if (!rocketChatAbsoluteUrlOptional.isPresent()) {
        return;
    }
    RecyclerView recyclerView = (RecyclerView) getDialog().findViewById(R.id.recyclerview);
    recyclerView.setLayoutManager(new GridLayoutManager(getContext(), 2));
    recyclerView.setAdapter(new RoomUserAdapter(getContext(), realmHelper, rocketChatAbsoluteUrlOptional.get()));
}
Also used : GridLayoutManager(android.support.v7.widget.GridLayoutManager) RoomUserAdapter(chat.rocket.android.layouthelper.chatroom.dialog.RoomUserAdapter) RecyclerView(android.support.v7.widget.RecyclerView)

Example 65 with GridLayoutManager

use of android.support.v7.widget.GridLayoutManager in project android_frameworks_base by ResurrectionRemix.

the class DirectoryFragment method onActivityCreated.

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    final Context context = getActivity();
    final State state = getDisplayState();
    // Read arguments when object created for the first time.
    // Restore state if fragment recreated.
    Bundle args = savedInstanceState == null ? getArguments() : savedInstanceState;
    mRoot = args.getParcelable(Shared.EXTRA_ROOT);
    mDocument = args.getParcelable(Shared.EXTRA_DOC);
    mStateKey = buildStateKey(mRoot, mDocument);
    mQuery = args.getString(Shared.EXTRA_QUERY);
    mType = args.getInt(Shared.EXTRA_TYPE);
    final Selection selection = args.getParcelable(Shared.EXTRA_SELECTION);
    mSelection = selection != null ? selection : new Selection();
    mSearchMode = args.getBoolean(Shared.EXTRA_SEARCH_MODE);
    mIconHelper = new IconHelper(context, MODE_GRID);
    mAdapter = new SectionBreakDocumentsAdapterWrapper(this, new ModelBackedDocumentsAdapter(this, mIconHelper));
    mRecView.setAdapter(mAdapter);
    // Switch Access Accessibility API needs an {@link AccessibilityDelegate} to know the proper
    // route when user selects an UI element. It usually guesses this if the element has an
    // {@link OnClickListener}, but since we do not have one for itemView, we will need to
    // manually route it to the right behavior. RecyclerView has its own AccessibilityDelegate,
    // and routes it to its LayoutManager; so we must override the LayoutManager's accessibility
    // methods to route clicks correctly.
    mLayout = new GridLayoutManager(getContext(), mColumnCount) {

        @Override
        public void onInitializeAccessibilityNodeInfoForItem(RecyclerView.Recycler recycler, RecyclerView.State state, View host, AccessibilityNodeInfoCompat info) {
            super.onInitializeAccessibilityNodeInfoForItem(recycler, state, host, info);
            info.addAction(AccessibilityActionCompat.ACTION_CLICK);
        }

        @Override
        public boolean performAccessibilityActionForItem(RecyclerView.Recycler recycler, RecyclerView.State state, View view, int action, Bundle args) {
            // We are only handling click events; route all other to default implementation
            if (action == AccessibilityNodeInfoCompat.ACTION_CLICK) {
                RecyclerView.ViewHolder vh = mRecView.getChildViewHolder(view);
                if (vh instanceof DocumentHolder) {
                    DocumentHolder dh = (DocumentHolder) vh;
                    if (dh.mEventListener != null) {
                        dh.mEventListener.onActivate(dh);
                        return true;
                    }
                }
            }
            return super.performAccessibilityActionForItem(recycler, state, view, action, args);
        }
    };
    SpanSizeLookup lookup = mAdapter.createSpanSizeLookup();
    if (lookup != null) {
        mLayout.setSpanSizeLookup(lookup);
    }
    mRecView.setLayoutManager(mLayout);
    mGestureDetector = new ListeningGestureDetector(this.getContext(), mDragHelper, new GestureListener());
    mRecView.addOnItemTouchListener(mGestureDetector);
    // TODO: instead of inserting the view into the constructor, extract listener-creation code
    // and set the listener on the view after the fact.  Then the view doesn't need to be passed
    // into the selection manager.
    mSelectionManager = new MultiSelectManager(mRecView, mAdapter, state.allowMultiple ? MultiSelectManager.MODE_MULTIPLE : MultiSelectManager.MODE_SINGLE, null);
    mSelectionManager.addCallback(new SelectionModeListener());
    mModel = new Model();
    mModel.addUpdateListener(mAdapter);
    mModel.addUpdateListener(mModelUpdateListener);
    // Make sure this is done after the RecyclerView is set up.
    mFocusManager = new FocusManager(context, mRecView, mModel);
    mTuner = FragmentTuner.pick(getContext(), state);
    mClipper = new DocumentClipper(context);
    final ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
    boolean svelte = am.isLowRamDevice() && (mType == TYPE_RECENT_OPEN);
    mIconHelper.setThumbnailsEnabled(!svelte);
    // Kick off loader at least once
    getLoaderManager().restartLoader(LOADER_ID, null, this);
}
Also used : Selection(com.android.documentsui.dirlist.MultiSelectManager.Selection) ActivityManager(android.app.ActivityManager) ViewHolder(android.support.v7.widget.RecyclerView.ViewHolder) Context(android.content.Context) Bundle(android.os.Bundle) AccessibilityNodeInfoCompat(android.support.v4.view.accessibility.AccessibilityNodeInfoCompat) ImageView(android.widget.ImageView) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) TextView(android.widget.TextView) Recycler(android.support.v7.widget.RecyclerView.Recycler) Point(android.graphics.Point) SpanSizeLookup(android.support.v7.widget.GridLayoutManager.SpanSizeLookup) DocumentClipper(com.android.documentsui.DocumentClipper) GridLayoutManager(android.support.v7.widget.GridLayoutManager) State(com.android.documentsui.State) RecyclerView(android.support.v7.widget.RecyclerView)

Aggregations

GridLayoutManager (android.support.v7.widget.GridLayoutManager)292 RecyclerView (android.support.v7.widget.RecyclerView)135 View (android.view.View)76 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)73 StaggeredGridLayoutManager (android.support.v7.widget.StaggeredGridLayoutManager)44 TextView (android.widget.TextView)39 BindView (butterknife.BindView)19 Toolbar (android.support.v7.widget.Toolbar)16 DefaultItemAnimator (android.support.v7.widget.DefaultItemAnimator)14 MaterialViewPagerHeaderDecorator (com.github.florent37.materialviewpager.header.MaterialViewPagerHeaderDecorator)14 Nullable (android.support.annotation.Nullable)13 ImageView (android.widget.ImageView)13 ArrayList (java.util.ArrayList)13 Intent (android.content.Intent)12 Handler (android.os.Handler)12 Bundle (android.os.Bundle)11 SwipeRefreshLayout (android.support.v4.widget.SwipeRefreshLayout)11 SuppressLint (android.annotation.SuppressLint)10 Context (android.content.Context)10 Point (android.graphics.Point)9