예제 #1
1
  private void showFragment(Class<?> paramClass, String paramString, boolean addToBackStack) {
    Log.d(TAG, "showFragment for " + paramClass);

    FragmentManager localFragmentManager = getSupportFragmentManager();

    Fragment localFragment = localFragmentManager.findFragmentById(R.id.fragment_container);

    if ((localFragment == null) || (!paramClass.isInstance(localFragment))) {
      try {
        Log.d(TAG, "replacing fragments");

        if (addToBackStack) {

          localFragment = (Fragment) paramClass.newInstance();
          localFragmentManager
              .beginTransaction()
              .add(R.id.fragment_container, localFragment)
              .addToBackStack("growth_stack")
              .commit();

        } else {
          localFragment = (Fragment) paramClass.newInstance();
          localFragmentManager
              .beginTransaction()
              .replace(R.id.fragment_container, localFragment)
              .commitAllowingStateLoss();
        }

      } catch (InstantiationException e) {
        e.printStackTrace();
      } catch (IllegalAccessException e) {
        e.printStackTrace();
      }
    }
  }
  @Override
  protected void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.network_monitor_content);

    final ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);

    final ViewPager pager = (ViewPager) findViewById(R.id.network_monitor_pager);

    final FragmentManager fm = getSupportFragmentManager();

    if (pager != null) {
      final ViewPagerTabs pagerTabs = (ViewPagerTabs) findViewById(R.id.network_monitor_pager_tabs);
      pagerTabs.addTabLabels(
          R.string.network_monitor_peer_list_title, R.string.network_monitor_block_list_title);

      final PagerAdapter pagerAdapter = new PagerAdapter(fm);

      pager.setAdapter(pagerAdapter);
      pager.setOnPageChangeListener(pagerTabs);
      pager.setPageMargin(2);
      pager.setPageMarginDrawable(R.color.bg_less_bright);

      peerListFragment = new PeerListFragment();
      blockListFragment = new BlockListFragment();
    } else {
      peerListFragment = (PeerListFragment) fm.findFragmentById(R.id.peer_list_fragment);
      blockListFragment = (BlockListFragment) fm.findFragmentById(R.id.block_list_fragment);
    }
  }
예제 #3
0
  /* (non-Javadoc)
   * @see org.chaseme.activities.helpers.SuperUI#onCreate(android.os.Bundle)
   */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_flight);

    fragmentManager = getSupportFragmentManager();
    // modeInfoPanel = fragmentManager.findFragmentById(R.id.modeInfoPanel);
    failsafeTextView = findViewById(R.id.failsafeTextView);

    // Load the activity fragments
    Fragment modeRtl = fragmentManager.findFragmentById(R.id.modeInfoPanel);
    if (modeRtl == null) {
      modeRtl = new ModeRTLFragment();
      fragmentManager.beginTransaction().add(R.id.modeInfoPanel, modeRtl).commit();
    }

    mapFragment = fragmentManager.findFragmentById(R.id.mapFragment);
    if (mapFragment == null) {
      mapFragment = new FlightMapFragment();
      fragmentManager.beginTransaction().add(R.id.mapFragment, mapFragment).commit();
    }

    Fragment telemetryFragment = fragmentManager.findFragmentById(R.id.telemetryFragment);
    if (telemetryFragment == null) {
      telemetryFragment = new TelemetryFragment();
      fragmentManager.beginTransaction().add(R.id.telemetryFragment, telemetryFragment).commit();
    }

    Fragment editorTools = fragmentManager.findFragmentById(R.id.editorToolsFragment);
    if (editorTools == null) {
      editorTools = new FlightActionsFragment();
      fragmentManager.beginTransaction().add(R.id.editorToolsFragment, editorTools).commit();
    }
  }
  @Override
  public void onCreate(Bundle savedInstanceState, Activity activity) {
    super.onCreate(savedInstanceState, activity);

    BaseActionBarActivity abActivity = (BaseActionBarActivity) activity;
    FragmentManager manager = abActivity.getSupportFragmentManager();

    poiFragment = (PointOfInterestFragmentWithMap) manager.findFragmentById(R.id.poi_frag);
    list = (BaseFragment) manager.findFragmentById(R.id.list);

    // When the activity is route_id loaded, we must wait for position
    // acquisition. When my location is acquired, animate in the poi list
    // and then the poi detail. So in route_id place, show the indeterminate
    // progress bar and hide the two other fragments.
    if (!loaded) {
      abActivity
          .getSupportFragmentManager()
          .beginTransaction()
          .hide(list)
          .hide(poiFragment)
          .commit();
      abActivity.findViewById(R.id.progress).setVisibility(View.VISIBLE);
    }

    // only show the poi detail container. This containers serves to occupy
    // space when the poi list is animated in.
    else {
      View v = abActivity.findViewById(R.id.poicontainer);
      v.setVisibility(View.VISIBLE);
      abActivity.findViewById(R.id.progress).setVisibility(View.GONE);
    }
  }
