Created
April 14, 2019 13:51
-
-
Save amit-bhandari/d63b3d03677a5bab26e9c59c89a6bfb9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class FragmentQuote extends LifecycleFragment{ | |
private QuoteViewModel quoteViewModel; | |
private TextView quotetv; | |
private TextView authortv; | |
@Nullable | |
@Override | |
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { | |
View view = inflater.inflate(R.layout.fragment_quote,container,false); | |
quotetv = (TextView) view.findViewById(R.id.quote); | |
authortv = (TextView) view.findViewById(R.id.author); | |
return view; | |
} | |
@Override | |
public void onActivityCreated(@Nullable Bundle savedInstanceState) { | |
super.onActivityCreated(savedInstanceState); | |
quoteViewModel = ViewModelProviders.of(this).get(QuoteViewModel.class); | |
quoteViewModel.init( getArguments().getString(Constants.stringConstants.CATEGORY_ID), Constants.quoteParam.count); | |
quoteViewModel.getQuote().observe(this, new Observer<Quote>() { | |
@Override | |
public void onChanged(@NonNull Quote quote) { | |
quotetv.setText(quote.getQuote()); | |
authortv.setText(quote.getAuthor()); | |
} | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment