This repository has been archived by the owner on Mar 9, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changed the way landing page and searching works.
- Loading branch information
BuildTools
committed
Jul 12, 2019
1 parent
a45ca22
commit 86aa5b8
Showing
60 changed files
with
953 additions
and
212 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 29 additions & 1 deletion
30
...Client/app/src/main/java/com/twitchflix/applicationclient/landingpage/drawers/Drawer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,32 @@ | ||
package com.twitchflix.applicationclient.landingpage.drawers; | ||
|
||
public class Drawer { | ||
import android.app.Activity; | ||
import android.view.ViewGroup; | ||
import com.twitchflix.applicationclient.viewmodels.LandingPageViewModel; | ||
|
||
import java.util.List; | ||
|
||
public abstract class Drawer { | ||
|
||
private ViewGroup parentViewGroup; | ||
|
||
private Activity parentActivity; | ||
|
||
public Drawer(Activity parent, ViewGroup parentView) { | ||
|
||
this.parentActivity = parent; | ||
this.parentViewGroup = parentView; | ||
|
||
} | ||
|
||
protected Activity getParentActivity() { | ||
return parentActivity; | ||
} | ||
|
||
protected ViewGroup getParentView() { | ||
return parentViewGroup; | ||
} | ||
|
||
public abstract void draw(List<LandingPageViewModel.VideoDAO> videos); | ||
|
||
} |
124 changes: 124 additions & 0 deletions
124
...src/main/java/com/twitchflix/applicationclient/landingpage/drawers/LandingPageDrawer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
package com.twitchflix.applicationclient.landingpage.drawers; | ||
|
||
import android.app.Activity; | ||
import android.view.ViewGroup; | ||
import android.widget.HorizontalScrollView; | ||
import android.widget.ImageView; | ||
import android.widget.LinearLayout; | ||
import android.widget.TextView; | ||
import com.twitchflix.applicationclient.landingpage.OnClickVideoListener; | ||
import com.twitchflix.applicationclient.viewmodels.LandingPageViewModel; | ||
|
||
import java.util.*; | ||
|
||
public class LandingPageDrawer extends Drawer { | ||
|
||
public LandingPageDrawer(Activity parent, ViewGroup parentView) { | ||
super(parent, parentView); | ||
} | ||
|
||
@Override | ||
public void draw(List<LandingPageViewModel.VideoDAO> videos) { | ||
|
||
getParentView().removeAllViews(); | ||
|
||
Map<UUID, List<LandingPageViewModel.VideoDAO>> groupedVideos = new HashMap<>(); | ||
|
||
for (LandingPageViewModel.VideoDAO video : videos) { | ||
List<LandingPageViewModel.VideoDAO> videoDAOS = groupedVideos.get(video.getUploader()); | ||
|
||
if (videoDAOS == null) { | ||
videoDAOS = new ArrayList<>(); | ||
} | ||
|
||
videoDAOS.add(video); | ||
|
||
groupedVideos.put(video.getUploader(), videoDAOS); | ||
} | ||
|
||
for (Map.Entry<UUID, List<LandingPageViewModel.VideoDAO>> channels : groupedVideos.entrySet()) { | ||
|
||
String channel_name_text = channels.getValue().get(0).getUploaderName(); | ||
|
||
TextView channel_name = new TextView(getParentActivity()); | ||
|
||
channel_name.setText(channel_name_text); | ||
|
||
channel_name.setClickable(true); | ||
|
||
channel_name.setTextSize(25); | ||
|
||
ViewGroup.MarginLayoutParams viewParams = new ViewGroup.MarginLayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, | ||
ViewGroup.LayoutParams.WRAP_CONTENT); | ||
|
||
viewParams.setMargins(10, 40, 0, 15); | ||
|
||
channel_name.setLayoutParams(viewParams); | ||
|
||
getParentView().addView(channel_name); | ||
|
||
drawIntoView(getParentView(), channels.getValue()); | ||
|
||
} | ||
|
||
} | ||
|
||
private void drawIntoView(ViewGroup parent, List<LandingPageViewModel.VideoDAO> toDraw) { | ||
|
||
HorizontalScrollView scrollingVideo = new HorizontalScrollView(getParentActivity()); | ||
|
||
scrollingVideo.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); | ||
|
||
LinearLayout videos = new LinearLayout(getParentActivity()); | ||
|
||
videos.setOrientation(LinearLayout.HORIZONTAL); | ||
|
||
videos.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); | ||
|
||
scrollingVideo.addView(videos); | ||
|
||
parent.addView(scrollingVideo); | ||
|
||
for (LandingPageViewModel.VideoDAO videoDAO : toDraw) { | ||
drawIntoView(videos, videoDAO); | ||
} | ||
} | ||
|
||
private void drawIntoView(ViewGroup parent, LandingPageViewModel.VideoDAO toDraw) { | ||
|
||
LinearLayout linearVideoLayout = new LinearLayout(getParentActivity()); | ||
|
||
ViewGroup.MarginLayoutParams params = new ViewGroup.MarginLayoutParams(320, 300); | ||
|
||
params.setMargins(15, 0, 0, 0); | ||
|
||
linearVideoLayout.setLayoutParams(params); | ||
|
||
linearVideoLayout.setOrientation(LinearLayout.VERTICAL); | ||
|
||
linearVideoLayout.setClickable(true); | ||
|
||
ImageView thumbnail = new ImageView(getParentActivity()); | ||
|
||
thumbnail.setLayoutParams(new ViewGroup.LayoutParams(320, 240)); | ||
|
||
thumbnail.setAdjustViewBounds(true); | ||
|
||
thumbnail.setScaleType(ImageView.ScaleType.FIT_CENTER); | ||
|
||
thumbnail.setImageBitmap(toDraw.getThumbnail()); | ||
|
||
TextView videoTitle = new TextView(getParentActivity()); | ||
|
||
videoTitle.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); | ||
|
||
videoTitle.setText(toDraw.getTitle()); | ||
|
||
linearVideoLayout.addView(thumbnail); | ||
linearVideoLayout.addView(videoTitle); | ||
|
||
linearVideoLayout.setOnClickListener(new OnClickVideoListener(getParentActivity(), toDraw.getVideoID())); | ||
|
||
parent.addView(linearVideoLayout); | ||
} | ||
} |
Oops, something went wrong.