Java源码示例:com.nextgis.maplib.api.INGWLayer

示例1
protected void deleteAccountLayers(
        final IGISApplication application,
        Account account)
{
    List<INGWLayer> layers = getLayersForAccount(application, account);

    for (INGWLayer layer : layers) {
        ((Layer) layer).delete();
    }

    application.getMap().save();

    if (null != mOnDeleteAccountListener) {
        mOnDeleteAccountListener.onDeleteAccount(account);
    }
}
 
示例2
protected void sync(
        LayerGroup layerGroup,
        String authority,
        SyncResult syncResult)
{
    for (int i = 0; i < layerGroup.getLayerCount(); i++) {
        if (isCanceled()) {
            return;
        }
        ILayer layer = layerGroup.getLayer(i);
        if (layer instanceof LayerGroup) {
            sync((LayerGroup) layer, authority, syncResult);
        } else if (layer instanceof INGWLayer) {
            INGWLayer ngwLayer = (INGWLayer) layer;
            String accountName = ngwLayer.getAccountName();
            if (!mVersions.containsKey(accountName))
                mVersions.put(accountName, NGWUtil.getNgwVersion(getContext(), accountName));

            Pair<Integer, Integer> ver = mVersions.get(accountName);
            ngwLayer.sync(authority, ver, syncResult);
        } else if (layer instanceof TrackLayer) {
            ((TrackLayer) layer).sync();
        }
    }
}
 
示例3
public static void getLayersByAccount(
        LayerGroup layerGroup,
        String account,
        List<INGWLayer> layerList)
{
    for (int i = 0; i < layerGroup.getLayerCount(); i++) {
        ILayer layer = layerGroup.getLayer(i);

        if (layer instanceof INGWLayer) {
            INGWLayer ngwLayer = (INGWLayer) layer;
            if (ngwLayer.getAccountName().equals(account)) {
                layerList.add(ngwLayer);
            }
        }

        if (layer instanceof LayerGroup) {
            getLayersByAccount((LayerGroup) layer, account, layerList);
        }
    }
}
 
示例4
public static void updateAccountLayersCacheData(
        final IGISApplication application,
        Account account)
{
    List<INGWLayer> layers = getLayersForAccount(application, account);

    for (INGWLayer layer : layers) {
        layer.setAccountCacheData();
    }
}
 
示例5
protected static List<INGWLayer> getLayersForAccount(
        final IGISApplication application,
        Account account)
{
    List<INGWLayer> out = new ArrayList<>();
    if (application == null || account == null) {
        return out;
    }

    MapContentProviderHelper.getLayersByAccount(application.getMap(), account.name, out);
    return out;
}
 
示例6
protected void setupSyncOptions()
{
    mAccounts.clear();
    final AccountManager accountManager = AccountManager.get(getActivity().getApplicationContext());
    Log.d(TAG, "LayersFragment: AccountManager.get(" + getActivity().getApplicationContext() + ")");
    final IGISApplication application = (IGISApplication) getActivity().getApplication();
    List<INGWLayer> layers = new ArrayList<>();

    for (Account account : accountManager.getAccountsByType(application.getAccountsType())) {
        layers.clear();
        MapContentProviderHelper.getLayersByAccount(application.getMap(), account.name, layers);

        if (layers.size() > 0)
            mAccounts.add(account);
    }

    if (mAccounts.isEmpty()) {
        if (null != mSyncButton) {
            mSyncButton.setEnabled(false);
            mSyncButton.setVisibility(View.GONE);
        }
        if (null != mInfoText) {
            mInfoText.setVisibility(View.INVISIBLE);
        }
    } else {
        if (null != mSyncButton) {
            mSyncButton.setVisibility(View.VISIBLE);
            mSyncButton.setEnabled(true);
            mSyncButton.setOnClickListener(this);
        }
        if (null != mInfoText) {
            mInfoText.setVisibility(View.VISIBLE);
        }
    }
}