No data available after Android docks with Bomb

Keywords: SDK Android

A while ago I did a Demo where I tried to use the Bmob backend cloud, but after filling in the data on the Web, I found that I could not get the data successfully.The entanglement was resolved successfully after a period of time.

In a nutshell, the first step is to import Bmob dependencies in Android Studio: Click SDK Import on the left after entering

Step 2 (1) Check that your JavaBean is consistent with the backend

(2) Check whether BmobObject or BmobUser is inherited

Step 3 Remember to get a connection to Bmob

                               

  //Provide two ways to initialize operations:

        //First: Default Initialization
        Bmob.initialize(this, "Your Application ID");
        // Note: Since v3.5.2, the statistical SDK has been stitched up inside the data sdk. Developers do not need additional integration. They can pass channel parameters without default data statistics function turned on.
        //Bmob.initialize (this,'Your Application ID','bmob'); you can actually use this

        //Second: Beginning with v3.4.7, BmobConfig is set, which allows setting request timeout, size of each slice when file slices are uploaded, and expiration time of files in seconds.
        //BmobConfig config =new BmobConfig.Builder(this)
        ////Set appkey
        //.setApplicationId("Your Application ID")
        ////Request timeout in seconds: default 15s
        //.setConnectTimeout(30)
        ////Size of each slice (in bytes) when file slices are uploaded, default 512*1024
        //.setUploadBlockSize(1024*1024)
        ////File expiration time in seconds: default 1800s
        //.setFileExpiration(2500)
        //.build();
        //Bmob.initialize(config);
    }

Then it was time to get the data, and I thought it would be ok ay to just use a List to store the data and pass it to the adapter, but...

Each time it is not stored in the List.. Log discoveries can be obtained, but not in the collection..

So there's a solution:

I used Map instead to store the data I searched from the back end and List to store the Map

private HashMap<String,String >mHashMap;
private List<Map<String,String>> mapList;

Here is the search that coexists in the collection (//Glide what can be automatically ignored ==)

mapList = new ArrayList<>();
        query = new BmobQuery<Book>();
        query.addWhereEqualTo("author_name", authorName);
        query.findObjects(new FindListener<Book>() {
            @Override
            public void done(List<Book> list, BmobException e) {
                if(e==null){
                    initArray(list.size());
                    for (Book book : list) {
                        mHashMap = new HashMap<>();
                        mHashMap.put("bookName",book.getBookName());
                        mHashMap.put("authorName",book.getAuthor_name());
                        mHashMap.put("imageUrl",book.getBook_image().getFileUrl());
                        Glide.with(context).load(book.getBook_image().getFileUrl()).preload();//Pre-caching
                        mHashMap.put("bookClass",book.getBookClass());
                        mHashMap.put("bookIntro",book.getIntro());
                        mapList.add(mHashMap);
                    }
So the mystery can be stored.

Then you can take the list and send it to the AdapterAs to why it could be solved... it is still under study.


Posted by phonydream on Thu, 16 Apr 2020 09:35:47 -0700