Back to project page GuildViewerApp2.
The source code is released under:
Apache License
If you think the Android project GuildViewerApp2 listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.skywomantechnology.app.guildviewer.data; // ww w . j a v a2 s .c o m /* * Guild Viewer is an Android app that allows users to view news feeds and news feed details * on a mobile device and while not logged into the game servers. * * Copyright 2014 Sky Woman Technology LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import android.content.ContentUris; import android.net.Uri; import android.provider.BaseColumns; /** * This tells the content provider how to access the data */ public class GuildViewerContract { public static final String CONTENT_AUTHORITY = "com.skywomantechnology.app.guildviewer"; private static final Uri BASE_CONTENT_URI = Uri.parse("content://" + CONTENT_AUTHORITY); //only dealing with news and items public static final String NEWS_PATH = "news"; public static final String ITEM_PATH = "item"; public static final String GUILD_PATH = "guild"; public static final String MEMBER_PATH = "member"; /** * This class handles the news items */ public static final class NewsEntry implements BaseColumns { public static final Uri CONTENT_URI = BASE_CONTENT_URI.buildUpon().appendPath(NEWS_PATH).build(); public static final String CONTENT_TYPE = "vnd.android.cursor.dir/" + CONTENT_AUTHORITY + "/" + NEWS_PATH; public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/" + CONTENT_AUTHORITY + "/" + NEWS_PATH; // yeah I could do a join with the items table but that can // be for version 2.0 public static final String TABLE_NAME = "news"; public static final String COLUMN_GUILD = "guild"; public static final String COLUMN_REGION = "region"; public static final String COLUMN_REALM = "realm"; public static final String COLUMN_TYPE = "type"; public static final String COLUMN_TIMESTAMP = "timestamp"; public static final String COLUMN_CHARACTER = "character"; public static final String COLUMN_CHARACTER_ICON = "character_icon"; public static final String COLUMN_ITEM_ID = "item_id"; public static final String COLUMN_ITEM_NAME = "item_name"; public static final String COLUMN_ITEM_ICON = "item_icon"; public static final String COLUMN_ITEM_DESCRIPTION = "item_description"; public static final String COLUMN_ACHIEVEMENT_TITLE = "achievement_title"; public static final String COLUMN_ACHIEVEMENT_DESCRIPTION = "achievement_description"; public static final String COLUMN_ACHIEVEMENT_ICON = "achievement_icon"; public static Uri buildNewsListUri() { return CONTENT_URI; } public static Uri buildNewsListUriWithId(long id) { return ContentUris.withAppendedId(CONTENT_URI, id); } public static String getRegionFromUri(Uri uri) { return uri.getPathSegments().get(1); } public static String getRealmFromUri(Uri uri) { return uri.getPathSegments().get(2); } public static String getGuildFromUri(Uri uri) { return uri.getPathSegments().get(3); } public static Uri buildNewsListWithRegionRealmGuild(String region, String realm, String guild) { return CONTENT_URI.buildUpon().appendPath(region) .appendPath(realm) .appendPath(guild).build(); } } /** * This class handles Items that are looted, purchased or crafted */ public static final class ItemEntry implements BaseColumns { public static final Uri CONTENT_URI = BASE_CONTENT_URI.buildUpon().appendPath(ITEM_PATH).build(); public static final String CONTENT_TYPE = "vnd.android.cursor.dir/" + CONTENT_AUTHORITY + "/" + ITEM_PATH; public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/" + CONTENT_AUTHORITY + "/" + ITEM_PATH; public static final String TABLE_NAME = "items"; public static final String COLUMN_ITEM_ID = "item_id"; public static final String COLUMN_NAME = "name"; public static final String COLUMN_ICON = "icon"; public static final String COLUMN_DESCRIPTION = "description"; public static String getItemIdFromUri(Uri uri) { return uri.getPathSegments().get(1); } public static Uri buildNewsItemUriWithItemId(String item_id) { return CONTENT_URI.buildUpon().appendPath(item_id).build(); } } /** * This class handles Guild Information */ public static final class GuildEntry implements BaseColumns { public static final Uri CONTENT_URI = BASE_CONTENT_URI.buildUpon().appendPath(GUILD_PATH).build(); public static final String CONTENT_TYPE = "vnd.android.cursor.dir/" + CONTENT_AUTHORITY + "/" + GUILD_PATH; public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/" + CONTENT_AUTHORITY + "/" + GUILD_PATH; public static final String TABLE_NAME = "guilds"; public static final String COLUMN_NAME = "name"; public static final String COLUMN_REGION = "region"; public static final String COLUMN_REALM = "realm"; public static final String COLUMN_LAST_MODIFIED = "last_modified"; public static final String COLUMN_BATTLEGROUP = "battlegroup"; public static final String COLUMN_LEVEL = "level"; public static final String COLUMN_SIDE = "side"; public static final String COLUMN_POINTS = "points"; public static int getGuildIdFromUri(Uri uri) { return Integer.parseInt(uri.getPathSegments().get(1)); } public static Uri buildGuildUriWithId(long id) { return ContentUris.withAppendedId(CONTENT_URI, id); } } /** * This class handles Guild Member Information */ public static final class MemberEntry implements BaseColumns { public static final Uri CONTENT_URI = BASE_CONTENT_URI.buildUpon() .appendPath(GUILD_PATH) .appendPath(MEMBER_PATH).build(); public static final String CONTENT_TYPE = "vnd.android.cursor.dir/" + CONTENT_AUTHORITY + "/" + GUILD_PATH + "/" + MEMBER_PATH; public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/" + CONTENT_AUTHORITY + "/" + GUILD_PATH + "/" + MEMBER_PATH; public static final String TABLE_NAME = "members"; public static final String COLUMN_NAME = "name"; public static final String COLUMN_GUILD_ID = "guildId"; public static final String COLUMN_LEVEL = "level"; public static final String COLUMN_GENDER = "gender"; public static final String COLUMN_RACE = "race"; public static final String COLUMN_CLASS ="class"; public static final String COLUMN_SIDE = "side"; public static final String COLUMN_RANK = "rank"; public static final String COLUMN_POINTS = "points"; public static final String COLUMN_THUMBNAIL = "thumbnail"; public static String getMemberIdFromUri(Uri uri) { return uri.getPathSegments().get(2); } public static String getMemberNameFromUri(Uri uri) { return uri.getPathSegments().get(2); } public static Uri buildGuildMemberUriWithId(long id) { return ContentUris.withAppendedId(CONTENT_URI, id); } public static Uri buildGuildMemberUriWithName(String name) { return CONTENT_URI.buildUpon().appendPath(name).build(); } } }