How to use complete method in Karma

Best JavaScript code snippet using karma

Run Karma automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

App.jsx

Source: App.jsx Github

copy
1import React, { useState } from "react";
2import ReactDOM from "react-dom";
3import "./styles.css";
4import { InputTodo } from "./components/InputTodo";
5import { InCompleteTodo } from "./components/InCompleteTodo";
6import { CompleteTodo } from "./components/CompleteTodo";
7
8export const App = () => {
9  const [todoText, setTodoText] = useState([""]);
10  const [inCompleteTodos, setInCompleteTodos] = useState([]);
11  const [completeTodos, setCompleteTodos] = useState([]);
12  const onChangeTodoText = (event) => setTodoText(event.target.value);
13  const onClickAdd = () => {
14    if (todoText === "") {
15      return null;
16    } else {
17      const newTodos = [...inCompleteTodos, todoText];
18      setInCompleteTodos(newTodos);
19      setTodoText("");
20    }
21  };
22  const onClickDelete = (index) => {
23    const newTodos = [...inCompleteTodos];
24    newTodos.splice(index, 1);
25    setInCompleteTodos(newTodos);
26  };
27  const onClickComplete = (index) => {
28    const newInCompleteTodos = [...inCompleteTodos];
29    // alert(newInCompleteTodos);
30    newInCompleteTodos.splice(index, 1);
31    // alert(newInCompleteTodos);
32
33    const newCompleteTodos = [...completeTodos, inCompleteTodos[index]];
34    setCompleteTodos(newCompleteTodos);
35    setInCompleteTodos(newInCompleteTodos);
36  };
37  const onClickBack = (index) => {
38    const newCompleteTodos = [...completeTodos];
39    newCompleteTodos.splice(index, 1);
40    const newInComplteTodos = [...inCompleteTodos, completeTodos[index]];
41    setInCompleteTodos(newInComplteTodos);
42    setCompleteTodos(newCompleteTodos);
43  };
44
45  return (
46    <>
47      <InputTodo
48        todoText={todoText}
49        onChange={onChangeTodoText}
50        onClick={onClickAdd}
51      />
52      <InCompleteTodo
53        inCompleteTodos={inCompleteTodos}
54        onClick={onClickComplete}
55        onClick2={onClickDelete}
56      />
57      <CompleteTodo completeTodos={completeTodos} onClick={onClickBack} />
58    </>
59  );
60};
61
Full Screen

ui-autocomplete.js

Source: ui-autocomplete.js Github

