Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't use activity.isFinishing() #2159

Merged
merged 1 commit into from
Oct 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ public void onResume() {

// React to deletion
DataRefreshService dataRefreshService = KoinJavaComponent.<DataRefreshService>get(DataRefreshService.class);
if (getActivity() != null && !getActivity().isFinishing() && mCurrentRow != null && mCurrentItem != null && mCurrentItem.getItemId() != null && mCurrentItem.getItemId().equals(dataRefreshService.getLastDeletedItemId())) {
if (mCurrentRow != null && mCurrentItem != null && mCurrentItem.getItemId() != null && mCurrentItem.getItemId().equals(dataRefreshService.getLastDeletedItemId())) {
((ItemRowAdapter) mCurrentRow.getAdapter()).remove(mCurrentItem);
dataRefreshService.setLastDeletedItemId(null);
}
Expand All @@ -201,7 +201,7 @@ public void run() {

for (int i = 0; i < mRowsAdapter.size(); i++) {
if (mRowsAdapter.get(i) instanceof ListRow) {
if (((ListRow) mRowsAdapter.get(i)).getAdapter() instanceof ItemRowAdapter && !mActivity.isFinishing()) {
if (((ListRow) mRowsAdapter.get(i)).getAdapter() instanceof ItemRowAdapter) {
((ItemRowAdapter) ((ListRow) mRowsAdapter.get(i)).getAdapter()).ReRetrieveIfNeeded();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ class HomeRowsFragment : RowsSupportFragment(), AudioEventListener, View.OnKeyLi
super.onResume()

//React to deletion
if (activity != null && !requireActivity().isFinishing && currentRow != null && currentItem != null && currentItem!!.getItemId() != null && currentItem!!.getItemId().equals(dataRefreshService.lastDeletedItemId)) {
if (currentRow != null && currentItem != null && currentItem!!.getItemId() != null && currentItem!!.getItemId().equals(dataRefreshService.lastDeletedItemId)) {

Check warning

Code scanning / detekt

Complex conditions should be simplified and extracted into well-named methods if necessary.

This condition is too complex (4). Defined complexity threshold for conditions is set to '4'

Check warning

Code scanning / detekt

Line detected, which is longer than the defined maximum line length in the code style.

Line detected, which is longer than the defined maximum line length in the code style.
(currentRow!!.adapter as ItemRowAdapter).remove(currentItem)
dataRefreshService.lastDeletedItemId = null
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ private void stopClock() {
private static List<BaseItemKind> buttonTypeList = Arrays.asList(buttonTypes);

private void updateWatched() {
if (mWatchedToggleButton != null && mBaseItem != null && mBaseItem.getUserData() != null && !requireActivity().isFinishing()) {
if (mWatchedToggleButton != null && mBaseItem != null && mBaseItem.getUserData() != null) {
mWatchedToggleButton.setActivated(mBaseItem.getUserData().getPlayed());
}
}
Expand Down Expand Up @@ -491,7 +491,7 @@ protected MyDetailsOverviewRow doInBackground(BaseItemDto... params) {
protected void onPostExecute(MyDetailsOverviewRow detailsOverviewRow) {
super.onPostExecute(detailsOverviewRow);

if (requireActivity().isFinishing()) return;
if (!getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) return;

ClassPresenterSelector ps = new ClassPresenterSelector();
ps.addClassPresenter(MyDetailsOverviewRow.class, mDorPresenter);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,6 @@ public void onFocusChange(View v, boolean hasFocus) {
};

private void updatePoster() {
if (requireActivity().isFinishing()) return;
// Figure image size
Double aspect = ImageUtils.getImageAspectRatio(mBaseItem, false);
int posterHeight = aspect > 1 ? Utils.convertDpToPixel(requireActivity(), 150) : Utils.convertDpToPixel(requireActivity(), 250);
Expand Down