/**
   * Callback method from {@link PaperListFragment.Callbacks} indicating that the item with the
   * given ID was selected.
   */
  @Override
  public void onItemSelected(String id) {

    noteId = id;
    if (mTwoPane) {

      // In two-pane mode, show the detail view in this activity by
      // adding or replacing the detail fragment using a
      // fragment transaction.
      Bundle arguments = new Bundle();
      arguments.putString(PaperDetailFragment.ARG_ITEM_ID, id);
      PaperDetailFragment fragment = new PaperDetailFragment();
      fragment.setArguments(arguments);
      FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
      ft.replace(R.id.note_detail_container, fragment);

      if (getIntent().getAction().equals(Intent.ACTION_VIEW)) ft.addToBackStack(null);

      ft.commit();

    } else {
      // In single-pane mode, simply start the detail activity
      // for the selected item ID.

      Intent detailIntent = new Intent(this, PaperDetailActivity.class);
      detailIntent.putExtra(PaperDetailFragment.ARG_ITEM_ID, id);
      startActivityForResult(detailIntent, DETAIL_NOTE);
    }
  }
Exemple #2
0
 public void commit(FragmentTransaction ft) {
   if (FRAG_ALLOW_LOSS_STATE == (FRAG_ALLOW_LOSS_STATE & mFlag)) {
     ft.commitAllowingStateLoss();
   } else {
     ft.commit();
   }
 }
Exemple #3
0
  void showDetails(int index) {
    mCurCheckPosition = index;

    Log.d("HabrQA", "TitleFragment requests qestion with ID: " + questionsList.get(index).getId());

    if (mDualPane) {
      getListView().setItemChecked(index, true);

      DetailsFragment details =
          (DetailsFragment) getFragmentManager().findFragmentById(R.id.details);
      if (details == null /*|| details.getShownIndex() != index*/) {
        details =
            DetailsFragment.newInstance(
                questionsList.get(index).getId(),
                questionsList.get(index).getTitle(),
                questionsList.get(index).getDescription(),
                questionsList.get(index).getUrl().toString());

        FragmentTransaction ft = getFragmentManager().beginTransaction();
        ft.replace(R.id.details, details);
        ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
        ft.commit();
      }

    } else {
      Intent intent = new Intent();
      intent.setClass(getActivity(), DetailsActivity.class);
      //			intent.putExtra("index", index);
      intent.putExtra("id", questionsList.get(index).getId());
      intent.putExtra("title", questionsList.get(index).getTitle());
      intent.putExtra("data", questionsList.get(index).getDescription());
      intent.putExtra("link", questionsList.get(index).getUrl().toString());
      startActivity(intent);
    }
  }
  private void displayView(int position) {

    String title = getString(R.string.app_name);
    FragmentManager fragmentManager = getSupportFragmentManager();
    FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
    switch (position) {
      case 0:
        fragment = new HomeFragment();
        title = getString(R.string.title_home);
        fragmentTransaction.replace(R.id.content_frame, fragment);
        break;
      case 1:
        //                fragment = new FriendsFragment();
        //                title = getString(R.string.title_friends);
        fragmentTransaction.remove(fragment);
        break;
      case 2:
        //                fragment = new MessagesFragment();
        //                title = getString(R.string.title_messages);
        break;
      default:
        break;
    }

    if (fragment != null) {

      fragmentTransaction.commit();

      // set the toolbar title
      getSupportActionBar().setTitle(title);
    }
  }
 public void onKeyboardShow() {
   Log.i("KeyboardFragment", "Showing keyboard");
   FragmentManager fm = getFragmentManager();
   FragmentTransaction ft = fm.beginTransaction();
   ft.show(this);
   ft.commit();
 }
 // changing manually to skip adding to back stack
 @Override
 public void paymentSuccessful() {
   FragmentTransaction ft = fm.beginTransaction();
   Fragment mFragement = SherlockFragment.instantiate(this, ServerUpload.class.getName(), null);
   ft.replace(R.id.layout_container, mFragement, "SERVER_UPLOAD");
   ft.commit();
 }
  /** {@inheritDoc} */
  @Override
  public void openActivityOrFragment(final Intent intent) {
    final PackageManager pm = getPackageManager();
    List<ResolveInfo> resolveInfoList =
        pm.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY);
    for (ResolveInfo resolveInfo : resolveInfoList) {
      final FragmentReplaceInfo fri =
          onSubstituteFragmentForActivityLaunch(resolveInfo.activityInfo.name);
      if (fri != null) {
        final Bundle arguments = intentToFragmentArguments(intent);
        final FragmentManager fm = getSupportFragmentManager();

        try {
          Fragment fragment = (Fragment) fri.getFragmentClass().newInstance();
          fragment.setArguments(arguments);

          FragmentTransaction ft = fm.beginTransaction();
          ft.replace(fri.getContainerId(), fragment, fri.getFragmentTag());
          onBeforeCommitReplaceFragment(fm, ft, fragment);
          ft.commit();
        } catch (InstantiationException e) {
          throw new IllegalStateException("Error creating new fragment.", e);
        } catch (IllegalAccessException e) {
          throw new IllegalStateException("Error creating new fragment.", e);
        }
        return;
      }
    }
    super.openActivityOrFragment(intent);
  }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.fragment_menu, container, false);

    // Make sure the two menu fragments are created.
    FragmentManager fm = getChildFragmentManager();
    FragmentTransaction ft = fm.beginTransaction();
    mFragment1 = fm.findFragmentByTag("f1");
    if (mFragment1 == null) {
      mFragment1 = new FragmentMenuSupport.MenuFragment();
      ft.add(mFragment1, "f1");
    }
    mFragment2 = fm.findFragmentByTag("f2");
    if (mFragment2 == null) {
      mFragment2 = new FragmentMenuSupport.Menu2Fragment();
      ft.add(mFragment2, "f2");
    }
    ft.commit();

    // Watch check box clicks.
    mCheckBox1 = (CheckBox) v.findViewById(R.id.menu1);
    mCheckBox1.setOnClickListener(mClickListener);
    mCheckBox2 = (CheckBox) v.findViewById(R.id.menu2);
    mCheckBox2.setOnClickListener(mClickListener);

    // Make sure fragments start out with correct visibility.
    updateFragmentVisibility();

    return v;
  }
Exemple #9
0
  @Override
  protected void initUI() {

    mMiddleTv.setText(getText(R.string.the_name));
    mLeftIv.setImageDrawable(getResources().getDrawable(R.drawable.ic_search));

    sendClientId();

    Date date = new Date();
    String time = mDateFormat.format(date);
    String oldTime =
        PreferencesUtils.getValueFromSPMap(
            this, PreferencesUtils.Keys.TODAY, "1", PreferencesUtils.Keys.USERINFO);

    if (!oldTime.equals(time)) {
      showSign();
    } else {
      showMakeSign();
    }

    mTransaction = getSupportFragmentManager().beginTransaction();
    mTransaction.replace(R.id.container_fragment, mFragIndex);
    mTransaction.addToBackStack(null);
    mTransaction.commit();
  }
 @Override
 protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   setContentView(R.layout.wallchanger);
   mProgressBar = (ProgressBar) findViewById(R.id.progress_progress);
   mProgressPanel = findViewById(R.id.progress_progress);
   mProgressLabel = (TextView) findViewById(R.id.progress_label);
   mProgressCancel = (Button) findViewById(R.id.progress_cancel);
   if (isGTV()) {
     showToast("Welcome, GoogleTV user!");
   }
   if (true) getActionBar().hide();
   else findViewById(R.id.title_frame).setVisibility(View.GONE);
   MediaUtils.init(getApplicationContext());
   try {
     if (!MediaUtils.writeFile("pewp", new byte[] {}, true))
       Logger.LogWarning("Unable to write to pewp");
     else Logger.LogInfo("Wrote to pewp!");
   } catch (IOException fnfe) {
     Logger.LogError("Unable to write to pewp!", fnfe);
   }
   mUseMultiplePanes = (null != findViewById(R.id.detail_container));
   if (null == savedInstanceState) {
     FragmentManager fm = getSupportFragmentManager();
     FragmentTransaction ft = fm.beginTransaction();
     mFragHash.put("list", new ProfileMakerList());
     ft.replace(R.id.list, mFragHash.get("list"), "list");
     ft.commit();
     ShowDetailFragment(new PreviewFragment(), "preview");
     ShowPreview(((BitmapDrawable) getWallpaper()).getBitmap());
   }
 }
 private void initFragment(Fragment userhomeFragment) {
   // Add the NotesFragment to the layout
   FragmentManager fragmentManager = getSupportFragmentManager();
   FragmentTransaction transaction = fragmentManager.beginTransaction();
   transaction.add(R.id.container_user_home, userhomeFragment);
   transaction.commit();
 }
 private void initFragment() {
   manager = getChildFragmentManager();
   fraTra = manager.beginTransaction();
   gril_fragment = new GirlFragment();
   fraTra.add(R.id.main_layout, gril_fragment);
   fraTra.commit();
 }
  @Override
  public void initView() {

    fm = getSupportFragmentManager();
    ft = fm.beginTransaction();
    bt_home = (Button) findViewById(R.id.bt_home);
    bt_search = (Button) findViewById(R.id.bt_search);
    bt_message = (Button) findViewById(R.id.bt_message);
    bt_user = (Button) findViewById(R.id.bt_user);
    unreadLabel = (TextView) findViewById(R.id.unread_msg_number);

    //        if (fm.findFragmentByTag("HOME") == null) {
    ft.add(R.id.rl_fragment_contanier, (HomeFragment) FragmentFactory.getFragment(HOME), "HOME")
        .add(
            R.id.rl_fragment_contanier,
            (MessageFragment) FragmentFactory.getFragment(MESSAGE),
            "MESSAGE")
        .hide((MessageFragment) FragmentFactory.getFragment(MESSAGE))
        .add(
            R.id.rl_fragment_contanier,
            (FindFragment) FragmentFactory.getFragment(LOOKINGFORTEACHER),
            "LOOKINGFORTEACHER")
        .hide((FindFragment) FragmentFactory.getFragment(LOOKINGFORTEACHER))
        .add(R.id.rl_fragment_contanier, FragmentFactory.getFragment(MYINFO), "MYINFO")
        .hide(((MyFragment) FragmentFactory.getFragment(MYINFO)));
    ft.show((HomeFragment) FragmentFactory.getFragment(HOME)).commit();
    bt_home.setCompoundDrawablesWithIntrinsicBounds(
        null, getResources().getDrawable(R.mipmap.tab_ico_home_pre), null, null);
    //        bt_home.setSelected(true);
    showLogD("==============================================");
  }
  /**
   * Replaces the entire stack with this fragment.
   *
   * @param args Arguments to be set on the fragment using {@link
   *     Fragment#setArguments(android.os.Bundle)}.
   */
  public void replace(Class<?> fragment, String tag, Bundle args) {
    Fragment first = stack.peekFirst();
    if (first != null && tag.equals(first.getTag())) {
      if (stack.size() > 1) {
        ensureTransaction();
        fragmentTransaction.setCustomAnimations(popStackEnterAnimation, popStackExitAnimation);
        while (stack.size() > 1) {
          removeFragment(stack.pollLast());
        }

        attachFragment(stack.peek(), tag);
      }
      return;
    }

    Fragment f = fragmentManager.findFragmentByTag(tag);
    if (f == null) {
      f = Fragment.instantiate(activity, fragment.getName(), args);
    }

    ensureTransaction();
    fragmentTransaction.setCustomAnimations(enterAnimation, exitAnimation);
    clear();
    attachFragment(f, tag);
    stack.add(f);

    topLevelTags.add(tag);
  }
Exemple #15
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setTitle(R.string.backpack_title);
    setContentView(R.layout.activity_script);
    setVolumeControlStream(AudioManager.STREAM_MUSIC);

    currentFragmentPosition = FRAGMENT_BACKPACK_SCRIPTS;

    if (savedInstanceState == null) {
      Bundle bundle = this.getIntent().getExtras();

      if (bundle != null) {
        currentFragmentPosition = bundle.getInt(EXTRA_FRAGMENT_POSITION, FRAGMENT_BACKPACK_SCRIPTS);
        backpackItem = bundle.getBoolean(BACKPACK_ITEM);
      }
    }

    FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
    setCurrentFragment(currentFragmentPosition);
    fragmentTransaction.commit();
    fragmentTransaction.add(R.id.script_fragment_container, currentFragment, currentFragmentTag);

    final ActionBar actionBar = getSupportActionBar();
    actionBar.setHomeButtonEnabled(true);
    actionBar.setDisplayShowTitleEnabled(true);
  }
Exemple #16
0
 private void loadFragments(String mensaje, int id) {
   FragmentManager gestorFragmentos = getSupportFragmentManager();
   gestorFragmentos.beginTransaction();
   FragmentTransaction transaccion = gestorFragmentos.beginTransaction();
   transaccion.replace(id, UnoFragment.newInstance(mensaje));
   transaccion.commit();
 }
Exemple #17
0
 public void switchTo(Class className, Bundle bundle, String tag) {
   FragmentTransaction ft = fm.beginTransaction();
   Fragment mFragement = SherlockFragment.instantiate(this, className.getName(), bundle);
   ft.replace(R.id.layout_container, mFragement, tag);
   ft.addToBackStack(null);
   ft.commit();
 }
  protected void initView() {
    setContentViewSrc(R.layout.activity_web_layout);
    webView = new WebActivityFragment();
    pb_bar = (ProgressBar) findViewById(R.id.pb_bar);
    FragmentManager fm = getSupportFragmentManager();
    FragmentTransaction ft = fm.beginTransaction();
    ft.add(R.id.fl_content, webView);
    ft.commit();

    refresh = new ImageView(this);
    RelativeLayout.LayoutParams params =
        new RelativeLayout.LayoutParams(CommonUtils.dp2px(30), CommonUtils.dp2px(30));
    params.setMargins(0, 0, CommonUtils.dp2px(10), 0);
    params.addRule(RelativeLayout.CENTER_IN_PARENT);
    refresh.setLayoutParams(params);
    if (!isUseToolbar()) addOptionsMenu(refresh);
    refresh.setBackgroundResource(R.mipmap.ic_refresh);
    refresh.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            if (isLoading) webView.stopLoading();
            else webView.refresh();
          }
        });
  }
Exemple #19
0
 // changing manually to skip adding to back stack
 @Override
 public void paypalNetworkUnavailable() {
   FragmentTransaction ft = fm.beginTransaction();
   Fragment mFragement = SherlockFragment.instantiate(this, OrderSummary.class.getName(), null);
   ft.replace(R.id.layout_container, mFragement);
   ft.commit();
 }
  public void initFragment(FragmentManager fragmentManager) {
    FragmentTransaction transaction;
    // 开启一个Fragment事务
    transaction = fragmentManager.beginTransaction();

    mainPageFragment = new MainPageFragment();
    transaction.add(R.id.content, mainPageFragment, Constant.FRAGMENTTAG[0]);

    scheduleFragment = new ScheduleFragment();
    transaction.add(R.id.content, scheduleFragment, Constant.FRAGMENTTAG[1]);

    gradesFragment = new GradesFragment();
    transaction.add(R.id.content, gradesFragment, Constant.FRAGMENTTAG[2]);

    cardfragment = new EcardFragmentImp();
    transaction.add(R.id.content, cardfragment, Constant.FRAGMENTTAG[3]);

    studyMaterialsFragment = new StudyMaterialsFragment();
    transaction.add(R.id.content, studyMaterialsFragment, Constant.FRAGMENTTAG[3]);

    findLostFragment = new FindLostFragment();
    transaction.add(R.id.content, findLostFragment, Constant.FRAGMENTTAG[4]);

    chargeFragment = new ChargeFragment();
    transaction.add(R.id.content, chargeFragment, Constant.FRAGMENTTAG[5]);

    libraryFragment = new LibFragment();
    transaction.add(R.id.content, libraryFragment, Constant.FRAGMENTTAG[6]);
    transaction.commit();
    hideFragments(transaction);
  }
 private void replaceFragment(Fragment fragment) {
   final FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
   ft.setCustomAnimations(R.anim.fragment_fade_enter, R.anim.fragment_fade_exit);
   ft.replace(R.id.content_view, fragment, fragment.getClass().getSimpleName());
   ft.addToBackStack(null);
   ft.commit();
 }
  /** {@inheritDoc} */
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_splash);

    mIsSplashEnd = false;
    mIsGcmRegistered = false;

    // Begin GCM jobs.
    if (savedInstanceState == null) {
      final FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
      ft.add(new PushRegistrationFragment(), "registration").commit();
    }

    mTimer =
        new CountDownTimer(Config.SPLASH_TIME_MILLIS, Config.SPLASH_TIME_MILLIS) {
          @Override
          public void onTick(long millisUntilFinished) {
            // do nothing
          }

          @Override
          public void onFinish() {
            mIsSplashEnd = true;
            startNextActivity();
          }
        }.start();
  }
