Java Code Examples for android.support.v4.app.FragmentActivity

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project agit, under directory /agit/src/main/java/com/madgag/android/util/store/.

Source file: InstallAppDialogFragment.java

  24 
vote

@Override public Dialog onCreateDialog(Bundle savedInstanceState){
  final Bundle args=getArguments();
  FragmentActivity activity=getActivity();
  return new AlertDialog.Builder(activity).setIcon(args.getInt(ICON)).setTitle(args.getInt(TITLE)).setMessage(args.getInt(MESSAGE)).setPositiveButton(activity.getString(R.string.market_button),new DialogInterface.OnClickListener(){
    public void onClick(    DialogInterface dialog,    int whichButton){
      startActivity(marketDownloadIntentFor(args.getString(APP_ID)));
    }
  }
).setNegativeButton(button_cancel,new DialogInterface.OnClickListener(){
    public void onClick(    DialogInterface dialog,    int whichButton){
    }
  }
).create();
}
 

Example 2

From project droidparts, under directory /modern/src/org/droidparts/inject/injector/.

Source file: ParentActivityInjector.java

  24 
vote

static boolean inject(Fragment fragment,Field field){
  FragmentActivity activity=fragment.getActivity();
  try {
    setFieldVal(fragment,field,activity);
    return true;
  }
 catch (  IllegalArgumentException e) {
  }
  return false;
}
 

Example 3

From project mWater-Android-App, under directory /android/src/co/mwater/clientapp/util/.

Source file: ProgressFragment.java

  23 
vote

protected void runNow(final ActivityTask task){
  final FragmentActivity activity=getActivity();
  activity.runOnUiThread(new Runnable(){
    public void run(){
      task.run(activity);
    }
  }
);
}
 

Example 4

From project eoit, under directory /EOIT/src/fr/eoit/activity/util/task/.

Source file: UpdateFavoriteStationPriceAsyncTask.java

  22 
vote

@Override protected Void doInBackground(FragmentActivity... params){
  FragmentActivity activity=params[0];
  Cursor cursor=activity.getContentResolver().query(Station.CONTENT_URI,new String[]{Station._ID,Station.COLUMN_NAME_SOLAR_SYSTEM_ID},Station.COLUMN_NAME_FAVORITE + " = 1",null,null);
  try {
    if (DbUtil.hasAtLeastOneRow(cursor)) {
      while (cursor.isAfterLast() == false) {
        int solarSystemId=cursor.getInt(cursor.getColumnIndexOrThrow(Station.COLUMN_NAME_SOLAR_SYSTEM_ID));
        PriceUpdaterService.updatePricesForItemId(activity.getApplicationContext(),solarSystemId,itemId);
        cursor.moveToNext();
      }
    }
  }
  finally {
    cursor.close();
  }
  activity.getContentResolver().notifyChange(ContentUris.withAppendedId(Station.CONTENT_ID_FAVORITE_STATIONS_PRICES_URI_BASE,itemId),null);
  return null;
}
 

Example 5

From project SeriesGuide, under directory /SeriesGuide/src/com/battlelancer/seriesguide/ui/.

Source file: SeasonsFragment.java

  22 
vote

public void run(){
  final FragmentActivity context=getActivity();
  if (context == null) {
    return;
  }
  final SharedPreferences prefs=PreferenceManager.getDefaultSharedPreferences(context);
  if (mSeasonId != null) {
    DBUtils.updateUnwatchedCount(context,mSeasonId,prefs);
  }
 else {
    final Cursor seasons=context.getContentResolver().query(Seasons.buildSeasonsOfShowUri(mShowId),new String[]{Seasons._ID},null,null,Seasons.COMBINED + " DESC");
    while (seasons.moveToNext()) {
      String seasonId=seasons.getString(0);
      DBUtils.updateUnwatchedCount(context,seasonId,prefs);
      notifyContentProvider(context);
    }
    seasons.close();
  }
  notifyContentProvider(context);
}
 

Example 6

From project Synodroid, under directory /src/com/bigpupdev/synodroid/ui/.

Source file: GetStartedFragment.java

  22 
vote

/** 
 * Activity creation
 */
