Fix moreee bugs
This commit is contained in:
parent
13e469f269
commit
59fde090ad
|
@ -1,6 +1,7 @@
|
||||||
package com.blankie.fileify;
|
package com.blankie.fileify;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
import android.widget.Toast;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.ActivityNotFoundException;
|
import android.content.ActivityNotFoundException;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
@ -10,12 +11,6 @@ import com.blankie.fileify.R;
|
||||||
public class PickActivity extends Activity {
|
public class PickActivity extends Activity {
|
||||||
public static final String TAG = "fileify";
|
public static final String TAG = "fileify";
|
||||||
|
|
||||||
private void logAndToast(int priority, String msg) {
|
|
||||||
Log.println(priority, TAG, msg);
|
|
||||||
Toast.makeText(getApplicationContext(), msg, Toast.LENGH_SHORT)
|
|
||||||
.show();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
@ -41,8 +36,10 @@ public class PickActivity extends Activity {
|
||||||
try {
|
try {
|
||||||
startActivityForResult(newIntent, 0);
|
startActivityForResult(newIntent, 0);
|
||||||
} catch (ActivityNotFoundException e) {
|
} catch (ActivityNotFoundException e) {
|
||||||
logAndToast(Log.ERROR, R.string.no_activity);
|
Log.e(TAG, getString(R.string.no_activity));
|
||||||
setResult(RESULT_CANCELLED);
|
Toast.makeText(getApplicationContext(), msg, Toast.LENGH_SHORT)
|
||||||
|
.show();
|
||||||
|
setResult(Activity.RESULT_CANCELLED);
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -55,13 +52,13 @@ public class PickActivity extends Activity {
|
||||||
|
|
||||||
if (resultCode != RESULT_OK) {
|
if (resultCode != RESULT_OK) {
|
||||||
Log.d(TAG, "Received resultCode = " + resultCode);
|
Log.d(TAG, "Received resultCode = " + resultCode);
|
||||||
setResult(RESULT_CANCELLED);
|
setResult(Activity.RESULT_CANCELLED);
|
||||||
finish();
|
finish();
|
||||||
// probably not necessary but just in case or something
|
// probably not necessary but just in case or something
|
||||||
return;
|
return;
|
||||||
} else if (data == null) {
|
} else if (data == null) {
|
||||||
Log.d(TAG, "Received data = null");
|
Log.d(TAG, "Received data = null");
|
||||||
setResult(RESULT_CANCELLED);
|
setResult(Activity.RESULT_CANCELLED);
|
||||||
finish();
|
finish();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -70,14 +67,14 @@ public class PickActivity extends Activity {
|
||||||
intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||||
if (data.getData() != null) {
|
if (data.getData() != null) {
|
||||||
intent.setData(data.getData());
|
intent.setData(data.getData());
|
||||||
setResult(RESULT_OK, intent);
|
setResult(Activity.RESULT_OK, intent);
|
||||||
} else if (data.getClipData() != null) {
|
} else if (data.getClipData() != null) {
|
||||||
// unsafe?
|
// unsafe?
|
||||||
intent.setClipData(data.getClipData());
|
intent.setClipData(data.getClipData());
|
||||||
setResult(RESULT_OK, intent);
|
setResult(Activity.RESULT_OK, intent);
|
||||||
} else {
|
} else {
|
||||||
Log.d(TAG, "Received data.getData() = null and data.getClipData() = null");
|
Log.d(TAG, "Received data.getData() = null and data.getClipData() = null");
|
||||||
setResult(RESULT_CANCELLED);
|
setResult(Activity.RESULT_CANCELLED);
|
||||||
}
|
}
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue