private void _reportCard() { try { startActivity(LazzyBeeShare.getOpenFacebookIntent(context)); } catch (Exception e) { LazzyBeeShare.showErrorOccurred(context, "_reportCard", 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); } }
@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 _trackerApplication() { try { DataLayer mDataLayer = LazzyBeeSingleton.mDataLayer; mDataLayer.pushEvent("openScreen", DataLayer.mapOf("screenName", GA_SCREEN)); } catch (Exception e) { LazzyBeeShare.showErrorOccurred(context, "_trackerApplication", e); } }
public String getCarID() { try { cardId = getIntent().getStringExtra(LazzyBeeShare.CARDID); } catch (Exception e) { cardId = LazzyBeeShare.EMPTY; LazzyBeeShare.showErrorOccurred(context, "getCarID", e); } return cardId; }
private void _initAdView() { try { mViewAdv = findViewById(R.id.mViewAdv); // get value form task manager Container container = LazzyBeeSingleton.getContainerHolder().getContainer(); String admob_pub_id = null; String adv_id = null; if (container == null) { } else { admob_pub_id = container.getString(LazzyBeeShare.ADMOB_PUB_ID); adv_id = container.getString(LazzyBeeShare.ADV_DETAILS_ID); Log.i(TAG, "admob -admob_pub_id:" + admob_pub_id); Log.i(TAG, "admob -adv_id:" + adv_id); } if (admob_pub_id != null) { if (adv_id == null || adv_id.equals(LazzyBeeShare.EMPTY)) { mViewAdv.setVisibility(View.GONE); } else if (adv_id != null || adv_id.length() > 1 || !adv_id.equals(LazzyBeeShare.EMPTY) || !adv_id.isEmpty()) { String advId = admob_pub_id + "/" + adv_id; Log.i(TAG, "admob -AdUnitId:" + advId); AdView mAdView = new AdView(this); mAdView.setAdSize(AdSize.BANNER); mAdView.setAdUnitId(advId); AdRequest adRequest = new AdRequest.Builder() .addTestDevice(AdRequest.DEVICE_ID_EMULATOR) .addTestDevice(getResources().getStringArray(R.array.devices)[0]) .addTestDevice(getResources().getStringArray(R.array.devices)[1]) .addTestDevice(getResources().getStringArray(R.array.devices)[2]) .addTestDevice(getResources().getStringArray(R.array.devices)[3]) .build(); mAdView.loadAd(adRequest); RelativeLayout relativeLayout = ((RelativeLayout) findViewById(R.id.adView)); RelativeLayout.LayoutParams adViewCenter = new RelativeLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); adViewCenter.addRule(RelativeLayout.CENTER_IN_PARENT); relativeLayout.addView(mAdView, adViewCenter); mViewAdv.setVisibility(View.VISIBLE); } else { mViewAdv.setVisibility(View.GONE); } } else { mViewAdv.setVisibility(View.GONE); } } catch (Exception e) { LazzyBeeShare.showErrorOccurred(context, "_initAdView", e); } }
@Override protected void onPause() { super.onPause(); int hour = learnApiImplements.getSettingIntergerValuebyKey( LazzyBeeShare.KEY_SETTING_HOUR_NOTIFICATION); int minute = learnApiImplements.getSettingIntergerValuebyKey( LazzyBeeShare.KEY_SETTING_MINUTE_NOTIFICATION); LazzyBeeShare._setUpNotification(context, hour, minute); }
/** * 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; }
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 _updateCardFormServer() { if (LazzyBeeShare.checkConn(context)) { // Check card==null get card form Sqlite by cardID if (card == null) card = learnApiImplements._getCardByID(cardId); GetCardFormServerByQuestion getCardFormServerByQuestion = new GetCardFormServerByQuestion(context); getCardFormServerByQuestion.execute(card); getCardFormServerByQuestion.delegate = this; } else { Toast.makeText(context, R.string.failed_to_connect_to_server, Toast.LENGTH_SHORT).show(); } }
@Override protected void onResume() { super.onResume(); LazzyBeeShare._cancelNotification(context); }
private void _initSettingUser() { mySubject = LazzyBeeShare.getSubjectSetting(); sDEBUG = LazzyBeeShare.getDebugSetting(); sPOSITION_MEANING = LazzyBeeShare.getPositionMeaning(); }