@Override public View onCreateView(LayoutInflater inflater,ViewGroup container,Bundle savedInstanceState){
  super.onCreateView(inflater,container,savedInstanceState);
  try {
    if (((Synodroid)getActivity().getApplication()).DEBUG)     Log.v(Synodroid.DS_TAG,"GetStartedFragment: Creating Get Started fragment");
  }
 catch (  Exception ex) {
  }
  final FragmentActivity gsActivity=this.getActivity();
  View gs=inflater.inflate(R.layout.get_started,null,false);
  Button btnSkip=(Button)gs.findViewById(R.id.btn_skip);
  btnSkip.setOnClickListener(new View.OnClickListener(){
    public void onClick(    View v){
      gsActivity.finish();
    }
  }
);
  return gs;
}
 

Example 7

From project twidere, under directory /src/org/mariotaku/twidere/activity/.

Source file: ComposeActivity.java

  22 
vote

@Override public void onClick(final DialogInterface dialog,final int which){
  final FragmentActivity activity=getActivity();
switch (which) {
case DialogInterface.BUTTON_POSITIVE:
{
      if (activity instanceof ComposeActivity) {
        ((ComposeActivity)activity).saveToDrafts();
        activity.finish();
      }
      break;
    }
case DialogInterface.BUTTON_NEGATIVE:
{
    activity.finish();
    break;
  }
}
}
 

Example 8

From project ActionBarSherlock, under directory /library/src/com/actionbarsherlock/internal/app/.

Source file: ActionBarImpl.java

  20 
vote

@Override public void selectTab(Tab tab){
  if (getNavigationMode() != NAVIGATION_MODE_TABS) {
    mSavedTabPosition=tab != null ? tab.getPosition() : INVALID_POSITION;
    return;
  }
  FragmentTransaction trans=null;
  if (mActivity instanceof FragmentActivity) {
    trans=((FragmentActivity)mActivity).getSupportFragmentManager().beginTransaction().disallowAddToBackStack();
  }
  if (mSelectedTab == tab) {
    if (mSelectedTab != null) {
      mSelectedTab.getCallback().onTabReselected(mSelectedTab,trans);
      mTabScrollView.animateToTab(tab.getPosition());
    }
  }
 else {
    mTabScrollView.setTabSelected(tab != null ? tab.getPosition() : Tab.INVALID_POSITION);
    if (mSelectedTab != null) {
      mSelectedTab.getCallback().onTabUnselected(mSelectedTab,trans);
    }
    mSelectedTab=(TabImpl)tab;
    if (mSelectedTab != null) {
      mSelectedTab.getCallback().onTabSelected(mSelectedTab,trans);
    }
  }
  if (trans != null && !trans.isEmpty()) {
    trans.commit();
  }
}
 

Example 9

From project adg-android, under directory /src/com/analysedesgeeks/android/.

Source file: MainActivity.java

  20 
vote

public TabsAdapter(final FragmentActivity activity,final ActionBar actionBar,final ViewPager pager){
  super(activity.getSupportFragmentManager());
  mActionBar=actionBar;
  mViewPager=pager;
  mViewPager.setAdapter(this);
  mViewPager.setOnPageChangeListener(this);
  rssFragment=RssListFragment.newInstance();
  twitterFragment=WebFragment.newInstance(Const.ADG_TWITTER_URL);
}
 

Example 10

From project Airports, under directory /src/com/nadmm/airports/utils/.

Source file: TabsAdapter.java

  20 
vote

public TabsAdapter(FragmentActivity activity,ViewPager pager){
  super(activity.getSupportFragmentManager());
  mContext=activity;
  mViewPager=pager;
  mViewPager.setAdapter(this);
}
 

Example 11

From project android-xbmcremote-sandbox, under directory /src/org/xbmc/android/util/google/.

Source file: TabsAdapter.java

  20 
vote

public TabsAdapter(FragmentActivity activity,TabHost tabHost,ViewPager pager){
  super(activity.getSupportFragmentManager());
  mContext=activity;
  mTabHost=tabHost;
  mViewPager=pager;
  mTabHost.setOnTabChangedListener(this);
  mViewPager.setAdapter(this);
  mViewPager.setOnPageChangeListener(this);
}
 

Example 12

From project android_7, under directory /src/org/immopoly/android/widget/.

