Java Code Examples for androidx.recyclerview.widget.LinearLayoutManager#getOrientation()

The following examples show how to use androidx.recyclerview.widget.LinearLayoutManager#getOrientation() . 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: FromRecyclerViewListener.java    From GestureViews with Apache License 2.0 6 votes vote down vote up
@Override
void scrollToPosition(RecyclerView list, int pos) {
    if (list.getLayoutManager() instanceof LinearLayoutManager) {
        // Centering item in its parent
        final LinearLayoutManager manager = (LinearLayoutManager) list.getLayoutManager();
        final boolean isHorizontal = manager.getOrientation() == LinearLayoutManager.HORIZONTAL;

        int offset = isHorizontal
                ? (list.getWidth() - list.getPaddingLeft() - list.getPaddingRight()) / 2
                : (list.getHeight() - list.getPaddingTop() - list.getPaddingBottom()) / 2;

        final RecyclerView.ViewHolder holder = list.findViewHolderForAdapterPosition(pos);
        if (holder != null) {
            final View view = holder.itemView;
            offset -= isHorizontal ? view.getWidth() / 2 : view.getHeight() / 2;
        }

        manager.scrollToPositionWithOffset(pos, offset);
    } else {
        list.scrollToPosition(pos);
    }
}
 
Example 2
Source File: SimpleRecyclerViewActivity.java    From Android with MIT License 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_simple_recycler_view);

    RecyclerView simpleRecyclerView = findViewById(R.id.simple_recycler_view);

    // add data in the mPersonList
    addPersonData();


    // set layout manager
    LinearLayoutManager layoutManager = new LinearLayoutManager(this);
    simpleRecyclerView.setLayoutManager(layoutManager);

    // set divider between two rows
    DividerItemDecoration divider = new DividerItemDecoration(simpleRecyclerView.getContext(), layoutManager.getOrientation());
    simpleRecyclerView.addItemDecoration(divider);

    // set adapter
    RecyclerViewJavaAdapter adapter = new RecyclerViewJavaAdapter(personModelList,this);
    simpleRecyclerView.setAdapter(adapter);

}
 
Example 3
Source File: AllTransactionsScreen.java    From adamant-android with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    AndroidInjection.inject(this);
    super.onCreate(savedInstanceState);
    currencyTransfersAdapter.setOnClickedLister(presenter::onTransactionClicked);

    layoutManager = new LinearLayoutManager(this);
    transactionsView.setLayoutManager(layoutManager);
    transactionsView.setAdapter(currencyTransfersAdapter);


    Drawable divider = ContextCompat.getDrawable(transactionsView.getContext(), R.drawable.line_divider);
    DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(transactionsView.getContext(), layoutManager.getOrientation());

    if (divider != null) {
        dividerItemDecoration.setDrawable(divider);
    }

    transactionsView.addItemDecoration(dividerItemDecoration);


    Intent intent = getIntent();
    if (intent != null) {
        if (intent.hasExtra(ARG_CURRENCY_ABBR)) {
            String abbr = getIntent().getStringExtra(ARG_CURRENCY_ABBR);
            String pattern = getString(R.string.activity_all_transactions_title);
            String title = String.format(Locale.ENGLISH, pattern, abbr);
            setTitle(title);

            if (savedInstanceState == null) {
                presenter.onShowTransactionsByCurrencyAbbr(abbr);
            }
        }
    }
}
 
Example 4
Source File: ViewItemDecoration.java    From Carbon with Apache License 2.0 5 votes vote down vote up
private int getOrientation(androidx.recyclerview.widget.RecyclerView parent) {
    if (parent.getLayoutManager() instanceof LinearLayoutManager) {
        LinearLayoutManager layoutManager = (LinearLayoutManager) parent.getLayoutManager();
        return layoutManager.getOrientation();
    } else {
        throw new IllegalStateException(
                "DividerItemDecoration can only be used with a LinearLayoutManager.");
    }
}
 
