tba request works

This commit is contained in:
Tylr-J42 2025-02-25 12:28:44 -05:00
parent 4d9aace5dd
commit f8bd16202e
26 changed files with 111 additions and 145 deletions

View File

@ -58,6 +58,17 @@
<option name="screenX" value="1080" />
<option name="screenY" value="2340" />
</PersistentDeviceSelectionData>
<PersistentDeviceSelectionData>
<option name="api" value="34" />
<option name="brand" value="samsung" />
<option name="codename" value="a35x" />
<option name="id" value="a35x" />
<option name="manufacturer" value="Samsung" />
<option name="name" value="A35" />
<option name="screenDensity" value="450" />
<option name="screenX" value="1080" />
<option name="screenY" value="2340" />
</PersistentDeviceSelectionData>
<PersistentDeviceSelectionData>
<option name="api" value="31" />
<option name="brand" value="samsung" />
@ -256,17 +267,6 @@
<option name="screenX" value="1080" />
<option name="screenY" value="2340" />
</PersistentDeviceSelectionData>
<PersistentDeviceSelectionData>
<option name="api" value="34" />
<option name="brand" value="samsung" />
<option name="codename" value="gta7lite" />
<option name="id" value="gta7lite" />
<option name="manufacturer" value="Samsung" />
<option name="name" value="Galaxy Tab A7 Lite" />
<option name="screenDensity" value="179" />
<option name="screenX" value="800" />
<option name="screenY" value="1340" />
</PersistentDeviceSelectionData>
<PersistentDeviceSelectionData>
<option name="api" value="33" />
<option name="brand" value="samsung" />
@ -422,6 +422,17 @@
<option name="screenX" value="1080" />
<option name="screenY" value="2400" />
</PersistentDeviceSelectionData>
<PersistentDeviceSelectionData>
<option name="api" value="34" />
<option name="brand" value="samsung" />
<option name="codename" value="t2q" />
<option name="id" value="t2q" />
<option name="manufacturer" value="Samsung" />
<option name="name" value="Galaxy S21 Plus" />
<option name="screenDensity" value="394" />
<option name="screenX" value="1080" />
<option name="screenY" value="2400" />
</PersistentDeviceSelectionData>
<PersistentDeviceSelectionData>
<option name="api" value="33" />
<option name="brand" value="google" />

View File

@ -1,4 +1,4 @@
#Fri Feb 14 13:39:16 EST 2025
#Tue Feb 25 11:52:55 EST 2025
base.0=C\:\\Users\\26jacquesty\\AndroidStudioProjects\\Reefscape-Scouting-App\\ScoutingApp\\app\\build\\intermediates\\dex\\debug\\mergeExtDexDebug\\classes.dex
base.1=C\:\\Users\\26jacquesty\\AndroidStudioProjects\\Reefscape-Scouting-App\\ScoutingApp\\app\\build\\intermediates\\dex\\debug\\mergeProjectDexDebug\\0\\classes.dex
base.2=C\:\\Users\\26jacquesty\\AndroidStudioProjects\\Reefscape-Scouting-App\\ScoutingApp\\app\\build\\intermediates\\dex\\debug\\mergeProjectDexDebug\\4\\classes.dex

View File

@ -97,12 +97,12 @@ public class MainActivity extends AppCompatActivity {
StrictMode.setThreadPolicy(policy);
stream = getJSON("https://www.thebluealliance.com/api/v3/match/2024melew_qm1");
JsonElement jsonElement = JsonParser.parseReader(new InputStreamReader(stream));
JsonObject teamsJSON = jsonElement.getAsJsonObject();
String blueTeams = teamsJSON.get("alliances").getAsJsonObject().get("blue").getAsJsonObject().get("team_keys").toString();
TBAView.setText(blueTeams);
String redTeams = teamsJSON.get("alliances").getAsJsonObject().get("blue").getAsJsonObject().get("team_keys").toString();
TBAView.setText(redTeams);
// JSONArray blueTeamsJSON = teamsJSON.getJSONObject("alliances").getJSONObject("blue").getJSONArray("team_keys");
// JSONArray redTeamsJSON = teamsJSON.getJSONObject("alliances").getJSONObject("blue").getJSONArray("team_keys");
@ -115,98 +115,6 @@ public class MainActivity extends AppCompatActivity {
}
public final class AsynchronousGet {
private final OkHttpClient client = new OkHttpClient();
public String[][] 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/match/2024melew_qm1")
.header("X-TBA-Auth-Key", "0zxxGYSvY7xI2onqcWg0NT0sEtmtR6hCpmYJ29nwfxvqrP3Mf1M3lRZO5x6Kc3kt")
.build();
/*
try(Response response = client.newCall(request).enqueue(new Callback())){
if(!response.isSuccessful()) throw new IOException("unexpected code " + response);
Log.d("test", "inside if statement");
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();
}
*/
Log.d("test", "before enqueue");
client.newCall(request).enqueue(new Callback() {
@Override
public void onResponse(@NonNull Call call, @NonNull Response response) throws IOException {
Log.d("test", "before try");
ResponseBody responseBody = response.body();
Log.d("test", responseBody.string());
//try (ResponseBody responseBody1 = 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));
}
fein = responseBody.string();
responseBody.close();
Log.d("test", "hehehehaw");
}
@Override
public void onFailure(@NonNull okhttp3.Call call, @NonNull IOException e) {
e.printStackTrace();
Log.d("test", "on fail");
}
});
JSONObject teamsJSON = new JSONObject();
JSONArray blueTeamsJSON = teamsJSON.getJSONObject("alliances").getJSONObject("blue").getJSONArray("team_keys");
JSONArray redTeamsJSON = teamsJSON.getJSONObject("alliances").getJSONObject("blue").getJSONArray("team_keys");
//String[] blueTeams = {blueTeamsJSON.getString(0), blueTeamsJSON.getString(1), blueTeamsJSON.getString(2)};
//String[] redTeams = {redTeamsJSON.getString(0), redTeamsJSON.getString(1), redTeamsJSON.getString(2)};
Log.d("test", "before return");
return new String[][]{{""}, {""}};
}
}
public final class SychronousGet{
private final OkHttpClient client = new OkHttpClient();
public void run() throws Exception{
Log.d( "test", "before");
Request request = new Request.Builder()
.url("https://www.thebluealliance.com/api/v3/match/2024melew_qm1")
.header("X-TBA-Auth-Key", "0zxxGYSvY7xI2onqcWg0NT0sEtmtR6hCpmYJ29nwfxvqrP3Mf1M3lRZO5x6Kc3kt")
.build();
try(Response response = client.newCall(request).execute()){
Log.d("test", String.valueOf(response.isSuccessful()));
if(!response.isSuccessful()) throw new IOException("bruh moment" + response);
Headers responseHeaders = response.headers();
for(int i = 0; i < responseHeaders.size(); i++){
Log.d("test", responseHeaders.name(i) + ": " + responseHeaders.value(i));
}
Log.d("test", response.body().string());
}
}
}
public InputStream getJSON(String path){
InputStream stream = null;

View File

@ -7,32 +7,6 @@
android:layout_height="match_parent"
tools:context=".MainActivity">
<Button
android:id="@+id/nextButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button"
app:layout_constraintBottom_toBottomOf="parent"
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="33dp"
tools:layout_editor_absoluteY="316dp" />
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView"
tools:layout_editor_absoluteX="75dp"
tools:layout_editor_absoluteY="54dp" />
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/textInputLayout2"
android:layout_width="409dp"
@ -40,16 +14,10 @@
android:layout_marginStart="1dp"
android:layout_marginTop="156dp"
android:layout_marginEnd="1dp"
app:layout_constraintBottom_toTopOf="@+id/nextButton"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/Event"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Event" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
@ -76,11 +44,6 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/Match"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Match Number" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputEditText
@ -90,7 +53,8 @@
android:hint="Team number"
app:layout_constraintBottom_toTopOf="@+id/textInputLayout2"
app:layout_constraintTop_toBottomOf="@+id/textInputLayout3"
tools:layout_editor_absoluteX="-16dp" />
app:layout_constraintVertical_bias="0.902"
tools:layout_editor_absoluteX="0dp" />
<Button
android:id="@+id/Submit_button"
@ -99,7 +63,90 @@
android:text="Submit"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/Match"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Match Number"
tools:layout_editor_absoluteX="33dp"
tools:layout_editor_absoluteY="156dp" />
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/Event"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Event"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/nextButton" />
app:layout_constraintTop_toTopOf="parent" />
<RadioGroup
android:layout_width="0dp"
android:layout_height="250dp"
android:orientation="horizontal"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
tools:layout_editor_absoluteY="216dp">
<LinearLayout
android:layout_width="409dp"
android:layout_height="215dp"
android:orientation="horizontal">
<LinearLayout
android:layout_width="210dp"
android:layout_height="match_parent"
android:background="#D11010"
android:orientation="vertical">
<RadioButton
android:id="@+id/radioButton10"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="RadioButton" />
<RadioButton
android:id="@+id/radioButton11"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="RadioButton" />
<RadioButton
android:id="@+id/radioButton12"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="RadioButton" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#3F51B5"
android:orientation="vertical">
<RadioButton
android:id="@+id/radioButton13"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="RadioButton" />
<RadioButton
android:id="@+id/radioButton14"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="RadioButton" />
<RadioButton
android:id="@+id/radioButton15"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="RadioButton" />
</LinearLayout>
</LinearLayout>
</RadioGroup>
</androidx.constraintlayout.widget.ConstraintLayout>