*********************************************************************************************

Adapter Methods
978321
@Override
    public VersionViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext())
                .inflate(R.layout.layout_change_item, parent, false);
        return new VersionViewHolder(view);
    }
1068075
function loadAdapters() {
        var adapters = {};
        var adaptersDir = path.join(this.injector.rootDir, this.injector.servicesDir + '/adapters');

        if (!fs.existsSync(adaptersDir)) {
            return this.injector.adapters || {};
        }

        var me = this;
        var adapterNames = fs.readdirSync(adaptersDir);

        _.each(adapterNames, function (adapterName) {
            if (adapterName.substring(adapterName.length - 3) !== '.js') {  // only dirs, not js files
                var adapterImpl = me.injector.adapterMap[adapterName];
                adapterName = utils.getPascalCase(adapterImpl + '.' + adapterName + '.adapter');
                adapters[adapterName] = me.injector.loadModule(adapterName);
            }
        });

        // add the adapters that come from plugins to the list
        _.extend(adapters, this.injector.adapters);

        // return the adapters
        return adapters;
    }
448641
@SuppressWarnings("unchecked")
    public void setAdapter(@Nullable AdaptiveTableAdapter adapter) {
        if (mAdapter != null) {
            // remove observers from old adapter
            mAdapter.unregisterDataSetObserver(this);
        }

        if (adapter != null) {
            // wrap adapter
            mAdapter = new LinkedAdaptiveTableAdapterImpl<>(adapter, mSettings.isSolidRowHeader());
            // register notify callbacks
            mAdapter.registerDataSetObserver(this);
            adapter.registerDataSetObserver(new DataSetObserverProxy(mAdapter));
        } else {
            // remove adapter
            mAdapter = null;
        }
        initItems();
    }
771864
public JsonConverterBuilder registerJsonTypeAdapter(JsonTypeAdapter adapter) {
        Validate.argumentIsNotNull(adapter);
        adapter.getValueTypes().forEach( c -> registerJsonTypeAdapterForType((Class)c, adapter));
        return this;
    }
379726
function initAdapters(container) {

        var calls = [];

        if (container === 'webserver') {
            _.each(adapters, function (adapter) {
                if (adapter.webInit) {
                    calls.push(adapter.webInit);
                }
            });
        }
        else {
            _.each(adapters, function (adapter) {
                if (adapter.init) {
                    calls.push(adapter.init);
                }
            });
        }

        return chainPromises(calls, config)
            .then(function (returnConfig) {
                if (returnConfig) {
                    return returnConfig;
                }
                else {
                    throw new Error('An adapter in the chain is not returning the config.');
                }
            });
    }
398855
public final void setAdapter(@Nullable final ExpandableListAdapter adapter) {
        expandedGroups.clear();

        if (adapter != null) {
            this.adapter = new AdapterWrapper(adapter);
            super.setAdapter(this.adapter);
        } else {
            this.adapter = null;
            super.setAdapter(null);
        }
    }
1153391
public static <A extends ModelAdapter<Model, Item>, Model, Item extends IItem> A set(final A adapter, final List<Item> items, final boolean detectMoves) {
        return set(adapter, items, new DiffCallbackImpl<Item>(), detectMoves);
    }
297057
public static <T> void writeNullable(
      @Nullable T value, @NonNull Parcel dest, int flags, @NonNull TypeAdapter<T> adapter) {
    if (value == null) {
      dest.writeInt(0);
    } else {
      dest.writeInt(1);
      adapter.writeToParcel(value, dest, flags);
    }
  }
1169607
public void setAdapter(final BaseCircularViewAdapter adapter) {
        mAdapter = adapter;
        if (mAdapter != null) {
            mAdapter.registerDataSetObserver(mAdapterDataSetObserver);
        }
        postInvalidate();
    }
