refactor: 🔥 remove X support
This commit is contained in:
parent
1c9dc4cca7
commit
9b2a65312a
@ -6,6 +6,7 @@ import android.os.Bundle;
|
|||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
|
import java.net.URI;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
|
||||||
public class MainActivity extends Activity {
|
public class MainActivity extends Activity {
|
||||||
@ -26,27 +27,15 @@ public class MainActivity extends Activity {
|
|||||||
|
|
||||||
private void handleUrl(String textUrl) {
|
private void handleUrl(String textUrl) {
|
||||||
URL originalUrl;
|
URL originalUrl;
|
||||||
URL fixedUrl;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
originalUrl = new URL(textUrl);
|
originalUrl = new URI(textUrl).toURL();
|
||||||
|
} catch (Exception e) {
|
||||||
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) {
|
|
||||||
Toast.makeText(this, e.getMessage(), Toast.LENGTH_SHORT).show();
|
Toast.makeText(this, e.getMessage(), Toast.LENGTH_SHORT).show();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
HttpThreadHandler handler = new HttpThreadHandler(fixedUrl);
|
HttpThreadHandler handler = new HttpThreadHandler(originalUrl);
|
||||||
Thread job = new Thread(handler);
|
Thread job = new Thread(handler);
|
||||||
|
|
||||||
job.start();
|
job.start();
|
||||||
|
Loading…
Reference in New Issue
Block a user