Source file: TabManager.java

  20 
vote

public TabManager(FragmentActivity activity,TabHost tabHost,int containerId){
  mActivity=activity;
  mTabHost=tabHost;
  mContainerId=containerId;
  mTabHost.setOnTabChangedListener(this);
}
 

Example 13

From project android_packages_apps_Superuser, under directory /src/com/noshufou/android/su/.

Source file: AppDetailsFragment.java

  20 
vote

public void closeDetails(){
  if (mDualPane) {
    Fragment logFragment=LogFragment.newInstance();
    FragmentTransaction transaction=((FragmentActivity)getActivity()).getSupportFragmentManager().beginTransaction();
    transaction.replace(R.id.fragment_container,logFragment);
    transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
    transaction.commit();
  }
 else {
    Util.goHome(getActivity());
  }
}
 

Example 14

From project Bitcoin-Wallet-for-Android, under directory /wallet/src/de/schildbach/wallet/ui/.

Source file: TransactionFragment.java

  20 
vote

@Override public void onAttach(final Activity activity){
  super.onAttach(activity);
  this.activity=(FragmentActivity)activity;
  dateFormat=android.text.format.DateFormat.getDateFormat(activity);
  timeFormat=android.text.format.DateFormat.getTimeFormat(activity);
}
 

Example 15

From project blogActivity, under directory /src/com/slezica/tools/async/.

Source file: ManagedAsyncTask.java

  20 
vote

public ManagedAsyncTask(FragmentActivity activity,String fragmentTag){
  FragmentManager fragmentManager=activity.getSupportFragmentManager();
  mManager=(TaskManagerFragment)fragmentManager.findFragmentByTag(fragmentTag);
  if (mManager == null) {
    mManager=new TaskManagerFragment();
    fragmentManager.beginTransaction().add(mManager,fragmentTag).commit();
  }
  mTask=new InternalAsyncTask();
}
 

Example 16

From project dungbeetle, under directory /src/edu/stanford/mobisocial/dungbeetle/feed/view/.

Source file: FeedViews.java

  20 
vote

public static void promptForView(final Context context,final Uri feedUri){
  String[] items=new String[getFeedViews().size()];
  int i=0;
  for (  FeedView v : getFeedViews()) {
    items[i++]=v.getName();
  }
  new AlertDialog.Builder(context).setItems(items,new DialogInterface.OnClickListener(){
    @Override public void onClick(    DialogInterface dialog,    int which){
      FeedView v=FeedViews.getFeedViews().get(which);
      Fragment f=v.getFragment();
      Bundle args=new Bundle();
      args.putParcelable("feed_uri",feedUri);
      f.setArguments(args);
      ((FragmentActivity)context).getSupportFragmentManager().beginTransaction().replace(R.id.feed_view,f).addToBackStack(null).commit();
    }
  }
).setTitle("View...").create().show();
}
 

Example 17

From project finch, under directory /libs/JakeWharton-ActionBarSherlock-2eabf25/samples/fragments/src/com/actionbarsherlock/sample/fragments/.

Source file: FragmentTabs.java

  20 
vote

public TabManager(FragmentActivity activity,TabHost tabHost,int containerId){
  mActivity=activity;
  mTabHost=tabHost;
  mContainerId=containerId;
  mTabHost.setOnTabChangedListener(this);
}
 

Example 18

From project Funf-Ohmage, under directory /src/com/slezica/tools/async/.

Source file: ManagedAsyncTask.java

  20 
vote

public ManagedAsyncTask(FragmentActivity activity,String fragmentTag){
  FragmentManager fragmentManager=activity.getSupportFragmentManager();
  mManager=(TaskManagerFragment)fragmentManager.findFragmentByTag(fragmentTag);
  if (mManager == null) {
    mManager=new TaskManagerFragment();
    fragmentManager.beginTransaction().add(mManager,fragmentTag).commit();
  }
  mTask=new InternalAsyncTask();
}
 

Example 19

From project iosched_3, under directory /android/src/com/google/android/apps/iosched/ui/.

Source file: SessionLivestreamActivity.java

  20 
vote

