fixed app crashing when using links that have data missing
This commit is contained in:
parent
4a387ea0cf
commit
8f533ab67e
5 changed files with 54 additions and 18 deletions
|
|
@ -77,9 +77,15 @@ public class DownloadsRecyclerViewAdapter extends RecyclerView.Adapter<Downloads
|
||||||
ImageView thumbnail = card.findViewById(R.id.downloads_image_view);
|
ImageView thumbnail = card.findViewById(R.id.downloads_image_view);
|
||||||
String imageURL= video.getThumb();
|
String imageURL= video.getThumb();
|
||||||
|
|
||||||
Handler uiHandler = new Handler(Looper.getMainLooper());
|
if (!imageURL.isEmpty()){
|
||||||
uiHandler.post(() -> Picasso.get().load(imageURL).into(thumbnail));
|
Handler uiHandler = new Handler(Looper.getMainLooper());
|
||||||
thumbnail.setColorFilter(Color.argb(70, 0, 0, 0));
|
uiHandler.post(() -> Picasso.get().load(imageURL).into(thumbnail));
|
||||||
|
thumbnail.setColorFilter(Color.argb(70, 0, 0, 0));
|
||||||
|
}else {
|
||||||
|
Handler uiHandler = new Handler(Looper.getMainLooper());
|
||||||
|
uiHandler.post(() -> Picasso.get().load(R.color.black).into(thumbnail));
|
||||||
|
thumbnail.setColorFilter(Color.argb(70, 0, 0, 0));
|
||||||
|
}
|
||||||
|
|
||||||
// TITLE ----------------------------------
|
// TITLE ----------------------------------
|
||||||
TextView videoTitle = card.findViewById(R.id.downloads_title);
|
TextView videoTitle = card.findViewById(R.id.downloads_title);
|
||||||
|
|
@ -92,7 +98,11 @@ public class DownloadsRecyclerViewAdapter extends RecyclerView.Adapter<Downloads
|
||||||
|
|
||||||
// Bottom Info ----------------------------------
|
// Bottom Info ----------------------------------
|
||||||
TextView bottomInfo = card.findViewById(R.id.downloads_info_bottom);
|
TextView bottomInfo = card.findViewById(R.id.downloads_info_bottom);
|
||||||
String info = video.getAuthor() + " • " + video.getDuration();
|
String info = video.getAuthor();
|
||||||
|
if (!video.getDuration().isEmpty()){
|
||||||
|
if (!video.getAuthor().isEmpty()) info += " • ";
|
||||||
|
info += video.getDuration();
|
||||||
|
}
|
||||||
bottomInfo.setText(info);
|
bottomInfo.setText(info);
|
||||||
|
|
||||||
// TIME DOWNLOADED ----------------------------------
|
// TIME DOWNLOADED ----------------------------------
|
||||||
|
|
|
||||||
|
|
@ -67,10 +67,15 @@ public class HomeRecyclerViewAdapter extends RecyclerView.Adapter<HomeRecyclerVi
|
||||||
// THUMBNAIL ----------------------------------
|
// THUMBNAIL ----------------------------------
|
||||||
ImageView thumbnail = card.findViewById(R.id.result_image_view);
|
ImageView thumbnail = card.findViewById(R.id.result_image_view);
|
||||||
String imageURL= video.getThumb();
|
String imageURL= video.getThumb();
|
||||||
|
if (!imageURL.isEmpty()){
|
||||||
Handler uiHandler = new Handler(Looper.getMainLooper());
|
Handler uiHandler = new Handler(Looper.getMainLooper());
|
||||||
uiHandler.post(() -> Picasso.get().load(imageURL).into(thumbnail));
|
uiHandler.post(() -> Picasso.get().load(imageURL).into(thumbnail));
|
||||||
thumbnail.setColorFilter(Color.argb(70, 0, 0, 0));
|
thumbnail.setColorFilter(Color.argb(70, 0, 0, 0));
|
||||||
|
}else {
|
||||||
|
Handler uiHandler = new Handler(Looper.getMainLooper());
|
||||||
|
uiHandler.post(() -> Picasso.get().load(R.color.black).into(thumbnail));
|
||||||
|
thumbnail.setColorFilter(Color.argb(70, 0, 0, 0));
|
||||||
|
}
|
||||||
|
|
||||||
// TITLE ----------------------------------
|
// TITLE ----------------------------------
|
||||||
TextView videoTitle = card.findViewById(R.id.result_title);
|
TextView videoTitle = card.findViewById(R.id.result_title);
|
||||||
|
|
@ -84,7 +89,11 @@ public class HomeRecyclerViewAdapter extends RecyclerView.Adapter<HomeRecyclerVi
|
||||||
// Bottom Info ----------------------------------
|
// Bottom Info ----------------------------------
|
||||||
|
|
||||||
TextView bottomInfo = card.findViewById(R.id.result_info_bottom);
|
TextView bottomInfo = card.findViewById(R.id.result_info_bottom);
|
||||||
String info = video.getAuthor() + " • " + video.getDuration();
|
String info = video.getAuthor();
|
||||||
|
if (!video.getDuration().isEmpty()){
|
||||||
|
if (!video.getAuthor().isEmpty()) info += " • ";
|
||||||
|
info += video.getDuration();
|
||||||
|
}
|
||||||
bottomInfo.setText(info);
|
bottomInfo.setText(info);
|
||||||
|
|
||||||
// BUTTONS ----------------------------------
|
// BUTTONS ----------------------------------
|
||||||
|
|
|
||||||
|
|
@ -262,7 +262,7 @@ public class HomeFragment extends Fragment implements HomeRecyclerViewAdapter.On
|
||||||
try{
|
try{
|
||||||
new Handler(Looper.getMainLooper()).post(() -> {
|
new Handler(Looper.getMainLooper()).post(() -> {
|
||||||
// DOWNLOAD ALL BUTTON
|
// DOWNLOAD ALL BUTTON
|
||||||
if (resultObjects.get(0).getIsPlaylistItem() == 1 || inputQueriesLength > 1) {
|
if ((resultObjects.size() > 1 && resultObjects.get(1).getIsPlaylistItem() == 1) || inputQueriesLength > 1) {
|
||||||
downloadAllFab.setVisibility(View.VISIBLE);
|
downloadAllFab.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
dbManager = new DBManager(context);
|
dbManager = new DBManager(context);
|
||||||
|
|
@ -385,7 +385,7 @@ public class HomeFragment extends Fragment implements HomeRecyclerViewAdapter.On
|
||||||
Thread thread = new Thread(() -> {
|
Thread thread = new Thread(() -> {
|
||||||
parseQuery(true);
|
parseQuery(true);
|
||||||
// DOWNLOAD ALL BUTTON
|
// DOWNLOAD ALL BUTTON
|
||||||
if (resultObjects.get(0).getIsPlaylistItem() == 1) {
|
if (resultObjects.size() > 1 && resultObjects.get(1).getIsPlaylistItem() == 1) {
|
||||||
new Handler(Looper.getMainLooper()).post(() -> downloadAllFab.setVisibility(View.VISIBLE));
|
new Handler(Looper.getMainLooper()).post(() -> downloadAllFab.setVisibility(View.VISIBLE));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -291,13 +291,30 @@ public class InfoUtil {
|
||||||
|
|
||||||
for (String result : results) {
|
for (String result : results) {
|
||||||
JSONObject jsonObject = new JSONObject(result);
|
JSONObject jsonObject = new JSONObject(result);
|
||||||
if (jsonObject.getString("title").equals("[Private video]")) continue;
|
|
||||||
|
String title = "";
|
||||||
|
if (jsonObject.has("title")){
|
||||||
|
if (jsonObject.getString("title").equals("[Private video]")) continue;
|
||||||
|
title = jsonObject.getString("title");
|
||||||
|
}else{
|
||||||
|
title = jsonObject.getString("webpage_url_basename");
|
||||||
|
}
|
||||||
|
|
||||||
|
String author = "";
|
||||||
|
if (jsonObject.has("uploader")){
|
||||||
|
author = jsonObject.getString("uploader");
|
||||||
|
}
|
||||||
|
|
||||||
|
String duration = "";
|
||||||
|
if (jsonObject.has("duration")){
|
||||||
|
duration = formatIntegerDuration(jsonObject.getInt("duration"));
|
||||||
|
}
|
||||||
|
|
||||||
String url = jsonObject.getString("webpage_url");
|
String url = jsonObject.getString("webpage_url");
|
||||||
String thumb = "";
|
String thumb = "";
|
||||||
if (jsonObject.has("thumbnail")){
|
if (jsonObject.has("thumbnail")){
|
||||||
thumb = jsonObject.getString("thumbnail");
|
thumb = jsonObject.getString("thumbnail");
|
||||||
}else {
|
}else if (jsonObject.has("thumbnails")){
|
||||||
JSONArray thumbs = jsonObject.getJSONArray("thumbnails");
|
JSONArray thumbs = jsonObject.getJSONArray("thumbnails");
|
||||||
thumb = thumbs.getJSONObject(thumbs.length()-1).getString("url");
|
thumb = thumbs.getJSONObject(thumbs.length()-1).getString("url");
|
||||||
}
|
}
|
||||||
|
|
@ -312,9 +329,9 @@ public class InfoUtil {
|
||||||
videos.add(new Video(
|
videos.add(new Video(
|
||||||
jsonObject.getString("id"),
|
jsonObject.getString("id"),
|
||||||
url,
|
url,
|
||||||
jsonObject.getString("title"),
|
title,
|
||||||
jsonObject.getString("uploader"),
|
author,
|
||||||
formatIntegerDuration(jsonObject.getInt("duration")),
|
duration,
|
||||||
thumb,
|
thumb,
|
||||||
dbManager.checkDownloaded(url, "audio"),
|
dbManager.checkDownloaded(url, "audio"),
|
||||||
dbManager.checkDownloaded(url, "video"),
|
dbManager.checkDownloaded(url, "video"),
|
||||||
|
|
|
||||||
|
|
@ -16,8 +16,8 @@ buildscript {
|
||||||
}
|
}
|
||||||
|
|
||||||
def versionMajor = 1
|
def versionMajor = 1
|
||||||
def versionMinor = 3
|
def versionMinor = 4
|
||||||
def versionPatch = 2
|
def versionPatch = 1
|
||||||
def versionBuild = 0 // bump for dogfood builds, public betas, etc.
|
def versionBuild = 0 // bump for dogfood builds, public betas, etc.
|
||||||
|
|
||||||
ext {
|
ext {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue