Java Code Examples for android.support.v4.app.Fragment#setTargetFragment()

The following examples show how to use android.support.v4.app.Fragment#setTargetFragment() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ConfigureCallEventDialog.java    From PowerSwitch_Android with GNU General Public License v3.0 6 votes vote down vote up
@Override
        public Fragment getItem(int i) {
            Fragment fragment = null;

            switch (i) {
                case 0:
                    fragment = new ConfigureCallDialogPage1ContactsFragment();
                    break;
                case 1:
                    fragment = new ConfigureCallDialogPage2ActionsFragment();
                    break;
                case 2:
//                    fragment = new ConfigureCallDialogPage3SummaryFragment();
                    fragment.setTargetFragment(recyclerViewFragment, 0);

                    setupFragment = (ConfigurationDialogTabbedSummaryFragment) fragment;
            }

            if (fragment != null && callEventId != -1) {
                Bundle bundle = new Bundle();
                bundle.putLong(CALL_EVENT_ID_KEY, callEventId);
                fragment.setArguments(bundle);
            }

            return fragment;
        }
 
Example 2
Source File: ConfigureGatewayDialog.java    From PowerSwitch_Android with GNU General Public License v3.0 6 votes vote down vote up
@Override
public Fragment getItem(int i) {
    Fragment fragment = null;

    switch (i) {
        case 0:
            fragment = new ConfigureGatewayDialogPage1Fragment();
            fragment.setTargetFragment(targetFragment, 0);
            break;
        case 1:
            fragment = new ConfigureGatewayDialogPage2Fragment();
            fragment.setTargetFragment(targetFragment, 0);

            setupFragment = (ConfigurationDialogTabbedSummaryFragment) fragment;
            break;
    }

    if (fragment != null && gatewayId != -1) {
        Bundle bundle = new Bundle();
        bundle.putLong(GATEWAY_ID_KEY, gatewayId);
        fragment.setArguments(bundle);
    }

    return fragment;
}
 
Example 3
Source File: ConfigureSceneDialog.java    From PowerSwitch_Android with GNU General Public License v3.0 6 votes vote down vote up
@Override
public Fragment getItem(int i) {
    Fragment fragment = null;

    switch (i) {
        case 0:
            fragment = new ConfigureSceneDialogPage1NameFragment();
            break;
        case 1:
            fragment = new ConfigureSceneDialogTabbedPage2SetupFragment();
            fragment.setTargetFragment(recyclerViewFragment, 0);

            setupFragment = (ConfigurationDialogTabbedSummaryFragment) fragment;
    }

    if (fragment != null && sceneId != -1) {
        Bundle bundle = new Bundle();
        bundle.putLong(SCENE_ID_KEY, sceneId);
        fragment.setArguments(bundle);
    }

    return fragment;
}
 
Example 4
Source File: ConfigureApartmentDialog.java    From PowerSwitch_Android with GNU General Public License v3.0 6 votes vote down vote up
@Override
public Fragment getItem(int i) {
    Fragment fragment = null;

    switch (i) {
        case 0:
            fragment = new ConfigureApartmentDialogPage1NameFragment();
            fragment.setTargetFragment(recyclerViewFragment, 0);

            setupFragment = (ConfigurationDialogTabbedSummaryFragment) fragment;
            break;
    }

    if (fragment != null && apartmentId != -1) {
        Bundle bundle = new Bundle();
        bundle.putLong(APARTMENT_ID_KEY, apartmentId);
        fragment.setArguments(bundle);
    }

    return fragment;
}
 
Example 5
Source File: SlideDayTimeDialogFragment.java    From SlideDayTimePicker with Apache License 2.0 6 votes vote down vote up
@Override
public Fragment getItem(int position)
{
    switch (position)
    {
    case 0:
        Fragment dayFragment = DayFragment.newInstance(
                mTheme,
                mDayIndex,
                mIsCustomDaysArraySpecified,
                mCustomDaysArray);
        dayFragment.setTargetFragment(SlideDayTimeDialogFragment.this, 100);
        return dayFragment;
    case 1:
        Fragment timeFragment = TimeFragment.newInstance(
                mTheme,
                mCalendar.get(Calendar.HOUR_OF_DAY),
                mCalendar.get(Calendar.MINUTE),
                mIsClientSpecified24HourTime,
                mIs24HourTime);
        timeFragment.setTargetFragment(SlideDayTimeDialogFragment.this, 200);
        return timeFragment;
    }

    return null;
}
 
Example 6
Source File: ConfigureGeofenceDialog.java    From PowerSwitch_Android with GNU General Public License v3.0 5 votes vote down vote up
@Override
public Fragment getItem(int i) {
    Fragment fragment = null;

    switch (i) {
        case 0:
            fragment = new ConfigureGeofenceDialogPage1LocationFragment();
            break;
        case 1:
            fragment = new ConfigureGeofenceDialogPage2EnterActionsFragment();
            break;
        case 2:
            fragment = new ConfigureGeofenceDialogPage3ExitActionsFragment();
            break;
        case 3:
            fragment = new ConfigureGeofenceDialogPage4SummaryFragment();
            fragment.setTargetFragment(recyclerViewFragment, 0);

            summaryFragment = (ConfigurationDialogTabbedSummaryFragment) fragment;
            break;
        default:
            break;
    }

    if (fragment != null && geofenceId != -1) {
        Bundle bundle = new Bundle();
        bundle.putLong(GEOFENCE_ID_KEY, geofenceId);
        fragment.setArguments(bundle);
    }

    return fragment;
}
 
