mirror of
https://github.com/CappielloAntonio/tempo.git
synced 2026-02-04 16:23:08 +00:00
fix: updated download section navigation to match the system's correct stack-based navigation
This commit is contained in:
@@ -7,6 +7,7 @@ import android.view.View;
|
|||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.PopupMenu;
|
import android.widget.PopupMenu;
|
||||||
|
|
||||||
|
import androidx.activity.OnBackPressedCallback;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
@@ -37,6 +38,8 @@ import java.util.Objects;
|
|||||||
|
|
||||||
@UnstableApi
|
@UnstableApi
|
||||||
public class DownloadFragment extends Fragment implements ClickCallback {
|
public class DownloadFragment extends Fragment implements ClickCallback {
|
||||||
|
private static final String TAG = "DownloadFragment";
|
||||||
|
|
||||||
private FragmentDownloadBinding bind;
|
private FragmentDownloadBinding bind;
|
||||||
private MainActivity activity;
|
private MainActivity activity;
|
||||||
private DownloadViewModel downloadViewModel;
|
private DownloadViewModel downloadViewModel;
|
||||||
@@ -160,6 +163,23 @@ public class DownloadFragment extends Fragment implements ClickCallback {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bind.downloadedGoBackImageView.setVisibility(stack.size() > 1 ? View.VISIBLE : View.GONE);
|
bind.downloadedGoBackImageView.setVisibility(stack.size() > 1 ? View.VISIBLE : View.GONE);
|
||||||
|
|
||||||
|
setupBackPressing(stack.size());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setupBackPressing(int stackSize) {
|
||||||
|
requireActivity().getOnBackPressedDispatcher().addCallback(getViewLifecycleOwner(), new OnBackPressedCallback(true) {
|
||||||
|
@Override
|
||||||
|
public void handleOnBackPressed() {
|
||||||
|
if (stackSize > 1) {
|
||||||
|
downloadViewModel.popViewStack();
|
||||||
|
} else {
|
||||||
|
activity.navController.navigateUp();
|
||||||
|
}
|
||||||
|
|
||||||
|
remove();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.cappielloantonio.tempo.viewmodel;
|
package com.cappielloantonio.tempo.viewmodel;
|
||||||
|
|
||||||
import android.app.Application;
|
import android.app.Application;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.lifecycle.AndroidViewModel;
|
import androidx.lifecycle.AndroidViewModel;
|
||||||
@@ -11,7 +12,6 @@ import androidx.lifecycle.MutableLiveData;
|
|||||||
import com.cappielloantonio.tempo.model.DownloadStack;
|
import com.cappielloantonio.tempo.model.DownloadStack;
|
||||||
import com.cappielloantonio.tempo.repository.DownloadRepository;
|
import com.cappielloantonio.tempo.repository.DownloadRepository;
|
||||||
import com.cappielloantonio.tempo.subsonic.models.Child;
|
import com.cappielloantonio.tempo.subsonic.models.Child;
|
||||||
import com.cappielloantonio.tempo.util.Constants;
|
|
||||||
import com.cappielloantonio.tempo.util.Preferences;
|
import com.cappielloantonio.tempo.util.Preferences;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|||||||
Reference in New Issue
Block a user