Initial commit
This commit is contained in:
commit
b305095ab3
79 changed files with 4092 additions and 0 deletions
87
app/src/main/java/com/ericsson/uecontrol/gui/EditActivity.java
Executable file
87
app/src/main/java/com/ericsson/uecontrol/gui/EditActivity.java
Executable file
|
|
@ -0,0 +1,87 @@
|
|||
package com.ericsson.uecontrol.gui;
|
||||
|
||||
import android.app.ListActivity;
|
||||
import android.os.Bundle;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.ListView;
|
||||
|
||||
import com.ericsson.uecontrol.R;
|
||||
import com.ericsson.uecontrol.core.UeBehaviour;
|
||||
import com.ericsson.uecontrol.core.UeControlExecutor;
|
||||
import com.ericsson.uecontrol.gui.fragments.SelectBehaviourDialog;
|
||||
import com.ericsson.uecontrol.gui.util.BehaviourListAdapter;
|
||||
import com.ericsson.uecontrol.gui.util.DynamicListView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class EditActivity extends ListActivity implements View.OnClickListener {
|
||||
private UeControlExecutor executor;
|
||||
private BehaviourListAdapter adapter;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_edit);
|
||||
|
||||
final List<UeBehaviour> list;
|
||||
if(getIntent().hasExtra("executor")) {
|
||||
int executorIndex = getIntent().getExtras().getInt("executor_index");
|
||||
executor = MainActivity.getExecutor(executorIndex);
|
||||
|
||||
list = executor.getBehaviourList();
|
||||
}
|
||||
else
|
||||
list = new ArrayList<UeBehaviour>();
|
||||
|
||||
adapter = new BehaviourListAdapter(this, list);
|
||||
adapter.setEditable(true);
|
||||
DynamicListView listView = (DynamicListView) findViewById(android.R.id.list);
|
||||
listView.setAdapter(adapter);
|
||||
listView.setActionListener(adapter);
|
||||
listView.setOnClickListener(this);
|
||||
listView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
// Inflate the menu; this adds items to the action bar if it is present.
|
||||
getMenuInflater().inflate(R.menu.edit, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
// Handle action bar item clicks here. The action bar will
|
||||
// automatically handle clicks on the Home/Up button, so long
|
||||
// as you specify a parent activity in AndroidManifest.xml.
|
||||
int id = item.getItemId();
|
||||
if (id == R.id.action_add) {
|
||||
SelectBehaviourDialog selector = new SelectBehaviourDialog();
|
||||
selector.setSelectionCallback(new SelectBehaviourDialog.BehaviourSelectionCallback() {
|
||||
public void behaviourSelected(String name, Class<UeBehaviour> objClass) {
|
||||
try {
|
||||
UeBehaviour obj = objClass.newInstance();
|
||||
executor.addBehaviour(obj);
|
||||
adapter.generateIds();
|
||||
adapter.notifyDataSetChanged();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
selector.show(getFragmentManager(), "behaviour_selector");
|
||||
return true;
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue