Java Code Examples for net.bither.bitherj.BitherjSettings#TransactionFeeMode

The following examples show how to use net.bither.bitherj.BitherjSettings#TransactionFeeMode . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OptionHotFragment.java    From bither-android with Apache License 2.0 6 votes vote down vote up
@Override
public String getOptionName(int index) {
    BitherjSettings.TransactionFeeMode transactionFeeMode = getModeByIndex(index);
    switch (transactionFeeMode) {
        case TwentyX:
            return getString(R.string.setting_name_transaction_fee_20x);
        case TenX:
            return getString(R.string.setting_name_transaction_fee_10x);
        case Higher:
            return getString(R.string.setting_name_transaction_fee_higher);
        case High:
            return getString(R.string.setting_name_transaction_fee_high);
        case Low:
            return getString(R.string.setting_name_transaction_fee_low);
        case Lower:
            return getString(R.string.setting_name_transaction_fee_lower);
        default:
            return getString(R.string.setting_name_transaction_fee_normal);
    }
}
 
Example 2
Source File: OptionHotFragment.java    From bither-android with Apache License 2.0 6 votes vote down vote up
@Override
public int getCurrentOptionIndex() {
    BitherjSettings.TransactionFeeMode mode = AppSharedPreference.getInstance()
            .getTransactionFeeMode();
    switch (mode) {
        case High:
            return 3;
        case Higher:
            return 2;
        case TenX:
            return 1;
        case TwentyX:
            return 0;
        case Low:
            return 5;
        case Lower:
            return 6;
        default:
            return 4;
    }
}
 
Example 3
Source File: OptionHotFragment.java    From bither-android with Apache License 2.0 6 votes vote down vote up
private BitherjSettings.TransactionFeeMode getModeByIndex(int index) {
    if (index >= 0 && index < BitherjSettings.TransactionFeeMode.values().length) {
        switch (index) {
            case 5:
                return BitherjSettings.TransactionFeeMode.Low;
            case 4:
                return BitherjSettings.TransactionFeeMode.Normal;
            case 3:
                return BitherjSettings.TransactionFeeMode.High;
            case 2:
                return BitherjSettings.TransactionFeeMode.Higher;
            case 1:
                return BitherjSettings.TransactionFeeMode.TenX;
            case 0:
                return BitherjSettings.TransactionFeeMode.TwentyX;
            case 6:
                return BitherjSettings.TransactionFeeMode.Lower;
        }
    }
    return BitherjSettings.TransactionFeeMode.Normal;
}
 
Example 4
Source File: UserPreference.java    From bither-desktop-java with Apache License 2.0 5 votes vote down vote up
public BitherjSettings.TransactionFeeMode getTransactionFeeMode() {
    int ordinal = getInt(TRANSACTION_FEE_MODE, 0);
    if (ordinal < BitherjSettings.TransactionFeeMode.values().length && ordinal >= 0) {
        return BitherjSettings.TransactionFeeMode.values()[ordinal];
    }
    return BitherjSettings.TransactionFeeMode.Normal;
}
 
Example 5
Source File: UserPreference.java    From bither-desktop-java with Apache License 2.0 5 votes vote down vote up
public void setTransactionFeeMode(BitherjSettings.TransactionFeeMode mode) {
    if (mode == null) {
        mode = BitherjSettings.TransactionFeeMode.Normal;
    }
    setValue(TRANSACTION_FEE_MODE, Integer.toString(mode.ordinal()));

}
 
Example 6
Source File: AppSharedPreference.java    From bither-android with Apache License 2.0 5 votes vote down vote up
public BitherjSettings.TransactionFeeMode getTransactionFeeMode() {
    int ordinal = this.mPreferences.getInt(TRANSACTION_FEE_MODE, -1);
    if (ordinal < BitherjSettings.TransactionFeeMode.values().length && ordinal >= 0) {
        return BitherjSettings.TransactionFeeMode.values()[ordinal];
    }
    return BitherjSettings.TransactionFeeMode.Normal;
}
 
Example 7
Source File: AppSharedPreference.java    From bither-android with Apache License 2.0 5 votes vote down vote up
public void setTransactionFeeMode(BitherjSettings.TransactionFeeMode mode) {
    if (mode == null) {
        mode = BitherjSettings.TransactionFeeMode.Normal;
    }
    this.mPreferences.edit().putInt(TRANSACTION_FEE_MODE, mode.ordinal()).commit();

}
 
