use of com.google.android.material.floatingactionbutton.FloatingActionButton in project Gadgetbridge by Freeyourgadget.
the class ConfigureReminders method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_configure_reminders);
gbDevice = getIntent().getParcelableExtra(GBDevice.EXTRA_DEVICE);
mGBReminderListAdapter = new GBReminderListAdapter(this);
final RecyclerView remindersRecyclerView = findViewById(R.id.reminder_list);
remindersRecyclerView.setHasFixedSize(true);
remindersRecyclerView.setLayoutManager(new LinearLayoutManager(this));
remindersRecyclerView.setAdapter(mGBReminderListAdapter);
updateRemindersFromDB();
final FloatingActionButton fab = findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final DeviceCoordinator coordinator = DeviceHelper.getInstance().getCoordinator(gbDevice);
final Prefs prefs = new Prefs(GBApplication.getDeviceSpecificSharedPrefs(gbDevice.getAddress()));
int reservedSlots = prefs.getInt(DeviceSettingsPreferenceConst.PREF_RESERVER_REMINDERS_CALENDAR, 9);
int deviceSlots = coordinator.getReminderSlotCount() - reservedSlots;
if (mGBReminderListAdapter.getItemCount() >= deviceSlots) {
// No more free slots
new AlertDialog.Builder(v.getContext()).setTitle(R.string.reminder_no_free_slots_title).setMessage(getBaseContext().getString(R.string.reminder_no_free_slots_description, String.format(Locale.getDefault(), "%d", deviceSlots))).setIcon(R.drawable.ic_warning).setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
public void onClick(final DialogInterface dialog, final int whichButton) {
}
}).show();
return;
}
final Reminder reminder;
try (DBHandler db = GBApplication.acquireDB()) {
final DaoSession daoSession = db.getDaoSession();
final Device device = DBHelper.getDevice(gbDevice, daoSession);
final User user = DBHelper.getUser(daoSession);
reminder = createDefaultReminder(device, user);
} catch (final Exception e) {
LOG.error("Error accessing database", e);
return;
}
configureReminder(reminder);
}
});
}
use of com.google.android.material.floatingactionbutton.FloatingActionButton in project kdeconnect-android by KDE.
the class CustomDevicesActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
ThemeUtil.setUserPreferredTheme(this);
super.onCreate(savedInstanceState);
final ActivityCustomDevicesBinding binding = ActivityCustomDevicesBinding.inflate(getLayoutInflater());
setContentView(binding.getRoot());
recyclerView = binding.recyclerView;
emptyListMessage = binding.emptyListMessage;
final FloatingActionButton fab = binding.floatingActionButton;
setSupportActionBar(binding.toolbarLayout.toolbar);
Objects.requireNonNull(getSupportActionBar()).setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowHomeEnabled(true);
fab.setOnClickListener(v -> showEditTextDialog(""));
sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
customDeviceList = getCustomDeviceList(sharedPreferences);
showEmptyListMessageIfRequired();
customDevicesAdapter = new CustomDevicesAdapter(this);
customDevicesAdapter.setCustomDevices(customDeviceList);
recyclerView.setHasFixedSize(true);
recyclerView.setLayoutManager(new LinearLayoutManager(this, RecyclerView.VERTICAL, false));
recyclerView.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL));
recyclerView.setAdapter(customDevicesAdapter);
addDeviceDialog = (EditTextAlertDialogFragment) getSupportFragmentManager().findFragmentByTag(TAG_ADD_DEVICE_DIALOG);
if (addDeviceDialog != null) {
addDeviceDialog.setCallback(new AddDeviceDialogCallback());
}
TooltipCompat.setTooltipText(fab, getString(R.string.custom_device_fab_hint));
if (savedInstanceState != null) {
editingDeviceAtPosition = savedInstanceState.getInt(KEY_EDITING_DEVICE_AT_POSITION);
} else {
editingDeviceAtPosition = -1;
}
}
use of com.google.android.material.floatingactionbutton.FloatingActionButton in project android by nextcloud.
the class FileDetailFragment method showHideFragmentView.
/**
* method will handle the views need to be hidden when sharing process fragment shows
* @param isFragmentReplaced
*/
public void showHideFragmentView(boolean isFragmentReplaced) {
binding.tabLayout.setVisibility(isFragmentReplaced ? View.GONE : View.VISIBLE);
binding.pager.setVisibility(isFragmentReplaced ? View.GONE : View.VISIBLE);
binding.sharingFrameContainer.setVisibility(isFragmentReplaced ? View.VISIBLE : View.GONE);
FloatingActionButton mFabMain = requireActivity().findViewById(R.id.fab_main);
if (isFragmentReplaced) {
mFabMain.hide();
} else {
mFabMain.show();
}
}
use of com.google.android.material.floatingactionbutton.FloatingActionButton in project android by nextcloud.
the class PreviewTextStringFragment method onCreateView.
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = super.onCreateView(inflater, container, savedInstanceState);
if (view == null) {
throw new RuntimeException("View may not be null");
}
FloatingActionButton fabMain = requireActivity().findViewById(R.id.fab_main);
fabMain.setVisibility(View.VISIBLE);
fabMain.setEnabled(true);
fabMain.setOnClickListener(v -> edit());
ThemeFabUtils.colorFloatingActionButton(fabMain, R.drawable.ic_edit, requireContext());
return view;
}
use of com.google.android.material.floatingactionbutton.FloatingActionButton in project iterable-android-sdk by Iterable.
the class MainActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG).setAction("Action", null).show();
}
});
}
Aggregations