mirror of
https://github.com/NiciDieNase/chaosflix
synced 2024-11-27 14:41:28 +00:00
add presenter and layout for header items
This commit is contained in:
parent
06708499d4
commit
7fd0557f24
2 changed files with 70 additions and 0 deletions
|
@ -0,0 +1,53 @@
|
||||||
|
package de.nicidienase.chaosflix;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.support.v17.leanback.widget.HeaderItem;
|
||||||
|
import android.support.v17.leanback.widget.ListRow;
|
||||||
|
import android.support.v17.leanback.widget.Presenter;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import butterknife.BindView;
|
||||||
|
import de.nicidienase.chaosflix.entities.recording.Conference;
|
||||||
|
import de.nicidienase.chaosflix.entities.streaming.LiveConference;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by felix on 16.04.17.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class HeaderItemPresenter extends Presenter {
|
||||||
|
@Override
|
||||||
|
public ViewHolder onCreateViewHolder(ViewGroup parent) {
|
||||||
|
LayoutInflater inflater = (LayoutInflater) parent.getContext()
|
||||||
|
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||||
|
View view = inflater.inflate(R.layout.header_item_layout, null);
|
||||||
|
|
||||||
|
return new ViewHolder(view);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBindViewHolder(ViewHolder viewHolder, Object item) {
|
||||||
|
HeaderItem headerItem = ((ListRow) item).getHeaderItem();
|
||||||
|
View view = viewHolder.view;
|
||||||
|
ImageView headerIcon = (ImageView) view.findViewById(R.id.header_icon);
|
||||||
|
TextView headerLabel = (TextView) view.findViewById(R.id.header_label);
|
||||||
|
|
||||||
|
if(item instanceof Conference){
|
||||||
|
Conference con = (Conference) item;
|
||||||
|
|
||||||
|
headerLabel.setText(con.getTitle());
|
||||||
|
} else if(item instanceof LiveConference){
|
||||||
|
LiveConference con = (LiveConference) item;
|
||||||
|
|
||||||
|
headerLabel.setText(con.getConference());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onUnbindViewHolder(ViewHolder viewHolder) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
17
app/src/main/res/layout/header_item_layout.xml
Normal file
17
app/src/main/res/layout/header_item_layout.xml
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/header_icon"
|
||||||
|
android:layout_width="32dp"
|
||||||
|
android:layout_height="32dp" />
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/header_label"
|
||||||
|
android:layout_marginTop="6dp"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
Loading…
Reference in a new issue