tba stuff

This commit is contained in:
Tylr-J42 2025-01-27 12:41:11 -05:00
parent f545996945
commit 675217f82d
2 changed files with 27 additions and 11 deletions

View File

@ -15,15 +15,15 @@ import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat; import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat; import androidx.core.view.WindowInsetsCompat;
import org.json.JSONArray;
import org.json.JSONObject;
import java.io.IOException; import java.io.IOException;
import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.Headers; import okhttp3.Headers;
import okhttp3.OkHttpClient; import okhttp3.OkHttpClient;
import okhttp3.Request; import okhttp3.Request;
import okhttp3.Response; import okhttp3.Response;
import okhttp3.ResponseBody;
public class MainActivity extends AppCompatActivity { public class MainActivity extends AppCompatActivity {
@ -52,11 +52,14 @@ public class MainActivity extends AppCompatActivity {
public final class AsynchronousGet { public final class AsynchronousGet {
private final OkHttpClient client = new OkHttpClient(); private final OkHttpClient client = new OkHttpClient();
/*
public int[] getMatchTeams(String eventKey, int qualMatchNum) throws Exception {
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/event/2024melew/teams?X-TBA-Auth-Key=0zxxGYSvY7xI2onqcWg0NT0sEtmtR6hCpmYJ29nwfxvqrP3Mf1M3lRZO5x6Kc3kt
// https://www.thebluealliance.com/api/v3/match/2024melew_qm1?X-TBA-Auth-Key=0zxxGYSvY7xI2onqcWg0NT0sEtmtR6hCpmYJ29nwfxvqrP3Mf1M3lRZO5x6Kc3kt // https://www.thebluealliance.com/api/v3/match/2024melew_qm1?X-TBA-Auth-Key=0zxxGYSvY7xI2onqcWg0NT0sEtmtR6hCpmYJ29nwfxvqrP3Mf1M3lRZO5x6Kc3kt
String fein;
Request request = new Request.Builder() Request request = new Request.Builder()
.url("https://www.thebluealliance.com/api/v3/match/" + eventKey + "_qm" + qualMatchNum + "?X-TBA-Auth-Key=0zxxGYSvY7xI2onqcWg0NT0sEtmtR6hCpmYJ29nwfxvqrP3Mf1M3lRZO5x6Kc3kt") .url("https://www.thebluealliance.com/api/v3/match/" + eventKey + "_qm" + qualMatchNum + "?X-TBA-Auth-Key=0zxxGYSvY7xI2onqcWg0NT0sEtmtR6hCpmYJ29nwfxvqrP3Mf1M3lRZO5x6Kc3kt")
.build(); .build();
@ -68,15 +71,20 @@ public class MainActivity extends AppCompatActivity {
for(int i = 0; i < responseHeaders.size(); i++){ for(int i = 0; i < responseHeaders.size(); i++){
System.out.println(responseHeaders.name(i) + ": " + responseHeaders.value(i)); System.out.println(responseHeaders.name(i) + ": " + responseHeaders.value(i));
} }
//fein = response.body().string(); fein = response.body().string();
} }
JSONObject teamsJSON = new JSONObject(fein);
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)};
//return return new String[][]{blueTeams, redTeams};
} }
*/
} }
private void makeIntent() private void makeIntent()

View File

@ -18,11 +18,19 @@
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />
<TextView <TextView
android:id="@+id/TBATest" android:id="@+id/textView2"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="TextView" android:text="TextView"
tools:layout_editor_absoluteX="113dp" tools:layout_editor_absoluteX="75dp"
tools:layout_editor_absoluteY="149dp" /> tools:layout_editor_absoluteY="94dp" />
<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" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>