Back to project page vocabulary-list.
The source code is released under:
Apache License
If you think the Android project vocabulary-list listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.rulych.vocabularylist.fragments; /* ww w . j a va 2 s . c o m*/ import com.rulych.vocabularylist.R; import com.rulych.vocabularylist.model.Card; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.Toast; import butterknife.OnClick; import rx.android.schedulers.AndroidSchedulers; import rx.functions.Action1; import timber.log.Timber; public class CardFragment extends BaseCardFragment { public static final String ARG_CARD_ENTRY = "card-entry"; private Card mCard; public static CardFragment newInstance(Card card) { CardFragment fragment = new CardFragment(); Bundle args = new Bundle(); args.putString(ARG_CARD_ENTRY, card.entry); fragment.setArguments(args); return fragment; } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = super.onCreateView(inflater, container, savedInstanceState); mDelete.setVisibility(View.VISIBLE); String cardEntry = getArguments().getString(ARG_CARD_ENTRY); mCardDAO.find(cardEntry) .observeOn(AndroidSchedulers.mainThread()) .subscribe(new OnGetCardSuccessAction(), new OnGetCardErrorAction()); return view; } @OnClick(R.id.card_delete) public void onDeleteClicked() { mCardDAO.delete(mCard); dismiss(); } private class OnGetCardSuccessAction implements Action1<Card> { @Override public void call(Card card) { mCard = card; mEntry.setText(mCard.entry); mPronunciation.setText(mCard.pronunciation); mTranslation.setText(mCard.translation); } } private class OnGetCardErrorAction implements Action1<Throwable> { @Override public void call(Throwable throwable) { Timber.e(throwable, "Couldn't load card."); Toast.makeText(getActivity(), R.string.card_get_error, Toast.LENGTH_SHORT).show(); } } }