copy
1function __export(m) {
2    for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
3}
4Object.defineProperty(exports, "__esModule", { value: true });
5var utils_1 = require("tns-core-modules/utils/utils");
6var stack_layout_1 = require("tns-core-modules/ui/layouts/stack-layout");
7var commonModule = require("./ui-autocomplete.common");
8__export(require("./ui-autocomplete.common"));
9var knownTemplates;
10(function (knownTemplates) {
11    knownTemplates.suggestionItemTemplate = "suggestionItemTemplate";
12})(knownTemplates = exports.knownTemplates || (exports.knownTemplates = {}));
13var TokenModel = /** @class */ (function (_super) {
14    __extends(TokenModel, _super);
15    function TokenModel(text, imageName) {
16        var _this = _super.call(this, text, imageName) || this;
17        if (imageName !== null && imageName !== undefined) {
18            var drawable = RadAutoCompleteTextView.resolveDrawableFromResource(imageName);
19            _this._android = new com.telerik.widget.autocomplete.TokenModel(text, drawable);
20            _this._android.setNsImageName(imageName);
21        }
22        else {
23            _this._android = new com.telerik.widget.autocomplete.TokenModel(text, null);
24        }
25        return _this;
26    }
27    Object.defineProperty(TokenModel.prototype, "android", {
28        get: function () {
29            return this._android;
30        },
31        enumerable: true,
32        configurable: true
33    });
34    return TokenModel;
35}(commonModule.TokenModel));
36exports.TokenModel = TokenModel;
37var SuggestionView = /** @class */ (function (_super) {
38    __extends(SuggestionView, _super);
39    function SuggestionView(parent) {
40        return _super.call(this) || this;
41    }
42    Object.defineProperty(SuggestionView.prototype, "android", {
43        get: function () {
44            return this._android;
45        },
46        set: function (value) {
47            this._android = value;
48        },
49        enumerable: true,
50        configurable: true
51    });
52    return SuggestionView;
53}(commonModule.SuggestionView));
54exports.SuggestionView = SuggestionView;
55var AutoCompleteAdapterClass;
56function ensureAutoCompleteAdapter() {
57    if (AutoCompleteAdapterClass) {
58        return AutoCompleteAdapterClass;
59    }
60    var AutoCompleteAdapter = /** @class */ (function (_super) {
61        __extends(AutoCompleteAdapter, _super);
62        function AutoCompleteAdapter(owner, items, isRemote) {
63            var _this = _super.call(this, utils_1.ad.getApplicationContext(), items, null) || this;
64            _this.suggestionsMap = {};
65            _this.owner = owner;
66            _this.isRemote = isRemote;
67            return global.__native(_this);
68        }
69        AutoCompleteAdapter.prototype.onCreateViewHolder = function (parent, viewType) {
70            var view = this.owner.getViewForViewType(commonModule.AutoCompleteViewType.ItemView);
71            var parentView = new stack_layout_1.StackLayout();
72            parentView.orientation = "vertical";
73            parentView.addChild(view);
74            this.owner._addView(parentView);
75            var layoutParams = new org.nativescript.widgets.CommonLayoutParams();
76            layoutParams.width = org.nativescript.widgets.CommonLayoutParams.MATCH_PARENT;
77            layoutParams.height = org.nativescript.widgets.CommonLayoutParams.WRAP_CONTENT;
78            var holder = new com.telerik.widget.autocomplete.SuggestionItemViewHolder(parentView.android);
79            parentView.android.setLayoutParams(layoutParams);
80            holder['nsView'] = parentView;
81            return holder;
82        };
83        AutoCompleteAdapter.prototype.onBindViewHolder = function (holder, position) {
84            var nativeItem = this.getFilteredList().get(position);
85            var model = this.nativeModelToNSModel(nativeItem);
86            if (holder.nsView !== undefined) {
87                holder.nsView.bindingContext = model;
88                this.attachOnClickListener(holder.itemView);
89                var args = {
90                    eventName: commonModule.RadAutoCompleteTextView.itemLoadingEvent,
91                    index: position,
92                    view: holder.nsView._subViews[0],
93                    android: holder,
94                    data: model
95                };
96                this.owner.notify(args);
97            }
98        };
99        AutoCompleteAdapter.prototype.filter = function (charText) {
100            if (!this.isRemote) {
101                _super.prototype.filter.call(this, charText);
102                var nsResult = new Array();
103                for (var i = 0; i < this.getFilteredList().size(); i++) {
104                    var nativeItem = this.getFilteredList().get(i);
105                    var model = this.nativeModelToNSModel(nativeItem);
106                    nsResult.push(model);
107                }
108                this.owner._filteredItems = nsResult;
109                return;
110            }
111            this.owner.android.getAdapter().getFilteredList().clear();
112            charText = charText.toLowerCase();
113            var self = this;
114            if (charText.length !== 0) {
115                this.owner.asyncCall(charText).then(function (items) {
116                    var result = new java.util.ArrayList();
117                    var nsResult = new Array();
118                    if (self.owner.completionMode === commonModule.AutoCompleteCompletionMode.StartsWith) {
119                        for (var i = 0; i < items.length; i++) {
120                            var current = items[i];
121                            var upperCase = current.android.getText().toLowerCase();
122                            if (upperCase.startsWith(charText)) {
123                                result.add(current.android);
124                                nsResult.push(current);
125                            }
126                        }
127                    }
128                    else {
129                        for (var i = 0; i < items.length; i++) {
130                            var current = items[i];
131                            var upperCase = current.android.getText().toLowerCase();
132                            if (upperCase.indexOf(charText !== -1)) {
133                                result.add(current.android);
134                                nsResult.push(current);
135                            }
136                        }
137                    }
138                    if (self.owner.isLoaded) {
139                        self.setItems(result);
140                        self.owner.android.getAdapter().setFilteredList(result);
141                        self.owner.android.resolveAfterFilter(self.owner.android.getTextField().getText().toString(), true);
142                        self.owner._filteredItems = nsResult;
143                    }
144                });
145            }
146        };
147        AutoCompleteAdapter.prototype.nativeModelToNSModel = function (nativeItem) {
148            var img = nativeItem.getNsImageName();
149            var model = new TokenModel(nativeItem.getText(), img);
150            return model;
151        };
152        return AutoCompleteAdapter;
153    }(com.telerik.widget.autocomplete.AutoCompleteAdapter));
154    AutoCompleteAdapterClass = AutoCompleteAdapter;
155}
156var AutoCompleteShowSuggestionListener;
157var AutoCompleteTextChangedListener;
158var AutoCompleteTokenAddedListener;
159var AutoCompleteTokenSelectedListener;
160var AutoCompleteTokenDeselectedListener;
161var AutoCompleteTokenRemovedListener;
162var AutoCompleteDidAutoCompleteListener;
163function initListeners() {
164    if (!AutoCompleteShowSuggestionListener) {
165        var AutoCompleteShowSuggestionListenerImpl = /** @class */ (function (_super) {
166            __extends(AutoCompleteShowSuggestionListenerImpl, _super);
167            function AutoCompleteShowSuggestionListenerImpl(owner) {
168                var _this = _super.call(this) || this;
169                _this.owner = owner;
170                return global.__native(_this);
171            }
172            AutoCompleteShowSuggestionListenerImpl.prototype.onShowSuggestionList = function (autoComplete, suggestions) {
173                var args = new commonModule.AutoCompleteEventData(this.owner, commonModule.RadAutoCompleteTextView.suggestionViewBecameVisibleEvent, undefined, undefined);
174                this.owner.notify(args);
175            };
176            AutoCompleteShowSuggestionListenerImpl = __decorate([
177                Interfaces([com.telerik.widget.autocomplete.ShowSuggestionListListener]),
178                __metadata("design:paramtypes", [RadAutoCompleteTextView])
179            ], AutoCompleteShowSuggestionListenerImpl);
180            return AutoCompleteShowSuggestionListenerImpl;
181        }(java.lang.Object));
182        AutoCompleteShowSuggestionListener = AutoCompleteShowSuggestionListenerImpl;
183    }
184    if (!AutoCompleteTextChangedListener) {
185        var AutoCompleteTextChangedListenerImpl = /** @class */ (function (_super) {
186            __extends(AutoCompleteTextChangedListenerImpl, _super);
187            function AutoCompleteTextChangedListenerImpl(owner) {
188                var _this = _super.call(this) || this;
189                _this.owner = owner;
190                return global.__native(_this);
191            }
192            AutoCompleteTextChangedListenerImpl.prototype.onTextChanged = function (autoComplete, text) {
193                if (this.owner.text !== text) {
194                    var args = new commonModule.AutoCompleteEventData(this.owner, commonModule.RadAutoCompleteTextView.textChangedEvent, text, undefined);
195                    this.owner.text = text;
196                    this.owner.notify(args);
197                }
198            };
199            AutoCompleteTextChangedListenerImpl = __decorate([
200                Interfaces([com.telerik.widget.autocomplete.TextChangedListener]),
201                __metadata("design:paramtypes", [RadAutoCompleteTextView])
202            ], AutoCompleteTextChangedListenerImpl);
203            return AutoCompleteTextChangedListenerImpl;
204        }(java.lang.Object));
205        AutoCompleteTextChangedListener = AutoCompleteTextChangedListenerImpl;
206    }
207    if (!AutoCompleteTokenAddedListener) {
208        var AutoCompleteTokenAddedListenerImpl = /** @class */ (function (_super) {
209            __extends(AutoCompleteTokenAddedListenerImpl, _super);
210            function AutoCompleteTokenAddedListenerImpl(owner) {
211                var _this = _super.call(this) || this;
212                _this.owner = owner;
213                return global.__native(_this);
214            }
215            AutoCompleteTokenAddedListenerImpl.prototype.onTokenAdded = function (autoComplete, token) {
216                var tokenModel = new TokenModel(token.getText(), token.getNsImageName());
217                var args = new commonModule.AutoCompleteEventData(this.owner, commonModule.RadAutoCompleteTextView.tokenAddedEvent, token.getText(), tokenModel);
218                this.owner.notify(args);
219            };
220            AutoCompleteTokenAddedListenerImpl = __decorate([
221                Interfaces([com.telerik.widget.autocomplete.TokenAddedListener]),
222                __metadata("design:paramtypes", [RadAutoCompleteTextView])
223            ], AutoCompleteTokenAddedListenerImpl);
224            return AutoCompleteTokenAddedListenerImpl;
225        }(java.lang.Object));
226        AutoCompleteTokenAddedListener = AutoCompleteTokenAddedListenerImpl;
227    }
228    if (!AutoCompleteTokenSelectedListener) {
229        var AutoCompleteTokenSelectedListenerImpl = /** @class */ (function (_super) {
230            __extends(AutoCompleteTokenSelectedListenerImpl, _super);
231            function AutoCompleteTokenSelectedListenerImpl(owner) {
232                var _this = _super.call(this) || this;
233                _this.owner = owner;
234                return global.__native(_this);
235            }
236            AutoCompleteTokenSelectedListenerImpl.prototype.onTokenSelected = function (autoComplete, token) {
237                var tokenModel = new TokenModel(token.getText(), token.getNsImageName());
238                var args = new commonModule.AutoCompleteEventData(this.owner, commonModule.RadAutoCompleteTextView.tokenSelectedEvent, token.getText(), tokenModel);
239                this.owner.notify(args);
240            };
241            AutoCompleteTokenSelectedListenerImpl = __decorate([
242                Interfaces([com.telerik.widget.autocomplete.TokenSelectedListener]),
243                __metadata("design:paramtypes", [RadAutoCompleteTextView])
244            ], AutoCompleteTokenSelectedListenerImpl);
245            return AutoCompleteTokenSelectedListenerImpl;
246        }(java.lang.Object));
247        AutoCompleteTokenSelectedListener = AutoCompleteTokenSelectedListenerImpl;
248    }
249    if (!AutoCompleteTokenDeselectedListener) {
250        var AutoCompleteTokenDeselectedListenerImpl = /** @class */ (function (_super) {
251            __extends(AutoCompleteTokenDeselectedListenerImpl, _super);
252            function AutoCompleteTokenDeselectedListenerImpl(owner) {
253                var _this = _super.call(this) || this;
254                _this.owner = owner;
255                return global.__native(_this);
256            }
257            AutoCompleteTokenDeselectedListenerImpl.prototype.onTokenDeselected = function (autoComplete, token) {
258                var tokenModel = new TokenModel(token.getText(), token.getNsImageName());
259                var args = new commonModule.AutoCompleteEventData(this.owner, commonModule.RadAutoCompleteTextView.tokenDeselectedEvent, token.getText(), tokenModel);
260                this.owner.notify(args);
261            };
262            AutoCompleteTokenDeselectedListenerImpl = __decorate([
263                Interfaces([com.telerik.widget.autocomplete.TokenDeselectedListener]),
264                __metadata("design:paramtypes", [RadAutoCompleteTextView])
265            ], AutoCompleteTokenDeselectedListenerImpl);
266            return AutoCompleteTokenDeselectedListenerImpl;
267        }(java.lang.Object));
268        AutoCompleteTokenDeselectedListener = AutoCompleteTokenDeselectedListenerImpl;
269    }
270    if (!AutoCompleteTokenRemovedListener) {
271        var AutoCompleteTokenRemovedListenerImpl = /** @class */ (function (_super) {
272            __extends(AutoCompleteTokenRemovedListenerImpl, _super);
273            function AutoCompleteTokenRemovedListenerImpl(owner) {
274                var _this = _super.call(this) || this;
275                _this.owner = owner;
276                return global.__native(_this);
277            }
278            AutoCompleteTokenRemovedListenerImpl.prototype.onTokenRemoved = function (autoComplete, token) {
279                var tokenModel = new TokenModel(token.getText(), token.getNsImageName());
280                var args = new commonModule.AutoCompleteEventData(this.owner, commonModule.RadAutoCompleteTextView.tokenRemovedEvent, token.getText(), tokenModel);
281                this.owner.notify(args);
282            };
283            AutoCompleteTokenRemovedListenerImpl = __decorate([
284                Interfaces([com.telerik.widget.autocomplete.TokenRemovedListener]),
285                __metadata("design:paramtypes", [RadAutoCompleteTextView])
286            ], AutoCompleteTokenRemovedListenerImpl);
287            return AutoCompleteTokenRemovedListenerImpl;
288        }(java.lang.Object));
289        AutoCompleteTokenRemovedListener = AutoCompleteTokenRemovedListenerImpl;
290    }
291    if (!AutoCompleteDidAutoCompleteListener) {
292        var AutoCompleteDidAutoCompleteListenerImpl = /** @class */ (function (_super) {
293            __extends(AutoCompleteDidAutoCompleteListenerImpl, _super);
294            function AutoCompleteDidAutoCompleteListenerImpl(owner) {
295                var _this = _super.call(this) || this;
296                _this.owner = owner;
297                return global.__native(_this);
298            }
299            AutoCompleteDidAutoCompleteListenerImpl.prototype.onDidAutoComplete = function (autoComplete, text) {
300                var args = new commonModule.AutoCompleteEventData(this.owner, commonModule.RadAutoCompleteTextView.didAutoCompleteEvent, text, undefined);
301                this.owner.notify(args);
302            };
303            AutoCompleteDidAutoCompleteListenerImpl = __decorate([
304                Interfaces([com.telerik.widget.autocomplete.DidAutoCompleteListener]),
305                __metadata("design:paramtypes", [RadAutoCompleteTextView])
306            ], AutoCompleteDidAutoCompleteListenerImpl);
307            return AutoCompleteDidAutoCompleteListenerImpl;
308        }(java.lang.Object));
309        AutoCompleteDidAutoCompleteListener = AutoCompleteDidAutoCompleteListenerImpl;
310    }
311}
312var RadAutoCompleteTextView = /** @class */ (function (_super) {
313    __extends(RadAutoCompleteTextView, _super);
314    function RadAutoCompleteTextView() {
315        var _this = _super.call(this) || this;
316        _this._androidViewId = -1;
317        return _this;
318    }
319    RadAutoCompleteTextView.prototype.createNativeView = function () {
320        this._android = new com.telerik.widget.autocomplete.RadAutoCompleteTextView(this._context);
321        initListeners();
322        this._android._showSuggestionListener = new AutoCompleteShowSuggestionListener(this);
323        this._android._textChangedListener = new AutoCompleteTextChangedListener(this);
324        this._android._tokenAddedListener = new AutoCompleteTokenAddedListener(this);
325        this._android._tokenSelectedListener = new AutoCompleteTokenSelectedListener(this);
326        this._android._tokenDeselectedListener = new AutoCompleteTokenDeselectedListener(this);
327        this._android._tokenRemovedListener = new AutoCompleteTokenRemovedListener(this);
328        this._android._didAutoCompleteListener = new AutoCompleteDidAutoCompleteListener(this);
329        this._android.addShowSuggestionListListener(this._android._showSuggestionListener);
330        this._android.addTextChangedListener(this._android._textChangedListener);
331        this._android.addTokenAddedListener(this._android._tokenAddedListener);
332        this._android.addTokenSelectedListener(this._android._tokenSelectedListener);
333        this._android.addTokenDeselectedListener(this._android._tokenDeselectedListener);
334        this._android.addTokenRemovedListener(this._android._tokenRemovedListener);
335        this._android.addDidAutoCompleteListener(this._android._didAutoCompleteListener);
336        if (this.displayMode) {
337            this.adjustDisplayMode(this.displayMode);
338        }
339        if (this.suggestMode) {
340            this.adjustSuggestMode(this.suggestMode);
341        }
342        if (this.layoutMode) {
343            this.adjustLayoutMode(this.layoutMode);
344        }
345        if (this.completionMode) {
346            this.adjustCompletionMode(this.completionMode);
347        }
348        if (this.suggestionView) {
349            this.adjustSuggestionView(this.suggestionView);
350        }
351        if (this.hint) {
352            this.adjustHint(this.hint);
353        }
354        if (this.text) {
355            this.adjustText(this.text);
356        }
357        if (this.minimumCharactersToSearch) {
358            this.adjustMinimumCharactersToSearch(this.minimumCharactersToSearch);
359        }
360        if (this.noResultsText) {
361            this.adjustNoResultsText(this.noResultsText);
362        }
363        if (this.closeButtonImageSrc) {
364            this.adjustCloseButtonImage(this.closeButtonImageSrc);
365        }
366        this.adjustShowCloseButton(this.showCloseButton);
367        if (this.asyncCall) {
368            this.adjustAsyncCall(true);
369        }
370        else {
371            this.loadData(false);
372        }
373        return this._nativeView;
374    };
375    RadAutoCompleteTextView.prototype.initNativeView = function () {
376        _super.prototype.initNativeView.call(this);
377        if (this._androidViewId < 0) {
378            this._androidViewId = android.view.View.generateViewId();
379        }
380        this._nativeView.setId(this._androidViewId);
381    };
382    RadAutoCompleteTextView.prototype.disposeNativeView = function () {
383        if (this._android._showSuggestionListener) {
384            this._android._showSuggestionListener.owner = null;
385        }
386        if (this._android._textChangedListener) {
387            this._android._textChangedListener.owner = null;
388        }
389        if (this._android._tokenAddedListener) {
390            this._android._tokenAddedListener.owner = null;
391        }
392        if (this._android._tokenSelectedListener) {
393            this._android._tokenSelectedListener.owner = null;
394        }
395        if (this._android._tokenDeselectedListener) {
396            this._android._tokenDeselectedListener.owner = null;
397        }
398        if (this._android._tokenRemovedListener) {
399            this._android._tokenRemovedListener.owner = null;
400        }
401        if (this._android._didAutoCompleteListener) {
402            this._android._didAutoCompleteListener.owner = null;
403        }
404        _super.prototype.disposeNativeView.call(this);
405    };
406    Object.defineProperty(RadAutoCompleteTextView.prototype, "_nativeView", {
407        get: function () {
408            return this._android;
409        },
410        enumerable: true,
411        configurable: true
412    });
413    Object.defineProperty(RadAutoCompleteTextView.prototype, "filteredItems", {
414        get: function () {
415            if (this._filteredItems === undefined) {
416                this._filteredItems = new Array();
417            }
418            return this._filteredItems;
419        },
420        enumerable: true,
421        configurable: true
422    });
423    RadAutoCompleteTextView.prototype.resetAutoComplete = function () {
424        this._android.resetAutocomplete();
425    };
426    RadAutoCompleteTextView.prototype.addToken = function (token) {
427        var image = token.image ? RadAutoCompleteTextView.resolveDrawableFromResource(token.image) : null;
428        var nativeObject = new com.telerik.widget.autocomplete.TokenModel(token.text, image);
429        this._android.addTokenView(nativeObject);
430        if (this._android.getDisplayMode() === com.telerik.widget.autocomplete.DisplayMode.PLAIN) {
431            // HACK: to unify behavior in iOS and Android
432            this._android.setText(token.text);
433        }
434    };
435    RadAutoCompleteTextView.prototype.insertTokenAtIndex = function (token, index) {
436        var image = token.image ? RadAutoCompleteTextView.resolveDrawableFromResource(token.image) : null;
437        var nativeObject = new com.telerik.widget.autocomplete.TokenModel(token.text, image);
438        var nativeTokenView = new com.telerik.widget.autocomplete.TokenView(this._context);
439        nativeTokenView.setModel(nativeObject);
440        this._android.insertTokenAt(index, nativeTokenView);
441    };
442    RadAutoCompleteTextView.prototype.removeToken = function (token) {
443        var nativeObject = new com.telerik.widget.autocomplete.TokenModel(token.text, null);
444        var nativeTokenView = new com.telerik.widget.autocomplete.TokenView(this._context);
445        nativeTokenView.setModel(nativeObject);
446        this._android.removeToken(nativeTokenView);
447    };
448    RadAutoCompleteTextView.prototype.removeTokenAtIndex = function (index) {
449        this._android.removeTokenAt(index);
450    };
451    RadAutoCompleteTextView.prototype.removeAllTokens = function () {
452        this._android.removeAllTokens();
453    };
454    RadAutoCompleteTextView.prototype.tokens = function () {
455        return this._android.getTokens();
456    };
457    RadAutoCompleteTextView.prototype.tokenAtIndex = function (index) {
458        return this._android.getTokenAt(index);
459    };
460    RadAutoCompleteTextView.prototype.onDisplayModeChanged = function (oldValue, newValue) {
461        this.adjustDisplayMode(newValue);
462    };
463    RadAutoCompleteTextView.prototype.onLayoutModeChanged = function (oldValue, newValue) {
464        this.adjustLayoutMode(newValue);
465    };
466    RadAutoCompleteTextView.prototype.onSuggestModeChanged = function (oldValue, newValue) {
467        this.adjustSuggestMode(newValue);
468    };
469    RadAutoCompleteTextView.prototype.onCompletionModeChanged = function (oldValue, newValue) {
470        this.adjustCompletionMode(newValue);
471    };
472    RadAutoCompleteTextView.prototype.onItemsChanged = function (oldValue, newValue) {
473        this.loadData(false);
474    };
475    RadAutoCompleteTextView.prototype.onSuggestionViewChanged = function (oldValue, newValue) {
476        this.adjustSuggestionView(newValue);
477    };
478    RadAutoCompleteTextView.prototype.onHintChanged = function (oldValue, newValue) {
479        this.adjustHint(newValue);
480    };
481    RadAutoCompleteTextView.prototype.onTextChanged = function (oldValue, newValue) {
482        this.adjustText(newValue);
483    };
484    RadAutoCompleteTextView.prototype.onMinimumCharactersToSearchChanged = function (oldValue, newValue) {
485        this.adjustMinimumCharactersToSearch(newValue);
486    };
487    RadAutoCompleteTextView.prototype.onNoResultsTextChanged = function (oldValue, newValue) {
488        this.adjustNoResultsText(newValue);
489    };
490    RadAutoCompleteTextView.prototype.onLoadSuggestionsAsyncChanged = function (oldValue, newValue) {
491        this.asyncCall = newValue;
492        this.adjustAsyncCall(true);
493    };
494    RadAutoCompleteTextView.prototype.onShowCloseButtonChanged = function (oldValue, newValue) {
495        this.adjustShowCloseButton(newValue);
496    };
497    RadAutoCompleteTextView.prototype.onCloseButtonImageSrcChanged = function (oldValue, newValue) {
498        this.adjustCloseButtonImage(newValue);
499    };
500    RadAutoCompleteTextView.prototype.onReadOnlyChanged = function (oldValue, newValue) {
501        this._android.setReadOnly(newValue);
502    };
503    RadAutoCompleteTextView.prototype.adjustAsyncCall = function (value) {
504        if (this._android && value) {
505            this._android.setUsingAsyncData(value);
506            this.loadData(true);
507        }
508    };
509    RadAutoCompleteTextView.prototype.adjustHint = function (value) {
510        if (this._android && value) {
511            this._android.setAutocompleteHint(value);
512        }
513    };
514    RadAutoCompleteTextView.prototype.adjustText = function (value) {
515        if (this._android && this._android.getText().toString() !== value) {
516            this._android.setText(value);
517        }
518    };
519    RadAutoCompleteTextView.prototype.adjustMinimumCharactersToSearch = function (value) {
520        if (this._android && value) {
521            this._android.setMinimumCharactersToSearch(value);
522        }
523    };
524    RadAutoCompleteTextView.prototype.adjustNoResultsText = function (value) {
525        if (this._android && value) {
526            this._android.setNoResultsText(value);
527        }
528    };
529    RadAutoCompleteTextView.prototype.adjustSuggestionView = function (value) {
530        if (this._android && value) {
531            var suggestionView = value;
532            suggestionView.android = this._android.getSuggestionView();
533            if (suggestionView.suggestionViewHeight) {
534                var heightInPixels = utils_1.layout.toDevicePixels(suggestionView.suggestionViewHeight);
535                this._android.setSuggestionViewHeight(heightInPixels);
536            }
537        }
538    };
539    RadAutoCompleteTextView.prototype.adjustCompletionMode = function (value) {
540        if (this._android && value) {
541            if (value === commonModule.AutoCompleteCompletionMode.Contains) {
542                this._android.getAdapter().setCompletionMode(com.telerik.widget.autocomplete.CompletionMode.CONTAINS);
543            }
544            else {
545                this._android.getAdapter().setCompletionMode(com.telerik.widget.autocomplete.CompletionMode.STARTS_WITH);
546            }
547        }
548    };
549    RadAutoCompleteTextView.prototype.adjustDisplayMode = function (value) {
550        if (this._android && value) {
551            this._android.setDisplayMode((value === commonModule.AutoCompleteDisplayMode.Plain) ?
552                com.telerik.widget.autocomplete.DisplayMode.PLAIN :
553                com.telerik.widget.autocomplete.DisplayMode.TOKENS);
554        }
555    };
556    RadAutoCompleteTextView.prototype.adjustSuggestMode = function (value) {
557        if (this._android && value) {
558            if (value === commonModule.AutoCompleteSuggestMode.Suggest) {
559                this._android.setSuggestMode(com.telerik.widget.autocomplete.SuggestMode.SUGGEST);
560            }
561            else if (value === commonModule.AutoCompleteSuggestMode.Append) {
562                this._android.setSuggestMode(com.telerik.widget.autocomplete.SuggestMode.APPEND);
563            }
564            else {
565                this._android.setSuggestMode(com.telerik.widget.autocomplete.SuggestMode.SUGGEST_APPEND);
566            }
567        }
568    };
569    RadAutoCompleteTextView.prototype.adjustLayoutMode = function (value) {
570        if (value && this._android) {
571            this._android.setTokensLayoutMode((value === commonModule.AutoCompleteLayoutMode.Horizontal) ?
572                com.telerik.widget.autocomplete.LayoutMode.HORIZONTAL :
573                com.telerik.widget.autocomplete.LayoutMode.WRAP);
574        }
575    };
576    RadAutoCompleteTextView.prototype.adjustShowCloseButton = function (value) {
577        if (this._android) {
578            this._android.setShowCloseButton(value);
579        }
580    };
581    RadAutoCompleteTextView.prototype.adjustCloseButtonImage = function (value) {
582        if (this._android) {
583            if (value !== null && value !== undefined) {
584                var drawable = RadAutoCompleteTextView.resolveDrawableFromResource(value);
585                if (drawable) {
586                    this._android.getCloseButtonView().setBackgroundDrawable(drawable);
587                }
588            }
589        }
590    };
591    RadAutoCompleteTextView.prototype.loadData = function (isRemote) {
592        if (this._nativeView !== undefined) {
593            if ((this.items === undefined && isRemote === true) || this.items !== undefined) {
594                var nativeSource = new java.util.ArrayList();
595                if (this.items !== undefined) {
596                    for (var i = 0; i < this.items.length; i++) {
597                        var a = this.items.getItem(i);
598                        nativeSource.add(a.android);
599                    }
600                }
601                ensureAutoCompleteAdapter();
602                var adapter = new AutoCompleteAdapterClass(this, nativeSource, isRemote);
603                this._android.setAdapter(adapter);
604                this.adjustCompletionMode(this.completionMode);
605            }
606        }
607    };
608    RadAutoCompleteTextView.resolveDrawableFromResource = function (imageName) {
609        var nativeValue = imageName;
610        var drawable;
611        if (imageName.startsWith("res://")) {
612            nativeValue = imageName.substring(6, imageName.length);
613        }
614        var appResources = utils_1.ad.getApplicationContext().getResources();
615        var packageName = utils_1.ad.getApplication().getPackageName();
616        if (appResources) {
617            var identifier = appResources.getIdentifier(nativeValue, 'drawable', packageName);
618            if (identifier > 0) {
619                drawable = appResources.getDrawable(identifier);
620            }
621            else {
622                console.log("WARNING: Can't find drawable with name: " + nativeValue);
623            }
624        }
625        return drawable;
626    };
627    return RadAutoCompleteTextView;
628}(commonModule.RadAutoCompleteTextView));
629exports.RadAutoCompleteTextView = RadAutoCompleteTextView;
630
Full Screen

Accelerate Your Automation Test Cycles With LambdaTest

Leverage LambdaTest’s cloud-based platform to execute your automation tests in parallel and trim down your test execution time significantly. Your first 100 automation testing minutes are on us.

Try LambdaTest

Run JavaScript Tests on LambdaTest Cloud Grid

Execute automation tests with Karma on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.

Test now for Free
LambdaTestX

We use cookies to give you the best experience. Cookies help to provide a more personalized experience and relevant advertising for you, and web analytics for us. Learn More in our Cookies policy, Privacy & Terms of service

Allow Cookie
Sarah

I hope you find the best code examples for your project.

If you want to accelerate automated browser testing, try LambdaTest. Your first 100 automation testing minutes are FREE.

Sarah Elson (Product & Growth Lead)