コード例 #1
0
  @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);
    }
  }
コード例 #2
0
    /**
     * 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;
    }