Android Open Source - bgBanking Sample Cursor






From Project

Back to project page bgBanking.

License

The source code is released under:

Apache License

If you think the Android project bgBanking 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 eu.masconsult.bgbanking.utils;
//from  www  . j a  va 2  s  .c  o  m
import static android.provider.BaseColumns._ID;
import static eu.masconsult.bgbanking.provider.BankingContract.BankAccount.COLUMN_NAME_AVAILABLE_BALANCE;
import static eu.masconsult.bgbanking.provider.BankingContract.BankAccount.COLUMN_NAME_BALANCE;
import static eu.masconsult.bgbanking.provider.BankingContract.BankAccount.COLUMN_NAME_CURRENCY;
import static eu.masconsult.bgbanking.provider.BankingContract.BankAccount.COLUMN_NAME_IBAN;
import static eu.masconsult.bgbanking.provider.BankingContract.BankAccount.COLUMN_NAME_LAST_TRANSACTION_DATE;
import static eu.masconsult.bgbanking.provider.BankingContract.BankAccount.COLUMN_NAME_NAME;
import android.content.Context;
import android.database.CursorWrapper;
import eu.masconsult.bgbanking.R;

public class SampleCursor extends CursorWrapper {

    static String[] currencyCodes = {
            "BGN", "EUR", "USD"
    };

    private int idx = 0;

    private Context context;

    public SampleCursor(Context context) {
        super(null);
        this.context = context;
    }

    @Override
    public int getCount() {
        return currencyCodes.length;
    }

    @Override
    public boolean moveToPosition(int position) {
        if (position < 0 || position >= currencyCodes.length) {
            return false;
        }
        idx = position;
        return true;
    }

    @Override
    public int getColumnIndex(String columnName) {
        int idx = 0;
        if (_ID.equals(columnName)) {
            return idx;
        }
        idx++;
        if (COLUMN_NAME_IBAN.equals(columnName)) {
            return idx;
        }
        idx++;
        if (COLUMN_NAME_NAME.equals(columnName)) {
            return idx;
        }
        idx++;
        if (COLUMN_NAME_CURRENCY.equals(columnName)) {
            return idx;
        }
        idx++;
        if (COLUMN_NAME_BALANCE.equals(columnName)) {
            return idx;
        }
        idx++;
        if (COLUMN_NAME_AVAILABLE_BALANCE.equals(columnName)) {
            return idx;
        }
        idx++;
        if (COLUMN_NAME_LAST_TRANSACTION_DATE.equals(columnName)) {
            return idx;
        }
        idx++;
        return -1;
    }

    @Override
    public boolean isNull(int columnIndex) {
        return columnIndex == 6;
    }

    @Override
    public String getString(int columnIndex) {
        switch (columnIndex) {
        // COLUMN_NAME_IBAN,
            case 1:
                return "BG01ABCD12345678901234";
                // COLUMN_NAME_NAME,
            case 2:
                return context.getString(R.string.sample_account_name);
                // COLUMN_NAME_CURRENCY,
            case 3:
                return currencyCodes[idx];
                // COLUMN_NAME_BALANCE
        }
        return "";
    }

    @Override
    public float getFloat(int columnIndex) {
        switch (columnIndex) {
        // COLUMN_NAME_BALANCE,
            case 4:
                return 1234567.89f;
                // COLUMN_NAME_AVAILABLE_BALANCE,
            case 5:
                return 1234567.89f;
        }
        return -1;
    }

    @Override
    public long getLong(int columnIndex) {
        switch (columnIndex) {
        // _ID,
            case 0:
                return idx;
                // COLUMN_NAME_IBAN,
        }
        return -1;
    }

    @Override
    public boolean isClosed() {
        return false;
    }

    @Override
    public boolean requery() {
        return true;
    }

    @Override
    public int getColumnIndexOrThrow(String columnName) throws IllegalArgumentException {
        int index = getColumnIndex(columnName);
        if (index == -1) {
            throw new IllegalArgumentException("Can't find " + columnName);
        }
        return index;
    }
}




Java Source Code List

eu.masconsult.bgbanking.BankAdapter.java
eu.masconsult.bgbanking.BankingApplication.java
eu.masconsult.bgbanking.Constants.java
eu.masconsult.bgbanking.accounts.AccountAuthenticator.java
eu.masconsult.bgbanking.accounts.AuthenticationService.java
eu.masconsult.bgbanking.accounts.LoginActivity.java
eu.masconsult.bgbanking.activity.HomeActivity.java
eu.masconsult.bgbanking.activity.fragment.AccountsListFragment.java
eu.masconsult.bgbanking.activity.fragment.ChooseAccountTypeFragment.java
eu.masconsult.bgbanking.banks.BankClient.java
eu.masconsult.bgbanking.banks.Bank.java
eu.masconsult.bgbanking.banks.CaptchaException.java
eu.masconsult.bgbanking.banks.RawBankAccount.java
eu.masconsult.bgbanking.banks.dskbank.AuthenticationService.java
eu.masconsult.bgbanking.banks.dskbank.DskClient.java
eu.masconsult.bgbanking.banks.dskbank.SyncService.java
eu.masconsult.bgbanking.banks.fibank.ebanking.AuthenticationService.java
eu.masconsult.bgbanking.banks.fibank.ebanking.EFIBankClient.java
eu.masconsult.bgbanking.banks.fibank.ebanking.SyncService.java
eu.masconsult.bgbanking.banks.fibank.my.AuthenticationService.java
eu.masconsult.bgbanking.banks.fibank.my.MyFIBankClient.java
eu.masconsult.bgbanking.banks.fibank.my.SyncService.java
eu.masconsult.bgbanking.banks.procreditbank.AuthenticationService.java
eu.masconsult.bgbanking.banks.procreditbank.ProcreditClient.java
eu.masconsult.bgbanking.banks.procreditbank.SyncService.java
eu.masconsult.bgbanking.banks.sgexpress.AuthenticationService.java
eu.masconsult.bgbanking.banks.sgexpress.SGExpressClient.java
eu.masconsult.bgbanking.banks.sgexpress.SyncService.java
eu.masconsult.bgbanking.platform.BankAccountManager.java
eu.masconsult.bgbanking.platform.BankAccountOperations.java
eu.masconsult.bgbanking.platform.BatchOperation.java
eu.masconsult.bgbanking.provider.BankingContract.java
eu.masconsult.bgbanking.provider.BankingProvider.java
eu.masconsult.bgbanking.sync.SyncAdapter.java
eu.masconsult.bgbanking.sync.SyncService.java
eu.masconsult.bgbanking.ui.LightProgressDialog.java
eu.masconsult.bgbanking.utils.Convert.java
eu.masconsult.bgbanking.utils.CookieQuotesFixerResponseInterceptor.java
eu.masconsult.bgbanking.utils.CookieRequestInterceptor.java
eu.masconsult.bgbanking.utils.DumpHeadersRequestInterceptor.java
eu.masconsult.bgbanking.utils.DumpHeadersResponseInterceptor.java
eu.masconsult.bgbanking.utils.SampleCursor.java