Simple email application for Android. Original source code: https://framagit.org/dystopia-project/simple-email
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

86 lines
2.8 KiB

  1. package eu.faircode.email;
  2. /*
  3. This file is part of Safe email.
  4. Safe email is free software: you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation, either version 3 of the License, or
  7. (at your option) any later version.
  8. NetGuard is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with NetGuard. If not, see <http://www.gnu.org/licenses/>.
  14. Copyright 2018 by Marcel Bokhorst (M66B)
  15. */
  16. import android.os.Bundle;
  17. import android.view.LayoutInflater;
  18. import android.view.View;
  19. import android.view.ViewGroup;
  20. import android.widget.ProgressBar;
  21. import java.util.List;
  22. import androidx.annotation.NonNull;
  23. import androidx.annotation.Nullable;
  24. import androidx.constraintlayout.widget.Group;
  25. import androidx.lifecycle.Observer;
  26. import androidx.recyclerview.widget.LinearLayoutManager;
  27. import androidx.recyclerview.widget.RecyclerView;
  28. public class FragmentOperations extends FragmentEx {
  29. private RecyclerView rvOperation;
  30. private ProgressBar pbWait;
  31. private Group grpReady;
  32. private AdapterOperation adapter;
  33. @Override
  34. @Nullable
  35. public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
  36. View view = inflater.inflate(R.layout.fragment_operations, container, false);
  37. // Get controls
  38. rvOperation = view.findViewById(R.id.rvOperation);
  39. pbWait = view.findViewById(R.id.pbWait);
  40. grpReady = view.findViewById(R.id.grpReady);
  41. // Wire controls
  42. rvOperation.setHasFixedSize(false);
  43. LinearLayoutManager llm = new LinearLayoutManager(getContext());
  44. rvOperation.setLayoutManager(llm);
  45. adapter = new AdapterOperation(getContext());
  46. rvOperation.setAdapter(adapter);
  47. // Initialize
  48. grpReady.setVisibility(View.GONE);
  49. pbWait.setVisibility(View.VISIBLE);
  50. return view;
  51. }
  52. @Override
  53. public void onActivityCreated(@Nullable Bundle savedInstanceState) {
  54. super.onActivityCreated(savedInstanceState);
  55. // Observe folders
  56. DB.getInstance(getContext()).operation().liveOperations().observe(getViewLifecycleOwner(), new Observer<List<EntityOperation>>() {
  57. @Override
  58. public void onChanged(@Nullable List<EntityOperation> operations) {
  59. if (operations != null)
  60. adapter.set(operations);
  61. pbWait.setVisibility(View.GONE);
  62. grpReady.setVisibility(View.VISIBLE);
  63. }
  64. });
  65. }
  66. }