Java Code Examples for android.support.v7.widget.DividerItemDecoration#VERTICAL

The following examples show how to use android.support.v7.widget.DividerItemDecoration#VERTICAL . 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: TaskListFragment.java    From mvp-helpers with MIT License 6 votes vote down vote up
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    ButterKnife.bind(this, view);

    final DividerItemDecoration itemDecoration = new DividerItemDecoration(getApplicationContext(), DividerItemDecoration.VERTICAL);
    itemDecoration.setDrawable(ContextCompat.getDrawable(getApplicationContext(), R.drawable.divider));

    taskListAdapter = new TaskListAdapter(getApplicationContext(), new ArrayList<>());
    taskListAdapter.setOnItemSelectedListener(this::handleItemSelected);

    taskListView.setLayoutManager(new LinearLayoutManager(getApplicationContext()));
    taskListView.addOnScrollListener(new RecyclerViewScrollBehavior(newTaskButton));
    taskListView.setItemViewCacheSize(1024 * 24);
    taskListView.addItemDecoration(itemDecoration);
    taskListView.setItemAnimator(new DefaultItemAnimator());
    taskListView.setAdapter(taskListAdapter);
    taskListView.setHasFixedSize(true);

    taskListAdapter.notifyDataSetChanged();
}
 
Example 2
Source File: ItemTabFragment.java    From Companion-For-PUBG-Android with MIT License 6 votes vote down vote up
@Override
public void onViewCreated(@NonNull final View view, @Nullable final Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    final Bundle args = getArguments();
    if (args == null || !args.containsKey(ARG_CATEGORY_NAME)) {
        return;
    }
    final Category.Name categoryName = (Category.Name) args.getSerializable(ARG_CATEGORY_NAME);
    if (this.recyclerView == null || categoryName == null) {
        return;
    }
    final Category<Item> category = PUBGApplication.getInstance().getItems().getCategories().get(categoryName);
    if (category == null) {
        return;
    }
    final DividerItemDecoration itemDecoration = new DividerItemDecoration(getActivity(), DividerItemDecoration.VERTICAL);
    this.recyclerView.addItemDecoration(itemDecoration);
    this.recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
    final ItemRecyclerViewAdapter<Item> adapter = new ItemRecyclerViewAdapter<>(category.getItems());
    adapter.setListener(this);
    this.recyclerView.setAdapter(adapter);
}
 
Example 3
Source File: AmmoDetailFragment.java    From Companion-For-PUBG-Android with MIT License 6 votes vote down vote up
@Override
public void onViewCreated(final View view,
                          @Nullable final Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    final Bundle args = getArguments();
    if (args == null) {
        throw new IllegalStateException("Missing arguments");
    }
    final Ammo ammo = (Ammo) args.getSerializable(ARG_AMMO);
    if (ammo == null) {
        throw new IllegalStateException("Missing Ammo");
    }
    setNameText(ammo.getName());
    setAmmoImageView(ammo.getImageUrl());
    if (this.weaponsRecycler != null) {
        final WeaponList weapons = PUBGApplication.getInstance().getItems().getCategories().getWeaponCategory().getWeaponsUsingAmmo(ammo.getId());
        ItemRecyclerViewAdapter<Weapon> adapter = new ItemRecyclerViewAdapter<>((weapons));
        adapter.setListener(this);
        final DividerItemDecoration itemDecoration = new DividerItemDecoration(getActivity(), DividerItemDecoration.VERTICAL);
        this.weaponsRecycler.addItemDecoration(itemDecoration);
        this.weaponsRecycler.setLayoutManager(new LinearLayoutManager(getActivity()));

        this.weaponsRecycler.setAdapter(adapter);
    }

}
 
Example 4
Source File: NotificationActivity.java    From 1Rramp-Android with MIT License 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_notification);
  ButterKnife.bind(this);
  mNotifications = new ArrayList<>();
  DividerItemDecoration itemDecor = new DividerItemDecoration(this, DividerItemDecoration.VERTICAL);
  Drawable drawable = getResources().getDrawable(R.drawable.notification_divider);
  itemDecor.setDrawable(drawable);
  mHandler = new Handler();
  notificationAdapter = new NotificationAdapter();
  recyclerView.setLayoutManager(new LinearLayoutManager(this));
  recyclerView.addItemDecoration(itemDecor);
  recyclerView.setAdapter(notificationAdapter);
  backBtn.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View view) {
      finish();
    }
  });
  listenToNotifications();
}
 
Example 5
Source File: SourceFragment.java    From NewsApp with GNU General Public License v3.0 6 votes vote down vote up
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {

    FragmentSourceBinding binding = DataBindingUtil.inflate(inflater,
            R.layout.fragment_source, container, false);

    setupViewModel();
    binding.rvSources.setAdapter(sourceAdapter);
    if (getContext() != null) {
        DividerItemDecoration divider = new DividerItemDecoration(getContext(), DividerItemDecoration.VERTICAL);
        divider.setDrawable(getResources().getDrawable(R.drawable.recycler_view_divider));
        binding.rvSources.addItemDecoration(divider);
    }

    return binding.getRoot();
}
 
Example 6
Source File: ScannerFragment.java    From neatle with MIT License 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    RecyclerView view = (RecyclerView) inflater.inflate(R.layout.fragment_scanner_list, container, false);

    DividerItemDecoration dividerItemDecoration =
            new DividerItemDecoration(view.getContext(), DividerItemDecoration.VERTICAL);
    view.addItemDecoration(dividerItemDecoration);

    adapter = new ScannerRecyclerViewAdapter(listener);
    view.setAdapter(adapter);

    return view;
}
 
Example 7
Source File: MosqueFragment.java    From android with Apache License 2.0 5 votes vote down vote up
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    mPresenter.setView(this);
    mPresenter.getMosqueList(false);

    mRefreshLayout.setColorSchemeResources(R.color.colorAccent);
    mRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            mPresenter.getMosqueList(true);
        }
    });

    LinearLayoutManager llm = new LinearLayoutManager(getActivity());

    TypedArray ta = getActivity().obtainStyledAttributes(new int[] {R.attr.mosqueDividerDrawable});
    Drawable divider = ta.getDrawable(0);
    ta.recycle();

    DividerItemDecoration decor = new DividerItemDecoration(getActivity(), DividerItemDecoration.VERTICAL);
    decor.setDrawable(divider);

    mRecyclerView.setLayoutManager(llm);
    mRecyclerView.addItemDecoration(decor);

    if (mRecyclerView.getAdapter() == null) mRecyclerView.setAdapter(mAdapter);

    Drawable drawable = mProgressView.getDrawable();
    if (drawable instanceof Animatable) {
        ((Animatable) drawable).start();
    }
}
 
Example 8
Source File: FindFragment.java    From POCenter with MIT License 5 votes vote down vote up
@Override
protected void initView(View view) {
    bind = DataBindingUtil.bind(view);

    // init recycler view
    findAdapter = new FindAdapter(new ArrayList<ProjectBean>(0));
    bind.rv.setAdapter(findAdapter);
    bind.rv.setLayoutManager(new LinearLayoutManager(getContext()));
    DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(getContext(), DividerItemDecoration.VERTICAL);
    dividerItemDecoration.setDrawable(getResources().getDrawable(R.drawable.shape_drive_line));
    bind.rv.addItemDecoration(dividerItemDecoration);

    initEvent();
}
 
Example 9
Source File: HomeFragment.java    From POCenter with MIT License 5 votes vote down vote up
@Override
protected void initView(View view) {
    bind = DataBindingUtil.bind(view);

    // init recycler view
    homeAdapter = new HomeAdapter(new ArrayList<ProjectBean>(0));
    bind.rv.setAdapter(homeAdapter);
    bind.rv.setLayoutManager(new LinearLayoutManager(getContext()));
    DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(getContext(), DividerItemDecoration.VERTICAL);
    dividerItemDecoration.setDrawable(getResources().getDrawable(R.drawable.shape_drive_line));
    bind.rv.addItemDecoration(dividerItemDecoration);

    initEvent();
}
 
Example 10
Source File: AdhellPermissionInAppsFragment.java    From SABS with MIT License 5 votes vote down vote up
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    if (parentActivity.getSupportActionBar() != null) {
        parentActivity.getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        parentActivity.getSupportActionBar().setHomeButtonEnabled(true);
    }

    ((MainActivity)getActivity()).hideBottomBar();

    sharedAppPermissionViewModel = ViewModelProviders.of(getActivity()).get(SharedAppPermissionViewModel.class);
    View view = inflater.inflate(R.layout.fragment_permission_in_apps, container, false);
    permissionInAppsRecyclerView = view.findViewById(R.id.permissionInAppsRecyclerView);
    permissionInAppsRecyclerView.setLayoutManager(new LinearLayoutManager(this.getContext()));
    RecyclerView.ItemDecoration itemDecoration = new DividerItemDecoration(this.getContext(), DividerItemDecoration.VERTICAL);
    permissionInAppsRecyclerView.addItemDecoration(itemDecoration);

    sharedAppPermissionViewModel.getSelected().observe(this, permissionInfo -> {
        getActivity().setTitle(permissionInfo.name);
        appInfos = sharedAppPermissionViewModel.loadPermissionsApps(sharedAppPermissionViewModel.installedApps, permissionInfo.name);
        AdhellPermissionInAppsAdapter adhellPermissionInAppsAdapter = new AdhellPermissionInAppsAdapter(this.getContext(), appInfos);
        adhellPermissionInAppsAdapter.currentPermissionName = permissionInfo.name;
        adhellPermissionInAppsAdapter.updateRestrictedPackages();
        permissionInAppsRecyclerView.setAdapter(adhellPermissionInAppsAdapter);
        adhellPermissionInAppsAdapter.notifyDataSetChanged();
    });
    return view;
}
 
Example 11
Source File: MainActivity.java    From droidovpn with GNU General Public License v3.0 5 votes vote down vote up
private void setupRecyclerView() {
    adapter = new ServerAdapter(servers, serverClickCallback);
    EmptyRecyclerView recyclerView = findViewById(R.id.recyclerview);
    RecyclerView.ItemDecoration itemDecoration = new
            DividerItemDecoration(this, DividerItemDecoration.VERTICAL);
    recyclerView.setHasFixedSize(true);
    recyclerView.addItemDecoration(itemDecoration);
    recyclerView.setLayoutManager(new LinearLayoutManager(recyclerView.getContext()));
    recyclerView.setEmptyView(findViewById(android.R.id.empty));
    recyclerView.setAdapter(adapter);
}
 
Example 12
Source File: NewsFragment.java    From NewsApp with GNU General Public License v3.0 5 votes vote down vote up
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
                         @Nullable Bundle savedInstanceState) {
    binding = DataBindingUtil
            .inflate(inflater, R.layout.news_fragment, container, false);
    RecyclerView recyclerView = binding.rvNewsPosts;
    recyclerView.setAdapter(newsAdapter);
    if (getContext() != null) {
        DividerItemDecoration divider = new DividerItemDecoration(getContext(), DividerItemDecoration.VERTICAL);
        divider.setDrawable(getResources().getDrawable(R.drawable.recycler_view_divider));
        recyclerView.addItemDecoration(divider);
    }

    return binding.getRoot();
}
 
Example 13
Source File: InboxFragment.java    From Beginner-Level-Android-Studio-Apps with GNU General Public License v3.0 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View rootView = inflater.inflate(R.layout.fragment_inbox, container, false);
    mRecyclerView = rootView.findViewById(R.id.rv_inbox);
    mRecyclerView.setHasFixedSize(true);
    mRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
    RecyclerView.ItemDecoration itemDecoration = new DividerItemDecoration(getActivity(), DividerItemDecoration.VERTICAL);
    mRecyclerView.addItemDecoration(itemDecoration);
    List<InboxMessageModel> inboxMessageModelList = getInboxMessageList();
    mInboxAdapter = new InboxAdapter(getContext(), inboxMessageModelList, this, selectedInboxMessageModelList);
    mRecyclerView.setAdapter(mInboxAdapter);
    return rootView;
}
 
Example 14
Source File: AdhellPermissionInAppsFragment.java    From notSABS with MIT License 5 votes vote down vote up
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    if (parentActivity.getSupportActionBar() != null) {
        parentActivity.getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        parentActivity.getSupportActionBar().setHomeButtonEnabled(true);
    }

    ((MainActivity)getActivity()).hideBottomBar();

    sharedAppPermissionViewModel = ViewModelProviders.of(getActivity()).get(SharedAppPermissionViewModel.class);
    View view = inflater.inflate(R.layout.fragment_permission_in_apps, container, false);
    permissionInAppsRecyclerView = view.findViewById(R.id.permissionInAppsRecyclerView);
    permissionInAppsRecyclerView.setLayoutManager(new LinearLayoutManager(this.getContext()));
    RecyclerView.ItemDecoration itemDecoration = new DividerItemDecoration(this.getContext(), DividerItemDecoration.VERTICAL);
    permissionInAppsRecyclerView.addItemDecoration(itemDecoration);

    sharedAppPermissionViewModel.getSelected().observe(this, permissionInfo -> {
        getActivity().setTitle(permissionInfo.name);
        appInfos = sharedAppPermissionViewModel.loadPermissionsApps(sharedAppPermissionViewModel.installedApps, permissionInfo.name);
        AdhellPermissionInAppsAdapter adhellPermissionInAppsAdapter = new AdhellPermissionInAppsAdapter(this.getContext(), appInfos);
        adhellPermissionInAppsAdapter.currentPermissionName = permissionInfo.name;
        adhellPermissionInAppsAdapter.updateRestrictedPackages();
        permissionInAppsRecyclerView.setAdapter(adhellPermissionInAppsAdapter);
        adhellPermissionInAppsAdapter.notifyDataSetChanged();
    });
    return view;
}
 