예제 #5
0
 /** Get references to existing fragments if the activity was restarted. */
 private void findFragments() {
   FragmentManager fragmentManager = getSupportFragmentManager();
   mMessageListFragment =
       (MessageListFragment) fragmentManager.findFragmentById(R.id.message_list_container);
   mMessageViewFragment =
       (MessageViewFragment) fragmentManager.findFragmentById(R.id.message_view_container);
 }
  // ****************************************************************
  // * Constructors
  // ****************************************************************
  public GroupCreateActivityViewHolder(
      Context context, IFragmentController fragmentController, View view) {
    super(context, fragmentController, view);
    try {
      AppCompatActivity activity = (AppCompatActivity) context;

      Toolbar toolbar = (Toolbar) view.findViewById(R.id.toolbar);
      activity.setSupportActionBar(toolbar);
      final ActionBar actionBar = activity.getSupportActionBar();
      actionBar.setHomeAsUpIndicator(R.drawable.ic_back);
      actionBar.setDisplayHomeAsUpEnabled(true);
      actionBar.setDisplayShowTitleEnabled(false);
      fragmentManager = activity.getSupportFragmentManager();
      groupCreateFragment =
          (GroupCreateFragment) fragmentManager.findFragmentById(R.id.groupCreateFragment);
      groupCreateChoosePrivacyFragment =
          (GroupCreateChoosePrivacyFragment)
              fragmentManager.findFragmentById(R.id.groupCreateChoosePrivacyFragment);
      groupCreateChooseIconFragment =
          (GroupCreateChooseIconFragment)
              fragmentManager.findFragmentById(R.id.groupCreateChooseIconFragment);
      progressBar = (RelativeLayout) view.findViewById(R.id.progressBar);

      title = (TextView) view.findViewById(R.id.toolbarTitle);
      initialize(context);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
예제 #7
0
 public ActionBarDrawerToggle getDrawerToggle() {
   if (mFragmentManager != null
       && mFragmentManager.findFragmentById(R.id.navigation_drawer) != null) {
     return ((NavigationDrawerFragment) mFragmentManager.findFragmentById(R.id.navigation_drawer))
         .mDrawerToggle;
   } else {
     return null;
   }
 }
예제 #8
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    // support version so that older versions can use
    FragmentManager manager = getSupportFragmentManager();
    listFragment = (PresidentListFragment) manager.findFragmentById(R.id.listFragment);
    detailFragment = (PresidentDetailFragment) manager.findFragmentById(R.id.detailFragment);
  }
  @Override
  protected void onCreate(Bundle arg0) {
    super.onCreate(arg0);
    this.setContentView(R.layout.topiclist_activity);
    PullToRefreshAttacher.Options options = new PullToRefreshAttacher.Options();
    options.refreshScrollDistance = 0.3f;
    options.refreshOnUp = true;
    mPullToRefreshAttacher = PullToRefreshAttacher.get(this, options);

    if (ActivityUtil.isNotLessThan_4_0()) setNfcCallBack();

    if (null == findViewById(R.id.item_detail_container)) {
      dualScreen = false;
    }
    FragmentManager fm = getSupportFragmentManager();
    Fragment f1 = fm.findFragmentById(R.id.item_list);
    if (f1 == null) {
      f1 = new TopiclistContainer();
      Bundle args = new Bundle(); // (getIntent().getExtras());
      if (null != getIntent().getExtras()) {
        args.putAll(getIntent().getExtras());
      }
      args.putString("url", getIntent().getDataString());
      f1.setArguments(args);
      FragmentTransaction ft = fm.beginTransaction().add(R.id.item_list, f1);
      // .add(R.id.item_detail_container, f);
      ft.commit();
    }
    Fragment f2 = fm.findFragmentById(R.id.item_detail_container);
    if (null == f2) {
      f1.setHasOptionsMenu(true);
    } else if (!dualScreen) {
      this.setTitle(R.string.app_name);
      fm.beginTransaction().remove(f2).commit();
      f1.setHasOptionsMenu(true);
    } else {
      f1.setHasOptionsMenu(false);
      f2.setHasOptionsMenu(true);
    }

    int fid = getIntent().getIntExtra("fid", 0);
    if (fid != 0) {
      String boardName = BoardHolder.boardNameMap.get(fid);
      if (null != boardName) {
        strs[0] = boardName;
      }
    }
    int favor = getIntent().getIntExtra("favor", 0);
    int authorid = getIntent().getIntExtra("authorid", 0);
    if (favor == 0 && authorid == 0) {
      setNavigation();
    } else {
      flags = ThemeManager.ACTION_BAR_FLAG;
    }
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Log.d(TAG, "onCreate");

    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    setSupportProgressBarIndeterminateVisibility(false);
    getSupportActionBar().setDisplayShowTitleEnabled(false);
    setContentView(R.layout.activity_multipane);

    // FragmentManager.enableDebugLogging(true);

    if (savedInstanceState != null) executeState(savedInstanceState);
    else executeDefaultInstanceState();

    ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayShowTitleEnabled(false);
    createSearchModeCustomView(actionBar);

    mResizeButton.setOnClickListener(this);

    FragmentManager fm = getSupportFragmentManager();
    FragmentTransaction t = fm.beginTransaction();

    mWorkerFragment = (CombinedWorkerFragment) fm.findFragmentByTag(CombinedWorkerFragment.TAG);
    if (mWorkerFragment == null) {
      mWorkerFragment = new CombinedWorkerFragment();
      t.add(mWorkerFragment, CombinedWorkerFragment.TAG);
    }

    mListFragment = (POIsListFragment) fm.findFragmentById(R.id.list_layout);
    if (mListFragment == null) {
      mListFragment = POIsListFragment.newInstance(false, true);
      t.add(R.id.list_layout, mListFragment, POIsListFragment.TAG);
    }

    mMapFragment = (POIsMapsforgeFragment) fm.findFragmentById(R.id.map_layout);
    if (mMapFragment == null) {
      mMapFragment = POIsMapsforgeFragment.newInstance(false, true);
      t.add(R.id.map_layout, mMapFragment, POIsMapsforgeFragment.TAG);
    }

    mDetailFragment = (POIDetailFragment) fm.findFragmentById(R.id.detail_layout);
    if (mDetailFragment == null) {
      mDetailFragment = POIDetailFragment.newInstance();
      t.add(R.id.detail_layout, mDetailFragment);
    }

    t.commit();
  }
예제 #11
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.dashboard_main);

    uiHelper = new UiLifecycleHelper(this, callback);
    uiHelper.onCreate(savedInstanceState);

    FragmentManager fm = getSupportFragmentManager();
    fragments[FEED] = fm.findFragmentById(R.id.feedFragment);
    fragments[SELECTION] = fm.findFragmentById(R.id.selectionFragment);

    showFragment(FEED, false);
  }
