@Override public void processFinish(Card card) { try { if (card != null) { // Update Success reload data this.card.setAnswers(card.getAnswers()); this.card.setL_vn(card.getL_vn()); this.card.setL_en(card.getL_en()); // Update Success reload data // Set Adapter PackageCardPageAdapter packageCardPageAdapter = new PackageCardPageAdapter(context, this.card); mViewPager.setAdapter(packageCardPageAdapter); mSlidingTabLayout.setViewPager(mViewPager); // Update Card form DB learnApiImplements._updateCardFormServer(card); Toast.makeText( context, getString(R.string.message_update_card_successful), Toast.LENGTH_SHORT) .show(); // set Result code for updated List card setResult( getResources().getInteger(R.integer.code_card_details_updated), new Intent(this, this.getIntent().getComponent().getClass())); } else { Toast.makeText(context, getString(R.string.message_update_card_fails), Toast.LENGTH_SHORT) .show(); } } catch (Exception e) { LazzyBeeShare.showErrorOccurred(context, "processFinish", e); } }
private void _addCardToFavorite() { try { if (card.getQuestion() == null) card = learnApiImplements._getCardByID(cardId); int statusFavrite = 0; // Set icon drawer // if // (itemFavorite.getTitle().toString().equals(getString(R.string.action_not_favorite))) { // statusFavrite = 1; // itemFavorite.setIcon(LazzyBeeShare.getDraweble(context, // R.drawable.ic_action_important)); // itemFavorite.setTitle(context.getString(R.string.action_favorite)); // } else { // itemFavorite.setIcon(LazzyBeeShare.getDraweble(context, // R.drawable.ic_action_not_important)); // itemFavorite.setTitle(context.getString(R.string.action_not_favorite)); // } // set status card and Update card card.setStatus(statusFavrite); learnApiImplements._updateCard(card); Toast.makeText( context, getString(R.string.message_add_favorite_card_done, card.getQuestion()), Toast.LENGTH_SHORT) .show(); } catch (Exception e) { LazzyBeeShare.showErrorOccurred(context, "_addCardToFavorite", e); } }
private void _shareCard() { try { // get card in Db if (card.getQuestion() == null) card = learnApiImplements._getCardByID(cardId); // get base url in Task Manager String base_url_sharing = LazzyBeeShare.DEFAULTS_BASE_URL_SHARING; String server_base_url_sharing = LazzyBeeSingleton.getContainerHolder() .getContainer() .getString(LazzyBeeShare.BASE_URL_SHARING); if (server_base_url_sharing != null) { if (server_base_url_sharing.length() > 0) base_url_sharing = server_base_url_sharing; } // define base url with question base_url_sharing = base_url_sharing + card.getQuestion(); Log.i(TAG, "Sharing URL:" + base_url_sharing); // Share card Intent sendIntent = new Intent(); sendIntent.setAction(Intent.ACTION_SEND); sendIntent.putExtra(Intent.EXTRA_TEXT, base_url_sharing); sendIntent.setType("text/plain"); startActivity(sendIntent); } catch (Exception e) { LazzyBeeShare.showErrorOccurred(context, "_shareCard", e); } }
private void _addCardToLearn() { try { String queue_list = learnApiImplements._getValueFromSystemByKey(LazzyBeeShare.QUEUE_LIST); List<String> cardIDs = learnApiImplements._getListCardIdFromStringArray(queue_list); if (cardIDs.contains(cardId)) { Toast.makeText( context, getString(R.string.message_action_add_card_to_learn_complete, card.getQuestion()), Toast.LENGTH_SHORT) .show(); } else { if (card == null) card = learnApiImplements._getCardByID(cardId); learnApiImplements._addCardIdToQueueList(card); Toast.makeText( context, getString(R.string.message_action_add_card_to_learn_complete, card.getQuestion()), Toast.LENGTH_SHORT) .show(); } // // Instantiate an AlertDialog.Builder with its constructor // final AlertDialog.Builder builder = new AlertDialog.Builder(new // ContextThemeWrapper(context, R.style.DialogLearnMore)); // // // Chain together various setter methods to set the dialog characteristics // builder.setMessage(getString(R.string.dialog_message_add_to_learn, // card.getQuestion())) // .setTitle(getString(R.string.dialog_title_add_to_learn)); // // // Add the buttons // builder.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { // public void onClick(DialogInterface dialog, int id) { // //Update Queue_list in system table // // // } // }); // builder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() // { // public void onClick(DialogInterface dialog, int id) { // // User cancelled the dialog // dialog.cancel(); // } // }); // // Get the AlertDialog from create() // AlertDialog dialog = builder.create(); // dialog.show(); } catch (Exception e) { LazzyBeeShare.showErrorOccurred(context, "_addCardToLearn", e); } }
private void _displayCard(String cardID) { try { card = learnApiImplements._getCardByID(cardID); setTitle(card.getQuestion()); // if (itemFavorite != null) { // //load favorite // if (card.getStatus() == 1) { // itemFavorite.setIcon(LazzyBeeShare.getDraweble(context, // R.drawable.ic_action_important)); // itemFavorite.setTitle(context.getString(R.string.action_favorite)); // } else { // itemFavorite.setIcon(LazzyBeeShare.getDraweble(context, // R.drawable.ic_action_not_important)); // itemFavorite.setTitle(context.getString(R.string.action_not_favorite)); // } // } PackageCardPageAdapter packageCardPageAdapter = new PackageCardPageAdapter(context, card); mViewPager.setAdapter(packageCardPageAdapter); mSlidingTabLayout.setViewPager(mViewPager); } catch (Exception e) { LazzyBeeShare.showErrorOccurred(context, "_displayCard", e); } }
/** * Create the page for the given position. The adapter is responsible for adding the view to the * container given here, although it only must ensure this is done by the time it returns from * {@link #finishUpdate(ViewGroup)}. * * @param container The containing View in which the page will be shown. * @param position The page position to be instantiated. * @return Returns an Object representing the new page. This does not need to be a View, but can * be some other container of the page. */ @Override public Object instantiateItem(ViewGroup container, int position) { // Inflate a new layout from our resources View view = getLayoutInflater().inflate(R.layout.page_package_card_item, container, false); // Add the newly created View to the ViewPager container.addView(view); // mWebViewLeadDetails = (WebView) view.findViewById(R.id.mWebViewCardDetails); WebSettings ws = mWebViewLeadDetails.getSettings(); ws.setJavaScriptEnabled(true); _addJavascriptInterface(card); try { String displayHTML = LazzyBeeShare.EMPTY; switch (position) { case 0: // dic VN displayHTML = LazzyBeeShare.getDictionaryHTML(card.getL_vn()); break; case 1: // dic ENG displayHTML = LazzyBeeShare.getDictionaryHTML(card.getL_en()); break; case 2: // dic Lazzybee displayHTML = LazzyBeeShare.getAnswerHTML(context, card, mySubject, sDEBUG, sPOSITION_MEANING); break; } Log.i(TAG, "Tab Dic:" + displayHTML); mWebViewLeadDetails.loadDataWithBaseURL( LazzyBeeShare.ASSETS, displayHTML, LazzyBeeShare.mime, LazzyBeeShare.encoding, null); } catch (Exception e) { LazzyBeeShare.showErrorOccurred(context, "instantiateItem", e); } // Return the View return view; }