Example 15
Source File: CommentFragment.java    From v9porn with MIT License 5 votes vote down vote up
@Override
public void onAttach(Activity activity) {
    super.onAttach(activity);
    dividerItemDecoration = new DividerItemDecoration(activity, DividerItemDecoration.VERTICAL);
    videoCommentAdapter = new VideoCommentAdapter(getContext(), R.layout.item_video_comment, videoCommentList);
    videoCommentAdapter.setOnLoadMoreListener(new BaseQuickAdapter.RequestLoadMoreListener() {
        @Override
        public void onLoadMoreRequested() {
            //加载评论
            if (v9PornItem.getVideoResultId() == 0) {
                videoCommentAdapter.loadMoreFail();
                return;
            }
            presenter.loadVideoComment(v9PornItem.getVideoResult().getVideoId(), v9PornItem.getViewKey(), false);
        }
    }, recyclerViewVideoComment);
    videoCommentAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
        @Override
        public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
            isComment = false;
            videoCommentAdapter.setClickPosition(position);
            videoCommentAdapter.notifyDataSetChanged();
            videoComment = (VideoComment) adapter.getData().get(position);
            etCommentVideo.setHint("回复:" + videoComment.getuName());
        }
    });
    commentVideoDialog = DialogUtils.initLoadingDialog(getContext(), "提交评论中,请稍后...");
}
 
Example 16
Source File: BaseListFragment.java    From playa with MIT License 5 votes vote down vote up
@Override
public void onFragmentViewCreated() {
    super.onFragmentViewCreated();
    layoutManager = new LinearLayoutManager(context);
    recyclerView.setLayoutManager(layoutManager);
    DividerItemDecoration itemDecoration = new DividerItemDecoration(context,
            DividerItemDecoration.VERTICAL);
    Drawable drawable = ContextCompat.getDrawable(context, R.drawable.list_divider);
    itemDecoration.setDrawable(drawable);
    recyclerView.addItemDecoration(itemDecoration);
}
 
Example 17
Source File: DoublelistlinkageActivity.java    From AndroidSamples with Apache License 2.0 5 votes vote down vote up
private void initView() {
    mLinearLayoutManager = new LinearLayoutManager(mContext);
    rvSort.setLayoutManager(mLinearLayoutManager);
    // 系统默认样式?
    DividerItemDecoration decoration = new DividerItemDecoration(mContext, DividerItemDecoration.VERTICAL);
    rvSort.addItemDecoration(decoration);
}
 
Example 18
Source File: CustomDividerActivity.java    From ItemDecorationDemo with Apache License 2.0 5 votes vote down vote up
private void initView() {
    findViewById(R.id.btn_padding).setVisibility(View.GONE);
    rvTest = findViewById(R.id.rv_test);
    mAdapter = new SampleAdapter(createList());
    rvTest.setAdapter(mAdapter);
    rvTest.setLayoutManager(new LinearLayoutManager(this));
    DividerItemDecoration decoration = new DividerItemDecoration(this,DividerItemDecoration.VERTICAL);
    decoration.setDrawable(getResources().getDrawable(R.drawable.divider_gradient));
    rvTest.addItemDecoration(decoration);
}
 
Example 19
Source File: AbstractListActivity.java    From eternity with Apache License 2.0 4 votes vote down vote up
protected RecyclerView.ItemDecoration getItemDividerDecoration() {
  return new DividerItemDecoration(this, DividerItemDecoration.VERTICAL);
}
 
Example 20
Source File: GanHuoPageFragment.java    From scallop with MIT License 4 votes vote down vote up
@Override
public void onFragmentViewCreated() {
    super.onFragmentViewCreated();

    if (presenter != null) {
        presenter.attachView(this);
    }

    String tabTitle = getArguments().getString("TITLE");
    categoryName = tabTitle.equals(getContext().getString(R.string.tab_title_all)) ? "all" : tabTitle;

    LinearLayoutManager layoutManager = new LinearLayoutManager(getContext());
    recyclerView.setLayoutManager(layoutManager);
    DividerItemDecoration itemDecoration = new DividerItemDecoration(getContext(),
            DividerItemDecoration.VERTICAL);
    itemDecoration.setDrawable(ContextCompat.getDrawable(getContext(),
            R.drawable.recycler_divider));
    recyclerView.addItemDecoration(itemDecoration);
    adapter = new GanhuoAdapter();
    recyclerView.setAdapter(adapter);

    recyclerViewScrollListener = new EndlessRecyclerViewScrollListener(layoutManager) {
        @Override
        public void onLoadMore(int page, int totalItemsCount, RecyclerView view) {
            adapter.setLoading();
            presenter.getGanHuo(categoryName, page);
        }
    };
    recyclerView.addOnScrollListener(recyclerViewScrollListener);

    refreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            presenter.getGanHuo(categoryName, 1);
            recyclerViewScrollListener.resetState();
            adapter.clear();
            adapter.resetFooter();
        }
    });
    refreshLayout.setRefreshing(true);
    presenter.getGanHuo(categoryName, 1);
}