예제 #12
0
  @Override
  public void onBackStackChanged() {
    FragmentManager fragmentManager = getSupportFragmentManager();
    mMessageListFragment =
        (MessageListFragment) fragmentManager.findFragmentById(R.id.message_list_container);
    mMessageViewFragment =
        (MessageViewFragment) fragmentManager.findFragmentById(R.id.message_view_container);

    if (mDisplayMode == DisplayMode.SPLIT_VIEW) {
      showMessageViewPlaceHolder();
    }

    configureMenu(mMenu);
  }
예제 #13
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.page_item);

    Intent intent = getIntent();
    PageItem item = (PageItem) intent.getSerializableExtra("pageitem");

    FragmentManager fm = getSupportFragmentManager();
    ItemInfoFragment itf = (ItemInfoFragment) fm.findFragmentById(R.id.page_item);
    itf.fillView(item);

    CommentListFragment clf = (CommentListFragment) fm.findFragmentById(R.id.comment_list);
    clf.loadData(IHackernewsApi.API_POST_INFO + item.id);
  }
예제 #14
0
  @Override
  public void onBackPressed() {
    boolean handled = false;
    try {
      FragmentManager fm = getSupportFragmentManager();
      Fragment frag = fm.findFragmentById(R.id.fragment_content);
      if (!(frag instanceof FragUtils.BackPressedHandler)) {
        Log.d(TAG, "frag type was: " + (frag == null ? "null" : frag.getClass().getSimpleName()));
        return;
      }

      if (!frag.isVisible()) {
        Log.d(TAG, "frag was not visible!");
        return;
      }

      handled = ((FragUtils.BackPressedHandler) frag).handleBackPressed();
      //      Log.w(TAG, "handleBackPressed returned: " + handled);
    } catch (Exception e) {
      Log.e(TAG, "Could not check onBackPressed", e);
    } finally {
      if (!handled) {
        super.onBackPressed();
      }
    }
  }
 @Override
 protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   setContentView(R.layout.activity_add_color);
   Toolbar mToolbar = (Toolbar) findViewById(R.id.toolbar);
   TextView tite = (TextView) findViewById(R.id.title);
   tite.setText(R.string.title_activity_add_color);
   setSupportActionBar(mToolbar);
   final ActionBar ab = getSupportActionBar();
   ab.setHomeAsUpIndicator(R.drawable.ic_arrow_back_white_24dp);
   ab.setDisplayHomeAsUpEnabled(true);
   FragmentManager fm = getSupportFragmentManager();
   Fragment fragment = fm.findFragmentById(R.id.container);
   if (fragment == null) {
     fragment = AddColorFragment.newInstance();
     fm.beginTransaction().add(R.id.container, fragment).commit();
   }
   FloatingActionButton floatingActionButton = (FloatingActionButton) findViewById(R.id.fab);
   floatingActionButton.setOnClickListener(
       new View.OnClickListener() {
         @Override
         public void onClick(View v) {
           finish();
         }
       });
 }
예제 #16
0
 @Override
 public void onBackPressed() {
   DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
   String attachedFragment = fragmentManager.findFragmentById(R.id.container).getTag();
   if (drawer.isDrawerOpen(GravityCompat.START)) {
     drawer.closeDrawer(GravityCompat.START);
   } else {
     switch (attachedFragment) {
       case Constants.FRAGMENT_NOTE:
       case Constants.FRAGMENT_TRASH_NOTE:
         if (textToFind.length() == 0) attachFragment(Constants.FRAGMENT_LIST);
         else attachFragment(Constants.FRAGMENT_SEARCH);
         break;
       case Constants.FRAGMENT_SEARCH:
         attachFragment(Constants.FRAGMENT_LIST);
         break;
       case Constants.FRAGMENT_LIST:
         if (!exit) {
           exit = true;
           handler.postDelayed(exitRunnable, 5000);
           Utils.showToast(this, getString(R.string.press_back_button_again_to_exit));
         } else {
           // Exit flag reset and canceling exit runnable in onStop method to handle home button
           // presses
           super.onBackPressed();
         }
         break;
     }
   }
 }
예제 #17
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {

    ((FDroidApp) getApplication()).applyTheme(this);
    super.onCreate(savedInstanceState);

    FragmentManager fm = getSupportFragmentManager();
    if (fm.findFragmentById(android.R.id.content) == null) {
      // Need to set a dummy view (which will get overridden by the fragment manager
      // below) so that we can call setContentView(). This is a work around for
      // a (bug?) thing in 3.0, 3.1 which requires setContentView to be invoked before
      // the actionbar is played with:
      // http://blog.perpetumdesign.com/2011/08/strange-case-of-dr-action-and-mr-bar.html
      if (Build.VERSION.SDK_INT >= 11 && Build.VERSION.SDK_INT <= 13) {
        setContentView(new LinearLayout(this));
      }

      PreferencesFragment preferencesFragment = new PreferencesFragment();
      fm.beginTransaction().add(android.R.id.content, preferencesFragment).commit();
    }

    // Actionbar cannot be accessed until after setContentView (on 3.0 and 3.1 devices)
    // see: http://blog.perpetumdesign.com/2011/08/strange-case-of-dr-action-and-mr-bar.html
    // for reason why.
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
  }
예제 #18
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {

    // Hide the window title.
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    // Hide the status bar.
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_fragment);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
      android.app.FragmentManager manager = getFragmentManager();
      android.app.Fragment fragment = manager.findFragmentById(R.id.fragmentContainer);
      if (fragment == null) {
        fragment = Camera2Fragment.newInstance();
      }
      manager.beginTransaction().add(R.id.fragmentContainer, fragment).commit();
    } else {
      FragmentManager manager = getSupportFragmentManager();
      Fragment fragment = manager.findFragmentById(R.id.fragmentContainer);
      if (fragment == null) {
        fragment = new CameraFragment();
      }
      manager.beginTransaction().add(R.id.fragmentContainer, fragment).commit();
    }
  }
예제 #19
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    IS_TABLET = isTablet();
    // AlexSt: 2 layouts below are identical. What is the point?
    if (IS_TABLET) {
      setContentView(R.layout.activity_main_tablet);
    } else {
      setContentView(R.layout.activity_main);
    }

    messageReciever = new MessageReciever();
    IntentFilter filter = new IntentFilter(MESSAGE_EVENT);
    LocalBroadcastManager.getInstance(this).registerReceiver(messageReciever, filter);

    FragmentManager fragmentManager = getSupportFragmentManager();

    navigationDrawerFragment =
        (NavigationDrawerFragment) fragmentManager.findFragmentById(R.id.navigation_drawer);
    title = getTitle();

    // Set up the drawer.
    navigationDrawerFragment.setUp(
        R.id.navigation_drawer, (DrawerLayout) findViewById(R.id.drawer_layout));

    // AlexSt: in tablet mode when changing orientation from landscape to portrait
    // prevent detail fragment from being recreated as only list of books should be available
    // in portrait mode
    if (IS_TABLET && savedInstanceState != null && findViewById(R.id.right_container) == null) {
      Fragment bookDetailsFragment =
          fragmentManager.findFragmentByTag(BookDetail.class.getSimpleName());
      if (bookDetailsFragment != null)
        fragmentManager.beginTransaction().remove(bookDetailsFragment).commit();
    }
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    setContentView(R.layout.panes_layout);

    panesLayout = (PanesLayout) findViewById(R.id.panes);
    panesLayout.setOnIndexChangedListener(this);

    if (savedInstanceState != null) {
      int[] panesType = savedInstanceState.getIntArray("PanesLayout_panesType");
      boolean[] panesFocused = savedInstanceState.getBooleanArray("PanesLayout_panesFocused");
      int currentIndex = savedInstanceState.getInt("PanesLayout_currentIndex");
      for (int i = 0; i < panesType.length; i++) {
        panesLayout.addPane(panesType[i], panesFocused[i]);
      }
      panesLayout.setIndex(currentIndex);
    }

    if (savedInstanceState != null) {
      FragmentManager fm = getSupportFragmentManager();

      for (int index = 0; index < panesLayout.getNumPanes(); index++) {
        int id = panesLayout.getPane(index).getInnerId();
        Fragment f = fm.findFragmentById(id);

        fragmentStack.add(f);
        updateFragment(f);
      }
    }
  }
예제 #21
0
  /** This test simulates a user submitting an empty form during registration. */
  @MediumTest
  public void testAttemptRegister_Fail() {
    Fragment currentFragment;

    // create a fake email in the sharedPreference, which
    // should be created in LoginActivity
    Utils.putPreference(getActivity(), Utils.PREFS_ACCOUNT_KEY, randomString(10) + "@anytaxi.hk");

    // create a new registration form
    currentFragment = rFragmentManager.findFragmentById(R.id.register_fragment_container);

    displayFragment(currentFragment, new Register_FormFragment(), true);

    EditText rField_FirstName = (EditText) getActivity().findViewById(R.id.register_first_name);
    EditText rField_LastName = (EditText) getActivity().findViewById(R.id.register_last_name);
    EditText rField_Phone = (EditText) getActivity().findViewById(R.id.register_phone);

    Button rConfirmBtn = (Button) getActivity().findViewById(R.id.register_confirm_btn);

    // simulate a user submitting the form with empty inputs
    rConfirmBtn.performClick();

    // errors should have been set for all fields
    assertNotNull("No error is shown in First Name.", rField_FirstName.getError());
    assertNotNull("No error is shown in Last Name.", rField_LastName.getError());
    assertNotNull("No error is shown in Phone.", rField_Phone.getError());

    // no other activity will start
    assertNull("A unintended activity has been started.", getStartedActivityIntent());
  }
  private void selectMenuSection(int position) {
    Section section = menuAdapter.getItem(position);
    if (section != currentSection) {
      // Switch to new section
      FragmentManager fm = getSupportFragmentManager();
      FragmentTransaction ft = fm.beginTransaction();
      Fragment f = fm.findFragmentById(R.id.content);
      if (f != null) {
        if (currentSection.shouldKeep()) {
          ft.detach(f);
        } else {
          ft.remove(f);
        }
      }
      String fragmentClassName = section.getFragmentClassName();
      if (section.shouldKeep() && ((f = fm.findFragmentByTag(fragmentClassName)) != null)) {
        ft.attach(f);
      } else {
        f = Fragment.instantiate(MainActivity.this, fragmentClassName);
        ft.add(R.id.content, f, fragmentClassName);
      }
      ft.commit();

      currentSection = section;
      updateActionBar();
      menuAdapter.notifyDataSetChanged();
    }
  }
예제 #23
0
 protected void popCommentDetail() {
   FragmentManager fm = getSupportFragmentManager();
   CommentFragment f = (CommentFragment) fm.findFragmentById(R.id.commentDetail);
   if (f == null) {
     fm.popBackStack();
   }
 }
예제 #24
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    createMenuDrawer(R.layout.comments);

    ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayShowTitleEnabled(true);
    setTitle(getString(R.string.tab_comments));

    Bundle extras = getIntent().getExtras();
    if (extras != null) {
      fromNotification = extras.getBoolean("fromNotification");
      if (fromNotification) {
        try {
          WordPress.currentBlog = new Blog(extras.getInt("id"));
        } catch (Exception e) {
          Toast.makeText(this, getResources().getText(R.string.blog_not_found), Toast.LENGTH_SHORT)
              .show();
          finish();
        }
      }
    }

    FragmentManager fm = getSupportFragmentManager();
    fm.addOnBackStackChangedListener(mOnBackStackChangedListener);
    commentList = (CommentsListFragment) fm.findFragmentById(R.id.commentList);

    WordPress.currentComment = null;

    attemptToSelectComment();
    if (fromNotification) commentList.refreshComments(false, false, false);
  }
예제 #25
0
  public void onItemSelected(long id) {
    if (findViewById(R.id.details) == null) {
      Intent i = new Intent(this, DetailForm.class);

      i.putExtra(ID_EXTRA, String.valueOf(id));
      startActivity(i);
    } else {
      FragmentManager fragMgr = getSupportFragmentManager();
      DetailFragment details = (DetailFragment) fragMgr.findFragmentById(R.id.details);

      if (details == null) {
        details = DetailFragment.newInstance(id);

        FragmentTransaction xaction = fragMgr.beginTransaction();

        xaction
            .add(R.id.details, details)
            .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
            .addToBackStack(null)
            .commit();
      } else {
        details.loadItem(String.valueOf(id));
      }
    }
  }
