androidx.recyclerview.widget.DividerItemDecoration Java Examples

The following examples show how to use androidx.recyclerview.widget.DividerItemDecoration. 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: Utils.java    From Beedio with GNU General Public License v2.0 6 votes vote down vote up
public static DividerItemDecoration createDivider(final Context context) {
    DividerItemDecoration divider = new DividerItemDecoration(context,
            DividerItemDecoration.VERTICAL) {
        @Override
        public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView
                .State state) {
            int verticalSpacing = (int) Math.ceil(TypedValue.applyDimension(TypedValue
                    .COMPLEX_UNIT_SP, 4, context.getResources()
                    .getDisplayMetrics()));
            outRect.top = verticalSpacing;
            outRect.bottom = verticalSpacing;
        }
    };
    divider.setDrawable(context.getResources().getDrawable(R.drawable.greydivider));
    return divider;
}
 
Example #2
Source File: FilePicker.java    From MyBookshelf with GNU General Public License v3.0 6 votes vote down vote up
@Override
@NonNull
protected LinearLayout makeCenterView() {
    @SuppressLint("InflateParams") LinearLayout rootLayout = (LinearLayout) LayoutInflater.from(activity).inflate(R.layout.view_file_picker, null);

    RecyclerView recyclerView = rootLayout.findViewById(R.id.rv_file);
    recyclerView.addItemDecoration(new DividerItemDecoration(activity, LinearLayout.VERTICAL));
    recyclerView.setLayoutManager(new LinearLayoutManager(activity));
    recyclerView.setAdapter(adapter);

    emptyView = rootLayout.findViewById(R.id.tv_empty);

    RecyclerView pathView = rootLayout.findViewById(R.id.rv_path);
    pathView.setLayoutManager(new LinearLayoutManager(activity, RecyclerView.HORIZONTAL, false));
    pathView.setAdapter(pathAdapter);

    return rootLayout;
}
 
Example #3
Source File: EntryListView.java    From Aegis with GNU General Public License v3.0 6 votes vote down vote up
private void updateDividerDecoration() {
    if (_dividerDecoration != null) {
        _recyclerView.removeItemDecoration(_dividerDecoration);
    }

    float height = _viewMode.getDividerHeight();
    if (_showProgress && height == 0) {
        DividerItemDecoration divider = new DividerItemDecoration(getContext(), DividerItemDecoration.VERTICAL);
        divider.setDrawable(ContextCompat.getDrawable(getContext(), R.drawable.entry_divider));
        _dividerDecoration = divider;
    } else {
        _dividerDecoration = new VerticalSpaceItemDecoration(height);
    }

    _recyclerView.addItemDecoration(_dividerDecoration);
}
 
Example #4
Source File: TEIDataFragment.java    From dhis2-android-capture-app with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public void setData(DashboardProgramModel nprogram) {
    this.dashboardModel = nprogram;

    if (nprogram != null && nprogram.getCurrentEnrollment() != null) {
        presenter.setDashboardProgram(this.dashboardModel);
        SharedPreferences prefs = context.getSharedPreferences(Constants.SHARE_PREFS, Context.MODE_PRIVATE);
        hasCatComb = nprogram.getCurrentProgram() != null && !nprogram.getCurrentProgram().categoryComboUid().equals(prefs.getString(Constants.DEFAULT_CAT_COMBO, ""));
        binding.setDashboardModel(nprogram);
    } else if (nprogram != null) {
        binding.fab.setVisibility(View.GONE);
        binding.teiRecycler.setAdapter(new DashboardProgramAdapter(presenter, nprogram));
        binding.teiRecycler.addItemDecoration(new DividerItemDecoration(getAbstracContext(), DividerItemDecoration.VERTICAL));
        binding.setDashboardModel(nprogram);
    }

    binding.executePendingBindings();

    if (getSharedPreferences().getString("COMPLETED_EVENT", null) != null) {
        presenter.displayGenerateEvent(getSharedPreferences().getString("COMPLETED_EVENT", null));
        getSharedPreferences().edit().remove("COMPLETED_EVENT").apply();
    }


}
 
