Thumbnail support
This commit is contained in:
		@ -289,6 +289,26 @@ public class Transfer {
 | 
				
			|||||||
        return fileList;
 | 
					        return fileList;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public InputStream getThumbnail(String href) {
 | 
				
			||||||
 | 
					        InputStream thumbnail = null;
 | 
				
			||||||
 | 
					            URL url;
 | 
				
			||||||
 | 
					            try {
 | 
				
			||||||
 | 
					                String query = URLEncoder.encode(href, StandardCharsets.UTF_8.toString());
 | 
				
			||||||
 | 
					                String serverUrl = root + "/thumbnail.php?file=" + query;
 | 
				
			||||||
 | 
					                url = new URL(protocol, host, port, serverUrl);
 | 
				
			||||||
 | 
					                HttpURLConnection conn = (HttpURLConnection) url.openConnection();
 | 
				
			||||||
 | 
					                conn.setRequestMethod("GET");
 | 
				
			||||||
 | 
					                conn.setConnectTimeout(2000);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                conn.connect();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                thumbnail = conn.getInputStream();
 | 
				
			||||||
 | 
					            } catch (IOException e) {
 | 
				
			||||||
 | 
					                e.printStackTrace();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        return thumbnail;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public void downloadFile(final Uri uri, String name, long fileSize, String href, Button button) throws IOException {
 | 
					    public void downloadFile(final Uri uri, String name, long fileSize, String href, Button button) throws IOException {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        /*final LinearLayout layout = activity.findViewById(id);
 | 
					        /*final LinearLayout layout = activity.findViewById(id);
 | 
				
			||||||
 | 
				
			|||||||
@ -4,6 +4,8 @@ import android.animation.ObjectAnimator;
 | 
				
			|||||||
import android.content.ActivityNotFoundException;
 | 
					import android.content.ActivityNotFoundException;
 | 
				
			||||||
import android.content.ContentValues;
 | 
					import android.content.ContentValues;
 | 
				
			||||||
import android.content.Intent;
 | 
					import android.content.Intent;
 | 
				
			||||||
 | 
					import android.graphics.Bitmap;
 | 
				
			||||||
 | 
					import android.graphics.BitmapFactory;
 | 
				
			||||||
import android.graphics.drawable.Drawable;
 | 
					import android.graphics.drawable.Drawable;
 | 
				
			||||||
import android.net.Uri;
 | 
					import android.net.Uri;
 | 
				
			||||||
import android.os.Bundle;
 | 
					import android.os.Bundle;
 | 
				
			||||||
@ -208,14 +210,19 @@ public class DownloadFragment extends Fragment {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
                    switch (type) {
 | 
					                    switch (type) {
 | 
				
			||||||
                        case "file-image":
 | 
					                        case "file-image":
 | 
				
			||||||
                            image.setImageResource(R.drawable.ic_icon_image);
 | 
					                        case "file-video":
 | 
				
			||||||
 | 
					                            //image.setImageResource(R.drawable.ic_icon_image);
 | 
				
			||||||
 | 
					                            new Thread(() -> {
 | 
				
			||||||
 | 
					                                InputStream thumbnail = tr.getThumbnail(href);
 | 
				
			||||||
 | 
					                                Bitmap bitmap = BitmapFactory.decodeStream(thumbnail);
 | 
				
			||||||
 | 
					                                getActivity().runOnUiThread(() -> {
 | 
				
			||||||
 | 
					                                        image.setImageBitmap(bitmap);
 | 
				
			||||||
 | 
					                                });
 | 
				
			||||||
 | 
					                            }).start();
 | 
				
			||||||
                            break;
 | 
					                            break;
 | 
				
			||||||
                        case "file-audio":
 | 
					                        case "file-audio":
 | 
				
			||||||
                            image.setImageResource(R.drawable.ic_icon_music);
 | 
					                            image.setImageResource(R.drawable.ic_icon_music);
 | 
				
			||||||
                            break;
 | 
					                            break;
 | 
				
			||||||
                        case "file-video":
 | 
					 | 
				
			||||||
                            image.setImageResource(R.drawable.ic_icon_video);
 | 
					 | 
				
			||||||
                            break;
 | 
					 | 
				
			||||||
                        default:
 | 
					                        default:
 | 
				
			||||||
                            image.setImageResource(R.drawable.ic_icon_file);
 | 
					                            image.setImageResource(R.drawable.ic_icon_file);
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user