net.bither.bitherj.AbstractApp Java Examples
The following examples show how to use
net.bither.bitherj.AbstractApp.
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: TransactionsUtil.java From bitherj with Apache License 2.0 | 6 votes |
public static void getMyTxFromBither() throws Exception { if (AbstractApp.bitherjSetting.getAppMode() != BitherjSettings.AppMode.HOT) { return; } // TODO: web type int flag = AbstractApp.bitherjSetting.getApiConfig().value(); getTxForAddress(flag); if (AddressManager.getInstance().getHDAccountHot() != null) { getTxForHDAccount(AddressManager.getInstance().getHDAccountHot().getHdSeedId(), flag); } if(AddressManager.getInstance().hasHDAccountMonitored()){ getTxForHDAccountMoitored(AddressManager.getInstance().getHDAccountMonitored().getHdSeedId(), flag); } if (AddressManager.getInstance().hasDesktopHDMKeychain()) { DesktopHDMKeychain desktopHDMKeychain = AddressManager.getInstance().getDesktopHDMKeychains().get(0); getTxForDesktopHDM(desktopHDMKeychain, flag); } }
Example #2
Source File: UpgradeAddressUtil.java From bitherj with Apache License 2.0 | 6 votes |
public static boolean upgradeAddress() throws Exception { boolean success = true; List<Address> addressList = new ArrayList<Address>(); addressList.addAll(initPrivateKeyListByDesc()); addressList.addAll(initWatchOnlyListByDesc()); addressList.addAll(initTrashListByDesc()); Collections.reverse(addressList); for (Address address : addressList) { address.setSyncComplete(false); AddressManager.getInstance().addAddress(address); } if (AbstractApp.bitherjSetting.getAppMode() == BitherjSettings.AppMode.HOT) { if (addressList.size() > 0) { AbstractDb.txProvider.clearAllTx(); } } return success; }
Example #3
Source File: CookieFactory.java From bitherj with Apache License 2.0 | 6 votes |
public synchronized static boolean initCookie() { boolean success = true; isRunning = true; CookieStore cookieStore = AbstractApp.bitherjSetting.getCookieStore(); if (cookieStore.getCookies() == null || cookieStore.getCookies().size() == 0) { try { GetCookieApi getCookieApi = new GetCookieApi(); getCookieApi.handleHttpPost(); // log.debug("getCookieApi"); } catch (Exception e) { success = false; e.printStackTrace(); } } isRunning = false; return success; }
Example #4
Source File: ColdAddressFragment.java From bither-android with Apache License 2.0 | 6 votes |
public void refresh() { if (AbstractApp.addressIsReady) { List<Address> ps = AddressManager.getInstance().getPrivKeyAddresses(); if (ps != null) { privates.clear(); privates.addAll(ps); } mAdapter.notifyDataSetChanged(); if (privates.size() == 0 && !AddressManager.getInstance().hasBitpieHDAccountCold() && !AddressManager.getInstance().hasHDMKeychain() && !AddressManager.getInstance().hasHDAccountCold() && !EnterpriseHDMSeed.hasSeed()) { ivNoAddress.setVisibility(View.VISIBLE); lvPrivate.setVisibility(View.GONE); } else { ivNoAddress.setVisibility(View.GONE); lvPrivate.setVisibility(View.VISIBLE); } if (addressesToShowAdded != null) { lvPrivate.postDelayed(showAddressesAddedRunnable, 600); } } }
Example #5
Source File: OptionHotFragment.java From bither-android with Apache License 2.0 | 6 votes |
private void configureSwitchToCold() { final Runnable check = new Runnable() { @Override public void run() { if (AddressManager.getInstance().getAllAddresses().size() > 0 || AddressManager .getInstance().getTrashAddresses().size() > 0 || AddressManager .getInstance().getHdmKeychain() != null || AddressManager.getInstance() .hasHDAccountHot() || AddressManager.getInstance().hasHDAccountMonitored()) { llSwitchToCold.setVisibility(View.GONE); } else { llSwitchToCold.setVisibility(View.VISIBLE); } } }; if (AbstractApp.addressIsReady) { check.run(); } else { new Thread() { @Override public void run() { AddressManager.getInstance().getAllAddresses(); ThreadUtil.runOnMainThread(check); } }.start(); } }
Example #6
Source File: PeerManager.java From bitherj with Apache License 2.0 | 6 votes |
public void stop() { if (running.getAndSet(false)) { log.info("peer manager stop"); if (connected.getAndSet(false)) { AbstractApp.notificationService.removeBroadcastPeerState(); bloomFilter = null; sendConnectedChangeBroadcast(); executor.getQueue().clear(); executor.submit(new Runnable() { @Override public void run() { for (Peer peer : connectedPeers) { peer.disconnect(); } } }); } } else { log.info("peer manager call stop, but it does not running"); } }
Example #7
Source File: BlockchainService.java From bither-android with Apache License 2.0 | 6 votes |
@Override public void onReceive(Context context, Intent intent) { LogUtil.d("block", "sendBroadcastSyncSPVFinished onReceive"); new Thread(new Runnable() { @Override public void run() { try { if (!AddressManager.getInstance().addressIsSyncComplete()) { TransactionsUtil.getMyTxFromBither(); } startPeerManager(); AbstractApp.notificationService.removeBroadcastSyncSPVFinished(); if (spvFinishedReceiver != null && spvFinishedReceivered) { unregisterReceiver(spvFinishedReceiver); spvFinishedReceivered = false; } } catch (Exception e) { e.printStackTrace(); } } }).start(); }
Example #8
Source File: DialogEditPassword.java From bither-android with Apache License 2.0 | 6 votes |
@Override public void onSuccess() { ThreadUtil.runOnMainThread(new Runnable() { @Override public void run() { dismiss(); DropdownMessage.showDropdownMessage(activity, R.string.edit_password_success); new Thread(new Runnable() { @Override public void run() { if (AbstractApp.bitherjSetting.getAppMode() == BitherjSettings.AppMode.COLD) { BackupUtil.backupColdKey(false); } else { BackupUtil.backupHotKey(); } } }).start(); } }); }
Example #9
Source File: BitherApplication.java From bither-android with Apache License 2.0 | 6 votes |
@Override public void onCreate() { new LinuxSecureRandom(); super.onCreate(); mContext = getApplicationContext(); ueHandler = new UEHandler(); Thread.setDefaultUncaughtExceptionHandler(ueHandler); activityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE); mAddressDbHelper = new AddressDatabaseHelper(mContext); mTxDbHelper = new TxDatabaseHelper(mContext); AndroidDbImpl androidDb = new AndroidDbImpl(); androidDb.construct(); AndroidImplAbstractApp appAndroid = new AndroidImplAbstractApp(); appAndroid.construct(); AbstractApp.notificationService.removeAddressLoadCompleteState(); StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectAll() .permitDiskReads().permitDiskWrites().penaltyLog().build()); Threading.throwOnLockCycles(); initApp(); mBitherApplication = this; upgrade(); }
Example #10
Source File: AddressManager.java From bitherj with Apache License 2.0 | 5 votes |
public static boolean isHDMKeychainLimit() { if (AbstractApp.bitherjSetting.getAppMode() == BitherjSettings.AppMode.COLD) { return AddressManager.getInstance().getHdmKeychain() != null; } else { if (AddressManager.getInstance().getHdmKeychain() == null) { return false; } return AddressManager.getInstance().getHdmKeychain().getAllCompletedAddresses().size () > 0; } }
Example #11
Source File: AddressManager.java From bitherj with Apache License 2.0 | 5 votes |
private AddressManager() { synchronized (lock) { initAddress(); initHDMKeychain(); initEnterpriseHDMKeychain(); initHDAccounts(); initDesktopHDMKeychain(); initAliasAndVanityLen(); AbstractApp.addressIsReady = true; AbstractApp.notificationService.sendBroadcastAddressLoadCompleteState(); } }
Example #12
Source File: AddressManager.java From bitherj with Apache License 2.0 | 5 votes |
private void initHDAccounts() { if (AbstractApp.bitherjSetting.getAppMode() == BitherjSettings.AppMode.HOT) { List<Integer> seeds = AbstractDb.hdAccountProvider.getHDAccountSeeds(); for (int seedId : seeds) { if (hdAccountHot == null && AbstractDb.hdAccountProvider.hasMnemonicSeed(seedId)) { hdAccountHot = new HDAccount(seedId); } else if (hdAccountMonitored == null && !AbstractDb.hdAccountProvider.hasMnemonicSeed(seedId)) { hdAccountMonitored = new HDAccount(seedId); } } } }
Example #13
Source File: AddressManager.java From bitherj with Apache License 2.0 | 5 votes |
public boolean hasHDMKeychain() { synchronized (lock) { if (AbstractApp.bitherjSetting.getAppMode() == BitherjSettings.AppMode.COLD) { return hdmKeychain != null; } else { return hdmKeychain != null && hdmKeychain.getAddresses().size() > 0; } } }
Example #14
Source File: AddressManager.java From bitherj with Apache License 2.0 | 5 votes |
public boolean hasEnterpriseHDMKeychain() { synchronized (lock) { if (AbstractApp.bitherjSetting.getAppMode() == BitherjSettings.AppMode.COLD) { return false; } else { return enterpriseHDMKeychain != null; } } }
Example #15
Source File: AddressManager.java From bitherj with Apache License 2.0 | 5 votes |
public boolean hasHDAccountCold() { synchronized (lock) { if (AbstractApp.bitherjSetting.getAppMode() == BitherjSettings.AppMode.COLD) { List<Integer> seeds = AbstractDb.hdAccountProvider.getHDAccountSeeds(); for (int seedId : seeds) { if (AbstractDb.hdAccountProvider.hasMnemonicSeed(seedId)) { return true; } } } return false; } }
Example #16
Source File: AddressManager.java From bitherj with Apache License 2.0 | 5 votes |
public HDAccountCold getHDAccountCold() { synchronized (lock) { if (AbstractApp.bitherjSetting.getAppMode() == BitherjSettings.AppMode.COLD) { List<Integer> seeds = AbstractDb.hdAccountProvider.getHDAccountSeeds(); for (int seedId : seeds) { if (AbstractDb.hdAccountProvider.hasMnemonicSeed(seedId)) { return new HDAccountCold(seedId); } } } return null; } }
Example #17
Source File: AddressManager.java From bitherj with Apache License 2.0 | 5 votes |
public static boolean isPrivateLimit() { int maxPrivateKey = AbstractApp.bitherjSetting.getAppMode() == BitherjSettings.AppMode .COLD ? AbstractApp.bitherjSetting.watchOnlyAddressCountLimit() : AbstractApp.bitherjSetting.privateKeyOfHotCountLimit(); return AddressManager.getInstance().getPrivKeyAddresses() != null && AddressManager.getInstance().getPrivKeyAddresses().size() >= maxPrivateKey; }
Example #18
Source File: AddressManager.java From bitherj with Apache License 2.0 | 5 votes |
public static int canAddPrivateKeyCount() { int max; if (AbstractApp.bitherjSetting.getAppMode() == BitherjSettings.AppMode.COLD) { max = AbstractApp.bitherjSetting.watchOnlyAddressCountLimit() - AddressManager .getInstance() .getAllAddresses().size(); } else { max = AbstractApp.bitherjSetting.privateKeyOfHotCountLimit() - AddressManager .getInstance() .getPrivKeyAddresses().size(); } return max; }
Example #19
Source File: NotificationDesktopImpl.java From bither-desktop-java with Apache License 2.0 | 5 votes |
@Override public void sendBroadcastSyncSPVFinished(boolean isFinished) { if (isFinished) { AbstractApp.bitherjSetting.setBitherjDoneSyncFromSpv(isFinished); PeerUtil.startPeer(); } }
Example #20
Source File: AddressManager.java From bitherj with Apache License 2.0 | 5 votes |
public static boolean isHDMAddressLimit() { if (AbstractApp.bitherjSetting.getAppMode() == BitherjSettings.AppMode.COLD) { return true; } if (AddressManager.getInstance().getHdmKeychain() == null) { return false; } return AddressManager.getInstance().getHdmKeychain().getAllCompletedAddresses().size() >= AbstractApp.bitherjSetting.hdmAddressPerSeedCount(); }
Example #21
Source File: DesktopHDMKeychain.java From bitherj with Apache License 2.0 | 5 votes |
public void onNewTx(Tx tx, List<DesktopHDMAddress> relatedAddresses, Tx.TxNotificationType txNotificationType) { if (relatedAddresses == null || relatedAddresses.size() == 0) { return; } int maxInternal = -1, maxExternal = -1; for (DesktopHDMAddress a : relatedAddresses) { if (a.getPathType() == AbstractHD.PathType.EXTERNAL_ROOT_PATH) { if (a.getIndex() > maxExternal) { maxExternal = a.getIndex(); } } else { if (a.getIndex() > maxInternal) { maxInternal = a.getIndex(); } } } log.info("HD on new tx issued ex {}, issued in {}", maxExternal, maxInternal); if (maxExternal >= 0 && maxExternal > issuedExternalIndex()) { updateIssuedExternalIndex(maxExternal); } if (maxInternal >= 0 && maxInternal > issuedInternalIndex()) { updateIssuedInternalIndex(maxInternal); } supplyEnoughKeys(true); long deltaBalance = getDeltaBalance(); AbstractApp.notificationService.notificatTx(DesktopHDMKeychainPlaceHolder, tx, txNotificationType, deltaBalance); }
Example #22
Source File: PeerManager.java From bitherj with Apache License 2.0 | 5 votes |
private void sendSyncProgress() { long lastBlockHeight = getLastBlockHeight(); if (synchronizing && syncStartHeight > 0 && downloadingPeer != null && lastBlockHeight >= syncStartHeight && lastBlockHeight <= downloadingPeer.getVersionLastBlockHeight()) { double progress = (double) (lastBlockHeight - syncStartHeight) / (double) (downloadingPeer.getVersionLastBlockHeight() - syncStartHeight); AbstractApp.notificationService.sendBroadcastProgressState(progress); } else { AbstractApp.notificationService.sendBroadcastProgressState(-1); } }
Example #23
Source File: PeerManager.java From bitherj with Apache License 2.0 | 5 votes |
private int getMaxPeerConnect() { if (AbstractApp.bitherjSetting.isApplicationRunInForeground()) { return BitherjSettings.MaxPeerConnections; } else { return BitherjSettings.MaxPeerBackgroundConnections; } }
Example #24
Source File: HDAccount.java From bitherj with Apache License 2.0 | 5 votes |
public void onNewTx(Tx tx, Tx.TxNotificationType txNotificationType) { supplyEnoughKeys(true); long deltaBalance = getDeltaBalance(); AbstractApp.notificationService.notificatTx(hasPrivKey() ? HDAccountPlaceHolder : HDAccountMonitoredPlaceHolder, tx, txNotificationType, deltaBalance); }
Example #25
Source File: NotificationDesktopImpl.java From bither-desktop-java with Apache License 2.0 | 5 votes |
@Override public void sendBroadcastSyncSPVFinished(boolean isFinished) { if (isFinished) { AbstractApp.bitherjSetting.setBitherjDoneSyncFromSpv(isFinished); PeerUtil.startPeer(); } }
Example #26
Source File: DownloadFile.java From bitherj with Apache License 2.0 | 5 votes |
private String getCookie() { String cookieStr = ""; for (Cookie cookie : AbstractApp.bitherjSetting.getCookieStore().getCookies()) { cookieStr = cookie.getName() + "=" + cookie.getValue() + ";"; } //LogUtil.d("cookie",cookieStr); if (!Utils.isEmpty(cookieStr)) { cookieStr = cookieStr.substring(0, cookieStr.length() - 1); } //LogUtil.d("cookie","substring:"+cookieStr); return cookieStr; }
Example #27
Source File: ColdAddressFragment.java From bither-android with Apache License 2.0 | 5 votes |
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_cold_address, container, false); view.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { FileUtil.getBackupFileListOfCold(); FileUtil.getBackupFileOfCold(); } }); lvPrivate = (ListView) view.findViewById(R.id.lv_address); ivNoAddress = view.findViewById(R.id.iv_no_address); privates = new ArrayList<Address>(); mAdapter = new AddressOfColdFragmentListAdapter(getActivity(), privates, this); lvPrivate.setAdapter(mAdapter); if (AbstractApp.addressIsReady) { List<Address> ps = AddressManager.getInstance().getPrivKeyAddresses(); if (ps != null) { privates.addAll(ps); mAdapter.notifyDataSetChanged(); } } return view; }
Example #28
Source File: BaseHttpsResponse.java From bitherj with Apache License 2.0 | 5 votes |
protected synchronized void trustCerts() { if (!isTrust) { ConnectHttps.trustCerts(AbstractApp.trustCert); isTrust = true; } }
Example #29
Source File: QRCodeUtil.java From bitherj with Apache License 2.0 | 5 votes |
public static int getNumOfQrCodeString(int length) { int quality = AbstractApp.bitherjSetting.getQRQuality().getQuality(); if (length < quality) { return 1; } else if (length <= (quality - 4) * 10) { return length / (quality - 4) + 1; } else if (length <= (quality - 5) * 100) { return length / (quality - 5) + 1; } else if (length <= (quality - 6) * 1000) { return length / (quality - 6) + 1; } else { return 1000; } }
Example #30
Source File: HotActivity.java From bither-android with Apache License 2.0 | 5 votes |
private void initView() { pbSync = (SyncProgressView) findViewById(R.id.pb_sync); flAddAddress = (FrameLayout) findViewById(R.id.fl_add_address); tbtnMain = (TabButton) findViewById(R.id.tbtn_main); tbtnMessage = (TabButton) findViewById(R.id.tbtn_message); tbtnMe = (TabButton) findViewById(R.id.tbtn_me); llAlert = findViewById(R.id.ll_alert); tvAlert = findViewById(R.id.tv_alert); pbAlert = findViewById(R.id.pb_alert); configureTopBarSize(); configureTabMainIcons(); tbtnMain.setBigInteger(null, null, null, null, null, null); if (AbstractApp.addressIsReady) { refreshTotalBalance(); } tbtnMessage.setIconResource(R.drawable.tab_market, R.drawable.tab_market_checked); tbtnMe.setIconResource(R.drawable.tab_option, R.drawable.tab_option_checked); mPager = (ViewPager) findViewById(R.id.pager); mPager.postDelayed(new Runnable() { @Override public void run() { mAdapter = new HotFragmentPagerAdapter(getSupportFragmentManager()); mPager.setAdapter(mAdapter); mPager.setCurrentItem(1); mPager.setOffscreenPageLimit(2); mPager.setOnPageChangeListener(new PageChangeListener(new TabButton[]{tbtnMessage, tbtnMain, tbtnMe}, mPager)); } }, 100); }