-
Notifications
You must be signed in to change notification settings - Fork 275
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added gear icon for the settings and text for others
- Loading branch information
Showing
3 changed files
with
111 additions
and
9 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
65 changes: 65 additions & 0 deletions
65
src/main/java/org/amahi/anywhere/tv/presenter/IconHeaderPresenter.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,65 @@ | ||
package org.amahi.anywhere.tv.presenter; | ||
|
||
import android.content.Context; | ||
import android.graphics.Color; | ||
import android.graphics.drawable.Drawable; | ||
import android.support.v17.leanback.widget.HeaderItem; | ||
import android.support.v17.leanback.widget.ListRow; | ||
import android.support.v17.leanback.widget.Presenter; | ||
import android.support.v17.leanback.widget.RowHeaderPresenter; | ||
import android.support.v4.content.ContextCompat; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.widget.ImageView; | ||
import android.widget.TextView; | ||
|
||
import org.amahi.anywhere.R; | ||
|
||
public class IconHeaderPresenter extends RowHeaderPresenter { | ||
|
||
private float mUnselectedAlpha; | ||
|
||
@Override | ||
public ViewHolder onCreateViewHolder(ViewGroup parent) { | ||
mUnselectedAlpha = parent.getResources() | ||
.getFraction(R.fraction.lb_browse_header_unselect_alpha, 1, 1); | ||
|
||
LayoutInflater inflater = (LayoutInflater) parent.getContext() | ||
.getSystemService(Context.LAYOUT_INFLATER_SERVICE); | ||
|
||
View view = inflater.inflate(R.layout.tv_header_item, null); | ||
view.setAlpha(mUnselectedAlpha); | ||
return new ViewHolder(view); | ||
} | ||
|
||
@Override | ||
public void onBindViewHolder(Presenter.ViewHolder viewHolder, Object item) { | ||
HeaderItem headerItem = ((ListRow) item).getHeaderItem(); | ||
View rootView = viewHolder.view; | ||
rootView.setFocusable(true); | ||
ImageView imageView = (ImageView) rootView.findViewById(R.id.header_icon); | ||
|
||
if (headerItem.getName().matches("Settings")) { | ||
imageView.setVisibility(View.VISIBLE); | ||
Drawable icon = ContextCompat.getDrawable(rootView.getContext(), R.drawable.ic_menu_settings); | ||
imageView.setImageDrawable(icon); | ||
} else { | ||
imageView.setVisibility(View.GONE); | ||
TextView label = (TextView) rootView.findViewById(R.id.header_label); | ||
label.setTextColor(Color.WHITE); | ||
label.setText(headerItem.getName()); | ||
} | ||
} | ||
|
||
@Override | ||
public void onUnbindViewHolder(Presenter.ViewHolder viewHolder) { | ||
// Nothing to be done here. | ||
} | ||
|
||
@Override | ||
protected void onSelectLevelChanged(RowHeaderPresenter.ViewHolder holder) { | ||
holder.view.setAlpha(mUnselectedAlpha + holder.getSelectLevel() * | ||
(1.0f - mUnselectedAlpha)); | ||
} | ||
} |
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,20 @@ | ||
<?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" | ||
android:visibility="gone" | ||
android:src="@drawable/ic_menu_settings"/> | ||
<TextView | ||
android:id="@+id/header_label" | ||
android:layout_marginTop="6dp" | ||
android:textSize="18sp" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" /> | ||
|
||
</LinearLayout> |