Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
/**
 *  g2-java-client, a Menalto Gallery2 Java Client API
 *  URLs: https://github.com/anthonydahanne/ReGalAndroid , http://blog.dahanne.net
 *  Copyright (c) 2010 Anthony Dahanne
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program. If not, see <http://www.gnu.org/licenses/>.
 */

public class Main {
    static final String BASE_URL_DEF = "main.php?g2_view=core.DownloadItem&g2_itemId=";
    static final String EMBEDDED_GALLERY_BASE_URL_DEF = "&g2_view=core.DownloadItem&g2_itemId=";

    /** Get the baseUrl */
    public static String getBaseUrl(String galleryUrl) {
        // bug #25 : for embedded gallery, should not add main.php
        if (isEmbeddedGallery(galleryUrl)) {
            return new StringBuilder().append(galleryUrl).append(EMBEDDED_GALLERY_BASE_URL_DEF).toString();
        }
        return new StringBuilder().append(galleryUrl).append("/").append(BASE_URL_DEF).toString();

    }

    public static boolean isEmbeddedGallery(String url) {
        if (url.contains("action=gallery")) {
            return true;
        }
        return false;
    }
}