Back to project page SMSAlive.
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.
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); } } }