mirror of
https://github.com/owncloud/android-library.git
synced 2025-06-07 16:06:08 +00:00
Manage responses with no avatar
This commit is contained in:
parent
d997c84a80
commit
ac21650da7
@ -38,7 +38,7 @@ import java.net.URL
|
|||||||
class GetRemoteUserAvatarOperation(private val avatarDimension: Int) :
|
class GetRemoteUserAvatarOperation(private val avatarDimension: Int) :
|
||||||
RemoteOperation<RemoteAvatarData>() {
|
RemoteOperation<RemoteAvatarData>() {
|
||||||
override fun run(client: OwnCloudClient): RemoteOperationResult<RemoteAvatarData> {
|
override fun run(client: OwnCloudClient): RemoteOperationResult<RemoteAvatarData> {
|
||||||
lateinit var inputStream: InputStream
|
var inputStream: InputStream? = null
|
||||||
lateinit var getMethod: GetMethod
|
lateinit var getMethod: GetMethod
|
||||||
|
|
||||||
lateinit var result: RemoteOperationResult<RemoteAvatarData>
|
lateinit var result: RemoteOperationResult<RemoteAvatarData>
|
||||||
@ -71,7 +71,7 @@ class GetRemoteUserAvatarOperation(private val avatarDimension: Int) :
|
|||||||
Timber.d("Avatar size: Bytes received ${bytesArray.size} of $contentLength")
|
Timber.d("Avatar size: Bytes received ${bytesArray.size} of $contentLength")
|
||||||
|
|
||||||
// find out etag
|
// find out etag
|
||||||
val etag = WebdavUtils.getEtagFromResponse(getMethod);
|
val etag = WebdavUtils.getEtagFromResponse(getMethod)
|
||||||
if (etag.isEmpty()) {
|
if (etag.isEmpty()) {
|
||||||
Timber.w("Could not read Etag from avatar")
|
Timber.w("Could not read Etag from avatar")
|
||||||
}
|
}
|
||||||
@ -87,14 +87,14 @@ class GetRemoteUserAvatarOperation(private val avatarDimension: Int) :
|
|||||||
|
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
result = RemoteOperationResult(e)
|
result = RemoteOperationResult(e)
|
||||||
Timber.e(e, "Exception while getting OC user avatar");
|
Timber.e(e, "Exception while getting OC user avatar")
|
||||||
|
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
try {
|
||||||
client.exhaustResponse(inputStream);
|
client.exhaustResponse(inputStream)
|
||||||
inputStream.close()
|
inputStream?.close()
|
||||||
} catch (i: IOException) {
|
} catch (i: IOException) {
|
||||||
Timber.e(i, "Unexpected exception closing input stream");
|
Timber.e(i, "Unexpected exception closing input stream")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user