fixed crashes

This commit is contained in:
Mariotaku Lee 2016-07-16 18:35:54 +08:00
parent 5af50a7289
commit 991b54c37d
3 changed files with 7 additions and 5 deletions

View File

@ -19,6 +19,7 @@
package org.mariotaku.microblog.library.twitter.model;
import android.support.annotation.Nullable;
import android.support.annotation.StringDef;
import com.bluelinelabs.logansquare.annotation.JsonField;
@ -39,6 +40,7 @@ public class MediaUploadResponse extends TwitterResponseObject implements Twitte
@JsonField(name = "video")
Video video;
@JsonField(name = "processing_info")
@Nullable
ProcessingInfo processingInfo;
public String getId() {
@ -57,6 +59,7 @@ public class MediaUploadResponse extends TwitterResponseObject implements Twitte
return video;
}
@Nullable
public ProcessingInfo getProcessingInfo() {
return processingInfo;
}

View File

@ -450,8 +450,8 @@ class UpdateStatusTask(internal val context: Context, internal val stateCallback
}
response = upload.finalizeUploadMedia(response.id)
run {
var info: MediaUploadResponse.ProcessingInfo = response.processingInfo
while (shouldWaitForProcess(info)) {
var info: MediaUploadResponse.ProcessingInfo? = response.processingInfo
while (info != null && shouldWaitForProcess(info)) {
val checkAfterSecs = info.checkAfterSecs
if (checkAfterSecs <= 0) {
break
@ -482,8 +482,7 @@ class UpdateStatusTask(internal val context: Context, internal val stateCallback
return exception is MicroBlogException && exception.errorCode == ErrorInfo.STATUS_IS_DUPLICATE
}
private fun shouldWaitForProcess(info: MediaUploadResponse.ProcessingInfo?): Boolean {
if (info == null) return false
private fun shouldWaitForProcess(info: MediaUploadResponse.ProcessingInfo): Boolean {
when (info.state) {
MediaUploadResponse.ProcessingInfo.State.PENDING, MediaUploadResponse.ProcessingInfo.State.IN_PROGRESS -> return true
else -> return false

View File

@ -144,7 +144,7 @@ class QuickSearchBarActivity : BaseActivity(), OnClickListener, LoaderCallbacks<
}
}
override fun onItemSelected(parent: AdapterView<*>, view: View, position: Int, id: Long) {
override fun onItemSelected(parent: AdapterView<*>, view: View?, position: Int, id: Long) {
supportLoaderManager.restartLoader(0, null, this)
}