diff --git a/mifosng-android/src/main/java/com/mifos/api/datamanager/DataManagerCenter.java b/mifosng-android/src/main/java/com/mifos/api/datamanager/DataManagerCenter.java index befcd5e6794..cea506033a8 100644 --- a/mifosng-android/src/main/java/com/mifos/api/datamanager/DataManagerCenter.java +++ b/mifosng-android/src/main/java/com/mifos/api/datamanager/DataManagerCenter.java @@ -3,7 +3,6 @@ import com.mifos.api.BaseApiManager; import com.mifos.api.GenericResponse; import com.mifos.api.local.databasehelper.DatabaseHelperCenter; -import com.mifos.objects.accounts.CenterAccounts; import com.mifos.objects.client.ActivatePayload; import com.mifos.objects.client.Page; import com.mifos.objects.group.Center; @@ -19,7 +18,6 @@ import javax.inject.Singleton; import rx.Observable; -import rx.functions.Func1; /** * This DataManager is for Managing Center API, In which Request is going to Server @@ -75,34 +73,6 @@ public Observable> getCenters(boolean paged, int offset, int limit) } } - /** - * This method save the single Center in Database. - * - * @param center Center - * @return Center - */ - public Observable
syncCenterInDatabase(Center center) { - return mDatabaseHelperCenter.saveCenter(center); - } - - /** - * This Method Fetching the Center Accounts (Loan, saving, etc Accounts ) from REST API - * and then Saving all Accounts into the Database and then returns the Center Group Accounts - * - * @param centerId Center Id - * @return CenterAccounts - */ - public Observable syncCenterAccounts(final int centerId) { - return mBaseApiManager.getCenterApi().getCenterAccounts(centerId) - .concatMap(new Func1>() { - @Override - public Observable call(CenterAccounts - centerAccounts) { - return mDatabaseHelperCenter.saveCenterAccounts(centerAccounts, centerId); - } - }); - } - /** * Method Fetching CollectionSheet of the Center from : * demo.openmf.org/fineract-provider/api/v1/centers/{centerId} @@ -132,36 +102,6 @@ public Observable createCenter(CenterPayload centerPayload) { } } - /** - * This Method Fetch the Groups that are attached to the Centers. - * @param centerId Center Id - * @return CenterWithAssociations - */ - public Observable getCenterWithAssociations(int centerId) { - switch (PrefManager.getUserStatus()) { - case 0: - return mBaseApiManager.getCenterApi().getAllGroupsForCenter(centerId); - case 1: - /** - * Return Groups from DatabaseHelperGroups. - */ - return mDatabaseHelperCenter.getCenterAssociateGroups(centerId); - - default: - return Observable.just(new CenterWithAssociations()); - } - } - - /** - * This Method Request to the DatabaseHelperCenter and DatabaseHelperCenter Read the All - * centers from Center_Table and give the response Page of List of Center - * - * @return Page of Center List - */ - public Observable> getAllDatabaseCenters() { - return mDatabaseHelperCenter.readAllCenters(); - } - public Observable> getOffices() { return mBaseApiManager.getOfficeApi().getAllOffices(); } diff --git a/mifosng-android/src/main/java/com/mifos/api/local/database/MigrationVersion2.java b/mifosng-android/src/main/java/com/mifos/api/local/database/MigrationVersion2.java deleted file mode 100644 index 05748be4c98..00000000000 --- a/mifosng-android/src/main/java/com/mifos/api/local/database/MigrationVersion2.java +++ /dev/null @@ -1,59 +0,0 @@ -package com.mifos.api.local.database; - -import com.mifos.api.local.MifosDatabase; -import com.mifos.objects.accounts.loan.LoanAccount; -import com.mifos.objects.accounts.savings.SavingsAccount; -import com.mifos.objects.group.Center; -import com.raizlabs.android.dbflow.annotation.Migration; -import com.raizlabs.android.dbflow.sql.SQLiteType; -import com.raizlabs.android.dbflow.sql.migration.AlterTableMigration; - -/** - * Created by mayankjindal on 17/07/17. - */ - -public class MigrationVersion2 { - @Migration(version = MifosDatabase.VERSION, database = MifosDatabase.class) - public static class Migration1 extends AlterTableMigration { - - public Migration1(Class table) { - super(table); - } - - @Override - public void onPreMigrate() { - addColumn(SQLiteType.INTEGER, "centerId"); - } - } - - @Migration(version = MifosDatabase.VERSION, database = MifosDatabase.class) - public static class Migration2 extends AlterTableMigration { - - public Migration2(Class table) { - super(table); - } - - @Override - public void onPreMigrate() { - addColumn(SQLiteType.INTEGER, "centerId"); - } - } - - @Migration(version = MifosDatabase.VERSION, database = MifosDatabase.class) - public static class Migration3 extends AlterTableMigration
{ - - public Migration3(Class
table) { - super(table); - } - - @Override - public void onPreMigrate() { - addColumn(SQLiteType.INTEGER, "sync"); - addColumn(SQLiteType.INTEGER, "centerDate_centerId"); - addColumn(SQLiteType.INTEGER, "centerDate_chargeId"); - addColumn(SQLiteType.INTEGER, "centerDate_day"); - addColumn(SQLiteType.INTEGER, "centerDate_month"); - addColumn(SQLiteType.INTEGER, "centerDate_year"); - } - } -} diff --git a/mifosng-android/src/main/java/com/mifos/api/local/databasehelper/DatabaseHelperCenter.java b/mifosng-android/src/main/java/com/mifos/api/local/databasehelper/DatabaseHelperCenter.java index abbe069d287..b5e729080de 100644 --- a/mifosng-android/src/main/java/com/mifos/api/local/databasehelper/DatabaseHelperCenter.java +++ b/mifosng-android/src/main/java/com/mifos/api/local/databasehelper/DatabaseHelperCenter.java @@ -3,15 +3,8 @@ import android.os.AsyncTask; import android.support.annotation.Nullable; -import com.mifos.objects.accounts.CenterAccounts; -import com.mifos.objects.accounts.loan.LoanAccount; -import com.mifos.objects.accounts.savings.SavingsAccount; import com.mifos.objects.client.Page; import com.mifos.objects.group.Center; -import com.mifos.objects.group.CenterDate; -import com.mifos.objects.group.CenterWithAssociations; -import com.mifos.objects.group.Group; -import com.mifos.objects.group.Group_Table; import com.mifos.objects.response.SaveResponse; import com.mifos.services.data.CenterPayload; import com.mifos.services.data.CenterPayload_Table; @@ -105,53 +98,6 @@ public Observable> call() { }); } - /** - * This Method Fetch the Groups that are attached to the Center. - * @param centerId Center Id - * @return CenterWithAssociations - */ - - public Observable getCenterAssociateGroups(final int centerId) { - return Observable.defer(new Func0>() { - @Override - public Observable call() { - - List groups = SQLite.select() - .from(Group.class) - .where(Group_Table.centerId.eq(centerId)) - .queryList(); - CenterWithAssociations centerWithAssociations = new CenterWithAssociations(); - centerWithAssociations.setGroupMembers(groups); - - return Observable.just(centerWithAssociations); - } - }); - } - - /** - * This Method Saving the Single Center in the Database - * - * @param center - * @return Observable.just(Center) - */ - public Observable
saveCenter(final Center center) { - return Observable.defer(new Func0>() { - @Override - public Observable
call() { - - if (center.getActivationDate().size() != 0) { - CenterDate centerDate = new CenterDate(center.getId(), 0, - center.getActivationDate().get(0), - center.getActivationDate().get(1), - center.getActivationDate().get(2)); - center.setCenterDate(centerDate); - } - center.save(); - return Observable.just(center); - } - }); - } - /** * This Method for deleting the center payload from the Database according to Id and * again fetch the center List from the Database CenterPayload_Table @@ -182,42 +128,4 @@ public Observable call() { } }); } - - /** - * This Method write the CenterAccounts in tho DB. According to Schema Defined in Model - * - * @param centerAccounts Model of List of LoanAccount and SavingAccount - * @param centerId Center Id - * @return CenterAccounts - */ - public Observable saveCenterAccounts(final CenterAccounts centerAccounts, - final int centerId) { - - return Observable.defer(new Func0>() { - @Override - public Observable call() { - - List loanAccounts = centerAccounts.getLoanAccounts(); - List savingsAccounts = centerAccounts.getSavingsAccounts(); - List memberLoanAccounts = centerAccounts.getMemberLoanAccounts(); - - for (LoanAccount loanAccount : loanAccounts) { - loanAccount.setCenterId(centerId); - loanAccount.save(); - } - - for (SavingsAccount savingsAccount : savingsAccounts) { - savingsAccount.setCenterId(centerId); - savingsAccount.save(); - } - - for (LoanAccount memberLoanAccount : memberLoanAccounts) { - memberLoanAccount.setCenterId(centerId); - memberLoanAccount.save(); - } - - return Observable.just(centerAccounts); - } - }); - } } diff --git a/mifosng-android/src/main/java/com/mifos/api/services/CenterService.java b/mifosng-android/src/main/java/com/mifos/api/services/CenterService.java index 6127dd6a863..55bf068971d 100755 --- a/mifosng-android/src/main/java/com/mifos/api/services/CenterService.java +++ b/mifosng-android/src/main/java/com/mifos/api/services/CenterService.java @@ -8,7 +8,6 @@ import com.mifos.api.model.APIEndPoint; import com.mifos.api.model.CollectionSheetPayload; import com.mifos.api.model.Payload; -import com.mifos.objects.accounts.CenterAccounts; import com.mifos.objects.client.ActivatePayload; import com.mifos.objects.response.SaveResponse; import com.mifos.objects.client.Page; @@ -40,9 +39,6 @@ Observable> getCenters(@Query("paged") boolean b, @Query("offset") int offset, @Query("limit") int limit); - @GET(APIEndPoint.CENTERS + "/{centerId}/accounts") - Observable getCenterAccounts(@Path("centerId") int centerId); - @GET(APIEndPoint.CENTERS + "/{centerId}?associations=groupMembers,collectionMeetingCalendar") Observable getCenterWithGroupMembersAndCollectionMeetingCalendar (@Path("centerId") int centerId); diff --git a/mifosng-android/src/main/java/com/mifos/mifosxdroid/adapters/CentersListAdapter.java b/mifosng-android/src/main/java/com/mifos/mifosxdroid/adapters/CentersListAdapter.java index 01ffa1e4083..e082c4fdd24 100755 --- a/mifosng-android/src/main/java/com/mifos/mifosxdroid/adapters/CentersListAdapter.java +++ b/mifosng-android/src/main/java/com/mifos/mifosxdroid/adapters/CentersListAdapter.java @@ -6,18 +6,13 @@ package com.mifos.mifosxdroid.adapters; import android.content.Context; -import android.graphics.Color; -import android.support.v4.content.ContextCompat; import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.widget.ImageView; -import android.widget.LinearLayout; import android.widget.TextView; import com.mifos.mifosxdroid.R; -import com.mifos.mifosxdroid.core.SelectableAdapter; import com.mifos.mifosxdroid.views.CircularImageView; import com.mifos.objects.group.Center; import com.mifos.utils.Utils; @@ -33,7 +28,7 @@ /** * Created by ishankhanna on 11/03/14. */ -public class CentersListAdapter extends SelectableAdapter { +public class CentersListAdapter extends RecyclerView.Adapter { private List
centers; private Context context; @@ -51,38 +46,28 @@ public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { } @Override - public void onBindViewHolder(final RecyclerView.ViewHolder holder, int position) { - if (holder instanceof ViewHolder) { - Center center = centers.get(position); - - ((ViewHolder) holder).tvAccountNumber.setText(String.format(context. - getString(R.string.centerList_account_prefix), center.getAccountNo())); - ((ViewHolder) holder).tvCenterId.setText(String.valueOf(center.getId())); - ((ViewHolder) holder).tvCenterName.setText(center.getName()); - if (center.getStaffId() != null) { - ((ViewHolder) holder).tvStaffId.setText(String.valueOf(center.getStaffId())); - ((ViewHolder) holder).tvStaffName.setText(center.getStaffName()); - } else { - ((ViewHolder) holder).tvStaffId.setText(""); - ((ViewHolder) holder).tvStaffName.setText(R.string.no_staff); - } - ((ViewHolder) holder).tvOfficeId.setText(String.valueOf(center.getOfficeId())); - ((ViewHolder) holder).tvOfficeName.setText(center.getOfficeName()); - if (center.getActive()) { - ((ViewHolder) holder).ivStatusIndicator.setImageDrawable( - Utils.setCircularBackground(R.color.light_green, context)); - } else { - ((ViewHolder) holder).ivStatusIndicator.setImageDrawable( - Utils.setCircularBackground(R.color.light_red, context)); - } - - //Changing the Color of Selected Centers - ((ViewHolder) holder).viewSelectedOverlay - .setBackgroundColor(isSelected(position) ? ContextCompat.getColor(context, - R.color.gray_light) : Color.WHITE); - - ((ViewHolder) holder).ivSyncStatus - .setVisibility(center.isSync() ? View.VISIBLE : View.INVISIBLE); + public void onBindViewHolder(ViewHolder holder, int position) { + Center center = centers.get(position); + + holder.tvAccountNumber.setText(String.format(context. + getString(R.string.centerList_account_prefix), center.getAccountNo())); + holder.tvCenterId.setText(String.valueOf(center.getId())); + holder.tvCenterName.setText(center.getName()); + if (center.getStaffId() != null) { + holder.tvStaffId.setText(String.valueOf(center.getStaffId())); + holder.tvStaffName.setText(center.getStaffName()); + } else { + holder.tvStaffId.setText(""); + holder.tvStaffName.setText(R.string.no_staff); + } + holder.tvOfficeId.setText(String.valueOf(center.getOfficeId())); + holder.tvOfficeName.setText(center.getOfficeName()); + if (center.getActive()) { + holder.ivStatusIndicator.setImageDrawable( + Utils.setCircularBackground(R.color.light_green, context)); + } else { + holder.ivStatusIndicator.setImageDrawable( + Utils.setCircularBackground(R.color.light_red, context)); } } @@ -136,12 +121,6 @@ public static class ViewHolder extends RecyclerView.ViewHolder { @BindView(R.id.tv_office_id) TextView tvOfficeId; - @BindView(R.id.linearLayout) - LinearLayout viewSelectedOverlay; - - @BindView(R.id.iv_sync_status) - ImageView ivSyncStatus; - public ViewHolder(View v) { super(v); ButterKnife.bind(this, v); diff --git a/mifosng-android/src/main/java/com/mifos/mifosxdroid/dialogfragments/synccenterdialog/SyncCenterDialogMvpView.java b/mifosng-android/src/main/java/com/mifos/mifosxdroid/dialogfragments/synccenterdialog/SyncCenterDialogMvpView.java deleted file mode 100644 index be75678e6e2..00000000000 --- a/mifosng-android/src/main/java/com/mifos/mifosxdroid/dialogfragments/synccenterdialog/SyncCenterDialogMvpView.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.mifos.mifosxdroid.dialogfragments.synccenterdialog; - -import com.mifos.mifosxdroid.base.MvpView; - -/** - * Created by mayankjindal on 10/07/17. - */ - -public interface SyncCenterDialogMvpView extends MvpView { - - void showUI(); - - void showSyncingCenter(String centerName); - - void showSyncedFailedCenters(int failedCount); - - void setMaxSingleSyncCenterProgressBar(int total); - - void setGroupSyncProgressBarMax(int count); - - void updateGroupSyncProgressBar(int i); - - void setClientSyncProgressBarMax(int count); - - void updateClientSyncProgressBar(int i); - - void updateSingleSyncCenterProgressBar(int i); - - void updateTotalSyncCenterProgressBarAndCount(int i); - - int getMaxSingleSyncCenterProgressBar(); - - void showNetworkIsNotAvailable(); - - void showCentersSyncSuccessfully(); - - Boolean isOnline(); - - void dismissDialog(); - - void showDialog(); - - void hideDialog(); - - void showError(int s); -} diff --git a/mifosng-android/src/main/java/com/mifos/mifosxdroid/dialogfragments/synccenterdialog/SyncCenterDialogPresenter.java b/mifosng-android/src/main/java/com/mifos/mifosxdroid/dialogfragments/synccenterdialog/SyncCenterDialogPresenter.java deleted file mode 100644 index f6e7a9a1f04..00000000000 --- a/mifosng-android/src/main/java/com/mifos/mifosxdroid/dialogfragments/synccenterdialog/SyncCenterDialogPresenter.java +++ /dev/null @@ -1,945 +0,0 @@ -package com.mifos.mifosxdroid.dialogfragments.synccenterdialog; - -import com.mifos.api.datamanager.DataManagerCenter; -import com.mifos.api.datamanager.DataManagerClient; -import com.mifos.api.datamanager.DataManagerGroups; -import com.mifos.api.datamanager.DataManagerLoan; -import com.mifos.api.datamanager.DataManagerSavings; -import com.mifos.mifosxdroid.R; -import com.mifos.mifosxdroid.base.BasePresenter; -import com.mifos.objects.accounts.CenterAccounts; -import com.mifos.objects.accounts.ClientAccounts; -import com.mifos.objects.accounts.GroupAccounts; -import com.mifos.objects.accounts.loan.LoanAccount; -import com.mifos.objects.accounts.loan.LoanWithAssociations; -import com.mifos.objects.accounts.savings.SavingsAccount; -import com.mifos.objects.accounts.savings.SavingsAccountWithAssociations; -import com.mifos.objects.client.Client; -import com.mifos.objects.group.CenterWithAssociations; -import com.mifos.objects.group.Group; -import com.mifos.objects.group.Center; -import com.mifos.objects.group.GroupWithAssociations; -import com.mifos.objects.templates.loans.LoanRepaymentTemplate; -import com.mifos.objects.templates.savings.SavingsAccountTransactionTemplate; -import com.mifos.objects.zipmodels.LoanAndLoanRepayment; -import com.mifos.objects.zipmodels.SavingsAccountAndTransactionTemplate; -import com.mifos.utils.Constants; -import com.mifos.utils.Utils; - -import java.util.ArrayList; -import java.util.List; - -import javax.inject.Inject; - -import retrofit2.adapter.rxjava.HttpException; -import rx.Observable; -import rx.Subscriber; -import rx.android.schedulers.AndroidSchedulers; -import rx.functions.Action1; -import rx.functions.Func2; -import rx.plugins.RxJavaPlugins; -import rx.schedulers.Schedulers; -import rx.subscriptions.CompositeSubscription; - -/** - * Created by mayankjindal on 10/07/17. - */ - -public class SyncCenterDialogPresenter extends BasePresenter { - - private final DataManagerCenter mDataManagerCenter; - private final DataManagerLoan mDataManagerLoan; - private final DataManagerSavings mDataManagerSavings; - private final DataManagerGroups mDataManagerGroups; - private final DataManagerClient mDataManagerClient; - private List mLoanAccountList; - private List mSavingsAccountList; - private List mMemberLoanAccountsList; - - private CompositeSubscription mSubscriptions; - private List
mCenterList, mFailedSyncCenter; - private List mGroups; - private List mClients; - - private Boolean mLoanAccountSyncStatus = false; - private Boolean mSavingAccountSyncStatus = false; - - private int mCenterSyncIndex = 0, mLoanAndRepaymentSyncIndex = 0, - mSavingsAndTransactionSyncIndex = 0, mMemberLoanSyncIndex = 0, - mClientSyncIndex = 0, mGroupSyncIndex; - - @Inject - public SyncCenterDialogPresenter(DataManagerCenter dataManagerCenter, - DataManagerLoan dataManagerLoan, - DataManagerSavings dataManagerSavings, - DataManagerGroups dataManagerGroups, - DataManagerClient dataManagerClient) { - mDataManagerCenter = dataManagerCenter; - mDataManagerLoan = dataManagerLoan; - mDataManagerSavings = dataManagerSavings; - mDataManagerGroups = dataManagerGroups; - mDataManagerClient = dataManagerClient; - mSubscriptions = new CompositeSubscription(); - mCenterList = new ArrayList<>(); - mFailedSyncCenter = new ArrayList<>(); - mLoanAccountList = new ArrayList<>(); - mSavingsAccountList = new ArrayList<>(); - mMemberLoanAccountsList = new ArrayList<>(); - mClients = new ArrayList<>(); - mGroups = new ArrayList<>(); - } - - @Override - public void attachView(SyncCenterDialogMvpView mvpView) { - super.attachView(mvpView); - } - - @Override - public void detachView() { - super.detachView(); - mSubscriptions.unsubscribe(); - } - - /** - * This Method Start Syncing Centers. Start Syncing the Centers Accounts. - * - * @param centers Selected Centers For Syncing - */ - public void startSyncingCenters(List
centers) { - mCenterList = centers; - checkNetworkConnectionAndSyncCenter(); - } - - /** - * This Method checking that mCenterSyncIndex and mCenterList Size are equal or not. If they - * are equal, It means all centers have been synced otherwise continue syncing centers. - */ - public void syncCenterAndUpdateUI() { - resetIndexes(); - updateTotalSyncProgressBarAndCount(); - if (mCenterSyncIndex != mCenterList.size()) { - updateCenterName(); - syncCenterAccounts(mCenterList.get(mCenterSyncIndex).getId()); - } else { - getMvpView().showCentersSyncSuccessfully(); - } - - } - - /** - * This Method for resetting the mLoanAndRepaymentSyncIndex and mSavingsAndTransactionSyncIndex - * and mMemberLoanSyncIndex and mLoanAccountSyncStatus and mSavingAccountSyncStatus. - */ - private void resetIndexes() { - mLoanAccountSyncStatus = false; - mSavingAccountSyncStatus = false; - mLoanAndRepaymentSyncIndex = 0; - mSavingsAndTransactionSyncIndex = 0; - mMemberLoanSyncIndex = 0; - } - - /** - * This Method checking network connection before starting center synchronization - */ - public void checkNetworkConnectionAndSyncCenter() { - if (getMvpView().isOnline()) { - syncCenterAndUpdateUI(); - } else { - getMvpView().showNetworkIsNotAvailable(); - getMvpView().dismissDialog(); - } - } - - /** - * This Method will be called when ever any request will be failed synced. - * - * @param e Throwable - */ - private void onAccountSyncFailed(Throwable e) { - try { - if (e instanceof HttpException) { - int singleSyncCenterMax = getMvpView().getMaxSingleSyncCenterProgressBar(); - getMvpView().updateSingleSyncCenterProgressBar(singleSyncCenterMax); - - mFailedSyncCenter.add(mCenterList.get(mCenterSyncIndex)); - mCenterSyncIndex = mCenterSyncIndex + 1; - - getMvpView().showSyncedFailedCenters(mFailedSyncCenter.size()); - checkNetworkConnectionAndSyncCenter(); - } - } catch (Throwable throwable) { - RxJavaPlugins.getInstance().getErrorHandler().handleError(throwable); - } - } - - /** - * Sync the Center Account with Center Id. This method fetching the Center Accounts from the - * REST API using retrofit 2 and saving these accounts to Database with DatabaseHelperCenter - * and then DataManagerCenter returns the Center Accounts to Presenter. - *

- *

- * onNext : As Center Accounts Successfully sync then sync there Loan and LoanRepayment - * onError : - * - * @param centerId Center Id - */ - public void syncCenterAccounts(int centerId) { - checkViewAttached(); - mSubscriptions.add(mDataManagerCenter.syncCenterAccounts(centerId) - .observeOn(AndroidSchedulers.mainThread()) - .subscribeOn(Schedulers.io()) - .subscribe(new Subscriber() { - @Override - public void onCompleted() { - } - - @Override - public void onError(Throwable e) { - getMvpView().showError(R.string.failed_to_sync_centeraccounts); - - //Updating UI - mFailedSyncCenter.add(mCenterList.get(mCenterSyncIndex)); - getMvpView().showSyncedFailedCenters(mFailedSyncCenter.size()); - mCenterSyncIndex = mCenterSyncIndex + 1; - checkNetworkConnectionAndSyncCenter(); - } - - @Override - public void onNext(CenterAccounts centerAccounts) { - mLoanAccountList = Utils.getActiveLoanAccounts(centerAccounts - .getLoanAccounts()); - mSavingsAccountList = Utils.getActiveSavingsAccounts(centerAccounts - .getSavingsAccounts()); - mMemberLoanAccountsList = Utils.getActiveLoanAccounts(centerAccounts - .getMemberLoanAccounts()); - //Updating UI - getMvpView().setMaxSingleSyncCenterProgressBar(mLoanAccountList.size() + - mSavingsAccountList.size() + mMemberLoanAccountsList.size()); - checkAccountsSyncStatusAndSyncAccounts(); - } - }) - ); - } - - /** - * This Method check the LoanAccount isEmpty or not, If LoanAccount is not Empty the sync the - * loanAccount locally and If LoanAccount is empty then check to the next SavingAccount - * isEmpty or not. if SavingAccount is not empty then sync the SavingsAccount locally and if - * savingsAccount are Empty then check to the next MemberLoanAccount isEmpty or not. if - * MemberLoanAccount is not empty then sync the MemberLoanAccount locally and if - * MemberLoanAccount are Empty the sync the Centers locally, Yep Centers has been synced. - */ - private void checkAccountsSyncStatusAndSyncAccounts() { - if (!mLoanAccountList.isEmpty() && !mLoanAccountSyncStatus) { - //Sync the Active Loan and LoanRepayment - checkNetworkConnectionAndSyncLoanAndLoanRepayment(); - } else if (!mSavingsAccountList.isEmpty() && !mSavingAccountSyncStatus) { - //Sync the Active Savings Account - checkNetworkConnectionAndSyncSavingsAccountAndTransactionTemplate(); - } else if (!mMemberLoanAccountsList.isEmpty()) { - //Sync the Active member Loan Account - checkNetworkConnectionAndSyncMemberLoanAndMemberLoanRepayment(); - } else { - getMvpView().setMaxSingleSyncCenterProgressBar(1); - loadCenterAssociateGroups(mCenterList.get(mCenterSyncIndex).getId()); - } - } - - /** - * This Method Checking network connection and Syncing the LoanAndLoanRepayment. - * If found no internet connection then stop syncing the Centers and dismiss the dialog. - */ - private void checkNetworkConnectionAndSyncLoanAndLoanRepayment() { - if (getMvpView().isOnline()) { - syncLoanAndLoanRepayment(mLoanAccountList - .get(mLoanAndRepaymentSyncIndex).getId()); - } else { - getMvpView().showNetworkIsNotAvailable(); - getMvpView().dismissDialog(); - } - } - - /** - * This Method Checking network connection and Syncing the MemberLoanAndMemberLoanRepayment. - * If found no internet connection then stop syncing the Centers and dismiss the dialog. - */ - private void checkNetworkConnectionAndSyncMemberLoanAndMemberLoanRepayment() { - if (getMvpView().isOnline()) { - syncMemberLoanAndMemberLoanRepayment(mMemberLoanAccountsList - .get(mMemberLoanSyncIndex).getId()); - } else { - getMvpView().showNetworkIsNotAvailable(); - getMvpView().dismissDialog(); - } - } - - /** - * This method checking the network connection and syncing the SavingsAccountAndTransactions. - * If found no internet connection then stop syncing the centers and dismiss the dialog. - */ - private void checkNetworkConnectionAndSyncSavingsAccountAndTransactionTemplate() { - if (getMvpView().isOnline()) { - syncSavingsAccountAndTemplate(mSavingsAccountList - .get(mSavingsAndTransactionSyncIndex).getDepositType().getEndpoint(), - mSavingsAccountList.get(mSavingsAndTransactionSyncIndex).getId()); - } else { - getMvpView().showNetworkIsNotAvailable(); - getMvpView().dismissDialog(); - } - } - - /** - * This Method for setting mLoanAccountSyncStatus = true, It means LoanAccounts have been - * synced locally. - */ - private void setLoanAccountSyncStatusTrue() { - if (mLoanAndRepaymentSyncIndex == mLoanAccountList.size()) { - mLoanAccountSyncStatus = true; - } - } - - /** - * This Method for setting mSavingAccountSyncStatus = true, It means LoanAccounts have been - * synced locally. - */ - private void setSavingnAccountSyncStatusTrue() { - if (mSavingsAndTransactionSyncIndex == mSavingsAccountList.size()) { - mSavingAccountSyncStatus = true; - } - } - - /** - * This Method Syncing the Center's Loan and their LoanRepayment. This is the - * Observable.combineLatest In Which two request is going to server Loans and LoanRepayment - * and This request will not complete till that both request completed successfully with - * response (200 OK). If one will fail then response will come in onError. and If both - * request is 200 response then response will come in onNext. - * - * @param loanId Loan Id - */ - private void syncLoanAndLoanRepayment(int loanId) { - checkViewAttached(); - mSubscriptions.add(getLoanAndLoanRepayment(loanId) - .subscribe(new Subscriber() { - @Override - public void onCompleted() { - - } - - @Override - public void onError(Throwable e) { - onAccountSyncFailed(e); - } - - @Override - public void onNext(LoanAndLoanRepayment loanAndLoanRepayment) { - mLoanAndRepaymentSyncIndex = mLoanAndRepaymentSyncIndex + 1; - getMvpView().updateSingleSyncCenterProgressBar(mLoanAndRepaymentSyncIndex); - if (mLoanAndRepaymentSyncIndex != mLoanAccountList.size()) { - checkNetworkConnectionAndSyncLoanAndLoanRepayment(); - } else { - setLoanAccountSyncStatusTrue(); - checkAccountsSyncStatusAndSyncAccounts(); - } - } - }) - ); - } - - /** - * This Method Syncing the Member's Loan and their LoanRepayment. This is the - * Observable.combineLatest In Which two request is going to server Loans and LoanRepayment - * and This request will not complete till that both request completed successfully with - * response (200 OK). If one will fail then response will come in onError. and If both - * request is 200 response then response will come in onNext. - * - * @param loanId Loan Id - */ - private void syncMemberLoanAndMemberLoanRepayment(int loanId) { - checkViewAttached(); - mSubscriptions.add(getLoanAndLoanRepayment(loanId) - .subscribe(new Subscriber() { - @Override - public void onCompleted() { - } - - @Override - public void onError(Throwable e) { - onAccountSyncFailed(e); - } - - @Override - public void onNext(LoanAndLoanRepayment loanAndLoanRepayment) { - mMemberLoanSyncIndex = mMemberLoanSyncIndex + 1; - getMvpView().updateSingleSyncCenterProgressBar(mLoanAndRepaymentSyncIndex - + mSavingsAndTransactionSyncIndex + mMemberLoanSyncIndex); - if (mMemberLoanSyncIndex != mMemberLoanAccountsList.size()) { - checkNetworkConnectionAndSyncMemberLoanAndMemberLoanRepayment(); - } else { - loadCenterAssociateGroups(mCenterList.get(mCenterSyncIndex).getId()); - } - } - }) - ); - } - - - /** - * This Method Fetching the SavingsAccount and SavingsAccountTransactionTemplate and Syncing - * them in Database table. - * - * @param savingsAccountType SavingsAccount Type Example : savingsaccounts - * @param savingsAccountId SavingsAccount Id - */ - private void syncSavingsAccountAndTemplate(String savingsAccountType, int savingsAccountId) { - checkViewAttached(); - mSubscriptions.add(getSavingsAccountAndTemplate(savingsAccountType, savingsAccountId) - .subscribe(new Subscriber() { - @Override - public void onCompleted() { - } - - @Override - public void onError(Throwable e) { - onAccountSyncFailed(e); - } - - @Override - public void onNext(SavingsAccountAndTransactionTemplate - savingsAccountAndTransactionTemplate) { - mSavingsAndTransactionSyncIndex = mSavingsAndTransactionSyncIndex + 1; - getMvpView().updateSingleSyncCenterProgressBar( - mLoanAndRepaymentSyncIndex + mSavingsAndTransactionSyncIndex); - - if (mSavingsAndTransactionSyncIndex != mSavingsAccountList.size()) { - checkNetworkConnectionAndSyncSavingsAccountAndTransactionTemplate(); - } else { - setSavingnAccountSyncStatusTrue(); - checkAccountsSyncStatusAndSyncAccounts(); - } - } - }) - ); - } - - /** - * This Method syncing the Center into the Database. - * - * @param center Center - */ - private void syncCenter(Center center) { - checkViewAttached(); - center.setSync(true); - mSubscriptions.add(mDataManagerCenter.syncCenterInDatabase(center) - .observeOn(AndroidSchedulers.mainThread()) - .subscribeOn(Schedulers.io()) - .subscribe(new Action1

() { - @Override - public void call(Center center) { - getMvpView().updateGroupSyncProgressBar(0); - getMvpView().updateSingleSyncCenterProgressBar( - getMvpView().getMaxSingleSyncCenterProgressBar()); - mCenterSyncIndex = mCenterSyncIndex + 1; - checkNetworkConnectionAndSyncCenter(); - } - }) - ); - } - - - /** - * This Method Fetching the LoanAndLoanRepayment - * - * @param loanId Loan Id - * @return LoanAndLoanRepayment - */ - private Observable getLoanAndLoanRepayment(int loanId) { - return Observable.combineLatest( - mDataManagerLoan.syncLoanById(loanId), - mDataManagerLoan.syncLoanRepaymentTemplate(loanId), - new Func2() { - @Override - public LoanAndLoanRepayment call(LoanWithAssociations loanWithAssociations, - LoanRepaymentTemplate loanRepaymentTemplate) { - return new LoanAndLoanRepayment(loanWithAssociations, - loanRepaymentTemplate); - } - }) - .observeOn(AndroidSchedulers.mainThread()) - .subscribeOn(Schedulers.io()); - } - - /** - * This method fetching SavingsAccountAndTemplate. - * - * @param savingsAccountType - * @param savingsAccountId - * @return SavingsAccountAndTransactionTemplate - */ - private Observable getSavingsAccountAndTemplate( - String savingsAccountType, int savingsAccountId) { - return Observable.combineLatest( - mDataManagerSavings.syncSavingsAccount(savingsAccountType, savingsAccountId, - Constants.TRANSACTIONS), - mDataManagerSavings.syncSavingsAccountTransactionTemplate(savingsAccountType, - savingsAccountId, Constants.SAVINGS_ACCOUNT_TRANSACTION_DEPOSIT), - new Func2() { - @Override - public SavingsAccountAndTransactionTemplate call( - SavingsAccountWithAssociations savingsAccountWithAssociations, - SavingsAccountTransactionTemplate savingsAccountTransactionTemplate) { - return new SavingsAccountAndTransactionTemplate( - savingsAccountWithAssociations, savingsAccountTransactionTemplate); - } - }) - .observeOn(AndroidSchedulers.mainThread()) - .subscribeOn(Schedulers.io()); - } - - /** - * This Method fetching the Center Associate Groups List. - * - * @param centerId Center Id - */ - private void loadCenterAssociateGroups(int centerId) { - checkViewAttached(); - getMvpView().showProgressbar(true); - mSubscriptions.add(mDataManagerCenter.getCenterWithAssociations(centerId) - .observeOn(AndroidSchedulers.mainThread()) - .subscribeOn(Schedulers.io()) - .subscribe(new Subscriber() { - @Override - public void onCompleted() { - - } - - @Override - public void onError(Throwable e) { - onAccountSyncFailed(e); - } - - @Override - public void onNext(CenterWithAssociations centerWithAssociations) { - mGroups = centerWithAssociations.getGroupMembers(); - mGroupSyncIndex = 0; - resetIndexes(); - if (mGroups.size() != 0) { - getMvpView().setGroupSyncProgressBarMax(mGroups.size()); - syncGroupAccounts(mGroups.get(mGroupSyncIndex).getId()); - } else { - syncCenter(mCenterList.get(mCenterSyncIndex)); - } - } - }) - ); - } - - /** - * This Method fetching the Group Associate Clients List. - * - * @param groupId Group Id - */ - private void loadGroupAssociateClients(int groupId) { - checkViewAttached(); - getMvpView().showProgressbar(true); - mSubscriptions.add(mDataManagerGroups.getGroupWithAssociations(groupId) - .observeOn(AndroidSchedulers.mainThread()) - .subscribeOn(Schedulers.io()) - .subscribe(new Subscriber() { - @Override - public void onCompleted() { - - } - - @Override - public void onError(Throwable e) { - onAccountSyncFailed(e); - } - - @Override - public void onNext(GroupWithAssociations groupWithAssociations) { - mClients = groupWithAssociations.getClientMembers(); - mClientSyncIndex = 0; - resetIndexes(); - if (mClients.size() != 0) { - getMvpView().setClientSyncProgressBarMax(mClients.size()); - syncClientAccounts(mClients.get(mClientSyncIndex).getId()); - } else { - syncGroup(mGroups.get(mGroupSyncIndex)); - } - } - }) - ); - } - - /** - * Sync the Group Account with Group Id. This method fetching the Group Accounts from the - * REST API using retrofit 2 and saving these accounts to Database with DatabaseHelperGroup - * and then DataManagerGroup gives the returns the Group Accounts to Presenter. - *

- *

- * onNext : As Group Accounts Successfully sync then now sync the there Loan and LoanRepayment - * onError : - * - * @param groupId Group Id - */ - private void syncGroupAccounts(int groupId) { - checkViewAttached(); - mSubscriptions.add(mDataManagerGroups.syncGroupAccounts(groupId) - .observeOn(AndroidSchedulers.mainThread()) - .subscribeOn(Schedulers.io()) - .subscribe(new Subscriber() { - @Override - public void onCompleted() { - - } - - @Override - public void onError(Throwable e) { - onAccountSyncFailed(e); - } - - @Override - public void onNext(GroupAccounts groupAccounts) { - mLoanAccountList = Utils.getActiveLoanAccounts(groupAccounts - .getLoanAccounts()); - mSavingsAccountList = Utils.getActiveSavingsAccounts(groupAccounts - .getSavingsAccounts()); - - checkAccountsSyncStatusAndSyncGroupAccounts(); - } - }) - ); - } - - /** - * Sync the Client Account with Client Id. This method fetching the Client Accounts from the - * REST API using retrofit 2 and saving these accounts to Database with DatabaseHelperClient - * and then DataManagerClient gives the returns the Clients Accounts to Presenter. - *

- *

- * onNext : As Client Accounts Successfully sync then now sync the there Loan and LoanRepayment - * onError : - * - * @param clientId Client Id - */ - private void syncClientAccounts(int clientId) { - checkViewAttached(); - mSubscriptions.add(mDataManagerClient.syncClientAccounts(clientId) - .observeOn(AndroidSchedulers.mainThread()) - .subscribeOn(Schedulers.io()) - .subscribe(new Subscriber() { - @Override - public void onCompleted() { - - } - - @Override - public void onError(Throwable e) { - onAccountSyncFailed(e); - } - - @Override - public void onNext(ClientAccounts clientAccounts) { - mLoanAccountList = Utils.getActiveLoanAccounts(clientAccounts - .getLoanAccounts()); - mSavingsAccountList = Utils.getActiveSavingsAccounts(clientAccounts - .getSavingsAccounts()); - - checkAccountsSyncStatusAndSyncClientAccounts(); - } - }) - ); - } - - /** - * This Method check the Group LoanAccount isEmpty or not, If LoanAccount is not Empty the sync - * the loanAccount locally and If LoanAccount is empty then check to the next SavingAccount - * isEmpty or not. if SavingAccount is not empty then sync the SavingsAccount locally and if - * savingsAccount are Empty the sync the groups locally, Yep Groups has been synced. - */ - private void checkAccountsSyncStatusAndSyncGroupAccounts() { - if (!mLoanAccountList.isEmpty() && !mLoanAccountSyncStatus) { - //Sync the Active Loan and LoanRepayment - syncGroupLoanAndLoanRepayment( - mLoanAccountList.get(mLoanAndRepaymentSyncIndex).getId()); - } else if (!mSavingsAccountList.isEmpty()) { - //Sync the Active Savings Account - syncGroupSavingsAccountAndTemplate(mSavingsAccountList - .get(mSavingsAndTransactionSyncIndex).getDepositType().getEndpoint(), - mSavingsAccountList.get(mSavingsAndTransactionSyncIndex).getId()); - } else { - loadGroupAssociateClients(mGroups.get(mGroupSyncIndex).getId()); - } - } - - /** - * This Method check the Client LoanAccount isEmpty or not, If LoanAccount is not Empty the sync - * the loanAccount locally and If LoanAccount is empty then check to the next SavingAccount - * isEmpty or not. if SavingAccount is not empty then sync the SavingsAccount locally and if - * savingsAccount are Empty the sync the groups locally, Yep Groups has been synced. - */ - private void checkAccountsSyncStatusAndSyncClientAccounts() { - if (!mLoanAccountList.isEmpty() && !mLoanAccountSyncStatus) { - //Sync the Active Loan and LoanRepayment - syncClientLoanAndLoanRepayment( - mLoanAccountList.get(mLoanAndRepaymentSyncIndex).getId()); - } else if (!mSavingsAccountList.isEmpty()) { - //Sync the Active Savings Account - syncClientSavingsAccountAndTemplate(mSavingsAccountList - .get(mSavingsAndTransactionSyncIndex).getDepositType().getEndpoint(), - mSavingsAccountList.get(mSavingsAndTransactionSyncIndex).getId()); - } else { - syncClient(mClients.get(mClientSyncIndex)); - } - } - - /** - * This Method Saving the Groups to Database, If their Accounts, Loan and LoanRepayment - * saved Synced successfully. - * - * @param group - */ - private void syncGroup(Group group) { - checkViewAttached(); - group.setCenterId(mCenterList.get(mCenterSyncIndex).getId()); - group.setSync(true); - mSubscriptions.add(mDataManagerGroups.syncGroupInDatabase(group) - .observeOn(AndroidSchedulers.mainThread()) - .subscribeOn(Schedulers.io()) - .subscribe(new Subscriber() { - @Override - public void onCompleted() { - - } - - @Override - public void onError(Throwable e) { - getMvpView().showError(R.string.failed_to_sync_client); - } - - @Override - public void onNext(Group Group) { - resetIndexes(); - getMvpView().updateClientSyncProgressBar(0); - mGroupSyncIndex = mGroupSyncIndex + 1; - getMvpView().updateGroupSyncProgressBar(mGroupSyncIndex); - if (mGroups.size() == mGroupSyncIndex) { - syncCenter(mCenterList.get(mCenterSyncIndex)); - } else { - syncGroupAccounts(mGroups.get(mGroupSyncIndex).getId()); - } - - } - }) - ); - } - - /** - * This Method Saving the Clients to Database, If their Accounts, Loan and LoanRepayment - * saved Synced successfully. - * - * @param client - */ - private void syncClient(Client client) { - checkViewAttached(); - client.setGroupId(mGroups.get(mGroupSyncIndex).getId()); - client.setSync(true); - mSubscriptions.add(mDataManagerClient.syncClientInDatabase(client) - .observeOn(AndroidSchedulers.mainThread()) - .subscribeOn(Schedulers.io()) - .subscribe(new Subscriber() { - @Override - public void onCompleted() { - - } - - @Override - public void onError(Throwable e) { - getMvpView().showError(R.string.failed_to_sync_client); - } - - @Override - public void onNext(Client client) { - resetIndexes(); - mClientSyncIndex = mClientSyncIndex + 1; - getMvpView().updateClientSyncProgressBar(mClientSyncIndex); - if (mClients.size() == mClientSyncIndex) { - syncGroup(mGroups.get(mGroupSyncIndex)); - } else { - syncClientAccounts(mClients.get(mClientSyncIndex).getId()); - } - - } - }) - ); - } - - /** - * This Method Syncing the Group's Loan and their LoanRepayment. This is the - * Observable.combineLatest In Which two request is going to server Loans and LoanRepayment - * and This request will not complete till that both request completed successfully with - * response (200 OK). If one will fail then response will come in onError. and If both - * request is 200 response then response will come in onNext. - * - * @param loanId Loan Id - */ - private void syncGroupLoanAndLoanRepayment(int loanId) { - checkViewAttached(); - mSubscriptions.add(getLoanAndLoanRepayment(loanId) - .subscribe(new Subscriber() { - @Override - public void onCompleted() { - - } - - @Override - public void onError(Throwable e) { - onAccountSyncFailed(e); - } - - @Override - public void onNext(LoanAndLoanRepayment loanAndLoanRepayment) { - mLoanAndRepaymentSyncIndex = mLoanAndRepaymentSyncIndex + 1; - if (mLoanAndRepaymentSyncIndex != mLoanAccountList.size()) { - syncGroupLoanAndLoanRepayment( - mLoanAccountList.get(mLoanAndRepaymentSyncIndex).getId()); - } else { - setLoanAccountSyncStatusTrue(); - checkAccountsSyncStatusAndSyncGroupAccounts(); - } - } - }) - ); - } - - /** - * This Method Syncing the Client's Loan and their LoanRepayment. This is the - * Observable.combineLatest In Which two request is going to server Loans and LoanRepayment - * and This request will not complete till that both request completed successfully with - * response (200 OK). If one will fail then response will come in onError. and If both - * request is 200 response then response will come in onNext. - * - * @param loanId Loan Id - */ - private void syncClientLoanAndLoanRepayment(int loanId) { - checkViewAttached(); - mSubscriptions.add(getLoanAndLoanRepayment(loanId) - .subscribe(new Subscriber() { - @Override - public void onCompleted() { - - } - - @Override - public void onError(Throwable e) { - onAccountSyncFailed(e); - } - - @Override - public void onNext(LoanAndLoanRepayment loanAndLoanRepayment) { - mLoanAndRepaymentSyncIndex = mLoanAndRepaymentSyncIndex + 1; - if (mLoanAndRepaymentSyncIndex != mLoanAccountList.size()) { - syncClientLoanAndLoanRepayment( - mLoanAccountList.get(mLoanAndRepaymentSyncIndex).getId()); - } else { - setLoanAccountSyncStatusTrue(); - checkAccountsSyncStatusAndSyncClientAccounts(); - } - } - }) - ); - } - - /** - * This Method Fetching the Groups SavingsAccount and SavingsAccountTransactionTemplate and Sync - * them in Database table. - * - * @param savingsAccountType SavingsAccount Type Example : savingsaccounts - * @param savingsAccountId SavingsAccount Id - */ - private void syncGroupSavingsAccountAndTemplate(String savingsAccountType, - int savingsAccountId) { - checkViewAttached(); - mSubscriptions.add(getSavingsAccountAndTemplate(savingsAccountType, savingsAccountId) - .subscribe(new Subscriber() { - @Override - public void onCompleted() { - - } - - @Override - public void onError(Throwable e) { - onAccountSyncFailed(e); - } - - @Override - public void onNext(SavingsAccountAndTransactionTemplate - savingsAccountAndTransactionTemplate) { - mSavingsAndTransactionSyncIndex = mSavingsAndTransactionSyncIndex + 1; - if (mSavingsAndTransactionSyncIndex != mSavingsAccountList.size()) { - syncGroupSavingsAccountAndTemplate( - mSavingsAccountList - .get(mSavingsAndTransactionSyncIndex) - .getDepositType().getEndpoint(), - mSavingsAccountList - .get(mSavingsAndTransactionSyncIndex).getId()); - } else { - loadGroupAssociateClients(mGroups.get(mGroupSyncIndex).getId()); - } - } - }) - ); - } - - /** - * This Method Fetching the Client SavingsAccount and SavingsAccountTransactionTemplate and Sync - * them in Database table. - * - * @param savingsAccountType SavingsAccount Type Example : savingsaccounts - * @param savingsAccountId SavingsAccount Id - */ - private void syncClientSavingsAccountAndTemplate(String savingsAccountType, - int savingsAccountId) { - checkViewAttached(); - mSubscriptions.add(getSavingsAccountAndTemplate(savingsAccountType, savingsAccountId) - .subscribe(new Subscriber() { - @Override - public void onCompleted() { - - } - - @Override - public void onError(Throwable e) { - onAccountSyncFailed(e); - } - - @Override - public void onNext(SavingsAccountAndTransactionTemplate - savingsAccountAndTransactionTemplate) { - mSavingsAndTransactionSyncIndex = mSavingsAndTransactionSyncIndex + 1; - if (mSavingsAndTransactionSyncIndex != mSavingsAccountList.size()) { - syncClientSavingsAccountAndTemplate( - mSavingsAccountList - .get(mSavingsAndTransactionSyncIndex) - .getDepositType().getEndpoint(), - mSavingsAccountList - .get(mSavingsAndTransactionSyncIndex).getId()); - } else { - syncClient(mClients.get(mClientSyncIndex)); - } - } - }) - ); - } - - public void updateTotalSyncProgressBarAndCount() { - getMvpView().updateTotalSyncCenterProgressBarAndCount(mCenterSyncIndex); - } - - public void updateCenterName() { - String centerName = mCenterList.get(mCenterSyncIndex).getName(); - getMvpView().showSyncingCenter(centerName); - } -} diff --git a/mifosng-android/src/main/java/com/mifos/mifosxdroid/dialogfragments/synccenterdialog/SyncCentersDialogFragment.java b/mifosng-android/src/main/java/com/mifos/mifosxdroid/dialogfragments/synccenterdialog/SyncCentersDialogFragment.java deleted file mode 100644 index e8b5508c0a9..00000000000 --- a/mifosng-android/src/main/java/com/mifos/mifosxdroid/dialogfragments/synccenterdialog/SyncCentersDialogFragment.java +++ /dev/null @@ -1,246 +0,0 @@ -package com.mifos.mifosxdroid.dialogfragments.synccenterdialog; - -import android.os.Bundle; -import android.os.Parcelable; -import android.support.annotation.Nullable; -import android.support.v4.app.DialogFragment; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.Button; -import android.widget.ProgressBar; -import android.widget.TextView; -import android.widget.Toast; - -import com.mifos.mifosxdroid.R; -import com.mifos.mifosxdroid.core.MifosBaseActivity; -import com.mifos.mifosxdroid.core.util.Toaster; -import com.mifos.objects.group.Center; -import com.mifos.utils.Constants; -import com.mifos.utils.Network; -import com.mifos.utils.PrefManager; - -import java.util.ArrayList; -import java.util.List; - -import javax.inject.Inject; - -import butterknife.BindView; -import butterknife.ButterKnife; -import butterknife.OnClick; - -public class SyncCentersDialogFragment extends DialogFragment implements SyncCenterDialogMvpView { - - @BindView(R.id.tv_sync_title) - TextView tvSyncTitle; - - @BindView(R.id.tv_center_name) - TextView tvSyncingCenterName; - - @BindView(R.id.tv_total_centers) - TextView tvTotalCenters; - - @BindView(R.id.tv_syncing_center) - TextView tvSyncingCenter; - - @BindView(R.id.pb_sync_center) - ProgressBar pbSyncingCenter; - - @BindView(R.id.tv_total_progress) - TextView tvTotalProgress; - - @BindView(R.id.pb_total_sync_center) - ProgressBar pbTotalSyncCenter; - - @BindView(R.id.tv_syncing_group) - TextView tvSyncingGroup; - - @BindView(R.id.pb_sync_group) - ProgressBar pbSyncingGroup; - - @BindView(R.id.tv_syncing_client) - TextView tvSyncingClient; - - @BindView(R.id.pb_sync_client) - ProgressBar pbSyncingClient; - - @BindView(R.id.tv_sync_failed) - TextView tvSyncFailed; - - @BindView(R.id.btn_hide) - Button btnHide; - - @BindView(R.id.btn_cancel) - Button btnCancel; - - @Inject - SyncCenterDialogPresenter syncCentersDialogPresenter; - - View rootView; - private List

mCenterList; - - public static SyncCentersDialogFragment newInstance(List
center) { - SyncCentersDialogFragment syncCentersDialogFragment = new SyncCentersDialogFragment(); - Bundle args = new Bundle(); - args.putParcelableArrayList(Constants.CENTER, (ArrayList) center); - syncCentersDialogFragment.setArguments(args); - return syncCentersDialogFragment; - } - - @Override - public void onCreate(@Nullable Bundle savedInstanceState) { - ((MifosBaseActivity) getActivity()).getActivityComponent().inject(this); - if (getArguments() != null) { - mCenterList = getArguments().getParcelableArrayList(Constants.CENTER); - } - super.onCreate(savedInstanceState); - } - - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { - rootView = inflater.inflate(R.layout.dialog_fragment_sync_centers, container, false); - ButterKnife.bind(this, rootView); - syncCentersDialogPresenter.attachView(this); - - showUI(); - - //Start Syncing Centers - if (isOnline() && (PrefManager.getUserStatus() == Constants.USER_ONLINE)) { - syncCentersDialogPresenter.startSyncingCenters(mCenterList); - } else { - showNetworkIsNotAvailable(); - getActivity().getSupportFragmentManager().popBackStack(); - } - - return rootView; - } - - @OnClick(R.id.btn_cancel) - void onClickCancelButton() { - dismissDialog(); - } - - @OnClick(R.id.btn_hide) - void onClickHideButton() { - if (btnHide.getText().equals(getResources().getString(R.string.dialog_action_ok))) { - dismissDialog(); - } else { - hideDialog(); - } - } - - @Override - public void showUI() { - pbTotalSyncCenter.setMax(mCenterList.size()); - String totalCenters = mCenterList.size() + getResources().getString(R.string.space) + - getResources().getString(R.string.centers); - tvTotalCenters.setText(totalCenters); - tvSyncFailed.setText(String.valueOf(0)); - } - - @Override - public void showSyncingCenter(String centerName) { - tvSyncingCenter.setText(centerName); - tvSyncingCenterName.setText(centerName); - } - - @Override - public void showSyncedFailedCenters(int failedCount) { - tvSyncFailed.setText(String.valueOf(failedCount)); - } - - @Override - public void setMaxSingleSyncCenterProgressBar(int total) { - pbSyncingCenter.setMax(total); - } - - @Override - public void updateSingleSyncCenterProgressBar(int count) { - pbSyncingCenter.setProgress(count); - } - - @Override - public void updateTotalSyncCenterProgressBarAndCount(int count) { - pbTotalSyncCenter.setProgress(count); - String totalSyncCount = getResources() - .getString(R.string.space) + count + getResources() - .getString(R.string.slash) + mCenterList.size(); - tvTotalProgress.setText(totalSyncCount); - } - - @Override - public int getMaxSingleSyncCenterProgressBar() { - return pbSyncingCenter.getMax(); - } - - @Override - public void showNetworkIsNotAvailable() { - Toast.makeText(getActivity(), getResources().getString(R.string - .error_network_not_available), Toast.LENGTH_SHORT).show(); - } - - @Override - public void showCentersSyncSuccessfully() { - btnCancel.setVisibility(View.INVISIBLE); - btnHide.setText(getResources().getString(R.string.dialog_action_ok)); - } - - @Override - public void setGroupSyncProgressBarMax(int count) { - pbSyncingGroup.setMax(count); - } - - @Override - public void updateGroupSyncProgressBar(int i) { - pbSyncingGroup.setProgress(i); - } - - @Override - public void setClientSyncProgressBarMax(int count) { - pbSyncingClient.setMax(count); - } - - @Override - public void updateClientSyncProgressBar(int i) { - pbSyncingClient.setProgress(i); - } - - - - @Override - public Boolean isOnline() { - return Network.isOnline(getActivity()); - } - - @Override - public void dismissDialog() { - getDialog().dismiss(); - } - - @Override - public void showDialog() { - getDialog().show(); - } - - @Override - public void hideDialog() { - getDialog().hide(); - } - - @Override - public void showError(int s) { - Toaster.show(rootView, s); - } - - @Override - public void showProgressbar(boolean b) { - - } - - @Override - public void onDestroyView() { - super.onDestroyView(); - syncCentersDialogPresenter.detachView(); - } -} diff --git a/mifosng-android/src/main/java/com/mifos/mifosxdroid/injection/component/ActivityComponent.java b/mifosng-android/src/main/java/com/mifos/mifosxdroid/injection/component/ActivityComponent.java index 765bc466f2b..ac8426f2a4e 100644 --- a/mifosng-android/src/main/java/com/mifos/mifosxdroid/injection/component/ActivityComponent.java +++ b/mifosng-android/src/main/java/com/mifos/mifosxdroid/injection/component/ActivityComponent.java @@ -7,7 +7,6 @@ import com.mifos.mifosxdroid.dialogfragments.documentdialog.DocumentDialogFragment; import com.mifos.mifosxdroid.dialogfragments.identifierdialog.IdentifierDialogFragment; import com.mifos.mifosxdroid.dialogfragments.loanchargedialog.LoanChargeDialogFragment; -import com.mifos.mifosxdroid.dialogfragments.synccenterdialog.SyncCentersDialogFragment; import com.mifos.mifosxdroid.dialogfragments.syncclientsdialog.SyncClientsDialogFragment; import com.mifos.mifosxdroid.dialogfragments.syncgroupsdialog.SyncGroupsDialogFragment; import com.mifos.mifosxdroid.injection.PerActivity; @@ -164,8 +163,6 @@ public interface ActivityComponent { void inject(SyncGroupsDialogFragment syncGroupsDialogFragment); - void inject(SyncCentersDialogFragment syncCentersDialogFragment); - void inject(IdentifierDialogFragment identifierDialogFragment); void inject(PathTrackingActivity pathTrackingActivity); diff --git a/mifosng-android/src/main/java/com/mifos/mifosxdroid/online/centerlist/CenterListFragment.java b/mifosng-android/src/main/java/com/mifos/mifosxdroid/online/centerlist/CenterListFragment.java index 7efc36e19cd..03153409306 100755 --- a/mifosng-android/src/main/java/com/mifos/mifosxdroid/online/centerlist/CenterListFragment.java +++ b/mifosng-android/src/main/java/com/mifos/mifosxdroid/online/centerlist/CenterListFragment.java @@ -7,18 +7,14 @@ import android.content.Intent; import android.os.Bundle; -import android.support.v4.app.FragmentTransaction; import android.support.v4.widget.SwipeRefreshLayout; import android.support.v4.widget.SwipeRefreshLayout.OnRefreshListener; -import android.support.v7.view.ActionMode; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; -import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; -import android.widget.ImageView; import android.widget.ProgressBar; import android.widget.RelativeLayout; import android.widget.TextView; @@ -31,7 +27,6 @@ import com.mifos.mifosxdroid.core.RecyclerItemClickListener; import com.mifos.mifosxdroid.core.RecyclerItemClickListener.OnItemClickListener; import com.mifos.mifosxdroid.core.util.Toaster; -import com.mifos.mifosxdroid.dialogfragments.synccenterdialog.SyncCentersDialogFragment; import com.mifos.mifosxdroid.online.CentersActivity; import com.mifos.mifosxdroid.online.collectionsheet.CollectionSheetFragment; import com.mifos.mifosxdroid.online.createnewcenter.CreateNewCenterFragment; @@ -39,7 +34,6 @@ import com.mifos.objects.group.Center; import com.mifos.objects.group.CenterWithAssociations; import com.mifos.utils.Constants; -import com.mifos.utils.FragmentConstants; import java.util.ArrayList; import java.util.List; @@ -60,13 +54,13 @@ public class CenterListFragment extends MifosBaseFragment implements CenterListMvpView, OnItemClickListener, OnRefreshListener { @BindView(R.id.rv_center_list) - RecyclerView rvCenters; + RecyclerView rv_centers; @BindView(R.id.swipe_container) SwipeRefreshLayout swipeRefreshLayout; @BindView(R.id.progressbar_center) - ProgressBar pbCenter; + ProgressBar pb_center; @BindView(R.id.noCenterText) TextView mNoCenterText; @@ -80,34 +74,20 @@ public class CenterListFragment extends MifosBaseFragment @Inject CentersListAdapter centersListAdapter; - @BindView(R.id.noCentersIcon) - ImageView mNoCenterIcon; - private View rootView; private List
centers; - private List
selectedCenters; private LinearLayoutManager layoutManager; - private ActionModeCallback actionModeCallback; - private ActionMode actionMode; @Override public void onItemClick(View childView, int position) { - if (actionMode != null) { - toggleSelection(position); - } else { - Intent centerIntent = new Intent(getActivity(), CentersActivity.class); - centerIntent.putExtra(Constants.CENTER_ID, centers.get(position).getId()); - startActivity(centerIntent); - } + Intent centerIntent = new Intent(getActivity(), CentersActivity.class); + centerIntent.putExtra(Constants.CENTER_ID, centers.get(position).getId()); + startActivity(centerIntent); } @Override public void onItemLongPress(View childView, int position) { - if (actionMode == null) { - actionMode = ((MifosBaseActivity) getActivity()).startSupportActionMode - (actionModeCallback); - } - toggleSelection(position); + mCenterListPresenter.loadCentersGroupAndMeeting(centers.get(position).getId()); } public static CenterListFragment newInstance() { @@ -122,8 +102,6 @@ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setHasOptionsMenu(true); centers = new ArrayList<>(); - selectedCenters = new ArrayList<>(); - actionModeCallback = new ActionModeCallback(); ((MifosBaseActivity) getActivity()).getActivityComponent().inject(this); } @@ -139,21 +117,19 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle showUserInterface(); //Fetching Centers + mCenterListPresenter.loadCenters(false, 0); /** * This is the LoadMore of the RecyclerView. It called When Last Element of RecyclerView * will shown on the Screen. */ - rvCenters.addOnScrollListener(new EndlessRecyclerViewScrollListener(layoutManager) { + rv_centers.addOnScrollListener(new EndlessRecyclerViewScrollListener(layoutManager) { @Override public void onLoadMore(int page, int totalItemsCount) { mCenterListPresenter.loadCenters(true, totalItemsCount); } }); - mCenterListPresenter.loadCenters(false, 0); - mCenterListPresenter.loadDatabaseCenters(); - return rootView; } @@ -165,11 +141,11 @@ public void showUserInterface() { setToolbarTitle(getResources().getString(R.string.title_activity_centers)); layoutManager = new LinearLayoutManager(getActivity()); layoutManager.setOrientation(LinearLayoutManager.VERTICAL); - rvCenters.setLayoutManager(layoutManager); - rvCenters.addOnItemTouchListener(new RecyclerItemClickListener(getActivity(), this)); - rvCenters.setHasFixedSize(true); + rv_centers.setLayoutManager(layoutManager); + rv_centers.addOnItemTouchListener(new RecyclerItemClickListener(getActivity(), this)); + rv_centers.setHasFixedSize(true); centersListAdapter.setContext(getActivity()); - rvCenters.setAdapter(centersListAdapter); + rv_centers.setAdapter(centersListAdapter); swipeRefreshLayout.setColorSchemeColors(getActivity() .getResources().getIntArray(R.array.swipeRefreshColors)); swipeRefreshLayout.setOnRefreshListener(this); @@ -187,8 +163,6 @@ void onClickCreateNewCenter() { @Override public void onRefresh() { mCenterListPresenter.loadCenters(false, 0); - mCenterListPresenter.loadDatabaseCenters(); - if (actionMode != null) actionMode.finish(); } /** @@ -197,9 +171,8 @@ public void onRefresh() { @OnClick(R.id.noCentersIcon) public void reloadOnError() { rlError.setVisibility(View.GONE); - rvCenters.setVisibility(View.VISIBLE); + rv_centers.setVisibility(View.VISIBLE); mCenterListPresenter.loadCenters(false, 0); - mCenterListPresenter.loadDatabaseCenters(); } /** @@ -211,7 +184,6 @@ public void reloadOnError() { public void showCenters(List
centers) { this.centers = centers; centersListAdapter.setCenters(centers); - centersListAdapter.notifyDataSetChanged(); } /** @@ -232,7 +204,7 @@ public void showMoreCenters(List
centers) { */ @Override public void showEmptyCenters(int message) { - rvCenters.setVisibility(View.GONE); + rv_centers.setVisibility(View.GONE); rlError.setVisibility(View.VISIBLE); mNoCenterText.setText(getStringMessage(message)); } @@ -280,7 +252,7 @@ public void onDatePicked(String date) { */ @Override public void showFetchingError() { - rvCenters.setVisibility(View.GONE); + rv_centers.setVisibility(View.GONE); rlError.setVisibility(View.VISIBLE); String errorMessage = getStringMessage(R.string.failed_to_fetch_centers) + getStringMessage(R.string.new_line) + getStringMessage(R.string.click_to_refresh); @@ -297,24 +269,13 @@ public void showFetchingError() { public void showProgressbar(boolean show) { swipeRefreshLayout.setRefreshing(show); if (show && centersListAdapter.getItemCount() == 0) { - pbCenter.setVisibility(View.VISIBLE); + pb_center.setVisibility(View.VISIBLE); swipeRefreshLayout.setRefreshing(false); } else { - pbCenter.setVisibility(View.GONE); + pb_center.setVisibility(View.GONE); } } - /** - * This Method unregister the RecyclerView OnScrollListener and SwipeRefreshLayout - * and NoClientIcon click event. - */ - @Override - public void unregisterSwipeAndScrollListener() { - rvCenters.clearOnScrollListeners(); - swipeRefreshLayout.setEnabled(false); - mNoCenterIcon.setEnabled(false); - } - @Override public boolean onOptionsItemSelected(MenuItem item) { if (item.getItemId() == R.id.mItem_search) @@ -327,76 +288,4 @@ public void onDestroyView() { super.onDestroyView(); mCenterListPresenter.detachView(); } - - /** - * Toggle the selection state of an item. - *

- * If the item was the last one in the selection and is unselected, the selection is stopped. - * Note that the selection must already be started (actionMode must not be null). - * - * @param position Position of the item to toggle the selection state - */ - private void toggleSelection(int position) { - centersListAdapter.toggleSelection(position); - int count = centersListAdapter.getSelectedItemCount(); - - if (count == 0) { - actionMode.finish(); - } else { - actionMode.setTitle(String.valueOf(count)); - actionMode.invalidate(); - } - } - - /** - * This ActionModeCallBack Class handling the User Event after the Selection of Clients. Like - * Click of Menu Sync Button and finish the ActionMode - */ - private class ActionModeCallback implements ActionMode.Callback { - @SuppressWarnings("unused") - private final String LOG_TAG = ActionModeCallback.class.getSimpleName(); - - @Override - public boolean onCreateActionMode(ActionMode mode, Menu menu) { - mode.getMenuInflater().inflate(R.menu.menu_sync, menu); - return true; - } - - @Override - public boolean onPrepareActionMode(ActionMode mode, Menu menu) { - return false; - } - - @Override - public boolean onActionItemClicked(ActionMode mode, MenuItem item) { - switch (item.getItemId()) { - case R.id.action_sync: - - selectedCenters.clear(); - for (Integer position : centersListAdapter.getSelectedItems()) { - selectedCenters.add(centers.get(position)); - } - - SyncCentersDialogFragment syncCentersDialogFragment = - SyncCentersDialogFragment.newInstance(selectedCenters); - FragmentTransaction fragmentTransaction = getActivity() - .getSupportFragmentManager().beginTransaction(); - fragmentTransaction.addToBackStack(FragmentConstants.FRAG_CLIENT_SYNC); - syncCentersDialogFragment.setCancelable(false); - syncCentersDialogFragment.show(fragmentTransaction, - getResources().getString(R.string.sync_centers)); - mode.finish(); - return true; - - default: - return false; - } - } - - @Override - public void onDestroyActionMode(ActionMode mode) { - centersListAdapter.clearSelection(); - actionMode = null; - } - } } \ No newline at end of file diff --git a/mifosng-android/src/main/java/com/mifos/mifosxdroid/online/centerlist/CenterListMvpView.java b/mifosng-android/src/main/java/com/mifos/mifosxdroid/online/centerlist/CenterListMvpView.java index 5459053ab04..746d68f37f4 100644 --- a/mifosng-android/src/main/java/com/mifos/mifosxdroid/online/centerlist/CenterListMvpView.java +++ b/mifosng-android/src/main/java/com/mifos/mifosxdroid/online/centerlist/CenterListMvpView.java @@ -21,8 +21,6 @@ public interface CenterListMvpView extends MvpView { void showMessage(int message); - void unregisterSwipeAndScrollListener(); - void showCentersGroupAndMeeting(CenterWithAssociations centerWithAssociations, int id); void showFetchingError(); diff --git a/mifosng-android/src/main/java/com/mifos/mifosxdroid/online/centerlist/CenterListPresenter.java b/mifosng-android/src/main/java/com/mifos/mifosxdroid/online/centerlist/CenterListPresenter.java index 2b919f7a74e..baa84741e20 100644 --- a/mifosng-android/src/main/java/com/mifos/mifosxdroid/online/centerlist/CenterListPresenter.java +++ b/mifosng-android/src/main/java/com/mifos/mifosxdroid/online/centerlist/CenterListPresenter.java @@ -7,7 +7,6 @@ import com.mifos.objects.group.Center; import com.mifos.objects.group.CenterWithAssociations; -import java.util.ArrayList; import java.util.List; import javax.inject.Inject; @@ -25,20 +24,15 @@ public class CenterListPresenter extends BasePresenter { private final DataManagerCenter mDataManagerCenter; private CompositeSubscription mSubscriptions; - private List

mDbCenterList; private List
mSyncCenterList; private int limit = 100; private Boolean loadmore = false; - private Boolean mRestApiCenterSyncStatus = false; - private Boolean mDatabaseCenterSyncStatus = false; @Inject public CenterListPresenter(DataManagerCenter dataManagerCenter) { mDataManagerCenter = dataManagerCenter; mSubscriptions = new CompositeSubscription(); - mDbCenterList = new ArrayList<>(); - mSyncCenterList = new ArrayList<>(); } @@ -51,7 +45,7 @@ public void attachView(CenterListMvpView mvpView) { @Override public void detachView() { super.detachView(); - mSubscriptions.unsubscribe(); + mSubscriptions.clear(); } @@ -79,15 +73,6 @@ public void showCenters(List
centers) { } } - /** - * Setting CenterSync Status True when mRestApiCenterSyncStatus && mDatabaseCenterSyncStatus - * are true. - */ - public void setAlreadyCenterSyncStatus() { - if (mRestApiCenterSyncStatus && mDatabaseCenterSyncStatus) { - showCenters(checkCenterAlreadySyncedOrNot(mSyncCenterList)); - } - } /** * @param paged True Enabling the Pagination of the API @@ -121,13 +106,10 @@ public void onNext(Page
centerPage) { if (mSyncCenterList.size() == 0 && !loadmore) { getMvpView().showEmptyCenters(R.string.empty_center_list); - getMvpView().unregisterSwipeAndScrollListener(); } else if (mSyncCenterList.size() == 0 && loadmore) { getMvpView().showMessage(R.string.no_more_centers_available); } else { showCenters(mSyncCenterList); - mRestApiCenterSyncStatus = true; - setAlreadyCenterSyncStatus(); } getMvpView().showProgressbar(false); } @@ -157,56 +139,4 @@ public void onNext(CenterWithAssociations centerWithAssociations) { } })); } - - /** - * This Method Loading the Center From Database. It request Observable to DataManagerCenter - * and DataManagerCenter Request to DatabaseHelperCenter to load the Center List Page from the - * Center_Table and As the Center List Page is loaded DataManagerCenter gives the Center List - * Page after getting response from DatabaseHelperCenter - */ - public void loadDatabaseCenters() { - checkViewAttached(); - mSubscriptions.add(mDataManagerCenter.getAllDatabaseCenters() - .observeOn(AndroidSchedulers.mainThread()) - .subscribeOn(Schedulers.io()) - .subscribe(new Subscriber>() { - @Override - public void onCompleted() { - } - - @Override - public void onError(Throwable e) { - getMvpView().showMessage(R.string.failed_to_load_db_centers); - } - - @Override - public void onNext(Page
centerPage) { - mDatabaseCenterSyncStatus = true; - mDbCenterList = centerPage.getPageItems(); - setAlreadyCenterSyncStatus(); - } - }) - ); - } - - /** - * This Method Filtering the Centers Loaded from Server is already sync or not. If yes the - * put the center.setSync(true) and view will show those centers as sync already to user - * - * @param - * @return Page
- */ - public List
checkCenterAlreadySyncedOrNot(List
centers) { - if (mDbCenterList.size() != 0) { - for (Center dbCenter : mDbCenterList) { - for (Center syncCenter : centers) { - if (dbCenter.getId().equals(syncCenter.getId())) { - syncCenter.setSync(true); - break; - } - } - } - } - return centers; - } -} \ No newline at end of file +} diff --git a/mifosng-android/src/main/java/com/mifos/objects/accounts/CenterAccounts.java b/mifosng-android/src/main/java/com/mifos/objects/accounts/CenterAccounts.java deleted file mode 100644 index c3cb61852af..00000000000 --- a/mifosng-android/src/main/java/com/mifos/objects/accounts/CenterAccounts.java +++ /dev/null @@ -1,118 +0,0 @@ -package com.mifos.objects.accounts; - -import android.os.Parcel; -import android.os.Parcelable; - -import com.mifos.objects.accounts.loan.LoanAccount; -import com.mifos.objects.accounts.savings.SavingsAccount; - -import java.util.ArrayList; -import java.util.List; - -/** - * Created by mayankjindal on 11/07/17. - */ - -public class CenterAccounts implements Parcelable { - - private List loanAccounts = new ArrayList(); - private List savingsAccounts = new ArrayList(); - private List memberLoanAccounts = new ArrayList(); - - public List getLoanAccounts() { - return loanAccounts; - } - - public void setLoanAccounts(List loanAccounts) { - this.loanAccounts = loanAccounts; - } - - public CenterAccounts withLoanAccounts(List loanAccounts) { - this.loanAccounts = loanAccounts; - return this; - } - - public List getSavingsAccounts() { - return savingsAccounts; - } - - public void setSavingsAccounts(List savingsAccounts) { - this.savingsAccounts = savingsAccounts; - } - - public List getMemberLoanAccounts() { - return memberLoanAccounts; - } - - public void setMemberLoanAccounts(List memberLoanAccounts) { - this.memberLoanAccounts = memberLoanAccounts; - } - - public CenterAccounts withSavingsAccounts(List savingsAccounts) { - this.savingsAccounts = savingsAccounts; - return this; - } - - public List getRecurringSavingsAccounts() { - return getSavingsAccounts(true); - } - - public List getNonRecurringSavingsAccounts() { - return getSavingsAccounts(false); - } - - private List getSavingsAccounts(boolean wantRecurring) { - List result = new ArrayList(); - if (this.savingsAccounts != null) { - for (SavingsAccount account : savingsAccounts) { - if (account.isRecurring() == wantRecurring) { - result.add(account); - } - } - } - return result; - } - - @Override - public String toString() { - return "ClientAccounts{" + - "loanAccounts=" + loanAccounts + - ", savingsAccounts=" + savingsAccounts + - ", memberLoanAccounts=" + memberLoanAccounts + - '}'; - } - - @Override - public int describeContents() { - return 0; - } - - @Override - public void writeToParcel(Parcel dest, int flags) { - dest.writeTypedList(this.loanAccounts); - dest.writeTypedList(this.savingsAccounts); - dest.writeTypedList(this.memberLoanAccounts); - } - - public CenterAccounts() { - } - - protected CenterAccounts(Parcel in) { - this.loanAccounts = in.createTypedArrayList(LoanAccount.CREATOR); - this.savingsAccounts = in.createTypedArrayList(SavingsAccount.CREATOR); - this.memberLoanAccounts = in.createTypedArrayList(LoanAccount.CREATOR); - } - - public static final Parcelable.Creator CREATOR = new Parcelable - .Creator() { - @Override - public CenterAccounts createFromParcel(Parcel source) { - return new CenterAccounts(source); - } - - @Override - public CenterAccounts[] newArray(int size) { - return new CenterAccounts[size]; - } - }; -} diff --git a/mifosng-android/src/main/java/com/mifos/objects/accounts/loan/LoanAccount.java b/mifosng-android/src/main/java/com/mifos/objects/accounts/loan/LoanAccount.java index 8cff325c69c..0ee5325029e 100755 --- a/mifosng-android/src/main/java/com/mifos/objects/accounts/loan/LoanAccount.java +++ b/mifosng-android/src/main/java/com/mifos/objects/accounts/loan/LoanAccount.java @@ -28,9 +28,6 @@ public class LoanAccount extends MifosBaseModel implements Parcelable { @Column long groupId; - @Column - long centerId; - @PrimaryKey Integer id; @@ -92,14 +89,6 @@ public void setClientId(long clientId) { this.clientId = clientId; } - public long getCenterId() { - return this.centerId; - } - - public void setCenterId(long centerId) { - this.centerId = centerId; - } - public Integer getId() { return id; } diff --git a/mifosng-android/src/main/java/com/mifos/objects/accounts/savings/SavingsAccount.java b/mifosng-android/src/main/java/com/mifos/objects/accounts/savings/SavingsAccount.java index f125e7bd1c7..2111644d832 100755 --- a/mifosng-android/src/main/java/com/mifos/objects/accounts/savings/SavingsAccount.java +++ b/mifosng-android/src/main/java/com/mifos/objects/accounts/savings/SavingsAccount.java @@ -27,9 +27,6 @@ public class SavingsAccount extends MifosBaseModel implements Parcelable { @Column transient long groupId; - @Column - long centerId; - @PrimaryKey Integer id; @@ -87,14 +84,6 @@ public void setClientId(long clientId) { this.clientId = clientId; } - public long getCenterId() { - return this.centerId; - } - - public void setCenterId(long centerId) { - this.centerId = centerId; - } - public Integer getId() { return id; } diff --git a/mifosng-android/src/main/java/com/mifos/objects/group/Center.java b/mifosng-android/src/main/java/com/mifos/objects/group/Center.java index 48edff5d4ed..949e429f195 100755 --- a/mifosng-android/src/main/java/com/mifos/objects/group/Center.java +++ b/mifosng-android/src/main/java/com/mifos/objects/group/Center.java @@ -13,7 +13,6 @@ import com.mifos.objects.Timeline; import com.mifos.objects.client.Status; import com.raizlabs.android.dbflow.annotation.Column; -import com.raizlabs.android.dbflow.annotation.ForeignKey; import com.raizlabs.android.dbflow.annotation.ModelContainer; import com.raizlabs.android.dbflow.annotation.PrimaryKey; import com.raizlabs.android.dbflow.annotation.Table; @@ -33,7 +32,7 @@ public class Center extends MifosBaseModel implements Parcelable { Integer id; @Column - transient boolean sync; + transient Boolean sync; @Column String accountNo; @@ -61,25 +60,13 @@ public class Center extends MifosBaseModel implements Parcelable { @Column Boolean active; - @Column - @ForeignKey(saveForeignKeyModel = true) - transient CenterDate centerDate; - List activationDate = new ArrayList(); Timeline timeline; String externalId; - public CenterDate getCenterDate() { - return centerDate; - } - - public void setCenterDate(CenterDate centerDate) { - this.centerDate = centerDate; - } - - public boolean isSync() { + public Boolean getSync() { return sync; } diff --git a/mifosng-android/src/main/java/com/mifos/objects/group/CenterDate.java b/mifosng-android/src/main/java/com/mifos/objects/group/CenterDate.java deleted file mode 100644 index 1b75ee620ca..00000000000 --- a/mifosng-android/src/main/java/com/mifos/objects/group/CenterDate.java +++ /dev/null @@ -1,117 +0,0 @@ -package com.mifos.objects.group; - -import android.os.Parcel; -import android.os.Parcelable; - -import com.google.gson.annotations.SerializedName; -import com.mifos.api.local.MifosBaseModel; -import com.mifos.api.local.MifosDatabase; -import com.raizlabs.android.dbflow.annotation.Column; -import com.raizlabs.android.dbflow.annotation.ModelContainer; -import com.raizlabs.android.dbflow.annotation.PrimaryKey; -import com.raizlabs.android.dbflow.annotation.Table; - -/** - * Created by mayankjindal on 11/07/17. - */ -@Table(database = MifosDatabase.class) -@ModelContainer -public class CenterDate extends MifosBaseModel implements Parcelable { - - @PrimaryKey - @SerializedName("centerId") - long centerId; - - @PrimaryKey - @SerializedName("chargeId") - long chargeId; - - @Column - @SerializedName("day") - int day; - - @Column - @SerializedName("month") - int month; - - @Column - @SerializedName("year") - int year; - - public CenterDate(long centerId, long chargeId, int day, int month, int year) { - this.centerId = centerId; - this.chargeId = chargeId; - this.day = day; - this.month = month; - this.year = year; - } - - public int getDay() { - return day; - } - - public void setDay(int day) { - this.day = day; - } - - public long getCenterId() { - return centerId; - } - - public void setCenterId(long centerId) { - this.centerId = centerId; - } - - public int getMonth() { - return month; - } - - public void setMonth(int month) { - this.month = month; - } - - public int getYear() { - return year; - } - - public void setYear(int year) { - this.year = year; - } - - - @Override - public int describeContents() { - return 0; - } - - @Override - public void writeToParcel(Parcel dest, int flags) { - dest.writeLong(this.centerId); - dest.writeInt(this.day); - dest.writeInt(this.month); - dest.writeInt(this.year); - } - - public CenterDate() { - } - - protected CenterDate(Parcel in) { - this.centerId = in.readLong(); - this.day = in.readInt(); - this.month = in.readInt(); - this.year = in.readInt(); - } - - public static final Parcelable.Creator CREATOR = new Parcelable - .Creator() { - @Override - public CenterDate createFromParcel(Parcel source) { - return new CenterDate(source); - } - - @Override - public CenterDate[] newArray(int size) { - return new CenterDate[size]; - } - }; -} diff --git a/mifosng-android/src/main/java/com/mifos/utils/Constants.java b/mifosng-android/src/main/java/com/mifos/utils/Constants.java index 02f1796c987..6a043398066 100755 --- a/mifosng-android/src/main/java/com/mifos/utils/Constants.java +++ b/mifosng-android/src/main/java/com/mifos/utils/Constants.java @@ -85,8 +85,6 @@ public class Constants { public static final String GROUP_ACCOUNT = "isGroupAccount"; - public static final String CENTER = "center"; - public static final String ENTITY_TYPE = "entityType"; public static final String ENTITY_ID = "entityId"; diff --git a/mifosng-android/src/main/res/layout/dialog_fragment_sync_centers.xml b/mifosng-android/src/main/res/layout/dialog_fragment_sync_centers.xml deleted file mode 100644 index 041a9778a39..00000000000 --- a/mifosng-android/src/main/res/layout/dialog_fragment_sync_centers.xml +++ /dev/null @@ -1,252 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -