Example usage for android.support.v4.app FragmentActivity getSupportFragmentManager

List of usage examples for android.support.v4.app FragmentActivity getSupportFragmentManager

Introduction

In this page you can find the example usage for android.support.v4.app FragmentActivity getSupportFragmentManager.

Prototype

public FragmentManager getSupportFragmentManager() 

Source Link

Document

Return the FragmentManager for interacting with fragments associated with this activity.

Usage

From source file:hku.fyp14017.blencode.utils.DownloadUtil.java

public void prepareDownloadAndStartIfPossible(FragmentActivity activity, String url) {
    int projectNameIndex = url.lastIndexOf(PROJECTNAME_TAG) + PROJECTNAME_TAG.length();
    String programName = url.substring(projectNameIndex);
    try {/*  w  w w  . j  a  v  a  2  s.c o  m*/
        programName = URLDecoder.decode(programName, "UTF-8");
    } catch (UnsupportedEncodingException e) {
        Log.e(TAG, "Could not decode program name: " + programName, e);
        return;
    }

    boolean programNameExists = Utils.checkIfProjectExistsOrIsDownloadingIgnoreCase(programName);
    if (programNameExists) {
        Log.v(TAG, "Program name exists - show overwrite dialog");
        OverwriteRenameDialog renameDialog = new OverwriteRenameDialog();

        renameDialog.setContext(activity);
        renameDialog.setProgramName(programName);
        renameDialog.setURL(url);

        renameDialog.show(activity.getSupportFragmentManager(), OverwriteRenameDialog.DIALOG_FRAGMENT_TAG);
    } else {
        startDownload(activity, url, programName);
    }
}

From source file:org.odk.collect.android.map.OsmMapFragment.java

@Override
public void addTo(@NonNull FragmentActivity activity, int containerId, @Nullable ReadyListener listener) {
    readyListener = listener;/*from ww  w  .ja  v  a2 s  . c  o m*/
    // If the containing activity is being re-created upon screen rotation,
    // the FragmentManager will have also re-created a copy of the previous
    // OsmMapFragment.  We don't want these useless copies of old fragments
    // to linger, so the following line calls .replace() instead of .add().
    activity.getSupportFragmentManager().beginTransaction().replace(containerId, this).commit();
}

From source file:ca.ualberta.cmput301w14t08.geochan.managers.ThreadManager.java

/**
 * Private constructor due to singleton pattern.
 */// ww w  .  j  a va2s .  c  om
private ThreadManager() {
    commentListCache = new LruCache<String, CommentList>(MAXIMUM_CACHE_SIZE);
    getImageCache = new LruCache<String, Bitmap>(MAXIMUM_CACHE_SIZE);
    getPOICache = new LruCache<String, String>(MAXIMUM_CACHE_SIZE);

    getCommentListRunnableQueue = new LinkedBlockingQueue<Runnable>();
    getCommentsRunnableQueue = new LinkedBlockingQueue<Runnable>();
    postImageRunnableQueue = new LinkedBlockingQueue<Runnable>();
    postRunnableQueue = new LinkedBlockingQueue<Runnable>();
    updateRunnableQueue = new LinkedBlockingQueue<Runnable>();
    getImageRunnableQueue = new LinkedBlockingQueue<Runnable>();
    getThreadCommentsRunnableQueue = new LinkedBlockingQueue<Runnable>();
    getPOIRunnableQueue = new LinkedBlockingQueue<Runnable>();

    getCommentsTaskQueue = new LinkedBlockingQueue<GetCommentsTask>();
    postTaskQueue = new LinkedBlockingQueue<PostTask>();
    getImageTaskQueue = new LinkedBlockingQueue<GetImageTask>();
    getThreadCommentsTaskQueue = new LinkedBlockingQueue<GetThreadCommentsTask>();
    getPOITaskQueue = new LinkedBlockingQueue<GetPOITask>();

    getCommentListPool = new ThreadPoolExecutor(CORE_POOL_SIZE, MAXIMUM_POOL_SIZE, KEEP_ALIVE_TIME,
            KEEP_ALIVE_TIME_UNIT, getCommentListRunnableQueue);
    getCommentsPool = new ThreadPoolExecutor(CORE_POOL_SIZE, MAXIMUM_POOL_SIZE, KEEP_ALIVE_TIME,
            KEEP_ALIVE_TIME_UNIT, getCommentsRunnableQueue);
    postImagePool = new ThreadPoolExecutor(CORE_POOL_SIZE, MAXIMUM_POOL_SIZE, KEEP_ALIVE_TIME,
            KEEP_ALIVE_TIME_UNIT, postImageRunnableQueue);
    postPool = new ThreadPoolExecutor(CORE_POOL_SIZE, MAXIMUM_POOL_SIZE, KEEP_ALIVE_TIME, KEEP_ALIVE_TIME_UNIT,
            postRunnableQueue);
    updatePool = new ThreadPoolExecutor(CORE_POOL_SIZE, MAXIMUM_POOL_SIZE, KEEP_ALIVE_TIME,
            KEEP_ALIVE_TIME_UNIT, updateRunnableQueue);
    getImagePool = new ThreadPoolExecutor(CORE_POOL_SIZE, MAXIMUM_POOL_SIZE, KEEP_ALIVE_TIME,
            KEEP_ALIVE_TIME_UNIT, getImageRunnableQueue);
    getThreadCommentsPool = new ThreadPoolExecutor(CORE_POOL_SIZE, MAXIMUM_POOL_SIZE, KEEP_ALIVE_TIME,
            KEEP_ALIVE_TIME_UNIT, getThreadCommentsRunnableQueue);
    getPOIPool = new ThreadPoolExecutor(CORE_POOL_SIZE, MAXIMUM_POOL_SIZE, KEEP_ALIVE_TIME,
            KEEP_ALIVE_TIME_UNIT, getPOIRunnableQueue);

    handler = new Handler(Looper.getMainLooper()) {

        @Override
        public void handleMessage(Message inputMessage) {
            switch (inputMessage.what) {
            case POST_TASK_COMPLETE:
                PostTask postTaskComplete = (PostTask) inputMessage.obj;
                if (postTaskComplete.getDialog() != null) {
                    postTaskComplete.getDialog().dismiss();
                }
                ThreadComment threadComment = postTaskComplete.getThreadComment();
                if (threadComment != null) {
                    if (!postTaskComplete.isEdit()) {
                        // Update the model and sort accordingly
                        ThreadList.addThread(threadComment);
                        SortUtil.sortThreads(PreferencesManager.getInstance().getThreadSort(),
                                ThreadList.getThreads());
                    }
                    FragmentActivity activity = (FragmentActivity) context;
                    ThreadListFragment fragment = (ThreadListFragment) activity.getSupportFragmentManager()
                            .findFragmentByTag("threadListFrag");
                    if (fragment != null) {
                        fragment.finishReload();
                    }
                }
                break;

            case GET_THREADS_COMPLETE:
                GetThreadCommentsTask threadTask = (GetThreadCommentsTask) inputMessage.obj;
                threadTask.getFragment().finishReload();
                recycleGetThreadCommentsTask(threadTask);
                break;

            case GET_THREADS_FAILED:
                GetThreadCommentsTask threadTaskFail = (GetThreadCommentsTask) inputMessage.obj;
                threadTaskFail.getFragment().finishReload();
                recycleGetThreadCommentsTask(threadTaskFail);
                break;

            case GET_COMMENTS_COMPLETE:
                GetCommentsTask task = (GetCommentsTask) inputMessage.obj;
                task.getFragment().finishReload();
                recycleCommentsTask(task);
                break;

            case GET_COMMENTS_FAILED:
                GetCommentsTask taskFail = (GetCommentsTask) inputMessage.obj;
                taskFail.getFragment().finishReload();
                recycleCommentsTask(taskFail);
                break;

            case GET_COMMENT_LIST_RUNNING:
                break;

            case GET_COMMENT_LIST_FAILED:
                GetCommentsTask taskListFail = (GetCommentsTask) inputMessage.obj;
                taskListFail.getFragment().finishReload();
                recycleCommentsTask(taskListFail);
                break;

            case GET_IMAGE_RUNNING:
                GetImageTask imageTask = (GetImageTask) inputMessage.obj;
                if (imageTask.getDialog() != null) {
                    imageTask.getDialog().show();
                }
                break;

            case GET_IMAGE_FAILED:
                GetImageTask imageTaskFail = (GetImageTask) inputMessage.obj;
                if (imageTaskFail.getDialog() != null) {
                    imageTaskFail.getDialog().dismiss();
                }
                recycleGetImageTask(imageTaskFail);
                break;

            case GET_IMAGE_COMPLETE:
                GetImageTask imageTaskComplete = (GetImageTask) inputMessage.obj;
                if (imageTaskComplete.getDialog() != null) {
                    imageTaskComplete.getDialog().dismiss();
                }
                Bitmap bitmap = imageTaskComplete.getImageCache();
                String id = imageTaskComplete.getId();
                ImageView view = imageTaskComplete.getmImageWeakRef().get();
                if (view != null) {
                    view.setImageBitmap(bitmap);
                }
                CacheManager.getInstance().serializeImage(bitmap, id);
                recycleGetImageTask(imageTaskComplete);
                break;

            case GET_POI_RUNNING:
                GetPOITask poiTaskRunning = (GetPOITask) inputMessage.obj;
                if (poiTaskRunning.getDialog() != null) {
                    poiTaskRunning.getDialog().show();
                }
                break;

            case GET_POI_COMPLETE:
                GetPOITask poiTaskComplete = (GetPOITask) inputMessage.obj;
                if (poiTaskComplete.getDialog() != null) {
                    poiTaskComplete.getDialog().dismiss();
                }
                if (poiTaskComplete.getMarker() != null) {
                    poiTaskComplete.getMarker().setSubDescription((poiTaskComplete.getPOICache()));
                    poiTaskComplete.getMarker().showInfoWindow();

                }
                poiTaskComplete.getLocation().setLocationDescription(poiTaskComplete.getPOICache());
                recycleGetPOITask(poiTaskComplete);
                break;

            case GET_POI_FAILED:
                GetPOITask poiTaskFailed = (GetPOITask) inputMessage.obj;
                if (poiTaskFailed.getDialog() != null) {
                    poiTaskFailed.getDialog().dismiss();
                }
                if (poiTaskFailed.getMarker() != null) {
                    poiTaskFailed.getMarker().setSubDescription(("Unknown Location"));
                    poiTaskFailed.getMarker().showInfoWindow();
                }
                poiTaskFailed.getLocation().setLocationDescription("Unknown Location");
                recycleGetPOITask(poiTaskFailed);
                break;

            case POST_GET_POI_RUNNING:
                PostTask postPoiTaskRunning = (PostTask) inputMessage.obj;
                if (postPoiTaskRunning.getDialog() != null) {
                    postPoiTaskRunning.getDialog().show();
                }
                break;

            case POST_GET_POI_COMPLETE:
                PostTask postPoiTaskComplete = (PostTask) inputMessage.obj;
                if (postPoiTaskComplete.getDialog() != null) {
                    postPoiTaskComplete.getDialog().setMessage("Posting to Server");
                }
                break;

            case POST_GET_POI_FAILED:
                PostTask postPoiTaskFailed = (PostTask) inputMessage.obj;
                if (postPoiTaskFailed.getDialog() != null) {
                    postPoiTaskFailed.getDialog().dismiss();
                }
                break;

            case UPDATE_FAILED:
                PostTask postTaskUpdateFailed = (PostTask) inputMessage.obj;
                if (postTaskUpdateFailed.getDialog() != null) {
                    postTaskUpdateFailed.getDialog().dismiss();
                }
                break;

            case POST_FAILED:
                PostTask postTaskFailed = (PostTask) inputMessage.obj;
                if (postTaskFailed.getDialog() != null) {
                    postTaskFailed.getDialog().dismiss();
                }
                break;

            case POST_RUNNING:
                PostTask postTaskRun = (PostTask) inputMessage.obj;
                if (postTaskRun.getDialog() != null && !postTaskRun.getDialog().isShowing()) {
                    postTaskRun.getDialog().show();
                }
                break;

            case POST_IMAGE_FAILED:
                PostTask postTaskImageFailed = (PostTask) inputMessage.obj;
                if (postTaskImageFailed.getDialog() != null) {
                    postTaskImageFailed.getDialog().dismiss();
                }
                break;

            default:
                super.handleMessage(inputMessage);
                break;
            }
        }
    };
}

From source file:org.odk.collect.android.map.GoogleMapFragment.java

@SuppressLint("MissingPermission") // Permission checks for location services handled in widgets
@Override//from w ww.j  a v  a2 s  . c  om
public void addTo(@NonNull FragmentActivity activity, int containerId, @Nullable ReadyListener listener) {
    // If the containing activity is being re-created upon screen rotation,
    // the FragmentManager will have also re-created a copy of the previous
    // OsmMapFragment.  We don't want these useless copies of old fragments
    // to linger, so the following line calls .replace() instead of .add().
    activity.getSupportFragmentManager().beginTransaction().replace(containerId, this).commitNow();
    getMapAsync((GoogleMap map) -> {
        if (map == null) {
            ToastUtils.showShortToast(R.string.google_play_services_error_occured);
            if (listener != null) {
                listener.onReady(null);
            }
            return;
        }
        this.map = map;
        map.setOnMapClickListener(this);
        map.setOnMapLongClickListener(this);
        map.setOnMarkerDragListener(this);
        map.getUiSettings().setCompassEnabled(true);
        // Show the blue dot on the map, but hide the Google-provided
        // "go to my location" button; we have our own button for that.
        map.setMyLocationEnabled(true);
        map.getUiSettings().setMyLocationButtonEnabled(false);
        map.setMinZoomPreference(1);
        map.moveCamera(CameraUpdateFactory.newLatLngZoom(INITIAL_CENTER, INITIAL_ZOOM));
        if (listener != null) {
            listener.onReady(this);
        }
    });

    // In Robolectric tests, getMapAsync() never gets around to calling its
    // callback; we have to invoke the ready listener directly.
    if (testMode) {
        listener.onReady(this);
    }
}

From source file:org.solovyev.android.messenger.BaseListFragment.java

private boolean canReuseFragment(@Nonnull FragmentActivity activity, @Nullable ListItem selectedItem) {
    final Fragment fragmentById = activity.getSupportFragmentManager()
            .findFragmentById(R.id.content_second_pane);
    if (fragmentById == null || selectedItem == null) {
        return false;
    } else {//ww w  .j  av a  2  s. co m
        return canReuseFragment(fragmentById, (LI) selectedItem);
    }
}

From source file:com.example.aula20141117.util.AmUtil.java

public GoogleMap obterGoogleMapViaResourceId(int idDoMapa, FragmentActivity geradoraDoPedido) {
    //ateno no confundir com android.app.FragmentManager
    //este  android.support.v4.app.FragmentManager;
    android.support.v4.app.FragmentManager mFragmentManager; //gestor de fragmentos na library v4
    android.support.v4.app.Fragment mMapFragment; //tipo de Fragment na library v4
    com.google.android.gms.maps.SupportMapFragment mSupportMapFragment; //transformador de fragmentos em mapas
    com.google.android.gms.maps.GoogleMap mMap; //mapas na Maps API V2

    GoogleMap ret = null;/*from w w  w  .  j ava 2  s.  c om*/

    String resultado = testarSuporteGooglePlayServicesNoDispositivo(geradoraDoPedido);
    mUltimoErro = resultado;
    //mostrarMensagem (resultado);

    if (resultado.equals("SUCCESS")) {
        //android.support.v4.app.FragmentManager;
        mFragmentManager = geradoraDoPedido.getSupportFragmentManager();
        if (mFragmentManager == null)
            mUltimoErro = "ERRO : no foi possvel obter um objeto FragmentManager";
        else
            mUltimoErro = "SUCESSO: foi possvel obter um objeto FragmentManager";

        //GoogleMap implica import com.google.android.gms.maps.GoogleMap;
        mMapFragment = mFragmentManager.findFragmentById(idDoMapa);
        if (mMapFragment == null)
            mUltimoErro = "ERRO : no foi possvel obter um MapFragment via um FragmentManager";
        else
            mUltimoErro = "SUCESSO: foi possvel obter um MapFragment via um FragmentManager";

        //SupportMapFragment implica import com.google.android.gms.maps.SupportMapFragment;
        mSupportMapFragment = (SupportMapFragment) mMapFragment;
        if (mSupportMapFragment == null)
            mUltimoErro = "ERRO : no foi possvel fazer um cast para SupportMapFragment a partir de um MapFragment";
        else
            mUltimoErro = "SUCESSO: foi possvel fazer um cast para SupportMapFragment a partir de um MapFragment";

        //finalmente o mapa
        ret = mMap = mSupportMapFragment.getMap();
        if (mMap == null)
            mUltimoErro = "ERRO : no foi possvel um GoogleMap a partir de um objeto SupportMapFragment via chamada a getMap()";
        else
            mUltimoErro = "SUCESSO: foi possvel um GoogleMap a partir de um objeto SupportMapFragment via chamada a getMap()";

    } //if

    return ret;
}

From source file:BannerListView.java

/**
 * this method take supported fragment and fragment activity to add that
 * fragment as a banner to listView it create a layout at runtime then when
 * view is added to list we replace it with fragment otherwise it will crash
 * since view is not on screen to be replaced
 * //from  www. j  a v  a 2s .c  o  m
 * @param fragment
 * @param activity
 */
public void addBannerFragment(final Fragment fragment, final FragmentActivity activity) {

    LinearLayout layout = new LinearLayout(activity);

    AbsListView.LayoutParams param = new AbsListView.LayoutParams(LayoutParams.MATCH_PARENT,
            LayoutParams.WRAP_CONTENT);

    layout.setLayoutParams(param);

    layout.setId(CONTAINER_ID);

    addLayoutContainer(layout);

    this.addOnLayoutChangeListener(new OnLayoutChangeListener() {

        @Override
        public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop,
                int oldRight, int oldBottom) {

            BannerListView.this.removeOnLayoutChangeListener(this);

            FragmentManager manager = activity.getSupportFragmentManager();
            FragmentTransaction transaction = manager.beginTransaction();

            transaction.add(CONTAINER_ID, fragment).commit();
        }
    });

}

From source file:com.yjt.app.utils.MapUtil.java

