mirror of
https://github.com/moonlight-stream/moonlight-android.git
synced 2025-07-20 19:42:45 +00:00
Fix UI performance issues
This commit is contained in:
parent
94b1c04fa6
commit
6dbb1a0c1f
@ -109,11 +109,7 @@ public class PcView extends Activity {
|
|||||||
public void onItemClick(AdapterView<?> arg0, View arg1, int pos,
|
public void onItemClick(AdapterView<?> arg0, View arg1, int pos,
|
||||||
long id) {
|
long id) {
|
||||||
ComputerObject computer = (ComputerObject) pcGridAdapter.getItem(pos);
|
ComputerObject computer = (ComputerObject) pcGridAdapter.getItem(pos);
|
||||||
if (computer.details == null) {
|
if (computer.details.reachability == ComputerDetails.Reachability.OFFLINE) {
|
||||||
// Placeholder item; no context menu for it
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else if (computer.details.reachability == ComputerDetails.Reachability.OFFLINE) {
|
|
||||||
// Open the context menu if a PC is offline
|
// Open the context menu if a PC is offline
|
||||||
openContextMenu(arg1);
|
openContextMenu(arg1);
|
||||||
}
|
}
|
||||||
@ -141,13 +137,8 @@ public class PcView extends Activity {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (pcGridAdapter.isEmpty()) {
|
|
||||||
addListPlaceholder();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
pcGridAdapter.notifyDataSetChanged();
|
pcGridAdapter.notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
@ -176,7 +167,7 @@ public class PcView extends Activity {
|
|||||||
PcView.this.runOnUiThread(new Runnable() {
|
PcView.this.runOnUiThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
updateListView(details);
|
updateComputer(details);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -505,7 +496,7 @@ public class PcView extends Activity {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
managerBinder.removeComputer(computer.details.name);
|
managerBinder.removeComputer(computer.details.name);
|
||||||
removeListView(computer.details);
|
removeComputer(computer.details);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case APP_LIST_ID:
|
case APP_LIST_ID:
|
||||||
@ -517,11 +508,7 @@ public class PcView extends Activity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addListPlaceholder() {
|
private void removeComputer(ComputerDetails details) {
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void removeListView(ComputerDetails details) {
|
|
||||||
for (int i = 0; i < pcGridAdapter.getCount(); i++) {
|
for (int i = 0; i < pcGridAdapter.getCount(); i++) {
|
||||||
ComputerObject computer = (ComputerObject) pcGridAdapter.getItem(i);
|
ComputerObject computer = (ComputerObject) pcGridAdapter.getItem(i);
|
||||||
|
|
||||||
@ -530,26 +517,14 @@ public class PcView extends Activity {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pcGridAdapter.getCount() == 0) {
|
|
||||||
// Add the placeholder if we're down to 0 computers
|
|
||||||
addListPlaceholder();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateListView(ComputerDetails details) {
|
private void updateComputer(ComputerDetails details) {
|
||||||
ComputerObject existingEntry = null;
|
ComputerObject existingEntry = null;
|
||||||
boolean placeholderPresent = false;
|
|
||||||
|
|
||||||
for (int i = 0; i < pcGridAdapter.getCount(); i++) {
|
for (int i = 0; i < pcGridAdapter.getCount(); i++) {
|
||||||
ComputerObject computer = (ComputerObject) pcGridAdapter.getItem(i);
|
ComputerObject computer = (ComputerObject) pcGridAdapter.getItem(i);
|
||||||
|
|
||||||
// If there's a placeholder, there's nothing else
|
|
||||||
if (computer.details == null) {
|
|
||||||
placeholderPresent = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if this is the same computer
|
// Check if this is the same computer
|
||||||
if (details.equals(computer.details)) {
|
if (details.equals(computer.details)) {
|
||||||
existingEntry = computer;
|
existingEntry = computer;
|
||||||
@ -562,18 +537,13 @@ public class PcView extends Activity {
|
|||||||
existingEntry.details = details;
|
existingEntry.details = details;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// If the placeholder is the only object, remove it
|
|
||||||
if (placeholderPresent) {
|
|
||||||
pcGridAdapter.removeComputer((ComputerObject) pcGridAdapter.getItem(0));
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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
|
// Notify the view that the data has changed
|
||||||
pcGridAdapter.notifyDataSetChanged();
|
pcGridAdapter.notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public class ComputerObject {
|
public class ComputerObject {
|
||||||
public ComputerDetails details;
|
public ComputerDetails details;
|
||||||
|
@ -49,7 +49,7 @@ public abstract class GenericGridAdapter<T> extends BaseAdapter {
|
|||||||
@Override
|
@Override
|
||||||
public View getView(int i, View convertView, ViewGroup viewGroup) {
|
public View getView(int i, View convertView, ViewGroup viewGroup) {
|
||||||
if (convertView == null) {
|
if (convertView == null) {
|
||||||
convertView = inflater.inflate(layoutId, null);
|
convertView = inflater.inflate(layoutId, viewGroup, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
ImageView imgView = (ImageView) convertView.findViewById(R.id.grid_image);
|
ImageView imgView = (ImageView) convertView.findViewById(R.id.grid_image);
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 46 KiB After Width: | Height: | Size: 40 KiB |
@ -2,11 +2,11 @@
|
|||||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:padding="10dp">
|
android:padding="20dp">
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/grid_image"
|
android:id="@+id/grid_image"
|
||||||
android:layout_centerHorizontal="true"
|
android:layout_centerHorizontal="true"
|
||||||
android:layout_width="100dp"
|
android:layout_width="150dp"
|
||||||
android:layout_height="100dp">
|
android:layout_height="100dp">
|
||||||
</ImageView>
|
</ImageView>
|
||||||
<TextView
|
<TextView
|
||||||
@ -14,6 +14,7 @@
|
|||||||
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"
|
||||||
|
android:layout_marginTop="10dp"
|
||||||
android:layout_centerHorizontal="true"
|
android:layout_centerHorizontal="true"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:textSize="20sp" >
|
android:textSize="20sp" >
|
||||||
|
Loading…
x
Reference in New Issue
Block a user