0

i am debugging an Android app,initially debugging variable value is accessible, but when i get response from an api it says 'this' is not awailable. please help.

i tried below link but no luck

“'this' is not available” in debug windows of Android Studio

here is the code snippet

    Error error = errors.getError().get(0);
                        if (request.getItemSearchRequest().getItemPage().equals("1")) {
                            // display the error on screen if it is first page
                            if (error.getCode().equals("AWS.ECommerceService.NoExactMatches")) {
                                // no results found
                                // check if the keyword is ASIN
                                if (ProductCodeValidator.INSTANCE.isValidASIN(keyword)) {
                                    // get the product info using Item Look up for that ASIN
                                    Map<String, String> params = new ArrayMap<>();
                                    params.put("Operation", "ItemLookup");
                                    params.put("ItemId", keyword);
                                    params.put("IdType", ProductCodeType.ASIN.getRealName());
                                    String requestUrl = getSignedUrl(params);
                                    getViewModel().lookUpASIN(requestUrl);
                                    return;
                                }
                            }
                            getViewModel().showEmptyView(getString(R.string.notFound)); // error.getMessage()
                        } else {
                            // display the error as toast
                            showToast(error.getMessage());
                        }

i am getting 'this' is not available while debugging "keyword" variable

Kotdroid
  • 165
  • 1
  • 12
  • where do you define this variable ? – a_local_nobody Jul 18 '19 at 18:12
  • I have defined that variable inside class. Means it is globally accessible through-out the class. – Kotdroid Jul 18 '19 at 18:15
  • ok , so where you do assign a value to that variable then ? – a_local_nobody Jul 19 '19 at 04:42
  • I have a searchview on submit I have assigned value to 'keyword' that is working good. Then I hit an API and observe it's response using livedata (using MVVM) and when there is a specific value in response I need to hit another API using that keyword . But at second time I get that 'this is not available' and that doesn't work from there bro. – Kotdroid Jul 19 '19 at 04:55
  • ok cool, just making sure – a_local_nobody Jul 19 '19 at 04:57
  • Can you add code of `ProductCodeValidator` class? – Skullper Jul 21 '19 at 08:16
  • yes this is the method written in ProductCodeValidator class ` /** * check if string is valid ASIn or not */ fun isValidASIN(code: String): Boolean { // this matches the total 10 digits or characters which is the length of ASIN return code.matches("^[0-9A-Za-z]{10}$".toRegex()) }` – Kotdroid Jul 22 '19 at 14:28

0 Answers0