Exemple #23
0
 @Override
 public void onCheckedChanged(RadioGroup group, int checkedId) {
   TabInfo newTab = mTabs.get("" + checkedId);
   if (mLastTab != newTab) {
     FragmentTransaction ft = mFragmentManager.beginTransaction();
     if (mLastTab != null) {
       if (mLastTab.fragment != null) {
         ft.detach(mLastTab.fragment);
       }
     }
     if (newTab != null) {
       if (newTab.fragment == null) {
         newTab.fragment =
             (BaseFragment)
                 Fragment.instantiate(group.getContext(), newTab.clss.getName(), newTab.args);
         ft.add(mContainerId, newTab.fragment, newTab.tag);
       } else {
         ft.attach(newTab.fragment);
       }
     }
     mLastTab = newTab;
     ft.commit();
     mFragmentManager.executePendingTransactions();
   }
 }
 private void initFragment() {
   FragmentManager fm = getSupportFragmentManager();
   FragmentTransaction transaction = fm.beginTransaction();
   Fragment topicFragment = new TopicFragment();
   transaction.replace(R.id.main_content, topicFragment);
   transaction.commit();
 }
 public void onKeyboardHide() {
   Log.i("KeyboardFragment", "Hiding keyboard");
   FragmentManager fm = getFragmentManager();
   FragmentTransaction ft = fm.beginTransaction();
   ft.hide(this);
   ft.commit();
 }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    HistoryFragment fragment = new HistoryFragment();
    android.support.v4.app.FragmentTransaction fragmentTransaction =
        getSupportFragmentManager().beginTransaction();
    fragmentTransaction.replace(R.id.fragment_container, fragment);
    fragmentTransaction.commit();

    toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);

    ActionBarDrawerToggle toggle =
        new ActionBarDrawerToggle(
            this,
            drawer,
            toolbar,
            R.string.navigation_drawer_open,
            R.string.navigation_drawer_close);
    drawer.setDrawerListener(toggle);
    toggle.syncState();

    navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);
  }
  /* (non-Javadoc)
   * @see uk.ac.swan.digitaltrails.fragments.SearchListFragment.OnWalkSelectedListener#onWalkSelected(uk.ac.swan.digitaltrails.components.Walk)
   */
  @Override
  public void onWalkSelected(Walk walk) {
    Log.d(TAG, "Trying to choose a walk");
    SearchDetailsFragment detailsFrag =
        (SearchDetailsFragment)
            getSupportFragmentManager().findFragmentById(R.id.search_details_fragment);
    mWalk = walk;
    if (detailsFrag != null) {
      Log.d(TAG, "In 2 pane view");
      // if available and we are in 2-pane view.
      detailsFrag.updateDetailsView(walk);
    } else {
      Log.d(TAG, "In 1 pane view");
      // if in 1 pane view
      SearchDetailsFragment newDetailsFragment = new SearchDetailsFragment();
      Bundle args = new Bundle();
      args.putParcelable(SearchDetailsFragment.ARG_POSITION, walk);
      newDetailsFragment.setArguments(args);

      FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();

      transaction.replace(R.id.fragment_container, newDetailsFragment);
      transaction.addToBackStack(null);

      transaction.commit();
    }
  }
Exemple #28
0
  @Override
  public void onTabSelected(Tab tab, FragmentTransaction ft) {

    if (tab.getPosition() == 0) {
      // Check if the fragment is already initialized
      mMapFragment = getSupportFragmentManager().findFragmentByTag("map");
      if (mMapFragment == null) {
        // If not, instantiate and add it to the activity
        mMapFragment = new ViewMapFragment_();
        ft.add(R.id.container, mMapFragment, "map");
      } else {
        // If it exists, simply attach it in order to show it
        ft.show(mMapFragment);
      }
    }
    if (tab.getPosition() == 1) {
      // Check if the fragment is already initialized
      mMapFragment = getSupportFragmentManager().findFragmentByTag("list");
      if (mListFragment == null) {
        // If not, instantiate and add it to the activity
        //	mListFragment = new RestroomListFragment_();
        ft.add(R.id.container, mListFragment, "list");
      } else {
        // If it exists, simply attach it in order to show it
        ft.show(mListFragment);
      }
    }
  }
  private void addFragment(Fragment f, int index) {
    if (f == null) return;

    Log.e("ASDF", f + ": " + index);

    clearFragments(index + 1);

    int type = 0;
    boolean focused = false;

    PaneSizer paneSizer = mPaneSizer;
    if (paneSizer != null) {
      type = paneSizer.getType(f);
      focused = paneSizer.getFocused(f);
    }

    PaneView p = panesLayout.getPane(index);
    if (p != null && p.type == type) {
    } else {
      clearFragments(index);
      p = panesLayout.addPane(type, focused);
      if (p.index != index) throw new IllegalStateException("Added pane has wrong index");
    }

    panesLayout.setIndex(index);

    FragmentManager fm = getSupportFragmentManager();
    FragmentTransaction ft = fm.beginTransaction();
    ft.replace(p.getInnerId(), f);
    ft.commit();

    fragmentStack.add(index, f);
    updateFragment(f);
  }
Exemple #30
0
 public void onTabSelected(Tab tab, FragmentTransaction ft) {
   // TODO Auto-generated method stub
   mFragment = new VaccineManager();
   // Attach fragment2.xml layout
   ft.add(android.R.id.content, mFragment);
   ft.attach(mFragment);
 }