use of org.omnirom.deskclock.widget.sgv.StaggeredGridView in project android_packages_apps_OmniClock by omnirom.
the class TimerFullScreenFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// Inflate the layout for this fragment
View v = inflater.inflate(org.omnirom.deskclock.R.layout.timer_full_screen_fragment, container, false);
// Handle arguments from parent
Bundle bundle = getArguments();
if (bundle != null && bundle.containsKey(Timers.TIMESUP_MODE)) {
if (bundle.getBoolean(Timers.TIMESUP_MODE, false)) {
try {
mOnEmptyListListener = (OnEmptyListListener) getActivity();
} catch (ClassCastException e) {
Log.wtf(TAG, getActivity().toString() + " must implement OnEmptyListListener");
}
}
}
mFab = (ImageButton) v.findViewById(org.omnirom.deskclock.R.id.fab);
mTimersList = (StaggeredGridView) v.findViewById(org.omnirom.deskclock.R.id.timers_list);
// For tablets in landscape, the count will be 2. All else will be 1.
mColumnCount = getResources().getInteger(org.omnirom.deskclock.R.integer.timer_column_count);
mTimersList.setColumnCount(mColumnCount);
// Set this to true; otherwise adding new views to the end of the list won't cause
// everything above it to be filled in correctly.
mTimersList.setGuardAgainstJaggedEdges(true);
mTimersListPage = v.findViewById(org.omnirom.deskclock.R.id.timers_list_page);
mTimerSetup = (TimerSetupView) v.findViewById(org.omnirom.deskclock.R.id.timer_setup);
mPrefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
mNotificationManager = (NotificationManager) getActivity().getSystemService(Context.NOTIFICATION_SERVICE);
return v;
}
use of org.omnirom.deskclock.widget.sgv.StaggeredGridView in project android_packages_apps_OmniClock by omnirom.
the class TimerFullScreenFragment method onResume.
@Override
public void onResume() {
Intent newIntent = null;
if (getActivity() instanceof DeskClock) {
DeskClock activity = (DeskClock) getActivity();
activity.registerPageChangedListener(this);
newIntent = activity.getIntent();
}
super.onResume();
mPrefs.registerOnSharedPreferenceChangeListener(this);
mAdapter = createAdapter(getActivity(), mPrefs);
mAdapter.onRestoreInstanceState(null);
LayoutParams params;
float dividerHeight = getResources().getDimension(org.omnirom.deskclock.R.dimen.timer_divider_height);
if (getActivity() instanceof DeskClock) {
// If this is a DeskClock fragment (i.e. not a FullScreenTimerAlert), add a footer to
// the bottom of the list so that it can scroll underneath the bottom button bar.
// StaggeredGridView doesn't support a footer view, but GridAdapter does, so this
// can't happen until the Adapter itself is instantiated.
View footerView = getActivity().getLayoutInflater().inflate(org.omnirom.deskclock.R.layout.blank_footer_view, mTimersList, false);
params = footerView.getLayoutParams();
params.height -= dividerHeight;
footerView.setLayoutParams(params);
mAdapter.setFooterView(footerView);
}
if (mPrefs.getBoolean(Timers.FROM_NOTIFICATION, false)) {
// Clear the flag set in the notification because the adapter was just
// created and is thus in sync with the database
SharedPreferences.Editor editor = mPrefs.edit();
editor.putBoolean(Timers.FROM_NOTIFICATION, false);
editor.apply();
}
if (mPrefs.getBoolean(Timers.FROM_ALERT, false)) {
// Clear the flag set in the alert because the adapter was just
// created and is thus in sync with the database
SharedPreferences.Editor editor = mPrefs.edit();
editor.putBoolean(Timers.FROM_ALERT, false);
editor.apply();
}
mTimersList.setAdapter(mAdapter);
// Force a non animation setting of the view
mLastVisibleView = null;
setPage();
// View was hidden in onPause, make sure it is visible now.
View v = getView();
if (v != null) {
getView().setVisibility(View.VISIBLE);
}
if (newIntent != null) {
processIntent(newIntent);
}
mFab.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
revealAnimation(mFab, getActivity().getResources().getColor(org.omnirom.deskclock.R.color.white));
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
updateAllTimesUpTimers(true);
}
}, TimerFragment.ANIMATION_TIME_MILLIS);
}
});
}
Aggregations