Skip to content

Commit

Permalink
feat: fetch & show notes for client and group
Browse files Browse the repository at this point in the history
  • Loading branch information
rahulbabbar1 committed Mar 4, 2017
1 parent 5d929aa commit a68edb0
Show file tree
Hide file tree
Showing 19 changed files with 725 additions and 11 deletions.
1 change: 1 addition & 0 deletions config/quality/pmd/pmd-ruleset.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,6 @@
<exclude name="ShortVariable" />
<exclude name="ShortClassName" />
<exclude name="VariableNamingConventions" />
<exclude name="AvoidFieldNameMatchingTypeName" />
</rule>
</ruleset>
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import com.mifos.api.services.DocumentService;
import com.mifos.api.services.GroupService;
import com.mifos.api.services.LoanService;
import com.mifos.api.services.NoteService;
import com.mifos.api.services.OfficeService;
import com.mifos.api.services.RunReportsService;
import com.mifos.api.services.SavingsAccountService;
Expand Down Expand Up @@ -54,6 +55,7 @@ public class BaseApiManager {
private static StaffService staffApi;
private static SurveyService surveyApi;
private static RunReportsService runreportsService;
private static NoteService noteService;

public BaseApiManager() {
createService();
Expand All @@ -75,6 +77,8 @@ public static void init() {
surveyApi = createApi(SurveyService.class);
chargeApi = createApi(ChargeService.class);
runreportsService = createApi(RunReportsService.class);
noteService = createApi(NoteService.class);

}

private static <T> T createApi(Class<T> clazz) {
Expand Down Expand Up @@ -155,4 +159,8 @@ public ChargeService getChargeApi() {
public RunReportsService getRunReportsService() {
return runreportsService;
}

public NoteService getNoteApi() {
return noteService;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.mifos.api.datamanager;

import com.mifos.api.BaseApiManager;
import com.mifos.api.local.databasehelper.DatabaseHelperNote;
import com.mifos.objects.noncore.Note;

import java.util.List;

import javax.inject.Inject;
import javax.inject.Singleton;

import rx.Observable;

/**
* This DataManager is for Managing Notes API, In which Request is going to Server
* and In Response, We are getting Notes API Observable Response using Retrofit2
* Created by rahul on 4/3/17.
*/
@Singleton
public class DataManagerNote {

public final BaseApiManager mBaseApiManager;
public final DatabaseHelperNote mDatabaseHelperNote;

@Inject
public DataManagerNote(BaseApiManager baseApiManager,
DatabaseHelperNote databaseHelperNote) {
mBaseApiManager = baseApiManager;
mDatabaseHelperNote = databaseHelperNote;
}


/**
* This Method Request the REST API of Note and In response give the List of Notes
*/
public Observable<List<Note>> getNote(String entityType, int entityId) {
return mBaseApiManager.getNoteApi().getNotes(entityType, entityId);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.mifos.api.local.databasehelper;

import javax.inject.Inject;
import javax.inject.Singleton;

/**
* Created by rahul on 4/3/17.
*/
@Singleton
public class DatabaseHelperNote {

@Inject
public DatabaseHelperNote() {

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,5 @@ public class APIEndPoint {
public static final String RECURRING_ACCOUNTS = "recurringdepositaccounts";

public static final String DISBURSE = "disburse";
public static final String NOTES = "notes";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* This project is licensed under the open source MPL V2.
* See https://github.com/openMF/android-client/blob/master/LICENSE.md
*/
package com.mifos.api.services;

import com.mifos.api.model.APIEndPoint;
import com.mifos.objects.noncore.Note;

import java.util.List;

import retrofit2.http.GET;
import retrofit2.http.Path;
import rx.Observable;

public interface NoteService {
@GET("{entityType}/{entityId}/" + APIEndPoint.NOTES)
Observable<List<Note>> getNotes(@Path("entityType") String entityType,
@Path("entityId") int entityId);
/**
* @param entityType - Type for which note is being fetched (Client or Group)
* @param entityId - Id of Entity
*/
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
package com.mifos.mifosxdroid.adapters;

import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.mifos.mifosxdroid.R;
import com.mifos.objects.noncore.Note;

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

import javax.inject.Inject;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
* Created by rahul on 4/3/17.
*/

public class NoteAdapter extends RecyclerView.Adapter<NoteAdapter.ViewHolder> {

List<Note> notes;

@Inject
public NoteAdapter() {
notes = new ArrayList<>();
}

@Override
public NoteAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext())
.inflate(R.layout.item_note, parent, false);
return new ViewHolder(view);
}

@Override
public void onBindViewHolder(final NoteAdapter.ViewHolder holder, int position) {
Note note = notes.get(position);
holder.tvNote.setText(note.getNote());
}


public void setNotes(List<Note> notes) {
this.notes = notes;
notifyDataSetChanged();
}

@Override
public int getItemCount() {
return notes.size();
}

public Note getItem(int position) {
return notes.get(position);
}

@Override
public long getItemId(int i) {
return 0;
}

public static class ViewHolder extends RecyclerView.ViewHolder {

@BindView(R.id.tv_note)
TextView tvNote;

public ViewHolder(View v) {
super(v);
ButterKnife.bind(this, v);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,7 @@
import com.mifos.mifosxdroid.dialogfragments.datatablerowdialog.DataTableRowDialogFragment;
import com.mifos.mifosxdroid.dialogfragments.documentdialog.DocumentDialogFragment;
import com.mifos.mifosxdroid.dialogfragments.identifierdialog.IdentifierDialogFragment;
import com.mifos.mifosxdroid.online.activate.ActivateFragment;
import com.mifos.mifosxdroid.online.centerdetails.CenterDetailsFragment;
import com.mifos.mifosxdroid.online.datatable.DataTableFragment;
import com.mifos.mifosxdroid.online.loanaccountapproval.LoanAccountApproval;
import com.mifos.mifosxdroid.online.loanaccountdisbursement.LoanAccountDisbursementFragment;
import com.mifos.mifosxdroid.dialogfragments.loanchargedialog.LoanChargeDialogFragment;
import com.mifos.mifosxdroid.online.savingsaccountapproval.SavingsAccountApprovalFragment;
import com.mifos.mifosxdroid.dialogfragments.syncclientsdialog.SyncClientsDialogFragment;
import com.mifos.mifosxdroid.dialogfragments.syncgroupsdialog.SyncGroupsDialogFragment;
import com.mifos.mifosxdroid.injection.PerActivity;
Expand All @@ -23,33 +17,40 @@
import com.mifos.mifosxdroid.offline.syncgrouppayloads.SyncGroupPayloadsFragment;
import com.mifos.mifosxdroid.offline.syncloanrepaymenttransacition.SyncLoanRepaymentTransactionFragment;
import com.mifos.mifosxdroid.offline.syncsavingsaccounttransaction.SyncSavingsAccountTransactionFragment;
import com.mifos.mifosxdroid.online.activate.ActivateFragment;
import com.mifos.mifosxdroid.online.centerdetails.CenterDetailsFragment;
import com.mifos.mifosxdroid.online.centerlist.CenterListFragment;
import com.mifos.mifosxdroid.online.clientcharge.ClientChargeFragment;
import com.mifos.mifosxdroid.online.clientdetails.ClientDetailsFragment;
import com.mifos.mifosxdroid.online.clientidentifiers.ClientIdentifiersFragment;
import com.mifos.mifosxdroid.online.clientlist.ClientListFragment;
import com.mifos.mifosxdroid.online.datatablelistfragment.DataTableListFragment;
import com.mifos.mifosxdroid.online.search.SearchFragment;
import com.mifos.mifosxdroid.online.collectionsheet.CollectionSheetFragment;
import com.mifos.mifosxdroid.online.createnewcenter.CreateNewCenterFragment;
import com.mifos.mifosxdroid.online.createnewclient.CreateNewClientFragment;
import com.mifos.mifosxdroid.online.createnewgroup.CreateNewGroupFragment;
import com.mifos.mifosxdroid.online.datatable.DataTableFragment;
import com.mifos.mifosxdroid.online.datatabledata.DataTableDataFragment;
import com.mifos.mifosxdroid.online.datatablelistfragment.DataTableListFragment;
import com.mifos.mifosxdroid.online.documentlist.DocumentListFragment;
import com.mifos.mifosxdroid.online.generatecollectionsheet.GenerateCollectionSheetFragment;
import com.mifos.mifosxdroid.online.groupdetails.GroupDetailsFragment;
import com.mifos.mifosxdroid.online.grouplist.GroupListFragment;
import com.mifos.mifosxdroid.online.grouploanaccount.GroupLoanAccountFragment;
import com.mifos.mifosxdroid.online.groupslist.GroupsListFragment;
import com.mifos.mifosxdroid.online.loanaccount.LoanAccountFragment;
import com.mifos.mifosxdroid.online.loanaccountapproval.LoanAccountApproval;
import com.mifos.mifosxdroid.online.loanaccountdisbursement.LoanAccountDisbursementFragment;
import com.mifos.mifosxdroid.online.loanaccountsummary.LoanAccountSummaryFragment;
import com.mifos.mifosxdroid.online.loancharge.LoanChargeFragment;
import com.mifos.mifosxdroid.online.loanrepayment.LoanRepaymentFragment;
import com.mifos.mifosxdroid.online.loanrepaymentschedule.LoanRepaymentScheduleFragment;
import com.mifos.mifosxdroid.online.loantransactions.LoanTransactionsFragment;
import com.mifos.mifosxdroid.online.note.NoteFragment;
import com.mifos.mifosxdroid.online.savingaccountsummary.SavingsAccountSummaryFragment;
import com.mifos.mifosxdroid.online.savingaccounttransaction.SavingsAccountTransactionFragment;
import com.mifos.mifosxdroid.online.savingsaccount.SavingsAccountFragment;
import com.mifos.mifosxdroid.online.savingsaccountapproval.SavingsAccountApprovalFragment;
import com.mifos.mifosxdroid.online.search.SearchFragment;
import com.mifos.mifosxdroid.online.surveylist.SurveyListFragment;
import com.mifos.mifosxdroid.online.surveysubmit.SurveySubmitFragment;

Expand Down Expand Up @@ -162,4 +163,6 @@ public interface ActivityComponent {
void inject(ActivateFragment activateClientFragment);

void inject(DataTableFragment dataTableFragment);

void inject(NoteFragment noteFragment);
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import com.mifos.api.datamanager.DataManagerDocument;
import com.mifos.api.datamanager.DataManagerGroups;
import com.mifos.api.datamanager.DataManagerLoan;
import com.mifos.api.datamanager.DataManagerNote;
import com.mifos.api.datamanager.DataManagerOffices;
import com.mifos.api.datamanager.DataManagerRunReport;
import com.mifos.api.datamanager.DataManagerSavings;
Expand All @@ -24,6 +25,7 @@
import com.mifos.api.local.databasehelper.DatabaseHelperDataTable;
import com.mifos.api.local.databasehelper.DatabaseHelperGroups;
import com.mifos.api.local.databasehelper.DatabaseHelperLoan;
import com.mifos.api.local.databasehelper.DatabaseHelperNote;
import com.mifos.api.local.databasehelper.DatabaseHelperOffices;
import com.mifos.api.local.databasehelper.DatabaseHelperSavings;
import com.mifos.api.local.databasehelper.DatabaseHelperStaff;
Expand Down Expand Up @@ -66,6 +68,7 @@ public interface ApplicationComponent {
DataManagerSearch dataManagerSearch();
DataManagerRunReport dataManagerRunReport();
DataManagerAuth dataManagerAuth();
DataManagerNote dataManagerNote();


DatabaseHelperClient databaseHelperClient();
Expand All @@ -78,5 +81,6 @@ public interface ApplicationComponent {
DatabaseHelperLoan databaseHelperLoan();
DatabaseHelperSavings databaseHelperSavings();
DatabaseHelperSurveys databaseHelperSurveys();
DatabaseHelperNote databaseHelperNote();

}
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
import com.mifos.mifosxdroid.online.datatable.DataTableFragment;
import com.mifos.mifosxdroid.online.documentlist.DocumentListFragment;
import com.mifos.mifosxdroid.online.loanaccount.LoanAccountFragment;
import com.mifos.mifosxdroid.online.note.NoteFragment;
import com.mifos.mifosxdroid.online.savingsaccount.SavingsAccountFragment;
import com.mifos.mifosxdroid.online.surveylist.SurveyListFragment;
import com.mifos.mifosxdroid.views.CircularImageView;
Expand Down Expand Up @@ -91,6 +92,8 @@ public class ClientDetailsFragment extends MifosBaseFragment implements ClientDe
public static final int MENU_ITEM_DOCUMENTS = 1006;
public static final int MENU_ITEM_IDENTIFIERS = 1007;
public static final int MENU_ITEM_SURVEYS = 1008;
public static final int MENU_ITEM_NOTE = 1009;


private final String TAG = ClientDetailsFragment.class.getSimpleName();

Expand Down Expand Up @@ -239,6 +242,7 @@ public void onPrepareOptionsMenu(Menu menu) {
menu.add(Menu.NONE, MENU_ITEM_DOCUMENTS, Menu.NONE, getString(R.string.documents));
menu.add(Menu.NONE, MENU_ITEM_IDENTIFIERS, Menu.NONE, getString(R.string.identifiers));
menu.add(Menu.NONE, MENU_ITEM_SURVEYS, Menu.NONE, getString(R.string.survey));
menu.add(Menu.NONE, MENU_ITEM_NOTE, Menu.NONE, getString(R.string.note));
}
super.onPrepareOptionsMenu(menu);
}
Expand Down Expand Up @@ -272,6 +276,8 @@ public boolean onOptionsItemSelected(MenuItem item) {
case MENU_ITEM_SURVEYS:
loadSurveys();
break;
case MENU_ITEM_NOTE:
loadNotes();
}
return super.onOptionsItemSelected(item);
}
Expand Down Expand Up @@ -307,6 +313,16 @@ public void loadDocuments() {
fragmentTransaction.commit();
}

public void loadNotes() {
NoteFragment noteFragment = NoteFragment.newInstance(Constants
.ENTITY_TYPE_CLIENTS, clientId);
FragmentTransaction fragmentTransaction = getActivity().getSupportFragmentManager()
.beginTransaction();
fragmentTransaction.addToBackStack(FragmentConstants.FRAG_CLIENT_DETAILS);
fragmentTransaction.replace(R.id.container, noteFragment);
fragmentTransaction.commit();
}

public void loadClientCharges() {
ClientChargeFragment clientChargeFragment = ClientChargeFragment.newInstance(clientId,
chargesList);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import com.mifos.mifosxdroid.online.datatable.DataTableFragment;
import com.mifos.mifosxdroid.online.documentlist.DocumentListFragment;
import com.mifos.mifosxdroid.online.grouploanaccount.GroupLoanAccountFragment;
import com.mifos.mifosxdroid.online.note.NoteFragment;
import com.mifos.objects.accounts.GroupAccounts;
import com.mifos.objects.accounts.savings.DepositType;
import com.mifos.objects.client.Client;
Expand Down Expand Up @@ -156,6 +157,16 @@ public void loadDocuments() {
fragmentTransaction.commit();
}

public void loadNotes() {
NoteFragment noteFragment = NoteFragment.newInstance(Constants
.ENTITY_TYPE_GROUPS, groupId);
FragmentTransaction fragmentTransaction = getActivity().getSupportFragmentManager()
.beginTransaction();
fragmentTransaction.addToBackStack(FragmentConstants.FRAG_CLIENT_DETAILS);
fragmentTransaction.replace(R.id.container, noteFragment);
fragmentTransaction.commit();
}

public void addGroupLoanAccount() {
GroupLoanAccountFragment grouploanAccountFragment = GroupLoanAccountFragment.newInstance
(groupId);
Expand Down Expand Up @@ -311,6 +322,9 @@ public boolean onOptionsItemSelected(MenuItem item) {
case R.id.group_clients:
mGroupDetailsPresenter.loadGroupAssociateClients(groupId);
break;
case R.id.group_notes:
loadNotes();
break;

}
return super.onOptionsItemSelected(item);
Expand Down
Loading

0 comments on commit a68edb0

Please sign in to comment.