Example 8
Source File: UserPreference.java    From bither-desktop-java with Apache License 2.0 5 votes vote down vote up
public BitherjSettings.TransactionFeeMode getTransactionFeeMode() {
    int ordinal = getInt(TRANSACTION_FEE_MODE, 0);
    if (ordinal < BitherjSettings.TransactionFeeMode.values().length && ordinal >= 0) {
        return BitherjSettings.TransactionFeeMode.values()[ordinal];
    }
    return BitherjSettings.TransactionFeeMode.Normal;
}
 
Example 9
Source File: UserPreference.java    From bither-desktop-java with Apache License 2.0 5 votes vote down vote up
public void setTransactionFeeMode(BitherjSettings.TransactionFeeMode mode) {
    if (mode == null) {
        mode = BitherjSettings.TransactionFeeMode.Normal;
    }
    setValue(TRANSACTION_FEE_MODE, Integer.toString(mode.ordinal()));

}
 
Example 10
Source File: DesktopImplAbstractApp.java    From bither-desktop-java with Apache License 2.0 4 votes vote down vote up
@Override
public ISetting initSetting() {
    return new ISetting() {
        @Override
        public BitherjSettings.AppMode getAppMode() {
            return UserPreference.getInstance().getAppMode();
        }

        @Override
        public boolean getBitherjDoneSyncFromSpv() {
            return UserPreference.getInstance().getBitherjDoneSyncFromSpv();
        }

        @Override
        public void setBitherjDoneSyncFromSpv(boolean isDone) {
            UserPreference.getInstance().setBitherjDoneSyncFromSpv(isDone);
        }

        @Override
        public boolean getDownloadSpvFinish() {
            return UserPreference.getInstance().getDownloadSpvFinish();
        }

        @Override
        public void setDownloadSpvFinish(boolean finish) {
            UserPreference.getInstance().setDownloadSpvFinish(finish);

        }

        @Override
        public BitherjSettings.TransactionFeeMode getTransactionFeeMode() {
            return UserPreference.getInstance().getTransactionFeeMode();
        }

        @Override
        public File getPrivateDir(String dirName) {
            File file = new File(new ApplicationDataDirectoryLocator().getApplicationDataDirectory() + File.separator + dirName);
            if (!file.exists()) {
                file.mkdirs();
            }
            return file;
        }

        @Override
        public boolean isApplicationRunInForeground() {

            return true;
        }

        @Override
        public CookieStore getCookieStore() {
            return PersistentCookieStore.getInstance();
        }

        @Override
        public QRCodeUtil.QRQuality getQRQuality() {
            return UserPreference.getInstance().getQRQuality();
        }
    };
}
 
Example 11
Source File: OptionHotFragment.java    From bither-android with Apache License 2.0 4 votes vote down vote up
private  String getFeeStr(BitherjSettings.TransactionFeeMode transactionFeeMode) {
    float dividend = 100000;
    String unit = "mBTC/kb";
    float fee = (float)transactionFeeMode.getMinFeeSatoshi()/dividend;
    return  String.valueOf(fee)+unit;
}
 
