コード例 #1
0
  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);
    }
  }
コード例 #2
0
  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);
    }
  }
コード例 #3
0
  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);
    }
  }
コード例 #4
0
  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);
    }
  }
コード例 #5
0
  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();
    }
  }