예제 #26
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main_screen);

    InternalStorageHelper isHelper = new InternalStorageHelper(getApplicationContext());
    SQLiteDatabase readableDatabase = isHelper.getReadableDatabase();

    Cursor queryCursor = isHelper.select(readableDatabase);
    mAnonUser = (queryCursor.getCount() == 0);
    if (!mAnonUser) {
      queryCursor.moveToFirst();
      mUserInfo = new Bundle();
      mUserInfo.putString("email", queryCursor.getString(0));
      mUserInfo.putString("password", queryCursor.getString(1));
      mUserInfo.putLong("externalId", queryCursor.getLong(2));
    }

    queryCursor.close();
    readableDatabase.close();
    isHelper.close();

    FragmentManager fragmentManager = getSupportFragmentManager();
    fragmentManager.beginTransaction().replace(R.id.main_content, new MainFragment()).commit();

    mDrawerMenuFragment =
        (DrawerMenuFragment) fragmentManager.findFragmentById(R.id.navigation_drawer);
    mDrawerMenuFragment.setUp(R.id.navigation_drawer, (DrawerLayout) findViewById(R.id.MainScreen));
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.base_toolbar_activity);

    // check if launch from notification
    if (getIntent() != null
        && getIntent().getBooleanExtra(INTENT_EXTRA_LAUNCH_NOTIFICATION, false)) {
      Passcode passcode = new Passcode(getApplicationContext());
      if (passcode.hasPasscode()) {
        Intent intent = new Intent(this, PasscodeActivity.class);
        // set action and data
        intent.setAction(PasscodeActivity.INTENT_REQUEST_PASSWORD);
        intent.putExtra(
            PasscodeActivity.INTENT_MESSAGE_TEXT, getString(R.string.enter_your_passcode));
        // start activity
        startActivityForResult(intent, INTENT_REQUEST_PASSCODE);
      }
    }
    // set actionbar
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    // set fragment and fragment manager
    FragmentManager fm = getSupportFragmentManager();
    listFragment = new RecurringTransactionListFragment();
    // attach fragment on activity
    if (fm.findFragmentById(R.id.content) == null) {
      fm.beginTransaction().add(R.id.content, listFragment, FRAGMENTTAG).commit();
    }
  }
  private void addOrUpdateChildFragments() {
    showLoadingView(false);

    final Bundle arguments = new Bundle();
    // TODO? arguments.putString(ARG_USER_ID,
    //        getUserId()); //Obtained in the super class.
    arguments.putString(ItemFragment.ARG_ITEM_ID, getItemId());

    // Add, or update, the nested child fragments.
    // This can only be done programmatically, not in the layout XML.
    // See http://developer.android.com/about/versions/android-4.2.html#NestedFragments

    final FragmentManager fragmentManager = getChildFragmentManager();
    SubjectFragment fragmentSubject =
        (SubjectFragment) fragmentManager.findFragmentById(R.id.child_fragment_subject);
    if (fragmentSubject == null) {
      fragmentSubject = new SubjectFragment();
      fragmentSubject.setArguments(arguments);
      fragmentManager
          .beginTransaction()
          .replace(R.id.child_fragment_subject, fragmentSubject)
          .commit();
    } else {
      // TODO: Is there some more standard method to do this,
      // to trigger the Fragments' onCreate()?
      fragmentSubject.setItemId(getItemId());
      fragmentSubject.update();
    }

    // Add extra details or links.
    SubjectExtrasFragment fragmentQuestion =
        (SubjectExtrasFragment)
            fragmentManager.findFragmentById(R.id.child_fragment_subject_extras);
    if (fragmentQuestion == null) {
      fragmentQuestion = new SubjectExtrasFragment();
      fragmentQuestion.setArguments(arguments);
      fragmentManager
          .beginTransaction()
          .replace(R.id.child_fragment_subject_extras, fragmentQuestion)
          .commit();
    } else {
      // TODO: Is there some more standard method to do this,
      // to trigger the Fragments' onCreate()?
      fragmentQuestion.setItemId(getItemId());
      fragmentQuestion.update();
    }
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    UIUtils.tryTranslateHttpIntent(this);
    BeamUtils.tryUpdateIntentFromBeam(this);

    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_sessions_sandbox);

    final FragmentManager fm = getSupportFragmentManager();
    mTracksDropdownFragment =
        (TracksDropdownFragment) fm.findFragmentById(R.id.fragment_tracks_dropdown);

    mSlidingPaneLayout = (SlidingPaneLayout) findViewById(R.id.sliding_pane_layout);

    // Offset the left pane by its full width and left margin when collapsed
    // (ViewPager-like presentation)
    mSlidingPaneLayout.setParallaxDistance(
        getResources().getDimensionPixelSize(R.dimen.sliding_pane_width)
            + getResources().getDimensionPixelSize(R.dimen.multipane_padding));
    mSlidingPaneLayout.setSliderFadeColor(
        getResources().getColor(R.color.sliding_pane_content_fade));

    routeIntent(getIntent(), savedInstanceState != null);

    if (savedInstanceState != null) {
      if (mFullUI) {
        int viewType = savedInstanceState.getInt(STATE_VIEW_TYPE);
        getSupportActionBar().setSelectedNavigationItem(viewType);
      }

      mDetailFragment = fm.findFragmentById(R.id.fragment_container_detail);
      updateDetailBackground();
    }

    // This flag prevents onTabSelected from triggering extra master pane reloads
    // unless it's actually being triggered by the user (and not automatically by
    // the system)
    mInitialTabSelect = false;

    mImageLoader =
        new ImageLoader(this, R.drawable.person_image_empty)
            .setMaxImageSize(getResources().getDimensionPixelSize(R.dimen.speaker_image_size))
            .setFadeInImage(UIUtils.hasHoneycombMR1());

    EasyTracker.getInstance().setContext(this);
  }
