gt:         return new PhotoGalleryAsyncLoader(getActivity());
context: /*
   * Copyright (c) 2014 Rex St. John on behalf of AirPair.com
   *
   * Permission is hereby granted, free of charge, to any person obtaining a copy
   * of this software and associated documentation files (the "Software"), to deal
   * in the Software without restriction, including without limitation the rights
   * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
   * copies of the Software, and to permit persons to whom the Software is
   * furnished to do so, subject to the following conditions:
   *
   * The above copyright notice and this permission notice shall be included in
   * all copies or substantial portions of the Software.
   *
   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
   * THE SOFTWARE.
   */
  
  package ocrm.labex.feevale.br.ocr_mobile.view.fragments;
  
  import android.app.Activity;
  import android.app.LoaderManager;
  import android.app.ProgressDialog;
  import android.content.Context;
  import android.content.Loader;
  import android.os.Bundle;
  import android.util.Log;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  import android.widget.AbsListView;
  import android.widget.AdapterView;
  import android.widget.BaseAdapter;
  import android.widget.ListAdapter;
  import android.widget.TextView;
  import android.widget.Toast;
  
  import java.util.ArrayList;
  import java.util.List;
  
  import ocrm.labex.feevale.br.ocr_mobile.R;
  import ocrm.labex.feevale.br.ocr_mobile.utils.PhotoGalleryAsyncLoader;
  import ocrm.labex.feevale.br.ocr_mobile.view.adapters.PhotoAdapter;
  import ocrm.labex.feevale.br.ocr_mobile.view.adapters.items.PhotoItem;
  
  
  /**
   * This is an example which will load all the images on your phone into a grid using a background
   * image AsyncLoader.
   *
   * Reference: http://developer.android.com/reference/android/content/AsyncTaskLoader.html
   *
   * Created by Rex St. John (on behalf of AirPair.com) on 3/4/14.
   */
  public class SimplePhotoGalleryListFragment extends BaseFragment implements AbsListView.OnItemClickListener, LoaderManager.LoaderCallbacks<List<PhotoItem>>  {
  
      // Ivars.
      protected OnFragmentInteractionListener mListener;
      protected AbsListView mListView;
      protected PhotoAdapter mAdapter;
      protected ArrayList<PhotoItem> mPhotoListItem;
      protected TextView mEmptyTextView;
      protected ProgressDialog mLoadingProgressDialog;
  
      /**
       * Required empty constructor
       */
      public SimplePhotoGalleryListFragment() {
          super();
      }
  
      /**
       * Static factory method
       * @param sectionNumber
       * @return
       */
      public static SimplePhotoGalleryListFragment newInstance(int sectionNumber) {
          SimplePhotoGalleryListFragment fragment = new SimplePhotoGalleryListFragment();
          Bundle args = new Bundle();
          args.putInt(ARG_SECTION_NUMBER, sectionNumber);
          fragment.setArguments(args);
          return fragment;
      }
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
  
  
          // Create an empty loader and pre-initialize the photo list items as an empty list.
          Context context = getActivity().getBaseContext();
          // Set up empty mAdapter
          mPhotoListItem = new ArrayList<PhotoItem>();
          mAdapter = new PhotoAdapter(context, R.layout.photo_item,
                  mPhotoListItem, false);
      }
      @Override
      public View onCreateView(LayoutInflater inflater,
                               ViewGroup container,
                               Bundle savedInstanceState) {
          View view = null;
          view = inflater.inflate(R.layout.fragment_photo_gallery, container, false);
  
          // Set the mAdapter
          mListView = (AbsListView) view.findViewById(android.R.id.list);
          ((AdapterView<ListAdapter>) mListView).setAdapter(mAdapter);
          mEmptyTextView = (TextView)view.findViewById(R.id.empty);
  
          resolveEmptyText();
  
          mListView.setOnItemClickListener(this);
  
          return view;
      }
  
      /**
       * Used to show a generic empty text warning. Override in inheriting classes.
       */
      protected void resolveEmptyText(){
          if(mAdapter.isEmpty()){
              mEmptyTextView.setVisibility(View.VISIBLE);
              setEmptyText();
          } else {
              mEmptyTextView.setVisibility(View.INVISIBLE);
          }
      }
  
      @Override
      public void onAttach(Activity activity) {
  
          super.onAttach(activity);
          try {
              mListener = (OnFragmentInteractionListener) activity;
              // Show a progress dialog.
              mLoadingProgressDialog = new ProgressDialog(getActivity());
              mLoadingProgressDialog.setMessage("Lucas...");
              mLoadingProgressDialog.setCancelable(true);
              mLoadingProgressDialog.show();
          } catch (ClassCastException e) {
              throw new ClassCastException(activity.toString()
                      + " must implement OnFragmentInteractionListener");
          }
      }
  
      @Override
      public void onDetach() {
  
          Toast toast = new Toast(getActivity());
          toast.makeText(getActivity(), "Valor", Toast.LENGTH_LONG);
          toast.show();
  
          
          super.onDetach();
          mListener = null;
          cancelProgressDialog();
      }
  
      @Override
      public void onPause(){
          super.onPause();
          cancelProgressDialog();
      }
  
      @Override
      public void onStop(){
          super.onStop();
          cancelProgressDialog();
      }
  
      /**
       * This is only triggered when the user selects a single photo.
       * @param parent
       * @param view
       * @param position
       * @param id
       */
  
      @Override
      public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
          if (null != mListener) {
              // Tell the share builder to add the photo to the share operation.
              PhotoItem photoListItem = (PhotoItem)this.mAdapter.getItem(position);
              String imagePath = photoListItem.getThumbnailUri().getPath();
              mListener.onFragmentInteraction(0);
              resetFragmentState();
          }
      }
  
      /**
       * Used when hitting the back button to reset the mFragment UI state
       */
      protected void resetFragmentState(){
          // Clear view state
          getActivity().invalidateOptionsMenu();
          ((BaseAdapter) mListView.getAdapter()).notifyDataSetChanged();
      }
  
      /**
       * The default content for this Fragment has a TextView that is shown when
       * the list is empty. If you would like to change the text, call this method
       * to supply the text it should use.
       */
      public void setEmptyText() {
          mEmptyTextView.setText("No Photos!");
      }
  
      /**
       * Loader Handlers for loading the photos in the background.
       */
      @Override
      public Loader<List<PhotoItem>> onCreateLoader(int id, Bundle args) {
          // This is called when a new Loader needs to be created.  This
          // sample only has one Loader with no arguments, so it is simple.
  