本文整理汇总了Java中com.nextgis.maplib.datasource.ngw.Connection类的典型用法代码示例。如果您正苦于以下问题:Java Connection类的具体用法?Java Connection怎么用?Java Connection使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Connection类属于com.nextgis.maplib.datasource.ngw包,在下文中一共展示了Connection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setCurrentResourceId
import com.nextgis.maplib.datasource.ngw.Connection; //导入依赖的package包/类
public void setCurrentResourceId(int id)
{
mCurrentResource = mConnections.getResourceById(id);
if (null != mCurrentResource) {
if (mCurrentResource instanceof Connection) {
Connection connection = (Connection) mCurrentResource;
if (mConnectionListener != null) {
mConnectionListener.onConnectionSelected(connection);
} else if (connection.isConnected()) {
notifyDataSetChanged();
} else {
NGWResourceAsyncTask task = new NGWResourceAsyncTask(mContext, connection);
task.execute();
}
}
if (null != mPathView) {
mPathView.onUpdate(mCurrentResource);
}
}
}
示例2: getItem
import com.nextgis.maplib.datasource.ngw.Connection; //导入依赖的package包/类
@Override
public Object getItem(int i)
{
if (null == mCurrentResource || mLoading) {
return null;
}
if (mCurrentResource.getType() == Connection.NGWResourceTypeConnections) {
if (i > mCurrentResource.getChildrenCount()) {
return null;
}
return mCurrentResource.getChild(i);
} else if (mCurrentResource.getType() == Connection.NGWResourceTypeConnection) {
int offset = mShowAccounts ? 1 : 0;
if (i == 0 && mShowAccounts) {
return null;
}
return mCurrentResource.getChild(i - offset);
} else if (mCurrentResource.getType() == Connection.NGWResourceTypeResourceGroup) {
if (i == 0) {
return null;
}
return mCurrentResource.getChild(i - 1);
}
return null;
}
示例3: getView
import com.nextgis.maplib.datasource.ngw.Connection; //导入依赖的package包/类
@Override
public View getView(
int i,
View view,
ViewGroup viewGroup)
{
//show loading view
if (mLoading) {
if (isAccountsDisabled())
return getLoadingView(view);
else if (i > 0)
return getLoadingView(view);
}
switch (mCurrentResource.getType()) {
case Connection.NGWResourceTypeConnections:
final Connection connection = (Connection) getItem(i);
return getConnectionView(connection, view);
case Connection.NGWResourceTypeConnection:
case Connection.NGWResourceTypeResourceGroup:
Resource resource = (Resource) getItem(i);
return getResourceView(resource, view);
default:
return null;
}
}
示例4: doInBackground
import com.nextgis.maplib.datasource.ngw.Connection; //导入依赖的package包/类
@Override
protected String doInBackground(Void... voids)
{
if (mINGWResource instanceof Connection) {
Connection connection = (Connection) mINGWResource;
if (connection.connect(NGW_ACCOUNT_GUEST.equals(connection.getLogin()))) {
connection.loadChildren();
} else {
return mContext.getString(R.string.error_connect_failed);
}
} else if (mINGWResource instanceof ResourceGroup) {
ResourceGroup resourceGroup = (ResourceGroup) mINGWResource;
resourceGroup.loadChildren();
}
return "";
}
示例5: sendToNGW
import com.nextgis.maplib.datasource.ngw.Connection; //导入依赖的package包/类
public void sendToNGW(final NGActivity activity) {
final SelectNGWResourceDialog selectAccountDialog = new SelectNGWResourceDialog();
selectAccountDialog.setConnectionListener(new NGWResourcesListAdapter.OnConnectionListener() {
@Override
public void onConnectionSelected(final Connection connection) {
Intent intent = new Intent(activity, SelectNGWResourceActivity.class);
Connections connections = new Connections(activity.getString(R.string.ngw_accounts));
connections.add(connection);
intent.putExtra(SelectNGWResourceActivity.KEY_TASK, SelectNGWResourceActivity.TYPE_SELECT);
intent.putExtra(SelectNGWResourceActivity.KEY_CONNECTIONS, connections);
intent.putExtra(SelectNGWResourceActivity.KEY_RESOURCE_ID, connections.getChild(0).getId());
intent.putExtra(SelectNGWResourceActivity.KEY_PUSH_ID, VectorLayerUI.this.getId());
activity.startActivity(intent);
selectAccountDialog.dismiss();
}
@Override
public void onAddConnection() {
selectAccountDialog.onAddAccount(mContext);
}
})
.setTitle(mContext.getString(R.string.ngw_accounts))
.setTheme(activity.getThemeId())
.show(activity.getSupportFragmentManager(), "send_layer_to_ngw");
}
示例6: toNGW
import com.nextgis.maplib.datasource.ngw.Connection; //导入依赖的package包/类
public void toNGW(Long id, String account, int syncType, Pair<Integer, Integer> ver) {
if (id != null && id != NOT_FOUND) {
mLayerType = Constants.LAYERTYPE_NGW_VECTOR;
try {
JSONObject rootConfig = toJSON();
if (ver != null) {
rootConfig.put(NGWVectorLayer.JSON_NGW_VERSION_MAJOR_KEY, ver.first);
rootConfig.put(NGWVectorLayer.JSON_NGW_VERSION_MINOR_KEY, ver.second);
}
rootConfig.put(NGWVectorLayer.JSON_ACCOUNT_KEY, account);
rootConfig.put(Constants.JSON_ID_KEY, id);
rootConfig.put(NGWVectorLayer.JSON_SYNC_TYPE_KEY, syncType);
rootConfig.put(NGWVectorLayer.JSON_NGWLAYER_TYPE_KEY, Connection.NGWResourceTypeVectorLayer);
FileUtil.writeToFile(getFileName(), rootConfig.toString());
MapBase map = MapDrawable.getInstance();
map.load();
new Sync().execute();
} catch (IOException | JSONException ignored) { }
}
}
示例7: createNewGroup
import com.nextgis.maplib.datasource.ngw.Connection; //导入依赖的package包/类
public static HttpResponse createNewGroup(
Context context,
Connection connection,
long parentId,
String name,
String keyName)
{
JSONObject payload = new JSONObject();
try {
JSONObject resource = new JSONObject();
resource.put(NGWKEY_CLS, NGWKEY_RESOURCE_GROUP);
JSONObject id = new JSONObject();
id.put(JSON_ID_KEY, parentId);
resource.put(NGWKEY_PARENT, id);
resource.put(NGWKEY_DISPLAY_NAME, name);
if (keyName != null) {
resource.put(NGWKEY_KEYNAME, keyName);
}
payload.put(JSON_RESOURCE_KEY, resource);
} catch (JSONException e) {
e.printStackTrace();
return new HttpResponse(500);
}
return createNewResource(context, connection, payload);
}
示例8: getConnection
import com.nextgis.maplib.datasource.ngw.Connection; //导入依赖的package包/类
public void getConnection() {
AccountManager accountManager = AccountManager.get(this);
IGISApplication app = (IGISApplication) getApplicationContext();
if (LoggerApplication.checkAccountStatus(getApplicationContext(), accountManager, GET_ACCOUNTS))
return;
try {
for (Account account : accountManager.getAccountsByType(Constants.NGW_ACCOUNT_TYPE)) {
if (account.name.equals(mLoggerName)) {
String url = app.getAccountUrl(account);
String password = app.getAccountPassword(account);
String login = app.getAccountLogin(account);
mConnection = new Connection(account.name, login, password, url.toLowerCase());
}
}
} catch (SecurityException e) {
e.printStackTrace();
}
}
示例9: refresh
import com.nextgis.maplib.datasource.ngw.Connection; //导入依赖的package包/类
public void refresh() {
if (mCurrentResource instanceof Connection)
((Connection) mCurrentResource).getRootResource().setLoadChildren(false);
else if (mCurrentResource instanceof ResourceGroup)
((ResourceGroup) mCurrentResource).setLoadChildren(false);
NGWResourceAsyncTask task = new NGWResourceAsyncTask(mContext, mCurrentResource);
task.execute();
}
示例10: fillConnections
import com.nextgis.maplib.datasource.ngw.Connection; //导入依赖的package包/类
public static Connections fillConnections(Context context, AccountManager accountManager)
{
Connections connections = new Connections(context.getString(R.string.ngw_accounts));
IGISApplication app = (IGISApplication) context.getApplicationContext();
for (Account account : accountManager.getAccountsByType(app.getAccountsType())) {
String url = app.getAccountUrl(account);
String password = app.getAccountPassword(account);
String login = app.getAccountLogin(account);
connections.add(new Connection(account.name, login, password, url.toLowerCase()));
}
return connections;
}
示例11: onActivityResult
import com.nextgis.maplib.datasource.ngw.Connection; //导入依赖的package包/类
@Override
public void onActivityResult(
int requestCode,
int resultCode,
Intent data)
{
if (requestCode == ADD_ACCOUNT_CODE) {
if (resultCode != Activity.RESULT_CANCELED) {
//search new account and add it
Connections connections = mListAdapter.getConnections();
IGISApplication app = (IGISApplication) mContext.getApplicationContext();
for (Account account : mAccountManager.getAccountsByType(app.getAccountsType())) {
boolean find = false;
for (int i = 0; i < connections.getChildrenCount(); i++) {
Connection connection = (Connection) connections.getChild(i);
if (null != connection && connection.getName().equals(account.name)) {
find = true;
break;
}
}
if (!find) {
String url = app.getAccountUrl(account);
String password = app.getAccountPassword(account);
String login = app.getAccountLogin(account);
connections.add(new Connection(account.name, login, password, url.toLowerCase()));
mListAdapter.notifyDataSetChanged();
break;
}
}
}
} else {
super.onActivityResult(requestCode, resultCode, data);
}
}
示例12: handleTrackSync
import com.nextgis.maplib.datasource.ngw.Connection; //导入依赖的package包/类
private void handleTrackSync() {
if (mTracksSyncEnabled) {
List<ILayer> tracks = new ArrayList<>();
LayerGroup.getLayersByType(mMap, LAYERTYPE_NGW_TRACKS, tracks);
if (tracks.size() > 0) {
tracks.get(0).delete();
mMap.save();
Toast.makeText(mContext, R.string.sync_disabled, Toast.LENGTH_SHORT).show();
}
} else {
final SelectNGWResourceDialog selectAccountDialog = new SelectNGWResourceDialog();
selectAccountDialog.setConnectionListener(new NGWResourcesListAdapter.OnConnectionListener() {
@Override
public void onConnectionSelected(final Connection connection) {
new NGWTrackLayerCreateTask(mActivity, connection).execute();
selectAccountDialog.dismiss();
}
@Override
public void onAddConnection() {
selectAccountDialog.onAddAccount(mContext);
}
})
.setTitle(mContext.getString(R.string.ngw_accounts))
.setTheme(mActivity.getThemeId())
.show(mActivity.getSupportFragmentManager(), "choose_ngw_account");
}
}
示例13: createNewNGWLayer
import com.nextgis.maplib.datasource.ngw.Connection; //导入依赖的package包/类
public void createNewNGWLayer(
final Context context,
final LayerGroup layerGroup)
{
if (context instanceof NGActivity) {
AccountManager accountManager = AccountManager.get(context);
Connections connections = SelectNGWResourceDialog.fillConnections(context, accountManager);
if (connections.getChildrenCount() == 1) {
startNGWResourceActivity(context, (Connection) connections.getChild(0), layerGroup);
} else {
NGActivity fragmentActivity = (NGActivity) context;
final SelectNGWResourceDialog newFragment = new SelectNGWResourceDialog();
newFragment.setLayerGroup(layerGroup)
.setTypeMask(
Connection.NGWResourceTypePostgisLayer |
Connection.NGWResourceTypeVectorLayer |
Connection.NGWResourceTypeRasterLayer |
Connection.NGWResourceTypeWMSClient |
Connection.NGWResourceTypeWebMap)
.setConnectionListener(new NGWResourcesListAdapter.OnConnectionListener() {
@Override
public void onConnectionSelected(Connection connection) {
startNGWResourceActivity(context, connection, layerGroup);
newFragment.dismiss();
}
@Override
public void onAddConnection() {
newFragment.onAddAccount(context);
}
})
.setTitle(context.getString(R.string.choose_layers))
.setTheme(fragmentActivity.getThemeId())
.show(fragmentActivity.getSupportFragmentManager(), "create_ngw_layer");
}
}
}
示例14: startNGWResourceActivity
import com.nextgis.maplib.datasource.ngw.Connection; //导入依赖的package包/类
private void startNGWResourceActivity(Context context, Connection connection, LayerGroup layerGroup) {
Intent intent = new Intent(context, SelectNGWResourceActivity.class);
Connections connections = new Connections(context.getString(R.string.ngw_accounts));
connections.add(connection);
intent.putExtra(SelectNGWResourceActivity.KEY_TASK, SelectNGWResourceActivity.TYPE_ADD);
intent.putExtra(SelectNGWResourceActivity.KEY_CONNECTIONS, connections);
intent.putExtra(SelectNGWResourceActivity.KEY_RESOURCE_ID, connections.getChild(0).getId());
intent.putExtra(SelectNGWResourceActivity.KEY_GROUP_ID, layerGroup.getId());
context.startActivity(intent);
}
示例15: getRemoteResourceId
import com.nextgis.maplib.datasource.ngw.Connection; //导入依赖的package包/类
public long getRemoteResourceId() {
long id = NOT_FOUND;
INGWResource resource = mListAdapter.getCurrentResource();
if (resource instanceof ResourceGroup)
id = ((ResourceGroup) resource).getRemoteId();
else if (resource instanceof Connection)
id = ((Connection) resource).getRootResource().getRemoteId();
return id;
}