コード例 #1
0
  @TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2)
  public View onCreateView(LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState) {
    View v;
    Savelog.d(TAG, debug, "onCreateView() entered");

    v = inflater.inflate(R.layout.fragment_viewer, parent, false);

    mLoadingView = (ProgressBar) v.findViewById(R.id.fragmentPng_loading_id);

    mListView = (ListView) v.findViewById(R.id.fragmentPng_list_id);

    /* There are three scenarios when we reach this point:
     * 1. Asyntask is completed and data is available for display
     * 2. Asyntask is completed and data is NOT available
     * 3. Asyntask is NOT completed
     */
    if (mFileLoader == null) {
      Savelog.d(TAG, debug, "bitmap array is null");
      if (mFetcherTask == null || mFetcherTask.getStatus() == AsyncTask.Status.FINISHED) {
        Savelog.d(TAG, debug, "Rendering done");
        onFetchingCompleted();
      } else {
        Savelog.d(TAG, debug, "Rendering in progress");
        mListView.setAlpha(0f);
        mListView.setVisibility(View.VISIBLE);
      }
    } else {
      Savelog.d(TAG, debug, "bitmap array is not null");
      onFetchingCompleted();
    }
    return v;
  } // end to implementing onCreateView()
コード例 #2
0
  // Allow user to cancel asynctask by moving to a different fragment
  @Override
  public void onDestroy() {
    super.onDestroy();
    if (mFetcherTask != null) {
      mFetcherTask.cancel(true);
      mFetcherTask = null;
    }

    MainActivity.clearInternalFiles(getActivity());
  }
コード例 #3
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mFilename = getArguments().getString(EXTRA_filename);
    Savelog.d(TAG, debug, "onCreate() entered for " + mFilename);

    mFileLoader = null;

    /* Create a bitmap that is tall enough to cover the screen.
     * This step is very important as the pages will be loaded asynchronously.
     * If the placeholder is too small, the listview will attempt to load all
     * the pages even if just 1 is to be displayed at any time. This will cause
     * oom err
     */
    mPlaceHolderBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.ic_action_help);

    mFetcherTask = new PdfFetcherAsyncTask(this, mFilename);
    mFetcherTask.execute();

    maxWidth = getScreenMaxDimension(this.getActivity());

    setRetainInstance(true);
  } // end to implementing onCreate()