use of brunonova.drmips.android.DrMIPSActivity in project drmips by brunonova.
the class DlgCodeHelp method setContents.
private void setContents(View rootView) {
DrMIPSActivity activity = (DrMIPSActivity) getActivity();
TableLayout tblInstructions = (TableLayout) rootView.findViewById(R.id.tblInstructions);
TableLayout tblPseudos = (TableLayout) rootView.findViewById(R.id.tblPseudos);
TableRow row;
TextView inst, desc;
tblInstructions.removeAllViews();
tblPseudos.removeAllViews();
CPU cpu = activity.getCPU();
for (Instruction i : cpu.getInstructionSet().getInstructions()) {
row = new TableRow(activity);
inst = new TextView(activity);
inst.setText(i.getUsage() + " ");
row.addView(inst);
desc = new TextView(activity);
desc.setText("# " + (i.hasDescription() ? i.getDescription() : "-"));
row.addView(desc);
tblInstructions.addView(row);
}
for (PseudoInstruction i : cpu.getInstructionSet().getPseudoInstructions()) {
row = new TableRow(activity);
inst = new TextView(activity);
inst.setText(i.getUsage() + " ");
row.addView(inst);
desc = new TextView(activity);
desc.setText("# " + (i.hasDescription() ? i.getDescription() : "-"));
row.addView(desc);
tblPseudos.addView(row);
}
}
use of brunonova.drmips.android.DrMIPSActivity in project drmips by brunonova.
the class DlgConfirmDelete method onClick.
@Override
public void onClick(DialogInterface dialog, int which) {
switch(which) {
case // OK
AlertDialog.BUTTON_POSITIVE:
Bundle args = getArguments();
DrMIPSActivity activity = (DrMIPSActivity) getActivity();
String path = args.getString("path");
File file;
if (path != null && (file = new File(path)).exists()) {
if (file.delete()) {
Toast.makeText(getActivity(), R.string.file_deleted, Toast.LENGTH_SHORT).show();
activity.newFile();
} else
Toast.makeText(getActivity(), R.string.error_deleting_file, Toast.LENGTH_SHORT).show();
}
break;
case // Cancel
AlertDialog.BUTTON_NEGATIVE:
dismiss();
break;
}
}
use of brunonova.drmips.android.DrMIPSActivity in project drmips by brunonova.
the class DlgOpen method onClick.
@Override
public void onClick(DialogInterface dialog, int which) {
Bundle args = getArguments();
DrMIPSActivity activity = (DrMIPSActivity) getActivity();
String[] files = args.containsKey("files") ? args.getStringArray("files") : new String[] {};
if (files != null && which >= 0 && which < files.length) {
String name = files[which];
File file = new File(DrMIPS.getApplication().getCodeDir() + File.separator + name);
activity.openFile(file);
}
dialog.dismiss();
}
use of brunonova.drmips.android.DrMIPSActivity in project drmips by brunonova.
the class DlgOpenCPU method onClick.
@Override
public void onClick(DialogInterface dialog, int which) {
Bundle args = getArguments();
DrMIPSActivity activity = (DrMIPSActivity) getActivity();
String[] files = args.containsKey("files") ? args.getStringArray("files") : new String[] {};
if (files != null && which >= 0 && which < files.length) {
String name = files[which];
File file = new File(DrMIPS.getApplication().getCPUDir() + File.separator + name);
try {
activity.loadCPU(file);
activity.setCurrentTab("tabDatapath");
} catch (Throwable ex) {
Toast.makeText(getActivity(), getString(R.string.invalid_file) + "\n" + ex.getClass().getName() + " (" + ex.getMessage() + ")", Toast.LENGTH_LONG).show();
Log.e(getActivity().getClass().getName(), "error loading CPU \"" + file.getName() + "\"", ex);
}
}
dialog.dismiss();
}
use of brunonova.drmips.android.DrMIPSActivity in project drmips by brunonova.
the class DlgEditRegister method onClick.
@Override
public void onClick(DialogInterface dialog, int which) {
switch(which) {
case //OK
AlertDialog.BUTTON_POSITIVE:
String value = txtRegisterValue.getText().toString().trim();
int val;
if (!value.isEmpty()) {
try {
Bundle args = getArguments();
DrMIPSActivity activity = (DrMIPSActivity) getActivity();
int index = args.getInt("index");
if (index >= 0 && index <= activity.getCPU().getRegBank().getNumberOfRegisters()) {
val = Integer.parseInt(value);
activity.setRegisterValue(index, val);
activity.refreshRegistersTableValues();
}
} catch (NumberFormatException ex) {
Toast.makeText(getActivity(), R.string.invalid_value, Toast.LENGTH_SHORT).show();
}
}
break;
case // Cancel
AlertDialog.BUTTON_NEGATIVE:
dismiss();
break;
}
}
Aggregations