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

The following examples show how to use net.bither.bitherj.BitherjSettings#AppMode . 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: UserPreference.java    From bither-desktop-java with Apache License 2.0 5 votes vote down vote up
public BitherjSettings.AppMode getAppMode() {
    int index = getInt(APP_MODE, -1);
    if (index < 0 || index >= BitherjSettings.AppMode.values().length) {
        return null;
    }
    return BitherjSettings.AppMode.values()[index];
}
 
Example 2
Source File: UserPreference.java    From bither-desktop-java with Apache License 2.0 5 votes vote down vote up
public void setAppMode(BitherjSettings.AppMode mode) {
    int index = -1;
    if (mode != null) {
        index = mode.ordinal();
    }
    setValue(APP_MODE, Integer.toString(index));


}
 
Example 3
Source File: ChooseModeActivity.java    From bither-android with Apache License 2.0 5 votes vote down vote up
private void initActivity() {
    setContentView(R.layout.activity_choose_mode);
    BitherjSettings.AppMode appMode = AppSharedPreference.getInstance().getAppMode();
    if (appMode == null) {
        BitherApplication.getBitherApplication().startBlockchainService();
        dowloadSpvBlock();
        initView();
    } else {
        if (appMode == BitherjSettings.AppMode.COLD) {
            vColdWalletInitCheck = (ColdWalletInitCheckView) findViewById(R.id
                    .v_cold_wallet_init_check);
            if (vColdWalletInitCheck.check()) {
                gotoActivity(appMode);
                finish();
                return;
            } else {
                initView();
                configureColdWait();
            }
        } else if (appMode == BitherjSettings.AppMode.HOT) {
            BitherApplication.getBitherApplication().startBlockchainService();
            if (!AppSharedPreference.getInstance().getDownloadSpvFinish()) {
                initView();
                dowloadSpvBlock();
                configureWarmWait();
            } else {
                gotoActivity(appMode);
                finish();
                return;
            }
        }
    }
}
 
Example 4
Source File: BlockchainService.java    From bither-android with Apache License 2.0 5 votes vote down vote up
@SuppressLint("Wakelock")
private void check() throws BlockStoreException {
    BitherjSettings.AppMode mode = AppSharedPreference.getInstance().getAppMode();
    if (mode == BitherjSettings.AppMode.COLD) {
        return;
    }
    final boolean hasEverything = hasConnectivity && hasStorage;
    NetworkType networkType = NetworkUtil.isConnectedType();
    boolean networkIsAvailadble = (!AppSharedPreference.getInstance().getSyncBlockOnlyWifi())
            || (networkType == NetworkType.Wifi);

    if (networkIsAvailadble) {
        if (hasEverything) {
            log.debug("acquiring wakelock");
            callWekelock();
            if (!PeerManager.instance().isRunning()) {
                startPeer();
            }
        } else {

            PeerManager.instance().stop();
        }
    } else {

        PeerManager.instance().stop();
    }


}
 
Example 5
Source File: AppSharedPreference.java    From bither-android with Apache License 2.0 5 votes vote down vote up
public BitherjSettings.AppMode getAppMode() {
    int index = mPreferences.getInt(APP_MODE, -1);
    if (index < 0 || index >= BitherjSettings.AppMode.values().length) {
        return null;
    }
    return BitherjSettings.AppMode.values()[index];
}
 
Example 6
Source File: AppSharedPreference.java    From bither-android with Apache License 2.0 5 votes vote down vote up
public void setAppMode(BitherjSettings.AppMode mode) {
    int index = -1;
    if (mode != null) {
        index = mode.ordinal();
    }
    mPreferences.edit().putInt(APP_MODE, index).commit();
}
 
Example 7
Source File: UserPreference.java    From bither-desktop-java with Apache License 2.0 5 votes vote down vote up
public BitherjSettings.AppMode getAppMode() {
    int index = getInt(APP_MODE, -1);
    if (index < 0 || index >= BitherjSettings.AppMode.values().length) {
        return null;
    }
    return BitherjSettings.AppMode.values()[index];
}
 
Example 8
Source File: UserPreference.java    From bither-desktop-java with Apache License 2.0 5 votes vote down vote up
public void setAppMode(BitherjSettings.AppMode mode) {
    int index = -1;
    if (mode != null) {
        index = mode.ordinal();
    }
    setValue(APP_MODE, Integer.toString(index));


}
 
Example 9
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 10
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 11
Source File: ChooseModeActivity.java    From bither-android with Apache License 2.0 4 votes vote down vote up
private void modeSelected(final BitherjSettings.AppMode mode) {
    vCold.setClickable(false);
    vWarm.setClickable(false);
    AppSharedPreference.getInstance().setAppMode(mode);

}
 
Example 12
Source File: ChooseModeActivity.java    From bither-android with Apache License 2.0 4 votes vote down vote up
public ModeGrowAnimatorListener(BitherjSettings.AppMode mode) {
    this.mode = mode;
}
 
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();
        }
    };
}