public TabsAdapter(FragmentActivity activity,TabHost tabHost,ViewPager pager){
  super(activity.getSupportFragmentManager());
  mContext=activity;
  mTabHost=tabHost;
  mViewPager=pager;
  mTabHost.setOnTabChangedListener(this);
  mViewPager.setAdapter(this);
  mViewPager.setOnPageChangeListener(this);
  mFragments=new SparseArray<Fragment>(3);
  mTabNums=new ArrayList<Integer>(3);
}
 

Example 20

From project maven-android-plugin-samples, under directory /support4demos/src/com/example/android/supportv4/app/.

Source file: FragmentTabs.java

  20 
vote

public TabManager(FragmentActivity activity,TabHost tabHost,int containerId){
  mActivity=activity;
  mTabHost=tabHost;
  mContainerId=containerId;
  mTabHost.setOnTabChangedListener(this);
}
 

Example 21

From project ohmagePhone, under directory /src/com/slezica/tools/async/.

Source file: ManagedAsyncTask.java

  20 
vote

public ManagedAsyncTask(FragmentActivity activity,String fragmentTag){
  FragmentManager fragmentManager=activity.getSupportFragmentManager();
  mManager=(TaskManagerFragment)fragmentManager.findFragmentByTag(fragmentTag);
  if (mManager == null) {
    mManager=new TaskManagerFragment();
    fragmentManager.beginTransaction().add(mManager,fragmentTag).commit();
  }
  mTask=new InternalAsyncTask();
}
 

Example 22

From project Ohmage_Phone, under directory /src/com/slezica/tools/async/.

Source file: ManagedAsyncTask.java

  20 
vote

public ManagedAsyncTask(FragmentActivity activity,String fragmentTag){
  FragmentManager fragmentManager=activity.getSupportFragmentManager();
  mManager=(TaskManagerFragment)fragmentManager.findFragmentByTag(fragmentTag);
  if (mManager == null) {
    mManager=new TaskManagerFragment();
    fragmentManager.beginTransaction().add(mManager,fragmentTag).commit();
  }
  mTask=new InternalAsyncTask();
}
 

Example 23

From project onebusaway-android, under directory /src/com/joulespersecond/seattlebusbot/.

Source file: TabListener.java

  20 
vote

public TabListener(FragmentActivity activity,String tag,Class<T> clz,Bundle args){
  mActivity=activity;
  mTag=tag;
  mClass=clz;
  mArgs=args;
  FragmentManager fm=mActivity.getSupportFragmentManager();
  mFragment=fm.findFragmentByTag(mTag);
  if (mFragment != null && !mFragment.isDetached()) {
    FragmentTransaction ft=fm.beginTransaction();
    ft.detach(mFragment);
    ft.commit();
  }
}
 

Example 24

From project pulWifi, under directory /src/es/pulimento/wifi/ui/.

Source file: HomeActivity.java

  20 
vote

public PagerAdapter(FragmentActivity activity,ViewPager pager,PagerHeader header){
  super(activity.getSupportFragmentManager());
  mContext=activity;
  mPager=pager;
  mHeader=header;
  mHeader.setOnHeaderClickListener(this);
  mPager.setAdapter(this);
  mPager.setOnPageChangeListener(this);
}
 

Example 25

From project rozkladpkp-android, under directory /src/org/tyszecki/rozkladpkp/.

Source file: RozkladPKP.java

  20 
vote

public TabsAdapter(FragmentActivity activity,ActionBar actionBar,ViewPager pager){
  super(activity.getSupportFragmentManager());
  mContext=activity;
  mActionBar=actionBar;
  mViewPager=pager;
  mViewPager.setAdapter(this);
  mViewPager.setOnPageChangeListener(this);
}
 

Example 26

From project simplefacebook, under directory /src/com/androidquery/simplefeed/.

Source file: PQuery.java

  20 
vote

public void forward(FragmentActivity act,int requestCode,int resultCode,Intent data){
  if (data == null)   return;
  String method=data.getStringExtra(FW_CB);
  AQUtility.debug("being forwarded!",method);
  if (method == null)   return;
  int id=data.getIntExtra(FW_ID,-1);
  if (id != -1) {
    Fragment f=act.getSupportFragmentManager().findFragmentById(id);
    AQUtility.debug("fr",f);
    if (f != null) {
      AQUtility.invokeHandler(f,method,false,true,FW_SIG,requestCode,resultCode,data);
    }
  }
}
 

