Java Code Examples for net.bither.bitherj.AbstractApp#addressIsReady()

The following examples show how to use net.bither.bitherj.AbstractApp#addressIsReady() . 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: ColdAddressFragment.java    From bither-android with Apache License 2.0 6 votes vote down vote up
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 2
Source File: OptionHotFragment.java    From bither-android with Apache License 2.0 6 votes vote down vote up
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 3
Source File: ColdAddressFragment.java    From bither-android with Apache License 2.0 5 votes vote down vote up
@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 4
Source File: EnterpriseHDMKeychainActivity.java    From bither-android with Apache License 2.0 5 votes vote down vote up
private void load() {
    if (AbstractApp.addressIsReady) {
        if (keychain != null) {
            addresses.clear();
            addresses.addAll(keychain.getAddresses());
            adapter.notifyDataSetChanged();
        }
    }
}
 
Example 5
Source File: HotActivity.java    From bither-android with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example 6
Source File: AddressManager.java    From bitherj with Apache License 2.0 5 votes vote down vote up
private AddressManager() {
    synchronized (lock) {
        initAddress();
        initHDMKeychain();
        initEnterpriseHDMKeychain();
        initHDAccounts();
        initDesktopHDMKeychain();
        initAliasAndVanityLen();
        AbstractApp.addressIsReady = true;
        AbstractApp.notificationService.sendBroadcastAddressLoadCompleteState();
    }
}
 
Example 7
Source File: HotAddressFragment.java    From bither-android with Apache License 2.0 4 votes vote down vote up
public void refresh() {
    if (AbstractApp.addressIsReady) {
        List<Address> ps = AddressManager.getInstance().getPrivKeyAddresses();
        List<Address> ws = AddressManager.getInstance().getWatchOnlyAddresses();
        List<HDMAddress> hs = AddressManager.getInstance().hasHDMKeychain() ? AddressManager
                .getInstance().getHdmKeychain().getAddresses() : null;
        watchOnlys.clear();
        privates.clear();
        hdms.clear();
        if (ws != null) {
            watchOnlys.addAll(ws);
        }
        if (ps != null) {
            privates.addAll(ps);
        }
        if (hs != null) {
            hdms.addAll(hs);
        }
        mAdapter.notifyDataSetChanged();
        if (watchOnlys.size() + privates.size() + hdms.size() + (AddressManager.getInstance()
                .hasHDAccountHot() ? 1 : 0) + (AddressManager.getInstance()
                .hasHDAccountMonitored() ? 1 : 0) +
                (AddressManager.getInstance().hasEnterpriseHDMKeychain() ? 1 : 0) == 0) {
            ivNoAddress.setVisibility(View.VISIBLE);
            lv.setVisibility(View.GONE);
        } else {
            ivNoAddress.setVisibility(View.GONE);
            lv.setVisibility(View.VISIBLE);
        }
        for (int i = 0;
             i < mAdapter.getGroupCount();
             i++) {
            lv.expandGroup(i);
        }
        if (notifyAddress != null) {
            scrollToAddress(notifyAddress);
        }
        lv.removeCallbacks(showAddressesAddedRunnable);
        if (addressesToShowAdded != null) {
            lv.postDelayed(showAddressesAddedRunnable, 600);
        }
    }
}