Skip to content

Commit

Permalink
moved updateView() to onResume() to have recent data when tabs are sw…
Browse files Browse the repository at this point in the history
…itched, fixed some warnings
  • Loading branch information
wolpi committed Nov 26, 2023
1 parent c6cba40 commit 983e65c
Showing 1 changed file with 14 additions and 20 deletions.
34 changes: 14 additions & 20 deletions primitiveFTPd/src/org/primftpd/ui/CleanSpaceFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import java.io.File;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;

public class CleanSpaceFragment extends Fragment implements RecreateLogger {
Expand All @@ -34,7 +35,7 @@ private static class DialogHandler extends Handler {
}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState)
{
super.onCreateView(inflater, container, savedInstanceState);
Expand All @@ -46,29 +47,22 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,

// register listeners
final CleanSpaceFragment fragment = this;
view.findViewById(R.id.quickShareFilesDelete).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
onButtonClick(fragment, quickShareDir(), true);
}
});
view.findViewById(R.id.logFilesDelete).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
onButtonClick(fragment, logsDir(), false);
}
});
view.findViewById(R.id.rootTmpFilesDelete).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
onButtonClick(fragment, rootTmpDir(), true);
}
});
view.findViewById(R.id.quickShareFilesDelete).setOnClickListener(
viewQ -> onButtonClick(fragment, quickShareDir(), true));
view.findViewById(R.id.logFilesDelete).setOnClickListener(
viewL -> onButtonClick(fragment, logsDir(), false));
view.findViewById(R.id.rootTmpFilesDelete).setOnClickListener(
viewR -> onButtonClick(fragment, rootTmpDir(), true));

updateView();
return view;
}

@Override
public void onResume() {
super.onResume();
updateView();
}

private void onButtonClick(CleanSpaceFragment fragment, File dir, boolean includeChildren) {
int numberOfFiles = collectNumberOfFiles(dir, includeChildren);
if (numberOfFiles > 0) {
Expand Down

0 comments on commit 983e65c

Please sign in to comment.