Example 5
Source File: DefineActivity.java    From SwipeRecyclerView with Apache License 2.0 5 votes vote down vote up
@Override
public int onDragFlags(RecyclerView recyclerView, RecyclerView.ViewHolder targetViewHolder) {
    int adapterPosition = targetViewHolder.getAdapterPosition();
    if (adapterPosition == 0) { // 这里让HeaderView不能拖拽。
        return OnItemMovementListener.INVALID;// 返回无效的方向。
    }

    // 真实的Position:通过ViewHolder拿到的position都需要减掉HeadView的数量。
    int position = adapterPosition - mRecyclerView.getHeaderCount();

    // 假如让普通Item的第一个不能拖拽。
    if (position == 0) {
        return OnItemMovementListener.INVALID;// 返回无效的方向。
    }

    RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager();
    if (layoutManager instanceof GridLayoutManager) {
        // Grid可以上下左右拖拽。
        return OnItemMovementListener.LEFT | OnItemMovementListener.UP | OnItemMovementListener.RIGHT |
            OnItemMovementListener.DOWN;
    } else if (layoutManager instanceof LinearLayoutManager) {
        LinearLayoutManager linearLayoutManager = (LinearLayoutManager)layoutManager;

        // 横向List只能左右拖拽。
        if (linearLayoutManager.getOrientation() == LinearLayoutManager.HORIZONTAL) {
            return (OnItemMovementListener.LEFT | OnItemMovementListener.RIGHT);
        }
        // 竖向List只能上下拖拽。
        else {
            return OnItemMovementListener.UP | OnItemMovementListener.DOWN;
        }
    }
    return OnItemMovementListener.INVALID;// 返回无效的方向。
}
 
Example 6
Source File: DividerItemDecoration.java    From Carbon with Apache License 2.0 5 votes vote down vote up
private int getOrientation(androidx.recyclerview.widget.RecyclerView parent) {
    if (parent.getLayoutManager() instanceof LinearLayoutManager) {
        LinearLayoutManager layoutManager = (LinearLayoutManager) parent.getLayoutManager();
        return layoutManager.getOrientation();
    } else {
        throw new IllegalStateException(
                "DividerItemDecoration can only be used with a LinearLayoutManager.");
    }
}
 
Example 7
Source File: HorizontalScrollCompat.java    From SmoothRefreshLayout with MIT License 5 votes vote down vote up
public static boolean canAutoRefresh(View view) {
    if (ViewCatcherUtil.isRecyclerView(view)) {
        RecyclerView recyclerView = (RecyclerView) view;
        RecyclerView.LayoutManager manager = recyclerView.getLayoutManager();
        if (manager == null) {
            return false;
        }
        int firstVisiblePosition = -1;
        if (manager instanceof LinearLayoutManager) {
            LinearLayoutManager linearManager = ((LinearLayoutManager) manager);
            if (linearManager.getOrientation() != RecyclerView.HORIZONTAL) {
                return false;
            }
            firstVisiblePosition = linearManager.findFirstVisibleItemPosition();
        } else if (manager instanceof StaggeredGridLayoutManager) {
            StaggeredGridLayoutManager gridLayoutManager = (StaggeredGridLayoutManager) manager;
            if (gridLayoutManager.getOrientation() != RecyclerView.HORIZONTAL) {
                return false;
            }
            int[] firstPositions = new int[gridLayoutManager.getSpanCount()];
            gridLayoutManager.findFirstVisibleItemPositions(firstPositions);
            for (int value : firstPositions) {
                if (value == 0) {
                    firstVisiblePosition = 0;
                    break;
                }
            }
        }
        RecyclerView.Adapter adapter = recyclerView.getAdapter();
        return adapter != null && firstVisiblePosition == 0;
    }
    return false;
}
 
Example 8
Source File: HistoryActivity.java    From Chimee with MIT License 5 votes vote down vote up
private void setupRecyclerView() {
    RecyclerView recyclerView = findViewById(R.id.rv_message_history);
    final LinearLayoutManager horizontalLayoutManager
            = new LinearLayoutManager(this,
            LinearLayoutManager.HORIZONTAL, false);
    recyclerView.setLayoutManager(horizontalLayoutManager);
    DividerItemDecoration dividerItemDecoration =
            new DividerItemDecoration(recyclerView.getContext(),
                    horizontalLayoutManager.getOrientation());
    recyclerView.addItemDecoration(dividerItemDecoration);
    adapter = new HistoryRvAdapter(this, mMessages);
    adapter.setClickListener(this);
    recyclerView.setAdapter(adapter);
}
 
Example 9
Source File: AssemblyRecyclerLinerDivider.java    From assembly-adapter with Apache License 2.0 5 votes vote down vote up
@Override
public void onDraw(@NonNull Canvas c, @NonNull RecyclerView parent, @NonNull RecyclerView.State state) {
    RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager();
    if (!(layoutManager instanceof LinearLayoutManager)) {
        return;
    }
    LinearLayoutManager linearLayoutManager = (LinearLayoutManager) layoutManager;
    int mOrientation = linearLayoutManager.getOrientation();
    if (mOrientation == LinearLayoutManager.VERTICAL) {
        drawVertical(c, parent);
    } else {
        drawHorizontal(c, parent);
    }
}
 
Example 10
Source File: AssemblyRecyclerLinerDivider.java    From assembly-adapter with Apache License 2.0 5 votes vote down vote up
@Override
public void getItemOffsets(@NonNull Rect outRect, @NonNull View view, @NonNull RecyclerView parent, @NonNull RecyclerView.State state) {
    RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager();
    if (!(layoutManager instanceof LinearLayoutManager)) {
        outRect.set(0, 0, 0, 0);
        return;
    }
    LinearLayoutManager linearLayoutManager = (LinearLayoutManager) layoutManager;
    int mOrientation = linearLayoutManager.getOrientation();

    int itemPosition = 0;
    int firstDataItemPosition = 0;
    int lastDataItemPosition = 0;
    RecyclerView.Adapter adapter = recyclerView.getAdapter();
    AssemblyRecyclerAdapter recyclerAdapter = null;
    if (adapter instanceof AssemblyRecyclerAdapter) {
        recyclerAdapter = (AssemblyRecyclerAdapter) adapter;
        itemPosition = ((RecyclerView.LayoutParams) view.getLayoutParams()).getViewLayoutPosition();
        firstDataItemPosition = recyclerAdapter.getHeaderCount();
        lastDataItemPosition = firstDataItemPosition + (recyclerAdapter.getDataCount() - 1);
    }

    if (recyclerAdapter == null || (itemPosition >= firstDataItemPosition && itemPosition <= lastDataItemPosition)) {
        if (mOrientation == LinearLayoutManager.VERTICAL) {
            outRect.set(0, 0, 0, mDivider.getIntrinsicHeight());
        } else {
            outRect.set(0, 0, mDivider.getIntrinsicWidth(), 0);
        }
    } else {
        outRect.set(0, 0, 0, 0);
    }
}
 
Example 11
Source File: ChatsScreen.java    From adamant-android with GNU General Public License v3.0 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = super.onCreateView(inflater, container, savedInstanceState);

    layoutManager = new LinearLayoutManager(this.getContext());
    chatList.setLayoutManager(layoutManager);
    chatList.setAdapter(adapter);

    Drawable divider = ContextCompat.getDrawable(chatList.getContext(), R.drawable.line_divider);
    int avatarWidth = getResources().getDimensionPixelSize(R.dimen.list_item_avatar_size);
    int itemPadding = getResources().getDimensionPixelSize(R.dimen.list_item_chat_padding);
    InsetDrawable insetDivider = new InsetDrawable(divider, avatarWidth + (itemPadding * 2), 0, 0, 0);

    DividerItemDecoration itemDecoration = new DividerItemDecoration(chatList.getContext(), layoutManager.getOrientation());
    itemDecoration.setDrawable(insetDivider);
    chatList.addItemDecoration(itemDecoration);

    adapter.setListener(this);

    chatList.addOnScrollListener(new RecyclerView.OnScrollListener() {
        @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
            super.onScrolled(recyclerView, dx, dy);
            if (dy > 0 && addChatFab.getVisibility() == View.VISIBLE) {
                addChatFab.hide();
            } else if (dy < 0 && addChatFab.getVisibility() != View.VISIBLE) {
                addChatFab.show();
            }
        }
    });

    addChatFab.setOnClickListener(v -> presenter.onClickCreateNewChatButton(buildRevealSettings()));

    return view;
}
 
Example 12
Source File: FavoriteActivity.java    From Chimee with MIT License 5 votes vote down vote up
private void setupRecyclerView() {
    RecyclerView recyclerView = findViewById(R.id.rv_all_favorites);
    LinearLayoutManager horizontalLayoutManager
            = new LinearLayoutManager(this,
            LinearLayoutManager.HORIZONTAL, false);
    recyclerView.setLayoutManager(horizontalLayoutManager);
    DividerItemDecoration dividerItemDecoration =
            new DividerItemDecoration(recyclerView.getContext(),
                    horizontalLayoutManager.getOrientation());
    recyclerView.addItemDecoration(dividerItemDecoration);
    adapter = new FavoritesRvAdapter(this, mMessages);
    adapter.setClickListener(this);
    recyclerView.setAdapter(adapter);
}
 
Example 13
Source File: FamiliarDefaultItemDecoration.java    From FamiliarRecyclerView with MIT License 5 votes vote down vote up
private void initLayoutManagerType() {
    mLayoutManagerType = mFamiliarRecyclerView.getCurLayoutManagerType();
    RecyclerView.LayoutManager layoutManager = mFamiliarRecyclerView.getLayoutManager();
    switch (mLayoutManagerType) {
        case FamiliarRecyclerView.LAYOUT_MANAGER_TYPE_LINEAR:
            LinearLayoutManager curLinearLayoutManager = (LinearLayoutManager) layoutManager;
            if (curLinearLayoutManager.getOrientation() == LinearLayoutManager.HORIZONTAL) {
                mOrientation = OrientationHelper.HORIZONTAL;
            } else {
                mOrientation = OrientationHelper.VERTICAL;
            }
            break;
        case FamiliarRecyclerView.LAYOUT_MANAGER_TYPE_GRID:
            GridLayoutManager curGridLayoutManager = (GridLayoutManager) layoutManager;
            mGridSpanCount = curGridLayoutManager.getSpanCount();
            if (curGridLayoutManager.getOrientation() == LinearLayoutManager.HORIZONTAL) {
                mOrientation = OrientationHelper.HORIZONTAL;
            } else {
                mOrientation = OrientationHelper.VERTICAL;
            }
            break;
        case FamiliarRecyclerView.LAYOUT_MANAGER_TYPE_STAGGERED_GRID:
            StaggeredGridLayoutManager curStaggeredGridLayoutManager = (StaggeredGridLayoutManager) layoutManager;
            mGridSpanCount = curStaggeredGridLayoutManager.getSpanCount();
            if (curStaggeredGridLayoutManager.getOrientation() == LinearLayoutManager.HORIZONTAL) {
                mOrientation = OrientationHelper.HORIZONTAL;
            } else {
                mOrientation = OrientationHelper.VERTICAL;
            }
            break;
        default:
            mLayoutManagerType = FamiliarRecyclerView.LAYOUT_MANAGER_TYPE_LINEAR;
    }

    initDivisible();
}
 
Example 14
Source File: WaypointList.java    From msdkui-android with Apache License 2.0 5 votes vote down vote up
private void init(final Context context) {
    final LinearLayoutManager layoutManager = new LinearLayoutManager(context);
    setLayoutManager(layoutManager);
    setHasFixedSize(true);
    setItemAnimator(new DefaultItemAnimator());
    final DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(context,
            layoutManager.getOrientation());
    final Drawable verticalDivider = getVerticalDivider(context);
    dividerItemDecoration.setDrawable(verticalDivider);
    addItemDecoration(dividerItemDecoration);
    setBackgroundColor(ThemeUtil.getColor(getContext(), R.attr.colorBackgroundBrand));
    mAdapter = new WaypointListAdapter(mWaypointEntries);
    setAdapter(mAdapter);
    addMinWaypointsItem();
}
 
Example 15
Source File: CustomRecyclerView.java    From msdkui-android with Apache License 2.0 5 votes vote down vote up
private void init(final Context context) {
    final LinearLayoutManager layoutManager = new LinearLayoutManager(context);
    setLayoutManager(layoutManager);
    setHasFixedSize(true);
    setItemAnimator(new DefaultItemAnimator());
    final DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(context,
            layoutManager.getOrientation());
    dividerItemDecoration.setDrawable(getVerticalDivider(context));
    addItemDecoration(dividerItemDecoration);
    addOnItemTouchListener(mRecyclerItemClickListener);
}
 
