Added warning icon
Some more work on settings Configuration dialog finished
This commit is contained in:
parent
1aec61f810
commit
ba153f5708
17 changed files with 187 additions and 77 deletions
|
|
@ -38,6 +38,7 @@ public class BehaviourListAdapter extends StableArrayAdapter<UeBehaviour>{
|
|||
ImageView draggable = (ImageView)vi.findViewById(R.id.draggable);
|
||||
TextView title = (TextView)vi.findViewById(R.id.title);
|
||||
TextView description = (TextView)vi.findViewById(R.id.description);
|
||||
final ImageView warning = (ImageView) vi.findViewById(R.id.warning);
|
||||
final ProgressBar active = (ProgressBar)vi.findViewById(R.id.active);
|
||||
final ProgressBar progress = (ProgressBar) vi.findViewById(R.id.progress);
|
||||
|
||||
|
|
@ -56,6 +57,7 @@ public class BehaviourListAdapter extends StableArrayAdapter<UeBehaviour>{
|
|||
public void run() {
|
||||
active.setVisibility(View.VISIBLE);
|
||||
progress.setVisibility(View.VISIBLE);
|
||||
warning.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
@ -71,6 +73,13 @@ public class BehaviourListAdapter extends StableArrayAdapter<UeBehaviour>{
|
|||
}
|
||||
});
|
||||
}
|
||||
public void exception(Exception e){
|
||||
warning.post(new Runnable() {
|
||||
public void run() {
|
||||
warning.setVisibility(View.VISIBLE);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
return vi;
|
||||
|
|
@ -79,4 +88,5 @@ public class BehaviourListAdapter extends StableArrayAdapter<UeBehaviour>{
|
|||
public void setEditable(boolean b) {
|
||||
editable = b;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,20 +25,6 @@ public class Configurator {
|
|||
STRING, INT
|
||||
}
|
||||
|
||||
public static class ConfigurationParam{
|
||||
protected Field field;
|
||||
protected ConfigType type;
|
||||
protected Object value;
|
||||
|
||||
public ConfigType getType(){return type;}
|
||||
|
||||
public int getInt (){return (Integer) value;}
|
||||
public String setString(){return (String) value;}
|
||||
|
||||
public void setInt (int v) {value = v;}
|
||||
public void setString(String v){value = v;}
|
||||
}
|
||||
|
||||
|
||||
private Object obj;
|
||||
private ConfigurationParam[] params;
|
||||
|
|
@ -52,30 +38,72 @@ public class Configurator {
|
|||
return params;
|
||||
}
|
||||
|
||||
protected static ConfigurationParam[] getConfiguration(Object obj){
|
||||
protected ConfigurationParam[] getConfiguration(Object obj){
|
||||
Class c = obj.getClass();
|
||||
ArrayList<ConfigurationParam> conf = new ArrayList<ConfigurationParam>();
|
||||
|
||||
Field[] all = c.getDeclaredFields();
|
||||
for(Field f : all){
|
||||
if(f.isAnnotationPresent(Configurable.class) && !Modifier.isStatic(f.getModifiers())) {
|
||||
ConfigurationParam confParam = new ConfigurationParam();
|
||||
confParam.field = f;
|
||||
conf.add(confParam);
|
||||
try {
|
||||
conf.add(new ConfigurationParam(f));
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return conf.toArray(new ConfigurationParam[conf.size()]);
|
||||
}
|
||||
|
||||
protected static void setConfiguration(ConfigurationParam[] params, Object obj){
|
||||
public void setConfiguration(){
|
||||
for(ConfigurationParam param : params){
|
||||
try {
|
||||
param.field.setAccessible(true);
|
||||
param.field.set(obj, param.value);
|
||||
param.set();
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class ConfigurationParam{
|
||||
protected Field field;
|
||||
protected String name;
|
||||
protected String niceName;
|
||||
protected ConfigType type;
|
||||
protected Object value;
|
||||
|
||||
|
||||
protected ConfigurationParam(Field f) throws IllegalAccessException {
|
||||
field = f;
|
||||
field.setAccessible(true);
|
||||
name = field.getName();
|
||||
niceName = field.getAnnotation(Configurable.class).value();
|
||||
value = field.get(obj);
|
||||
|
||||
if (f.getType() == String.class) type = ConfigType.STRING;
|
||||
else if(f.getType() == int.class) type = ConfigType.INT;
|
||||
|
||||
}
|
||||
|
||||
public String getName(){return name;}
|
||||
public String getNiceName(){return niceName;}
|
||||
public ConfigType getType(){return type;}
|
||||
|
||||
public String getString(){return (String) value;}
|
||||
|
||||
public void setString(String v){
|
||||
switch(type){
|
||||
case STRING:
|
||||
value = v; break;
|
||||
case INT:
|
||||
value = Integer.parseInt(v); break;
|
||||
}
|
||||
}
|
||||
|
||||
protected void set() throws IllegalAccessException {
|
||||
field.set(obj, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
/*
|
||||
* Copyright (C) 2013 The Android Open Source Project
|
||||
* https://android.googlesource.com/platform/development/+/master/samples/devbytes/animation/ListViewDraggingAnimation/src/com/example/android/listviewdragginganimation/DynamicListView.java
|
||||
* Modified by Ziver Koc
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -57,6 +59,7 @@ import android.widget.ListView;
|
|||
* <p/>
|
||||
* When the hover cell is either above or below the bounds of the listview, this
|
||||
* listview also scrolls on its own so as to reveal additional content.
|
||||
*
|
||||
*/
|
||||
public class DynamicListView extends ListView {
|
||||
private static final int INVALID_POINTER_ID = -1;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue