Search in sources :

Example 6 with Fragment

use of android.support.v4.app.Fragment in project UltimateAndroid by cymcsg.

the class ViewPagerTabScrollViewActivity method onUpOrCancelMotionEvent.

@Override
public void onUpOrCancelMotionEvent(ScrollState scrollState) {
    mBaseTranslationY = 0;
    Fragment fragment = getCurrentFragment();
    if (fragment == null) {
        return;
    }
    View view = fragment.getView();
    if (view == null) {
        return;
    }
    int toolbarHeight = mToolbarView.getHeight();
    final ObservableScrollView scrollView = (ObservableScrollView) view.findViewById(R.id.scroll);
    if (scrollState == ScrollState.UP) {
        if (toolbarHeight < scrollView.getCurrentScrollY()) {
            hideToolbar();
        } else if (scrollView.getCurrentScrollY() < toolbarHeight) {
            showToolbar();
        }
    } else if (scrollState == ScrollState.DOWN) {
        if (toolbarHeight < scrollView.getCurrentScrollY()) {
            showToolbar();
        }
    }
}
Also used : ObservableScrollView(com.github.ksoichiro.android.observablescrollview.ObservableScrollView) Fragment(android.support.v4.app.Fragment) ObservableScrollView(com.github.ksoichiro.android.observablescrollview.ObservableScrollView) View(android.view.View)

Example 7 with Fragment

use of android.support.v4.app.Fragment in project UltimateAndroid by cymcsg.

the class ViewPagerTabScrollViewActivity method propagateToolbarState.

private void propagateToolbarState(boolean isShown) {
    int toolbarHeight = mToolbarView.getHeight();
    // Set scrollY for the fragments that are not created yet
    mPagerAdapter.setScrollY(isShown ? 0 : toolbarHeight);
    // Set scrollY for the active fragments
    for (int i = 0; i < mPagerAdapter.getCount(); i++) {
        // Skip current item
        if (i == mPager.getCurrentItem()) {
            continue;
        }
        // Skip destroyed or not created item
        Fragment f = mPagerAdapter.getItemAt(i);
        if (f == null) {
            continue;
        }
        ObservableScrollView scrollView = (ObservableScrollView) f.getView().findViewById(R.id.scroll);
        if (isShown) {
            // Scroll up
            if (0 < scrollView.getCurrentScrollY()) {
                scrollView.scrollTo(0, 0);
            }
        } else {
            // Scroll down (to hide padding)
            if (scrollView.getCurrentScrollY() < toolbarHeight) {
                scrollView.scrollTo(0, toolbarHeight);
            }
        }
    }
}
Also used : ObservableScrollView(com.github.ksoichiro.android.observablescrollview.ObservableScrollView) Fragment(android.support.v4.app.Fragment)

Example 8 with Fragment

use of android.support.v4.app.Fragment in project UltimateAndroid by cymcsg.

the class ViewPagerTabActivity method propagateToolbarState.

private void propagateToolbarState(boolean isShown) {
    int toolbarHeight = mToolbarView.getHeight();
    // Set scrollY for the fragments that are not created yet
    mPagerAdapter.setScrollY(isShown ? 0 : toolbarHeight);
    // Set scrollY for the active fragments
    for (int i = 0; i < mPagerAdapter.getCount(); i++) {
        // Skip current item
        if (i == mPager.getCurrentItem()) {
            continue;
        }
        // Skip destroyed or not created item
        Fragment f = mPagerAdapter.getItemAt(i);
        if (f == null) {
            continue;
        }
        View view = f.getView();
        if (view == null) {
            continue;
        }
        propagateToolbarStateForScrollView(isShown, view, toolbarHeight);
        propagateToolbarStateForListView(isShown, view, toolbarHeight);
    }
}
Also used : Fragment(android.support.v4.app.Fragment) ObservableScrollView(com.github.ksoichiro.android.observablescrollview.ObservableScrollView) View(android.view.View) ObservableListView(com.github.ksoichiro.android.observablescrollview.ObservableListView)

Example 9 with Fragment

use of android.support.v4.app.Fragment in project android-betterpickers by code-troopers.

the class ExpirationPickerDialogFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.expiration_picker_dialog, container, false);
    Button doneButton = (Button) view.findViewById(R.id.done_button);
    Button cancelButton = (Button) view.findViewById(R.id.cancel_button);
    cancelButton.setTextColor(mTextColor);
    cancelButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            dismiss();
        }
    });
    doneButton.setTextColor(mTextColor);
    doneButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            for (ExpirationPickerDialogHandler handler : mExpirationPickerDialogHandlers) {
                handler.onDialogExpirationSet(mReference, mPicker.getYear(), mPicker.getMonthOfYear());
            }
            final Activity activity = getActivity();
            final Fragment fragment = getTargetFragment();
            if (activity instanceof ExpirationPickerDialogHandler) {
                final ExpirationPickerDialogHandler act = (ExpirationPickerDialogHandler) activity;
                act.onDialogExpirationSet(mReference, mPicker.getYear(), mPicker.getMonthOfYear());
            } else if (fragment instanceof ExpirationPickerDialogHandler) {
                final ExpirationPickerDialogHandler frag = (ExpirationPickerDialogHandler) fragment;
                frag.onDialogExpirationSet(mReference, mPicker.getYear(), mPicker.getMonthOfYear());
            }
            dismiss();
        }
    });
    mPicker = (ExpirationPicker) view.findViewById(R.id.expiration_picker);
    mPicker.setSetButton(doneButton);
    mPicker.setTheme(mTheme);
    if (mMinimumYear != 0) {
        mPicker.setMinYear(mMinimumYear);
    }
    if (mMonthOfYear != -1 || mYear != 0) {
        mPicker.setExpiration(mYear, mMonthOfYear);
    }
    getDialog().getWindow().setBackgroundDrawableResource(mDialogBackgroundResId);
    return view;
}
Also used : Button(android.widget.Button) Activity(android.app.Activity) View(android.view.View) Fragment(android.support.v4.app.Fragment) DialogFragment(android.support.v4.app.DialogFragment)

Example 10 with Fragment

use of android.support.v4.app.Fragment in project android-betterpickers by code-troopers.

the class HmsPickerDialogFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.hms_picker_dialog, container, false);
    Button doneButton = (Button) view.findViewById(R.id.done_button);
    Button cancelButton = (Button) view.findViewById(R.id.cancel_button);
    cancelButton.setTextColor(mTextColor);
    cancelButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            HmsPickerDialogFragment.this.dismiss();
        }
    });
    doneButton.setTextColor(mTextColor);
    doneButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            for (HmsPickerDialogHandlerV2 handler : mHmsPickerDialogHandlerV2s) {
                handler.onDialogHmsSet(mReference, mPicker.isNegative(), mPicker.getHours(), mPicker.getMinutes(), mPicker.getSeconds());
            }
            final Activity activity = getActivity();
            final Fragment fragment = getTargetFragment();
            if (activity instanceof HmsPickerDialogHandlerV2) {
                final HmsPickerDialogHandlerV2 act = (HmsPickerDialogHandlerV2) activity;
                act.onDialogHmsSet(mReference, mPicker.isNegative(), mPicker.getHours(), mPicker.getMinutes(), mPicker.getSeconds());
            } else if (fragment instanceof HmsPickerDialogHandlerV2) {
                final HmsPickerDialogHandlerV2 frag = (HmsPickerDialogHandlerV2) fragment;
                frag.onDialogHmsSet(mReference, mPicker.isNegative(), mPicker.getHours(), mPicker.getMinutes(), mPicker.getSeconds());
            }
            dismiss();
        }
    });
    mPicker = (HmsPicker) view.findViewById(R.id.hms_picker);
    mPicker.setSetButton(doneButton);
    mPicker.setTime(mHours, mMinutes, mSeconds);
    mPicker.setTheme(mTheme);
    mPicker.setPlusMinusVisibility(mPlusMinusVisibility);
    getDialog().getWindow().setBackgroundDrawableResource(mDialogBackgroundResId);
    return view;
}
Also used : Button(android.widget.Button) Activity(android.app.Activity) View(android.view.View) Fragment(android.support.v4.app.Fragment) DialogFragment(android.support.v4.app.DialogFragment)

Aggregations

Fragment (android.support.v4.app.Fragment)617 FragmentTransaction (android.support.v4.app.FragmentTransaction)220 Bundle (android.os.Bundle)140 View (android.view.View)129 FragmentManager (android.support.v4.app.FragmentManager)115 DialogFragment (android.support.v4.app.DialogFragment)77 TextView (android.widget.TextView)55 FragmentInstruction (de.madcyph3r.example.example.FragmentInstruction)48 MaterialMenu (de.madcyph3r.materialnavigationdrawer.menu.MaterialMenu)48 MaterialItemSectionFragment (de.madcyph3r.materialnavigationdrawer.menu.item.section.MaterialItemSectionFragment)48 FragmentDummy (de.madcyph3r.example.example.FragmentDummy)43 Intent (android.content.Intent)39 ViewPager (android.support.v4.view.ViewPager)35 FragmentActivity (android.support.v4.app.FragmentActivity)34 BaseFragment (com.waz.zclient.pages.BaseFragment)29 ImageView (android.widget.ImageView)27 FragmentPagerAdapter (android.support.v4.app.FragmentPagerAdapter)25 Button (android.widget.Button)24 ArrayList (java.util.ArrayList)24 FragmentStatePagerAdapter (android.support.v4.app.FragmentStatePagerAdapter)21