1351406
function EngineWrapper(adapter) {
    class AjaxEngine {
        constructor() {
            this.requestHeaders = {};
            this.readyState = 0;
            this.timeout = 0;// 0 stands for no timeout
            this.responseURL = "";
            this.responseHeaders = {};
        }

        _call(name) {
            this[name] && this[name].apply(this, [].splice.call(arguments, 1))
        }

        _changeReadyState(state) {
            this.readyState = state;
            this._call("onreadystatechange")
        }

        open(method, url) {
            this.method = method;
            if (!url) {
                url = location.href;
            } else {
                url = util.trim(url);
                if (url.indexOf("http") !== 0) {
                    // Normalize the request url
                    if (isBrowser) {
                        let t = document.createElement("a");
                        t.href = url;
                        url = t.href;
                    }
                }
            }
            this.responseURL = url;
            this._changeReadyState(1)
        }

        send(arg) {
            arg = arg || null;
            let self = this;
            if (adapter) {
                let request = {
                    method: self.method,
                    url: self.responseURL,
                    headers: self.requestHeaders || {},
                    body: arg
                }
                util.merge(request, self._options || {})
                if (request.method === "GET") {
                    request.body = null;
                }
                self._changeReadyState(3)
                let timer;
                self.timeout = self.timeout || 0;
                if (self.timeout > 0) {
                    timer = setTimeout(() => {
                        if (self.readyState === 3) {
                            this._call("onloadend");
                            self._changeReadyState(0);
                            self._call("ontimeout");

                        }
                    }, self.timeout);
                }
                request.timeout = self.timeout;
                adapter(request, function (response) {

                    function getAndDelete(key) {
                        let t = response[key]
                        delete response[key]
                        return t;
                    }

                    // If the request has already timeout, return
                    if (self.readyState !== 3) return;
                    clearTimeout(timer)

                    // Make sure the type of status is integer
                    self.status = getAndDelete("statusCode") - 0;

                    let responseText = getAndDelete("responseText")
                    let statusMessage = getAndDelete("statusMessage")

                    // Network error, set the status code 0
                    if (!self.status) {
                        self.statusText = responseText;
                        self._call("onerror", {msg: statusMessage});
                    } else {
                        // Parsing the response headers to array in a object,  because
                        // there may be multiple values with the same header name
                        let responseHeaders = getAndDelete("headers")
                        let headers = {};
                        for (let field in responseHeaders) {
                            let value = responseHeaders[field];
                            let key = field.toLowerCase();
                            // Is array
                            if (typeof value === "object") {
                                headers[key] = value;
                            } else {
                                headers[key] = headers[key] || []
                                headers[key].push(value)
                            }
                        }
                        let cookies = headers["set-cookie"];
                        if (isBrowser && cookies) {
                            cookies.forEach((e) => {
                                // Remove the http-Only property of the  cookie
                                // so that JavaScript can operate it.
                                document.cookie = e.replace(/;\s*httpOnly/ig, "")
                            })
                        }
                        self.responseHeaders = headers;
                        // Set the fields of engine from response
                        self.statusText = statusMessage || "";
                        self.response = self.responseText = responseText;
                        self._response = response;
                        self._changeReadyState(4);
                        self._call("onload");
                    }
                    self._call("onloadend");
                });
            } else {
                console.error("Ajax require adapter")
            }
        }

        setRequestHeader(key, value) {
            this.requestHeaders[util.trim(key)] = value;
        }

        getResponseHeader(key) {
            return (this.responseHeaders[key.toLowerCase()] || "").toString() || null
        }

        getAllResponseHeaders() {
            let str = "";
            for (let key in this.responseHeaders) {
                str += key + ":" + this.getResponseHeader(key) + "\r\n";
            }
            return str || null;
        }

        abort(msg) {
            this._changeReadyState(0)
            this._call("onerror", {msg});
            this._call("onloadend");
        }

        static setAdapter(requestAdapter) {
            adapter = requestAdapter
        }
    }

    return AjaxEngine;
}
125828
function getMergeByTypeAdapter(type)
{
  var adapter = adapters[type] || passThru;

  // only if usage of custom adapters is authorized
  // to prevent global context leaking in
  if (this.useCustomAdapters === behaviors.useCustomAdapters
  && typeof this[type] == 'function'
  )
  {
    adapter = this[type];
  }

  return adapter;
}
161472
public static <E extends SqlTypeAdapter<?, ?>> E getAdapter(Class<E> clazz) {
		@SuppressWarnings("unchecked")
		E adapter = (E) cache.get(clazz);

		if (adapter == null) {
			try {
				lock.lock();
				adapter = clazz.newInstance();
				cache.put(clazz, adapter);
			} catch(Throwable e) {
				throw(new KriptonRuntimeException(e));
			} finally {
				lock.unlock();
			}
		}

		return adapter;
	}
773354
public ClientInterfaceHandleManager bindAdapter(final Connection adapter, final ClientInterfaceRepairCallback repairCallback) {
        return bindAdapter(adapter, repairCallback, false);
    }
1032788
public static function init(): void
    {
        if (static::$adapters === null) {
        	static::$randomNumber = rand(100000, 999999);

        	// set the "who"
            static::resetWho();

            static::$adapters = [];
            $configs = Application::getConfig('application')->get('log', []);

            $count = 0;
            foreach ($configs as $index => $config) {
                $enabled = $config['enabled'] && is_array($config['options']['log']) && count($config['options']['log']) > 0;

                // TODO: Register module if needed

                if ($enabled) {
                    if (!isset($config['adapter_class'])) {
                        throw new ConfigException("Logger[{$index}] defined in application config is missing adapter_class key");
                    }

                    // if the config is enabled, then make new instance
                    $adapter = $config['adapter_class'];

                    static::$adapters[$count] = new $adapter($config['options']);

                    // Log class must be instance of AbstractLogAdapter
                    if (!(static::$adapters[$count] instanceof AbstractLogAdapter)) {
                        throw new Exception("Log adapter {$adapter} must extend AbstractLogAdapter");
                    }

                    static::$enabledAdapters[$config['adapter_class']] = true;

                    foreach ($config['options']['log'] as $level) {
                        static::$enabledLevels[$level] = true;
                    }

                    $count++;
                }
            }
        }
    }
344849
private static Adapter tryAdapter( Class adapterClass, Object externalContext )
    {
        try
        {
            Adapter sa = ( Adapter ) adapterClass.newInstance();

            try
            {
                AdapterContext context = new AdapterContext( externalContext );
                
                if ( sa.accept( context ) )
                {
                    _log.info( "Adapter " + adapterClass.getName() + " accepted." );
                    sa.setContext( context );
                    return sa;
                }
                else
                {
                    _log.info( "Adapter " + adapterClass.getName() + " is present but did not accept." );
                }
            }
            catch ( Exception e )
            {
                _log.error( adapterClass.getName() + ".accept() threw an exception.", e );
            }
            catch ( LinkageError e )
            {
                _log.error( adapterClass.getName() + ".accept() caused a linkage error and may be out of date.", e );
            }
        }
        catch ( InstantiationException e )
        {
            _log.error( "Could not create instance of Adapter class " + adapterClass.getName(), e );
        }
        catch ( IllegalAccessException e )
        {
            _log.error( "Could not create instance of Adapter class " + adapterClass.getName(), e );
        }
        catch ( Exception e )
        {
            _log.error( "Error creating instance of Adapter class " + adapterClass.getName(), e );
        }

        return null;
    }
644405
public void setCategoriesAdapter(@NonNull RecyclerView.Adapter<? extends RecyclerView.ViewHolder> inputAdapter) {
        mInputAdapter = inputAdapter;
        mOuterAdapter = new ChangeScrollModeAdapter(inputAdapter);
        boolean hasItems = inputAdapter.getItemCount() > 0;
        if (hasItems) {
            IOperationItem firstItem = mOuterAdapter.getItem(0);
            firstItem.setVisible(false);
        }
        validateScrollMode();
        mOuterAdapter.setIsIndeterminate(mInfinite);
        mOuterAdapter.setListener(this);
        mOuterAdapter.setOrientation(mOrientationState.getOrientation());
        mOuterAdapter.setSelectedGravity(mSelectionGravity);
        mRvCategories.setAdapter(mOuterAdapter);

        mSelectorHolder = (ChangeScrollModeAdapter.ChangeScrollModeHolder) mOuterAdapter
                .createViewHolder(mRvCategories, ChangeScrollModeAdapter.VIEW_TYPE_CHANGE_SCROLL_MODE);
        // set first item to selectionView
        if (hasItems) {
            mSelectorHolder.bindItemWildcardHelper(inputAdapter, 0);
        }
        mSelectorHolder.itemView.setBackgroundColor(mColorCodeSelectionView);

        mFlContainerSelected.addView(mSelectorHolder.itemView);

        mOrientationState.initSelectionContainer(mFlContainerSelected);

        FrameLayout.LayoutParams layoutParams = (LayoutParams) mSelectorHolder.itemView.getLayoutParams();
        layoutParams.gravity = Gravity.CENTER;
    }
277455
public void setAdapter(SpinnerAdapter adapter) {
		if(mAdapter != null)
			mAdapter.unregisterDataSetObserver(mDataSetObserver);

        mRecycler.clear();

		mAdapter = adapter;
		mAdapter.registerDataSetObserver(mDataSetObserver);
		onDataChanged();

        if (mPopup != null)
            mPopup.setAdapter(new DropDownAdapter(adapter));
        else
            mTempAdapter = new DropDownAdapter(adapter);
	}