Skip to content

Commit

Permalink
GridItem dialog: display plugin category alongside with its name
Browse files Browse the repository at this point in the history
  • Loading branch information
quentin-st committed Jan 12, 2016
1 parent 3afc38c commit b78d165
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 86 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

import com.chteuchteu.munin.MuninFoo;
import com.chteuchteu.munin.R;
import com.chteuchteu.munin.adptr.Adapter_CheckablePluginsList;
import com.chteuchteu.munin.adptr.Adapter_IconList;
import com.chteuchteu.munin.adptr.Adapter_NodesList;
import com.chteuchteu.munin.hlpr.Settings;
Expand Down Expand Up @@ -301,29 +302,19 @@ public void onItemClick(AdapterView<?> arg0, View arg1, int pos, long arg3) {

private static void add_pluginsListDialog(final Context c, final MuninNode node, final MuninFoo f, final Grid g, final IGridActivity activity, final Fragment_Grid fragment,
final int X, final int Y) {
List<MuninPlugin> l = node.getPlugins();

final CharSequence[] items = new CharSequence[l.size()];
for (int i=0; i<l.size(); i++)
items[i] = l.get(i).getFancyName();

final List<Integer> selectedItems = new ArrayList<>();

final Adapter_CheckablePluginsList pluginsAdapter = new Adapter_CheckablePluginsList(c, node.getPlugins());
ListView pluginsList = new ListView(c);
pluginsList.setAdapter(pluginsAdapter);

AlertDialog dialog;
AlertDialog.Builder builder = new AlertDialog.Builder(c);
builder.setTitle(c.getText(R.string.text72));
builder.setMultiChoiceItems(items, null, new DialogInterface.OnMultiChoiceClickListener() {
@Override
public void onClick(DialogInterface dialog, int indexSelected, boolean isChecked) {
if (isChecked)
selectedItems.add(indexSelected);
else if (selectedItems.contains(indexSelected))
selectedItems.remove(Integer.valueOf(indexSelected));
}
})
.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
builder.setTitle(c.getText(R.string.text72))
.setView(pluginsList)
.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
List<MuninPlugin> selectedItems = pluginsAdapter.getSelectedItems();

if (selectedItems.isEmpty())
return;

Expand All @@ -333,8 +324,7 @@ public void onClick(DialogInterface dialog, int id) {

int maxWidth = g.getNbColumns();
List<GridItem> addedItems = new ArrayList<>();
for (Integer i : selectedItems) {
MuninPlugin p = node.getPlugin(i);
for (MuninPlugin p : selectedItems) {
if (!alreadyAdded(g, p)) {
GridItem item = new GridItem(g, p);
item.setActivityReferences(c, activity, fragment);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public void onClick(View view) {
MuninNode node = muninFoo.getNodes().get(i);

LayoutInflater vi = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View v = vi.inflate(R.layout.servers_list_checkbox, null);
View v = vi.inflate(R.layout.adapter_twolines_checkbox, null);

checkboxes[i] = (CheckBox) v.findViewById(R.id.line_0);
int id = Resources.getSystem().getIdentifier("btn_check_holo_light", "drawable", "android");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ protected void onCreate(Bundle savedInstanceState) {

for (int i=0; i<muninFoo.getNodes().size(); i++) {
LayoutInflater vi = (LayoutInflater) getApplicationContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View v = vi.inflate(R.layout.servers_list_checkbox, checkboxesView, false);
View v = vi.inflate(R.layout.adapter_twolines_checkbox, checkboxesView, false);

checkboxes[i] = (CheckBox) v.findViewById(R.id.line_0);
int id = Resources.getSystem().getIdentifier("btn_check_holo_light", "drawable", "android");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@
android:textColor="#333333"
android:textSize="20sp" />

</LinearLayout>
</LinearLayout>
31 changes: 0 additions & 31 deletions muninforAndroid/src/main/res/layout/servers_list_checkbox.xml

This file was deleted.

31 changes: 0 additions & 31 deletions muninforAndroid/src/main/res/layout/twolineslist.xml

This file was deleted.

0 comments on commit b78d165

Please sign in to comment.