use of android.app.Activity in project UltimateAndroid by cymcsg.
the class ViewPagerTabScrollViewFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.observable_scroll_view_fragment_scrollview, container, false);
final ObservableScrollView scrollView = (ObservableScrollView) view.findViewById(R.id.scroll);
Activity parentActivity = getActivity();
if (parentActivity instanceof ObservableScrollViewCallbacks) {
// Scroll to the specified offset after layout
Bundle args = getArguments();
if (args != null && args.containsKey(ARG_SCROLL_Y)) {
final int scrollY = args.getInt(ARG_SCROLL_Y, 0);
ViewTreeObserver vto = scrollView.getViewTreeObserver();
vto.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
scrollView.getViewTreeObserver().removeGlobalOnLayoutListener(this);
} else {
scrollView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
}
scrollView.scrollTo(0, scrollY);
}
});
}
scrollView.setScrollViewCallbacks((ObservableScrollViewCallbacks) parentActivity);
}
return view;
}
use of android.app.Activity in project android-betterpickers by code-troopers.
the class CalendarDatePickerDialogFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
Log.d(TAG, "onCreateView: ");
if (getShowsDialog()) {
getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);
}
View view = inflater.inflate(R.layout.calendar_date_picker_dialog, container, false);
mSelectedDateLayout = (LinearLayout) view.findViewById(R.id.day_picker_selected_date_layout);
mDayOfWeekView = (TextView) view.findViewById(R.id.date_picker_header);
mMonthAndDayView = (LinearLayout) view.findViewById(R.id.date_picker_month_and_day);
mMonthAndDayView.setOnClickListener(this);
mSelectedMonthTextView = (TextView) view.findViewById(R.id.date_picker_month);
mSelectedDayTextView = (TextView) view.findViewById(R.id.date_picker_day);
mYearView = (TextView) view.findViewById(R.id.date_picker_year);
mYearView.setOnClickListener(this);
int listPosition = -1;
int listPositionOffset = 0;
int currentView = MONTH_AND_DAY_VIEW;
if (savedInstanceState != null) {
mWeekStart = savedInstanceState.getInt(KEY_WEEK_START);
mMinDate = new CalendarDay(savedInstanceState.getLong(KEY_DATE_START));
mMaxDate = new CalendarDay(savedInstanceState.getLong(KEY_DATE_END));
currentView = savedInstanceState.getInt(KEY_CURRENT_VIEW);
listPosition = savedInstanceState.getInt(KEY_LIST_POSITION);
listPositionOffset = savedInstanceState.getInt(KEY_LIST_POSITION_OFFSET);
mStyleResId = savedInstanceState.getInt(KEY_THEME);
mDisabledDays = savedInstanceState.getSparseParcelableArray(KEY_DISABLED_DAYS);
}
final Activity activity = getActivity();
mDayPickerView = new SimpleDayPickerView(activity, this);
mYearPickerView = new YearPickerView(activity, this);
Resources res = getResources();
TypedArray themeColors = getActivity().obtainStyledAttributes(mStyleResId, R.styleable.BetterPickersDialogs);
mDayPickerDescription = res.getString(R.string.day_picker_description);
mSelectDay = res.getString(R.string.select_day);
mYearPickerDescription = res.getString(R.string.year_picker_description);
mSelectYear = res.getString(R.string.select_year);
int headerBackgroundColor = themeColors.getColor(R.styleable.BetterPickersDialogs_bpHeaderBackgroundColor, ContextCompat.getColor(getActivity(), R.color.bpWhite));
int preHeaderBackgroundColor = themeColors.getColor(R.styleable.BetterPickersDialogs_bpPreHeaderBackgroundColor, ContextCompat.getColor(getActivity(), R.color.bpWhite));
int bodyBgColor = themeColors.getColor(R.styleable.BetterPickersDialogs_bpBodyBackgroundColor, ContextCompat.getColor(getActivity(), R.color.bpWhite));
int buttonBgColor = themeColors.getColor(R.styleable.BetterPickersDialogs_bpButtonsBackgroundColor, ContextCompat.getColor(getActivity(), R.color.bpWhite));
int buttonTextColor = themeColors.getColor(R.styleable.BetterPickersDialogs_bpButtonsTextColor, ContextCompat.getColor(getActivity(), R.color.bpBlue));
mSelectedColor = themeColors.getColor(R.styleable.BetterPickersDialogs_bpHeaderSelectedTextColor, ContextCompat.getColor(getActivity(), R.color.bpWhite));
mUnselectedColor = themeColors.getColor(R.styleable.BetterPickersDialogs_bpHeaderUnselectedTextColor, ContextCompat.getColor(getActivity(), R.color.radial_gray_light));
mAnimator = (AccessibleDateAnimator) view.findViewById(R.id.animator);
mAnimator.addView(mDayPickerView);
mAnimator.addView(mYearPickerView);
mAnimator.setDateMillis(mCalendar.getTimeInMillis());
// TODO: Replace with animation decided upon by the design team.
Animation animation = new AlphaAnimation(0.0f, 1.0f);
animation.setDuration(ANIMATION_DURATION);
mAnimator.setInAnimation(animation);
// TODO: Replace with animation decided upon by the design team.
Animation animation2 = new AlphaAnimation(1.0f, 0.0f);
animation2.setDuration(ANIMATION_DURATION);
mAnimator.setOutAnimation(animation2);
Button doneButton = (Button) view.findViewById(R.id.done_button);
if (mDoneText != null) {
doneButton.setText(mDoneText);
}
doneButton.setTextColor(buttonTextColor);
doneButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
tryVibrate();
if (mCallBack != null) {
mCallBack.onDateSet(CalendarDatePickerDialogFragment.this, mCalendar.get(Calendar.YEAR), mCalendar.get(Calendar.MONTH), mCalendar.get(Calendar.DAY_OF_MONTH));
}
dismiss();
}
});
Button cancelButton = (Button) view.findViewById(R.id.cancel_button);
if (mCancelText != null) {
cancelButton.setText(mCancelText);
}
cancelButton.setTextColor(buttonTextColor);
cancelButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
tryVibrate();
dismiss();
}
});
view.findViewById(R.id.ok_cancel_buttons_layout).setBackgroundColor(buttonBgColor);
updateDisplay(false);
setCurrentView(currentView);
if (listPosition != -1) {
if (currentView == MONTH_AND_DAY_VIEW) {
mDayPickerView.postSetSelection(listPosition);
} else if (currentView == YEAR_VIEW) {
mYearPickerView.postSetSelectionFromTop(listPosition, listPositionOffset);
}
}
mHapticFeedbackController = new HapticFeedbackController(activity);
mDayPickerView.setTheme(themeColors);
mYearPickerView.setTheme(themeColors);
mSelectedDateLayout.setBackgroundColor(headerBackgroundColor);
mYearView.setBackgroundColor(headerBackgroundColor);
mMonthAndDayView.setBackgroundColor(headerBackgroundColor);
if (mDayOfWeekView != null) {
mDayOfWeekView.setBackgroundColor(preHeaderBackgroundColor);
}
view.setBackgroundColor(bodyBgColor);
mYearPickerView.setBackgroundColor(bodyBgColor);
mDayPickerView.setBackgroundColor(bodyBgColor);
return view;
}
use of android.app.Activity in project android-betterpickers by code-troopers.
the class CalendarDatePickerDialogFragment method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
final Activity activity = getActivity();
activity.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
if (savedInstanceState != null) {
mCalendar.set(Calendar.YEAR, savedInstanceState.getInt(KEY_SELECTED_YEAR));
mCalendar.set(Calendar.MONTH, savedInstanceState.getInt(KEY_SELECTED_MONTH));
mCalendar.set(Calendar.DAY_OF_MONTH, savedInstanceState.getInt(KEY_SELECTED_DAY));
}
}
use of android.app.Activity 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.app.Activity 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