mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-02-23 07:31:56 +00:00
Fix a couple of crashes
This commit is contained in:
parent
94477df686
commit
7faf1cb3f3
@ -51,9 +51,11 @@ std::string ResolveUrl(std::string baseUrl, std::string url) {
|
|||||||
class HttpImageFileView : public UI::View {
|
class HttpImageFileView : public UI::View {
|
||||||
public:
|
public:
|
||||||
HttpImageFileView(http::Downloader *downloader, const std::string &path, UI::ImageSizeMode sizeMode = UI::IS_DEFAULT, UI::LayoutParams *layoutParams = 0)
|
HttpImageFileView(http::Downloader *downloader, const std::string &path, UI::ImageSizeMode sizeMode = UI::IS_DEFAULT, UI::LayoutParams *layoutParams = 0)
|
||||||
: UI::View(layoutParams), downloader_(downloader), path_(path), color_(0xFFFFFFFF), sizeMode_(sizeMode), texture_(nullptr), textureFailed_(false), fixedSizeW_(0.0f), fixedSizeH_(0.0f) {}
|
: UI::View(layoutParams), path_(path), color_(0xFFFFFFFF), sizeMode_(sizeMode), downloader_(downloader), texture_(nullptr), textureFailed_(false), fixedSizeW_(0.0f), fixedSizeH_(0.0f) {}
|
||||||
|
|
||||||
~HttpImageFileView() {
|
~HttpImageFileView() {
|
||||||
|
if (download_)
|
||||||
|
download_->Cancel();
|
||||||
delete texture_;
|
delete texture_;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,6 +121,10 @@ void HttpImageFileView::SetFilename(std::string filename) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void HttpImageFileView::DownloadCompletedCallback(http::Download &download) {
|
void HttpImageFileView::DownloadCompletedCallback(http::Download &download) {
|
||||||
|
if (download.IsCancelled()) {
|
||||||
|
// We were probably destroyed. Can't touch "this" (heh).
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (download.ResultCode() == 200) {
|
if (download.ResultCode() == 200) {
|
||||||
download.buffer().TakeAll(&textureData_);
|
download.buffer().TakeAll(&textureData_);
|
||||||
} else {
|
} else {
|
||||||
|
@ -740,40 +740,69 @@ public class NativeActivity extends Activity {
|
|||||||
|
|
||||||
public boolean processCommand(String command, String params) {
|
public boolean processCommand(String command, String params) {
|
||||||
if (command.equals("launchBrowser")) {
|
if (command.equals("launchBrowser")) {
|
||||||
Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(params));
|
|
||||||
startActivity(i);
|
|
||||||
return true;
|
|
||||||
} else if (command.equals("launchEmail")) {
|
|
||||||
Intent send = new Intent(Intent.ACTION_SENDTO);
|
|
||||||
String uriText;
|
|
||||||
uriText = "mailto:email@gmail.com" + "?subject=Your app is..."
|
|
||||||
+ "&body=great! Or?";
|
|
||||||
uriText = uriText.replace(" ", "%20");
|
|
||||||
Uri uri = Uri.parse(uriText);
|
|
||||||
send.setData(uri);
|
|
||||||
startActivity(Intent.createChooser(send, "E-mail the app author!"));
|
|
||||||
return true;
|
|
||||||
} else if (command.equals("sharejpeg")) {
|
|
||||||
Intent share = new Intent(Intent.ACTION_SEND);
|
|
||||||
share.setType("image/jpeg");
|
|
||||||
share.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + params));
|
|
||||||
startActivity(Intent.createChooser(share, "Share Picture"));
|
|
||||||
} else if (command.equals("sharetext")) {
|
|
||||||
Intent sendIntent = new Intent();
|
|
||||||
sendIntent.setType("text/plain");
|
|
||||||
sendIntent.putExtra(Intent.EXTRA_TEXT, params);
|
|
||||||
sendIntent.setAction(Intent.ACTION_SEND);
|
|
||||||
startActivity(sendIntent);
|
|
||||||
} else if (command.equals("showTwitter")) {
|
|
||||||
String twitter_user_name = params;
|
|
||||||
try {
|
try {
|
||||||
startActivity(new Intent(Intent.ACTION_VIEW,
|
Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(params));
|
||||||
Uri.parse("twitter://user?screen_name="
|
startActivity(i);
|
||||||
+ twitter_user_name)));
|
return true;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
startActivity(new Intent(
|
// No browser?
|
||||||
Intent.ACTION_VIEW,
|
Log.e(TAG, e.toString());
|
||||||
Uri.parse("https://twitter.com/#!/" + twitter_user_name)));
|
return false;
|
||||||
|
}
|
||||||
|
} else if (command.equals("launchEmail")) {
|
||||||
|
try {
|
||||||
|
Intent send = new Intent(Intent.ACTION_SENDTO);
|
||||||
|
String uriText;
|
||||||
|
uriText = "mailto:email@gmail.com" + "?subject=Your app is..."
|
||||||
|
+ "&body=great! Or?";
|
||||||
|
uriText = uriText.replace(" ", "%20");
|
||||||
|
Uri uri = Uri.parse(uriText);
|
||||||
|
send.setData(uri);
|
||||||
|
startActivity(Intent.createChooser(send, "E-mail the app author!"));
|
||||||
|
return true;
|
||||||
|
} catch (Exception e) { // For example, android.content.ActivityNotFoundException
|
||||||
|
Log.e(TAG, e.toString());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else if (command.equals("sharejpeg")) {
|
||||||
|
try {
|
||||||
|
Intent share = new Intent(Intent.ACTION_SEND);
|
||||||
|
share.setType("image/jpeg");
|
||||||
|
share.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + params));
|
||||||
|
startActivity(Intent.createChooser(share, "Share Picture"));
|
||||||
|
return true;
|
||||||
|
} catch (Exception e) { // For example, android.content.ActivityNotFoundException
|
||||||
|
Log.e(TAG, e.toString());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else if (command.equals("sharetext")) {
|
||||||
|
try {
|
||||||
|
Intent sendIntent = new Intent();
|
||||||
|
sendIntent.setType("text/plain");
|
||||||
|
sendIntent.putExtra(Intent.EXTRA_TEXT, params);
|
||||||
|
sendIntent.setAction(Intent.ACTION_SEND);
|
||||||
|
startActivity(sendIntent);
|
||||||
|
return true;
|
||||||
|
} catch (Exception e) { // For example, android.content.ActivityNotFoundException
|
||||||
|
Log.e(TAG, e.toString());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else if (command.equals("showTwitter")) {
|
||||||
|
try {
|
||||||
|
String twitter_user_name = params;
|
||||||
|
try {
|
||||||
|
startActivity(new Intent(Intent.ACTION_VIEW,
|
||||||
|
Uri.parse("twitter://user?screen_name="
|
||||||
|
+ twitter_user_name)));
|
||||||
|
} catch (Exception e) {
|
||||||
|
startActivity(new Intent(
|
||||||
|
Intent.ACTION_VIEW,
|
||||||
|
Uri.parse("https://twitter.com/#!/" + twitter_user_name)));
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
} catch (Exception e) { // For example, android.content.ActivityNotFoundException
|
||||||
|
Log.e(TAG, e.toString());
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
} else if (command.equals("launchMarket")) {
|
} else if (command.equals("launchMarket")) {
|
||||||
// Don't need this, can just use launchBrowser with a market:
|
// Don't need this, can just use launchBrowser with a market:
|
||||||
|
@ -104,6 +104,10 @@ public:
|
|||||||
cancelled_ = true;
|
cancelled_ = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IsCancelled() const {
|
||||||
|
return cancelled_;
|
||||||
|
}
|
||||||
|
|
||||||
// NOTE: Callbacks are NOT executed until RunCallback is called. This is so that
|
// NOTE: Callbacks are NOT executed until RunCallback is called. This is so that
|
||||||
// the call will end up on the thread that calls g_DownloadManager.Update().
|
// the call will end up on the thread that calls g_DownloadManager.Update().
|
||||||
void SetCallback(std::function<void(Download &)> callback) {
|
void SetCallback(std::function<void(Download &)> callback) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user