Added refresh button in enrollment module to update information about

group types and groups
This commit is contained in:
Helena Rodriguez 2012-11-03 01:54:33 +01:00
parent 088e1e8f76
commit 0b86db5c21
3 changed files with 65 additions and 4 deletions

View File

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/groupsLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"

View File

@ -19,6 +19,7 @@ import android.widget.BaseExpandableListAdapter;
import android.widget.CheckBox;
import android.widget.ImageView;
import android.widget.RadioButton;
import android.widget.RelativeLayout;
import android.widget.TextView;
/**
* Adapter to populate with data an expandable list.
@ -40,6 +41,7 @@ public class EnrollmentExpandableListAdapter extends BaseExpandableListAdapter {
TextView openTimeText;
}
private static class ChildHolder{
RelativeLayout relativeLayout;
ImageView imagePadlock;
CheckBox checkBox;
RadioButton radioButton;
@ -80,6 +82,7 @@ public class EnrollmentExpandableListAdapter extends BaseExpandableListAdapter {
if(convertView == null){
convertView = mInflater.inflate(layoutChild, parent, false);
holder = new ChildHolder();
holder.relativeLayout = (RelativeLayout) convertView.findViewById(R.id.groupsLayout);
holder.imagePadlock = (ImageView) convertView.findViewById(R.id.padlockIcon);
holder.checkBox = (CheckBox) convertView.findViewById(R.id.checkBox);
holder.radioButton = (RadioButton) convertView.findViewById(R.id.radioButton);
@ -104,11 +107,25 @@ public class EnrollmentExpandableListAdapter extends BaseExpandableListAdapter {
int open = group.getOpen();
int member = group.getMember();
if(open != 0)
if(open != 0){
holder.imagePadlock.setImageResource(R.drawable.padlockgreen);
else
convertView.setEnabled(true);
/*holder.checkBox.setEnabled(true);
holder.imagePadlock.setEnabled(true);
holder.nStudentText.setEnabled(true);
holder.radioButton.setEnabled(true);
holder.relativeLayout.setEnabled(true);
holder.vacantsText.setEnabled(true);*/
}else{
holder.imagePadlock.setImageResource(R.drawable.padlockred);
convertView.setEnabled(false);
/* holder.checkBox.setEnabled(false);
holder.imagePadlock.setEnabled(false);
holder.nStudentText.setEnabled(false);
holder.radioButton.setEnabled(false);
holder.relativeLayout.setEnabled(false);
holder.vacantsText.setEnabled(false);*/
}
//for multiple inscriptions the groups should be checkboxes to allow multiple choice
//otherwise the groups should be radio button to allow just a single choice
if(multiple == 0){ //single inscriptions:
@ -275,5 +292,10 @@ public class EnrollmentExpandableListAdapter extends BaseExpandableListAdapter {
}
return groupCodes;
}
@Override
public boolean areAllItemsEnabled() {
return false;
}
}

View File

@ -13,6 +13,8 @@ import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.ExpandableListView;
import android.widget.ImageButton;
import android.widget.ProgressBar;
import android.widget.TextView;
import com.android.dataframework.DataFramework;
@ -55,6 +57,12 @@ public class MyGroupsManager extends MenuExpandableListActivity {
private boolean groupTypesRequested = false;
private boolean refreshRequested = false;
private ImageButton updateButton;
private ProgressBar progressbar;
@Override
protected void onStart() {
super.onStart();
@ -110,6 +118,12 @@ public class MyGroupsManager extends MenuExpandableListActivity {
TextView moduleText = (TextView) this.findViewById(R.id.moduleName);
moduleText.setText(R.string.myGroupsModuleLabel);
progressbar = (ProgressBar) this.findViewById(R.id.progress_refresh);
progressbar.setVisibility(View.GONE);
updateButton = (ImageButton)this.findViewById(R.id.refresh);
updateButton.setVisibility(View.VISIBLE);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
@ -127,10 +141,16 @@ public class MyGroupsManager extends MenuExpandableListActivity {
setEmptyMenu();
break;
case Global.GROUPS_REQUEST_CODE:
if(dbHelper.getGroups(courseCode).size() > 0){
if(dbHelper.getGroups(courseCode).size() > 0 || refreshRequested){
getExpandableListView().setVisibility(View.VISIBLE);
this.findViewById(R.id.sendMyGroupsButton).setVisibility(View.VISIBLE);
this.findViewById(R.id.noGroupsText).setVisibility(View.GONE);
updateButton.setVisibility(View.VISIBLE);
progressbar.setVisibility(View.GONE);
refreshRequested = false;
setMenu();
}else
setEmptyMenu();
@ -287,6 +307,24 @@ public class MyGroupsManager extends MenuExpandableListActivity {
return children;
}
/**
* Launches an action when refresh button is pushed.
*
* The listener onClick is set in action_bar.xml
* @param v Actual view
*/
public void onRefreshClick(View v)
{
updateButton.setVisibility(View.GONE);
progressbar.setVisibility(View.VISIBLE);
refreshRequested = true;
Intent activity = new Intent(getBaseContext(),GroupTypes.class);
activity.putExtra("courseCode", courseCode);
startActivityForResult(activity,Global.GROUPTYPES_REQUEST_CODE);
}
}