grabbing json from tba

This commit is contained in:
Tylr-J42 2025-01-23 13:58:08 -05:00
parent 08862f8345
commit f74e340cd2
37 changed files with 44 additions and 20 deletions

View File

@ -201,6 +201,17 @@
<option name="screenX" value="2208" />
<option name="screenY" value="1840" />
</PersistentDeviceSelectionData>
<PersistentDeviceSelectionData>
<option name="api" value="34" />
<option name="brand" value="motorola" />
<option name="codename" value="fogona" />
<option name="id" value="fogona" />
<option name="manufacturer" value="Motorola" />
<option name="name" value="moto g play - 2024" />
<option name="screenDensity" value="280" />
<option name="screenX" value="720" />
<option name="screenY" value="1600" />
</PersistentDeviceSelectionData>
<PersistentDeviceSelectionData>
<option name="api" value="33" />
<option name="brand" value="samsung" />

View File

@ -3,7 +3,9 @@
xmlns:tools="http://schemas.android.com/tools">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.VIBRATE" />
<application
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"

View File

@ -7,6 +7,7 @@ import android.os.AsyncTask;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
@ -45,36 +46,37 @@ public class MainActivity extends AppCompatActivity {
});
TextView TBAView = (TextView)findViewById(R.id.TBATest);
}
public final class AsynchronousGet {
private final OkHttpClient client = new OkHttpClient();
public void run() throws Exception {
/*
public int[] getMatchTeams(String eventKey, int qualMatchNum) throws Exception {
// https://www.thebluealliance.com/api/v3/event/2024melew/teams?X-TBA-Auth-Key=0zxxGYSvY7xI2onqcWg0NT0sEtmtR6hCpmYJ29nwfxvqrP3Mf1M3lRZO5x6Kc3kt
// https://www.thebluealliance.com/api/v3/match/2024melew_qm1?X-TBA-Auth-Key=0zxxGYSvY7xI2onqcWg0NT0sEtmtR6hCpmYJ29nwfxvqrP3Mf1M3lRZO5x6Kc3kt
Request request = new Request.Builder()
.url("https://www.thebluealliance.com/api/v3/event/2025melew/teams?X-TBA-Auth-Key=your_api_key")
.url("https://www.thebluealliance.com/api/v3/match/" + eventKey + "_qm" + qualMatchNum + "?X-TBA-Auth-Key=0zxxGYSvY7xI2onqcWg0NT0sEtmtR6hCpmYJ29nwfxvqrP3Mf1M3lRZO5x6Kc3kt")
.build();
client.newCall(request).enqueue(new Callback() {
@Override
public void onFailure(Call call, IOException e) {
e.printStackTrace();
}
try(Response response = client.newCall(request).execute()){
if(!response.isSuccessful()) throw new IOException("unexpected code " + response);
@Override
public void onResponse(Call call, Response response) throws IOException {
try (ResponseBody responseBody = response.body()) {
if (!response.isSuccessful())
throw new IOException("Unexpected code " + response);
Headers responseHeaders = response.headers();
for (int i = 0, size = responseHeaders.size(); i < size; i++) {
System.out.println(responseHeaders.name(i) + ": " + responseHeaders.value(i));
}
}
Headers responseHeaders = response.headers();
for(int i = 0; i < responseHeaders.size(); i++){
System.out.println(responseHeaders.name(i) + ": " + responseHeaders.value(i));
}
});
//fein = response.body().string();
}
//return
}
*/
}
private void makeIntent()

View File

@ -16,4 +16,13 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/TBATest"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView"
tools:layout_editor_absoluteX="113dp"
tools:layout_editor_absoluteY="149dp" />
</androidx.constraintlayout.widget.ConstraintLayout>