Search in sources :

Example 11 with Fragment

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

the class NumberPickerDialogFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.number_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) {
            BigDecimal number = mPicker.getEnteredNumber();
            if (mMinNumber != null && mMaxNumber != null && (isSmaller(number) || isBigger(number))) {
                String errorText = getString(R.string.min_max_error, mMinNumber, mMaxNumber);
                mPicker.getErrorView().setText(errorText);
                mPicker.getErrorView().show();
                return;
            } else if (mMinNumber != null && isSmaller(number)) {
                String errorText = getString(R.string.min_error, mMinNumber);
                mPicker.getErrorView().setText(errorText);
                mPicker.getErrorView().show();
                return;
            } else if (mMaxNumber != null && isBigger(number)) {
                String errorText = getString(R.string.max_error, mMaxNumber);
                mPicker.getErrorView().setText(errorText);
                mPicker.getErrorView().show();
                return;
            }
            for (NumberPickerDialogHandlerV2 handler : mNumberPickerDialogHandlersV2) {
                handler.onDialogNumberSet(mReference, mPicker.getNumber(), mPicker.getDecimal(), mPicker.getIsNegative(), number);
            }
            final Activity activity = getActivity();
            final Fragment fragment = getTargetFragment();
            if (activity instanceof NumberPickerDialogHandlerV2) {
                final NumberPickerDialogHandlerV2 act = (NumberPickerDialogHandlerV2) activity;
                act.onDialogNumberSet(mReference, mPicker.getNumber(), mPicker.getDecimal(), mPicker.getIsNegative(), number);
            } else if (fragment instanceof NumberPickerDialogHandlerV2) {
                final NumberPickerDialogHandlerV2 frag = (NumberPickerDialogHandlerV2) fragment;
                frag.onDialogNumberSet(mReference, mPicker.getNumber(), mPicker.getDecimal(), mPicker.getIsNegative(), number);
            }
            dismiss();
        }
    });
    mPicker = (NumberPicker) view.findViewById(R.id.number_picker);
    mPicker.setSetButton(doneButton);
    mPicker.setTheme(mTheme);
    mPicker.setDecimalVisibility(mDecimalVisibility);
    mPicker.setPlusMinusVisibility(mPlusMinusVisibility);
    mPicker.setLabelText(mLabelText);
    if (mMinNumber != null) {
        mPicker.setMin(mMinNumber);
    }
    if (mMaxNumber != null) {
        mPicker.setMax(mMaxNumber);
    }
    mPicker.setNumber(mCurrentNumber, mCurrentDecimal, mCurrentSign);
    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) BigDecimal(java.math.BigDecimal)

Example 12 with Fragment

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

the class DatePickerBuilder method show.

/**
     * Instantiate and show the Picker
     */
public void show() {
    if (manager == null || styleResId == null) {
        Log.e("DatePickerBuilder", "setFragmentManager() and setStyleResId() must be called.");
        return;
    }
    FragmentTransaction ft = manager.beginTransaction();
    final Fragment prev = manager.findFragmentByTag("date_dialog");
    if (prev != null) {
        ft.remove(prev).commit();
        ft = manager.beginTransaction();
    }
    ft.addToBackStack(null);
    final DatePickerDialogFragment fragment = DatePickerDialogFragment.newInstance(mReference, styleResId, monthOfYear, dayOfMonth, year, yearOptional);
    if (targetFragment != null) {
        fragment.setTargetFragment(targetFragment, 0);
    }
    fragment.setDatePickerDialogHandlers(mDatePickerDialogHandlers);
    fragment.setOnDismissListener(mOnDismissListener);
    fragment.show(ft, "date_dialog");
}
Also used : FragmentTransaction(android.support.v4.app.FragmentTransaction) Fragment(android.support.v4.app.Fragment)

Example 13 with Fragment

use of android.support.v4.app.Fragment in project SimplifyReader by chentao0707.

the class ImagesContainerFragment method initializePagerViews.

@Override
public void initializePagerViews(final List<BaseEntity> categoryList) {
    if (null != categoryList && !categoryList.isEmpty()) {
        mViewPager.setOffscreenPageLimit(categoryList.size());
        mViewPager.setAdapter(new ImagesContainerPagerAdapter(getSupportFragmentManager(), categoryList));
        mSmartTabLayout.setViewPager(mViewPager);
        mSmartTabLayout.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {

            @Override
            public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
            }

            @Override
            public void onPageSelected(int position) {
                ImagesListFragment fragment = (ImagesListFragment) mViewPager.getAdapter().instantiateItem(mViewPager, position);
                fragment.onPageSelected(position, categoryList.get(position).getId());
            }

            @Override
            public void onPageScrollStateChanged(int state) {
            }
        });
    }
}
Also used : ImagesContainerPagerAdapter(com.github.obsessive.simplifyreader.ui.adpter.ImagesContainerPagerAdapter) ViewPager(android.support.v4.view.ViewPager) XViewPager(com.github.obsessive.library.widgets.XViewPager)

Example 14 with Fragment

use of android.support.v4.app.Fragment in project SimplifyReader by chentao0707.

the class VideosContainerFragment method initializePagerViews.

@Override
public void initializePagerViews(final List<BaseEntity> categoryList) {
    if (null != categoryList && !categoryList.isEmpty()) {
        mViewPager.setOffscreenPageLimit(categoryList.size());
        mViewPager.setAdapter(new VideosContainerPagerAdapter(getSupportFragmentManager(), categoryList));
        mSmartTabLayout.setViewPager(mViewPager);
        mSmartTabLayout.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {

            @Override
            public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
            }

            @Override
            public void onPageSelected(int position) {
                VideosListFragment fragment = (VideosListFragment) mViewPager.getAdapter().instantiateItem(mViewPager, position);
                fragment.onPageSelected(position, categoryList.get(position).getId());
            }

            @Override
            public void onPageScrollStateChanged(int state) {
            }
        });
    }
}
Also used : VideosContainerPagerAdapter(com.github.obsessive.simplifyreader.ui.adpter.VideosContainerPagerAdapter) ViewPager(android.support.v4.view.ViewPager) XViewPager(com.github.obsessive.library.widgets.XViewPager)

Example 15 with Fragment

use of android.support.v4.app.Fragment in project philm by chrisbanes.

the class BasePhilmTabFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_viewpager, container, false);
    mAdapter = new TabPagerAdapter(getChildFragmentManager());
    mViewPager = (ViewPager) view.findViewById(R.id.viewpager);
    mViewPager.setAdapter(mAdapter);
    mViewPager.setPageMargin(getResources().getDimensionPixelSize(R.dimen.spacing_minor));
    mTabLayout = (TabLayout) view.findViewById(R.id.viewpager_tabs);
    mTabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {

        @Override
        public void onTabSelected(TabLayout.Tab tab) {
        }

        @Override
        public void onTabUnselected(TabLayout.Tab tab) {
        }

        @Override
        public void onTabReselected(TabLayout.Tab tab) {
            final Fragment fragment = mAdapter.getItem(tab.getPosition());
            if (fragment instanceof ListFragment) {
                ((ListFragment) fragment).smoothScrollTo(0);
            }
        }
    });
    if (savedInstanceState != null) {
        mCurrentItem = savedInstanceState.getInt(SAVE_SELECTED_TAB);
    }
    return view;
}
Also used : TabLayout(android.support.design.widget.TabLayout) View(android.view.View) Fragment(android.support.v4.app.Fragment)

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