mirror of
https://github.com/moonlight-stream/moonlight-android.git
synced 2025-07-19 19:13:03 +00:00
Add visual feeback for offline machines and running games
This commit is contained in:
parent
68c1aaf433
commit
406d26ec1c
@ -540,10 +540,10 @@ public class PcView extends Activity {
|
|||||||
else {
|
else {
|
||||||
// Add a new entry
|
// Add a new entry
|
||||||
pcGridAdapter.addComputer(new ComputerObject(details));
|
pcGridAdapter.addComputer(new ComputerObject(details));
|
||||||
|
|
||||||
// Notify the view that the data has changed
|
|
||||||
pcGridAdapter.notifyDataSetChanged();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Notify the view that the data has changed
|
||||||
|
pcGridAdapter.notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ComputerObject {
|
public class ComputerObject {
|
||||||
|
@ -152,4 +152,16 @@ public class AppGridAdapter extends GenericGridAdapter<AppView.AppObject> {
|
|||||||
// Return false to use the app's toString method
|
// Return false to use the app's toString method
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean populateOverlayView(ImageView overlayView, AppView.AppObject obj) {
|
||||||
|
if (obj.app.getIsRunning()) {
|
||||||
|
// Show the play button overlay
|
||||||
|
overlayView.setImageResource(R.drawable.play);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// No overlay
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -49,6 +49,7 @@ public abstract class GenericGridAdapter<T> extends BaseAdapter {
|
|||||||
|
|
||||||
public abstract boolean populateImageView(ImageView imgView, T obj);
|
public abstract boolean populateImageView(ImageView imgView, T obj);
|
||||||
public abstract boolean populateTextView(TextView txtView, T obj);
|
public abstract boolean populateTextView(TextView txtView, T obj);
|
||||||
|
public abstract boolean populateOverlayView(ImageView overlayView, T obj);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View getView(int i, View convertView, ViewGroup viewGroup) {
|
public View getView(int i, View convertView, ViewGroup viewGroup) {
|
||||||
@ -57,6 +58,7 @@ public abstract class GenericGridAdapter<T> extends BaseAdapter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ImageView imgView = (ImageView) convertView.findViewById(R.id.grid_image);
|
ImageView imgView = (ImageView) convertView.findViewById(R.id.grid_image);
|
||||||
|
ImageView overlayView = (ImageView) convertView.findViewById(R.id.grid_overlay);
|
||||||
TextView txtView = (TextView) convertView.findViewById(R.id.grid_text);
|
TextView txtView = (TextView) convertView.findViewById(R.id.grid_text);
|
||||||
|
|
||||||
if (!populateImageView(imgView, itemList.get(i))) {
|
if (!populateImageView(imgView, itemList.get(i))) {
|
||||||
@ -65,6 +67,12 @@ public abstract class GenericGridAdapter<T> extends BaseAdapter {
|
|||||||
if (!populateTextView(txtView, itemList.get(i))) {
|
if (!populateTextView(txtView, itemList.get(i))) {
|
||||||
txtView.setText(itemList.get(i).toString());
|
txtView.setText(itemList.get(i).toString());
|
||||||
}
|
}
|
||||||
|
if (!populateOverlayView(overlayView, itemList.get(i))) {
|
||||||
|
overlayView.setVisibility(View.INVISIBLE);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
overlayView.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
|
|
||||||
return convertView;
|
return convertView;
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ import android.widget.TextView;
|
|||||||
|
|
||||||
import com.limelight.PcView;
|
import com.limelight.PcView;
|
||||||
import com.limelight.R;
|
import com.limelight.R;
|
||||||
|
import com.limelight.nvstream.http.ComputerDetails;
|
||||||
|
|
||||||
public class PcGridAdapter extends GenericGridAdapter<PcView.ComputerObject> {
|
public class PcGridAdapter extends GenericGridAdapter<PcView.ComputerObject> {
|
||||||
|
|
||||||
@ -23,13 +24,32 @@ public class PcGridAdapter extends GenericGridAdapter<PcView.ComputerObject> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean populateImageView(ImageView imgView, PcView.ComputerObject obj) {
|
public boolean populateImageView(ImageView imgView, PcView.ComputerObject obj) {
|
||||||
|
if (obj.details.reachability != ComputerDetails.Reachability.OFFLINE) {
|
||||||
|
imgView.setAlpha(1.0f);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
imgView.setAlpha(0.4f);
|
||||||
|
}
|
||||||
|
|
||||||
// Return false to use the default drawable
|
// Return false to use the default drawable
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean populateTextView(TextView txtView, PcView.ComputerObject obj) {
|
public boolean populateTextView(TextView txtView, PcView.ComputerObject obj) {
|
||||||
|
if (obj.details.reachability != ComputerDetails.Reachability.OFFLINE) {
|
||||||
|
txtView.setAlpha(1.0f);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
txtView.setAlpha(0.4f);
|
||||||
|
}
|
||||||
|
|
||||||
// Return false to use the computer's toString method
|
// Return false to use the computer's toString method
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean populateOverlayView(ImageView overlayView, PcView.ComputerObject obj) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
BIN
app/src/main/res/drawable/play.png
Normal file
BIN
app/src/main/res/drawable/play.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 17 KiB |
@ -3,17 +3,29 @@
|
|||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:padding="30dp">
|
android:padding="30dp">
|
||||||
<ImageView
|
<RelativeLayout
|
||||||
android:id="@+id/grid_image"
|
android:id="@+id/grid_image_layout"
|
||||||
android:layout_centerHorizontal="true"
|
android:layout_width="wrap_content"
|
||||||
android:layout_width="100dp"
|
android:layout_height="wrap_content">
|
||||||
android:layout_height="150dp">
|
<ImageView
|
||||||
</ImageView>
|
android:id="@+id/grid_image"
|
||||||
|
android:layout_centerHorizontal="true"
|
||||||
|
android:layout_width="100dp"
|
||||||
|
android:layout_height="150dp">
|
||||||
|
</ImageView>
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/grid_overlay"
|
||||||
|
android:layout_centerHorizontal="true"
|
||||||
|
android:layout_centerVertical="true"
|
||||||
|
android:layout_width="50dp"
|
||||||
|
android:layout_height="50dp">
|
||||||
|
</ImageView>
|
||||||
|
</RelativeLayout>
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/grid_text"
|
android:id="@+id/grid_text"
|
||||||
android:layout_width="125dp"
|
android:layout_width="125dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_below="@id/grid_image"
|
android:layout_below="@id/grid_image_layout"
|
||||||
android:layout_marginTop="10dp"
|
android:layout_marginTop="10dp"
|
||||||
android:layout_centerHorizontal="true"
|
android:layout_centerHorizontal="true"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
|
@ -3,17 +3,29 @@
|
|||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:padding="20dp">
|
android:padding="20dp">
|
||||||
<ImageView
|
<RelativeLayout
|
||||||
android:id="@+id/grid_image"
|
android:id="@+id/grid_image_layout"
|
||||||
android:layout_centerHorizontal="true"
|
android:layout_width="wrap_content"
|
||||||
android:layout_width="150dp"
|
android:layout_height="wrap_content">
|
||||||
android:layout_height="100dp">
|
<ImageView
|
||||||
</ImageView>
|
android:id="@+id/grid_image"
|
||||||
|
android:layout_centerHorizontal="true"
|
||||||
|
android:layout_width="150dp"
|
||||||
|
android:layout_height="100dp">
|
||||||
|
</ImageView>
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/grid_overlay"
|
||||||
|
android:layout_centerHorizontal="true"
|
||||||
|
android:layout_centerVertical="true"
|
||||||
|
android:layout_width="50dp"
|
||||||
|
android:layout_height="50dp">
|
||||||
|
</ImageView>
|
||||||
|
</RelativeLayout>
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/grid_text"
|
android:id="@+id/grid_text"
|
||||||
android:layout_width="150dp"
|
android:layout_width="150dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_below="@id/grid_image"
|
android:layout_below="@id/grid_image_layout"
|
||||||
android:layout_marginTop="10dp"
|
android:layout_marginTop="10dp"
|
||||||
android:layout_centerHorizontal="true"
|
android:layout_centerHorizontal="true"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user