Android Open Source - PictureBookReader J S O N Manager






From Project

Back to project page PictureBookReader.

License

The source code is released under:

GNU General Public License

If you think the Android project PictureBookReader listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package net.uyghurdev.avaroid.picturebookreader;
//ww  w.ja va  2s. co  m
import java.util.ArrayList;

import org.json.JSONArray;
import org.json.JSONException;

import android.app.ProgressDialog;
import android.content.Context;
import android.util.Log;

public class JSONManager {
  public int onlinePBar;
  ProgressDialog progressBar;
  Context cxt;
  JSONManager(Context _cxt){
    this.cxt=_cxt;
    
  }
  public ArrayList<GetOnlineBookInfo> getOnlineCats() {
    // TODO Auto-generated method stub
    ArrayList<GetOnlineBookInfo> cats = new ArrayList<GetOnlineBookInfo>();
    NetWorkOperator net = new NetWorkOperator();
    String jString = "";
    jString = net.urlToString(Configs.CategoriesServer);
    try {
      // this will break the JSON messages into an array
      JSONArray aryJSONStrings = new JSONArray(jString);
      // loop through the array
      for (int i = 0; i < aryJSONStrings.length(); i++) {
        GetOnlineBookInfo cat = new GetOnlineBookInfo();
        cat.setID(aryJSONStrings.getJSONObject(i).getInt("id"));

      }

    } catch (JSONException e) {
      Log.d("json", e.toString());
    }

    return cats;
  }

  public ArrayList<Book> getOnlineBooks() {
  
    // TODO Auto-generated method stub
    ArrayList<Book> books = new ArrayList<Book>();
    NetWorkOperator net = new NetWorkOperator();
    String jString1 = "";
    GetOnlineBookInfo cat = new GetOnlineBookInfo();
    jString1 = net.urlToString(Configs.CategoriesServer);
    JSONArray aryJSONStrings1;
    try {
      aryJSONStrings1 = new JSONArray(jString1);
      for (int f = 0; f < aryJSONStrings1.length(); f++) {
        cat.setID(aryJSONStrings1.getJSONObject(f).getInt("id"));
        Configs.CatId = cat.getID();

        String jString = "";
        jString = net.urlToString(Configs.BooksServer + Configs.CatId);

        try {
          // this will break the JSON messages into an array
          JSONArray aryJSONStrings = new JSONArray(jString);
          // loop through the array
          // onlinePBar=aryJSONStrings.length();
          for (int i = 0; i < aryJSONStrings.length(); i++) {
            Book book = new Book();

            book.setID(aryJSONStrings.getJSONObject(i).getInt("id"));
            book.setTitle(aryJSONStrings.getJSONObject(i)
                .getString("title"));
            book.setDescription(aryJSONStrings.getJSONObject(i)
                .getString("description"));
            book.setPubDate(Long.parseLong(aryJSONStrings
                .getJSONObject(i).getString("date")
                .replace("/", "").replace("Date(", "")
                .replace(")", "")));
            book.setAuthor(aryJSONStrings.getJSONObject(i)
                .getString("author"));
            book.setCoverImg(aryJSONStrings.getJSONObject(i)
                .getString("coverimage"));
            book.setLanguage(aryJSONStrings.getJSONObject(i)
                .getString("language"));
            book.setSize(aryJSONStrings.getJSONObject(i).getString(
                "size"));
          
            books.add(book);

          }

        } catch (JSONException e) {
          Log.d("json", e.toString());
        }
      }
    } catch (JSONException e1) {
      // TODO Auto-generated catch block
      e1.printStackTrace();
    }
    
    return books;

  }
}




Java Source Code List

net.uyghurdev.avaroid.picturebookreader.About.java
net.uyghurdev.avaroid.picturebookreader.BookText.java
net.uyghurdev.avaroid.picturebookreader.Book.java
net.uyghurdev.avaroid.picturebookreader.BookmarkData.java
net.uyghurdev.avaroid.picturebookreader.Configs.java
net.uyghurdev.avaroid.picturebookreader.CurlMesh.java
net.uyghurdev.avaroid.picturebookreader.CurlPage.java
net.uyghurdev.avaroid.picturebookreader.CurlRenderer.java
net.uyghurdev.avaroid.picturebookreader.CurlView.java
net.uyghurdev.avaroid.picturebookreader.DecompressReader.java
net.uyghurdev.avaroid.picturebookreader.Decompresser.java
net.uyghurdev.avaroid.picturebookreader.DownloadFile.java
net.uyghurdev.avaroid.picturebookreader.FileCache.java
net.uyghurdev.avaroid.picturebookreader.GetOnlineBookInfo.java
net.uyghurdev.avaroid.picturebookreader.ImageLoader.java
net.uyghurdev.avaroid.picturebookreader.JSONManager.java
net.uyghurdev.avaroid.picturebookreader.LocalBook.java
net.uyghurdev.avaroid.picturebookreader.MemoryCache.java
net.uyghurdev.avaroid.picturebookreader.NetWorkOperator.java
net.uyghurdev.avaroid.picturebookreader.OnlineBookAdapter.java
net.uyghurdev.avaroid.picturebookreader.OnlineBooks.java
net.uyghurdev.avaroid.picturebookreader.OnlineGBookAdapter.java
net.uyghurdev.avaroid.picturebookreader.PlayOrder1.java
net.uyghurdev.avaroid.picturebookreader.ReadBook.java
net.uyghurdev.avaroid.picturebookreader.RecentBooksAdapter.java
net.uyghurdev.avaroid.picturebookreader.RecentGBooksAdapter.java
net.uyghurdev.avaroid.picturebookreader.Splash.java
net.uyghurdev.avaroid.picturebookreader.Utils.java
net.uyghurdev.avaroid.picturebookreader.XMLContent.java
net.uyghurdev.avaroid.picturebookreader.XMLHandler.java