예제 #30
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Log.v(
        TAG,
        getClass().getSimpleName()
            + ".onCreate ("
            + hashCode()
            + "): "
            + (savedInstanceState != null));

    ApiCompatUtil compatUtil = ApiCompatUtil.getInstance();
    compatUtil.requestWindowFeatures(this);
    setContentView(R.layout.prime);
    compatUtil.setWindowFeatures(this);

    compatUtil.setupActionBar(this);

    int curTab = DEFAULT_TAB;

    if (savedInstanceState != null) {
      Bundle fragData = savedInstanceState.getBundle("fragData");
      if (fragData != null) {
        Log.d(TAG, "MainActivity.onCreate: got fragData!");
        for (String key : fragData.keySet()) {
          Log.d(TAG, "  fragData key: " + key);
          if (!m_fragData.containsKey(key)) m_fragData.putBundle(key, fragData.getBundle(key));
        }
      }

      curTab = savedInstanceState.getInt(PrefKey.opentab.name(), DEFAULT_TAB);
    }

    boolean upgraded = false;
    if (savedInstanceState != null) {
      //      setCurrentTab(savedInstanceState.getInt(PrefKey.opentab.name(), -1));
    } else {
      Resources resources = getResources();
      SharedPreferences p = StaticUtils.getApplicationPreferences(this);
      upgraded = StaticUtils.checkUpgrade(this);
      if (!readInstanceState(this)) setInitialState();
      if (PrefKey.sync_on_open.getBoolean(p, resources)) {
        WeaveAccountInfo loginInfo = StaticUtils.getLoginInfo(this);
        if (upgraded || loginInfo == null) {
          StaticUtils.requestSync(this, m_handler);
        }
      }
    }

    FragmentManager fm = getSupportFragmentManager();
    // You can find Fragments just like you would with a View by using FragmentManager.
    Fragment fragment = fm.findFragmentById(R.id.fragment_content);

    // If we are using activity_fragment_xml.xml then this the fragment will not be null, otherwise
    // it will be.
    if (fragment == null) {
      setMyFragment(new MiscListFragment(), false);
    }
  }