diff --git a/android/AndroidClient/app/build.gradle b/android/AndroidClient/app/build.gradle index 1fc7ad1..09349b1 100644 --- a/android/AndroidClient/app/build.gradle +++ b/android/AndroidClient/app/build.gradle @@ -30,5 +30,5 @@ dependencies { compile 'de.hdodenhof:circleimageview:2.0.0' compile 'com.squareup.picasso:picasso:2.5.2' compile 'se.emilsjolander:stickylistheaders:2.7.0' - compile 'com.android.support:support-v13:22.2.1' + compile 'com.android.support:support-v4:22.2.1' } diff --git a/android/AndroidClient/app/src/main/AndroidManifest.xml b/android/AndroidClient/app/src/main/AndroidManifest.xml index 29fe3a8..185a667 100644 --- a/android/AndroidClient/app/src/main/AndroidManifest.xml +++ b/android/AndroidClient/app/src/main/AndroidManifest.xml @@ -29,6 +29,15 @@ android:name=".AddFavoriteActivity" android:label="@string/title_activity_add_favorite" > + + + + diff --git a/android/AndroidClient/app/src/main/java/com/swagoverflow/androidclient/Constants.java b/android/AndroidClient/app/src/main/java/com/swagoverflow/androidclient/Constants.java index d3488f6..1ec22e8 100644 --- a/android/AndroidClient/app/src/main/java/com/swagoverflow/androidclient/Constants.java +++ b/android/AndroidClient/app/src/main/java/com/swagoverflow/androidclient/Constants.java @@ -7,6 +7,8 @@ public class Constants { private Constants() { } public static final String IS_TEAM = "isTeam"; - public static final String TEAM = "team"; - public static final String SHOW = "show"; + public static final String NAME = "name"; + public static final String ID = "id"; + public static final String NOTIFICATIONS = "notifications"; + public static final String URI = "uri"; } diff --git a/android/AndroidClient/app/src/main/java/com/swagoverflow/androidclient/LoginActivity.java b/android/AndroidClient/app/src/main/java/com/swagoverflow/androidclient/LoginActivity.java index 8abdb44..8be4f0a 100644 --- a/android/AndroidClient/app/src/main/java/com/swagoverflow/androidclient/LoginActivity.java +++ b/android/AndroidClient/app/src/main/java/com/swagoverflow/androidclient/LoginActivity.java @@ -11,6 +11,8 @@ import android.widget.AutoCompleteTextView; import android.widget.Button; import android.widget.EditText; +import android.widget.ProgressBar; +import android.widget.ScrollView; import android.widget.TextView; import com.squareup.otto.Subscribe; @@ -58,6 +60,11 @@ public void onClick(View view) { private void attemptLogin() { apiCaller.obtainData(new GetUserRequest(2)); + ScrollView loginView = (ScrollView) findViewById(R.id.login_form); + loginView.setVisibility(View.GONE); + + ProgressBar progressBar = (ProgressBar) findViewById(R.id.progress); + progressBar.setVisibility(View.VISIBLE); } @Override @@ -77,6 +84,9 @@ public void onUserObtained(GetUserResponse response) { ((SwagApplication) getApplication()).setUser(response.getUser()); Intent intent = new Intent(this, MainActivity.class); + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK); + intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); startActivity(intent); } } diff --git a/android/AndroidClient/app/src/main/java/com/swagoverflow/androidclient/MainActivity.java b/android/AndroidClient/app/src/main/java/com/swagoverflow/androidclient/MainActivity.java index edb54a8..a4303de 100644 --- a/android/AndroidClient/app/src/main/java/com/swagoverflow/androidclient/MainActivity.java +++ b/android/AndroidClient/app/src/main/java/com/swagoverflow/androidclient/MainActivity.java @@ -49,9 +49,14 @@ public void onPageScrolled(int position, float positionOffset, int positionOffse public void onPageSelected(int position) { // TODO make an animation if (position == 0) { - mFab.setVisibility(View.VISIBLE); - } else { - mFab.setVisibility(View.GONE); + mFab.show(); + setTitle("Favorites"); + } else if (position == 1) { + mFab.hide(); + setTitle("Events"); + } else if (position == 2) { + mFab.hide(); + setTitle("Account Settings"); } } @@ -76,8 +81,17 @@ public void onClick(View view) { } }); + setTitle("Favorites"); } + @Override + public void onBackPressed() { + if (mViewPager.getCurrentItem() != 0) { + mViewPager.setCurrentItem(0); + } else { + super.onBackPressed(); + } + } @Override public boolean onCreateOptionsMenu(Menu menu) { diff --git a/android/AndroidClient/app/src/main/java/com/swagoverflow/androidclient/ViewFavoriteActivity.java b/android/AndroidClient/app/src/main/java/com/swagoverflow/androidclient/ViewFavoriteActivity.java new file mode 100644 index 0000000..01e46a7 --- /dev/null +++ b/android/AndroidClient/app/src/main/java/com/swagoverflow/androidclient/ViewFavoriteActivity.java @@ -0,0 +1,32 @@ +package com.swagoverflow.androidclient; + +import android.content.Intent; +import android.os.Bundle; +import android.app.Activity; +import android.widget.Switch; + +public class ViewFavoriteActivity extends Activity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_view_favorite); + + handleIntent(getIntent()); + } + + private void handleIntent(Intent intent) { + boolean isTeam = intent.getBooleanExtra(Constants.IS_TEAM, false); + boolean notifications = intent.getBooleanExtra(Constants.NOTIFICATIONS, true); + + Switch notificationsEnabled = (Switch) findViewById(R.id.notificationEnabled); + notificationsEnabled.setChecked(notifications); + + if (isTeam) { + // TODO get team info + } else { + // TODO get show info + } + } + +} diff --git a/android/AndroidClient/app/src/main/java/com/swagoverflow/androidclient/WatchContentActivity.java b/android/AndroidClient/app/src/main/java/com/swagoverflow/androidclient/WatchContentActivity.java new file mode 100644 index 0000000..0308afe --- /dev/null +++ b/android/AndroidClient/app/src/main/java/com/swagoverflow/androidclient/WatchContentActivity.java @@ -0,0 +1,27 @@ +package com.swagoverflow.androidclient; + +import android.content.Intent; +import android.net.Uri; +import android.os.Bundle; +import android.app.Activity; +import android.widget.MediaController; +import android.widget.VideoView; + +public class WatchContentActivity extends Activity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_watch_content); + + Intent intent = getIntent(); + String uri = intent.getStringExtra(Constants.URI); + + VideoView videoView = (VideoView) findViewById(R.id.videoView); + videoView.setMediaController(new MediaController(this)); + videoView.setVideoURI(Uri.parse(uri)); + videoView.requestFocus(); + videoView.start(); + } + +} diff --git a/android/AndroidClient/app/src/main/java/com/swagoverflow/androidclient/adapters/EventListAdapter.java b/android/AndroidClient/app/src/main/java/com/swagoverflow/androidclient/adapters/EventListAdapter.java new file mode 100644 index 0000000..6bb581c --- /dev/null +++ b/android/AndroidClient/app/src/main/java/com/swagoverflow/androidclient/adapters/EventListAdapter.java @@ -0,0 +1,147 @@ +package com.swagoverflow.androidclient.adapters; + +import android.app.Activity; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.BaseAdapter; +import android.widget.ImageView; +import android.widget.SectionIndexer; +import android.widget.TextView; + +import com.squareup.picasso.Picasso; +import com.swagoverflow.androidclient.R; +import com.swagoverflow.androidclient.models.Episode; +import com.swagoverflow.androidclient.models.Game; +import com.swagoverflow.androidclient.utilities.Utility; + +import java.text.SimpleDateFormat; +import java.util.List; + +import se.emilsjolander.stickylistheaders.StickyListHeadersAdapter; + +/** + * Created by Mike on 2/27/2016. + */ +public class EventListAdapter extends BaseAdapter implements StickyListHeadersAdapter, SectionIndexer { + + private Activity context; + private List games; + private List episodes; + private String[] mSections = new String[] { "Games", "Episodes" }; + + public EventListAdapter(Activity context, List games, List episodes) { + this.context = context; + this.games = games; + this.episodes = episodes; + } + + @Override + public View getHeaderView(int position, View convertView, ViewGroup parent) { + HeaderViewHolder holder; + + if (convertView == null) { + holder = new HeaderViewHolder(); + convertView = LayoutInflater.from(context).inflate(R.layout.header, parent, false); + holder.textView = (TextView) convertView.findViewById(R.id.title); + convertView.setTag(holder); + } else { + holder = (HeaderViewHolder) convertView.getTag(); + } + + if (position < games.size()) { + holder.textView.setText(mSections[0]); + } else { + holder.textView.setText(mSections[1]); + } + + return convertView; + } + + @Override + public long getHeaderId(int position) { + if (position < games.size()) { + return 0; + } else { + return 1; + } + } + + @Override + public int getCount() { + return games.size() + episodes.size() + 1; + } + + @Override + public Object getItem(int i) { + if (i < games.size()) { + return games.get(i); + } else if (i < episodes.size() + games.size()) { + return episodes.get(i - games.size()); + } + + return null; + } + + @Override + public long getItemId(int i) { + return 0; + } + + @Override + public View getView(int position, View v, ViewGroup parent) { + View view = LayoutInflater.from(context).inflate(R.layout.layout_event, parent, false); + + ImageView thumbnail = (ImageView) view.findViewById(R.id.thumbnail); + TextView name = (TextView) view.findViewById(R.id.name); + TextView date = (TextView) view.findViewById(R.id.date); + TextView channel = (TextView) view.findViewById(R.id.channel); + + SimpleDateFormat sdf = new SimpleDateFormat("EEE, MMM d 'at' h:mm a"); + + if (position < games.size()) { + Game game = games.get(position); + Picasso.with(context).load(game.getThumbnailUrl()).into(thumbnail); + name.setText(game.getDescription()); + date.setText(sdf.format(game.getDate())); + channel.setText(game.getChannel()); + } else if (position < games.size() + episodes.size()) { + Episode episode = episodes.get(position - games.size()); + Picasso.with(context).load(episode.getThumbnailUrl()).into(thumbnail); + name.setText(episode.getShow().getName()); + date.setText(sdf.format(episode.getDate())); + channel.setText(episode.getChannel()); + } else { + view.setMinimumHeight(Utility.convertDpToPx(context.getWindowManager().getDefaultDisplay(), 10)); + } + + return view; + } + + @Override + public Object[] getSections() { + return mSections; + } + + @Override + public int getPositionForSection(int i) { + if (games.size() == 0 && episodes.size() == 0) { + return 0; + } + + if (i <= 0) { + return 0; + } else { + return games.size(); + } + } + + @Override + public int getSectionForPosition(int i) { + return 0; + } + + class HeaderViewHolder { + TextView textView; + } +} diff --git a/android/AndroidClient/app/src/main/java/com/swagoverflow/androidclient/adapters/PreferenceListAdapter.java b/android/AndroidClient/app/src/main/java/com/swagoverflow/androidclient/adapters/PreferenceListAdapter.java index b4922d8..342823c 100644 --- a/android/AndroidClient/app/src/main/java/com/swagoverflow/androidclient/adapters/PreferenceListAdapter.java +++ b/android/AndroidClient/app/src/main/java/com/swagoverflow/androidclient/adapters/PreferenceListAdapter.java @@ -12,10 +12,15 @@ import com.squareup.picasso.Picasso; import com.swagoverflow.androidclient.R; +import com.swagoverflow.androidclient.SwagApplication; +import com.swagoverflow.androidclient.api.IApiCaller; +import com.swagoverflow.androidclient.api.requests.DeleteFavoriteShowRequest; +import com.swagoverflow.androidclient.api.requests.DeleteFavoriteTeamRequest; import com.swagoverflow.androidclient.models.Show; import com.swagoverflow.androidclient.models.ShowFavorite; import com.swagoverflow.androidclient.models.Team; import com.swagoverflow.androidclient.models.TeamFavorite; +import com.swagoverflow.androidclient.models.User; import com.swagoverflow.androidclient.utilities.Utility; import java.util.List; @@ -28,11 +33,13 @@ public class PreferenceListAdapter extends BaseAdapter implements StickyListHead private List shows; private Activity activity; private String[] mSections; + private IApiCaller apiCaller; - public PreferenceListAdapter(Activity activity, List teams, List shows) { + public PreferenceListAdapter(Activity activity, List teams, List shows, IApiCaller apiCaller) { this.teams = teams; this.shows = shows; this.activity = activity; + this.apiCaller = apiCaller; mSections = new String[] { "Teams", "Shows" }; } @@ -59,31 +66,33 @@ public long getItemId(int i) { } @Override - public View getView(int position, View convertView, ViewGroup parent) { + public View getView(final int position, View convertView, ViewGroup parent) { View view = LayoutInflater.from(activity).inflate(R.layout.layout_preference_item, parent, false); ImageView logo = (ImageView) view.findViewById(R.id.logo); TextView name = (TextView) view.findViewById(R.id.name); ImageView delete = (ImageView) view.findViewById(R.id.delete); + final User user = ((SwagApplication) activity.getApplication()).getUser(); + if (position < teams.size()) { - Team team = teams.get(position).getTeam(); + final Team team = teams.get(position).getTeam(); Picasso.with(activity).load(team.getImageUrl()).into(logo); name.setText(team.getName()); delete.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { - Log.i("AS", "delete clicked"); + apiCaller.obtainData(new DeleteFavoriteTeamRequest(user.getId(), teams.get(position).getId())); } }); } else if (position < teams.size() + shows.size()) { - Show show = shows.get(position - teams.size()).getShow(); + final Show show = shows.get(position - teams.size()).getShow(); Picasso.with(activity).load(show.getImageUrl()).into(logo); name.setText(show.getName()); delete.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { - Log.i("AS", "delete clicked"); + apiCaller.obtainData(new DeleteFavoriteShowRequest(user.getId(), shows.get(position - teams.size()).getId())); } }); } else { diff --git a/android/AndroidClient/app/src/main/java/com/swagoverflow/androidclient/api/RestApi.java b/android/AndroidClient/app/src/main/java/com/swagoverflow/androidclient/api/RestApi.java index aac9466..595bb67 100644 --- a/android/AndroidClient/app/src/main/java/com/swagoverflow/androidclient/api/RestApi.java +++ b/android/AndroidClient/app/src/main/java/com/swagoverflow/androidclient/api/RestApi.java @@ -1,8 +1,11 @@ package com.swagoverflow.androidclient.api; import com.squareup.okhttp.Response; +import com.swagoverflow.androidclient.api.requests.PostFavoriteShowRequest; import com.swagoverflow.androidclient.api.requests.PostFavoriteTeamRequest; +import com.swagoverflow.androidclient.api.responses.GetEventsForUserResponse; import com.swagoverflow.androidclient.api.responses.GetShowResponse; +import com.swagoverflow.androidclient.api.responses.GetShowsResponse; import com.swagoverflow.androidclient.api.responses.GetTeamResponse; import com.swagoverflow.androidclient.api.responses.GetTeamsResponse; import com.swagoverflow.androidclient.api.responses.GetUserResponse; @@ -16,24 +19,36 @@ import retrofit.http.Path; public interface RestApi { - @GET("/user/{user_id}/favorites") + @GET("/user/{user_id}/favorites/") void getFavorites(@Path("user_id") long userId, Callback response); - @GET("/user/{user_id}") + @GET("/user/{user_id}/") void getUser(@Path("user_id") long userId, Callback response); - @GET("/team") + @GET("/team/") void getAllTeams(Callback response); - @GET("/user/{user_id}/shows/{show_id}") + @GET("/show/") + void getAllShows(Callback response); + + @GET("/user/{user_id}/shows/{show_id}/") void getShow(@Path("user_id") long userId, @Path("show_id") long showId, Callback response); - @GET("/user/{user_id}/teams/{team_id}") + @GET("/user/{user_id}/teams/{team_id}/") void getTeam(@Path("user_id") long userId, @Path("team_id") long teamId, Callback response); @POST("/user/{user_id}/teams/") void postTeam(@Path("user_id") long userId, @Body PostFavoriteTeamRequest request, Callback response); - @DELETE("/user/{user_id}/teams/{team_id}") + @DELETE("/user/{user_id}/teams/{team_id}/") void deleteFavoriteTeam(@Path("user_id") long userId, @Path("team_id") long teamId, Callback response); + + @POST("/user/{user_id}/shows/") + void postShow(@Path("user_id") long userId, @Body PostFavoriteShowRequest request, Callback response); + + @DELETE("/user/{user_id}/shows/{show_id}/") + void deleteFavoriteShow(@Path("user_id") long userId, @Path("show_id") long showId, Callback response); + + @GET("/user/{user_id}/events/") + void getEvents(@Path("user_id") long userId, Callback response); } diff --git a/android/AndroidClient/app/src/main/java/com/swagoverflow/androidclient/api/requests/DeleteFavoriteShowRequest.java b/android/AndroidClient/app/src/main/java/com/swagoverflow/androidclient/api/requests/DeleteFavoriteShowRequest.java new file mode 100644 index 0000000..d4043ca --- /dev/null +++ b/android/AndroidClient/app/src/main/java/com/swagoverflow/androidclient/api/requests/DeleteFavoriteShowRequest.java @@ -0,0 +1,22 @@ +package com.swagoverflow.androidclient.api.requests; + +/** + * Created by Mike on 2/27/2016. + */ +public class DeleteFavoriteShowRequest { + private long userId; + private long showId; + + public DeleteFavoriteShowRequest(long userId, long showId) { + this.userId = userId; + this.showId = showId; + } + + public long getUserId() { + return userId; + } + + public long getShowId() { + return showId; + } +} diff --git a/android/AndroidClient/app/src/main/java/com/swagoverflow/androidclient/api/requests/GetEventsForUserRequest.java b/android/AndroidClient/app/src/main/java/com/swagoverflow/androidclient/api/requests/GetEventsForUserRequest.java new file mode 100644 index 0000000..0a3f0ce --- /dev/null +++ b/android/AndroidClient/app/src/main/java/com/swagoverflow/androidclient/api/requests/GetEventsForUserRequest.java @@ -0,0 +1,16 @@ +package com.swagoverflow.androidclient.api.requests; + +/** + * Created by Mike on 2/27/2016. + */ +public class GetEventsForUserRequest { + private long userId; + + public GetEventsForUserRequest(long userId) { + this.userId = userId; + } + + public long getUserId() { + return userId; + } +} diff --git a/android/AndroidClient/app/src/main/java/com/swagoverflow/androidclient/api/requests/PostFavoriteShowRequest.java b/android/AndroidClient/app/src/main/java/com/swagoverflow/androidclient/api/requests/PostFavoriteShowRequest.java new file mode 100644 index 0000000..3635a61 --- /dev/null +++ b/android/AndroidClient/app/src/main/java/com/swagoverflow/androidclient/api/requests/PostFavoriteShowRequest.java @@ -0,0 +1,20 @@ +package com.swagoverflow.androidclient.api.requests; + +public class PostFavoriteShowRequest { + private long show; + private long user; + private boolean notifications = true; + + public PostFavoriteShowRequest(long showId, long userId) { + this.show = showId; + this.user = userId; + } + + public long getShowId() { + return show; + } + + public long getUserId() { + return user; + } +} diff --git a/android/AndroidClient/app/src/main/java/com/swagoverflow/androidclient/api/requests/PostFavoriteTeamRequest.java b/android/AndroidClient/app/src/main/java/com/swagoverflow/androidclient/api/requests/PostFavoriteTeamRequest.java index ad1008d..96bd90c 100644 --- a/android/AndroidClient/app/src/main/java/com/swagoverflow/androidclient/api/requests/PostFavoriteTeamRequest.java +++ b/android/AndroidClient/app/src/main/java/com/swagoverflow/androidclient/api/requests/PostFavoriteTeamRequest.java @@ -4,19 +4,20 @@ * Created by Mike on 2/27/2016. */ public class PostFavoriteTeamRequest { - private long teamId; - private long userId; + private long team; + private long user; + private boolean notifications = true; public PostFavoriteTeamRequest(long teamId, long userId) { - this.teamId = teamId; - this.userId = userId; + this.team = teamId; + this.user = userId; } public long getTeamId() { - return teamId; + return team; } public long getUserId() { - return userId; + return user; } } diff --git a/android/AndroidClient/app/src/main/java/com/swagoverflow/androidclient/api/responses/GetEventsForUserResponse.java b/android/AndroidClient/app/src/main/java/com/swagoverflow/androidclient/api/responses/GetEventsForUserResponse.java new file mode 100644 index 0000000..6506fee --- /dev/null +++ b/android/AndroidClient/app/src/main/java/com/swagoverflow/androidclient/api/responses/GetEventsForUserResponse.java @@ -0,0 +1,22 @@ +package com.swagoverflow.androidclient.api.responses; + +import com.swagoverflow.androidclient.models.Episode; +import com.swagoverflow.androidclient.models.Game; + +import java.util.List; + +/** + * Created by Mike on 2/27/2016. + */ +public class GetEventsForUserResponse { + private List games; + private List episodes; + + public List getGames() { + return games; + } + + public List getEpisodes() { + return episodes; + } +} diff --git a/android/AndroidClient/app/src/main/java/com/swagoverflow/androidclient/api/responses/ShowDeletedResponse.java b/android/AndroidClient/app/src/main/java/com/swagoverflow/androidclient/api/responses/ShowDeletedResponse.java new file mode 100644 index 0000000..8e82db9 --- /dev/null +++ b/android/AndroidClient/app/src/main/java/com/swagoverflow/androidclient/api/responses/ShowDeletedResponse.java @@ -0,0 +1,7 @@ +package com.swagoverflow.androidclient.api.responses; + +/** + * Created by Mike on 2/27/2016. + */ +public class ShowDeletedResponse { +} diff --git a/android/AndroidClient/app/src/main/java/com/swagoverflow/androidclient/api/responses/ShowPostedResponse.java b/android/AndroidClient/app/src/main/java/com/swagoverflow/androidclient/api/responses/ShowPostedResponse.java new file mode 100644 index 0000000..a413158 --- /dev/null +++ b/android/AndroidClient/app/src/main/java/com/swagoverflow/androidclient/api/responses/ShowPostedResponse.java @@ -0,0 +1,14 @@ +package com.swagoverflow.androidclient.api.responses; + +import com.swagoverflow.androidclient.models.ShowFavorite; + +/** + * Created by Mike on 2/27/2016. + */ +public class ShowPostedResponse { + private ShowFavorite favoriteshows; + + public ShowFavorite getFavoriteshows() { + return favoriteshows; + } +} diff --git a/android/AndroidClient/app/src/main/java/com/swagoverflow/androidclient/api/responses/TeamDeletedResponse.java b/android/AndroidClient/app/src/main/java/com/swagoverflow/androidclient/api/responses/TeamDeletedResponse.java new file mode 100644 index 0000000..c6f1f04 --- /dev/null +++ b/android/AndroidClient/app/src/main/java/com/swagoverflow/androidclient/api/responses/TeamDeletedResponse.java @@ -0,0 +1,7 @@ +package com.swagoverflow.androidclient.api.responses; + +/** + * Created by Mike on 2/27/2016. + */ +public class TeamDeletedResponse { +} diff --git a/android/AndroidClient/app/src/main/java/com/swagoverflow/androidclient/api/responses/TeamPostedResponse.java b/android/AndroidClient/app/src/main/java/com/swagoverflow/androidclient/api/responses/TeamPostedResponse.java new file mode 100644 index 0000000..a2afb9c --- /dev/null +++ b/android/AndroidClient/app/src/main/java/com/swagoverflow/androidclient/api/responses/TeamPostedResponse.java @@ -0,0 +1,14 @@ +package com.swagoverflow.androidclient.api.responses; + +import com.swagoverflow.androidclient.models.TeamFavorite; + +/** + * Created by Mike on 2/27/2016. + */ +public class TeamPostedResponse { + TeamFavorite favoriteteams; + + public TeamFavorite getFavoriteteams() { + return favoriteteams; + } +} diff --git a/android/AndroidClient/app/src/main/java/com/swagoverflow/androidclient/api/services/RequestService.java b/android/AndroidClient/app/src/main/java/com/swagoverflow/androidclient/api/services/RequestService.java index 04a0469..0490182 100644 --- a/android/AndroidClient/app/src/main/java/com/swagoverflow/androidclient/api/services/RequestService.java +++ b/android/AndroidClient/app/src/main/java/com/swagoverflow/androidclient/api/services/RequestService.java @@ -5,18 +5,28 @@ import com.squareup.otto.Bus; import com.squareup.otto.Subscribe; import com.swagoverflow.androidclient.api.RestApi; +import com.swagoverflow.androidclient.api.requests.DeleteFavoriteShowRequest; import com.swagoverflow.androidclient.api.requests.DeleteFavoriteTeamRequest; +import com.swagoverflow.androidclient.api.requests.GetEventsForUserRequest; import com.swagoverflow.androidclient.api.requests.GetShowForUserRequest; +import com.swagoverflow.androidclient.api.requests.GetShowsRequest; import com.swagoverflow.androidclient.api.requests.GetTeamForUserRequest; import com.swagoverflow.androidclient.api.requests.GetTeamsRequest; import com.swagoverflow.androidclient.api.requests.GetUserRequest; import com.swagoverflow.androidclient.api.requests.ObtainFavoritesRequest; +import com.swagoverflow.androidclient.api.requests.PostFavoriteShowRequest; import com.swagoverflow.androidclient.api.requests.PostFavoriteTeamRequest; +import com.swagoverflow.androidclient.api.responses.GetEventsForUserResponse; import com.swagoverflow.androidclient.api.responses.GetShowResponse; +import com.swagoverflow.androidclient.api.responses.GetShowsResponse; import com.swagoverflow.androidclient.api.responses.GetTeamResponse; import com.swagoverflow.androidclient.api.responses.GetTeamsResponse; import com.swagoverflow.androidclient.api.responses.GetUserResponse; import com.swagoverflow.androidclient.api.responses.ObtainFavoritesResult; +import com.swagoverflow.androidclient.api.responses.ShowDeletedResponse; +import com.swagoverflow.androidclient.api.responses.ShowPostedResponse; +import com.swagoverflow.androidclient.api.responses.TeamDeletedResponse; +import com.swagoverflow.androidclient.api.responses.TeamPostedResponse; import retrofit.Callback; import retrofit.RetrofitError; @@ -116,6 +126,7 @@ public void onPostFavoriteTeam(PostFavoriteTeamRequest request) { @Override public void success(com.squareup.okhttp.Response response, Response response2) { Log.i(TAG, "Succeeded in posting team"); + mBus.post(new TeamPostedResponse()); } @Override @@ -131,6 +142,69 @@ public void onDeleteFavoriteTeam(DeleteFavoriteTeamRequest request) { @Override public void success(com.squareup.okhttp.Response response, Response response2) { Log.i(TAG, "Succeeded in deleting team"); + mBus.post(new ShowDeletedResponse()); + } + + @Override + public void failure(RetrofitError error) { + Log.e(TAG, error.getMessage()); + } + }); + } + + @Subscribe + public void onGetShows(GetShowsRequest request) { + mApi.getAllShows(new Callback() { + @Override + public void success(GetShowsResponse response, Response response2) { + mBus.post(response); + } + + @Override + public void failure(RetrofitError error) { + Log.e(TAG, error.getMessage()); + } + }); + } + + @Subscribe + public void onPostShow(PostFavoriteShowRequest request){ + mApi.postShow(request.getUserId(), request, new Callback() { + @Override + public void success(com.squareup.okhttp.Response response, Response response2) { + Log.i(TAG, "Success"); + mBus.post(new ShowPostedResponse()); + } + + @Override + public void failure(RetrofitError error) { + Log.e(TAG, error.getMessage()); + } + }); + } + + @Subscribe + public void onDeleteShow(DeleteFavoriteShowRequest request) { + mApi.deleteFavoriteShow(request.getUserId(), request.getShowId(), new Callback() { + @Override + public void success(com.squareup.okhttp.Response response, Response response2) { + Log.i(TAG, "deleted"); + mBus.post(new ShowDeletedResponse()); + } + + @Override + public void failure(RetrofitError error) { + Log.e(TAG, error.getMessage()); + } + }); + } + + @Subscribe + public void onGetEvents(GetEventsForUserRequest request) { + mApi.getEvents(request.getUserId(), new Callback() { + @Override + public void success(GetEventsForUserResponse getEventsForUserResponse, Response response) { + mBus.post(getEventsForUserResponse); } @Override diff --git a/android/AndroidClient/app/src/main/java/com/swagoverflow/androidclient/fragments/AddFavoriteShowFragment.java b/android/AndroidClient/app/src/main/java/com/swagoverflow/androidclient/fragments/AddFavoriteShowFragment.java index 28cc851..5a47ae2 100644 --- a/android/AndroidClient/app/src/main/java/com/swagoverflow/androidclient/fragments/AddFavoriteShowFragment.java +++ b/android/AndroidClient/app/src/main/java/com/swagoverflow/androidclient/fragments/AddFavoriteShowFragment.java @@ -1,18 +1,34 @@ package com.swagoverflow.androidclient.fragments; +import android.os.AsyncTask; import android.os.Bundle; +import android.support.design.widget.CoordinatorLayout; +import android.support.design.widget.Snackbar; import android.support.v4.app.Fragment; +import android.support.v4.util.Pair; +import android.text.Editable; +import android.text.TextWatcher; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.AdapterView; +import android.widget.EditText; +import android.widget.ListView; import com.squareup.otto.Subscribe; import com.swagoverflow.androidclient.R; +import com.swagoverflow.androidclient.SwagApplication; +import com.swagoverflow.androidclient.adapters.AddOptionAdapter; import com.swagoverflow.androidclient.api.ApiCallerProvider; import com.swagoverflow.androidclient.api.IApiCaller; +import com.swagoverflow.androidclient.api.requests.DeleteFavoriteShowRequest; import com.swagoverflow.androidclient.api.requests.GetShowsRequest; +import com.swagoverflow.androidclient.api.requests.PostFavoriteShowRequest; import com.swagoverflow.androidclient.api.responses.GetShowsResponse; +import com.swagoverflow.androidclient.api.responses.ShowPostedResponse; import com.swagoverflow.androidclient.models.Show; +import com.swagoverflow.androidclient.models.ShowFavorite; +import com.swagoverflow.androidclient.models.User; import java.util.ArrayList; import java.util.List; @@ -25,6 +41,9 @@ public class AddFavoriteShowFragment extends Fragment { private List shows; private List filteredShows; private IApiCaller apiCaller; + private FilterShowsTask task; + private boolean shouldDelete; + private long userId; public AddFavoriteShowFragment() { // Required empty public constructor @@ -41,10 +60,75 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, @Override public void onViewCreated(View view, Bundle savedInstanceState) { shows = new ArrayList<>(); - filteredShows = new ArrayList<>(); apiCaller = ApiCallerProvider.getInstance(); + task = null; + + EditText search = (EditText) getView().findViewById(R.id.searchField); + search.addTextChangedListener(new TextWatcher() { + @Override + public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { + + } + + @Override + public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { + + } + + @Override + public void afterTextChanged(Editable editable) { + User user = ((SwagApplication) getActivity().getApplication()).getUser(); + if (task != null) { + task.cancel(false); + } + task = new FilterShowsTask(); + task.execute(new Pair<>(editable.toString(), user)); + } + }); apiCaller.obtainData(new GetShowsRequest()); + + ListView shows = (ListView) view.findViewById(R.id.results); + shows.setOnItemClickListener(new AdapterView.OnItemClickListener() { + @Override + public void onItemClick(AdapterView adapterView, View view, int i, long l) { + Show show = filteredShows.get(i); + User user = ((SwagApplication) getActivity().getApplication()).getUser(); + userId = user.getId(); + apiCaller.obtainData(new PostFavoriteShowRequest(show.getId(), user.getId())); + CoordinatorLayout layout = (CoordinatorLayout) getActivity().findViewById(R.id.main_content); + Snackbar.make(layout, "Favorite show added", Snackbar.LENGTH_SHORT) + .setAction("Undo", new View.OnClickListener() { + @Override + public void onClick(View view) { + shouldDelete = true; + } + }) + .show(); + } + }); + } + + @Subscribe + public void onPosted(ShowPostedResponse response) { + ((SwagApplication) getActivity().getApplication()).getUser().addFavoriteShow(response.getFavoriteshows()); + if (shouldDelete) { + apiCaller.obtainData(new DeleteFavoriteShowRequest(userId, response.getFavoriteshows().getId())); + CoordinatorLayout layout = (CoordinatorLayout) getActivity().findViewById(R.id.main_content); + Snackbar.make(layout, "Successfully deleted show", Snackbar.LENGTH_SHORT) + .show(); + } + shouldDelete = false; + + if (task != null) { + task.cancel(false); + } + + EditText search = (EditText) getView().findViewById(R.id.searchField); + User user = ((SwagApplication) getActivity().getApplication()).getUser(); + + task = new FilterShowsTask(); + task.execute(new Pair<>(search.getText().toString(), user)); } @Override @@ -63,10 +147,73 @@ public void onPause() { public void onShowsObtained(GetShowsResponse response) { this.shows = response.getShows(); - filterShows(); + EditText search = (EditText) getView().findViewById(R.id.searchField); + User user = ((SwagApplication) getActivity().getApplication()).getUser(); + + if (task != null) { + task.cancel(false); + } + task = new FilterShowsTask(); + task.execute(new Pair<>(search.getText().toString(), user)); + } + + private void filterShows(List filteredShows) { + this.filteredShows = filteredShows; + + ListView showsList = (ListView) getView().findViewById(R.id.results); + showsList.setAdapter(new AddOptionAdapter(getActivity(), R.layout.layout_preference_item, null, filteredShows)); } - private void filterShows() { - filteredShows = new ArrayList<>(); + private class FilterShowsTask extends AsyncTask, Void, List> { + + @Override + protected List doInBackground(Pair... args) { + List filteredShows = new ArrayList<>(); + boolean hasShow; + Pair data = args[0]; + String text = data.first.toLowerCase(); + List showFavorites = data.second.getFavoriteShows(); + + if (!text.equals("")) { + for (Show s : shows) { + if (isCancelled()) + break; + hasShow = false; + for (ShowFavorite f : showFavorites) { + if (f != null && f.getShow().getName().equals(s.getName())) { + hasShow = true; + break; + } + if (isCancelled()) + break; + } + + if (!hasShow && s.getName().toLowerCase().contains(text)){ + filteredShows.add(s); + } + } + } else { + for (Show s : shows) { + hasShow = false; + for (ShowFavorite f : showFavorites) { + if (f != null && f.getShow().getName().equals(s.getName())) { + hasShow = true; + break; + } + } + + if (!hasShow){ + filteredShows.add(s); + } + } + } + + return filteredShows; + } + + @Override + protected void onPostExecute(List shows) { + filterShows(shows); + } } } diff --git a/android/AndroidClient/app/src/main/java/com/swagoverflow/androidclient/fragments/AddFavoriteTeamFragment.java b/android/AndroidClient/app/src/main/java/com/swagoverflow/androidclient/fragments/AddFavoriteTeamFragment.java index 414af70..e19361b 100644 --- a/android/AndroidClient/app/src/main/java/com/swagoverflow/androidclient/fragments/AddFavoriteTeamFragment.java +++ b/android/AndroidClient/app/src/main/java/com/swagoverflow/androidclient/fragments/AddFavoriteTeamFragment.java @@ -22,6 +22,7 @@ import com.swagoverflow.androidclient.api.requests.GetTeamsRequest; import com.swagoverflow.androidclient.api.requests.PostFavoriteTeamRequest; import com.swagoverflow.androidclient.api.responses.GetTeamsResponse; +import com.swagoverflow.androidclient.api.responses.TeamPostedResponse; import com.swagoverflow.androidclient.models.Team; import com.swagoverflow.androidclient.models.TeamFavorite; import com.swagoverflow.androidclient.models.User; @@ -37,6 +38,8 @@ public class AddFavoriteTeamFragment extends Fragment { private List teams; private List filteredTeams; private IApiCaller apiCaller; + private long userId; + private boolean shouldDelete; public AddFavoriteTeamFragment() { // Required empty public constructor @@ -77,15 +80,16 @@ public void onNothingSelected(AdapterView adapterView) { teams.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView adapterView, View view, int i, long l) { - final Team team = filteredTeams.get(i); - final User user = ((SwagApplication) getActivity().getApplication()).getUser(); + Team team = filteredTeams.get(i); + User user = ((SwagApplication) getActivity().getApplication()).getUser(); + userId = user.getId(); apiCaller.obtainData(new PostFavoriteTeamRequest(team.getId(), user.getId())); CoordinatorLayout layout = (CoordinatorLayout) getActivity().findViewById(R.id.main_content); Snackbar.make(layout, "Favorite team added", Snackbar.LENGTH_SHORT) .setAction("Undo", new View.OnClickListener() { @Override public void onClick(View view) { - deleteFavoriteTeam(team.getId(), user.getId()); + shouldDelete = true; } }) .show(); @@ -93,8 +97,22 @@ public void onClick(View view) { }); } - private void deleteFavoriteTeam(long teamId, long userId) { - apiCaller.obtainData(new DeleteFavoriteTeamRequest(teamId, userId)); + @Subscribe + public void onPosted(TeamPostedResponse response) { + ((SwagApplication) getActivity().getApplication()).getUser().addFavoriteTeam(response.getFavoriteteams()); + + if (shouldDelete) { + apiCaller.obtainData(new DeleteFavoriteTeamRequest(userId, response.getFavoriteteams().getId())); + CoordinatorLayout layout = (CoordinatorLayout) getActivity().findViewById(R.id.main_content); + Snackbar.make(layout, "Successfully deleted team", Snackbar.LENGTH_SHORT) + .show(); + } + shouldDelete = false; + + Spinner spinner = (Spinner) getView().findViewById(R.id.teamSpinner); + int position = spinner.getSelectedItemPosition(); + String[] options = getResources().getStringArray(R.array.leagues); + filterTeamsByLeague(options[position]); } @Override @@ -131,7 +149,7 @@ private void filterTeamsByLeague(String leagueName) { for (Team t : teams) { hasTeam = false; for (TeamFavorite f : teamFavorites) { - if (f.getTeam().getName().equals(t.getName())) { + if (f != null && f.getTeam().getName().equals(t.getName())) { hasTeam = true; break; } @@ -145,7 +163,7 @@ private void filterTeamsByLeague(String leagueName) { for (Team t : teams) { hasTeam = false; for (TeamFavorite f : teamFavorites) { - if (f.getTeam().getName().equals(t.getName())) { + if (f != null && f.getTeam().getName().equals(t.getName())) { hasTeam = true; break; } diff --git a/android/AndroidClient/app/src/main/java/com/swagoverflow/androidclient/fragments/EventsFragment.java b/android/AndroidClient/app/src/main/java/com/swagoverflow/androidclient/fragments/EventsFragment.java index e4859cc..252d279 100644 --- a/android/AndroidClient/app/src/main/java/com/swagoverflow/androidclient/fragments/EventsFragment.java +++ b/android/AndroidClient/app/src/main/java/com/swagoverflow/androidclient/fragments/EventsFragment.java @@ -1,22 +1,42 @@ package com.swagoverflow.androidclient.fragments; - +import android.content.Intent; import android.os.Bundle; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.AdapterView; +import com.squareup.otto.Subscribe; +import com.swagoverflow.androidclient.Constants; import com.swagoverflow.androidclient.R; +import com.swagoverflow.androidclient.SwagApplication; +import com.swagoverflow.androidclient.WatchContentActivity; +import com.swagoverflow.androidclient.adapters.EventListAdapter; +import com.swagoverflow.androidclient.api.ApiCallerProvider; +import com.swagoverflow.androidclient.api.IApiCaller; +import com.swagoverflow.androidclient.api.requests.GetEventsForUserRequest; +import com.swagoverflow.androidclient.api.responses.GetEventsForUserResponse; +import com.swagoverflow.androidclient.models.Episode; +import com.swagoverflow.androidclient.models.Game; +import com.swagoverflow.androidclient.models.User; + +import java.util.List; + +import se.emilsjolander.stickylistheaders.StickyListHeadersListView; public class EventsFragment extends Fragment { + private IApiCaller apiCaller; + private List games; + private List episodes; + private EventListAdapter adapter; public EventsFragment() { // Required empty public constructor } - @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { @@ -24,5 +44,50 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, return inflater.inflate(R.layout.fragment_events, container, false); } + @Override + public void onViewCreated(View view, Bundle savedInstanceState) { + User user = ((SwagApplication) getActivity().getApplication()).getUser(); + apiCaller = ApiCallerProvider.getInstance(); + apiCaller.obtainData(new GetEventsForUserRequest(user.getId())); + } + + @Override + public void onResume() { + super.onResume(); + apiCaller.registerObject(this); + } + @Override + public void onPause() { + apiCaller.unregisterObject(this); + super.onPause(); + } + + @Subscribe + public void onEvents(GetEventsForUserResponse response) { + games = response.getGames(); + episodes = response.getEpisodes(); + + StickyListHeadersListView listView = (StickyListHeadersListView) getView().findViewById(R.id.events_list); + + adapter = new EventListAdapter(getActivity(), games, episodes); + listView.setAdapter(adapter); + listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { + @Override + public void onItemClick(AdapterView adapterView, View view, int i, long l) { + Intent intent = new Intent(getActivity(), WatchContentActivity.class); + + if (i < games.size()) { + Game game = games.get(i); + intent.putExtra(Constants.URI, game.getVideoUrl()); + } else if (i < games.size() + episodes.size()) { + Episode episode = episodes.get(i - games.size()); + intent.putExtra(Constants.URI, episode.getVideoUrl()); + } + + if (i < games.size() + episodes.size()) + startActivity(intent); + } + }); + } } diff --git a/android/AndroidClient/app/src/main/java/com/swagoverflow/androidclient/fragments/PreferencesFragment.java b/android/AndroidClient/app/src/main/java/com/swagoverflow/androidclient/fragments/PreferencesFragment.java index 6d2f721..04a7272 100644 --- a/android/AndroidClient/app/src/main/java/com/swagoverflow/androidclient/fragments/PreferencesFragment.java +++ b/android/AndroidClient/app/src/main/java/com/swagoverflow/androidclient/fragments/PreferencesFragment.java @@ -2,12 +2,9 @@ import android.os.Bundle; import android.support.v4.app.Fragment; -import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.widget.AdapterView; -import android.widget.Toast; import com.squareup.otto.Subscribe; import com.swagoverflow.androidclient.R; @@ -17,6 +14,7 @@ import com.swagoverflow.androidclient.api.IApiCaller; import com.swagoverflow.androidclient.api.requests.ObtainFavoritesRequest; import com.swagoverflow.androidclient.api.responses.ObtainFavoritesResult; +import com.swagoverflow.androidclient.api.responses.ShowDeletedResponse; import com.swagoverflow.androidclient.models.User; import se.emilsjolander.stickylistheaders.StickyListHeadersListView; @@ -26,6 +24,9 @@ public class PreferencesFragment extends Fragment { private static final String TAG = "PreferencesFragment"; private IApiCaller apiCaller; + private PreferenceListAdapter adapter; + private int teamsCount; + private int showsCount; public PreferencesFragment() { // Required empty public constructor @@ -56,22 +57,26 @@ public void onPause() { public void onResume() { super.onResume(); apiCaller.registerObject(this); + User user = ((SwagApplication) getActivity().getApplication()).getUser(); + apiCaller.obtainData(new ObtainFavoritesRequest(user.getId())); + } + + @Subscribe + public void onDeleted(ShowDeletedResponse response) { + User user = ((SwagApplication) getActivity().getApplication()).getUser(); + apiCaller.obtainData(new ObtainFavoritesRequest(user.getId())); } @Subscribe public void onFavoritesObtained(ObtainFavoritesResult result) { StickyListHeadersListView listView = (StickyListHeadersListView) getView().findViewById(R.id.preference_list); - listView.setAdapter(new PreferenceListAdapter(getActivity(), result.getTeams(), result.getShows())); + adapter = new PreferenceListAdapter(getActivity(), result.getTeams(), result.getShows(), apiCaller); + listView.setAdapter(adapter); User user = ((SwagApplication) getActivity().getApplication()).getUser(); user.setFavoriteShows(result.getShows()); user.setFavoriteTeams(result.getTeams()); - - listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { - @Override - public void onItemClick(AdapterView adapterView, View view, int position, long l) { - Toast.makeText(getActivity(), "Todo", Toast.LENGTH_SHORT).show(); - } - }); + teamsCount = result.getTeams().size(); + showsCount = result.getShows().size(); } } diff --git a/android/AndroidClient/app/src/main/java/com/swagoverflow/androidclient/fragments/SettingsFragment.java b/android/AndroidClient/app/src/main/java/com/swagoverflow/androidclient/fragments/SettingsFragment.java index 1e4f07c..9896979 100644 --- a/android/AndroidClient/app/src/main/java/com/swagoverflow/androidclient/fragments/SettingsFragment.java +++ b/android/AndroidClient/app/src/main/java/com/swagoverflow/androidclient/fragments/SettingsFragment.java @@ -5,8 +5,15 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.ArrayAdapter; +import android.widget.Button; +import android.widget.EditText; +import android.widget.Spinner; +import android.widget.Toast; import com.swagoverflow.androidclient.R; +import com.swagoverflow.androidclient.SwagApplication; +import com.swagoverflow.androidclient.models.User; public class SettingsFragment extends Fragment { @@ -23,5 +30,24 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, return inflater.inflate(R.layout.fragment_settings, container, false); } - + @Override + public void onViewCreated(View view, Bundle savedInstanceState) { + Spinner spinner = (Spinner) view.findViewById(R.id.notificationOption); + spinner.setAdapter(new ArrayAdapter<>(getActivity(), android.R.layout.simple_spinner_dropdown_item, getResources().getStringArray(R.array.options))); + + EditText email = (EditText) view.findViewById(R.id.email); + EditText phoneNumber = (EditText) view.findViewById(R.id.phoneNumber); + Button button = (Button) view.findViewById(R.id.update); + button.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + Toast.makeText(getActivity(), "Updates pending", Toast.LENGTH_SHORT).show(); + } + }); + + User user = ((SwagApplication) getActivity().getApplication()).getUser(); + + email.setText(user.getEmail()); + phoneNumber.setText(user.getPhone()); + } } diff --git a/android/AndroidClient/app/src/main/java/com/swagoverflow/androidclient/models/Episode.java b/android/AndroidClient/app/src/main/java/com/swagoverflow/androidclient/models/Episode.java new file mode 100644 index 0000000..9cfd69d --- /dev/null +++ b/android/AndroidClient/app/src/main/java/com/swagoverflow/androidclient/models/Episode.java @@ -0,0 +1,34 @@ +package com.swagoverflow.androidclient.models; + +import java.util.Date; + +/** + * Created by Mike on 2/27/2016. + */ +public class Episode { + private Show show; + private Date date; + private String channel_number; + private String video_url; + private String thumbnail_url; + + public Date getDate() { + return date; + } + + public String getChannel() { + return channel_number; + } + + public String getVideoUrl() { + return video_url; + } + + public String getThumbnailUrl() { + return thumbnail_url; + } + + public Show getShow() { + return show; + } +} diff --git a/android/AndroidClient/app/src/main/java/com/swagoverflow/androidclient/models/Game.java b/android/AndroidClient/app/src/main/java/com/swagoverflow/androidclient/models/Game.java new file mode 100644 index 0000000..b2b881e --- /dev/null +++ b/android/AndroidClient/app/src/main/java/com/swagoverflow/androidclient/models/Game.java @@ -0,0 +1,35 @@ +package com.swagoverflow.androidclient.models; + +import java.util.Date; + +/** + * Created by Mike on 2/27/2016. + */ +public class Game { + private Date date; + private String channel_number; + private String video_url; + private String thumbnail_url; + private Team home_team; + private Team away_team; + + public Date getDate() { + return date; + } + + public String getChannel() { + return channel_number; + } + + public String getVideoUrl() { + return video_url; + } + + public String getThumbnailUrl() { + return thumbnail_url; + } + + public String getDescription() { + return home_team.getName() + " vs. " + away_team.getName(); + } +} diff --git a/android/AndroidClient/app/src/main/java/com/swagoverflow/androidclient/models/User.java b/android/AndroidClient/app/src/main/java/com/swagoverflow/androidclient/models/User.java index 22b6231..6fbdea2 100644 --- a/android/AndroidClient/app/src/main/java/com/swagoverflow/androidclient/models/User.java +++ b/android/AndroidClient/app/src/main/java/com/swagoverflow/androidclient/models/User.java @@ -45,4 +45,31 @@ public void setFavoriteShows(List favoriteShows) { public void setFavoriteTeams(List favoriteTeams) { this.favoriteTeams = favoriteTeams; } + + public void addFavoriteTeam(TeamFavorite favorite) { + this.favoriteTeams.add(favorite); + } + + public void addFavoriteShow(ShowFavorite favorite) { + this.favoriteShows.add(favorite); + } + + public TeamFavorite getFavoriteTeamByTeamId(long id) { + for (TeamFavorite t : favoriteTeams) { + if (id == t.getTeam().getId()) { + return t; + } + } + return null; + } + + public ShowFavorite getFavoriteShowByShowId(long id) { + for (ShowFavorite s : favoriteShows) { + if (id == s.getShow().getId()) { + return s; + } + } + + return null; + } } diff --git a/android/AndroidClient/app/src/main/res/drawable/swag_overflow.png b/android/AndroidClient/app/src/main/res/drawable/swag_overflow.png new file mode 100644 index 0000000..3f15de7 Binary files /dev/null and b/android/AndroidClient/app/src/main/res/drawable/swag_overflow.png differ diff --git a/android/AndroidClient/app/src/main/res/layout/activity_login.xml b/android/AndroidClient/app/src/main/res/layout/activity_login.xml index 8f2a5ae..8425154 100644 --- a/android/AndroidClient/app/src/main/res/layout/activity_login.xml +++ b/android/AndroidClient/app/src/main/res/layout/activity_login.xml @@ -9,6 +9,15 @@ android:scaleType="centerCrop" android:src="@drawable/log_in"/> + + + android:layout_marginTop="120dp"> @@ -30,6 +39,7 @@ @@ -49,6 +59,7 @@