Example 12
Source File: AndroidImplAbstractApp.java    From bither-android with Apache License 2.0 4 votes vote down vote up
@Override
public ISetting initSetting() {
    return new ISetting() {
        @Override
        public BitherjSettings.AppMode getAppMode() {
            return AppSharedPreference.getInstance().getAppMode();
        }

        @Override
        public boolean getBitherjDoneSyncFromSpv() {
            return AppSharedPreference.getInstance().getBitherjDoneSyncFromSpv();
        }

        @Override
        public void setBitherjDoneSyncFromSpv(boolean isDone) {
            AppSharedPreference.getInstance().setBitherjDoneSyncFromSpv(isDone);
        }

        @Override
        public BitherjSettings.TransactionFeeMode getTransactionFeeMode() {
            return AppSharedPreference.getInstance().getTransactionFeeMode();
        }

        @Override
        public BitherjSettings.ApiConfig getApiConfig() {
            return AppSharedPreference.getInstance().getApiConfig();
        }

        @Override
        public File getPrivateDir(String dirName) {
            File file = BitherApplication.mContext.getDir(dirName, Context.MODE_PRIVATE);
            if (!file.exists()) {
                file.mkdirs();
            }
            return file;
        }

        @Override
        public boolean isApplicationRunInForeground() {
            if (BitherApplication.mContext == null) {
                return false;
            }
            ActivityManager am = (ActivityManager) BitherApplication.mContext
                    .getSystemService(Context.ACTIVITY_SERVICE);
            List<ActivityManager.RunningTaskInfo> tasks = am.getRunningTasks(1);
            if (tasks != null && !tasks.isEmpty()) {
                ComponentName topActivity = tasks.get(0).topActivity;
                if (!topActivity.getPackageName().equals(BitherApplication.mContext.getPackageName())) {
                    return false;
                }
                if (topActivity.getClassName().equals(AdActivity.class.getName())) {
                    return false;
                }
            }
            return true;
        }

        @Override
        public QRCodeUtil.QRQuality getQRQuality() {
            return AppSharedPreference.getInstance().getQRQuality();
        }

        @Override
        public boolean getDownloadSpvFinish() {
            return AppSharedPreference.getInstance().getDownloadSpvFinish();
        }

        @Override
        public void setDownloadSpvFinish(boolean finish) {
            AppSharedPreference.getInstance().setDownloadSpvFinish(finish);
        }

        @Override
        public CookieStore getCookieStore() {
            return PersistentCookieStore.getInstance();
        }


        
    };
}
 
Example 13
Source File: TestImplAbstractApp.java    From bitherj with Apache License 2.0 4 votes vote down vote up
@Override
public ISetting initSetting() {
    return new ISetting() {
        @Override
        public BitherjSettings.AppMode getAppMode() {
            return BitherjSettings.AppMode.HOT;
        }

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

        @Override
        public void setBitherjDoneSyncFromSpv(boolean isDone) {
            // AppSharedPreference.getInstance().setBitherjDoneSyncFromSpv(isDone);
        }

        @Override
        public BitherjSettings.TransactionFeeMode getTransactionFeeMode() {
            return BitherjSettings.TransactionFeeMode.Low;
        }

        @Override
        public File getPrivateDir(String dirName) {
            File file = new File("test/wallet");
            if (!file.exists()) {
                file.mkdirs();
            }
            return file;
        }

        @Override
        public boolean isApplicationRunInForeground() {

            return true;
        }

        @Override
        public QRCodeUtil.QRQuality getQRQuality() {
            return QRCodeUtil.QRQuality.Normal;
        }

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

        @Override
        public void setDownloadSpvFinish(boolean finish) {
            // AppSharedPreference.getInstance().setDownloadSpvFinish(finish);
        }

        @Override
        public CookieStore getCookieStore() {
            return cookieStore;
        }


    };
}
 
Example 14
Source File: DesktopImplAbstractApp.java    From bither-desktop-java with Apache License 2.0 4 votes vote down vote up
@Override
public ISetting initSetting() {
    return new ISetting() {
        @Override
        public BitherjSettings.AppMode getAppMode() {
            return UserPreference.getInstance().getAppMode();
        }

        @Override
        public boolean getBitherjDoneSyncFromSpv() {
            return UserPreference.getInstance().getBitherjDoneSyncFromSpv();
        }

        @Override
        public void setBitherjDoneSyncFromSpv(boolean isDone) {
            UserPreference.getInstance().setBitherjDoneSyncFromSpv(isDone);
        }

        @Override
        public boolean getDownloadSpvFinish() {
            return UserPreference.getInstance().getDownloadSpvFinish();
        }

        @Override
        public void setDownloadSpvFinish(boolean finish) {
            UserPreference.getInstance().setDownloadSpvFinish(finish);

        }

        @Override
        public BitherjSettings.TransactionFeeMode getTransactionFeeMode() {
            return UserPreference.getInstance().getTransactionFeeMode();
        }

        @Override
        public File getPrivateDir(String dirName) {
            File file = new File(new ApplicationDataDirectoryLocator().getApplicationDataDirectory() + File.separator + dirName);
            if (!file.exists()) {
                file.mkdirs();
            }
            return file;
        }

        @Override
        public boolean isApplicationRunInForeground() {

            return true;
        }

        @Override
        public CookieStore getCookieStore() {
            return PersistentCookieStore.getInstance();
        }

        @Override
        public QRCodeUtil.QRQuality getQRQuality() {
            return UserPreference.getInstance().getQRQuality();
        }
    };
}