Skip to content

Commit

Permalink
Merge pull request #471 from TypicalGitHubUser/no-groups-message
Browse files Browse the repository at this point in the history
Add empty message if no groups available
  • Loading branch information
therajanmaurya authored Feb 21, 2017
2 parents fbd4258 + 80129ce commit 8b570c6
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.ViewFlipper;

import com.mifos.mifosxdroid.R;
import com.mifos.mifosxdroid.adapters.GroupListAdapter;
Expand All @@ -37,6 +40,15 @@ public class GroupListFragment extends ProgressableFragment
@BindView(R.id.lv_group_list)
ListView lv_groupList;

@BindView(R.id.ll_error)
LinearLayout ll_error;

@BindView(R.id.view_flipper)
ViewFlipper viewFlipper;

@BindView(R.id.noGroupsText)
TextView noGroupsText;

@Inject
GroupListPresenter mGroupListPresenter;

Expand Down Expand Up @@ -88,21 +100,22 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle
return rootView;
}


public void inflateGroupList() {
mGroupListPresenter.loadGroupByCenter(centerId);
}


@Override
public void showGroupList(CenterWithAssociations centerWithAssociations) {
if (centerWithAssociations != null) {

mCenterWithAssociations = centerWithAssociations;
mGroupListAdapter = new GroupListAdapter(getActivity(),
centerWithAssociations.getGroupMembers());
lv_groupList.setAdapter(mGroupListAdapter);

if (centerWithAssociations.getGroupMembers().size() == 0) {
showEmptyGroups(R.string.empty_groups);
} else {
mCenterWithAssociations = centerWithAssociations;
mGroupListAdapter = new GroupListAdapter(getActivity(),
centerWithAssociations.getGroupMembers());
lv_groupList.setAdapter(mGroupListAdapter);
}
}
}

Expand All @@ -118,6 +131,13 @@ public void showFetchingError(String s) {
Toast.makeText(getActivity(), s, Toast.LENGTH_SHORT).show();
}

@Override
public void showEmptyGroups(int message) {
viewFlipper.setVisibility(View.GONE);
ll_error.setVisibility(View.VISIBLE);
noGroupsText.setText(getStringMessage(message));
}

@Override
public void showProgressbar(boolean b) {
showProgress(b);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,7 @@ public interface GroupListMvpView extends MvpView {

void showFetchingError(String s);

void showEmptyGroups(int messageId);

void showGroups(GroupWithAssociations groupWithAssociations);
}
28 changes: 26 additions & 2 deletions mifosng-android/src/main/res/layout/fragment_group_list.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
~ See https://github.com/openMF/android-client/blob/master/LICENSE.md
-->

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
Expand All @@ -26,5 +26,29 @@
android:id="@+id/lv_group_list"
android:layout_width="match_parent"
android:layout_height="match_parent" />

</ViewFlipper>
</LinearLayout>

<LinearLayout
android:id="@+id/ll_error"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="vertical"
android:visibility="gone">

<ImageView
android:id="@+id/noGroupsIcon"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_gravity="center"
android:src="@drawable/ic_error_black_24dp" />

<TextView
android:id="@+id/noGroupsText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"/>
</LinearLayout>

</FrameLayout>
1 change: 1 addition & 0 deletions mifosng-android/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@
<string name="empty_client_list">Empty ClientList</string>
<string name="empty_group_clients">Empty Group ClientList</string>
<string name="empty_groups_list">Empty GroupList</string>
<string name="empty_groups">No group associated with this center</string>
<string name="empty_center_list">Empty CenterList</string>
<string name="empty_path_tracking">Empty Path Tracking</string>
<string name="empty_data_table">Empty DataTable</string>
Expand Down

0 comments on commit 8b570c6

Please sign in to comment.