Commiting stuff the IDE did not

This commit is contained in:
Ziver Koc 2014-07-31 15:01:44 +02:00
parent 73a3de5eb8
commit ff7138bf9d
52 changed files with 3887 additions and 3887 deletions

View file

@ -1,92 +1,92 @@
package com.ericsson.uecontrol.gui.util;
import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.TextView;
import com.ericsson.uecontrol.R;
import com.ericsson.uecontrol.core.UeBehaviour;
import java.util.List;
/**
* Created by ezivkoc on 2014-07-15.
*/
public class BehaviourListAdapter extends StableArrayAdapter<UeBehaviour>{
private static final int VIEW_RESOURCE = R.layout.behaviour_list_item;
private static LayoutInflater inflater = null;
private boolean editable = false;
public BehaviourListAdapter(Activity a, List<UeBehaviour> objects) {
super(a, VIEW_RESOURCE, objects);
inflater = (LayoutInflater)a.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
public View getView(int position, View convertView, ViewGroup parent) {
View vi = convertView;
if(convertView==null)
vi = inflater.inflate(VIEW_RESOURCE, null);
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);
UeBehaviour behaviour = super.getItem(position);
// Setting all values in listview
title.setText(behaviour.getName());
description.setText(behaviour.toString());
if(editable)
draggable.setVisibility(View.VISIBLE);
behaviour.setExecutionListener(new UeBehaviour.BehaviourExecutionListener() {
public void executionStarted() {
progress.post(new Runnable() {
public void run() {
active.setVisibility(View.VISIBLE);
progress.setVisibility(View.VISIBLE);
warning.setVisibility(View.INVISIBLE);
}
});
}
public void progressChanged(final float p) {
progress.setMax(100);
progress.setProgress((int) (p * 100));
}
public void executionStopped() {
progress.post(new Runnable() {
public void run() {
active.setVisibility(View.INVISIBLE);
progress.setVisibility(View.INVISIBLE);
}
});
}
public void exception(Exception e){
warning.post(new Runnable() {
public void run() {
warning.setVisibility(View.VISIBLE);
}
});
}
});
return vi;
}
public void setEditable(boolean b) {
editable = b;
}
}
package com.ericsson.uecontrol.gui.util;
import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.TextView;
import com.ericsson.uecontrol.R;
import com.ericsson.uecontrol.core.UeBehaviour;
import java.util.List;
/**
* Created by ezivkoc on 2014-07-15.
*/
public class BehaviourListAdapter extends StableArrayAdapter<UeBehaviour>{
private static final int VIEW_RESOURCE = R.layout.behaviour_list_item;
private static LayoutInflater inflater = null;
private boolean editable = false;
public BehaviourListAdapter(Activity a, List<UeBehaviour> objects) {
super(a, VIEW_RESOURCE, objects);
inflater = (LayoutInflater)a.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
public View getView(int position, View convertView, ViewGroup parent) {
View vi = convertView;
if(convertView==null)
vi = inflater.inflate(VIEW_RESOURCE, null);
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);
UeBehaviour behaviour = super.getItem(position);
// Setting all values in listview
title.setText(behaviour.getName());
description.setText(behaviour.toString());
if(editable)
draggable.setVisibility(View.VISIBLE);
behaviour.setExecutionListener(new UeBehaviour.BehaviourExecutionListener() {
public void executionStarted() {
progress.post(new Runnable() {
public void run() {
active.setVisibility(View.VISIBLE);
progress.setVisibility(View.VISIBLE);
warning.setVisibility(View.INVISIBLE);
}
});
}
public void progressChanged(final float p) {
progress.setMax(100);
progress.setProgress((int) (p * 100));
}
public void executionStopped() {
progress.post(new Runnable() {
public void run() {
active.setVisibility(View.INVISIBLE);
progress.setVisibility(View.INVISIBLE);
}
});
}
public void exception(Exception e){
warning.post(new Runnable() {
public void run() {
warning.setVisibility(View.VISIBLE);
}
});
}
});
return vi;
}
public void setEditable(boolean b) {
editable = b;
}
}

View file