Example #5
Source File: FilesFragment.java    From ArchPackages with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    if (fragmentFilesBinding != null) {
        fragmentFilesBinding.setFiles(files);
        fragmentFilesBinding.executePendingBindings();
        Context context = fragmentFilesBinding.getRoot().getContext();
        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false);
        RecyclerView recyclerView = fragmentFilesBinding.fragmentFilesRecyclerView;
        recyclerView.setLayoutManager(linearLayoutManager);
        recyclerView.setHasFixedSize(true);
        recyclerView.addItemDecoration(new DividerItemDecoration(context, DividerItemDecoration.VERTICAL));
        RoomFileAdapter roomFileAdapter = new RoomFileAdapter();
        RoomFileViewModel mViewModel = new ViewModelProvider(this).get(RoomFileViewModel.class);
        mViewModel.getPagedListLiveData().observe(getViewLifecycleOwner(), roomFiles -> {
            if (roomFiles != null) {
                roomFileAdapter.submitList(roomFiles);
            }
        });
        recyclerView.setAdapter(roomFileAdapter);
    }
}
 
Example #6
Source File: DataSetDetailActivity.java    From dhis2-android-capture-app with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public void setData(List<DataSetDetailModel> datasets) {
    binding.programProgress.setVisibility(View.GONE);
    if (binding.recycler.getAdapter() == null) {
        binding.recycler.setAdapter(adapter);
        binding.recycler.addItemDecoration(new DividerItemDecoration(getContext(), DividerItemDecoration.VERTICAL));
    }
    if(datasets.size() == 0){
        binding.emptyTeis.setVisibility(View.VISIBLE);
        binding.recycler.setVisibility(View.GONE);
    } else {
        binding.emptyTeis.setVisibility(View.GONE);
        binding.recycler.setVisibility(View.VISIBLE);
        adapter.setDataSets(datasets);
    }
}
 
Example #7
Source File: HomeActivity.java    From auth with MIT License 6 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_home);

    inject();

    adapter =
            new RedditAccountAdapter(
                    accountManager,
                    account -> startActivity(LatestCommentsActivity.newIntent(this, account)));

    RecyclerView recyclerView = findViewById(R.id.recycler_view);
    recyclerView.setAdapter(adapter);
    recyclerView.setLayoutManager(new LinearLayoutManager(this));
    recyclerView.addItemDecoration(
            new DividerItemDecoration(this, DividerItemDecoration.VERTICAL));
}
 
Example #8
Source File: FriendRequests.java    From Hify with MIT License 6 votes vote down vote up
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    mFirestore = FirebaseFirestore.getInstance();
    mAuth = FirebaseAuth.getInstance();

    mRequestView = view.findViewById(R.id.recyclerView);
    refreshLayout=view.findViewById(R.id.refreshLayout);

    requestList = new ArrayList<>();
    requestAdapter = new FriendRequestAdapter(requestList, view.getContext());

    mRequestView.setItemAnimator(new DefaultItemAnimator());
    mRequestView.setLayoutManager(new LinearLayoutManager(view.getContext(), VERTICAL, false));
    mRequestView.addItemDecoration(new DividerItemDecoration(view.getContext(),DividerItemDecoration.VERTICAL));
    mRequestView.setHasFixedSize(true);
    mRequestView.setAdapter(requestAdapter);

    refreshLayout.setOnRefreshListener(this::getUsers);

    getUsers();

}
 
Example #9
Source File: VideoTutorialsActivity.java    From BaldPhone with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(@Nullable final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_help);
    final RecyclerView recycler_view = findViewById(R.id.recycler_view);
    final DividerItemDecoration dividerItemDecoration =
            new DividerItemDecoration(recycler_view.getContext(), DividerItemDecoration.VERTICAL);
    dividerItemDecoration.setDrawable(getDrawable(R.drawable.ll_divider));
    recycler_view.addItemDecoration(dividerItemDecoration);
    final Resources resources = getResources();
    recycler_view.setAdapter(
            new HelpRecyclerViewAdapter(
                    this,
                    S.typedArrayToResArray(resources, R.array.yt_texts),
                    S.typedArrayToResArray(resources, R.array.yt_logos)));
}
 
