Public projects 1

Christmas Wreath

Project in progress by S Milliken

  • 1,011 views
  • 0 comments
  • 2 respects


Replicated projects 0

 S Milliken hasn't replicated any projects yet.

Fingerprint Door Lock Based on FPM10A

Project tutorial by SurtrTech

  • 4,791 views
  • 0 comments
  • 27 respects

AiouLinux

Project showcase by CESARMASSARI

  • 4,407 views
  • 1 comment
  • 29 respects

Weather Forecast Clock Using Old Alarm and Arduino

Project showcase by LenkaDesign

  • 7,059 views
  • 18 comments
  • 36 respects

  • BU ScoreBoard (IoT ScoreBoard) 4 months ago

    Does your board report a proper score? I ask because in the Photon console, I'm only getting the date and the home team.

  • BU ScoreBoard (IoT ScoreBoard) 4 months ago

    Got the app working, at least it now says Matchup Set!!! Red Sox vs Astros. Onward.

    My account will only give the final scores, I believe, for now.

  • BU ScoreBoard (IoT ScoreBoard) 4 months ago

    I'm still having troubles with the app. Can you see if I have this tab set up correctly(ChooseMatchupActivity.java. Or do I need to completely rename the app?

    [code]package com.buinvent.buscoreapp;

    import android.content.Intent;
    import android.os.AsyncTask;
    import android.support.v7.app.AppCompatActivity;
    import android.os.Bundle;
    import android.util.Log;
    import android.view.Gravity;
    import android.widget.Button;
    import android.widget.LinearLayout;
    import android.widget.LinearLayout.LayoutParams;

    import org.json.JSONArray;
    import org.json.JSONObject;

    import java.io.BufferedReader;
    import java.io.InputStreamReader;
    import java.net.Authenticator;
    import java.net.PasswordAuthentication;
    import java.net.URL;
    import java.net.URLConnection;
    import java.text.SimpleDateFormat;
    import java.util.Calendar;

    public class ChooseMatchupActivity extends AppCompatActivity {

    /* Data API URL and authentication. */
    private static final String API_USERNAME = "Powderjockey";
    private static final String API_PASSWORD = "xxxxxxxxxxxxx";
    
    /* Debug tag. */
    private static final String TAG = "ChooseMatchupActivity";
    
    /* Activity members. */
    private LinearLayout mLinearLayout;
    private LayoutParams mButtonLayoutParams;
    private String mLeague;
    
    @Override
    protected void onCreate(Bundle savedInstanceState) {
    
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_choose_matchup);
    
        // Get the league that was selected and current date.
        Intent leagueIntent = getIntent();
        mLeague = leagueIntent.getStringExtra("league");
        String timeStamp = new SimpleDateFormat("yyyyMMdd").format(Calendar.getInstance().getTime());
    
        // Initialize API URL.
        String apiFeedUrl = "https://api.mysportsfeeds.com/v1.1/pull/" + mLeague +
                "/current/daily_game_schedule.json?fordate=" + timeStamp;
    
        // Initialize XML content
        mLinearLayout = findViewById(R.id.matchup_layout);
        mButtonLayoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    
    
        // Set API Authentication.
        Authenticator.setDefault(new Authenticator() {
            protected PasswordAuthentication getPasswordAuthentication() {
                return new PasswordAuthentication(API_USERNAME, API_PASSWORD.toCharArray());
            }
        });
    
        // Get data feed from API
        new RetrieveFeedTask().execute(apiFeedUrl);
    }
    
    /*
     * Start an instance of MatchupSetActivity.
     */
    private void setMatchup(final String away, final String home, final String league, final String abbreviation) {
        Intent intent = new Intent(getApplicationContext(), MatchupSetActivity.class);
        intent.putExtra(MatchupSetActivity.EXTRA_AWAY_TEAM, away);
        intent.putExtra(MatchupSetActivity.EXTRA_HOME_TEAM, home);
        intent.putExtra(MatchupSetActivity.EXTRA_LEAGUE, league);
        intent.putExtra(MatchupSetActivity.EXTRA_ABBREVIATION, abbreviation);
        startActivity(intent);
    }
    
    /*
     * Display feedback message. E.g. When an API error has occurred.
     */
    private void displayMessage(String message) {
        Intent popup = new Intent(ChooseMatchupActivity.this, PopupActivity.class);
        popup.putExtra("message", message);
        startActivity(popup);
    }
    
    class RetrieveFeedTask extends AsyncTask<String, Void, String> {
    
        protected void onPreExecute() {}
    
        protected String doInBackground(String... urls) {
            String url = urls[0];
            String response = null;
    
            try {
                // Set up HTTP Connection
                URLConnection connection = new URL(url).openConnection();
                InputStreamReader streamReader = new InputStreamReader(connection.getInputStream());
                BufferedReader in = new BufferedReader(streamReader);
    
                // Read HTTP response.
                StringBuilder stringBuilder = new StringBuilder();
                String line;
                while ((line = in.readLine()) != null) {
                    stringBuilder.append(line).append("\n");
                }
                response = stringBuilder.toString();
    
            } catch (Exception e) {
                Log.e(TAG, "Exception", e);
            }
    
            return response;
        }
    
        protected void onPostExecute(String response) {
            // Grab all matchups from API and add them to the layout.
            try {
                // Grab the current dates matchups in a JSONArray.
                JSONObject obj = new JSONObject(response);
    
                // Display message if there were no games for the selected league.
                if (!obj.getJSONObject("dailygameschedule").has("gameentry")) {
                    displayMessage("There are no " + mLeague.toUpperCase() + "\ngames today");
                    return;
                }
    
                JSONArray games = obj.getJSONObject("dailygameschedule").getJSONArray("gameentry");
    
                for (int i = 0; i < games.length(); i++) {
                    // Grab the home and away team's names for every matchup.
                    String awayTeam = games.getJSONObject(i).getJSONObject("awayTeam").getString("Name");
                    String homeTeam = games.getJSONObject(i).getJSONObject("homeTeam").getString("Name");
                    String teamAbbreviation = games.getJSONObject(i).getJSONObject("homeTeam").getString("Abbreviation");
                    String matchUpStr = awayTeam + "\n" + homeTeam;
    
                    // Create a button for the matchup.
                    Button button = new Button(getApplicationContext());
                    button.setTextSize(30);
                    button.setGravity(Gravity.START);
                    button.setText(matchUpStr);
                    button.setOnClickListener(view -> setMatchup(awayTeam, homeTeam, mLeague, teamAbbreviation));
    
                    // Add the button to the layout.
                    mLinearLayout.addView(button, mButtonLayoutParams);
                }
            } catch (Exception e) {
                e.printStackTrace();
                displayMessage("ERROR!!!\n\nThere was a problem with the API.");
            }
        }
    }
    

    }[/code]

    And then the other tab, SetMatchActivity.java

    package com.buinvent.buscoreapp;

    import android.content.Intent;
    import android.support.annotation.NonNull;
    import android.support.v7.app.AppCompatActivity;
    import android.os.Bundle;
    import android.widget.TextView;

    import java.io.IOException;
    import java.util.ArrayList;
    import java.util.List;

    import io.particle.android.sdk.cloud.ParticleCloud;
    import io.particle.android.sdk.cloud.ParticleCloudException;
    import io.particle.android.sdk.cloud.ParticleCloudSDK;
    import io.particle.android.sdk.cloud.ParticleDevice;
    import io.particle.android.sdk.utils.Async;

    public class MatchupSetActivity extends AppCompatActivity {

    // Set macros for string extras
    public static final String EXTRA_AWAY_TEAM = "com.buinvent.buscoreapp.AWAY_TEAM";
    public static final String EXTRA_HOME_TEAM = "com.buinvent.buscoreapp.HOME_TEAM";
    public static final String EXTRA_LEAGUE = "com.buinvent.buscoreapp.LEAGUE";
    public static final String EXTRA_ABBREVIATION = "com.buinvent.buscoreapp.ABBREVIATION";
    
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_matchup_set);
    
        // Grab the textviews from activity_matchup_set.xml
        TextView away = findViewById(R.id.away_TextView);
        TextView home = findViewById(R.id.home_TextView);
        TextView matchupSet = findViewById(R.id.matchup_set_text);
        TextView vsText = findViewById(R.id.vs_TextView);
    
        // Grab the extra strings that were set in ChooseMatchupActivity
        Intent teamsIntent = getIntent();
        String awayTeam = teamsIntent.getStringExtra(EXTRA_AWAY_TEAM);
        String homeTeam = teamsIntent.getStringExtra(EXTRA_HOME_TEAM);
        String mLeague = teamsIntent.getStringExtra(EXTRA_LEAGUE);
        String teamAbbreviation = teamsIntent.getStringExtra(EXTRA_ABBREVIATION);
    
    
        // Login to Particle Cloud and call the Photon's "team_league" function and pass in the
        // user's selected home team abbreviation and league
        ParticleCloudSDK.init(this);
    
        Async.executeAsync(ParticleCloudSDK.getCloud(), new Async.ApiWork<ParticleCloud, Object>() {
    
            private ParticleDevice mDevice;
    
            @Override
            public Object callApi(@NonNull ParticleCloud sparkCloud) throws ParticleCloudException, IOException {
    
                sparkCloud.logIn("sdmilliken@gmail.com", "xxxxxxxxxxx");
                mDevice = sparkCloud.getDevice("particleDviceNumber");
    
                List<String> teamLeague = new ArrayList<>();
                teamLeague.add( mLeague.toUpperCase() + " " + teamAbbreviation );
    
                try {
                    mDevice.callFunction("team_league", teamLeague);
                } catch (Exception e) {
                    throw new ParticleCloudException(e);
                }
    
                return -1;
            }
    
            // Tell the user the matchup has been set if they were successfully logged in to the
            // Particle cloud and the team_league function was called successfully
            @Override
            public void onSuccess(@NonNull Object value) {
    
                matchupSet.setText(R.string.header_matchup_set);
                vsText.setText(R.string.vs_text);
                away.setText(awayTeam);
                home.setText(homeTeam);
            }
    
            // Tell the user the matchup has not been set if they were successfully logged in to the
            // Particle cloud and the team_league function was called successfully
            @Override
            public void onFailure(@NonNull ParticleCloudException e) {
                matchupSet.setText("Error!!!");
                vsText.setText("Matchup could not be set");
            }
        });
    }
    

    }

Add projectSign up / Login