/** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    uiHandler = new Handler();
    restoreInstance();
    if (mOldGraphView != null) {
      mGraphView = new GraphView(this, pdffilename);
      mGraphView.fileMillis = mOldGraphView.fileMillis;
      mGraphView.mBi = mOldGraphView.mBi;
      mGraphView.mLine1 = mOldGraphView.mLine1;
      mGraphView.mLine2 = mOldGraphView.mLine2;
      mGraphView.mLine3 = mOldGraphView.mLine3;
      mGraphView.mText = mOldGraphView.mText;
      mGraphView.pageParseMillis = mOldGraphView.pageParseMillis;
      mGraphView.pageRenderMillis = mOldGraphView.pageRenderMillis;
      mOldGraphView = null;
      mGraphView.mImageView.setImageBitmap(mGraphView.mBi);
      mGraphView.updateTexts();
      setContentView(mGraphView);
    } else {
      Intent intent = getIntent();
      Log.i(TAG, "" + intent);

      boolean showImages =
          getIntent()
              .getBooleanExtra(
                  PdfFileSelectActivity.EXTRA_SHOWIMAGES, PdfFileSelectActivity.DEFAULTSHOWIMAGES);
      PDFImage.sShowImages = showImages;
      boolean antiAlias =
          getIntent()
              .getBooleanExtra(
                  PdfFileSelectActivity.EXTRA_ANTIALIAS, PdfFileSelectActivity.DEFAULTANTIALIAS);
      PDFPaint.s_doAntiAlias = antiAlias;
      boolean useFontSubstitution =
          getIntent()
              .getBooleanExtra(
                  PdfFileSelectActivity.EXTRA_USEFONTSUBSTITUTION,
                  PdfFileSelectActivity.DEFAULTUSEFONTSUBSTITUTION);
      PDFFont.sUseFontSubstitution = useFontSubstitution;
      boolean keepCaches =
          getIntent()
              .getBooleanExtra(
                  PdfFileSelectActivity.EXTRA_KEEPCACHES, PdfFileSelectActivity.DEFAULTKEEPCACHES);
      HardReference.sKeepCaches = keepCaches;

      if (intent != null) {
        if ("android.intent.action.VIEW".equals(intent.getAction())) {
          pdffilename = storeUriContentToFile(intent.getData());
        } else {
          pdffilename = getIntent().getStringExtra(PdfFileSelectActivity.EXTRA_PDFFILENAME);
        }
      }
      mGraphView = new GraphView(this, pdffilename);

      if (pdffilename == null) pdffilename = "no file selected";

      mPage = STARTPAGE;
      mZoom = STARTZOOM;

      setContent(null);
    }
  }
Ejemplo n.º 2
0
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    Log.i(TAG, "onCreate");

    // progress = ProgressDialog.show(PdfViewerActivity.this, "Loading", "Loading PDF Page");
    /*closeNavigationHandler = new Handler();
    closeNavigationThread = new Thread(new Runnable() {

    	public void run() {
    		navigationPanel.startAnimation(AnimationUtils.loadAnimation(PdfViewerActivity.this,
    				R.anim.slide_out));
    		navigationPanel.setVisibility(View.GONE);
    	}
    });*/

    /*if (navigationPanel == null) {
    	navigationPanel = ((ViewStub) findViewById(R.id.stub_navigation)).inflate();
    	navigationPanel.setVisibility(View.GONE);
    	ImageButton previous = (ImageButton)navigationPanel.findViewById(R.id.navigation_previous);
    	previous.setBackgroundDrawable(null);
    }*/

    uiHandler = new Handler();
    restoreInstance();

    mAllShareService = new AllShareService(getApplicationContext());

    if (mOldGraphView != null) {

      System.out.println("mOldGraphView != null");
      mGraphView = new GraphView(this);
      // mGraphView.fileMillis = mOldGraphView.fileMillis;
      mGraphView.mBi = mOldGraphView.mBi;
      // mGraphView.mLine1 = mOldGraphView.mLine1;
      // mGraphView.mLine2 = mOldGraphView.mLine2;
      // mGraphView.mLine3 = mOldGraphView.mLine3;
      // mGraphView.mText = mOldGraphView.mText;
      // mGraphView.pageParseMillis= mOldGraphView.pageParseMillis;
      // mGraphView.pageRenderMillis= mOldGraphView.pageRenderMillis;
      mOldGraphView = null;
      mGraphView.mImageView.setImageBitmap(mGraphView.mBi);
      mGraphView.updateTexts();

      setContentView(mGraphView);

      // *********************************ALLSHARE****************************

      findUiElements();

      // checks if image to show exists; if not: create it
      copyAssets();

      // set the image to be shown
      File dir = Environment.getExternalStorageDirectory();
      File file = new File(dir, IMAGE_PATH);
      mImageUri = Uri.fromFile(file);

      if (IMAGE_PATH != null) {
        System.out.println("PDFFILE IMAGE_PATH " + IMAGE_PATH);
      }
      if (mImageUri != null) {
        System.out.println("\n mImageURI " + mImageUri);
      } else {
        System.out.println("MIMAGEURI IS NULL");
      }

      System.out.println("DIR " + dir.getAbsolutePath());
      if (file != null) {
        System.out.println("\n file " + file.getAbsolutePath());
      }

      mImageView = (ImageView) findViewById(R.id.pdf_image);
      if (mImageView == null) {
        System.out.println("IMAGEVIEW NULL");
      } else {
        System.out.println("IMAGE VIEW NOT NULL");
      }
      mImageView.setImageBitmap(decodeImage(file));

      mAllShareService = AllShareService.getInstance();

      if (mAllShareService == null) {
        System.out.println("mAllShareService == null");
      }

      mAllShareService.init(getApplicationContext());

      // listens for layout measurements finish
      ViewTreeObserver viewTreeObserver = mImageView.getViewTreeObserver();
      if (viewTreeObserver.isAlive()) {
        viewTreeObserver.addOnGlobalLayoutListener(
            new ViewTreeObserver.OnGlobalLayoutListener() {
              @Override
              public void onGlobalLayout() {
                initialize();
                System.out.println("GlobalLayout Listener");
                scaleTv(0, mImageViewWidth / 2.0f, mImageViewHeight / 2.0f);
              }
            });
      }

      // *********************************ALLSHARE****************************

    } else {
      System.out.println("mOldGraphView == null");
      mGraphView = new GraphView(this);
      Intent intent = getIntent();
      Log.i(TAG, "" + intent);

      boolean showImages =
          getIntent()
              .getBooleanExtra(
                  PdfViewerActivity.EXTRA_SHOWIMAGES, PdfViewerActivity.DEFAULTSHOWIMAGES);
      PDFImage.sShowImages = showImages;
      boolean antiAlias =
          getIntent()
              .getBooleanExtra(
                  PdfViewerActivity.EXTRA_ANTIALIAS, PdfViewerActivity.DEFAULTANTIALIAS);
      PDFPaint.s_doAntiAlias = antiAlias;
      boolean useFontSubstitution =
          getIntent()
              .getBooleanExtra(
                  PdfViewerActivity.EXTRA_USEFONTSUBSTITUTION,
                  PdfViewerActivity.DEFAULTUSEFONTSUBSTITUTION);
      PDFFont.sUseFontSubstitution = useFontSubstitution;
      boolean keepCaches =
          getIntent()
              .getBooleanExtra(
                  PdfViewerActivity.EXTRA_KEEPCACHES, PdfViewerActivity.DEFAULTKEEPCACHES);
      HardReference.sKeepCaches = keepCaches;

      if (intent != null) {
        if ("android.intent.action.VIEW".equals(intent.getAction())) {
          pdffilename = storeUriContentToFile(intent.getData());
        } else {
          pdffilename = getIntent().getStringExtra(PdfViewerActivity.EXTRA_PDFFILENAME);
        }
      }

      if (pdffilename == null) pdffilename = "no file selected";

      mPage = STARTPAGE;
      mZoom = STARTZOOM;

      setContent(null);
    }
  }