Example #10
Source File: DialerActivity.java    From BaldPhone with Apache License 2.0 6 votes vote down vote up
private void attachXml() {
    recyclerView = findViewById(R.id.contacts_recycler_view);
    final DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(recyclerView.getContext(), DividerItemDecoration.VERTICAL);
    dividerItemDecoration.setDrawable(getDrawable(R.drawable.ll_divider));
    recyclerView.addItemDecoration(dividerItemDecoration);

    tv_number = findViewById(R.id.tv_number);
    numpad = new View[]{
            findViewById(R.id.b_0),
            findViewById(R.id.b_1),
            findViewById(R.id.b_2),
            findViewById(R.id.b_3),
            findViewById(R.id.b_4),
            findViewById(R.id.b_5),
            findViewById(R.id.b_6),
            findViewById(R.id.b_7),
            findViewById(R.id.b_8),
            findViewById(R.id.b_9)
    };
    empty_view = findViewById(R.id.empty_view);
    b_call = findViewById(R.id.b_call);
    b_clear = findViewById(R.id.b_clear);
    b_backspace = findViewById(R.id.b_backspace);
    b_sulamit = findViewById(R.id.b_sulamit);
    b_hash = findViewById(R.id.b_hash);
}
 
Example #11
Source File: RecentActivity.java    From BaldPhone with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(@Nullable final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (!checkPermissions(this, requiredPermissions()))
        return;

    setContentView(R.layout.activity_recent);

    recyclerView = findViewById(R.id.recycler_view);
    final DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(recyclerView.getContext(), DividerItemDecoration.VERTICAL);
    dividerItemDecoration.setDrawable(getDrawable(R.drawable.ll_divider));
    recyclerView.addItemDecoration(dividerItemDecoration);
    final CallsRecyclerViewAdapter callsRecyclerViewAdapter = new CallsRecyclerViewAdapter(CallLogsHelper.getAllCalls(getContentResolver()), this);
    CallLogsHelper.markAllAsRead(getContentResolver());
    recyclerView.setAdapter(callsRecyclerViewAdapter);

    setupYoutube(3);
}
 
Example #12
Source File: BaseListFragment.java    From pandora with Apache License 2.0 6 votes vote down vote up
@Override
protected View getLayoutView() {
    adapter = new UniversalAdapter();
    recyclerView = new MenuRecyclerView(getContext());
    recyclerView.setBackgroundColor(ViewKnife.getColor(R.color.pd_main_bg));
    recyclerView.setLayoutManager(onCreateLayoutManager());
    if (needDefaultDivider()) {
        DividerItemDecoration divider = new DividerItemDecoration(getContext(), DividerItemDecoration.VERTICAL);
        GradientDrawable horizontalDrawable = new GradientDrawable();
        horizontalDrawable.setColor(0xffE5E5E5);
        horizontalDrawable.setSize(0, 1);
        divider.setDrawable(horizontalDrawable);
        recyclerView.addItemDecoration(divider);
    }
    recyclerView.setAdapter(adapter);
    return recyclerView;
}
 
Example #13
Source File: ClusterMapContributeActivity.java    From intra42 with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_cluster_map_contribute);
    setActionBarToggle(ActionBarToggle.ARROW);

    recyclerView = findViewById(R.id.recyclerView);
    swipeRefreshLayout = findViewById(R.id.swipeRefreshLayout);

    recyclerView.setLayoutManager(new LinearLayoutManager(this));
    recyclerView.setNestedScrollingEnabled(false);
    recyclerView.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL));

    new Thread(new Runnable() {
        @Override
        public void run() {
            listCampus = CacheCampus.getAllowInternet(app.cacheSQLiteHelper, app);
        }
    }).start();

    super.onCreateFinished();
}
 
Example #14
Source File: CoalitionsActivity.java    From intra42 with Apache License 2.0 6 votes vote down vote up
@Override
protected void setViewContent() {
    if (blocs == null) {
        setViewState(StatusCode.EMPTY);
        return;
    }
    List<Coalitions> coalitions = blocs.coalitions;
    Collections.sort(coalitions, (o1, o2) -> {
        if (o1.score == o2.score)
            return 0;
        return o1.score < o2.score ? 1 : -1;
    });

    RecyclerAdapterCoalitionsBlocs adapter = new RecyclerAdapterCoalitionsBlocs(this, coalitions);
    recyclerView.setAdapter(adapter);
    recyclerView.setLayoutManager(new LinearLayoutManager(this));
    recyclerView.setNestedScrollingEnabled(false);
    DividerItemDecoration decoration = new DividerItemDecoration(this, DividerItemDecoration.VERTICAL);
    Drawable decoDrawable = decoration.getDrawable();
    decoDrawable.setAlpha(1);
    decoration.setDrawable(decoDrawable);
    recyclerView.addItemDecoration(decoration);
}
 
Example #15
Source File: UrbanDictSheet.java    From PretendYoureXyzzyAndroid with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onCreateBody(@NonNull LayoutInflater inflater, @NonNull ViewGroup parent, @NonNull String payload) {
    inflater.inflate(R.layout.sheet_urban_dict, parent, true);

    message = parent.findViewById(R.id.urbanDictSheet_message);
    list = parent.findViewById(R.id.urbanDictSheet_list);
    list.setLayoutManager(new LinearLayoutManager(getContext(), RecyclerView.VERTICAL, false));
    list.addItemDecoration(new DividerItemDecoration(requireContext(), DividerItemDecoration.VERTICAL));

    UrbanDictApi.get().define(payload, getActivity(), new UrbanDictApi.OnDefine() {
        @Override
        public void onResult(@NonNull Definitions result) {
            update(result);
            isLoading(false);

            ThisApplication.sendAnalytics(Utils.ACTION_OPEN_URBAN_DICT);
        }

        @Override
        public void onException(@NonNull Exception ex) {
            Log.e(TAG, "Failed getting definition.", ex);
            DialogUtils.showToast(getContext(), Toaster.build().message(R.string.failedLoading));
            dismissAllowingStateLoss();
        }
    });
}
 
Example #16
Source File: BaseRecyclerViewActivity.java    From SmartSwipe with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_base_recycler_view);
    recyclerView = findViewById(R.id.recyclerView);


    LinearLayoutManager layoutManager = new LinearLayoutManager(this);
    layoutManager.setOrientation(RecyclerView.VERTICAL);
    recyclerView.setLayoutManager(layoutManager);
    recyclerView.setItemAnimator(new DefaultItemAnimator());
    recyclerView.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL));
    recyclerView.setItemAnimator(new DefaultItemAnimator());
    adapter = new RecyclerAdapter(getInitData());
    recyclerView.setAdapter(adapter);
}
 
Example #17
Source File: SwitchNetworkFragment.java    From green_android with GNU General Public License v3.0 6 votes vote down vote up
@Override
public View onCreateView(final LayoutInflater inflater, final ViewGroup container,
                         final Bundle savedInstanceState) {
    final View view = inflater.inflate(R.layout.switch_network_dialog_fragment, container, false);

    final RecyclerView recyclerView = UI.find(view, R.id.switch_network_recycler);
    recyclerView.addItemDecoration(new DividerItemDecoration(getContext(), LinearLayoutManager.VERTICAL) {
        @Override
        public void onDraw(Canvas canvas, RecyclerView parent, RecyclerView.State state) {
            // Do not draw the divider
        }
    });

    final NetworkData networkData = getGAApp().getCurrentNetworkData();
    recyclerView.setAdapter(new SwitchNetworkAdapter(getContext(), GDKSession.getNetworks(),
                                                     networkData,
                                                     this));
    recyclerView.setLayoutManager(new GridLayoutManager(getContext(), 1));

    return view;
}
 
Example #18
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 #19
Source File: RecentNotificationFragment.java    From NGA-CLIENT-VER-OPEN-SOURCE with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    mRefreshLayout = view.findViewById(R.id.swipe_refresh);
    mRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            mNotificationTask.queryRecentReply(RecentNotificationFragment.this);
        }
    });
    mRefreshLayout.setVisibility(View.GONE);

    mLoadingLayout = view.findViewById(R.id.loading_view);
    mEmptyLayout = view.findViewById(R.id.empty_view);

    RecyclerViewEx listView = view.findViewById(R.id.list);
    listView.setLayoutManager(new LinearLayoutManager(getContext()));
    listView.setAdapter(mNotificationAdapter);
    listView.setEmptyView(mEmptyLayout);
    listView.addItemDecoration(new DividerItemDecoration(getContext(), DividerItemDecoration.VERTICAL));

    mNotificationTask.queryRecentReply(this);
}
 
