@Override public void onFinishEditDialog(String nameText, String categoryText) { if (mOnCardAddedListener.checkNetworkConnection()) { mPresenter.createDeck(nameText, categoryText); } else { makeErrorToast("You must be connected to the internet"); } }
@Override public void onClick(View v) { switch (v.getId()) { case R.id.createDeckButton: if (mPresenter.getCards().size() > 0) { showNewDeckDialog(); } else { Toast.makeText(getActivity(), "Please add at least one card", Toast.LENGTH_SHORT).show(); } break; } }
@Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_create_deck_display, container, false); ButterKnife.bind(this, view); Log.d("it", "works"); mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(getActivity()); String uid = mSharedPreferences.getString(Constants.KEY_UID, ""); mPresenter = new CreateDeckDisplayPresenter(this, uid); mCreateDeckButton.setOnClickListener(this); adapter = new CardListAdapter(getActivity(), mPresenter.getCards()); mCardsRecyclerView.setAdapter(adapter); RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(getActivity()); mCardsRecyclerView.setLayoutManager(layoutManager); return view; }
public void updateCardsList(ArrayList<Card> cards) { mPresenter.updateCards(cards); if (adapter != null) { adapter.notifyDataSetChanged(); } }