Example 16
Source File: SaveActivity.java    From Chimee with MIT License 5 votes vote down vote up
private void setupRecyclerView(List<String> files) {
    RecyclerView recyclerView = findViewById(R.id.rv_document_list);
    LinearLayoutManager horizontalLayoutManager
            = new LinearLayoutManager(this,
            LinearLayoutManager.HORIZONTAL, false);
    recyclerView.setLayoutManager(horizontalLayoutManager);
    DividerItemDecoration dividerItemDecoration =
            new DividerItemDecoration(recyclerView.getContext(),
                    horizontalLayoutManager.getOrientation());
    recyclerView.addItemDecoration(dividerItemDecoration);
    adapter = new SimpleListRvAdapter(this, files);
    adapter.setClickListener(this);
    recyclerView.setAdapter(adapter);
}
 
Example 17
Source File: RecordingsActivity.java    From linphone-android with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mOnBackPressGoHome = false;
    mAlwaysHideTabBar = true;

    // Uses the fragment container layout to inflate the about view instead of using a fragment
    View recordingsView =
            LayoutInflater.from(this).inflate(R.layout.recordings_list, null, false);
    LinearLayout fragmentContainer = findViewById(R.id.fragmentContainer);
    LinearLayout.LayoutParams params =
            new LinearLayout.LayoutParams(
                    ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    fragmentContainer.addView(recordingsView, params);

    if (isTablet()) {
        findViewById(R.id.fragmentContainer2).setVisibility(View.GONE);
    }

    ImageView backButton = findViewById(R.id.back);
    backButton.setOnClickListener(
            new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    goBack();
                }
            });

    mSelectableHelper = new SelectableHelper(findViewById(R.id.root_layout), this);

    mRecordingList = findViewById(R.id.recording_list);
    mNoRecordings = findViewById(R.id.no_recordings);

    LinearLayoutManager mLayoutManager = new LinphoneLinearLayoutManager(this);
    mRecordingList.setLayoutManager(mLayoutManager);

    // Divider between items
    DividerItemDecoration dividerItemDecoration =
            new DividerItemDecoration(this, mLayoutManager.getOrientation());
    dividerItemDecoration.setDrawable(getResources().getDrawable(R.drawable.divider));
    mRecordingList.addItemDecoration(dividerItemDecoration);

    mRecordings = new ArrayList<>();

    mPermissionsToHave =
            new String[] {
                Manifest.permission.READ_EXTERNAL_STORAGE,
            };
}
 
Example 18
Source File: HistoryFragment.java    From linphone-android with GNU General Public License v3.0 4 votes vote down vote up
@Override
public View onCreateView(
        LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.history, container, false);
    mSelectionHelper = new SelectableHelper(view, this);

    mNoCallHistory = view.findViewById(R.id.no_call_history);
    mNoMissedCallHistory = view.findViewById(R.id.no_missed_call_history);

    mHistoryList = view.findViewById(R.id.history_list);

    LinearLayoutManager layoutManager = new LinphoneLinearLayoutManager(getActivity());
    mHistoryList.setLayoutManager(layoutManager);
    // Divider between items
    DividerItemDecoration dividerItemDecoration =
            new DividerItemDecoration(
                    mHistoryList.getContext(), layoutManager.getOrientation());
    dividerItemDecoration.setDrawable(getResources().getDrawable(R.drawable.divider));
    mHistoryList.addItemDecoration(dividerItemDecoration);

    mAllCalls = view.findViewById(R.id.all_calls);
    mAllCalls.setOnClickListener(this);

    mAllCallsSelected = view.findViewById(R.id.all_calls_select);

    mMissedCalls = view.findViewById(R.id.missed_calls);
    mMissedCalls.setOnClickListener(this);

    mMissedCallsSelected = view.findViewById(R.id.missed_calls_select);

    mAllCalls.setEnabled(false);
    mOnlyDisplayMissedCalls = false;

    mListener =
            new CoreListenerStub() {
                @Override
                public void onCallStateChanged(
                        Core core, Call call, Call.State state, String message) {
                    if (state == Call.State.End || state == Call.State.Error) {
                        reloadData();
                    }
                }
            };

    return view;
}
 
