Android Open Source - SMSAlive Application Services Impl






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;
/*from  w  w  w  . j av  a 2s .  c o m*/
import android.content.Context;
import android.database.Cursor;
import android.net.Uri;

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

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

/**
 * Created by ironhulk on 2014/12/01.
 */
public class ApplicationServicesImpl implements ApplicationServices {

    private AccountTransactionCrudService acs;
    private Context context;

    public ApplicationServicesImpl(Context context){
        acs = new AccountTransactionCrudServiceImpl(context);
       this.context = context;
    }

    @Override
    public void insertNewBankMessage(String message) {
        String bankName  = editBankName(message);
        Uri uri = Uri.parse("content://sms/inbox");
        Cursor curSms = context.getContentResolver().query(uri, null, null ,null,null);
        String body[] = new String[curSms.getCount()];
        if(curSms.moveToFirst()){
            for(int i = 0;i < curSms.getCount();i++){
                body[i] = curSms.getString(curSms.getColumnIndexOrThrow("body")).toString();
                curSms.moveToNext();
            }
        }
        curSms.close();

        insertIntoDB(body);
    }

    @Override
    public void initialiseBroadCastReceiver() {

    }

    @Override
    public List<AccountTransaction> viewAllAccountTransactions() {
        List<AccountTransaction> accountTransactionList = acs.findAllEntities();
        if(accountTransactionList!=null&&accountTransactionList.size()>0)
            return accountTransactionList;

        return null;
    }

    private String editBankName(String bank){
        return bank.substring(0,1).toUpperCase()+bank.substring(1).toLowerCase();
    }

    private void insertIntoDB(String body[]){
        WithDrawalHandler wdh = new WithDrawalHandler();
        PurchaseHandler ph = new PurchaseHandler();
        DepositHandler dh = new DepositHandler();

        wdh.setSuccessor(ph);
        ph.setSuccessor(dh);
        for(int i = 0;i < body.length;i++) {
            if(body[i].substring(0,4).contains("Absa"))
                wdh.handleAccountType(body[i].substring(4),context);
        }
    }

}




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