Example 7
Source File: ConfigureTimerDialog.java    From PowerSwitch_Android with GNU General Public License v3.0 5 votes vote down vote up
@Override
public Fragment getItem(int i) {
    Fragment fragment = null;

    switch (i) {
        case 0:
            fragment = new ConfigureTimerDialogPage1TimeFragment();
            break;
        case 1:
            fragment = new ConfigureTimerDialogPage2DaysFragment();
            break;
        case 2:
            fragment = new ConfigureTimerDialogPage3ActionFragment();
            break;
        case 3:
            fragment = new ConfigureTimerDialogPage4TabbedSummaryFragment();
            fragment.setTargetFragment(recyclerViewFragment, 0);
            summaryFragment = (ConfigurationDialogTabbedSummaryFragment) fragment;
    }

    if (fragment != null && timerId != -1) {
        Bundle bundle = new Bundle();
        bundle.putLong(TIMER_ID_KEY, timerId);
        fragment.setArguments(bundle);
    }

    return fragment;
}
 
Example 8
Source File: ConfigureReceiverDialog.java    From PowerSwitch_Android with GNU General Public License v3.0 5 votes vote down vote up
@Override
public Fragment getItem(int i) {
    Fragment fragment = null;

    switch (i) {
        case 0:
            fragment = new ConfigureReceiverDialogPage1NameFragment();
            break;
        case 1:
            fragment = new ConfigureReceiverDialogPage2TypeFragment();
            break;
        case 2:
            fragment = new ConfigureReceiverDialogPage3SetupFragment();
            break;
        case 3:
            fragment = new ConfigureReceiverDialogPage4TabbedSummaryFragment();
            fragment.setTargetFragment(recyclerViewFragment, 0);

            summaryFragment = (ConfigurationDialogTabbedSummaryFragment) fragment;
            break;
        default:
            break;
    }

    if (fragment != null && receiverId != -1) {
        Bundle bundle = new Bundle();
        bundle.putLong(RECEIVER_ID_KEY, receiverId);
        fragment.setArguments(bundle);
    }

    return fragment;
}
 
Example 9
Source File: ConfigureApartmentGeofenceDialog.java    From PowerSwitch_Android with GNU General Public License v3.0 5 votes vote down vote up
@Override
public Fragment getItem(int i) {
    Fragment fragment = null;

    switch (i) {
        case 0:
            fragment = new ConfigureGeofenceDialogPage1LocationFragment();
            break;
        case 1:
            fragment = new ConfigureGeofenceDialogPage2EnterActionsFragment();
            break;
        case 2:
            fragment = new ConfigureGeofenceDialogPage3ExitActionsFragment();
            break;
        case 3:
            fragment = new ConfigureGeofenceDialogPage4SummaryFragment();
            fragment.setTargetFragment(recyclerViewFragment, 0);

            summaryFragment = (ConfigurationDialogTabbedSummaryFragment) fragment;
            break;
        default:
            break;
    }

    if (fragment != null && apartmentId != -1) {
        Bundle bundle = new Bundle();
        bundle.putLong(APARTMENT_ID_KEY, apartmentId);

        if (geofenceId != -1) {
            bundle.putLong(GEOFENCE_ID_KEY, geofenceId);
        }

        fragment.setArguments(bundle);
    }

    return fragment;
}
 
Example 10
Source File: PreferenceActivity.java    From PreferenceFragment with Apache License 2.0 4 votes vote down vote up
/**
 * Start a new fragment containing a preference panel. If the preferences
 * are being displayed in multi-pane mode, the given fragment class will
 * be instantiated and placed in the appropriate pane. If running in
 * single-pane mode, a new activity will be launched in which to show the
 * fragment.
 * 
 * @param fragmentClass
 *            Full name of the class implementing the fragment.
 * @param args
 *            Any desired arguments to supply to the fragment.
 * @param titleRes
 *            Optional resource identifier of the title of this
 *            fragment.
 * @param titleText
 *            Optional text of the title of this fragment.
 * @param resultTo
 *            Optional fragment that result data should be sent to.
 *            If non-null, resultTo.onActivityResult() will be called when this
 *            preference panel is done. The launched panel must use
 *            {@link #finishPreferencePanel(Fragment, int, Intent)} when done.
 * @param resultRequestCode
 *            If resultTo is non-null, this is the caller's
 *            request code to be received with the resut.
 */
public void startPreferencePanel(String fragmentClass, Bundle args, int titleRes,
        CharSequence titleText, Fragment resultTo, int resultRequestCode) {
    if (mSinglePane) {
        startWithFragment(fragmentClass, args, resultTo, resultRequestCode, titleRes, 0);
    } else {
        Fragment f = Fragment.instantiate(this, fragmentClass, args);
        if (resultTo != null) {
            f.setTargetFragment(resultTo, resultRequestCode);
        }
        FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
        transaction.replace(R.id.prefs, f);
        if (titleRes != 0) {
            transaction.setBreadCrumbTitle(titleRes);
        } else if (titleText != null) {
            transaction.setBreadCrumbTitle(titleText);
        }
        transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
        transaction.addToBackStack(BACK_STACK_PREFS);
        transaction.commitAllowingStateLoss();
    }
}