Skip to content

Commit

Permalink
Merge pull request #536 from therajanmaurya/groupdatatable
Browse files Browse the repository at this point in the history
feat: group more info
  • Loading branch information
therajanmaurya authored Feb 19, 2017
2 parents cd21fa5 + 8fc14ac commit 58c9153
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 57 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
public void onPrepareOptionsMenu(Menu menu) {
menu.clear();
if (isClientActive) {
menu.addSubMenu(Menu.NONE, MENU_ITEM_DATA_TABLES, Menu.NONE, Constants
menu.add(Menu.NONE, MENU_ITEM_DATA_TABLES, Menu.NONE, Constants
.DATA_TABLE_CLIENTS_NAME);
menu.add(Menu.NONE, MENU_ITEM_PIN_POINT, Menu.NONE, getString(R.string.pinpoint));
menu.add(Menu.NONE, MENU_ITEM_CLIENT_CHARGES, Menu.NONE, getString(R.string.charges));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,17 @@
import com.mifos.mifosxdroid.core.MifosBaseActivity;
import com.mifos.mifosxdroid.core.MifosBaseFragment;
import com.mifos.mifosxdroid.online.activate.ActivateFragment;
import com.mifos.mifosxdroid.online.datatable.DataTableFragment;
import com.mifos.mifosxdroid.online.documentlist.DocumentListFragment;
import com.mifos.mifosxdroid.online.grouploanaccount.GroupLoanAccountFragment;
import com.mifos.objects.accounts.GroupAccounts;
import com.mifos.objects.accounts.savings.DepositType;
import com.mifos.objects.client.Client;
import com.mifos.objects.group.Group;
import com.mifos.objects.noncore.DataTable;
import com.mifos.utils.Constants;
import com.mifos.utils.FragmentConstants;
import com.mifos.utils.Utils;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import javax.inject.Inject;
Expand Down Expand Up @@ -105,7 +103,6 @@ public class GroupDetailsFragment extends MifosBaseFragment implements GroupDeta
private int groupId;
private AccountAccordion accountAccordion;
private OnFragmentInteractionListener mListener;
public List<DataTable> clientDataTables = new ArrayList<>();

public static GroupDetailsFragment newInstance(int groupId) {
GroupDetailsFragment fragment = new GroupDetailsFragment();
Expand Down Expand Up @@ -134,7 +131,6 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle
mGroupDetailsPresenter.attachView(this);

mGroupDetailsPresenter.loadGroupDetailsAndAccounts(groupId);
mGroupDetailsPresenter.loadClientDataTable();

return rootView;
}
Expand Down Expand Up @@ -170,6 +166,16 @@ public void addGroupLoanAccount() {
fragmentTransaction.commit();
}

public void loadGroupDataTables() {
DataTableFragment dataTableFragment = DataTableFragment.newInstance(Constants
.DATA_TABLE_NAME_GROUP, groupId);
FragmentTransaction fragmentTransaction = getActivity().getSupportFragmentManager()
.beginTransaction();
fragmentTransaction.addToBackStack(FragmentConstants.FRAG_GROUP_DETAILS);
fragmentTransaction.replace(R.id.container, dataTableFragment);
fragmentTransaction.commit();
}

@Override
public void showProgressbar(boolean show) {
if (show) {
Expand Down Expand Up @@ -267,17 +273,6 @@ public void onItemClick(AdapterView<?> adapterView, View view, int i,
}
}

@Override
public void showGroupDataTable(List<DataTable> dataTables) {
if (dataTables != null) {
Iterator<DataTable> dataTableIterator = dataTables.iterator();
clientDataTables.clear();
while (dataTableIterator.hasNext()) {
clientDataTables.add(dataTableIterator.next());
}
}
}

@Override
public void showFetchingError(int errorMessage) {
Toast.makeText(getActivity(), getStringMessage(errorMessage), Toast.LENGTH_SHORT).show();
Expand All @@ -297,13 +292,16 @@ public void onAttach(Activity activity) {

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.group, menu);
inflater.inflate(R.menu.menu_group, menu);
super.onCreateOptionsMenu(menu, inflater);
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.more_group_info:
loadGroupDataTables();
break;
case R.id.documents:
loadDocuments();
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import com.mifos.objects.accounts.GroupAccounts;
import com.mifos.objects.client.Client;
import com.mifos.objects.group.Group;
import com.mifos.objects.noncore.DataTable;

import java.util.List;

Expand All @@ -20,7 +19,5 @@ public interface GroupDetailsMvpView extends MvpView {

void showGroupAccounts(GroupAccounts groupAccounts);

void showGroupDataTable(List<DataTable> dataTables);

void showFetchingError(int errorMessage);
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
package com.mifos.mifosxdroid.online.groupdetails;

import com.mifos.api.datamanager.DataManagerDataTable;
import com.mifos.api.datamanager.DataManagerGroups;
import com.mifos.mifosxdroid.R;
import com.mifos.mifosxdroid.base.BasePresenter;
import com.mifos.objects.accounts.GroupAccounts;
import com.mifos.objects.group.Group;
import com.mifos.objects.group.GroupWithAssociations;
import com.mifos.objects.noncore.DataTable;
import com.mifos.objects.zipmodels.GroupAndGroupAccounts;
import com.mifos.utils.Constants;

import java.util.List;

import javax.inject.Inject;

Expand All @@ -28,14 +23,11 @@
public class GroupDetailsPresenter extends BasePresenter<GroupDetailsMvpView> {

private final DataManagerGroups mDataManagerGroups;
private final DataManagerDataTable mDataManagerDataTable;
private CompositeSubscription mSubscriptions;

@Inject
public GroupDetailsPresenter(DataManagerGroups dataManagerGroups,
DataManagerDataTable dataManagerDataTable) {
public GroupDetailsPresenter(DataManagerGroups dataManagerGroups) {
mDataManagerGroups = dataManagerGroups;
mDataManagerDataTable = dataManagerDataTable;
mSubscriptions = new CompositeSubscription();
}

Expand Down Expand Up @@ -112,27 +104,4 @@ public void onNext(GroupWithAssociations groupWithAssociations) {
);
}


public void loadClientDataTable() {
checkViewAttached();
mSubscriptions.add(mDataManagerDataTable.getDataTable(Constants.DATA_TABLE_NAME_GROUP)
.observeOn(AndroidSchedulers.mainThread())
.subscribeOn(Schedulers.io())
.subscribe(new Subscriber<List<DataTable>>() {
@Override
public void onCompleted() {
}

@Override
public void onError(Throwable e) {
getMvpView().showFetchingError(R.string.failed_to_fetch_datatable);
}

@Override
public void onNext(List<DataTable> dataTables) {
getMvpView().showGroupDataTable(dataTables);
}
}));
}

}
2 changes: 1 addition & 1 deletion mifosng-android/src/main/res/layout/item_data_table.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
android:foreground="?android:attr/selectableItemBackground"
app:cardUseCompatPadding="true">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,16 @@
-->

<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context="com.mifos.mifosxdroid.online.GroupsActivity">
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context="com.mifos.mifosxdroid.online.GroupsActivity">

<item
android:id="@+id/more_group_info"
android:enabled="true"
android:title="@string/more_group_info"
app:showAsAction="never" />


<item
android:id="@+id/add_group_loan"
Expand Down
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 @@ -88,6 +88,7 @@
<string name="savings_account_closed">Savings Account Closed</string>
<string name="savings_account_activated">Savings Account Activated</string>
<string name="more_info">More client info</string>
<string name="more_group_info">More group Info</string>
<string name="pinpoint">Pinpoint location</string>
<string name="charges">Charges </string>
<string name="add_loan">Add Loan Account</string>
Expand Down

0 comments on commit 58c9153

Please sign in to comment.