Merge pull request #3694 from ByteHamster/optionsitem-crash

Do not crash when clicking menu items while loading
This commit is contained in:
H. Lehmann 2019-12-19 16:57:11 +01:00 committed by GitHub
commit cc66936726
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 0 deletions

View File

@ -214,6 +214,10 @@ public class FeedInfoFragment extends Fragment {
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (feed == null) {
Toast.makeText(getContext(), R.string.please_wait_for_data, Toast.LENGTH_LONG).show();
return super.onOptionsItemSelected(item);
}
boolean handled = false;
try {
handled = FeedMenuHandler.onOptionsItemClicked(getContext(), item, feed);

View File

@ -19,6 +19,7 @@ import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.appcompat.widget.SearchView;
import androidx.core.view.MenuItemCompat;
@ -235,6 +236,10 @@ public class FeedItemlistFragment extends ListFragment {
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (!super.onOptionsItemSelected(item)) {
if (feed == null) {
Toast.makeText(getContext(), R.string.please_wait_for_data, Toast.LENGTH_LONG).show();
return true;
}
try {
if (!FeedMenuHandler.onOptionsItemClicked(getActivity(), item, feed)) {
switch (item.getItemId()) {

View File

@ -157,6 +157,7 @@
<string name="filtered_label">Filtered</string>
<string name="refresh_failed_msg">{fa-exclamation-circle} Last Refresh failed</string>
<string name="open_podcast">Open Podcast</string>
<string name="please_wait_for_data">Please wait until the data is loaded</string>
<!-- actions on feeditems -->
<string name="download_label">Download</string>