Example 19
Source File: MessagesActivity.java    From android with MIT License 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_messages);
    ButterKnife.bind(this);
    Log.i("Entering " + getClass().getSimpleName());
    settings = new Settings(this);

    picassoHandler = new PicassoHandler(this, settings);

    client =
            ClientFactory.clientToken(settings.url(), settings.sslSettings(), settings.token());
    appsHolder = new ApplicationHolder(this, client);
    appsHolder.onUpdate(() -> onUpdateApps(appsHolder.get()));
    appsHolder.request();
    initDrawer();

    messages = new MessageFacade(client.createService(MessageApi.class), appsHolder);

    LinearLayoutManager layoutManager = new LinearLayoutManager(this);
    DividerItemDecoration dividerItemDecoration =
            new DividerItemDecoration(
                    messagesView.getContext(), layoutManager.getOrientation());
    ListMessageAdapter adapter =
            new ListMessageAdapter(
                    this, settings, picassoHandler.get(), emptyList(), this::scheduleDeletion);

    messagesView.addItemDecoration(dividerItemDecoration);
    messagesView.setHasFixedSize(true);
    messagesView.setLayoutManager(layoutManager);
    messagesView.addOnScrollListener(new MessageListOnScrollListener());
    messagesView.setAdapter(adapter);

    ItemTouchHelper itemTouchHelper = new ItemTouchHelper(new SwipeToDeleteCallback(adapter));
    itemTouchHelper.attachToRecyclerView(messagesView);

    swipeRefreshLayout.setOnRefreshListener(this::onRefresh);
    drawer.addDrawerListener(
            new DrawerLayout.SimpleDrawerListener() {
                @Override
                public void onDrawerClosed(View drawerView) {
                    if (selectAppIdOnDrawerClose != null) {
                        appId = selectAppIdOnDrawerClose;
                        new SelectApplicationAndUpdateMessages(true)
                                .execute(selectAppIdOnDrawerClose);
                        selectAppIdOnDrawerClose = null;
                    }
                }
            });

    swipeRefreshLayout.setEnabled(false);
    messagesView
            .getViewTreeObserver()
            .addOnScrollChangedListener(
                    () -> {
                        View topChild = messagesView.getChildAt(0);
                        if (topChild != null) {
                            swipeRefreshLayout.setEnabled(topChild.getTop() == 0);
                        } else {
                            swipeRefreshLayout.setEnabled(true);
                        }
                    });

    new SelectApplicationAndUpdateMessages(true).execute(appId);
}
 
Example 20
Source File: FragmentCertificates.java    From FairEmail with GNU General Public License v3.0 4 votes vote down vote up
@Override
@Nullable
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    setSubtitle(R.string.title_advanced_manage_certificates);
    setHasOptionsMenu(true);

    View view = inflater.inflate(R.layout.fragment_certificates, container, false);

    // Get controls
    rvCertificate = view.findViewById(R.id.rvCertificate);
    pbWait = view.findViewById(R.id.pbWait);
    grpReady = view.findViewById(R.id.grpReady);
    fab = view.findViewById(R.id.fab);

    // Wire controls

    rvCertificate.setHasFixedSize(false);
    LinearLayoutManager llm = new LinearLayoutManager(getContext());
    rvCertificate.setLayoutManager(llm);

    DividerItemDecoration itemDecorator = new DividerItemDecoration(getContext(), llm.getOrientation());
    itemDecorator.setDrawable(getContext().getDrawable(R.drawable.divider));
    rvCertificate.addItemDecoration(itemDecorator);

    adapter = new AdapterCertificate(this);
    rvCertificate.setAdapter(adapter);

    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(getContext());
            lbm.sendBroadcast(new Intent(ActivitySetup.ACTION_IMPORT_CERTIFICATE));
        }
    });

    // Initialize
    grpReady.setVisibility(View.GONE);
    pbWait.setVisibility(View.VISIBLE);

    return view;
}