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.

91 lines
3.0 KiB

  1. package eu.faircode.email;
  2. /*
  3. This file is part of FairEmail.
  4. FairEmail 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.ArrayList;
  22. import java.util.List;
  23. import androidx.annotation.NonNull;
  24. import androidx.annotation.Nullable;
  25. import androidx.constraintlayout.widget.Group;
  26. import androidx.lifecycle.Observer;
  27. import androidx.recyclerview.widget.LinearLayoutManager;
  28. import androidx.recyclerview.widget.RecyclerView;
  29. public class FragmentOperations extends FragmentEx {
  30. private RecyclerView rvOperation;
  31. private ProgressBar pbWait;
  32. private Group grpReady;
  33. private AdapterOperation adapter;
  34. @Override
  35. @Nullable
  36. public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
  37. setSubtitle(R.string.menu_operations);
  38. View view = inflater.inflate(R.layout.fragment_operations, container, false);
  39. // Get controls
  40. rvOperation = view.findViewById(R.id.rvOperation);
  41. pbWait = view.findViewById(R.id.pbWait);
  42. grpReady = view.findViewById(R.id.grpReady);
  43. // Wire controls
  44. rvOperation.setHasFixedSize(false);
  45. LinearLayoutManager llm = new LinearLayoutManager(getContext());
  46. rvOperation.setLayoutManager(llm);
  47. adapter = new AdapterOperation(getContext(), getViewLifecycleOwner());
  48. rvOperation.setAdapter(adapter);
  49. // Initialize
  50. grpReady.setVisibility(View.GONE);
  51. pbWait.setVisibility(View.VISIBLE);
  52. return view;
  53. }
  54. @Override
  55. public void onActivityCreated(@Nullable Bundle savedInstanceState) {
  56. super.onActivityCreated(savedInstanceState);
  57. // Observe folders
  58. DB.getInstance(getContext()).operation().liveOperations().observe(getViewLifecycleOwner(), new Observer<List<EntityOperation>>() {
  59. @Override
  60. public void onChanged(@Nullable List<EntityOperation> operations) {
  61. if (operations == null)
  62. operations = new ArrayList<>();
  63. adapter.set(operations);
  64. pbWait.setVisibility(View.GONE);
  65. grpReady.setVisibility(View.VISIBLE);
  66. }
  67. });
  68. }
  69. }