@ -1,112 +1,112 @@
package com.ericsson.uecontrol.gui.util;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
/**
* Created by ezivkoc on 2014-07-24.
*/
public class Configurator {
/**
* Sets a field in a class as externally configurable.
*/
@Retention(RetentionPolicy.RUNTIME) // Make this annotation accessible at runtime via reflection.
@Target({ElementType.FIELD}) // This annotation can only be applied to class fields.
public static @interface Configurable{
String value();
}
public static enum ConfigType{
STRING, INT
}
private Object obj;
private ConfigurationParam[] params;
public Configurator(Object obj){
this.obj = obj;
this.params = getConfiguration(obj);
}
public ConfigurationParam[] getConfiguration(){
return params;
}
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())) {
try {
conf.add(new ConfigurationParam(f));
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
}
return conf.toArray(new ConfigurationParam[conf.size()]);
}
public void setConfiguration(){
for(ConfigurationParam param : params){
try {
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(){
if(value == null)
return null;
return value.toString();}
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);
}
}
}
package com.ericsson.uecontrol.gui.util;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
/**
* Created by ezivkoc on 2014-07-24.
*/
public class Configurator {
/**
* Sets a field in a class as externally configurable.
*/
@Retention(RetentionPolicy.RUNTIME) // Make this annotation accessible at runtime via reflection.
@Target({ElementType.FIELD}) // This annotation can only be applied to class fields.
public static @interface Configurable{
String value();
}
public static enum ConfigType{
STRING, INT
}
private Object obj;
private ConfigurationParam[] params;
public Configurator(Object obj){
this.obj = obj;
this.params = getConfiguration(obj);
}
public ConfigurationParam[] getConfiguration(){
return params;
}
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())) {
try {
conf.add(new ConfigurationParam(f));
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
}
return conf.toArray(new ConfigurationParam[conf.size()]);
}
public void setConfiguration(){
for(ConfigurationParam param : params){
try {
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(){
if(value == null)
return null;
return value.toString();}
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);
}
}
}

View file

@ -1,73 +1,73 @@
/*
* Copyright (C) 2013 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.ericsson.uecontrol.gui.util;
import android.content.Context;
import android.widget.ArrayAdapter;
import java.util.HashMap;
import java.util.List;
public class StableArrayAdapter<T> extends ArrayAdapter<T> implements DynamicListView.DynamicListActionListener {
final int INVALID_ID = -1;
private HashMap<T, Integer> mIdMap = new HashMap<T, Integer>();
private List<T> objects;
public StableArrayAdapter(Context context, int textViewResourceId, List<T> obj) {
super(context, textViewResourceId, obj);
objects = obj;
generateIds();
}
public void generateIds(){
mIdMap.clear();
for (int i = 0; i < objects.size(); ++i) {
mIdMap.put(objects.get(i), i);
}
}
@Override
public long getItemId(int position) {
if (position < 0 || position >= mIdMap.size()) {
return INVALID_ID;
}
T item = getItem(position);
return mIdMap.get(item);
}
@Override
public void swapItems(int from, int to) {
T temp = objects.get(from);
objects.set(from, objects.get(to));
objects.set(to, temp);
}
@Override
public void removeItem(int which) {
objects.remove(which);
generateIds();
}
@Override
public boolean hasStableIds() {
return true;
}
/*
* Copyright (C) 2013 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.ericsson.uecontrol.gui.util;
import android.content.Context;
import android.widget.ArrayAdapter;
import java.util.HashMap;
import java.util.List;
public class StableArrayAdapter<T> extends ArrayAdapter<T> implements DynamicListView.DynamicListActionListener {
final int INVALID_ID = -1;
private HashMap<T, Integer> mIdMap = new HashMap<T, Integer>();
private List<T> objects;
public StableArrayAdapter(Context context, int textViewResourceId, List<T> obj) {
super(context, textViewResourceId, obj);
objects = obj;
generateIds();
}
public void generateIds(){
mIdMap.clear();
for (int i = 0; i < objects.size(); ++i) {
mIdMap.put(objects.get(i), i);
}
}
@Override
public long getItemId(int position) {
if (position < 0 || position >= mIdMap.size()) {
return INVALID_ID;
}
T item = getItem(position);
return mIdMap.get(item);
}
@Override
public void swapItems(int from, int to) {
T temp = objects.get(from);
objects.set(from, objects.get(to));
objects.set(to, temp);
}
@Override
public void removeItem(int which) {
objects.remove(which);
generateIds();
}
@Override
public boolean hasStableIds() {
return true;
}
}