public void showLastRead() {
   int num = prefsManager.getLastnum();
   float per = prefsManager.getLastPer();
   currentPageNo = num;
   String path = book.getFlatNavPoints().get(currentPageNo - 1).getContent().getPath();
   content.loadContent(path, per);
   chapter.startAnimation(chapterLeftOut);
 }
 public void showPre() {
   if (currentPageNo == 1) {
     Toast.makeText(mContext, "已经是最前一章", Toast.LENGTH_SHORT).show();
     return;
   }
   currentPageNo--;
   String path = book.getFlatNavPoints().get(currentPageNo - 1).getContent().getPath();
   content.loadContent(path, 0);
 }
예제 #3
0
  /** @param context */
  public ChapterView(Context context, Book bok, BookViewController controller) {
    super(context);
    // TODO Auto-generated constructor stub
    mContext = context;
    this.book = bok;
    mBookViewController = controller;
    display = ((Activity) context).getWindowManager().getDefaultDisplay();
    setBackgroundColor(Color.WHITE);

    prefsManager = new PrefsManager(mContext);
    hasHistory = prefsManager.hashistory();

    int btnWidth = display.getWidth() / 2;

    layout = new LinearLayout(context);
    layout.setOrientation(LinearLayout.VERTICAL);
    layout.setGravity(Gravity.CENTER_HORIZONTAL);

    continuBtn = new Button(context);
    continuBtn.setId(0);
    continuBtn.setText("¼ÌÐøÉÏ´ÎÔĶÁ");
    continuBtn.setOnClickListener(this);
    continuBtn.setEnabled(hasHistory);
    layout.addView(continuBtn, LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);

    for (int i = 0; i < book.getFlatNavPoints().size(); i++) {
      NavPoint np = book.getFlatNavPoints().get(i);
      Button b = new Button(context);
      b.setId(i + 1);
      b.setText(np.getLabel());
      b.setWidth(btnWidth);
      b.setOnClickListener(this);
      layout.addView(b, LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
    }

    addView(layout);
  }
  public BookViewController(Context context, Book boo) {
    mContext = context;
    layout = new RelativeLayout(mContext);
    book = boo;
    //		allPageNo = book.getNavPoints().size();
    allPageNo = book.getFlatNavPoints().size();
    display = ((Activity) mContext).getWindowManager().getDefaultDisplay();
    prefsManager = new PrefsManager(mContext);
    /** chapter view */
    chapter = new ChapterView(mContext, book, this);

    /*
     *content view
     */
    content = new ContentView(mContext);
    controllBarClickListener = new ControllBarClickListener(mContext, this);
    content.setControllButtonsClickListener(controllBarClickListener);

    adView = new AdView(mContext);
    LayoutParams params = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
    adView.setId(genID);
    adView.setVisibility(View.INVISIBLE);
    adView.postDelayed(
        new Runnable() {

          @Override
          public void run() {
            // TODO Auto-generated method stub
            adView.setVisibility(View.VISIBLE);
          }
        },
        1000 * 60);

    LayoutParams mainParams = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
    mainParams.addRule(RelativeLayout.BELOW, adView.getId());

    layout.addView(adView, params);
    layout.addView(content, mainParams);
    layout.addView(chapter, mainParams);

    chapterLeftOut = new TranslateAnimation(0, -display.getWidth(), 0, 0);
    chapterLeftOut.setDuration(300);
    chapterLeftOut.setAnimationListener(
        new AnimationListener() {

          @Override
          public void onAnimationStart(Animation animation) {
            // TODO Auto-generated method stub

          }

          @Override
          public void onAnimationRepeat(Animation animation) {
            // TODO Auto-generated method stub

          }

          @Override
          public void onAnimationEnd(Animation animation) {
            // TODO Auto-generated method stub
            chapter.setVisibility(View.INVISIBLE);
          }
        });
    chapterLeftIn = new TranslateAnimation(-display.getWidth(), 0, 0, 0);
    chapterLeftIn.setDuration(300);
  }
 public void showPage(int number) {
   currentPageNo = number;
   String path = book.getFlatNavPoints().get(currentPageNo - 1).getContent().getPath();
   content.loadContent(path, 0);
   chapter.startAnimation(chapterLeftOut);
 }