зеркало из https://github.com/mozilla/gecko-dev.git
Bug 904551 - Stop using deprecated managedQuery api. r=lucasr
This commit is contained in:
Родитель
0904ed4341
Коммит
444057f160
|
@ -7,8 +7,14 @@ package org.mozilla.gecko;
|
||||||
import org.mozilla.gecko.util.ActivityResultHandler;
|
import org.mozilla.gecko.util.ActivityResultHandler;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
import android.support.v4.app.FragmentActivity;
|
||||||
|
import android.support.v4.app.LoaderManager;
|
||||||
|
import android.support.v4.app.LoaderManager.LoaderCallbacks;
|
||||||
|
import android.support.v4.content.CursorLoader;
|
||||||
|
import android.support.v4.content.Loader;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
|
import android.os.Bundle;
|
||||||
import android.provider.MediaStore;
|
import android.provider.MediaStore;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
|
@ -40,20 +46,37 @@ class CameraVideoResultHandler implements ActivityResultHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onActivityResult(int resultCode, Intent data) {
|
public void onActivityResult(int resultCode, final Intent data) {
|
||||||
// Intent.getData() can return null. Avoid a crash. See bug 904551.
|
// Intent.getData() can return null. Avoid a crash. See bug 904551.
|
||||||
if (data == null || data.getData() == null || resultCode != Activity.RESULT_OK) {
|
if (data == null || data.getData() == null || resultCode != Activity.RESULT_OK) {
|
||||||
sendResult("");
|
sendResult("");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Cursor cursor = GeckoAppShell.getGeckoInterface().getActivity().managedQuery(data.getData(),
|
final FragmentActivity fa = (FragmentActivity) GeckoAppShell.getGeckoInterface().getActivity();
|
||||||
new String[] { MediaStore.Video.Media.DATA },
|
final LoaderManager lm = fa.getSupportLoaderManager();
|
||||||
null,
|
lm.initLoader(data.hashCode(), null, new LoaderCallbacks<Cursor>() {
|
||||||
null,
|
@Override
|
||||||
null);
|
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
|
||||||
cursor.moveToFirst();
|
return new CursorLoader(fa,
|
||||||
|
data.getData(),
|
||||||
|
new String[] { MediaStore.Video.Media.DATA },
|
||||||
|
null, // selection
|
||||||
|
null, // selectionArgs
|
||||||
|
null); // sortOrder
|
||||||
|
}
|
||||||
|
|
||||||
sendResult(cursor.getString(cursor.getColumnIndexOrThrow(MediaStore.Video.Media.DATA)));
|
@Override
|
||||||
|
public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) {
|
||||||
|
if (cursor.moveToFirst()) {
|
||||||
|
sendResult(cursor.getString(cursor.getColumnIndexOrThrow(MediaStore.Video.Media.DATA)));
|
||||||
|
} else {
|
||||||
|
sendResult("");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onLoaderReset(Loader<Cursor> loader) { }
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче