Merge pull request #4628 from ByteHamster/local-feeds-metadata
Fixed local feed metadata, show directly
This commit is contained in:
commit
23763eb87f
|
@ -35,6 +35,9 @@ import de.danoeh.antennapod.discovery.FyydPodcastSearcher;
|
||||||
import de.danoeh.antennapod.discovery.ItunesPodcastSearcher;
|
import de.danoeh.antennapod.discovery.ItunesPodcastSearcher;
|
||||||
import de.danoeh.antennapod.discovery.PodcastIndexPodcastSearcher;
|
import de.danoeh.antennapod.discovery.PodcastIndexPodcastSearcher;
|
||||||
import de.danoeh.antennapod.fragment.gpodnet.GpodnetMainFragment;
|
import de.danoeh.antennapod.fragment.gpodnet.GpodnetMainFragment;
|
||||||
|
import io.reactivex.Observable;
|
||||||
|
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||||
|
import io.reactivex.schedulers.Schedulers;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
|
||||||
|
@ -162,15 +165,25 @@ public class AddFeedFragment extends Fragment {
|
||||||
intent.setData(uri);
|
intent.setData(uri);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
} else if (requestCode == REQUEST_CODE_ADD_LOCAL_FOLDER) {
|
} else if (requestCode == REQUEST_CODE_ADD_LOCAL_FOLDER) {
|
||||||
addLocalFolder(uri);
|
Observable.fromCallable(() -> addLocalFolder(uri))
|
||||||
|
.subscribeOn(Schedulers.io())
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(
|
||||||
|
feed -> {
|
||||||
|
Fragment fragment = FeedItemlistFragment.newInstance(feed.getId());
|
||||||
|
((MainActivity) getActivity()).loadChildFragment(fragment);
|
||||||
|
}, error -> {
|
||||||
|
Log.e(TAG, Log.getStackTraceString(error));
|
||||||
|
((MainActivity) getActivity())
|
||||||
|
.showSnackbarAbovePlayer(error.getLocalizedMessage(), Snackbar.LENGTH_LONG);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addLocalFolder(Uri uri) {
|
private Feed addLocalFolder(Uri uri) throws DownloadRequestException {
|
||||||
if (Build.VERSION.SDK_INT < 21) {
|
if (Build.VERSION.SDK_INT < 21) {
|
||||||
return;
|
return null;
|
||||||
}
|
}
|
||||||
try {
|
|
||||||
getActivity().getContentResolver()
|
getActivity().getContentResolver()
|
||||||
.takePersistableUriPermission(uri, Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
.takePersistableUriPermission(uri, Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||||
DocumentFile documentFile = DocumentFile.fromTreeUri(getContext(), uri);
|
DocumentFile documentFile = DocumentFile.fromTreeUri(getContext(), uri);
|
||||||
|
@ -181,12 +194,8 @@ public class AddFeedFragment extends Fragment {
|
||||||
dirFeed.setDescription(getString(R.string.local_feed_description));
|
dirFeed.setDescription(getString(R.string.local_feed_description));
|
||||||
dirFeed.setItems(Collections.emptyList());
|
dirFeed.setItems(Collections.emptyList());
|
||||||
dirFeed.setSortOrder(SortOrder.EPISODE_TITLE_A_Z);
|
dirFeed.setSortOrder(SortOrder.EPISODE_TITLE_A_Z);
|
||||||
DBTasks.forceRefreshFeed(getContext(), dirFeed, true);
|
Feed fromDatabase = DBTasks.updateFeed(getContext(), dirFeed, false);
|
||||||
((MainActivity) getActivity())
|
DBTasks.forceRefreshFeed(getContext(), fromDatabase, true);
|
||||||
.showSnackbarAbovePlayer(R.string.add_local_folder_success, Snackbar.LENGTH_SHORT);
|
return fromDatabase;
|
||||||
} catch (DownloadRequestException | IllegalArgumentException e) {
|
|
||||||
Log.e(TAG, Log.getStackTraceString(e));
|
|
||||||
((MainActivity) getActivity()).showSnackbarAbovePlayer(e.getLocalizedMessage(), Snackbar.LENGTH_LONG);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -369,7 +369,7 @@ public class FeedInfoFragment extends Fragment {
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe(
|
.subscribe(
|
||||||
() -> ((MainActivity) getActivity())
|
() -> ((MainActivity) getActivity())
|
||||||
.showSnackbarAbovePlayer(R.string.add_local_folder_success, Snackbar.LENGTH_SHORT),
|
.showSnackbarAbovePlayer(android.R.string.ok, Snackbar.LENGTH_SHORT),
|
||||||
error -> ((MainActivity) getActivity())
|
error -> ((MainActivity) getActivity())
|
||||||
.showSnackbarAbovePlayer(error.getLocalizedMessage(), Snackbar.LENGTH_LONG));
|
.showSnackbarAbovePlayer(error.getLocalizedMessage(), Snackbar.LENGTH_LONG));
|
||||||
}
|
}
|
||||||
|
|
|
@ -742,7 +742,6 @@
|
||||||
<string name="discover_powered_by_itunes">Suggestions by iTunes</string>
|
<string name="discover_powered_by_itunes">Suggestions by iTunes</string>
|
||||||
<string name="search_powered_by">Results by %1$s</string>
|
<string name="search_powered_by">Results by %1$s</string>
|
||||||
<string name="add_local_folder">Add local folder</string>
|
<string name="add_local_folder">Add local folder</string>
|
||||||
<string name="add_local_folder_success">Adding local folder succeeded</string>
|
|
||||||
<string name="reconnect_local_folder">Re-connect local folder</string>
|
<string name="reconnect_local_folder">Re-connect local folder</string>
|
||||||
<string name="reconnect_local_folder_warning">In case of permission denials, you can use this to re-connect to the exact same folder. Do not select another folder.</string>
|
<string name="reconnect_local_folder_warning">In case of permission denials, you can use this to re-connect to the exact same folder. Do not select another folder.</string>
|
||||||
<string name="local_feed_description">This virtual podcast was created by adding a folder to AntennaPod.</string>
|
<string name="local_feed_description">This virtual podcast was created by adding a folder to AntennaPod.</string>
|
||||||
|
|
Loading…
Reference in New Issue