mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-11 08:36:38 -04:00
Server list now changes colour for clicked row
This commit is contained in:
parent
069325fcf8
commit
7b733e610c
@ -57,6 +57,7 @@ import android.view.inputmethod.EditorInfo;
|
|||||||
import android.view.inputmethod.InputConnection;
|
import android.view.inputmethod.InputConnection;
|
||||||
import android.view.inputmethod.InputMethodManager;
|
import android.view.inputmethod.InputMethodManager;
|
||||||
import android.widget.AbsoluteLayout;
|
import android.widget.AbsoluteLayout;
|
||||||
|
import android.widget.AdapterView;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
import android.widget.BaseAdapter;
|
import android.widget.BaseAdapter;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
@ -71,8 +72,6 @@ import android.widget.ProgressBar;
|
|||||||
import android.widget.RelativeLayout;
|
import android.widget.RelativeLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import com.classicube.android.client.R;
|
|
||||||
|
|
||||||
// This class contains all the glue/interop code for bridging ClassiCube to the java Android world.
|
// This class contains all the glue/interop code for bridging ClassiCube to the java Android world.
|
||||||
// Some functionality is only available on later Android versions - try {} catch {} is used in such places
|
// Some functionality is only available on later Android versions - try {} catch {} is used in such places
|
||||||
// to ensure that the game can still run on earlier Android versions (albeit with reduced functionality)
|
// to ensure that the game can still run on earlier Android versions (albeit with reduced functionality)
|
||||||
@ -805,10 +804,27 @@ public class MainActivity extends Activity
|
|||||||
View.SCROLL_INDICATOR_START |
|
View.SCROLL_INDICATOR_START |
|
||||||
View.SCROLL_INDICATOR_END);
|
View.SCROLL_INDICATOR_END);
|
||||||
list.setScrollbarFadingEnabled(false);*/
|
list.setScrollbarFadingEnabled(false);*/
|
||||||
|
final CCTableAdapter adapter = new CCTableAdapter(MainActivity.this);
|
||||||
|
// https://stackoverflow.com/questions/2454337/why-is-my-onitemselectedlistener-not-called-in-a-listview
|
||||||
|
|
||||||
|
list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||||
|
View prev;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||||
|
if (prev != null) {
|
||||||
|
int prevPos = list.getPositionForView(prev);
|
||||||
|
if (prevPos >= 0)
|
||||||
|
prev.setBackgroundColor(adapter.getRowColor(prevPos, false));
|
||||||
|
}
|
||||||
|
|
||||||
|
prev = view;
|
||||||
|
view.setBackgroundColor(adapter.getRowColor(position, true));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
return showWidgetAsync(list, lp, new UICallback() {
|
return showWidgetAsync(list, lp, new UICallback() {
|
||||||
public void execute() {
|
public void execute() {
|
||||||
CCTableAdapter adapter = new CCTableAdapter(MainActivity.this, list.getId());
|
|
||||||
list.setAdapter(adapter);
|
list.setAdapter(adapter);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -849,11 +865,9 @@ public class MainActivity extends Activity
|
|||||||
{
|
{
|
||||||
public Object[] entries = new Object[0];
|
public Object[] entries = new Object[0];
|
||||||
Context ctx;
|
Context ctx;
|
||||||
int listID;
|
|
||||||
|
|
||||||
public CCTableAdapter(Context context, int id) {
|
public CCTableAdapter(Context context) {
|
||||||
ctx = context;
|
ctx = context;
|
||||||
listID = id;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -884,11 +898,15 @@ public class MainActivity extends Activity
|
|||||||
title.setText(entry.title);
|
title.setText(entry.title);
|
||||||
details.setText(entry.details);
|
details.setText(entry.details);
|
||||||
|
|
||||||
int color = tableGetColor(position, false, entry.featured);
|
convertView.setBackgroundColor(getRowColor(position, false));
|
||||||
convertView.setBackgroundColor(color);
|
|
||||||
return convertView;
|
return convertView;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getRowColor(int position, boolean selected) {
|
||||||
|
TableEntry entry = (TableEntry)entries[position];
|
||||||
|
return tableGetColor(position, selected, entry.featured);
|
||||||
|
}
|
||||||
|
|
||||||
View createRow(int position) {
|
View createRow(int position) {
|
||||||
ImageView image = new ImageView(ctx);
|
ImageView image = new ImageView(ctx);
|
||||||
LinearLayout.LayoutParams imageLP = new LinearLayout.LayoutParams(
|
LinearLayout.LayoutParams imageLP = new LinearLayout.LayoutParams(
|
||||||
@ -1176,11 +1194,11 @@ public class MainActivity extends Activity
|
|||||||
keyboardType = flags;
|
keyboardType = flags;
|
||||||
keyboardText = text;
|
keyboardText = text;
|
||||||
//runOnUiThread(new Runnable() {
|
//runOnUiThread(new Runnable() {
|
||||||
//public void run() {
|
//public void run() {
|
||||||
// Restart view so it uses the right INPUT_TYPE
|
// Restart view so it uses the right INPUT_TYPE
|
||||||
if (curView != null) input.restartInput(curView);
|
if (curView != null) input.restartInput(curView);
|
||||||
if (curView != null) input.showSoftInput(curView, 0);
|
if (curView != null) input.showSoftInput(curView, 0);
|
||||||
//}
|
//}
|
||||||
//});
|
//});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1192,9 +1210,9 @@ public class MainActivity extends Activity
|
|||||||
input.hideSoftInputFromWindow(view.getWindowToken(), 0);
|
input.hideSoftInputFromWindow(view.getWindowToken(), 0);
|
||||||
keyboardText = "";
|
keyboardText = "";
|
||||||
//runOnUiThread(new Runnable() {
|
//runOnUiThread(new Runnable() {
|
||||||
//public void run() {
|
//public void run() {
|
||||||
if (curView != null) input.hideSoftInputFromWindow(curView.getWindowToken(), 0);
|
if (curView != null) input.hideSoftInputFromWindow(curView.getWindowToken(), 0);
|
||||||
//}
|
//}
|
||||||
//});
|
//});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user