Android Open Source - TheGamesDB-Android-app Url Maker






From Project

Back to project page TheGamesDB-Android-app.

License

The source code is released under:

GNU General Public License

If you think the Android project TheGamesDB-Android-app 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 dragni.tgb.thegamesdb.util;
//from  w  ww. jav  a2 s.c  om
import java.net.MalformedURLException;
import java.net.URL;

public class UrlMaker {
  private static String baseUrl = "http://thegamesdb.net/api/";
  private static String getGameBaseUrl = "GetGame.php";
  private static String baseImgUrl = "http://thegamesdb.net/banners/";

  public URL getGameByIdUrl(int id) {
    URL url = null;

    try {
      String link = baseUrl + getGameBaseUrl + "?id=" + id;
      url = new URL(link);
    } catch (MalformedURLException e) {
      // TODO: handle error
    }
    return url;
  }

  public URL getGameByNameUrl(String name) {
    URL url = null;
    name = name.replace(" ", "+");

    try {
      String link = baseUrl + getGameBaseUrl + "?name=" + name;
      url = new URL(link);
    } catch (MalformedURLException e) {
      // TODO: handle error
    }
    return url;
  }

  public URL getGameByNameAndPlatformUrl(String name, String platform) {
    URL url = null;
    name = name.replace(" ", "+");
    platform = platform.replace(" ", "+");

    try {
      String link = baseUrl + getGameBaseUrl + "?name=" + name
          + "&platform=" + platform;
      url = new URL(link);
    } catch (MalformedURLException e) {
      // TODO: handle error
    }
    return url;
  }

  public String getGameImageUrl(String relativePath) {
    String url = null;
    url = baseImgUrl + relativePath;
    return url;
  }
}




Java Source Code List

dragni.tgb.thegamesdb.entity.GameList.java
dragni.tgb.thegamesdb.entity.Game.java
dragni.tgb.thegamesdb.entity.ImageList.java
dragni.tgb.thegamesdb.entity.Image.java
dragni.tgb.thegamesdb.logic.GameSearcher.java
dragni.tgb.thegamesdb.util.GameListSorter.java
dragni.tgb.thegamesdb.util.SearchType.java
dragni.tgb.thegamesdb.util.UrlMaker.java
dragni.tgb.thegamesdb.views.FragmentGameImages.java
dragni.tgb.thegamesdb.views.FragmentGameInformation.java
dragni.tgb.thegamesdb.views.FragmentGameVideos.java
dragni.tgb.thegamesdb.views.GameListActivity.java
dragni.tgb.thegamesdb.views.GameOverviewActivity.java
dragni.tgb.thegamesdb.views.ImageAdapter.java
dragni.tgb.thegamesdb.views.ImageZoomActivity.java
dragni.tgb.thegamesdb.views.ListAdapter.java
dragni.tgb.thegamesdb.views.SearchActivity.java
dragni.tgb.thegamesdb.views.ViewPagerAdapter.java