Search in sources :

Example 1 with ActivityCustomDevicesBinding

use of org.kde.kdeconnect_tp.databinding.ActivityCustomDevicesBinding 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;
    }
}
Also used : ActivityCustomDevicesBinding(org.kde.kdeconnect_tp.databinding.ActivityCustomDevicesBinding) FloatingActionButton(com.google.android.material.floatingactionbutton.FloatingActionButton) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) DividerItemDecoration(androidx.recyclerview.widget.DividerItemDecoration)

Aggregations

DividerItemDecoration (androidx.recyclerview.widget.DividerItemDecoration)1 LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)1 FloatingActionButton (com.google.android.material.floatingactionbutton.FloatingActionButton)1 ActivityCustomDevicesBinding (org.kde.kdeconnect_tp.databinding.ActivityCustomDevicesBinding)1