如何在BottomNavigationView中通知已删除查询

时间:2018-08-22 22:19:43

标签: java android

我正在尝试通知BottomNavigationView中的徽章。当我添加一条记录时,它很重要,但是当我删除该记录时,它并不能确定它已更改。仅在我关闭并打开该应用程序时有效。

我正在使用以下两个库: https://github.com/ittianyu/BottomNavigationViewEx https://github.com/qstumn/BadgeView

public void configuraBottomNavigationView(){
        BottomNavigationViewEx bottomNavigationViewEx = findViewById(R.id.bottomNavigation);
        bottomNavigationViewEx.enableAnimation(true);
        bottomNavigationViewEx.enableItemShiftingMode(true);
        bottomNavigationViewEx.enableShiftingMode(false);
        bottomNavigationViewEx.setTextVisibility(true);
        habilitarNavegacao(bottomNavigationViewEx);

        Menu menu = bottomNavigationViewEx.getMenu();
        MenuItem menuItem = menu.getItem(0);
        menuItem.setChecked(true);
        new QBadgeView(getApplicationContext())
                .setGravityOffset(59, 2, true)
                .bindTarget(bottomNavigationViewEx.getBottomNavigationItemView(1))
                .setBadgeNumber((int) getShoppingCount());
    }

    public long getShoppingCount() {
        SQLiteDatabase db = openOrCreateDatabase("DB_SHOPPING", MODE_PRIVATE, null);
        long count = DatabaseUtils.queryNumEntries(db, "shopping");
        db.close();
        return count;
    }

recyclerView = view.findViewById(R.id.recyclerViewShopping);

        recyclerView.addOnItemTouchListener(new RecyclerItemClickListener(getActivity(), recyclerView, new RecyclerItemClickListener.OnItemClickListener() {
            @Override
            public void onItemClick(View view, int position) {

            }

            @Override
            public void onLongItemClick(View view, int position) {
                cars = listShopping.get(position);
                PurchaseDAO purchaseDAO = new PurchaseDAO(getActivity().getApplicationContext());

                if (purchaseDAO.delete(cars)){
                    loadShopping();
                    sumShopping();
                    Toast.makeText(getActivity().getApplicationContext(), "Purchase deleted successfully.", Toast.LENGTH_LONG).show();
                } else {
                    Toast.makeText(getActivity().getApplicationContext(), "Error deleting.", Toast.LENGTH_LONG).show();
                }

            }

            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

            }
        }));

0 个答案:

没有答案