Android Open Source - SMSAlive With Drawal Handler






From Project

Back to project page SMSAlive.

License

The source code is released under:

Apache License

If you think the Android project SMSAlive listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.futuretech.app.smsalive.Application.Services.impl;
/*ww  w  .j  a v a  2  s.c  o m*/
import android.content.Context;

import com.futuretech.app.smsalive.Domain.models.AccountTransaction;
import com.futuretech.app.smsalive.Application.Services.TranscactionTypeHandler;
import com.futuretech.app.smsalive.Domain.crud.AccountTransactionCrudService;
import com.futuretech.app.smsalive.Domain.crud.impl.AccountTransactionCrudServiceImpl;

import org.joda.time.LocalDate;
import org.joda.time.format.DateTimeFormat;

/**
 * Created by ironhulk on 2014/12/02.
 */
public class WithDrawalHandler extends TranscactionTypeHandler {

    private AccountTransactionCrudService atcs;
    private AccountTransaction accountTransaction;

    @Override
    public void handleAccountType(String message, Context c) {
        atcs = new AccountTransactionCrudServiceImpl(c);
        accountTransaction = new AccountTransaction();

        if(message.indexOf("WthDr")!=-1){
            if(message.substring(0, 4).contains("Absa")){
                String witDrawPassOn = message.substring(6);
                int isWithDrw = witDrawPassOn.indexOf("Wthdr");
                if(isWithDrw!=-1){
                    accountTransaction.setAccountNumber(witDrawPassOn.substring(4, 8));
                    accountTransaction.setAccountType(witDrawPassOn.substring(0, 4));
                    LocalDate d =  LocalDate.parse(witDrawPassOn.substring(isWithDrw+7,isWithDrw+7+9),
                            DateTimeFormat.forPattern("dd/MM/yyyy"));
                    accountTransaction.setTransactionDate(d);
                    accountTransaction.setTransactionPlace(witDrawPassOn.substring(isWithDrw+7+9,witDrawPassOn.indexOf("-")));
                    String transactionAmount = witDrawPassOn.substring(witDrawPassOn.indexOf("ATM WITHDRAWAL,")+18,witDrawPassOn.indexOf("Available")-2);
                    accountTransaction.setTransactionAmount(Double.valueOf(transactionAmount));
                    accountTransaction.setTransactionType("Withdrawal");
                    String balance = witDrawPassOn.substring(witDrawPassOn.indexOf("Available R")+11,witDrawPassOn.indexOf("Help")-2);
                    accountTransaction.setAccountBalance(Double.valueOf(balance.replace(",","")));
                }
            }
        }else{
            successor.handleAccountType(message,c);
        }

    }
}




Java Source Code List

com.futuretech.app.smsalive.ApplicationTest.java
com.futuretech.app.smsalive.Test.java
com.futuretech.app.smsalive.Application.Services.ApplicationServices.java
com.futuretech.app.smsalive.Application.Services.TranscactionTypeHandler.java
com.futuretech.app.smsalive.Application.Services.impl.ApplicationServicesImpl.java
com.futuretech.app.smsalive.Application.Services.impl.DepositHandler.java
com.futuretech.app.smsalive.Application.Services.impl.PurchaseHandler.java
com.futuretech.app.smsalive.Application.Services.impl.WithDrawalHandler.java
com.futuretech.app.smsalive.Domain.crud.AccountTransactionCrudService.java
com.futuretech.app.smsalive.Domain.crud.impl.AccountTransactionCrudServiceImpl.java
com.futuretech.app.smsalive.Domain.models.AccountTransaction.java
com.futuretech.app.smsalive.Presentation.activities.InitializingData.java
com.futuretech.app.smsalive.Presentation.fragments.InitialDataGathering.java
com.futuretech.app.smsalive.Presentation.fragments.WelcomeFragment.java
com.futuretech.app.smsalive.Presentation.services.DataGatheringService.java
com.futuretech.app.smsalive.repository.DBHelper.java
com.futuretech.app.smsalive.repository.RepositoryUtil.java
com.futuretech.app.smsalive.utils.Constants.java
com.futuretech.app.smsalive.utils.Factory.java
com.futuretech.app.smsalive.utils.TransactionTypes.java