コード例 #1
0
 @Override
 protected String doInBackground(String... params) {
   try {
     JSONObject o = NetworkConnection.getInstance().fetchJSON(params[0]);
     if (o.getString("item_type").equalsIgnoreCase("image")) return o.getString("content_url");
   } catch (Exception e) {
   }
   return null;
 }
コード例 #2
0
    @Override
    protected String doInBackground(String... params) {
      try {
        JSONObject o = NetworkConnection.getInstance().fetchJSON(params[0]);
        if (o.has("provider_name")) provider = o.getString("provider_name");

        if ((provider != null && provider.equals("Giphy"))
            || o.getString("type").equalsIgnoreCase("photo")) return o.getString("url");
      } catch (Exception e) {
      }
      return null;
    }
コード例 #3
0
 @Override
 protected String doInBackground(String... params) {
   try {
     JSONObject o = NetworkConnection.getInstance().fetchJSON(params[0]);
     JSONObject pages = o.getJSONObject("query").getJSONObject("pages");
     Iterator<String> i = pages.keys();
     String pageid = i.next();
     return pages
         .getJSONObject(pageid)
         .getJSONArray("imageinfo")
         .getJSONObject(0)
         .getString("url");
   } catch (Exception e) {
   }
   return null;
 }
コード例 #4
0
 @Override
 protected String doInBackground(String... params) {
   try {
     HashMap<String, String> headers = new HashMap<>();
     if (BuildConfig.MASHAPE_KEY.length() > 0)
       headers.put("X-Mashape-Authorization", BuildConfig.MASHAPE_KEY);
     headers.put("Authorization", "Client-ID " + BuildConfig.IMGUR_KEY);
     JSONObject o = NetworkConnection.getInstance().fetchJSON(IMAGE_URL + params[0], headers);
     if (o.getBoolean("success")) {
       JSONObject data = o.getJSONObject("data");
       if (data.getString("type").startsWith("image/") && !data.getBoolean("animated"))
         return data.getString("link");
       else if (data.getBoolean("animated")) return data.getString("mp4");
     }
   } catch (Exception e) {
   }
   return null;
 }
コード例 #5
0
 @Override
 protected String doInBackground(String... params) {
   try {
     HashMap<String, String> headers = new HashMap<>();
     JSONObject o =
         NetworkConnection.getInstance()
             .fetchJSON("https://gfycat.com/cajax/get/" + params[0], headers);
     if (o.has("gfyItem")) {
       JSONObject data = o.getJSONObject("gfyItem");
       if (data.has("mp4Url") && data.getString("mp4Url").length() > 0)
         return data.getString("mp4Url");
       else if (data.has("gifUrl") && data.getString("gifUrl").length() > 0)
         return data.getString("gifUrl");
     }
   } catch (Exception e) {
   }
   return null;
 }
コード例 #6
0
 @Override
 protected String doInBackground(String... params) {
   try {
     HashMap<String, String> headers = new HashMap<>();
     JSONObject o =
         NetworkConnection.getInstance()
             .fetchJSON(
                 "https://api.giphy.com/v1/gifs/" + params[0] + "?api_key=dc6zaTOxFJmzC",
                 headers);
     if (o.has("data") && o.getJSONObject("data").has("images")) {
       JSONObject data =
           o.getJSONObject("data").getJSONObject("images").getJSONObject("original");
       if (data.has("mp4") && data.getString("mp4").length() > 0) return data.getString("mp4");
       else if (data.getString("url").endsWith(".gif")) return data.getString("url");
     }
   } catch (Exception e) {
   }
   return null;
 }