This repository has been archived by the owner on Nov 22, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 605
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
343 additions
and
19 deletions.
There are no files selected for viewing
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,11 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:orientation="vertical" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent"> | ||
<GridView | ||
android:id="@+id/grid_view" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:numColumns="2"/> | ||
</LinearLayout> |
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,18 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:orientation="vertical" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent"> | ||
|
||
<ImageView | ||
android:id="@+id/frame_image" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent"/> | ||
|
||
<TextView | ||
android:id="@+id/frame_title" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_gravity="center"/> | ||
|
||
</FrameLayout> |
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
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
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
92 changes: 92 additions & 0 deletions
92
sample/src/main/java/com/github/pedrovgs/sample/renderer/VideoRenderer.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,92 @@ | ||
/* | ||
* Copyright (C) 2014 Pedro Paulo de Amorim. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.github.pedrovgs.sample.renderer; | ||
|
||
import android.content.Context; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.widget.ImageView; | ||
import android.widget.TextView; | ||
|
||
import com.github.pedrovgs.sample.R; | ||
import com.github.pedrovgs.sample.viewmodel.VideoViewModel; | ||
import com.pedrogomez.renderers.Renderer; | ||
import com.squareup.picasso.Picasso; | ||
|
||
import butterknife.ButterKnife; | ||
import butterknife.InjectView; | ||
|
||
/** | ||
* Renderer implementation used to render video inside ListView or GridViews. More info in | ||
* this link: {@link https://github.com/pedrovgs/Renderers} | ||
* | ||
* @author Pedro Paulo de Amorim. | ||
*/ | ||
public class VideoRenderer extends Renderer<VideoViewModel> { | ||
|
||
private Context context; | ||
|
||
@InjectView(R.id.frame_image) ImageView frameImage; | ||
@InjectView(R.id.frame_title) TextView frameTitle; | ||
|
||
private int position; | ||
|
||
public VideoRenderer(Context context) { | ||
this.context = context; | ||
} | ||
|
||
/** | ||
* Configure the position associated to this renderer. | ||
*/ | ||
public void setPosition(int position) { | ||
this.position = position; | ||
} | ||
|
||
/** | ||
* Apply ButterKnife inject method to support view injections. | ||
*/ | ||
@Override | ||
protected void setUpView(View view) { | ||
ButterKnife.inject(this, view); | ||
} | ||
|
||
@Override | ||
protected void hookListeners(View rootView) { | ||
//Empty | ||
} | ||
|
||
/** | ||
* Inflate the layout associated to this renderer | ||
*/ | ||
@Override | ||
protected View inflate(LayoutInflater layoutInflater, ViewGroup viewGroup) { | ||
return layoutInflater.inflate(R.layout.video_row, viewGroup, false); | ||
} | ||
|
||
/** | ||
* Render the PlaceViewModel information. | ||
*/ | ||
@Override | ||
protected void render() { | ||
VideoViewModel item = getContent(); | ||
frameTitle.setText(item.getTitle()); | ||
Picasso.with(context) | ||
.load(item.getImage()) | ||
.placeholder(R.drawable.maps_placeholder) | ||
.into(frameImage); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
sample/src/main/java/com/github/pedrovgs/sample/renderer/VideoRendererAdapter.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,31 @@ | ||
package com.github.pedrovgs.sample.renderer; | ||
|
||
import android.view.LayoutInflater; | ||
|
||
import com.github.pedrovgs.sample.viewmodel.EpisodeViewModel; | ||
import com.github.pedrovgs.sample.viewmodel.VideoViewModel; | ||
import com.pedrogomez.renderers.AdapteeCollection; | ||
import com.pedrogomez.renderers.Renderer; | ||
import com.pedrogomez.renderers.RendererAdapter; | ||
import com.pedrogomez.renderers.RendererBuilder; | ||
|
||
/** | ||
* Created by pedro on 1/24/15. | ||
*/ | ||
public class VideoRendererAdapter extends RendererAdapter<VideoViewModel> { | ||
|
||
public VideoRendererAdapter(LayoutInflater layoutInflater, RendererBuilder rendererBuilder, AdapteeCollection<VideoViewModel> collection) { | ||
super(layoutInflater, rendererBuilder, collection); | ||
} | ||
|
||
/** | ||
* Override method used to update the EpisodeRenderer position. | ||
*/ | ||
@Override protected void updateRendererExtraValues(VideoViewModel content, | ||
Renderer<VideoViewModel> renderer, int position) { | ||
super.updateRendererExtraValues(content, renderer, position); | ||
VideoRenderer episodeRenderer = (VideoRenderer) renderer; | ||
episodeRenderer.setPosition(position); | ||
} | ||
|
||
} |
29 changes: 29 additions & 0 deletions
29
...a/com/github/pedrovgs/sample/renderer/rendererbuilder/VideoCollectionRendererBuilder.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,29 @@ | ||
package com.github.pedrovgs.sample.renderer.rendererbuilder; | ||
|
||
import android.content.Context; | ||
|
||
import com.github.pedrovgs.sample.renderer.VideoRenderer; | ||
import com.github.pedrovgs.sample.viewmodel.VideoViewModel; | ||
import com.pedrogomez.renderers.Renderer; | ||
import com.pedrogomez.renderers.RendererBuilder; | ||
|
||
import java.util.Collection; | ||
|
||
import javax.inject.Inject; | ||
|
||
/** | ||
* RendererBuilder implementation created to map VideoViewModel with VideoRenderer | ||
* implementations. More info in this link: {@link https://github.com/pedrovgs/Renderers} | ||
* | ||
* @author Pedro Paulo de Amorim | ||
*/ | ||
public class VideoCollectionRendererBuilder extends RendererBuilder<VideoViewModel> { | ||
|
||
public VideoCollectionRendererBuilder(Collection<Renderer<VideoViewModel>> prototypes) { | ||
super(prototypes); | ||
} | ||
|
||
@Override protected Class getPrototypeClass(VideoViewModel tvShowViewModel) { | ||
return VideoRenderer.class; | ||
} | ||
} |
Oops, something went wrong.