Cannot resolve method enqueue....
See original GitHub issueI can not use the fetch2 because the Android Studio shows an error “cannot resolve method enqueune…”
public class BookCardActivity extends AppCompatActivity {
static final String TAG = "myLogs";
private int bookId;
Fetch mFetch;
ProgressBar progressBar;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_book_card);
progressBar = (ProgressBar) findViewById(R.id.progressBar3);
mFetch = (Fetch) new Fetch.Builder(this, "ToddlerBook")
.setDownloadConcurrentLimit(4)
.enableLogging(true)
.build();
ImageButton imageButton = (ImageButton) findViewById(R.id.imageButtonHome);
View.OnClickListener clickHome = new View.OnClickListener() {
@Override
public void onClick(View v) {
GoHome();
}
};
imageButton.setOnClickListener(clickHome);
BookUriFromId();
String fileNamePath = "filesPath.json";
String covers = MyJSON.getData(this, fileNamePath);
ArrayList<String> coversPaths = getFilesPathFromFile(covers);
ImageView imageView = (ImageView) findViewById(R.id.imageView);
int posit = bookId - 1;
File imgFile = new File(coversPaths.get(posit));
Bitmap myBitmap = BitmapFactory.decodeFile(imgFile.getAbsolutePath());
imageView.setImageBitmap(myBitmap);
final Button buttonDownload = (Button) findViewById(R.id.button);
/**
* Проверим наличие файлов в папке bookfiles_1, bookfiles_2, ...
*/
String folderBook = "bookfiles_" + bookId;
int count = 0;
/**
* Проверяем необходимость загрузки файлов
*/
File rootFile = new File(String.valueOf(getExternalFilesDir(folderBook)));
File[] filesArray = rootFile.listFiles();
int numbFiles = filesArray.length;
if (numbFiles == 0) {
buttonDownload.setText(R.string.buttonDownload);
/**
* Загрузим json с url файлов книги
*/
Thread jsDownload = new Thread(new Runnable() {
@Override
public void run() {
BookLoader();
}
});
jsDownload.start(); // запустили поток 1
/**
* Обрабатываем нажатие кнопки "Загрузить" и грузим файлы книги
*/
buttonDownload.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String fileListB = "list_" + "book_" + bookId + ".json";
String jsReadFile = MyJSON.getData(getApplicationContext(), fileListB);
Log.d(TAG, jsReadFile);
Gson gson = new Gson();
Book book = gson.fromJson(jsReadFile, Book.class);
List<String> pages = book.getPageUrl();
List<String> sounds = book.getSoundUrl();
String[] urlsPages = pages.toArray(new String[0]);
String[] urlsSounds = sounds.toArray(new String[0]);
String[] urlsFiles = ArrayAndArrayNewArray(urlsPages, urlsSounds);
String folderB = "bookfiles_" + bookId;
String fileNameForWrite = "book_" + bookId + ".json";
final List<Request> requestList = new ArrayList<>();
File bookfolder = new File(String.valueOf(getExternalFilesDir(folderB)));
ArrayList<String> pagesFiles = new ArrayList<>();
for (int i = 0; i < urlsFiles.length; i++) {
String url = urlsFiles[i];
String path = String.valueOf(bookfolder);
String fileName = Uri.parse(url).getLastPathSegment();
Log.d("my2", fileName);
String pageFilePath = path + "/" + fileName;
final Request request = new Request(url, pageFilePath);
request.setPriority(Priority.HIGH);
request.setNetworkType(NetworkType.ALL);
requestList.add(request);
// Log.d("my2", pageFilePath);
pagesFiles.add(pageFilePath);
}
// ERROR!!!!
mFetch.enqueue(requestList, new Func<List<? extends Download>>() {
@Override
public void call(List<? extends Download> downloads) {
//Successfully enqueued requests.
}
}, new Func<Error>() {
@Override
public void call(Error error) {
// An error occurred when enqueuing requests.
}
});
BookFiles bookFiles = new BookFiles();
bookFiles.setBookID(bookId);
ArrayList<String> pagesPath = getPagesArray(pagesFiles);
ArrayList<String> soundsPath = getSoundsArray(pagesFiles);
bookFiles.setPagesPath(pagesPath);
bookFiles.setSoundsPath(soundsPath);
Gson gson11 = new Gson();
String filesJson = gson11.toJson(bookFiles);
MyJSON.saveData(getApplicationContext(), filesJson, fileNameForWrite);
buttonDownload.setText(R.string.buttonRead);
buttonDownload.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
NextActivity();
}
});
}
});
} else {
buttonDownload.setText(R.string.buttonRead);
buttonDownload.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
NextActivity();
}
});
}
}
private void BookUriFromId() {
//получаем номер ID книги, с обложки которой перешли в слайдер
Intent intent = getIntent();
bookId = intent.getIntExtra("bookId", 1);
Log.d(TAG, "You read book №" + bookId);
}
private void NextActivity() {
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
Intent intent = new Intent(BookCardActivity.this, SliderActivity.class);
intent.putExtra("bookId", bookId); // передаю в слайдер номер книги
startActivity(intent);
finish();
}
}, 20);
}
private ArrayList<String> getFilesPathFromFile(String jsResult) {
ArrayList<String> urisImg = new ArrayList<>();
try {
JSONArray rootJson = new JSONArray(new JSONTokener(jsResult));
for (int i = 0; i < rootJson.length(); i++) {
JSONObject o = rootJson.getJSONObject(i);
String strTo = (String) o.get("uriString");
urisImg.add(strTo);
}
} catch (JSONException e) {
e.printStackTrace();
}
return urisImg;
}
private void BookLoader() {
HttpURLConnection urlConnection = null;
BufferedReader reader = null;
String resultJsonServer = "";
String fileBook = "list_" + "book_" + bookId + ".json";
try {
String jsUrl = "http://******.ru/todbook/book" + bookId + ".json";
URL url = new URL(jsUrl);
urlConnection = (HttpURLConnection) url.openConnection();
urlConnection.setRequestMethod("GET");
urlConnection.connect();
InputStream inputStream = urlConnection.getInputStream();
StringBuilder buffer = new StringBuilder();
reader = new BufferedReader(new InputStreamReader(inputStream));
String line;
while ((line = reader.readLine()) != null) {
buffer.append(line);
}
resultJsonServer = buffer.toString();
MyJSON.saveData(getApplicationContext(), resultJsonServer, fileBook);
} catch (Exception e) {
e.printStackTrace();
}
}
public static String[] ArrayAndArrayNewArray(String[] a, String[] b) {
if (a == null)
return b;
if (b == null)
return a;
String[] r = new String[a.length + b.length];
System.arraycopy(a, 0, r, 0, a.length);
System.arraycopy(b, 0, r, a.length, b.length);
return r;
}
public ArrayList<String> getSoundsArray(ArrayList<String> pagesFiles) {
ArrayList<String> res = new ArrayList<>();
for (int i = 0; i < pagesFiles.size(); i++) {
String soun = pagesFiles.get(i);
if (soun.contains("sound")) {
res.add(soun);
}
}
return res;
}
public ArrayList<String> getPagesArray(ArrayList<String> pagesFiles) {
ArrayList<String> res = new ArrayList<>();
for (int i = 0; i < pagesFiles.size(); i++) {
String soun = pagesFiles.get(i);
if (!soun.contains("sound")) {
res.add(soun);
}
}
return res;
}
private void GoHome() {
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
Intent intent = new Intent(BookCardActivity.this, MainActivity.class);
startActivity(intent);
finish();
}
}, 10);
}
}`
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
enqueue okhttp3 cannot resolve method java - Stack Overflow
I'm having a bit of trouble creating an app with 2 factor authentication. I decided to use twilio as my sms gateway and...
Read more >call.enqueue error (Example) | Treehouse Community
So guys i was trying to ad call.enqueue method but it says that can't resolve symbol 'enqueue'. what should i do to resolve...
Read more >retrofit2.Call.enqueue java code examples - Tabnine
call.enqueue(new Callback () { ... 'callbackExecutor' is not null, the 'callback' methods should be executed // on that executor by submitting a Runnable....
Read more >Enqueue callback not called #1693 - square/retrofit - GitHub
Hi,. I am using retrofit2 and recognized that sometimes the callback for Call.enqueue is not called. e.g.. mService.getItem ...
Read more >Different Ways to fix Cannot resolve symbol ... - GeeksforGeeks
Go to your build.gradle(Module:app) file and in the dependencies section the appcompat one, you should see something like compile 'com.android.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@CoMatu I had the same error and moving the functions out of the other function seemed to solve it for me.
I showed that the IDE shows the name of the method. The method does not work.