{"action":"created","comment":{"url":"https://api.github.com/repos/nextcloud/android/pulls/comments/174724818","pull_request_review_id":104131022,"id":174724818,"diff_hunk":"@@ -528,55 +528,62 @@ private Bitmap doThumbnailFromOCFileInBackground() {\n                     }\n \n                 } else {\n-                    // Download thumbnail from server\n-                    OwnCloudVersion serverOCVersion = AccountUtils.getServerVersion(mAccount);\n-                    if (mClient != null && serverOCVersion != null) {\n-                        if (serverOCVersion.supportsRemoteThumbnails()) {\n-                            getMethod = null;\n-                            try {\n-                                // thumbnail\n-                                String uri = mClient.getBaseUri() + \"/index.php/apps/files/api/v1/thumbnail/\" +\n-                                        pxW + \"/\" + pxH + Uri.encode(file.getRemotePath(), \"/\");\n-                                Log_OC.d(TAG, \"generate thumbnail: \" + file.getFileName() +\n-                                        \" URI: \" + uri);\n-                                getMethod = new GetMethod(uri);\n-                                getMethod.setRequestHeader(\"Cookie\",\n-                                        \"nc_sameSiteCookielax=true;nc_sameSiteCookiestrict=true\");\n-\n-                                getMethod.setRequestHeader(RemoteOperation.OCS_API_HEADER,\n-                                        RemoteOperation.OCS_API_HEADER_VALUE);\n-\n-                                int status = mClient.executeMethod(getMethod);\n-                                if (status == HttpStatus.SC_OK) {\n-                                    InputStream inputStream = getMethod.getResponseBodyAsStream();\n-                                    Bitmap bitmap = BitmapFactory.decodeStream(inputStream);\n-                                    thumbnail = ThumbnailUtils.extractThumbnail(bitmap, pxW, pxH);\n-                                } else {\n-                                    mClient.exhaustResponse(getMethod.getResponseBodyAsStream());\n-                                }\n-\n-                                // Handle PNG\n-                                if (file.getMimetype().equalsIgnoreCase(PNG_MIMETYPE)) {\n-                                    thumbnail = handlePNG(thumbnail, pxW, pxH);\n-                                }\n+                    // check if resized version is available\n+                    String resizedImageKey = PREFIX_RESIZED_IMAGE + String.valueOf(file.getRemoteId());\n+                    Bitmap resizedImage = getBitmapFromDiskCache(resizedImageKey);\n \n-                                // Add thumbnail to cache\n-                                if (thumbnail != null) {\n-                                    Log_OC.d(TAG, \"add thumbnail to cache: \" + file.getFileName());\n-                                    addBitmapToCache(imageKey, thumbnail);\n-                                }\n-\n-                            } catch (Exception e) {\n-                                Log_OC.d(TAG, e.getMessage(), e);\n-                            } finally {\n-                                if (getMethod != null) {\n-                                    getMethod.releaseConnection();\n+                    if (resizedImage != null) {\n+                        thumbnail = ThumbnailUtils.extractThumbnail(resizedImage, pxW, pxH);\n+                    } else {\n+                        // Download thumbnail from server\n+                        OwnCloudVersion serverOCVersion = AccountUtils.getServerVersion(mAccount);\n+                        if (mClient != null && serverOCVersion != null) {\n+                            if (serverOCVersion.supportsRemoteThumbnails()) {","path":"src/main/java/com/owncloud/android/datamodel/ThumbnailsCacheManager.java","position":56,"original_position":56,"commit_id":"488664c86049948bdf99b8e2cbbdf60d09e22952","original_commit_id":"488664c86049948bdf99b8e2cbbdf60d09e22952","user":{"login":"mario","id":5810,"avatar_url":"https://avatars3.githubusercontent.com/u/5810?v=4","gravatar_id":"","url":"https://api.github.com/users/mario","html_url":"https://github.com/mario","followers_url":"https://api.github.com/users/mario/followers","following_url":"https://api.github.com/users/mario/following{/other_user}","gists_url":"https://api.github.com/users/mario/gists{/gist_id}","starred_url":"https://api.github.com/users/mario/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mario/subscriptions","organizations_url":"https://api.github.com/users/mario/orgs","repos_url":"https://api.github.com/users/mario/repos","events_url":"https://api.github.com/users/mario/events{/privacy}","received_events_url":"https://api.github.com/users/mario/received_events","type":"User","site_admin":false},"body":"please use AccountUtils.getServerVersion(mAccount).supportsRemoteThumbnails() where possible.\r\n\r\nAlso put if (mClient != null && AccountUtils.getServerVersion(mAccount).supportsRemoteThumbnails()) in the else above.","created_at":"2018-03-15T09:44:35Z","updated_at":"2018-03-15T09:44:35Z","html_url":"https://github.com/nextcloud/android/pull/2183#discussion_r174724818","pull_request_url":"https://api.github.com/repos/nextcloud/android/pulls/2183","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/nextcloud/android/pulls/comments/174724818"},"html":{"href":"https://github.com/nextcloud/android/pull/2183#discussion_r174724818"},"pull_request":{"href":"https://api.github.com/repos/nextcloud/android/pulls/2183"}}},"pull_request":{"url":"https://api.github.com/repos/nextcloud/android/pulls/2183","id":169369051,"html_url":"https://github.com/nextcloud/android/pull/2183","diff_url":"https://github.com/nextcloud/android/pull/2183.diff","patch_url":"https://github.com/nextcloud/android/pull/2183.patch","issue_url":"https://api.github.com/repos/nextcloud/android/issues/2183","number":2183,"state":"open","locked":false,"title":"If no thumbnail exists, check if resized version exist and use this","user":{"login":"tobiasKaminsky","id":5836855,"avatar_url":"https://avatars3.githubusercontent.com/u/5836855?v=4","gravatar_id":"","url":"https://api.github.com/users/tobiasKaminsky","html_url":"https://github.com/tobiasKaminsky","followers_url":"https://api.github.com/users/tobiasKaminsky/followers","following_url":"https://api.github.com/users/tobiasKaminsky/following{/other_user}","gists_url":"https://api.github.com/users/tobiasKaminsky/gists{/gist_id}","starred_url":"https://api.github.com/users/tobiasKaminsky/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tobiasKaminsky/subscriptions","organizations_url":"https://api.github.com/users/tobiasKaminsky/orgs","repos_url":"https://api.github.com/users/tobiasKaminsky/repos","events_url":"https://api.github.com/users/tobiasKaminsky/events{/privacy}","received_events_url":"https://api.github.com/users/tobiasKaminsky/received_events","type":"User","site_admin":false},"body":"This is useful if you have a very large image folder, scroll to a decent point and then immediately click on an image. While swiping the resized version is fetched.\r\nIf you then browse the file listing, the app would download the thumbnails, but now uses the resized images as source.\r\n\r\nSigned-off-by: tobiasKaminsky <tobias@kaminsky.me>","created_at":"2018-02-15T13:19:25Z","updated_at":"2018-03-15T09:44:35Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9da43341cf243b60e46a778185c86e3905ae05b0","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":392413889,"url":"https://api.github.com/repos/nextcloud/android/labels/2.%20to%20review","name":"2. to review","color":"0052cc","default":false}],"milestone":{"url":"https://api.github.com/repos/nextcloud/android/milestones/16","html_url":"https://github.com/nextcloud/android/milestone/16","labels_url":"https://api.github.com/repos/nextcloud/android/milestones/16/labels","id":2900336,"number":16,"title":"Nextcloud App 3.1.0","description":"","creator":{"login":"AndyScherzinger","id":1315170,"avatar_url":"https://avatars3.githubusercontent.com/u/1315170?v=4","gravatar_id":"","url":"https://api.github.com/users/AndyScherzinger","html_url":"https://github.com/AndyScherzinger","followers_url":"https://api.github.com/users/AndyScherzinger/followers","following_url":"https://api.github.com/users/AndyScherzinger/following{/other_user}","gists_url":"https://api.github.com/users/AndyScherzinger/gists{/gist_id}","starred_url":"https://api.github.com/users/AndyScherzinger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AndyScherzinger/subscriptions","organizations_url":"https://api.github.com/users/AndyScherzinger/orgs","repos_url":"https://api.github.com/users/AndyScherzinger/repos","events_url":"https://api.github.com/users/AndyScherzinger/events{/privacy}","received_events_url":"https://api.github.com/users/AndyScherzinger/received_events","type":"User","site_admin":false},"open_issues":39,"closed_issues":76,"state":"open","created_at":"2017-11-09T09:36:26Z","updated_at":"2018-03-15T09:40:58Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/nextcloud/android/pulls/2183/commits","review_comments_url":"https://api.github.com/repos/nextcloud/android/pulls/2183/comments","review_comment_url":"https://api.github.com/repos/nextcloud/android/pulls/comments{/number}","comments_url":"https://api.github.com/repos/nextcloud/android/issues/2183/comments","statuses_url":"https://api.github.com/repos/nextcloud/android/statuses/488664c86049948bdf99b8e2cbbdf60d09e22952","head":{"label":"nextcloud:generateThumbnailFromResizedImage","ref":"generateThumbnailFromResizedImage","sha":"488664c86049948bdf99b8e2cbbdf60d09e22952","user":{"login":"nextcloud","id":19211038,"avatar_url":"https://avatars1.githubusercontent.com/u/19211038?v=4","gravatar_id":"","url":"https://api.github.com/users/nextcloud","html_url":"https://github.com/nextcloud","followers_url":"https://api.github.com/users/nextcloud/followers","following_url":"https://api.github.com/users/nextcloud/following{/other_user}","gists_url":"https://api.github.com/users/nextcloud/gists{/gist_id}","starred_url":"https://api.github.com/users/nextcloud/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nextcloud/subscriptions","organizations_url":"https://api.github.com/users/nextcloud/orgs","repos_url":"https://api.github.com/users/nextcloud/repos","events_url":"https://api.github.com/users/nextcloud/events{/privacy}","received_events_url":"https://api.github.com/users/nextcloud/received_events","type":"Organization","site_admin":false},"repo":{"id":60561834,"name":"android","full_name":"nextcloud/android","owner":{"login":"nextcloud","id":19211038,"avatar_url":"https://avatars1.githubusercontent.com/u/19211038?v=4","gravatar_id":"","url":"https://api.github.com/users/nextcloud","html_url":"https://github.com/nextcloud","followers_url":"https://api.github.com/users/nextcloud/followers","following_url":"https://api.github.com/users/nextcloud/following{/other_user}","gists_url":"https://api.github.com/users/nextcloud/gists{/gist_id}","starred_url":"https://api.github.com/users/nextcloud/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nextcloud/subscriptions","organizations_url":"https://api.github.com/users/nextcloud/orgs","repos_url":"https://api.github.com/users/nextcloud/repos","events_url":"https://api.github.com/users/nextcloud/events{/privacy}","received_events_url":"https://api.github.com/users/nextcloud/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/nextcloud/android","description":"📱 Nextcloud Android app","fork":false,"url":"https://api.github.com/repos/nextcloud/android","forks_url":"https://api.github.com/repos/nextcloud/android/forks","keys_url":"https://api.github.com/repos/nextcloud/android/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nextcloud/android/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nextcloud/android/teams","hooks_url":"https://api.github.com/repos/nextcloud/android/hooks","issue_events_url":"https://api.github.com/repos/nextcloud/android/issues/events{/number}","events_url":"https://api.github.com/repos/nextcloud/android/events","assignees_url":"https://api.github.com/repos/nextcloud/android/assignees{/user}","branches_url":"https://api.github.com/repos/nextcloud/android/branches{/branch}","tags_url":"https://api.github.com/repos/nextcloud/android/tags","blobs_url":"https://api.github.com/repos/nextcloud/android/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nextcloud/android/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nextcloud/android/git/refs{/sha}","trees_url":"https://api.github.com/repos/nextcloud/android/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nextcloud/android/statuses/{sha}","languages_url":"https://api.github.com/repos/nextcloud/android/languages","stargazers_url":"https://api.github.com/repos/nextcloud/android/stargazers","contributors_url":"https://api.github.com/repos/nextcloud/android/contributors","subscribers_url":"https://api.github.com/repos/nextcloud/android/subscribers","subscription_url":"https://api.github.com/repos/nextcloud/android/subscription","commits_url":"https://api.github.com/repos/nextcloud/android/commits{/sha}","git_commits_url":"https://api.github.com/repos/nextcloud/android/git/commits{/sha}","comments_url":"https://api.github.com/repos/nextcloud/android/comments{/number}","issue_comment_url":"https://api.github.com/repos/nextcloud/android/issues/comments{/number}","contents_url":"https://api.github.com/repos/nextcloud/android/contents/{+path}","compare_url":"https://api.github.com/repos/nextcloud/android/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nextcloud/android/merges","archive_url":"https://api.github.com/repos/nextcloud/android/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nextcloud/android/downloads","issues_url":"https://api.github.com/repos/nextcloud/android/issues{/number}","pulls_url":"https://api.github.com/repos/nextcloud/android/pulls{/number}","milestones_url":"https://api.github.com/repos/nextcloud/android/milestones{/number}","notifications_url":"https://api.github.com/repos/nextcloud/android/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nextcloud/android/labels{/name}","releases_url":"https://api.github.com/repos/nextcloud/android/releases{/id}","deployments_url":"https://api.github.com/repos/nextcloud/android/deployments","created_at":"2016-06-06T21:23:36Z","updated_at":"2018-03-15T09:42:15Z","pushed_at":"2018-03-15T09:42:11Z","git_url":"git://github.com/nextcloud/android.git","ssh_url":"git@github.com:nextcloud/android.git","clone_url":"https://github.com/nextcloud/android.git","svn_url":"https://github.com/nextcloud/android","homepage":"https://play.google.com/store/apps/details?id=com.nextcloud.client","size":288044,"stargazers_count":656,"watchers_count":656,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":363,"mirror_url":null,"archived":false,"open_issues_count":540,"license":{"key":"gpl-2.0","name":"GNU General Public License v2.0","spdx_id":"GPL-2.0","url":"https://api.github.com/licenses/gpl-2.0"},"forks":363,"open_issues":540,"watchers":656,"default_branch":"master"}},"base":{"label":"nextcloud:master","ref":"master","sha":"0cafb86e28ee8a87a81da5b18e06ea5a9926e57d","user":{"login":"nextcloud","id":19211038,"avatar_url":"https://avatars1.githubusercontent.com/u/19211038?v=4","gravatar_id":"","url":"https://api.github.com/users/nextcloud","html_url":"https://github.com/nextcloud","followers_url":"https://api.github.com/users/nextcloud/followers","following_url":"https://api.github.com/users/nextcloud/following{/other_user}","gists_url":"https://api.github.com/users/nextcloud/gists{/gist_id}","starred_url":"https://api.github.com/users/nextcloud/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nextcloud/subscriptions","organizations_url":"https://api.github.com/users/nextcloud/orgs","repos_url":"https://api.github.com/users/nextcloud/repos","events_url":"https://api.github.com/users/nextcloud/events{/privacy}","received_events_url":"https://api.github.com/users/nextcloud/received_events","type":"Organization","site_admin":false},"repo":{"id":60561834,"name":"android","full_name":"nextcloud/android","owner":{"login":"nextcloud","id":19211038,"avatar_url":"https://avatars1.githubusercontent.com/u/19211038?v=4","gravatar_id":"","url":"https://api.github.com/users/nextcloud","html_url":"https://github.com/nextcloud","followers_url":"https://api.github.com/users/nextcloud/followers","following_url":"https://api.github.com/users/nextcloud/following{/other_user}","gists_url":"https://api.github.com/users/nextcloud/gists{/gist_id}","starred_url":"https://api.github.com/users/nextcloud/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nextcloud/subscriptions","organizations_url":"https://api.github.com/users/nextcloud/orgs","repos_url":"https://api.github.com/users/nextcloud/repos","events_url":"https://api.github.com/users/nextcloud/events{/privacy}","received_events_url":"https://api.github.com/users/nextcloud/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/nextcloud/android","description":"📱 Nextcloud Android app","fork":false,"url":"https://api.github.com/repos/nextcloud/android","forks_url":"https://api.github.com/repos/nextcloud/android/forks","keys_url":"https://api.github.com/repos/nextcloud/android/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nextcloud/android/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nextcloud/android/teams","hooks_url":"https://api.github.com/repos/nextcloud/android/hooks","issue_events_url":"https://api.github.com/repos/nextcloud/android/issues/events{/number}","events_url":"https://api.github.com/repos/nextcloud/android/events","assignees_url":"https://api.github.com/repos/nextcloud/android/assignees{/user}","branches_url":"https://api.github.com/repos/nextcloud/android/branches{/branch}","tags_url":"https://api.github.com/repos/nextcloud/android/tags","blobs_url":"https://api.github.com/repos/nextcloud/android/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nextcloud/android/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nextcloud/android/git/refs{/sha}","trees_url":"https://api.github.com/repos/nextcloud/android/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nextcloud/android/statuses/{sha}","languages_url":"https://api.github.com/repos/nextcloud/android/languages","stargazers_url":"https://api.github.com/repos/nextcloud/android/stargazers","contributors_url":"https://api.github.com/repos/nextcloud/android/contributors","subscribers_url":"https://api.github.com/repos/nextcloud/android/subscribers","subscription_url":"https://api.github.com/repos/nextcloud/android/subscription","commits_url":"https://api.github.com/repos/nextcloud/android/commits{/sha}","git_commits_url":"https://api.github.com/repos/nextcloud/android/git/commits{/sha}","comments_url":"https://api.github.com/repos/nextcloud/android/comments{/number}","issue_comment_url":"https://api.github.com/repos/nextcloud/android/issues/comments{/number}","contents_url":"https://api.github.com/repos/nextcloud/android/contents/{+path}","compare_url":"https://api.github.com/repos/nextcloud/android/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nextcloud/android/merges","archive_url":"https://api.github.com/repos/nextcloud/android/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nextcloud/android/downloads","issues_url":"https://api.github.com/repos/nextcloud/android/issues{/number}","pulls_url":"https://api.github.com/repos/nextcloud/android/pulls{/number}","milestones_url":"https://api.github.com/repos/nextcloud/android/milestones{/number}","notifications_url":"https://api.github.com/repos/nextcloud/android/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nextcloud/android/labels{/name}","releases_url":"https://api.github.com/repos/nextcloud/android/releases{/id}","deployments_url":"https://api.github.com/repos/nextcloud/android/deployments","created_at":"2016-06-06T21:23:36Z","updated_at":"2018-03-15T09:42:15Z","pushed_at":"2018-03-15T09:42:11Z","git_url":"git://github.com/nextcloud/android.git","ssh_url":"git@github.com:nextcloud/android.git","clone_url":"https://github.com/nextcloud/android.git","svn_url":"https://github.com/nextcloud/android","homepage":"https://play.google.com/store/apps/details?id=com.nextcloud.client","size":288044,"stargazers_count":656,"watchers_count":656,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":363,"mirror_url":null,"archived":false,"open_issues_count":540,"license":{"key":"gpl-2.0","name":"GNU General Public License v2.0","spdx_id":"GPL-2.0","url":"https://api.github.com/licenses/gpl-2.0"},"forks":363,"open_issues":540,"watchers":656,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/nextcloud/android/pulls/2183"},"html":{"href":"https://github.com/nextcloud/android/pull/2183"},"issue":{"href":"https://api.github.com/repos/nextcloud/android/issues/2183"},"comments":{"href":"https://api.github.com/repos/nextcloud/android/issues/2183/comments"},"review_comments":{"href":"https://api.github.com/repos/nextcloud/android/pulls/2183/comments"},"review_comment":{"href":"https://api.github.com/repos/nextcloud/android/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/nextcloud/android/pulls/2183/commits"},"statuses":{"href":"https://api.github.com/repos/nextcloud/android/statuses/488664c86049948bdf99b8e2cbbdf60d09e22952"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"mario"}}