Android Open Source - sms-smap-gateway Base Fragment






From Project

Back to project page sms-smap-gateway.

License

The source code is released under:

GNU General Public License

If you think the Android project sms-smap-gateway listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.android.smap.fragments;
/*from   w  w  w  .j  a va2s. co  m*/
import android.app.ActionBar;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;

import com.android.smap.R;

/**
 * <pre>
 * BaseFragment acts as a superclass for all major fragments in the application.
 * 
 * BaseFragment provides:
 *      The new/next device-agnostic navigation 
 *      Resetting the action bar title as you navigate.
 * </pre>
 * 
 * BaseFragment also acts as a suitable bottleneck to attach behaviors such as
 * Google Analytics or Deep Linking.
 * 
 * @author matt witherow
 */

public class BaseFragment extends Fragment {

  public static final String  EXTRA_DEEP_LINK_DATA  = BaseFragment.class
                                .getName()
                                + ".EXTRA_DEEP_LINK_DATA";

  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (hasActionBarTitle()) {
      getActionBar().setTitle(getActionBarTitle());
    }
  }

  @Override
  public void onDetach() {
    super.onDetach();
    if (hasActionBarTitle()) {
      getActionBar().setTitle(getString(R.string.app_name));
    }
  }

  /**
   * Function to get the action bar instance
   * 
   * @return
   */
  public ActionBar getActionBar() {
    return getActivity().getActionBar();
  }

  /**
   * full screen regardless of tablet or phone
   * 
   * @return
   */
  public boolean isFullScreen() {
    return false;
  }

  /**
   * Whether or not this fragment wants to display a custom action bar title.
   * Subclasses that return true can return the action bar title that they
   * wish to display from getActionBarTitle. When a fragment that returns true
   * in hasActionBarTitle is detached the action bar title will be reset to
   * the app name.
   * 
   * @return
   */
  public boolean hasActionBarTitle() {
    return false;
  }

  /**
   * The action bar title to use when this fragment is displayed. Note: if
   * this fragment wants this title to be displayed it must also override
   * hasActionBarTitle and return true
   * 
   * @return
   */
  public String getActionBarTitle() {
    return "";
  }

  /**
   * Push a new fragment onto the stack.
   * 
   * @param cls
   *            The fragment class to push.
   */
  public void pushFragment(Class<?> cls) {
    pushFragment(cls, null);
  }

  /**
   * Push a new fragment onto the stack.
   * 
   * @param cls
   *            The fragment class to push.
   * @param args
   *            The arguments provided to the fragment.
   */
  public void pushFragment(Class<?> cls, Bundle args) {
    Fragment f = Fragment.instantiate(getActivity(), cls.getName());
    f.setArguments(args);
    FragmentTransaction ft = getFragmentManager().beginTransaction();
    ft.replace(R.id.container, f);
    ft.addToBackStack(null);
    ft.commit();
  }

  /**
   * Replaces the current fragment. This can be used for adding the initial
   * fragment as well as replacing.
   * 
   * @param cls
   *            The fragment that will replace the current fragment.
   */
  public void replaceFragment(Class<?> cls) {
    replaceFragment(cls, null);
  }

  /**
   * Replaces the current fragment. This can be used for adding the initial
   * fragment as well as replacing.
   * 
   * @param cls
   *            The fragment that will replace the current fragment.
   * @param args
   *            The arguments provided to the fragment.
   */
  public void replaceFragment(Class<?> cls, Bundle args) {
    Fragment f = Fragment.instantiate(getActivity(), cls.getName());
    f.setArguments(args);
    FragmentTransaction ft = getFragmentManager().beginTransaction();
    ft.replace(R.id.container, f);
    ft.commit();
  }
}




Java Source Code List

com.android.smap.AppConfig.java
com.android.smap.GatewayApp.java
com.android.smap.PhoneStateWrapper.java
com.android.smap.activities.BaseActivity.java
com.android.smap.activities.FragmentWrapperActivity.java
com.android.smap.activities.MainActivity.java
com.android.smap.adapters.MenuDrawerAdapter.java
com.android.smap.api.ApiConstants.java
com.android.smap.api.models.Gojo.java
com.android.smap.api.models.Node.java
com.android.smap.api.models.SmapException.java
com.android.smap.api.models.Status.java
com.android.smap.api.models.validator.ModelValidator.java
com.android.smap.api.models.validator.Required.java
com.android.smap.api.requests.ApiRequest.java
com.android.smap.api.requests.GojoRequest.java
com.android.smap.api.requests.StatusRequest.java
com.android.smap.commonsware.wakefull.AlarmReceiver.java
com.android.smap.commonsware.wakefull.WakefulIntentService.java
com.android.smap.controllers.ControllerErrorListener.java
com.android.smap.controllers.ControllerError.java
com.android.smap.controllers.ControllerFactory.java
com.android.smap.controllers.ControllerListener.java
com.android.smap.controllers.Controller.java
com.android.smap.controllers.EmailController.java
com.android.smap.controllers.GojoController.java
com.android.smap.controllers.UIPagingController.java
com.android.smap.controllers.UIRequestController.java
com.android.smap.fragments.BaseFragment.java
com.android.smap.fragments.HomeFragment.java
com.android.smap.models.MenuDrawerItem.java
com.android.smap.models.TextMessage.java
com.android.smap.samuel.Samuel.java
com.android.smap.sms.CellularModem.java
com.android.smap.sms.GatewayService.java
com.android.smap.sms.MonitorService.java
com.android.smap.sms.ScheduleMonitoringListener.java
com.android.smap.sms.ServiceRebooter.java
com.android.smap.ui.ArrayVelocAdapter.java
com.android.smap.ui.OnErrorTouchedListener.java
com.android.smap.ui.Operation.java
com.android.smap.ui.VelocAdapter.java
com.android.smap.ui.ViewBinder.java
com.android.smap.ui.ViewQuery.java
com.android.smap.ui.views.AnimatedNetworkImageView.java
com.android.smap.ui.views.ErrorView.java
com.android.smap.ui.views.FontableTextView.java
com.android.smap.utils.BitmapLruCache.java
com.android.smap.utils.MWAPNUtils.java
com.android.smap.utils.MWAnimUtil.java
com.android.smap.utils.MWAssetsUtils.java
com.android.smap.utils.MWConnectionUtils.java
com.android.smap.utils.MWEmailUtils.java
com.android.smap.utils.MWUiUtils.java
com.android.smap.utils.PreferenceWrapper.java
com.android.smap.utils.Refresher.java
com.android.smap.utils.UriBuilder.java