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