Back to project page NoiseBridge_General.
The source code is released under:
GPLv3.txt
If you think the Android project NoiseBridge_General listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.noysbrij.noisebridgeGeneral; /*from w w w . ja v a 2 s . c o m*/ import android.app.Activity; import android.util.SparseArray; import android.view.LayoutInflater; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; import android.widget.BaseExpandableListAdapter; import android.widget.CheckedTextView; import android.widget.TextView; import android.widget.Toast; import android.util.*; import android.content.*; import android.app.*; import android.widget.*; import android.view.*; import android.widget.RadioGroup.*; import android.os.storage.*; class TicketsExpandableListAdapter extends BaseExpandableListAdapter { //after this class has full functionality, expand it with reflection //reflection in a listview will murder performance/joules private final Tickets tickets; public LayoutInflater inflater; public Activity activity; private LinearLayout adbParent; public TicketsExpandableListAdapter(Activity act, Tickets tickets) { this.activity = act; this.tickets = tickets; inflater = act.getLayoutInflater(); } @Override public Object getChild(int groupPosition, int childPosition) { if (childPosition == 0) return tickets.tickets.get(groupPosition).complexity; else if (childPosition == 1) return tickets.tickets.get(groupPosition).created_at; else if (childPosition == 2) return tickets.tickets.get(groupPosition).description; else if (childPosition == 3) return tickets.tickets.get(groupPosition).status; else {return null;} } public String getKey(int childPosition) { String string = null; switch (childPosition) { case 0: string = activity.getString(R.string.complexity_label); break; case 1: string = activity.getString(R.string.created_at_label); break; case 2: string = activity.getString(R.string.description_label); break; case 3: string = activity.getString(R.string.status_label); break; } return string; } public void editChild(int childPosition) { } @Override public long getChildId(int groupPosition, int childPosition) { return 0; } @Override public View getChildView(int groupPosition, final int childPosition, boolean isLastChild, View convertView, ViewGroup parent) { final String child = (String) getChild(groupPosition, childPosition); final String key = getKey(childPosition); TextView text = null; if (convertView == null) { convertView = inflater.inflate(R.layout.listrow_details, null); } text = (TextView) convertView.findViewById(R.id.textView1); text.setText(key + " " + child); convertView.setOnClickListener(new OnClickListener(){ //derp derp derp.... @Override public void onClick(View v) { Toast.makeText(activity, child, Toast.LENGTH_SHORT).show(); AlertDialog.Builder adb = new AlertDialog.Builder(activity); adbParent = new LinearLayout(activity); adbParent.setGravity(Gravity.CENTER); adbParent.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); switch (childPosition) { case 0: final RatingBar complexityRating = new RatingBar(activity); //should be integer thatdescribesmaxstars complexityRating.setNumStars(10); complexityRating.setRating(Integer.valueOf(child)); complexityRating.setStepSize(0.1f); complexityRating.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); adbParent.addView(complexityRating); adb.setTitle("Redefine Complexity"); adb.setView(adbParent); break; case 1: final TextView createdAtDisplay = new TextView(activity); createdAtDisplay.setText(child); adb.setView(createdAtDisplay); adb.setTitle("Creation Date"); break; case 2: final EditText descriptionInput = new EditText(activity); descriptionInput.setText(child); adb.setView(descriptionInput); adb.setTitle("Redefine Description"); break; case 3: final ToggleButton toggle = new ToggleButton(activity); toggle.setTextOff("closed"); toggle.setTextOn("open"); if (child == "open") toggle.setChecked(true); else {toggle.setChecked(false); Toast.makeText(activity, "setchecked false", Toast.LENGTH_SHORT).show(); } adb.setView(toggle); adb.setTitle("Ticket status"); toggle.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { // The toggle is enabled } else { // The toggle is disabled } } }); break; } // Button OK adb.setPositiveButton(R.string.submit, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { //send string to HTML that indicates new complexityvalue //reload list dialog.dismiss(); } }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); adb.create(); adb.show(); } }); //too general return convertView; } @Override public int getChildrenCount(int groupPosition) { return 4; } @Override public Object getGroup(int groupPosition) { return tickets.tickets.get(groupPosition); } @Override public int getGroupCount() { Log.e("NBG", "true? " + tickets.tickets.isEmpty()); return tickets.tickets.size(); } @Override public void onGroupCollapsed(int groupPosition) { super.onGroupCollapsed(groupPosition); } @Override public void onGroupExpanded(int groupPosition) { super.onGroupExpanded(groupPosition); } @Override public long getGroupId(int groupPosition) { return 0; } @Override public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) { if (convertView == null) { convertView = inflater.inflate(R.layout.listrow_group, null); } Ticket ticket = (Ticket) getGroup(groupPosition); ((CheckedTextView) convertView).setText(ticket.title); ((CheckedTextView) convertView).setChecked(isExpanded); return convertView; } @Override public boolean hasStableIds() { return false; } @Override public boolean isChildSelectable(int groupPosition, int childPosition) { return false; } }