Commits

kulti committed 87ab272

Move open file handling to BookState

  • Participants
  • Parent commits 4911bcd

Comments (0)

Files changed (2)

pdf_book_reader/src/ru/homeless/kulti/pdf_book_reader/BookState.java

 package ru.homeless.kulti.pdf_book_reader;
 
+import java.io.IOException;
+
 public class BookState
 {
     private IBookView bookView;
     {
         this.bookView = bookView;
     }
+    
+    public void openFile(String fileName)
+    {
+        try
+        {
+            PdfParser pdfParser = new PdfParser();
+            pdfParser.open(fileName);
+            bookView.setPageContent(pdfParser.getPageContent(1));
+        }
+        catch (IOException e)
+        {
+            bookView.setPageContent("IOException occured: " + e.getMessage());
+        }
+    }
 
     public void goToPage(int pageNum)
     {

pdf_book_reader/src/ru/homeless/kulti/pdf_book_reader/PdfBookReaderActivity.java

 package ru.homeless.kulti.pdf_book_reader;
 
-import java.io.IOException;
-
 import android.app.Activity;
 import android.os.Bundle;
 import android.view.View;
         
         bookState = new BookState(this);
         pageContent = (TextView)findViewById(R.id.pageContent);
-        
-        try
-        {
-            PdfParser pdfParser = new PdfParser();
-            pdfParser.open("/sdcard/test.pdf");
-            pageContent.setText(pdfParser.getPageContent(1));
-        }
-        catch (IOException e)
-        {
-            pageContent.setText("IOException occured: " + e.getMessage());
-        }
+
+        bookState.openFile("/sdcard/test.pdf");
         
         Button nextPageBtn = (Button)findViewById(R.id.nextPageBtn);
         Button prevPageBtn = (Button)findViewById(R.id.prevPageBtn);
     {
         pageContent.setText(text);
     }
-}
+}