Example #20
Source File: ScanActivity.java    From DeviceConnect-Android with MIT License 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_scan);

    if (DEBUG) {
        Log.d(TAG, "onCreate()");
        Log.d(TAG, "savedInstanceState : " + savedInstanceState);
    }

    mBLEScanner = new BLEScanner(this);
    mListAdapter = new ListAdapter<>(new ArrayList<>(), R.layout.list_scan_row, this);

    RecyclerView deviceList = findViewById(R.id.list_device);
    deviceList.setHasFixedSize(true);
    deviceList.setLayoutManager(new LinearLayoutManager(this));
    deviceList.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL));
    deviceList.setAdapter(mListAdapter);

    BluetoothManager bluetoothManager = (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE);
    if (bluetoothManager != null) {
        BluetoothAdapter bluetoothAdapter = bluetoothManager.getAdapter();
        if (bluetoothAdapter.isEnabled()) {
            startScan();
        } else {
            Intent intent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
            startActivityForResult(intent, REQUEST_ENABLE_BLUETOOTH);
        }
    }
}
 
Example #21
Source File: FilePicker.java    From a with GNU General Public License v3.0 6 votes vote down vote up
@Override
@NonNull
protected LinearLayout makeCenterView() {
    @SuppressLint("InflateParams") LinearLayout rootLayout = (LinearLayout) LayoutInflater.from(activity).inflate(R.layout.view_file_picker, null);

    RecyclerView recyclerView = rootLayout.findViewById(R.id.rv_file);
    recyclerView.addItemDecoration(new DividerItemDecoration(activity, LinearLayout.VERTICAL));
    recyclerView.setLayoutManager(new LinearLayoutManager(activity));
    recyclerView.setAdapter(adapter);

    emptyView = rootLayout.findViewById(R.id.tv_empty);

    RecyclerView pathView = rootLayout.findViewById(R.id.rv_path);
    pathView.setLayoutManager(new LinearLayoutManager(activity, LinearLayout.HORIZONTAL, false));
    pathView.setAdapter(pathAdapter);

    return rootLayout;
}
 
Example #22
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 #23
Source File: MainActivity.java    From SugarAdapter with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    RecyclerView recyclerView = findViewById(R.id.recycler);
    recyclerView.setLayoutManager(new LinearLayoutManager(this));
    recyclerView.addItemDecoration(new DividerItemDecoration(this, RecyclerView.VERTICAL));

    // Choose one of usage example
    simpleUsageExample(recyclerView);
    // singleDataMultiHolderExample(recyclerView);
    // sugarHolderListenerExample(recyclerView);
    // lifecycleAwareExample(recyclerView);
}
 
Example #24
Source File: InviteMemberActivity.java    From SendBird-Android with MIT License 5 votes vote down vote up
private void setUpRecyclerView() {
    mLayoutManager = new LinearLayoutManager(this);
    mRecyclerView.setLayoutManager(mLayoutManager);
    mRecyclerView.setAdapter(mListAdapter);
    mRecyclerView.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL));

    mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
        @Override
        public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
            if (mLayoutManager.findLastVisibleItemPosition() == mListAdapter.getItemCount() - 1) {
                loadNextUserList(10);
            }
        }
    });
}
 
Example #25
Source File: ScannerActivity.java    From Android-nRF-Mesh-Library with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
protected void onCreate(@Nullable final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_scanner);
    ButterKnife.bind(this);

    // Create view model containing utility methods for scanning
    mViewModel = new ViewModelProvider(this, mViewModelFactory).get(ScannerViewModel.class);

    final Toolbar toolbar = findViewById(R.id.toolbar);
    toolbar.setTitle(R.string.title_scanner);
    setSupportActionBar(toolbar);
    //noinspection ConstantConditions
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    if (getIntent() != null) {
        mScanWithProxyService = getIntent().getBooleanExtra(Utils.EXTRA_DATA_PROVISIONING_SERVICE, true);
        if (mScanWithProxyService) {
            getSupportActionBar().setSubtitle(R.string.sub_title_scanning_nodes);
        } else {
            getSupportActionBar().setSubtitle(R.string.sub_title_scanning_proxy_node);
        }
    }

    // Configure the recycler view
    final RecyclerView recyclerViewDevices = findViewById(R.id.recycler_view_ble_devices);
    recyclerViewDevices.setLayoutManager(new LinearLayoutManager(this));
    final DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(recyclerViewDevices.getContext(), DividerItemDecoration.VERTICAL);
    recyclerViewDevices.addItemDecoration(dividerItemDecoration);

    final SimpleItemAnimator itemAnimator = (SimpleItemAnimator) recyclerViewDevices.getItemAnimator();
    if (itemAnimator != null) itemAnimator.setSupportsChangeAnimations(false);

    final DevicesAdapter adapter = new DevicesAdapter(this, mViewModel.getScannerRepository().getScannerResults());
    adapter.setOnItemClickListener(this);
    recyclerViewDevices.setAdapter(adapter);

    mViewModel.getScannerRepository().getScannerState().observe(this, this::startScan);
}
 
Example #26
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 #27
Source File: TransactionListActivity.java    From Gander with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.gander_act_transaction_list);
    Toolbar toolbar = findViewById(R.id.gander_toolbar);
    setSupportActionBar(toolbar);
    toolbar.setSubtitle(getApplicationName());

    mRecyclerView = findViewById(R.id.gander_transaction_list);
    final AppBarLayout appBarLayout = findViewById(R.id.gander_appbar);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) {
        appBarLayout.setOnApplyWindowInsetsListener(new View.OnApplyWindowInsetsListener() {
            @Override
            public WindowInsets onApplyWindowInsets(View v, WindowInsets insets) {
                appBarLayout.setPadding(0, insets.getSystemWindowInsetTop(), 0, 0);
                return insets;
            }
        });
    }

    mListDiffUtil = new ListDiffUtil();
    mTransactionAdapter = new TransactionAdapter(this, mListDiffUtil).setListener(this);
    mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
    mRecyclerView.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL));

    mRecyclerView.setAdapter(mTransactionAdapter);

    mViewModel = ViewModelProviders.of(this).get(TransactionListViewModel.class);

    loadResults(null, mViewModel.getTransactions(null));
}
 
Example #28
Source File: CustomNotificationSettingsActivity.java    From an2linuxclient with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_custom_notification_settings);

    final CustomProgressDialog progressDialog = new CustomProgressDialog();
    progressDialog.setCancelable(false);
    progressDialog.show(getSupportFragmentManager(), "progressDialog");

    final RecyclerView recyclerView = findViewById(R.id.recyclerView);
    final ConstraintLayout emptyView = findViewById(R.id.emptyView);
    emptyView.setOnClickListener(view -> {
        Intent intent = new Intent(CustomNotificationSettingsActivity.this, EnabledApplicationsActivity.class);
        startActivityForResult(intent, RETURNED_FROM_ENABLED_APPS_SETTINGS_REQUEST);
    });

    recyclerView.setHasFixedSize(true);
    recyclerView.setLayoutManager(new LinearLayoutManager(this));

    final CustomNotificationSettingsAdapter adapter = new CustomNotificationSettingsAdapter(this);
    recyclerView.setAdapter(adapter);

    recyclerView.addItemDecoration(new DividerItemDecoration(recyclerView.getContext(), DividerItemDecoration.VERTICAL));

    viewModel = ViewModelProviders.of(this).get(CustomNotificationSettingsViewModel.class);
    viewModel.getAppsDataList().observe(this, customSettingsAppData -> {
        adapter.setAppDataList(customSettingsAppData);
        progressDialog.dismiss();
        if (customSettingsAppData.size() == 0) {
            emptyView.setVisibility(View.VISIBLE);
            recyclerView.setVisibility(View.GONE);
        } else {
            emptyView.setVisibility(View.GONE);
            recyclerView.setVisibility(View.VISIBLE);
        }
    });
}
 
Example #29
Source File: BlockedMembersListActivity.java    From SendBird-Android with MIT License 5 votes vote down vote up
private void setUpRecyclerView() {
    mLayoutManager = new LinearLayoutManager(this);
    mRecyclerView.setLayoutManager(mLayoutManager);
    mRecyclerView.setAdapter(mListAdapter);
    mRecyclerView.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL));
    mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
        @Override
        public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
            if (mLayoutManager.findLastVisibleItemPosition() == mListAdapter.getItemCount() - 1) {
                loadNextUserList(10);
            }
        }
    });
}
 
Example #30
Source File: TableView.java    From dhis2-android-capture-app with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public DividerItemDecoration getHorizontalItemDecoration() {
    if (mHorizontalItemDecoration == null) {
        mHorizontalItemDecoration = createItemDecoration(DividerItemDecoration.HORIZONTAL);
    }
    return mHorizontalItemDecoration;
}