refactor: 🔥 remove X support

This commit is contained in:
Michel Roux 2024-02-28 09:27:56 +01:00
parent 1c9dc4cca7
commit 9b2a65312a

View File

@ -6,6 +6,7 @@ import android.os.Bundle;
import android.widget.Toast;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URL;
public class MainActivity extends Activity {
@ -26,27 +27,15 @@ public class MainActivity extends Activity {
private void handleUrl(String textUrl) {
URL originalUrl;
URL fixedUrl;
try {
originalUrl = new URL(textUrl);
switch (originalUrl.getHost()) {
case "twitter.com":
case "t.co":
case "x.com":
fixedUrl = new URL(originalUrl.getProtocol(), "nitter.net", originalUrl.getPort(), originalUrl.getFile());
break;
default:
fixedUrl = originalUrl;
break;
}
} catch (MalformedURLException e) {
originalUrl = new URI(textUrl).toURL();
} catch (Exception e) {
Toast.makeText(this, e.getMessage(), Toast.LENGTH_SHORT).show();
return;
}
HttpThreadHandler handler = new HttpThreadHandler(fixedUrl);
HttpThreadHandler handler = new HttpThreadHandler(originalUrl);
Thread job = new Thread(handler);
job.start();