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;
}
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");
}
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) {
}
});
}
}
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) {
}
});
}
}
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;
}
Aggregations