Java 类android.provider.SyncStateContract 实例源码

项目:android_maplibui    文件:FormBuilderModifyAttributesActivity.java   
private void appendData(IFormControl control, JSONObject element) throws JSONException {
    if (mLayer instanceof NGWVectorLayer)
        element.put(SyncStateContract.Columns.ACCOUNT_NAME, ((NGWVectorLayer) mLayer).getAccountName());

    if (control instanceof Counter && mTable != null && mRow != -1) {
        JSONObject attrs = element.getJSONObject(JSON_ATTRIBUTES_KEY);
        if (!attrs.isNull(Counter.PREFIX_LIST)) {
            String prefix = attrs.getString(Counter.PREFIX_LIST);
            prefix = mTable.get(prefix).get(mRow);
            attrs.put(Counter.PREFIX, prefix);
        }

        if (!attrs.isNull(Counter.SUFFIX_LIST)) {
            String suffix = attrs.getString(Counter.SUFFIX_LIST);
            suffix = mTable.get(suffix).get(mRow);
            attrs.put(Counter.SUFFIX, suffix);
        }
    }
}
项目:android_maplibui    文件:TextEdit.java   
@Override
public void init(JSONObject element,
                 List<Field> fields,
                 Bundle savedState,
                 Cursor featureCursor,
                 SharedPreferences preferences) throws JSONException{
    ControlHelper.setClearAction(this);

    JSONObject attributes = element.getJSONObject(JSON_ATTRIBUTES_KEY);
    mFieldName = attributes.getString(JSON_FIELD_NAME_KEY);
    mIsShowLast = ControlHelper.isSaveLastValue(attributes);
    boolean enabled = ControlHelper.isEnabled(fields, mFieldName);

    String value = null;
    if (ControlHelper.hasKey(savedState, mFieldName))
        value = savedState.getString(ControlHelper.getSavedStateKey(mFieldName));
    else if (null != featureCursor) { // feature exists
        int column = featureCursor.getColumnIndex(mFieldName);
        if (column >= 0)
            value = featureCursor.getString(column);
    } else {    // new feature
        if (!attributes.isNull(JSON_TEXT_KEY))
            value = attributes.getString(JSON_TEXT_KEY);

        if (mIsShowLast)
            value = preferences.getString(mFieldName, value);
    }

    boolean useLogin = attributes.optBoolean(USE_LOGIN);
    String accountName = element.optString(SyncStateContract.Columns.ACCOUNT_NAME);
    if (useLogin && !TextUtils.isEmpty(accountName)) {
        enabled = false;
        Activity activity = ControlHelper.getActivity(getContext());
        if (activity != null) {
            GISApplication app = (GISApplication) activity.getApplication();
            Account account = app.getAccount(accountName);
            value = app.getAccountLogin(account);
        }
    }

    setEnabled(enabled);
    setText(value);

    //let's create control
    int maxLines = attributes.getInt(JSON_MAX_STRING_COUNT_KEY);
    if (maxLines < 2) {
        setSingleLine(true);
    } else {
        setMaxLines(maxLines);
    }

    int fieldType = NOT_FOUND;
    for (Field field : fields) {
        if (field.getName().equals(mFieldName)) {
            fieldType = field.getType();
            break;
        }
    }

    boolean onlyFigures = attributes.getBoolean(JSON_ONLY_FIGURES_KEY);
    if (onlyFigures) {
        //check field type
        switch (fieldType) {
            default:
            case GeoConstants.FTInteger:
                setInputType(InputType.TYPE_CLASS_NUMBER);
                break;

            case GeoConstants.FTReal:
                setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);
                break;
        }
    }
}