public void showMapError(FragmentActivity activity, final int resultCode) {
    switch (resultCode) {
    case AMapException.CODE_AMAP_SIGNATURE_ERROR:
        PromptDialog.createBuilder(activity.getSupportFragmentManager())
                .setTitle(activity.getString(R.string.error_prompt))
                .setPrompt(AMapException.AMAP_SIGNATURE_ERROR).setNegativeButtonText(R.string.cancel)
                .setRequestCode(Constant.RequestCode.DIALOG_ERROR).setCancelableOnTouchOutside(false).show();
        break;//from   w w  w.j  a va 2 s .  c o  m
    case AMapException.CODE_AMAP_INVALID_USER_KEY:
        PromptDialog.createBuilder(activity.getSupportFragmentManager())
                .setTitle(activity.getString(R.string.error_prompt))
                .setPrompt(AMapException.AMAP_INVALID_USER_KEY).setNegativeButtonText(R.string.cancel)
                .setRequestCode(Constant.RequestCode.DIALOG_ERROR).setCancelableOnTouchOutside(false).show();
        break;
    case AMapException.CODE_AMAP_SERVICE_NOT_AVAILBALE:
        PromptDialog.createBuilder(activity.getSupportFragmentManager())
                .setTitle(activity.getString(R.string.error_prompt))
                .setPrompt(AMapException.AMAP_SERVICE_NOT_AVAILBALE).setNegativeButtonText(R.string.cancel)
                .setRequestCode(Constant.RequestCode.DIALOG_ERROR).setCancelableOnTouchOutside(false).show();
        break;
    case AMapException.CODE_AMAP_DAILY_QUERY_OVER_LIMIT:
        PromptDialog.createBuilder(activity.getSupportFragmentManager())
                .setTitle(activity.getString(R.string.error_prompt))
                .setPrompt(AMapException.AMAP_DAILY_QUERY_OVER_LIMIT).setNegativeButtonText(R.string.cancel)
                .setRequestCode(Constant.RequestCode.DIALOG_ERROR).setCancelableOnTouchOutside(false).show();
        break;
    case AMapException.CODE_AMAP_ACCESS_TOO_FREQUENT:
        PromptDialog.createBuilder(activity.getSupportFragmentManager())
                .setTitle(activity.getString(R.string.error_prompt))
                .setPrompt(AMapException.AMAP_ACCESS_TOO_FREQUENT).setNegativeButtonText(R.string.cancel)
                .setRequestCode(Constant.RequestCode.DIALOG_ERROR).setCancelableOnTouchOutside(false).show();
        break;
    case AMapException.CODE_AMAP_INVALID_USER_IP:
        PromptDialog.createBuilder(activity.getSupportFragmentManager())
                .setTitle(activity.getString(R.string.error_prompt))
                .setPrompt(AMapException.AMAP_INVALID_USER_IP).setNegativeButtonText(R.string.cancel)
                .setRequestCode(Constant.RequestCode.DIALOG_ERROR).setCancelableOnTouchOutside(false).show();
        break;
    case AMapException.CODE_AMAP_INVALID_USER_DOMAIN:
        PromptDialog.createBuilder(activity.getSupportFragmentManager())
                .setTitle(activity.getString(R.string.error_prompt))
                .setPrompt(AMapException.AMAP_INVALID_USER_DOMAIN).setNegativeButtonText(R.string.cancel)
                .setRequestCode(Constant.RequestCode.DIALOG_ERROR).setCancelableOnTouchOutside(false).show();
        break;
    case AMapException.CODE_AMAP_INVALID_USER_SCODE:
        PromptDialog.createBuilder(activity.getSupportFragmentManager())
                .setTitle(activity.getString(R.string.error_prompt))
                .setPrompt(AMapException.AMAP_INVALID_USER_SCODE).setNegativeButtonText(R.string.cancel)
                .setRequestCode(Constant.RequestCode.DIALOG_ERROR).setCancelableOnTouchOutside(false).show();
        break;
    case AMapException.CODE_AMAP_USERKEY_PLAT_NOMATCH:
        PromptDialog.createBuilder(activity.getSupportFragmentManager())
                .setTitle(activity.getString(R.string.error_prompt))
                .setPrompt(AMapException.AMAP_USERKEY_PLAT_NOMATCH).setNegativeButtonText(R.string.cancel)
                .setRequestCode(Constant.RequestCode.DIALOG_ERROR).setCancelableOnTouchOutside(false).show();
        break;
    case AMapException.CODE_AMAP_IP_QUERY_OVER_LIMIT:
        PromptDialog.createBuilder(activity.getSupportFragmentManager())
                .setTitle(activity.getString(R.string.error_prompt))
                .setPrompt(AMapException.AMAP_IP_QUERY_OVER_LIMIT).setNegativeButtonText(R.string.cancel)
                .setRequestCode(Constant.RequestCode.DIALOG_ERROR).setCancelableOnTouchOutside(false).show();
        break;
    case AMapException.CODE_AMAP_NOT_SUPPORT_HTTPS:
        PromptDialog.createBuilder(activity.getSupportFragmentManager())
                .setTitle(activity.getString(R.string.error_prompt))
                .setPrompt(AMapException.AMAP_NOT_SUPPORT_HTTPS).setNegativeButtonText(R.string.cancel)
                .setRequestCode(Constant.RequestCode.DIALOG_ERROR).setCancelableOnTouchOutside(false).show();
        break;
    case AMapException.CODE_AMAP_INSUFFICIENT_PRIVILEGES:
        PromptDialog.createBuilder(activity.getSupportFragmentManager())
                .setTitle(activity.getString(R.string.error_prompt))
                .setPrompt(AMapException.AMAP_INSUFFICIENT_PRIVILEGES).setNegativeButtonText(R.string.cancel)
                .setRequestCode(Constant.RequestCode.DIALOG_ERROR).setCancelableOnTouchOutside(false).show();
        break;
    case AMapException.CODE_AMAP_USER_KEY_RECYCLED:
        PromptDialog.createBuilder(activity.getSupportFragmentManager())
                .setTitle(activity.getString(R.string.error_prompt))
                .setPrompt(AMapException.AMAP_USER_KEY_RECYCLED).setNegativeButtonText(R.string.cancel)
                .setRequestCode(Constant.RequestCode.DIALOG_ERROR).setCancelableOnTouchOutside(false).show();
        break;
    case AMapException.CODE_AMAP_ENGINE_RESPONSE_ERROR:
        PromptDialog.createBuilder(activity.getSupportFragmentManager())
                .setTitle(activity.getString(R.string.error_prompt))
                .setPrompt(AMapException.AMAP_ENGINE_RESPONSE_ERROR).setNegativeButtonText(R.string.cancel)
                .setRequestCode(Constant.RequestCode.DIALOG_ERROR).setCancelableOnTouchOutside(false).show();
        break;
    case AMapException.CODE_AMAP_ENGINE_RESPONSE_DATA_ERROR:
        PromptDialog.createBuilder(activity.getSupportFragmentManager())
                .setTitle(activity.getString(R.string.error_prompt))
                .setPrompt(AMapException.AMAP_ENGINE_RESPONSE_DATA_ERROR).setNegativeButtonText(R.string.cancel)
                .setRequestCode(Constant.RequestCode.DIALOG_ERROR).setCancelableOnTouchOutside(false).show();
        break;
    case AMapException.CODE_AMAP_ENGINE_CONNECT_TIMEOUT:
        PromptDialog.createBuilder(activity.getSupportFragmentManager())
                .setTitle(activity.getString(R.string.error_prompt))
                .setPrompt(AMapException.AMAP_ENGINE_CONNECT_TIMEOUT).setNegativeButtonText(R.string.cancel)
                .setRequestCode(Constant.RequestCode.DIALOG_ERROR).setCancelableOnTouchOutside(false).show();
        break;
    case AMapException.CODE_AMAP_ENGINE_RETURN_TIMEOUT:
        PromptDialog.createBuilder(activity.getSupportFragmentManager())
                .setTitle(activity.getString(R.string.error_prompt))
                .setPrompt(AMapException.AMAP_ENGINE_RETURN_TIMEOUT).setNegativeButtonText(R.string.cancel)
                .setRequestCode(Constant.RequestCode.DIALOG_ERROR).setCancelableOnTouchOutside(false).show();
        break;
    case AMapException.CODE_AMAP_SERVICE_INVALID_PARAMS:
        PromptDialog.createBuilder(activity.getSupportFragmentManager())
                .setTitle(activity.getString(R.string.error_prompt))
                .setPrompt(AMapException.AMAP_SERVICE_INVALID_PARAMS).setNegativeButtonText(R.string.cancel)
                .setRequestCode(Constant.RequestCode.DIALOG_ERROR).setCancelableOnTouchOutside(false).show();
        break;
    case AMapException.CODE_AMAP_SERVICE_MISSING_REQUIRED_PARAMS:
        PromptDialog.createBuilder(activity.getSupportFragmentManager())
                .setTitle(activity.getString(R.string.error_prompt))
                .setPrompt(AMapException.AMAP_SERVICE_MISSING_REQUIRED_PARAMS)
                .setNegativeButtonText(R.string.cancel).setRequestCode(Constant.RequestCode.DIALOG_ERROR)
                .setCancelableOnTouchOutside(false).show();
        break;
    case AMapException.CODE_AMAP_SERVICE_ILLEGAL_REQUEST:
        PromptDialog.createBuilder(activity.getSupportFragmentManager())
                .setTitle(activity.getString(R.string.error_prompt))
                .setPrompt(AMapException.AMAP_SERVICE_ILLEGAL_REQUEST).setNegativeButtonText(R.string.cancel)
                .setRequestCode(Constant.RequestCode.DIALOG_ERROR).setCancelableOnTouchOutside(false).show();
        break;
    case AMapException.CODE_AMAP_SERVICE_UNKNOWN_ERROR:
        PromptDialog.createBuilder(activity.getSupportFragmentManager())
                .setTitle(activity.getString(R.string.error_prompt))
                .setPrompt(AMapException.AMAP_SERVICE_UNKNOWN_ERROR).setNegativeButtonText(R.string.cancel)
                .setRequestCode(Constant.RequestCode.DIALOG_ERROR).setCancelableOnTouchOutside(false).show();
        break;
    case AMapException.CODE_AMAP_CLIENT_ERRORCODE_MISSSING:
        PromptDialog.createBuilder(activity.getSupportFragmentManager())
                .setTitle(activity.getString(R.string.error_prompt))
                .setPrompt(AMapException.AMAP_CLIENT_ERRORCODE_MISSSING).setNegativeButtonText(R.string.cancel)
                .setRequestCode(Constant.RequestCode.DIALOG_ERROR).setCancelableOnTouchOutside(false).show();
        break;
    case AMapException.CODE_AMAP_CLIENT_ERROR_PROTOCOL:
        PromptDialog.createBuilder(activity.getSupportFragmentManager())
                .setTitle(activity.getString(R.string.error_prompt))
                .setPrompt(AMapException.AMAP_CLIENT_ERROR_PROTOCOL).setNegativeButtonText(R.string.cancel)
                .setRequestCode(Constant.RequestCode.DIALOG_ERROR).setCancelableOnTouchOutside(false).show();
        break;
    case AMapException.CODE_AMAP_CLIENT_SOCKET_TIMEOUT_EXCEPTION:
        PromptDialog.createBuilder(activity.getSupportFragmentManager())
                .setTitle(activity.getString(R.string.error_prompt))
                .setPrompt(AMapException.AMAP_CLIENT_SOCKET_TIMEOUT_EXCEPTION)
                .setNegativeButtonText(R.string.cancel).setRequestCode(Constant.RequestCode.DIALOG_ERROR)
                .setCancelableOnTouchOutside(false).show();
        break;
    case AMapException.CODE_AMAP_CLIENT_URL_EXCEPTION:
        PromptDialog.createBuilder(activity.getSupportFragmentManager())
                .setTitle(activity.getString(R.string.error_prompt))
                .setPrompt(AMapException.AMAP_CLIENT_URL_EXCEPTION).setNegativeButtonText(R.string.cancel)
                .setRequestCode(Constant.RequestCode.DIALOG_ERROR).setCancelableOnTouchOutside(false).show();
        break;
    case AMapException.CODE_AMAP_CLIENT_UNKNOWHOST_EXCEPTION:
        PromptDialog.createBuilder(activity.getSupportFragmentManager())
                .setTitle(activity.getString(R.string.error_prompt))
                .setPrompt(AMapException.AMAP_CLIENT_UNKNOWHOST_EXCEPTION)
                .setNegativeButtonText(R.string.cancel).setRequestCode(Constant.RequestCode.DIALOG_ERROR)
                .setCancelableOnTouchOutside(false).show();
        break;
    case AMapException.CODE_AMAP_CLIENT_NETWORK_EXCEPTION:
        PromptDialog.createBuilder(activity.getSupportFragmentManager())
                .setTitle(activity.getString(R.string.error_prompt))
                .setPrompt(AMapException.AMAP_CLIENT_NETWORK_EXCEPTION).setNegativeButtonText(R.string.cancel)
                .setRequestCode(Constant.RequestCode.DIALOG_ERROR).setCancelableOnTouchOutside(false).show();
        break;
    case AMapException.CODE_AMAP_CLIENT_UNKNOWN_ERROR:
        PromptDialog.createBuilder(activity.getSupportFragmentManager())
                .setTitle(activity.getString(R.string.error_prompt))
                .setPrompt(AMapException.AMAP_CLIENT_UNKNOWN_ERROR).setNegativeButtonText(R.string.cancel)
                .setRequestCode(Constant.RequestCode.DIALOG_ERROR).setCancelableOnTouchOutside(false).show();
        break;
    case AMapException.CODE_AMAP_CLIENT_INVALID_PARAMETER:
        PromptDialog.createBuilder(activity.getSupportFragmentManager())
                .setTitle(activity.getString(R.string.error_prompt))
                .setPrompt(AMapException.AMAP_CLIENT_INVALID_PARAMETER).setNegativeButtonText(R.string.cancel)
                .setRequestCode(Constant.RequestCode.DIALOG_ERROR).setCancelableOnTouchOutside(false).show();
        break;
    case AMapException.CODE_AMAP_CLIENT_IO_EXCEPTION:
        PromptDialog.createBuilder(activity.getSupportFragmentManager())
                .setTitle(activity.getString(R.string.error_prompt))
                .setPrompt(AMapException.AMAP_CLIENT_IO_EXCEPTION).setNegativeButtonText(R.string.cancel)
                .setRequestCode(Constant.RequestCode.DIALOG_ERROR).setCancelableOnTouchOutside(false).show();
        break;
    case AMapException.CODE_AMAP_CLIENT_NULLPOINT_EXCEPTION:
        PromptDialog.createBuilder(activity.getSupportFragmentManager())
                .setTitle(activity.getString(R.string.error_prompt))
                .setPrompt(AMapException.AMAP_CLIENT_NULLPOINT_EXCEPTION).setNegativeButtonText(R.string.cancel)
                .setRequestCode(Constant.RequestCode.DIALOG_ERROR).setCancelableOnTouchOutside(false).show();
        break;
    case AMapException.CODE_AMAP_SERVICE_TABLEID_NOT_EXIST:
        PromptDialog.createBuilder(activity.getSupportFragmentManager())
                .setTitle(activity.getString(R.string.error_prompt))
                .setPrompt(AMapException.AMAP_SERVICE_TABLEID_NOT_EXIST).setNegativeButtonText(R.string.cancel)
                .setRequestCode(Constant.RequestCode.DIALOG_ERROR).setCancelableOnTouchOutside(false).show();
        break;
    case AMapException.CODE_AMAP_ID_NOT_EXIST:
        PromptDialog.createBuilder(activity.getSupportFragmentManager())
                .setTitle(activity.getString(R.string.error_prompt)).setPrompt(AMapException.AMAP_ID_NOT_EXIST)
                .setNegativeButtonText(R.string.cancel).setRequestCode(Constant.RequestCode.DIALOG_ERROR)
                .setCancelableOnTouchOutside(false).show();
        break;
    case AMapException.CODE_AMAP_SERVICE_MAINTENANCE:
        PromptDialog.createBuilder(activity.getSupportFragmentManager())
                .setTitle(activity.getString(R.string.error_prompt))
                .setPrompt(AMapException.AMAP_SERVICE_MAINTENANCE).setNegativeButtonText(R.string.cancel)
                .setRequestCode(Constant.RequestCode.DIALOG_ERROR).setCancelableOnTouchOutside(false).show();
        break;
    case AMapException.CODE_AMAP_ENGINE_TABLEID_NOT_EXIST:
        PromptDialog.createBuilder(activity.getSupportFragmentManager())
                .setTitle(activity.getString(R.string.error_prompt))
                .setPrompt(AMapException.AMAP_ENGINE_TABLEID_NOT_EXIST).setNegativeButtonText(R.string.cancel)
                .setRequestCode(Constant.RequestCode.DIALOG_ERROR).setCancelableOnTouchOutside(false).show();
        break;
    case AMapException.CODE_AMAP_NEARBY_INVALID_USERID:
        PromptDialog.createBuilder(activity.getSupportFragmentManager())
                .setTitle(activity.getString(R.string.error_prompt))
                .setPrompt(AMapException.AMAP_NEARBY_INVALID_USERID).setNegativeButtonText(R.string.cancel)
                .setRequestCode(Constant.RequestCode.DIALOG_ERROR).setCancelableOnTouchOutside(false).show();
        break;
    case AMapException.CODE_AMAP_NEARBY_KEY_NOT_BIND:
        PromptDialog.createBuilder(activity.getSupportFragmentManager())
                .setTitle(activity.getString(R.string.error_prompt))
                .setPrompt(AMapException.AMAP_NEARBY_KEY_NOT_BIND).setNegativeButtonText(R.string.cancel)
                .setRequestCode(Constant.RequestCode.DIALOG_ERROR).setCancelableOnTouchOutside(false).show();
        break;
    case AMapException.CODE_AMAP_CLIENT_UPLOADAUTO_STARTED_ERROR:
        PromptDialog.createBuilder(activity.getSupportFragmentManager())
                .setTitle(activity.getString(R.string.error_prompt))
                .setPrompt(AMapException.AMAP_CLIENT_UPLOADAUTO_STARTED_ERROR)
                .setNegativeButtonText(R.string.cancel).setRequestCode(Constant.RequestCode.DIALOG_ERROR)
                .setCancelableOnTouchOutside(false).show();
        break;
    case AMapException.CODE_AMAP_CLIENT_USERID_ILLEGAL:
        PromptDialog.createBuilder(activity.getSupportFragmentManager())
                .setTitle(activity.getString(R.string.error_prompt))
                .setPrompt(AMapException.AMAP_CLIENT_USERID_ILLEGAL).setNegativeButtonText(R.string.cancel)
                .setRequestCode(Constant.RequestCode.DIALOG_ERROR).setCancelableOnTouchOutside(false).show();
        break;
    case AMapException.CODE_AMAP_CLIENT_NEARBY_NULL_RESULT:
        PromptDialog.createBuilder(activity.getSupportFragmentManager())
                .setTitle(activity.getString(R.string.error_prompt))
                .setPrompt(AMapException.AMAP_CLIENT_NEARBY_NULL_RESULT).setNegativeButtonText(R.string.cancel)
                .setRequestCode(Constant.RequestCode.DIALOG_ERROR).setCancelableOnTouchOutside(false).show();
        break;
    case AMapException.CODE_AMAP_CLIENT_UPLOAD_TOO_FREQUENT:
        PromptDialog.createBuilder(activity.getSupportFragmentManager())
                .setTitle(activity.getString(R.string.error_prompt))
                .setPrompt(AMapException.AMAP_CLIENT_UPLOAD_TOO_FREQUENT).setNegativeButtonText(R.string.cancel)
                .setRequestCode(Constant.RequestCode.DIALOG_ERROR).setCancelableOnTouchOutside(false).show();
        break;
    case AMapException.CODE_AMAP_CLIENT_UPLOAD_LOCATION_ERROR:
        PromptDialog.createBuilder(activity.getSupportFragmentManager())
                .setTitle(activity.getString(R.string.error_prompt))
                .setPrompt(AMapException.AMAP_CLIENT_UPLOAD_LOCATION_ERROR)
                .setNegativeButtonText(R.string.cancel).setRequestCode(Constant.RequestCode.DIALOG_ERROR)
                .setCancelableOnTouchOutside(false).show();
        break;
    case AMapException.CODE_AMAP_ROUTE_OUT_OF_SERVICE:
        PromptDialog.createBuilder(activity.getSupportFragmentManager())
                .setTitle(activity.getString(R.string.error_prompt))
                .setPrompt(AMapException.AMAP_ROUTE_OUT_OF_SERVICE).setNegativeButtonText(R.string.cancel)
                .setRequestCode(Constant.RequestCode.DIALOG_ERROR).setCancelableOnTouchOutside(false).show();
        break;
    case AMapException.CODE_AMAP_ROUTE_NO_ROADS_NEARBY:
        PromptDialog.createBuilder(activity.getSupportFragmentManager())
                .setTitle(activity.getString(R.string.error_prompt))
                .setPrompt(AMapException.AMAP_ROUTE_NO_ROADS_NEARBY).setNegativeButtonText(R.string.cancel)
                .setRequestCode(Constant.RequestCode.DIALOG_ERROR).setCancelableOnTouchOutside(false).show();
        break;
    case AMapException.CODE_AMAP_ROUTE_FAIL:
        PromptDialog.createBuilder(activity.getSupportFragmentManager())
                .setTitle(activity.getString(R.string.error_prompt)).setPrompt(AMapException.AMAP_ROUTE_FAIL)
                .setNegativeButtonText(R.string.cancel).setRequestCode(Constant.RequestCode.DIALOG_ERROR)
                .setCancelableOnTouchOutside(false).show();
        break;
    case AMapException.CODE_AMAP_OVER_DIRECTION_RANGE:
        PromptDialog.createBuilder(activity.getSupportFragmentManager())
                .setTitle(activity.getString(R.string.error_prompt))
                .setPrompt(AMapException.AMAP_OVER_DIRECTION_RANGE).setNegativeButtonText(R.string.cancel)
                .setRequestCode(Constant.RequestCode.DIALOG_ERROR).setCancelableOnTouchOutside(false).show();
        break;
    case AMapException.CODE_AMAP_SHARE_LICENSE_IS_EXPIRED:
        PromptDialog.createBuilder(activity.getSupportFragmentManager())
                .setTitle(activity.getString(R.string.error_prompt))
                .setPrompt(AMapException.AMAP_SHARE_LICENSE_IS_EXPIRED).setNegativeButtonText(R.string.cancel)
                .setRequestCode(Constant.RequestCode.DIALOG_ERROR).setCancelableOnTouchOutside(false).show();
        break;
    case AMapException.CODE_AMAP_SHARE_FAILURE:
        PromptDialog.createBuilder(activity.getSupportFragmentManager())
                .setTitle(activity.getString(R.string.error_prompt)).setPrompt(AMapException.AMAP_SHARE_FAILURE)
                .setNegativeButtonText(R.string.cancel).setRequestCode(Constant.RequestCode.DIALOG_ERROR)
                .setCancelableOnTouchOutside(false).show();
        break;
    case PathPlanningErrCode.ERROR_CONNECTION:
        PromptDialog.createBuilder(activity.getSupportFragmentManager())
                .setTitle(activity.getString(R.string.error_prompt))
                .setPrompt(activity.getString(R.string.error_prompt_path_plan1))
                .setNegativeButtonText(R.string.cancel).setRequestCode(Constant.RequestCode.DIALOG_ERROR)
                .setCancelableOnTouchOutside(false).show();
        break;
    case PathPlanningErrCode.ERROR_ENDPOINT:
        PromptDialog.createBuilder(activity.getSupportFragmentManager())
                .setTitle(activity.getString(R.string.error_prompt))
                .setPrompt(activity.getString(R.string.error_prompt_path_plan2))
                .setNegativeButtonText(R.string.cancel).setRequestCode(Constant.RequestCode.DIALOG_ERROR)
                .setCancelableOnTouchOutside(false).show();
        break;
    case PathPlanningErrCode.ERROR_NOROADFORENDPOINT:
        PromptDialog.createBuilder(activity.getSupportFragmentManager())
                .setTitle(activity.getString(R.string.error_prompt))
                .setPrompt(activity.getString(R.string.error_prompt_path_plan3))
                .setNegativeButtonText(R.string.cancel).setRequestCode(Constant.RequestCode.DIALOG_ERROR)
                .setCancelableOnTouchOutside(false).show();
        break;
    case PathPlanningErrCode.ERROR_NOROADFORSTARTPOINT:
        PromptDialog.createBuilder(activity.getSupportFragmentManager())
                .setTitle(activity.getString(R.string.error_prompt))
                .setPrompt(activity.getString(R.string.error_prompt_path_plan4))
                .setNegativeButtonText(R.string.cancel).setRequestCode(Constant.RequestCode.DIALOG_ERROR)
                .setCancelableOnTouchOutside(false).show();
        break;
    case PathPlanningErrCode.ERROR_NOROADFORWAYPOINT:
        PromptDialog.createBuilder(activity.getSupportFragmentManager())
                .setTitle(activity.getString(R.string.error_prompt))
                .setPrompt(activity.getString(R.string.error_prompt_path_plan5))
                .setNegativeButtonText(R.string.cancel).setRequestCode(Constant.RequestCode.DIALOG_ERROR)
                .setCancelableOnTouchOutside(false).show();
        break;
    case PathPlanningErrCode.ERROR_PROTOCOL:
        PromptDialog.createBuilder(activity.getSupportFragmentManager())
                .setTitle(activity.getString(R.string.error_prompt))
                .setPrompt(activity.getString(R.string.error_prompt_path_plan6))
                .setNegativeButtonText(R.string.cancel).setRequestCode(Constant.RequestCode.DIALOG_ERROR)
                .setCancelableOnTouchOutside(false).show();
        break;
    case PathPlanningErrCode.ERROR_STARTPOINT:
        PromptDialog.createBuilder(activity.getSupportFragmentManager())
                .setTitle(activity.getString(R.string.error_prompt))
                .setPrompt(activity.getString(R.string.error_prompt_path_plan7))
                .setNegativeButtonText(R.string.cancel).setRequestCode(Constant.RequestCode.DIALOG_ERROR)
                .setCancelableOnTouchOutside(false).show();
        break;
    case PathPlanningErrCode.INSUFFICIENT_PRIVILEGES:
        PromptDialog.createBuilder(activity.getSupportFragmentManager())
                .setTitle(activity.getString(R.string.error_prompt))
                .setPrompt(activity.getString(R.string.error_prompt_path_plan8))
                .setNegativeButtonText(R.string.cancel).setRequestCode(Constant.RequestCode.DIALOG_ERROR)
                .setCancelableOnTouchOutside(false).show();
        break;
    case PathPlanningErrCode.INVALID_PARAMS:
        PromptDialog.createBuilder(activity.getSupportFragmentManager())
                .setTitle(activity.getString(R.string.error_prompt))
                .setPrompt(activity.getString(R.string.error_prompt_path_plan9))
                .setNegativeButtonText(R.string.cancel).setRequestCode(Constant.RequestCode.DIALOG_ERROR)
                .setCancelableOnTouchOutside(false).show();
        break;
    case PathPlanningErrCode.INVALID_USER_KEY:
        PromptDialog.createBuilder(activity.getSupportFragmentManager())
                .setTitle(activity.getString(R.string.error_prompt))
                .setPrompt(activity.getString(R.string.error_prompt_path_plan10))
                .setNegativeButtonText(R.string.cancel).setRequestCode(Constant.RequestCode.DIALOG_ERROR)
                .setCancelableOnTouchOutside(false).show();
        break;
    case PathPlanningErrCode.OVER_QUOTA:
        PromptDialog.createBuilder(activity.getSupportFragmentManager())
                .setTitle(activity.getString(R.string.error_prompt))
                .setPrompt(activity.getString(R.string.error_prompt_path_plan11))
                .setNegativeButtonText(R.string.cancel).setRequestCode(Constant.RequestCode.DIALOG_ERROR)
                .setCancelableOnTouchOutside(false).show();
        break;
    case PathPlanningErrCode.SERVICE_NOT_EXIST:
        PromptDialog.createBuilder(activity.getSupportFragmentManager())
                .setTitle(activity.getString(R.string.error_prompt))
                .setPrompt(activity.getString(R.string.error_prompt_path_plan12))
                .setNegativeButtonText(R.string.cancel).setRequestCode(Constant.RequestCode.DIALOG_ERROR)
                .setCancelableOnTouchOutside(false).show();
        break;
    case PathPlanningErrCode.SERVICE_RESPONSE_ERROR:
        PromptDialog.createBuilder(activity.getSupportFragmentManager())
                .setTitle(activity.getString(R.string.error_prompt))
                .setPrompt(activity.getString(R.string.error_prompt_path_plan13))
                .setNegativeButtonText(R.string.cancel).setRequestCode(Constant.RequestCode.DIALOG_ERROR)
                .setCancelableOnTouchOutside(false).show();
        break;
    case PathPlanningErrCode.SUCCESS_ROUTE:
        PromptDialog.createBuilder(activity.getSupportFragmentManager())
                .setTitle(activity.getString(R.string.error_prompt))
                .setPrompt(activity.getString(R.string.error_prompt_path_plan14))
                .setNegativeButtonText(R.string.cancel).setRequestCode(Constant.RequestCode.DIALOG_ERROR)
                .setCancelableOnTouchOutside(false).show();
        break;
    case PathPlanningErrCode.UNKNOWN_ERROR:
        PromptDialog.createBuilder(activity.getSupportFragmentManager())
                .setTitle(activity.getString(R.string.error_prompt))
                .setPrompt(activity.getString(R.string.error_prompt_path_plan15))
                .setNegativeButtonText(R.string.cancel).setRequestCode(Constant.RequestCode.DIALOG_ERROR)
                .setCancelableOnTouchOutside(false).show();
        break;
    default:
        PromptDialog.createBuilder(activity.getSupportFragmentManager())
                .setTitle(activity.getString(R.string.error_prompt))
                .setPrompt(activity.getString(R.string.error_prompt_path_plan1))
                .setNegativeButtonText(R.string.cancel).setRequestCode(Constant.RequestCode.DIALOG_ERROR)
                .setCancelableOnTouchOutside(false).show();
        break;
    }
}