Example 27

From project sthlmtraveling, under directory /src/com/markupartist/sthlmtraveling/.

Source file: FavoritesFragment.java

  20 
vote

/** 
 * Converts old favorites to the new journey table.
 */
private void maybeInitListAdapter(){
  SharedPreferences localSettings=getActivity().getPreferences(FragmentActivity.MODE_PRIVATE);
  boolean isFavoritesConvertedLegacy=localSettings.getBoolean("converted_favorites",false);
  SharedPreferences settings=getActivity().getSharedPreferences("sthlmtraveling",FragmentActivity.MODE_PRIVATE);
  boolean isFavoritesConverted=settings.getBoolean("converted_favorites",false);
  if (isFavoritesConvertedLegacy || isFavoritesConverted) {
    initListAdapter();
    return;
  }
  Toast.makeText(getActivity(),"Converting Favorites...",Toast.LENGTH_SHORT).show();
}
 

Example 28

From project The-Reverse-Recipe-Book, under directory /Mobile/src/com/reverserecipebook/.

Source file: ReverseRecipeCookbookActivity.java

  20 
vote

public TabListener(FragmentActivity activity,String tag,Class<T> clz,Bundle args){
  mActivity=activity;
  mTag=tag;
  mClass=clz;
  mArgs=args;
}
 

Example 29

From project TransportsRennes, under directory /TransportsCommun/src/fr/ybo/transportscommun/activity/commun/.

Source file: BaseActivity.java

  20 
vote

public TabsAdapter(FragmentActivity activity,TabHost tabHost,ViewPager pager){
  super(activity.getSupportFragmentManager());
  mContext=activity;
  mTabHost=tabHost;
  mViewPager=pager;
  mTabHost.setOnTabChangedListener(this);
  mViewPager.setAdapter(this);
  mViewPager.setOnPageChangeListener(this);
  dummyTabFactory=new DummyTabFactory(activity);
}
 

Example 30

From project Ushahidi_Android, under directory /Core/src/com/ushahidi/android/app/helpers/.

Source file: TabManager.java

  20 
vote

public TabManager(FragmentActivity activity,ActionBar actionBar,ViewPager pager){
  super(activity.getSupportFragmentManager());
  mContext=activity;
  mActionBar=actionBar;
  mViewPager=pager;
  mViewPager.setAdapter(this);
  mViewPager.setOnPageChangeListener(this);
}
 

Example 31

From project weechat-android, under directory /weechat-android/src/com/ubergeek42/WeechatAndroid/.

Source file: ChatLinesAdapter.java

  20 
vote

public ChatLinesAdapter(FragmentActivity activity,Buffer buffer){
  this.activity=activity;
  this.buffer=buffer;
  this.inflater=LayoutInflater.from(activity);
  prefs=PreferenceManager.getDefaultSharedPreferences(activity.getBaseContext());
  prefs.registerOnSharedPreferenceChangeListener(this);
  lines=buffer.getLines();
  enableColor=prefs.getBoolean("chatview_colors",true);
  enableTimestamp=prefs.getBoolean("chatview_timestamps",true);
  enableFilters=prefs.getBoolean("chatview_filters",true);
  prefix_align=prefs.getString("prefix_align","right");
  textSize=Float.parseFloat(prefs.getString("text_size","10"));
  timestampFormat=new SimpleDateFormat(prefs.getString("timestamp_format","HH:mm:ss"));
}
 

Example 32

From project XTrade, under directory /src/com/xtrade/android/fragment/.

Source file: TraderGeneralFragment.java

  20 
vote

@Override public void onActivityResult(int requestCode,int resultCode,Intent data){
  super.onActivityResult(requestCode,resultCode,data);
  if (resultCode == FragmentActivity.RESULT_OK) {
    if (txtTraderPhoto != null) {
      if (requestCode == TRADER_PHOTO_GALLERY_REQUEST)       txtTraderPhoto.setImageURI(data.getData());
 else       if (requestCode == TRADER_PHOTO_CAMERA_REQUEST) {
        Debug.info(this,"Ok this dialog " + data.getExtras());
      }
    }
  }
}