From source file:com.abiansoftware.lib.reader.AbianReaderListView.java

public void initializeViewAfterPopulation(FragmentActivity parentActivity) {
    m_abianReaderListView = (ListView) parentActivity.findViewById(R.id.abian_reader_list_view_listview);

    LayoutInflater theLayoutInflater = LayoutInflater.from(parentActivity);

    m_headerViewPagerLayout = (RelativeLayout) theLayoutInflater
            .inflate(R.layout.abian_reader_list_header_view_pager, null);

    m_headerViewPager = (UninterceptableViewPager) m_headerViewPagerLayout
            .findViewById(R.id.abian_reader_list_header_viewpager_view);
    m_pageIndicator = (CirclePageIndicator) m_headerViewPagerLayout
            .findViewById(R.id.abian_reader_list_header_page_indicator);

    m_headerViewPagerAdapter = new AbianReaderListHeaderViewPagerAdapter(
            parentActivity.getSupportFragmentManager());
    m_headerViewPager.setAdapter(m_headerViewPagerAdapter);
    m_pageIndicator.setViewPager(m_headerViewPager);

    // m_pageIndicator.setPageColor(0xFFcbedcc);

    int indicatorColor = AbianReaderApplication.getInstance().getResources()
            .getColor(R.color.view_page_indicator_color);

    m_pageIndicator.setFillColor(indicatorColor);
    m_pageIndicator.setStrokeColor(indicatorColor);
    m_pageIndicator.setSnap(true);/*from   w w  w  .  ja v a2s  . com*/

    ViewGroup.LayoutParams headerViewPagerLayoutParams = m_headerViewPager.getLayoutParams();
    m_preferredListItemHeight = headerViewPagerLayoutParams.height;
    headerViewPagerLayoutParams.height = (int) (m_preferredListItemHeight
            * AbianReaderApplication.FEATURED_IMAGE_SIZE);
    m_headerViewPager.setLayoutParams(headerViewPagerLayoutParams);

    m_abianReaderListView.addHeaderView(m_headerViewPagerLayout);

    // have to set the adapter after you add header/footer views
    m_abianReaderListAdapter = new AbianReaderListAdapter(parentActivity);
    m_abianReaderListView.setAdapter(m_abianReaderListAdapter);

    m_headerViewPagerLayout.setVisibility(View.GONE);
    m_headerViewPager.setVisibility(View.GONE);
    m_pageIndicator.setVisibility(View.GONE);

    AbianReaderApplication.getInstance().registerAdapter(m_abianReaderListAdapter);
}

From source file:com.wit.android.support.fragment.manage.FragmentController.java

/**
 * Creates a new instance of FragmentController within the given <var>parentActivity</var>'s context.
 * <p>//from  w w w.  j a v  a2s. c o  m
 * Passed activity will be used to obtain an instance of {@link android.support.v4.app.FragmentManager}
 * by {@link android.support.v4.app.FragmentActivity#getFragmentManager()} that will be used to
 * mange fragments by this controller.
 * <p>
 * If the given <var>parentActivity</var> implements {@link FragmentController.OnBackStackChangeListener}
 * or {@link com.wit.android.support.fragment.manage.FragmentController.OnChangeListener} it will
 * be automatically set as these callbacks to this controller.
 *
 * @param parentActivity An activity in which will be this controller used.
 * @see #FragmentController(android.support.v4.app.Fragment)
 */
public FragmentController(@NonNull FragmentActivity parentActivity) {
    this(parentActivity.getSupportFragmentManager());
    if (parentActivity instanceof OnBackStackChangeListener) {
        setOnBackStackChangeListener((OnBackStackChangeListener) parentActivity);
    }
    if (parentActivity instanceof OnChangeListener) {
        setOnChangeListener((OnChangeListener) parentActivity);
    }
}