repo_name
stringlengths 7
104
| file_path
stringlengths 13
198
| context
stringlengths 67
7.15k
| import_statement
stringlengths 16
4.43k
| code
stringlengths 40
6.98k
| prompt
stringlengths 227
8.27k
| next_line
stringlengths 8
795
|
---|---|---|---|---|---|---|
MiniDigger/projecttd | core/src/me/minidigger/projecttd/systems/PathFindingSystem.java | // Path: core/src/me/minidigger/projecttd/components/PathComponent.java
// public class PathComponent implements Component, Pool.Poolable {
//
// public int tilesToGoal = -1;
// public Vector2 nextPoint;
// public PathFindingSystem.GoalReachedAction completed = (e) -> {
// };
//
// @Override
// public void reset() {
// tilesToGoal = -1;
// nextPoint = null;
// completed = (e) -> {
// };
// }
// }
//
// Path: core/src/me/minidigger/projecttd/components/TransformComponent.java
// public class TransformComponent implements Component, Pool.Poolable {
//
// public Vector2 position;
// public float rotation = 0f;
//
// @Override
// public void reset() {
// position = new Vector2();
// rotation = 0f;
// }
// }
//
// Path: core/src/me/minidigger/projecttd/utils/CoordinateUtil.java
// public class CoordinateUtil {
//
// private static Vector3 vector3 = new Vector3();
//
// public static Vector2 touchToWorld(Vector2 point, Camera camera) {
// vector3.set(point, 0);
// camera.unproject(vector3);
// point.set(vector3.x, vector3.y);
// return point;
// }
//
// public static Vector2 worldToTouch(Vector2 point, Camera camera) {
// vector3.set(point, 0);
// camera.project(vector3);
// point.set(vector3.x, vector3.y);
// return point;
// }
//
// public static Vector2 alignToGrid(Vector2 input) {
// input.x = (int) (input.x) + 0.5f;
// input.y = (int) (input.y) + 0.5f;
// return input;
// }
// }
//
// Path: core/src/me/minidigger/projecttd/utils/Vector2i.java
// public class Vector2i {
//
// public int x;
// public int y;
//
// public Vector2i(int x, int y) {
// this.x = x;
// this.y = y;
// }
//
// @Override
// public String toString() {
// return "Vector2i{" +
// "x=" + x +
// ", y=" + y +
// '}';
// }
// }
| import com.badlogic.ashley.core.ComponentMapper;
import com.badlogic.ashley.core.Entity;
import com.badlogic.ashley.core.Family;
import com.badlogic.ashley.systems.IteratingSystem;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Camera;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import com.badlogic.gdx.maps.tiled.TiledMap;
import com.badlogic.gdx.maps.tiled.TiledMapTileLayer;
import com.badlogic.gdx.math.Vector2;
import me.minidigger.projecttd.components.PathComponent;
import me.minidigger.projecttd.components.TransformComponent;
import me.minidigger.projecttd.utils.CoordinateUtil;
import me.minidigger.projecttd.utils.Vector2i;
import java.util.LinkedList;
import java.util.Queue; | package me.minidigger.projecttd.systems;
/**
* Created by mbenndorf on 13.04.2017.
*/
public class PathFindingSystem extends IteratingSystem {
private final int mapWidth;
private final int mapHeight;
private final TileType[][] map;
private int[][] cost;
private boolean[][] visited;
private Vector2[][] direction;
private Vector2 goal;
| // Path: core/src/me/minidigger/projecttd/components/PathComponent.java
// public class PathComponent implements Component, Pool.Poolable {
//
// public int tilesToGoal = -1;
// public Vector2 nextPoint;
// public PathFindingSystem.GoalReachedAction completed = (e) -> {
// };
//
// @Override
// public void reset() {
// tilesToGoal = -1;
// nextPoint = null;
// completed = (e) -> {
// };
// }
// }
//
// Path: core/src/me/minidigger/projecttd/components/TransformComponent.java
// public class TransformComponent implements Component, Pool.Poolable {
//
// public Vector2 position;
// public float rotation = 0f;
//
// @Override
// public void reset() {
// position = new Vector2();
// rotation = 0f;
// }
// }
//
// Path: core/src/me/minidigger/projecttd/utils/CoordinateUtil.java
// public class CoordinateUtil {
//
// private static Vector3 vector3 = new Vector3();
//
// public static Vector2 touchToWorld(Vector2 point, Camera camera) {
// vector3.set(point, 0);
// camera.unproject(vector3);
// point.set(vector3.x, vector3.y);
// return point;
// }
//
// public static Vector2 worldToTouch(Vector2 point, Camera camera) {
// vector3.set(point, 0);
// camera.project(vector3);
// point.set(vector3.x, vector3.y);
// return point;
// }
//
// public static Vector2 alignToGrid(Vector2 input) {
// input.x = (int) (input.x) + 0.5f;
// input.y = (int) (input.y) + 0.5f;
// return input;
// }
// }
//
// Path: core/src/me/minidigger/projecttd/utils/Vector2i.java
// public class Vector2i {
//
// public int x;
// public int y;
//
// public Vector2i(int x, int y) {
// this.x = x;
// this.y = y;
// }
//
// @Override
// public String toString() {
// return "Vector2i{" +
// "x=" + x +
// ", y=" + y +
// '}';
// }
// }
// Path: core/src/me/minidigger/projecttd/systems/PathFindingSystem.java
import com.badlogic.ashley.core.ComponentMapper;
import com.badlogic.ashley.core.Entity;
import com.badlogic.ashley.core.Family;
import com.badlogic.ashley.systems.IteratingSystem;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Camera;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import com.badlogic.gdx.maps.tiled.TiledMap;
import com.badlogic.gdx.maps.tiled.TiledMapTileLayer;
import com.badlogic.gdx.math.Vector2;
import me.minidigger.projecttd.components.PathComponent;
import me.minidigger.projecttd.components.TransformComponent;
import me.minidigger.projecttd.utils.CoordinateUtil;
import me.minidigger.projecttd.utils.Vector2i;
import java.util.LinkedList;
import java.util.Queue;
package me.minidigger.projecttd.systems;
/**
* Created by mbenndorf on 13.04.2017.
*/
public class PathFindingSystem extends IteratingSystem {
private final int mapWidth;
private final int mapHeight;
private final TileType[][] map;
private int[][] cost;
private boolean[][] visited;
private Vector2[][] direction;
private Vector2 goal;
| private ComponentMapper<TransformComponent> transformM = ComponentMapper.getFor(TransformComponent.class); |
MiniDigger/projecttd | core/src/me/minidigger/projecttd/systems/PathFindingSystem.java | // Path: core/src/me/minidigger/projecttd/components/PathComponent.java
// public class PathComponent implements Component, Pool.Poolable {
//
// public int tilesToGoal = -1;
// public Vector2 nextPoint;
// public PathFindingSystem.GoalReachedAction completed = (e) -> {
// };
//
// @Override
// public void reset() {
// tilesToGoal = -1;
// nextPoint = null;
// completed = (e) -> {
// };
// }
// }
//
// Path: core/src/me/minidigger/projecttd/components/TransformComponent.java
// public class TransformComponent implements Component, Pool.Poolable {
//
// public Vector2 position;
// public float rotation = 0f;
//
// @Override
// public void reset() {
// position = new Vector2();
// rotation = 0f;
// }
// }
//
// Path: core/src/me/minidigger/projecttd/utils/CoordinateUtil.java
// public class CoordinateUtil {
//
// private static Vector3 vector3 = new Vector3();
//
// public static Vector2 touchToWorld(Vector2 point, Camera camera) {
// vector3.set(point, 0);
// camera.unproject(vector3);
// point.set(vector3.x, vector3.y);
// return point;
// }
//
// public static Vector2 worldToTouch(Vector2 point, Camera camera) {
// vector3.set(point, 0);
// camera.project(vector3);
// point.set(vector3.x, vector3.y);
// return point;
// }
//
// public static Vector2 alignToGrid(Vector2 input) {
// input.x = (int) (input.x) + 0.5f;
// input.y = (int) (input.y) + 0.5f;
// return input;
// }
// }
//
// Path: core/src/me/minidigger/projecttd/utils/Vector2i.java
// public class Vector2i {
//
// public int x;
// public int y;
//
// public Vector2i(int x, int y) {
// this.x = x;
// this.y = y;
// }
//
// @Override
// public String toString() {
// return "Vector2i{" +
// "x=" + x +
// ", y=" + y +
// '}';
// }
// }
| import com.badlogic.ashley.core.ComponentMapper;
import com.badlogic.ashley.core.Entity;
import com.badlogic.ashley.core.Family;
import com.badlogic.ashley.systems.IteratingSystem;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Camera;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import com.badlogic.gdx.maps.tiled.TiledMap;
import com.badlogic.gdx.maps.tiled.TiledMapTileLayer;
import com.badlogic.gdx.math.Vector2;
import me.minidigger.projecttd.components.PathComponent;
import me.minidigger.projecttd.components.TransformComponent;
import me.minidigger.projecttd.utils.CoordinateUtil;
import me.minidigger.projecttd.utils.Vector2i;
import java.util.LinkedList;
import java.util.Queue; | package me.minidigger.projecttd.systems;
/**
* Created by mbenndorf on 13.04.2017.
*/
public class PathFindingSystem extends IteratingSystem {
private final int mapWidth;
private final int mapHeight;
private final TileType[][] map;
private int[][] cost;
private boolean[][] visited;
private Vector2[][] direction;
private Vector2 goal;
private ComponentMapper<TransformComponent> transformM = ComponentMapper.getFor(TransformComponent.class); | // Path: core/src/me/minidigger/projecttd/components/PathComponent.java
// public class PathComponent implements Component, Pool.Poolable {
//
// public int tilesToGoal = -1;
// public Vector2 nextPoint;
// public PathFindingSystem.GoalReachedAction completed = (e) -> {
// };
//
// @Override
// public void reset() {
// tilesToGoal = -1;
// nextPoint = null;
// completed = (e) -> {
// };
// }
// }
//
// Path: core/src/me/minidigger/projecttd/components/TransformComponent.java
// public class TransformComponent implements Component, Pool.Poolable {
//
// public Vector2 position;
// public float rotation = 0f;
//
// @Override
// public void reset() {
// position = new Vector2();
// rotation = 0f;
// }
// }
//
// Path: core/src/me/minidigger/projecttd/utils/CoordinateUtil.java
// public class CoordinateUtil {
//
// private static Vector3 vector3 = new Vector3();
//
// public static Vector2 touchToWorld(Vector2 point, Camera camera) {
// vector3.set(point, 0);
// camera.unproject(vector3);
// point.set(vector3.x, vector3.y);
// return point;
// }
//
// public static Vector2 worldToTouch(Vector2 point, Camera camera) {
// vector3.set(point, 0);
// camera.project(vector3);
// point.set(vector3.x, vector3.y);
// return point;
// }
//
// public static Vector2 alignToGrid(Vector2 input) {
// input.x = (int) (input.x) + 0.5f;
// input.y = (int) (input.y) + 0.5f;
// return input;
// }
// }
//
// Path: core/src/me/minidigger/projecttd/utils/Vector2i.java
// public class Vector2i {
//
// public int x;
// public int y;
//
// public Vector2i(int x, int y) {
// this.x = x;
// this.y = y;
// }
//
// @Override
// public String toString() {
// return "Vector2i{" +
// "x=" + x +
// ", y=" + y +
// '}';
// }
// }
// Path: core/src/me/minidigger/projecttd/systems/PathFindingSystem.java
import com.badlogic.ashley.core.ComponentMapper;
import com.badlogic.ashley.core.Entity;
import com.badlogic.ashley.core.Family;
import com.badlogic.ashley.systems.IteratingSystem;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Camera;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import com.badlogic.gdx.maps.tiled.TiledMap;
import com.badlogic.gdx.maps.tiled.TiledMapTileLayer;
import com.badlogic.gdx.math.Vector2;
import me.minidigger.projecttd.components.PathComponent;
import me.minidigger.projecttd.components.TransformComponent;
import me.minidigger.projecttd.utils.CoordinateUtil;
import me.minidigger.projecttd.utils.Vector2i;
import java.util.LinkedList;
import java.util.Queue;
package me.minidigger.projecttd.systems;
/**
* Created by mbenndorf on 13.04.2017.
*/
public class PathFindingSystem extends IteratingSystem {
private final int mapWidth;
private final int mapHeight;
private final TileType[][] map;
private int[][] cost;
private boolean[][] visited;
private Vector2[][] direction;
private Vector2 goal;
private ComponentMapper<TransformComponent> transformM = ComponentMapper.getFor(TransformComponent.class); | private ComponentMapper<PathComponent> pathM = ComponentMapper.getFor(PathComponent.class); |
MiniDigger/projecttd | core/src/me/minidigger/projecttd/systems/PathFindingSystem.java | // Path: core/src/me/minidigger/projecttd/components/PathComponent.java
// public class PathComponent implements Component, Pool.Poolable {
//
// public int tilesToGoal = -1;
// public Vector2 nextPoint;
// public PathFindingSystem.GoalReachedAction completed = (e) -> {
// };
//
// @Override
// public void reset() {
// tilesToGoal = -1;
// nextPoint = null;
// completed = (e) -> {
// };
// }
// }
//
// Path: core/src/me/minidigger/projecttd/components/TransformComponent.java
// public class TransformComponent implements Component, Pool.Poolable {
//
// public Vector2 position;
// public float rotation = 0f;
//
// @Override
// public void reset() {
// position = new Vector2();
// rotation = 0f;
// }
// }
//
// Path: core/src/me/minidigger/projecttd/utils/CoordinateUtil.java
// public class CoordinateUtil {
//
// private static Vector3 vector3 = new Vector3();
//
// public static Vector2 touchToWorld(Vector2 point, Camera camera) {
// vector3.set(point, 0);
// camera.unproject(vector3);
// point.set(vector3.x, vector3.y);
// return point;
// }
//
// public static Vector2 worldToTouch(Vector2 point, Camera camera) {
// vector3.set(point, 0);
// camera.project(vector3);
// point.set(vector3.x, vector3.y);
// return point;
// }
//
// public static Vector2 alignToGrid(Vector2 input) {
// input.x = (int) (input.x) + 0.5f;
// input.y = (int) (input.y) + 0.5f;
// return input;
// }
// }
//
// Path: core/src/me/minidigger/projecttd/utils/Vector2i.java
// public class Vector2i {
//
// public int x;
// public int y;
//
// public Vector2i(int x, int y) {
// this.x = x;
// this.y = y;
// }
//
// @Override
// public String toString() {
// return "Vector2i{" +
// "x=" + x +
// ", y=" + y +
// '}';
// }
// }
| import com.badlogic.ashley.core.ComponentMapper;
import com.badlogic.ashley.core.Entity;
import com.badlogic.ashley.core.Family;
import com.badlogic.ashley.systems.IteratingSystem;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Camera;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import com.badlogic.gdx.maps.tiled.TiledMap;
import com.badlogic.gdx.maps.tiled.TiledMapTileLayer;
import com.badlogic.gdx.math.Vector2;
import me.minidigger.projecttd.components.PathComponent;
import me.minidigger.projecttd.components.TransformComponent;
import me.minidigger.projecttd.utils.CoordinateUtil;
import me.minidigger.projecttd.utils.Vector2i;
import java.util.LinkedList;
import java.util.Queue; | this.mapWidth = mapWidth;
map = new TileType[mapWidth][mapHeight];
TiledMapTileLayer path = (TiledMapTileLayer) tiledMap.getLayers().get("Path");
TiledMapTileLayer rocks = (TiledMapTileLayer) tiledMap.getLayers().get("Rocks");
TiledMapTileLayer bushes = (TiledMapTileLayer) tiledMap.getLayers().get("Bushes");
for (int x = 0; x < map.length; x++) {
for (int y = 0; y < map[x].length; y++) {
if (path.getCell(x, y) != null) {
map[x][y] = TileType.FLOOR;
} else if (rocks.getCell(x, y) != null || bushes.getCell(x, y) != null) {
map[x][y] = TileType.WALL;
} else {
map[x][y] = TileType.EMPTY;
}
}
}
}
public void init(Vector2 goal) {
goal = goal.set((int) goal.x, (int) goal.y);
this.goal = goal; // save for later recalculation
cost = new int[mapWidth][mapHeight];
visited = new boolean[mapWidth][mapHeight];
direction = new Vector2[mapWidth][mapHeight];
// wavefront (bfs) | // Path: core/src/me/minidigger/projecttd/components/PathComponent.java
// public class PathComponent implements Component, Pool.Poolable {
//
// public int tilesToGoal = -1;
// public Vector2 nextPoint;
// public PathFindingSystem.GoalReachedAction completed = (e) -> {
// };
//
// @Override
// public void reset() {
// tilesToGoal = -1;
// nextPoint = null;
// completed = (e) -> {
// };
// }
// }
//
// Path: core/src/me/minidigger/projecttd/components/TransformComponent.java
// public class TransformComponent implements Component, Pool.Poolable {
//
// public Vector2 position;
// public float rotation = 0f;
//
// @Override
// public void reset() {
// position = new Vector2();
// rotation = 0f;
// }
// }
//
// Path: core/src/me/minidigger/projecttd/utils/CoordinateUtil.java
// public class CoordinateUtil {
//
// private static Vector3 vector3 = new Vector3();
//
// public static Vector2 touchToWorld(Vector2 point, Camera camera) {
// vector3.set(point, 0);
// camera.unproject(vector3);
// point.set(vector3.x, vector3.y);
// return point;
// }
//
// public static Vector2 worldToTouch(Vector2 point, Camera camera) {
// vector3.set(point, 0);
// camera.project(vector3);
// point.set(vector3.x, vector3.y);
// return point;
// }
//
// public static Vector2 alignToGrid(Vector2 input) {
// input.x = (int) (input.x) + 0.5f;
// input.y = (int) (input.y) + 0.5f;
// return input;
// }
// }
//
// Path: core/src/me/minidigger/projecttd/utils/Vector2i.java
// public class Vector2i {
//
// public int x;
// public int y;
//
// public Vector2i(int x, int y) {
// this.x = x;
// this.y = y;
// }
//
// @Override
// public String toString() {
// return "Vector2i{" +
// "x=" + x +
// ", y=" + y +
// '}';
// }
// }
// Path: core/src/me/minidigger/projecttd/systems/PathFindingSystem.java
import com.badlogic.ashley.core.ComponentMapper;
import com.badlogic.ashley.core.Entity;
import com.badlogic.ashley.core.Family;
import com.badlogic.ashley.systems.IteratingSystem;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Camera;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import com.badlogic.gdx.maps.tiled.TiledMap;
import com.badlogic.gdx.maps.tiled.TiledMapTileLayer;
import com.badlogic.gdx.math.Vector2;
import me.minidigger.projecttd.components.PathComponent;
import me.minidigger.projecttd.components.TransformComponent;
import me.minidigger.projecttd.utils.CoordinateUtil;
import me.minidigger.projecttd.utils.Vector2i;
import java.util.LinkedList;
import java.util.Queue;
this.mapWidth = mapWidth;
map = new TileType[mapWidth][mapHeight];
TiledMapTileLayer path = (TiledMapTileLayer) tiledMap.getLayers().get("Path");
TiledMapTileLayer rocks = (TiledMapTileLayer) tiledMap.getLayers().get("Rocks");
TiledMapTileLayer bushes = (TiledMapTileLayer) tiledMap.getLayers().get("Bushes");
for (int x = 0; x < map.length; x++) {
for (int y = 0; y < map[x].length; y++) {
if (path.getCell(x, y) != null) {
map[x][y] = TileType.FLOOR;
} else if (rocks.getCell(x, y) != null || bushes.getCell(x, y) != null) {
map[x][y] = TileType.WALL;
} else {
map[x][y] = TileType.EMPTY;
}
}
}
}
public void init(Vector2 goal) {
goal = goal.set((int) goal.x, (int) goal.y);
this.goal = goal; // save for later recalculation
cost = new int[mapWidth][mapHeight];
visited = new boolean[mapWidth][mapHeight];
direction = new Vector2[mapWidth][mapHeight];
// wavefront (bfs) | Queue<Vector2i> queue = new LinkedList<>(); |
MiniDigger/projecttd | core/src/me/minidigger/projecttd/systems/PathFindingSystem.java | // Path: core/src/me/minidigger/projecttd/components/PathComponent.java
// public class PathComponent implements Component, Pool.Poolable {
//
// public int tilesToGoal = -1;
// public Vector2 nextPoint;
// public PathFindingSystem.GoalReachedAction completed = (e) -> {
// };
//
// @Override
// public void reset() {
// tilesToGoal = -1;
// nextPoint = null;
// completed = (e) -> {
// };
// }
// }
//
// Path: core/src/me/minidigger/projecttd/components/TransformComponent.java
// public class TransformComponent implements Component, Pool.Poolable {
//
// public Vector2 position;
// public float rotation = 0f;
//
// @Override
// public void reset() {
// position = new Vector2();
// rotation = 0f;
// }
// }
//
// Path: core/src/me/minidigger/projecttd/utils/CoordinateUtil.java
// public class CoordinateUtil {
//
// private static Vector3 vector3 = new Vector3();
//
// public static Vector2 touchToWorld(Vector2 point, Camera camera) {
// vector3.set(point, 0);
// camera.unproject(vector3);
// point.set(vector3.x, vector3.y);
// return point;
// }
//
// public static Vector2 worldToTouch(Vector2 point, Camera camera) {
// vector3.set(point, 0);
// camera.project(vector3);
// point.set(vector3.x, vector3.y);
// return point;
// }
//
// public static Vector2 alignToGrid(Vector2 input) {
// input.x = (int) (input.x) + 0.5f;
// input.y = (int) (input.y) + 0.5f;
// return input;
// }
// }
//
// Path: core/src/me/minidigger/projecttd/utils/Vector2i.java
// public class Vector2i {
//
// public int x;
// public int y;
//
// public Vector2i(int x, int y) {
// this.x = x;
// this.y = y;
// }
//
// @Override
// public String toString() {
// return "Vector2i{" +
// "x=" + x +
// ", y=" + y +
// '}';
// }
// }
| import com.badlogic.ashley.core.ComponentMapper;
import com.badlogic.ashley.core.Entity;
import com.badlogic.ashley.core.Family;
import com.badlogic.ashley.systems.IteratingSystem;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Camera;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import com.badlogic.gdx.maps.tiled.TiledMap;
import com.badlogic.gdx.maps.tiled.TiledMapTileLayer;
import com.badlogic.gdx.math.Vector2;
import me.minidigger.projecttd.components.PathComponent;
import me.minidigger.projecttd.components.TransformComponent;
import me.minidigger.projecttd.utils.CoordinateUtil;
import me.minidigger.projecttd.utils.Vector2i;
import java.util.LinkedList;
import java.util.Queue; | pathComponent.tilesToGoal = cost[x][y];
pathComponent.nextPoint = new Vector2(x + 0.5f, y + 0.5f).add(dir);
}
}
// do nothing
else {
pathComponent.tilesToGoal = -1;
pathComponent.nextPoint = null;
}
}
public void debugRender(ShapeRenderer shapeRenderer, SpriteBatch spriteBatch, BitmapFont font, Camera camera) {
// box
shapeRenderer.begin(ShapeRenderer.ShapeType.Line);
shapeRenderer.setColor(Color.BLACK);
for (float x = 0; x < mapWidth; x++) {
for (float y = 0; y < mapHeight; y++) {
shapeRenderer.box(x, y, 0, 1f, 1f, 0f);
}
}
shapeRenderer.end();
// fps
spriteBatch.begin();
font.setColor(Color.RED);
font.draw(spriteBatch, Gdx.graphics.getFramesPerSecond() + "", 0, 15);
font.setColor(Color.WHITE);
// costs + cords
for (int x = 0; x < mapWidth; x++) {
for (int y = 0; y < mapHeight; y++) {
Vector2 point = new Vector2(x, y + 1); | // Path: core/src/me/minidigger/projecttd/components/PathComponent.java
// public class PathComponent implements Component, Pool.Poolable {
//
// public int tilesToGoal = -1;
// public Vector2 nextPoint;
// public PathFindingSystem.GoalReachedAction completed = (e) -> {
// };
//
// @Override
// public void reset() {
// tilesToGoal = -1;
// nextPoint = null;
// completed = (e) -> {
// };
// }
// }
//
// Path: core/src/me/minidigger/projecttd/components/TransformComponent.java
// public class TransformComponent implements Component, Pool.Poolable {
//
// public Vector2 position;
// public float rotation = 0f;
//
// @Override
// public void reset() {
// position = new Vector2();
// rotation = 0f;
// }
// }
//
// Path: core/src/me/minidigger/projecttd/utils/CoordinateUtil.java
// public class CoordinateUtil {
//
// private static Vector3 vector3 = new Vector3();
//
// public static Vector2 touchToWorld(Vector2 point, Camera camera) {
// vector3.set(point, 0);
// camera.unproject(vector3);
// point.set(vector3.x, vector3.y);
// return point;
// }
//
// public static Vector2 worldToTouch(Vector2 point, Camera camera) {
// vector3.set(point, 0);
// camera.project(vector3);
// point.set(vector3.x, vector3.y);
// return point;
// }
//
// public static Vector2 alignToGrid(Vector2 input) {
// input.x = (int) (input.x) + 0.5f;
// input.y = (int) (input.y) + 0.5f;
// return input;
// }
// }
//
// Path: core/src/me/minidigger/projecttd/utils/Vector2i.java
// public class Vector2i {
//
// public int x;
// public int y;
//
// public Vector2i(int x, int y) {
// this.x = x;
// this.y = y;
// }
//
// @Override
// public String toString() {
// return "Vector2i{" +
// "x=" + x +
// ", y=" + y +
// '}';
// }
// }
// Path: core/src/me/minidigger/projecttd/systems/PathFindingSystem.java
import com.badlogic.ashley.core.ComponentMapper;
import com.badlogic.ashley.core.Entity;
import com.badlogic.ashley.core.Family;
import com.badlogic.ashley.systems.IteratingSystem;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Camera;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import com.badlogic.gdx.maps.tiled.TiledMap;
import com.badlogic.gdx.maps.tiled.TiledMapTileLayer;
import com.badlogic.gdx.math.Vector2;
import me.minidigger.projecttd.components.PathComponent;
import me.minidigger.projecttd.components.TransformComponent;
import me.minidigger.projecttd.utils.CoordinateUtil;
import me.minidigger.projecttd.utils.Vector2i;
import java.util.LinkedList;
import java.util.Queue;
pathComponent.tilesToGoal = cost[x][y];
pathComponent.nextPoint = new Vector2(x + 0.5f, y + 0.5f).add(dir);
}
}
// do nothing
else {
pathComponent.tilesToGoal = -1;
pathComponent.nextPoint = null;
}
}
public void debugRender(ShapeRenderer shapeRenderer, SpriteBatch spriteBatch, BitmapFont font, Camera camera) {
// box
shapeRenderer.begin(ShapeRenderer.ShapeType.Line);
shapeRenderer.setColor(Color.BLACK);
for (float x = 0; x < mapWidth; x++) {
for (float y = 0; y < mapHeight; y++) {
shapeRenderer.box(x, y, 0, 1f, 1f, 0f);
}
}
shapeRenderer.end();
// fps
spriteBatch.begin();
font.setColor(Color.RED);
font.draw(spriteBatch, Gdx.graphics.getFramesPerSecond() + "", 0, 15);
font.setColor(Color.WHITE);
// costs + cords
for (int x = 0; x < mapWidth; x++) {
for (int y = 0; y < mapHeight; y++) {
Vector2 point = new Vector2(x, y + 1); | CoordinateUtil.worldToTouch(point, camera); |
MiniDigger/projecttd | core/src/me/minidigger/projecttd/screens/LevelSelectScreen.java | // Path: core/src/me/minidigger/projecttd/level/Level.java
// public class Level {
//
// private String name;
// private String file;
// private String author;
// private String thumbnail;
// private List<Wave> waves;
//
// public Level(String name, String file, String author, String thumbnail, List<Wave> waves) {
// this.name = name;
// this.file = file;
// this.author = author;
// this.thumbnail = thumbnail;
// this.waves = waves;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getFile() {
// return file;
// }
//
// public void setFile(String file) {
// this.file = file;
// }
//
// public String getAuthor() {
// return author;
// }
//
// public void setAuthor(String author) {
// this.author = author;
// }
//
// public String getThumbnail() {
// return thumbnail;
// }
//
// public void setThumbnail(String thumbnail) {
// this.thumbnail = thumbnail;
// }
//
// public List<Wave> getWaves() {
// return waves;
// }
//
// public void setWaves(List<Wave> waves) {
// this.waves = waves;
// }
// }
//
// Path: core/src/me/minidigger/projecttd/level/LevelManager.java
// public class LevelManager {
//
// private Gson gson = new GsonBuilder().setPrettyPrinting().create();
// private List<Level> levels = new ArrayList<>();
//
// private LevelManager() {
// load();
// }
//
// public List<Level> getLevels() {
// if (levels.size() == 0) {
// Vector2 spawn = new Vector2(1.5f, 9.5f);
// Vector2 goal = new Vector2(39.5f, 5.5f);
// Wave wave = new WaveBuilder().waveType(WaveType.NORMAL).name("Wave 1").points(100).money(10)
// .group().delay(5).interval(1).health(100).speed(6).type(Minion.MinionType.LAND).count(10).sprite(Minion.SPRITE).spawn(spawn).goal(goal).finish()
// .group().delay(20).interval(2).health(300).speed(4).type(Minion.MinionType.LAND).count(5).sprite(Minion.SPRITE).spawn(spawn).goal(goal).finish()
// .group().delay(30).interval(1).health(1000).speed(2).type(Minion.MinionType.LAND).count(1).sprite(Minion.SPRITE).spawn(spawn).goal(goal).finish()
// .build();
// List<Wave> waves = new ArrayList<>();
// waves.add(wave);
//
// levels.add(new Level("Map 1", "map01.tmx", "MiniDigger", "badlogic.jpg", waves));
//
// levels.add(new Level("Map 2", "map02.tmx", "MiniDigger", "badlogic.jpg", waves));
//
// //DEBUG DEBUG
// try (Writer writer = Gdx.files.absolute("maps/map01.json").writer(false)) {
// gson.toJson(levels.get(0), writer);
// } catch (IOException ex) {
// }
// try (Writer writer = Gdx.files.absolute("maps/map02.json").writer(false)) {
// gson.toJson(levels.get(1), writer);
// } catch (IOException ex) {
// }
//
// load();
// }
// return levels;
// }
//
// public void load() {
// levels = Arrays.stream(Gdx.files.internal("maps").list())
// .filter(f -> f.extension().equalsIgnoreCase("json"))
// .map(f -> gson.fromJson(f.reader(), Level.class))
// .filter(Objects::nonNull)
// .collect(Collectors.toList());
//
// Gdx.app.log("DEBUG", "Loaded " + levels.size() + " levels");
// }
//
// private static LevelManager instance = new LevelManager();
//
// public static LevelManager getInstance() {
// return instance;
// }
// }
| import com.badlogic.gdx.Game;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Screen;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
import com.badlogic.gdx.scenes.scene2d.utils.Drawable;
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;
import com.kotcrab.vis.ui.VisUI;
import com.kotcrab.vis.ui.building.CenteredTableBuilder;
import com.kotcrab.vis.ui.building.utilities.Padding;
import com.kotcrab.vis.ui.layout.GridGroup;
import com.kotcrab.vis.ui.widget.*;
import me.minidigger.projecttd.level.Level;
import me.minidigger.projecttd.level.LevelManager; | package me.minidigger.projecttd.screens;
/**
* Created by Martin on 29/04/2017.
*/
public class LevelSelectScreen implements Screen {
private Stage stage;
@Override
public void show() {
stage = new Stage();
Gdx.input.setInputProcessor(stage);
VisUI.load();
CenteredTableBuilder tableBuilder = new CenteredTableBuilder(new Padding(2, 3));
VisLabel heading = new VisLabel("Level Select");
heading.setColor(Color.BLACK);
tableBuilder.append(heading).row();
stage.addActor(heading);
| // Path: core/src/me/minidigger/projecttd/level/Level.java
// public class Level {
//
// private String name;
// private String file;
// private String author;
// private String thumbnail;
// private List<Wave> waves;
//
// public Level(String name, String file, String author, String thumbnail, List<Wave> waves) {
// this.name = name;
// this.file = file;
// this.author = author;
// this.thumbnail = thumbnail;
// this.waves = waves;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getFile() {
// return file;
// }
//
// public void setFile(String file) {
// this.file = file;
// }
//
// public String getAuthor() {
// return author;
// }
//
// public void setAuthor(String author) {
// this.author = author;
// }
//
// public String getThumbnail() {
// return thumbnail;
// }
//
// public void setThumbnail(String thumbnail) {
// this.thumbnail = thumbnail;
// }
//
// public List<Wave> getWaves() {
// return waves;
// }
//
// public void setWaves(List<Wave> waves) {
// this.waves = waves;
// }
// }
//
// Path: core/src/me/minidigger/projecttd/level/LevelManager.java
// public class LevelManager {
//
// private Gson gson = new GsonBuilder().setPrettyPrinting().create();
// private List<Level> levels = new ArrayList<>();
//
// private LevelManager() {
// load();
// }
//
// public List<Level> getLevels() {
// if (levels.size() == 0) {
// Vector2 spawn = new Vector2(1.5f, 9.5f);
// Vector2 goal = new Vector2(39.5f, 5.5f);
// Wave wave = new WaveBuilder().waveType(WaveType.NORMAL).name("Wave 1").points(100).money(10)
// .group().delay(5).interval(1).health(100).speed(6).type(Minion.MinionType.LAND).count(10).sprite(Minion.SPRITE).spawn(spawn).goal(goal).finish()
// .group().delay(20).interval(2).health(300).speed(4).type(Minion.MinionType.LAND).count(5).sprite(Minion.SPRITE).spawn(spawn).goal(goal).finish()
// .group().delay(30).interval(1).health(1000).speed(2).type(Minion.MinionType.LAND).count(1).sprite(Minion.SPRITE).spawn(spawn).goal(goal).finish()
// .build();
// List<Wave> waves = new ArrayList<>();
// waves.add(wave);
//
// levels.add(new Level("Map 1", "map01.tmx", "MiniDigger", "badlogic.jpg", waves));
//
// levels.add(new Level("Map 2", "map02.tmx", "MiniDigger", "badlogic.jpg", waves));
//
// //DEBUG DEBUG
// try (Writer writer = Gdx.files.absolute("maps/map01.json").writer(false)) {
// gson.toJson(levels.get(0), writer);
// } catch (IOException ex) {
// }
// try (Writer writer = Gdx.files.absolute("maps/map02.json").writer(false)) {
// gson.toJson(levels.get(1), writer);
// } catch (IOException ex) {
// }
//
// load();
// }
// return levels;
// }
//
// public void load() {
// levels = Arrays.stream(Gdx.files.internal("maps").list())
// .filter(f -> f.extension().equalsIgnoreCase("json"))
// .map(f -> gson.fromJson(f.reader(), Level.class))
// .filter(Objects::nonNull)
// .collect(Collectors.toList());
//
// Gdx.app.log("DEBUG", "Loaded " + levels.size() + " levels");
// }
//
// private static LevelManager instance = new LevelManager();
//
// public static LevelManager getInstance() {
// return instance;
// }
// }
// Path: core/src/me/minidigger/projecttd/screens/LevelSelectScreen.java
import com.badlogic.gdx.Game;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Screen;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
import com.badlogic.gdx.scenes.scene2d.utils.Drawable;
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;
import com.kotcrab.vis.ui.VisUI;
import com.kotcrab.vis.ui.building.CenteredTableBuilder;
import com.kotcrab.vis.ui.building.utilities.Padding;
import com.kotcrab.vis.ui.layout.GridGroup;
import com.kotcrab.vis.ui.widget.*;
import me.minidigger.projecttd.level.Level;
import me.minidigger.projecttd.level.LevelManager;
package me.minidigger.projecttd.screens;
/**
* Created by Martin on 29/04/2017.
*/
public class LevelSelectScreen implements Screen {
private Stage stage;
@Override
public void show() {
stage = new Stage();
Gdx.input.setInputProcessor(stage);
VisUI.load();
CenteredTableBuilder tableBuilder = new CenteredTableBuilder(new Padding(2, 3));
VisLabel heading = new VisLabel("Level Select");
heading.setColor(Color.BLACK);
tableBuilder.append(heading).row();
stage.addActor(heading);
| for (Level level : LevelManager.getInstance().getLevels()) { |
MiniDigger/projecttd | core/src/me/minidigger/projecttd/screens/LevelSelectScreen.java | // Path: core/src/me/minidigger/projecttd/level/Level.java
// public class Level {
//
// private String name;
// private String file;
// private String author;
// private String thumbnail;
// private List<Wave> waves;
//
// public Level(String name, String file, String author, String thumbnail, List<Wave> waves) {
// this.name = name;
// this.file = file;
// this.author = author;
// this.thumbnail = thumbnail;
// this.waves = waves;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getFile() {
// return file;
// }
//
// public void setFile(String file) {
// this.file = file;
// }
//
// public String getAuthor() {
// return author;
// }
//
// public void setAuthor(String author) {
// this.author = author;
// }
//
// public String getThumbnail() {
// return thumbnail;
// }
//
// public void setThumbnail(String thumbnail) {
// this.thumbnail = thumbnail;
// }
//
// public List<Wave> getWaves() {
// return waves;
// }
//
// public void setWaves(List<Wave> waves) {
// this.waves = waves;
// }
// }
//
// Path: core/src/me/minidigger/projecttd/level/LevelManager.java
// public class LevelManager {
//
// private Gson gson = new GsonBuilder().setPrettyPrinting().create();
// private List<Level> levels = new ArrayList<>();
//
// private LevelManager() {
// load();
// }
//
// public List<Level> getLevels() {
// if (levels.size() == 0) {
// Vector2 spawn = new Vector2(1.5f, 9.5f);
// Vector2 goal = new Vector2(39.5f, 5.5f);
// Wave wave = new WaveBuilder().waveType(WaveType.NORMAL).name("Wave 1").points(100).money(10)
// .group().delay(5).interval(1).health(100).speed(6).type(Minion.MinionType.LAND).count(10).sprite(Minion.SPRITE).spawn(spawn).goal(goal).finish()
// .group().delay(20).interval(2).health(300).speed(4).type(Minion.MinionType.LAND).count(5).sprite(Minion.SPRITE).spawn(spawn).goal(goal).finish()
// .group().delay(30).interval(1).health(1000).speed(2).type(Minion.MinionType.LAND).count(1).sprite(Minion.SPRITE).spawn(spawn).goal(goal).finish()
// .build();
// List<Wave> waves = new ArrayList<>();
// waves.add(wave);
//
// levels.add(new Level("Map 1", "map01.tmx", "MiniDigger", "badlogic.jpg", waves));
//
// levels.add(new Level("Map 2", "map02.tmx", "MiniDigger", "badlogic.jpg", waves));
//
// //DEBUG DEBUG
// try (Writer writer = Gdx.files.absolute("maps/map01.json").writer(false)) {
// gson.toJson(levels.get(0), writer);
// } catch (IOException ex) {
// }
// try (Writer writer = Gdx.files.absolute("maps/map02.json").writer(false)) {
// gson.toJson(levels.get(1), writer);
// } catch (IOException ex) {
// }
//
// load();
// }
// return levels;
// }
//
// public void load() {
// levels = Arrays.stream(Gdx.files.internal("maps").list())
// .filter(f -> f.extension().equalsIgnoreCase("json"))
// .map(f -> gson.fromJson(f.reader(), Level.class))
// .filter(Objects::nonNull)
// .collect(Collectors.toList());
//
// Gdx.app.log("DEBUG", "Loaded " + levels.size() + " levels");
// }
//
// private static LevelManager instance = new LevelManager();
//
// public static LevelManager getInstance() {
// return instance;
// }
// }
| import com.badlogic.gdx.Game;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Screen;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
import com.badlogic.gdx.scenes.scene2d.utils.Drawable;
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;
import com.kotcrab.vis.ui.VisUI;
import com.kotcrab.vis.ui.building.CenteredTableBuilder;
import com.kotcrab.vis.ui.building.utilities.Padding;
import com.kotcrab.vis.ui.layout.GridGroup;
import com.kotcrab.vis.ui.widget.*;
import me.minidigger.projecttd.level.Level;
import me.minidigger.projecttd.level.LevelManager; | package me.minidigger.projecttd.screens;
/**
* Created by Martin on 29/04/2017.
*/
public class LevelSelectScreen implements Screen {
private Stage stage;
@Override
public void show() {
stage = new Stage();
Gdx.input.setInputProcessor(stage);
VisUI.load();
CenteredTableBuilder tableBuilder = new CenteredTableBuilder(new Padding(2, 3));
VisLabel heading = new VisLabel("Level Select");
heading.setColor(Color.BLACK);
tableBuilder.append(heading).row();
stage.addActor(heading);
| // Path: core/src/me/minidigger/projecttd/level/Level.java
// public class Level {
//
// private String name;
// private String file;
// private String author;
// private String thumbnail;
// private List<Wave> waves;
//
// public Level(String name, String file, String author, String thumbnail, List<Wave> waves) {
// this.name = name;
// this.file = file;
// this.author = author;
// this.thumbnail = thumbnail;
// this.waves = waves;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getFile() {
// return file;
// }
//
// public void setFile(String file) {
// this.file = file;
// }
//
// public String getAuthor() {
// return author;
// }
//
// public void setAuthor(String author) {
// this.author = author;
// }
//
// public String getThumbnail() {
// return thumbnail;
// }
//
// public void setThumbnail(String thumbnail) {
// this.thumbnail = thumbnail;
// }
//
// public List<Wave> getWaves() {
// return waves;
// }
//
// public void setWaves(List<Wave> waves) {
// this.waves = waves;
// }
// }
//
// Path: core/src/me/minidigger/projecttd/level/LevelManager.java
// public class LevelManager {
//
// private Gson gson = new GsonBuilder().setPrettyPrinting().create();
// private List<Level> levels = new ArrayList<>();
//
// private LevelManager() {
// load();
// }
//
// public List<Level> getLevels() {
// if (levels.size() == 0) {
// Vector2 spawn = new Vector2(1.5f, 9.5f);
// Vector2 goal = new Vector2(39.5f, 5.5f);
// Wave wave = new WaveBuilder().waveType(WaveType.NORMAL).name("Wave 1").points(100).money(10)
// .group().delay(5).interval(1).health(100).speed(6).type(Minion.MinionType.LAND).count(10).sprite(Minion.SPRITE).spawn(spawn).goal(goal).finish()
// .group().delay(20).interval(2).health(300).speed(4).type(Minion.MinionType.LAND).count(5).sprite(Minion.SPRITE).spawn(spawn).goal(goal).finish()
// .group().delay(30).interval(1).health(1000).speed(2).type(Minion.MinionType.LAND).count(1).sprite(Minion.SPRITE).spawn(spawn).goal(goal).finish()
// .build();
// List<Wave> waves = new ArrayList<>();
// waves.add(wave);
//
// levels.add(new Level("Map 1", "map01.tmx", "MiniDigger", "badlogic.jpg", waves));
//
// levels.add(new Level("Map 2", "map02.tmx", "MiniDigger", "badlogic.jpg", waves));
//
// //DEBUG DEBUG
// try (Writer writer = Gdx.files.absolute("maps/map01.json").writer(false)) {
// gson.toJson(levels.get(0), writer);
// } catch (IOException ex) {
// }
// try (Writer writer = Gdx.files.absolute("maps/map02.json").writer(false)) {
// gson.toJson(levels.get(1), writer);
// } catch (IOException ex) {
// }
//
// load();
// }
// return levels;
// }
//
// public void load() {
// levels = Arrays.stream(Gdx.files.internal("maps").list())
// .filter(f -> f.extension().equalsIgnoreCase("json"))
// .map(f -> gson.fromJson(f.reader(), Level.class))
// .filter(Objects::nonNull)
// .collect(Collectors.toList());
//
// Gdx.app.log("DEBUG", "Loaded " + levels.size() + " levels");
// }
//
// private static LevelManager instance = new LevelManager();
//
// public static LevelManager getInstance() {
// return instance;
// }
// }
// Path: core/src/me/minidigger/projecttd/screens/LevelSelectScreen.java
import com.badlogic.gdx.Game;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Screen;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
import com.badlogic.gdx.scenes.scene2d.utils.Drawable;
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;
import com.kotcrab.vis.ui.VisUI;
import com.kotcrab.vis.ui.building.CenteredTableBuilder;
import com.kotcrab.vis.ui.building.utilities.Padding;
import com.kotcrab.vis.ui.layout.GridGroup;
import com.kotcrab.vis.ui.widget.*;
import me.minidigger.projecttd.level.Level;
import me.minidigger.projecttd.level.LevelManager;
package me.minidigger.projecttd.screens;
/**
* Created by Martin on 29/04/2017.
*/
public class LevelSelectScreen implements Screen {
private Stage stage;
@Override
public void show() {
stage = new Stage();
Gdx.input.setInputProcessor(stage);
VisUI.load();
CenteredTableBuilder tableBuilder = new CenteredTableBuilder(new Padding(2, 3));
VisLabel heading = new VisLabel("Level Select");
heading.setColor(Color.BLACK);
tableBuilder.append(heading).row();
stage.addActor(heading);
| for (Level level : LevelManager.getInstance().getLevels()) { |
MiniDigger/projecttd | core/src/me/minidigger/projecttd/systems/MoveToSystem.java | // Path: core/src/me/minidigger/projecttd/components/MinionComponent.java
// public class MinionComponent implements Component, Pool.Poolable {
//
// public int money = 1;
// public float speed = 1f;
// public Minion.MinionType type = Minion.MinionType.LAND;
// public int points = 10;
//
// @Override
// public void reset() {
// money = 1;
// speed = 1f;
// type = Minion.MinionType.LAND;
// points = 10;
// }
// }
//
// Path: core/src/me/minidigger/projecttd/components/PathComponent.java
// public class PathComponent implements Component, Pool.Poolable {
//
// public int tilesToGoal = -1;
// public Vector2 nextPoint;
// public PathFindingSystem.GoalReachedAction completed = (e) -> {
// };
//
// @Override
// public void reset() {
// tilesToGoal = -1;
// nextPoint = null;
// completed = (e) -> {
// };
// }
// }
//
// Path: core/src/me/minidigger/projecttd/components/TransformComponent.java
// public class TransformComponent implements Component, Pool.Poolable {
//
// public Vector2 position;
// public float rotation = 0f;
//
// @Override
// public void reset() {
// position = new Vector2();
// rotation = 0f;
// }
// }
//
// Path: core/src/me/minidigger/projecttd/components/VelocityComponent.java
// public class VelocityComponent implements Component, Pool.Poolable {
//
// public Vector2 linear = new Vector2();
// public float angular = 0f;
//
// @Override
// public void reset() {
// linear = new Vector2();
// angular = 0f;
// }
// }
//
// Path: core/src/me/minidigger/projecttd/entities/Minion.java
// public class Minion {
//
// public static PooledEngine ENGINE;
// public static Sprite SPRITE;
//
// public static Entity newMinion(Vector2 spawn) {
// Entity entity = ENGINE.createEntity();
//
// SpriteComponent spriteComponent = ENGINE.createComponent(SpriteComponent.class);
// spriteComponent.sprite = SPRITE;
// entity.add(spriteComponent);
//
// VelocityComponent velocityComponent = ENGINE.createComponent(VelocityComponent.class);
// entity.add(velocityComponent);
//
// TransformComponent transformComponent = ENGINE.createComponent(TransformComponent.class);
// transformComponent.position = spawn;
// entity.add(transformComponent);
//
// HealthComponent healthComponent = ENGINE.createComponent(HealthComponent.class);
// healthComponent.health = 100;
// entity.add(healthComponent);
//
// PathComponent pathComponent = ENGINE.createComponent(PathComponent.class);
// entity.add(pathComponent);
//
// MinionComponent minionComponent = ENGINE.createComponent(MinionComponent.class);
// entity.add(minionComponent);
//
// ENGINE.addEntity(entity);
// return entity;
// }
//
// public enum MinionType{
// LAND,
// WATER,
// AIR;
// }
// }
//
// Path: core/src/me/minidigger/projecttd/utils/VectorUtil.java
// public class VectorUtil {
//
// // returns radians
// public static float vectorToAngle(Vector2 vector) {
// return (float) Math.atan2(-vector.x, vector.y);
// }
//
// // angle = radians
// public static Vector2 angleToVector(Vector2 outVector, float angle) {
// outVector.x = -(float) Math.sin(angle);
// outVector.y = (float) Math.cos(angle);
// return outVector;
// }
// }
| import com.badlogic.ashley.core.ComponentMapper;
import com.badlogic.ashley.core.Entity;
import com.badlogic.ashley.core.Family;
import com.badlogic.ashley.systems.IteratingSystem;
import com.badlogic.gdx.ai.utils.ArithmeticUtils;
import com.badlogic.gdx.math.MathUtils;
import com.badlogic.gdx.math.Vector2;
import me.minidigger.projecttd.components.MinionComponent;
import me.minidigger.projecttd.components.PathComponent;
import me.minidigger.projecttd.components.TransformComponent;
import me.minidigger.projecttd.components.VelocityComponent;
import me.minidigger.projecttd.entities.Minion;
import me.minidigger.projecttd.utils.VectorUtil; | package me.minidigger.projecttd.systems;
/**
* Created by Martin on 07.04.2017.
*/
public class MoveToSystem extends IteratingSystem {
private ComponentMapper<TransformComponent> pm = ComponentMapper.getFor(TransformComponent.class); | // Path: core/src/me/minidigger/projecttd/components/MinionComponent.java
// public class MinionComponent implements Component, Pool.Poolable {
//
// public int money = 1;
// public float speed = 1f;
// public Minion.MinionType type = Minion.MinionType.LAND;
// public int points = 10;
//
// @Override
// public void reset() {
// money = 1;
// speed = 1f;
// type = Minion.MinionType.LAND;
// points = 10;
// }
// }
//
// Path: core/src/me/minidigger/projecttd/components/PathComponent.java
// public class PathComponent implements Component, Pool.Poolable {
//
// public int tilesToGoal = -1;
// public Vector2 nextPoint;
// public PathFindingSystem.GoalReachedAction completed = (e) -> {
// };
//
// @Override
// public void reset() {
// tilesToGoal = -1;
// nextPoint = null;
// completed = (e) -> {
// };
// }
// }
//
// Path: core/src/me/minidigger/projecttd/components/TransformComponent.java
// public class TransformComponent implements Component, Pool.Poolable {
//
// public Vector2 position;
// public float rotation = 0f;
//
// @Override
// public void reset() {
// position = new Vector2();
// rotation = 0f;
// }
// }
//
// Path: core/src/me/minidigger/projecttd/components/VelocityComponent.java
// public class VelocityComponent implements Component, Pool.Poolable {
//
// public Vector2 linear = new Vector2();
// public float angular = 0f;
//
// @Override
// public void reset() {
// linear = new Vector2();
// angular = 0f;
// }
// }
//
// Path: core/src/me/minidigger/projecttd/entities/Minion.java
// public class Minion {
//
// public static PooledEngine ENGINE;
// public static Sprite SPRITE;
//
// public static Entity newMinion(Vector2 spawn) {
// Entity entity = ENGINE.createEntity();
//
// SpriteComponent spriteComponent = ENGINE.createComponent(SpriteComponent.class);
// spriteComponent.sprite = SPRITE;
// entity.add(spriteComponent);
//
// VelocityComponent velocityComponent = ENGINE.createComponent(VelocityComponent.class);
// entity.add(velocityComponent);
//
// TransformComponent transformComponent = ENGINE.createComponent(TransformComponent.class);
// transformComponent.position = spawn;
// entity.add(transformComponent);
//
// HealthComponent healthComponent = ENGINE.createComponent(HealthComponent.class);
// healthComponent.health = 100;
// entity.add(healthComponent);
//
// PathComponent pathComponent = ENGINE.createComponent(PathComponent.class);
// entity.add(pathComponent);
//
// MinionComponent minionComponent = ENGINE.createComponent(MinionComponent.class);
// entity.add(minionComponent);
//
// ENGINE.addEntity(entity);
// return entity;
// }
//
// public enum MinionType{
// LAND,
// WATER,
// AIR;
// }
// }
//
// Path: core/src/me/minidigger/projecttd/utils/VectorUtil.java
// public class VectorUtil {
//
// // returns radians
// public static float vectorToAngle(Vector2 vector) {
// return (float) Math.atan2(-vector.x, vector.y);
// }
//
// // angle = radians
// public static Vector2 angleToVector(Vector2 outVector, float angle) {
// outVector.x = -(float) Math.sin(angle);
// outVector.y = (float) Math.cos(angle);
// return outVector;
// }
// }
// Path: core/src/me/minidigger/projecttd/systems/MoveToSystem.java
import com.badlogic.ashley.core.ComponentMapper;
import com.badlogic.ashley.core.Entity;
import com.badlogic.ashley.core.Family;
import com.badlogic.ashley.systems.IteratingSystem;
import com.badlogic.gdx.ai.utils.ArithmeticUtils;
import com.badlogic.gdx.math.MathUtils;
import com.badlogic.gdx.math.Vector2;
import me.minidigger.projecttd.components.MinionComponent;
import me.minidigger.projecttd.components.PathComponent;
import me.minidigger.projecttd.components.TransformComponent;
import me.minidigger.projecttd.components.VelocityComponent;
import me.minidigger.projecttd.entities.Minion;
import me.minidigger.projecttd.utils.VectorUtil;
package me.minidigger.projecttd.systems;
/**
* Created by Martin on 07.04.2017.
*/
public class MoveToSystem extends IteratingSystem {
private ComponentMapper<TransformComponent> pm = ComponentMapper.getFor(TransformComponent.class); | private ComponentMapper<VelocityComponent> vm = ComponentMapper.getFor(VelocityComponent.class); |
MiniDigger/projecttd | core/src/me/minidigger/projecttd/systems/MoveToSystem.java | // Path: core/src/me/minidigger/projecttd/components/MinionComponent.java
// public class MinionComponent implements Component, Pool.Poolable {
//
// public int money = 1;
// public float speed = 1f;
// public Minion.MinionType type = Minion.MinionType.LAND;
// public int points = 10;
//
// @Override
// public void reset() {
// money = 1;
// speed = 1f;
// type = Minion.MinionType.LAND;
// points = 10;
// }
// }
//
// Path: core/src/me/minidigger/projecttd/components/PathComponent.java
// public class PathComponent implements Component, Pool.Poolable {
//
// public int tilesToGoal = -1;
// public Vector2 nextPoint;
// public PathFindingSystem.GoalReachedAction completed = (e) -> {
// };
//
// @Override
// public void reset() {
// tilesToGoal = -1;
// nextPoint = null;
// completed = (e) -> {
// };
// }
// }
//
// Path: core/src/me/minidigger/projecttd/components/TransformComponent.java
// public class TransformComponent implements Component, Pool.Poolable {
//
// public Vector2 position;
// public float rotation = 0f;
//
// @Override
// public void reset() {
// position = new Vector2();
// rotation = 0f;
// }
// }
//
// Path: core/src/me/minidigger/projecttd/components/VelocityComponent.java
// public class VelocityComponent implements Component, Pool.Poolable {
//
// public Vector2 linear = new Vector2();
// public float angular = 0f;
//
// @Override
// public void reset() {
// linear = new Vector2();
// angular = 0f;
// }
// }
//
// Path: core/src/me/minidigger/projecttd/entities/Minion.java
// public class Minion {
//
// public static PooledEngine ENGINE;
// public static Sprite SPRITE;
//
// public static Entity newMinion(Vector2 spawn) {
// Entity entity = ENGINE.createEntity();
//
// SpriteComponent spriteComponent = ENGINE.createComponent(SpriteComponent.class);
// spriteComponent.sprite = SPRITE;
// entity.add(spriteComponent);
//
// VelocityComponent velocityComponent = ENGINE.createComponent(VelocityComponent.class);
// entity.add(velocityComponent);
//
// TransformComponent transformComponent = ENGINE.createComponent(TransformComponent.class);
// transformComponent.position = spawn;
// entity.add(transformComponent);
//
// HealthComponent healthComponent = ENGINE.createComponent(HealthComponent.class);
// healthComponent.health = 100;
// entity.add(healthComponent);
//
// PathComponent pathComponent = ENGINE.createComponent(PathComponent.class);
// entity.add(pathComponent);
//
// MinionComponent minionComponent = ENGINE.createComponent(MinionComponent.class);
// entity.add(minionComponent);
//
// ENGINE.addEntity(entity);
// return entity;
// }
//
// public enum MinionType{
// LAND,
// WATER,
// AIR;
// }
// }
//
// Path: core/src/me/minidigger/projecttd/utils/VectorUtil.java
// public class VectorUtil {
//
// // returns radians
// public static float vectorToAngle(Vector2 vector) {
// return (float) Math.atan2(-vector.x, vector.y);
// }
//
// // angle = radians
// public static Vector2 angleToVector(Vector2 outVector, float angle) {
// outVector.x = -(float) Math.sin(angle);
// outVector.y = (float) Math.cos(angle);
// return outVector;
// }
// }
| import com.badlogic.ashley.core.ComponentMapper;
import com.badlogic.ashley.core.Entity;
import com.badlogic.ashley.core.Family;
import com.badlogic.ashley.systems.IteratingSystem;
import com.badlogic.gdx.ai.utils.ArithmeticUtils;
import com.badlogic.gdx.math.MathUtils;
import com.badlogic.gdx.math.Vector2;
import me.minidigger.projecttd.components.MinionComponent;
import me.minidigger.projecttd.components.PathComponent;
import me.minidigger.projecttd.components.TransformComponent;
import me.minidigger.projecttd.components.VelocityComponent;
import me.minidigger.projecttd.entities.Minion;
import me.minidigger.projecttd.utils.VectorUtil; | package me.minidigger.projecttd.systems;
/**
* Created by Martin on 07.04.2017.
*/
public class MoveToSystem extends IteratingSystem {
private ComponentMapper<TransformComponent> pm = ComponentMapper.getFor(TransformComponent.class);
private ComponentMapper<VelocityComponent> vm = ComponentMapper.getFor(VelocityComponent.class); | // Path: core/src/me/minidigger/projecttd/components/MinionComponent.java
// public class MinionComponent implements Component, Pool.Poolable {
//
// public int money = 1;
// public float speed = 1f;
// public Minion.MinionType type = Minion.MinionType.LAND;
// public int points = 10;
//
// @Override
// public void reset() {
// money = 1;
// speed = 1f;
// type = Minion.MinionType.LAND;
// points = 10;
// }
// }
//
// Path: core/src/me/minidigger/projecttd/components/PathComponent.java
// public class PathComponent implements Component, Pool.Poolable {
//
// public int tilesToGoal = -1;
// public Vector2 nextPoint;
// public PathFindingSystem.GoalReachedAction completed = (e) -> {
// };
//
// @Override
// public void reset() {
// tilesToGoal = -1;
// nextPoint = null;
// completed = (e) -> {
// };
// }
// }
//
// Path: core/src/me/minidigger/projecttd/components/TransformComponent.java
// public class TransformComponent implements Component, Pool.Poolable {
//
// public Vector2 position;
// public float rotation = 0f;
//
// @Override
// public void reset() {
// position = new Vector2();
// rotation = 0f;
// }
// }
//
// Path: core/src/me/minidigger/projecttd/components/VelocityComponent.java
// public class VelocityComponent implements Component, Pool.Poolable {
//
// public Vector2 linear = new Vector2();
// public float angular = 0f;
//
// @Override
// public void reset() {
// linear = new Vector2();
// angular = 0f;
// }
// }
//
// Path: core/src/me/minidigger/projecttd/entities/Minion.java
// public class Minion {
//
// public static PooledEngine ENGINE;
// public static Sprite SPRITE;
//
// public static Entity newMinion(Vector2 spawn) {
// Entity entity = ENGINE.createEntity();
//
// SpriteComponent spriteComponent = ENGINE.createComponent(SpriteComponent.class);
// spriteComponent.sprite = SPRITE;
// entity.add(spriteComponent);
//
// VelocityComponent velocityComponent = ENGINE.createComponent(VelocityComponent.class);
// entity.add(velocityComponent);
//
// TransformComponent transformComponent = ENGINE.createComponent(TransformComponent.class);
// transformComponent.position = spawn;
// entity.add(transformComponent);
//
// HealthComponent healthComponent = ENGINE.createComponent(HealthComponent.class);
// healthComponent.health = 100;
// entity.add(healthComponent);
//
// PathComponent pathComponent = ENGINE.createComponent(PathComponent.class);
// entity.add(pathComponent);
//
// MinionComponent minionComponent = ENGINE.createComponent(MinionComponent.class);
// entity.add(minionComponent);
//
// ENGINE.addEntity(entity);
// return entity;
// }
//
// public enum MinionType{
// LAND,
// WATER,
// AIR;
// }
// }
//
// Path: core/src/me/minidigger/projecttd/utils/VectorUtil.java
// public class VectorUtil {
//
// // returns radians
// public static float vectorToAngle(Vector2 vector) {
// return (float) Math.atan2(-vector.x, vector.y);
// }
//
// // angle = radians
// public static Vector2 angleToVector(Vector2 outVector, float angle) {
// outVector.x = -(float) Math.sin(angle);
// outVector.y = (float) Math.cos(angle);
// return outVector;
// }
// }
// Path: core/src/me/minidigger/projecttd/systems/MoveToSystem.java
import com.badlogic.ashley.core.ComponentMapper;
import com.badlogic.ashley.core.Entity;
import com.badlogic.ashley.core.Family;
import com.badlogic.ashley.systems.IteratingSystem;
import com.badlogic.gdx.ai.utils.ArithmeticUtils;
import com.badlogic.gdx.math.MathUtils;
import com.badlogic.gdx.math.Vector2;
import me.minidigger.projecttd.components.MinionComponent;
import me.minidigger.projecttd.components.PathComponent;
import me.minidigger.projecttd.components.TransformComponent;
import me.minidigger.projecttd.components.VelocityComponent;
import me.minidigger.projecttd.entities.Minion;
import me.minidigger.projecttd.utils.VectorUtil;
package me.minidigger.projecttd.systems;
/**
* Created by Martin on 07.04.2017.
*/
public class MoveToSystem extends IteratingSystem {
private ComponentMapper<TransformComponent> pm = ComponentMapper.getFor(TransformComponent.class);
private ComponentMapper<VelocityComponent> vm = ComponentMapper.getFor(VelocityComponent.class); | private ComponentMapper<PathComponent> pathM = ComponentMapper.getFor(PathComponent.class); |
MiniDigger/projecttd | core/src/me/minidigger/projecttd/systems/MoveToSystem.java | // Path: core/src/me/minidigger/projecttd/components/MinionComponent.java
// public class MinionComponent implements Component, Pool.Poolable {
//
// public int money = 1;
// public float speed = 1f;
// public Minion.MinionType type = Minion.MinionType.LAND;
// public int points = 10;
//
// @Override
// public void reset() {
// money = 1;
// speed = 1f;
// type = Minion.MinionType.LAND;
// points = 10;
// }
// }
//
// Path: core/src/me/minidigger/projecttd/components/PathComponent.java
// public class PathComponent implements Component, Pool.Poolable {
//
// public int tilesToGoal = -1;
// public Vector2 nextPoint;
// public PathFindingSystem.GoalReachedAction completed = (e) -> {
// };
//
// @Override
// public void reset() {
// tilesToGoal = -1;
// nextPoint = null;
// completed = (e) -> {
// };
// }
// }
//
// Path: core/src/me/minidigger/projecttd/components/TransformComponent.java
// public class TransformComponent implements Component, Pool.Poolable {
//
// public Vector2 position;
// public float rotation = 0f;
//
// @Override
// public void reset() {
// position = new Vector2();
// rotation = 0f;
// }
// }
//
// Path: core/src/me/minidigger/projecttd/components/VelocityComponent.java
// public class VelocityComponent implements Component, Pool.Poolable {
//
// public Vector2 linear = new Vector2();
// public float angular = 0f;
//
// @Override
// public void reset() {
// linear = new Vector2();
// angular = 0f;
// }
// }
//
// Path: core/src/me/minidigger/projecttd/entities/Minion.java
// public class Minion {
//
// public static PooledEngine ENGINE;
// public static Sprite SPRITE;
//
// public static Entity newMinion(Vector2 spawn) {
// Entity entity = ENGINE.createEntity();
//
// SpriteComponent spriteComponent = ENGINE.createComponent(SpriteComponent.class);
// spriteComponent.sprite = SPRITE;
// entity.add(spriteComponent);
//
// VelocityComponent velocityComponent = ENGINE.createComponent(VelocityComponent.class);
// entity.add(velocityComponent);
//
// TransformComponent transformComponent = ENGINE.createComponent(TransformComponent.class);
// transformComponent.position = spawn;
// entity.add(transformComponent);
//
// HealthComponent healthComponent = ENGINE.createComponent(HealthComponent.class);
// healthComponent.health = 100;
// entity.add(healthComponent);
//
// PathComponent pathComponent = ENGINE.createComponent(PathComponent.class);
// entity.add(pathComponent);
//
// MinionComponent minionComponent = ENGINE.createComponent(MinionComponent.class);
// entity.add(minionComponent);
//
// ENGINE.addEntity(entity);
// return entity;
// }
//
// public enum MinionType{
// LAND,
// WATER,
// AIR;
// }
// }
//
// Path: core/src/me/minidigger/projecttd/utils/VectorUtil.java
// public class VectorUtil {
//
// // returns radians
// public static float vectorToAngle(Vector2 vector) {
// return (float) Math.atan2(-vector.x, vector.y);
// }
//
// // angle = radians
// public static Vector2 angleToVector(Vector2 outVector, float angle) {
// outVector.x = -(float) Math.sin(angle);
// outVector.y = (float) Math.cos(angle);
// return outVector;
// }
// }
| import com.badlogic.ashley.core.ComponentMapper;
import com.badlogic.ashley.core.Entity;
import com.badlogic.ashley.core.Family;
import com.badlogic.ashley.systems.IteratingSystem;
import com.badlogic.gdx.ai.utils.ArithmeticUtils;
import com.badlogic.gdx.math.MathUtils;
import com.badlogic.gdx.math.Vector2;
import me.minidigger.projecttd.components.MinionComponent;
import me.minidigger.projecttd.components.PathComponent;
import me.minidigger.projecttd.components.TransformComponent;
import me.minidigger.projecttd.components.VelocityComponent;
import me.minidigger.projecttd.entities.Minion;
import me.minidigger.projecttd.utils.VectorUtil; | package me.minidigger.projecttd.systems;
/**
* Created by Martin on 07.04.2017.
*/
public class MoveToSystem extends IteratingSystem {
private ComponentMapper<TransformComponent> pm = ComponentMapper.getFor(TransformComponent.class);
private ComponentMapper<VelocityComponent> vm = ComponentMapper.getFor(VelocityComponent.class);
private ComponentMapper<PathComponent> pathM = ComponentMapper.getFor(PathComponent.class); | // Path: core/src/me/minidigger/projecttd/components/MinionComponent.java
// public class MinionComponent implements Component, Pool.Poolable {
//
// public int money = 1;
// public float speed = 1f;
// public Minion.MinionType type = Minion.MinionType.LAND;
// public int points = 10;
//
// @Override
// public void reset() {
// money = 1;
// speed = 1f;
// type = Minion.MinionType.LAND;
// points = 10;
// }
// }
//
// Path: core/src/me/minidigger/projecttd/components/PathComponent.java
// public class PathComponent implements Component, Pool.Poolable {
//
// public int tilesToGoal = -1;
// public Vector2 nextPoint;
// public PathFindingSystem.GoalReachedAction completed = (e) -> {
// };
//
// @Override
// public void reset() {
// tilesToGoal = -1;
// nextPoint = null;
// completed = (e) -> {
// };
// }
// }
//
// Path: core/src/me/minidigger/projecttd/components/TransformComponent.java
// public class TransformComponent implements Component, Pool.Poolable {
//
// public Vector2 position;
// public float rotation = 0f;
//
// @Override
// public void reset() {
// position = new Vector2();
// rotation = 0f;
// }
// }
//
// Path: core/src/me/minidigger/projecttd/components/VelocityComponent.java
// public class VelocityComponent implements Component, Pool.Poolable {
//
// public Vector2 linear = new Vector2();
// public float angular = 0f;
//
// @Override
// public void reset() {
// linear = new Vector2();
// angular = 0f;
// }
// }
//
// Path: core/src/me/minidigger/projecttd/entities/Minion.java
// public class Minion {
//
// public static PooledEngine ENGINE;
// public static Sprite SPRITE;
//
// public static Entity newMinion(Vector2 spawn) {
// Entity entity = ENGINE.createEntity();
//
// SpriteComponent spriteComponent = ENGINE.createComponent(SpriteComponent.class);
// spriteComponent.sprite = SPRITE;
// entity.add(spriteComponent);
//
// VelocityComponent velocityComponent = ENGINE.createComponent(VelocityComponent.class);
// entity.add(velocityComponent);
//
// TransformComponent transformComponent = ENGINE.createComponent(TransformComponent.class);
// transformComponent.position = spawn;
// entity.add(transformComponent);
//
// HealthComponent healthComponent = ENGINE.createComponent(HealthComponent.class);
// healthComponent.health = 100;
// entity.add(healthComponent);
//
// PathComponent pathComponent = ENGINE.createComponent(PathComponent.class);
// entity.add(pathComponent);
//
// MinionComponent minionComponent = ENGINE.createComponent(MinionComponent.class);
// entity.add(minionComponent);
//
// ENGINE.addEntity(entity);
// return entity;
// }
//
// public enum MinionType{
// LAND,
// WATER,
// AIR;
// }
// }
//
// Path: core/src/me/minidigger/projecttd/utils/VectorUtil.java
// public class VectorUtil {
//
// // returns radians
// public static float vectorToAngle(Vector2 vector) {
// return (float) Math.atan2(-vector.x, vector.y);
// }
//
// // angle = radians
// public static Vector2 angleToVector(Vector2 outVector, float angle) {
// outVector.x = -(float) Math.sin(angle);
// outVector.y = (float) Math.cos(angle);
// return outVector;
// }
// }
// Path: core/src/me/minidigger/projecttd/systems/MoveToSystem.java
import com.badlogic.ashley.core.ComponentMapper;
import com.badlogic.ashley.core.Entity;
import com.badlogic.ashley.core.Family;
import com.badlogic.ashley.systems.IteratingSystem;
import com.badlogic.gdx.ai.utils.ArithmeticUtils;
import com.badlogic.gdx.math.MathUtils;
import com.badlogic.gdx.math.Vector2;
import me.minidigger.projecttd.components.MinionComponent;
import me.minidigger.projecttd.components.PathComponent;
import me.minidigger.projecttd.components.TransformComponent;
import me.minidigger.projecttd.components.VelocityComponent;
import me.minidigger.projecttd.entities.Minion;
import me.minidigger.projecttd.utils.VectorUtil;
package me.minidigger.projecttd.systems;
/**
* Created by Martin on 07.04.2017.
*/
public class MoveToSystem extends IteratingSystem {
private ComponentMapper<TransformComponent> pm = ComponentMapper.getFor(TransformComponent.class);
private ComponentMapper<VelocityComponent> vm = ComponentMapper.getFor(VelocityComponent.class);
private ComponentMapper<PathComponent> pathM = ComponentMapper.getFor(PathComponent.class); | private ComponentMapper<MinionComponent> minionM = ComponentMapper.getFor(MinionComponent.class); |
MiniDigger/projecttd | core/src/me/minidigger/projecttd/systems/MoveToSystem.java | // Path: core/src/me/minidigger/projecttd/components/MinionComponent.java
// public class MinionComponent implements Component, Pool.Poolable {
//
// public int money = 1;
// public float speed = 1f;
// public Minion.MinionType type = Minion.MinionType.LAND;
// public int points = 10;
//
// @Override
// public void reset() {
// money = 1;
// speed = 1f;
// type = Minion.MinionType.LAND;
// points = 10;
// }
// }
//
// Path: core/src/me/minidigger/projecttd/components/PathComponent.java
// public class PathComponent implements Component, Pool.Poolable {
//
// public int tilesToGoal = -1;
// public Vector2 nextPoint;
// public PathFindingSystem.GoalReachedAction completed = (e) -> {
// };
//
// @Override
// public void reset() {
// tilesToGoal = -1;
// nextPoint = null;
// completed = (e) -> {
// };
// }
// }
//
// Path: core/src/me/minidigger/projecttd/components/TransformComponent.java
// public class TransformComponent implements Component, Pool.Poolable {
//
// public Vector2 position;
// public float rotation = 0f;
//
// @Override
// public void reset() {
// position = new Vector2();
// rotation = 0f;
// }
// }
//
// Path: core/src/me/minidigger/projecttd/components/VelocityComponent.java
// public class VelocityComponent implements Component, Pool.Poolable {
//
// public Vector2 linear = new Vector2();
// public float angular = 0f;
//
// @Override
// public void reset() {
// linear = new Vector2();
// angular = 0f;
// }
// }
//
// Path: core/src/me/minidigger/projecttd/entities/Minion.java
// public class Minion {
//
// public static PooledEngine ENGINE;
// public static Sprite SPRITE;
//
// public static Entity newMinion(Vector2 spawn) {
// Entity entity = ENGINE.createEntity();
//
// SpriteComponent spriteComponent = ENGINE.createComponent(SpriteComponent.class);
// spriteComponent.sprite = SPRITE;
// entity.add(spriteComponent);
//
// VelocityComponent velocityComponent = ENGINE.createComponent(VelocityComponent.class);
// entity.add(velocityComponent);
//
// TransformComponent transformComponent = ENGINE.createComponent(TransformComponent.class);
// transformComponent.position = spawn;
// entity.add(transformComponent);
//
// HealthComponent healthComponent = ENGINE.createComponent(HealthComponent.class);
// healthComponent.health = 100;
// entity.add(healthComponent);
//
// PathComponent pathComponent = ENGINE.createComponent(PathComponent.class);
// entity.add(pathComponent);
//
// MinionComponent minionComponent = ENGINE.createComponent(MinionComponent.class);
// entity.add(minionComponent);
//
// ENGINE.addEntity(entity);
// return entity;
// }
//
// public enum MinionType{
// LAND,
// WATER,
// AIR;
// }
// }
//
// Path: core/src/me/minidigger/projecttd/utils/VectorUtil.java
// public class VectorUtil {
//
// // returns radians
// public static float vectorToAngle(Vector2 vector) {
// return (float) Math.atan2(-vector.x, vector.y);
// }
//
// // angle = radians
// public static Vector2 angleToVector(Vector2 outVector, float angle) {
// outVector.x = -(float) Math.sin(angle);
// outVector.y = (float) Math.cos(angle);
// return outVector;
// }
// }
| import com.badlogic.ashley.core.ComponentMapper;
import com.badlogic.ashley.core.Entity;
import com.badlogic.ashley.core.Family;
import com.badlogic.ashley.systems.IteratingSystem;
import com.badlogic.gdx.ai.utils.ArithmeticUtils;
import com.badlogic.gdx.math.MathUtils;
import com.badlogic.gdx.math.Vector2;
import me.minidigger.projecttd.components.MinionComponent;
import me.minidigger.projecttd.components.PathComponent;
import me.minidigger.projecttd.components.TransformComponent;
import me.minidigger.projecttd.components.VelocityComponent;
import me.minidigger.projecttd.entities.Minion;
import me.minidigger.projecttd.utils.VectorUtil; | float distance = toTarget.len();
// don't go too far!
if (distance <= 0.05) {
velocity.linear.setZero();
velocity.angular = 0;
path.nextPoint = null;
return;
}
float maxSpeed = minionComponent.speed;
System.out.println("speed " + maxSpeed);
// Target velocity combines speed and direction
Vector2 targetVelocity = toTarget.scl(maxSpeed / distance); // Optimized code for:
// toTarget.nor().scl(maxSpeed)
// Acceleration tries to get to the nextPoint velocity without exceeding max acceleration
targetVelocity.sub(velocity.linear).scl(1f / linearAccelerationTime).limit(maxLinearAcceleration);
// set it
velocity.linear.set(toTarget);
// angular
// Check for a zero direction, and set to 0 is so
if (velocity.linear.isZero(zeroThreshold)) {
velocity.angular = 0;
return;
}
// Calculate the orientation based on the velocity of the owner | // Path: core/src/me/minidigger/projecttd/components/MinionComponent.java
// public class MinionComponent implements Component, Pool.Poolable {
//
// public int money = 1;
// public float speed = 1f;
// public Minion.MinionType type = Minion.MinionType.LAND;
// public int points = 10;
//
// @Override
// public void reset() {
// money = 1;
// speed = 1f;
// type = Minion.MinionType.LAND;
// points = 10;
// }
// }
//
// Path: core/src/me/minidigger/projecttd/components/PathComponent.java
// public class PathComponent implements Component, Pool.Poolable {
//
// public int tilesToGoal = -1;
// public Vector2 nextPoint;
// public PathFindingSystem.GoalReachedAction completed = (e) -> {
// };
//
// @Override
// public void reset() {
// tilesToGoal = -1;
// nextPoint = null;
// completed = (e) -> {
// };
// }
// }
//
// Path: core/src/me/minidigger/projecttd/components/TransformComponent.java
// public class TransformComponent implements Component, Pool.Poolable {
//
// public Vector2 position;
// public float rotation = 0f;
//
// @Override
// public void reset() {
// position = new Vector2();
// rotation = 0f;
// }
// }
//
// Path: core/src/me/minidigger/projecttd/components/VelocityComponent.java
// public class VelocityComponent implements Component, Pool.Poolable {
//
// public Vector2 linear = new Vector2();
// public float angular = 0f;
//
// @Override
// public void reset() {
// linear = new Vector2();
// angular = 0f;
// }
// }
//
// Path: core/src/me/minidigger/projecttd/entities/Minion.java
// public class Minion {
//
// public static PooledEngine ENGINE;
// public static Sprite SPRITE;
//
// public static Entity newMinion(Vector2 spawn) {
// Entity entity = ENGINE.createEntity();
//
// SpriteComponent spriteComponent = ENGINE.createComponent(SpriteComponent.class);
// spriteComponent.sprite = SPRITE;
// entity.add(spriteComponent);
//
// VelocityComponent velocityComponent = ENGINE.createComponent(VelocityComponent.class);
// entity.add(velocityComponent);
//
// TransformComponent transformComponent = ENGINE.createComponent(TransformComponent.class);
// transformComponent.position = spawn;
// entity.add(transformComponent);
//
// HealthComponent healthComponent = ENGINE.createComponent(HealthComponent.class);
// healthComponent.health = 100;
// entity.add(healthComponent);
//
// PathComponent pathComponent = ENGINE.createComponent(PathComponent.class);
// entity.add(pathComponent);
//
// MinionComponent minionComponent = ENGINE.createComponent(MinionComponent.class);
// entity.add(minionComponent);
//
// ENGINE.addEntity(entity);
// return entity;
// }
//
// public enum MinionType{
// LAND,
// WATER,
// AIR;
// }
// }
//
// Path: core/src/me/minidigger/projecttd/utils/VectorUtil.java
// public class VectorUtil {
//
// // returns radians
// public static float vectorToAngle(Vector2 vector) {
// return (float) Math.atan2(-vector.x, vector.y);
// }
//
// // angle = radians
// public static Vector2 angleToVector(Vector2 outVector, float angle) {
// outVector.x = -(float) Math.sin(angle);
// outVector.y = (float) Math.cos(angle);
// return outVector;
// }
// }
// Path: core/src/me/minidigger/projecttd/systems/MoveToSystem.java
import com.badlogic.ashley.core.ComponentMapper;
import com.badlogic.ashley.core.Entity;
import com.badlogic.ashley.core.Family;
import com.badlogic.ashley.systems.IteratingSystem;
import com.badlogic.gdx.ai.utils.ArithmeticUtils;
import com.badlogic.gdx.math.MathUtils;
import com.badlogic.gdx.math.Vector2;
import me.minidigger.projecttd.components.MinionComponent;
import me.minidigger.projecttd.components.PathComponent;
import me.minidigger.projecttd.components.TransformComponent;
import me.minidigger.projecttd.components.VelocityComponent;
import me.minidigger.projecttd.entities.Minion;
import me.minidigger.projecttd.utils.VectorUtil;
float distance = toTarget.len();
// don't go too far!
if (distance <= 0.05) {
velocity.linear.setZero();
velocity.angular = 0;
path.nextPoint = null;
return;
}
float maxSpeed = minionComponent.speed;
System.out.println("speed " + maxSpeed);
// Target velocity combines speed and direction
Vector2 targetVelocity = toTarget.scl(maxSpeed / distance); // Optimized code for:
// toTarget.nor().scl(maxSpeed)
// Acceleration tries to get to the nextPoint velocity without exceeding max acceleration
targetVelocity.sub(velocity.linear).scl(1f / linearAccelerationTime).limit(maxLinearAcceleration);
// set it
velocity.linear.set(toTarget);
// angular
// Check for a zero direction, and set to 0 is so
if (velocity.linear.isZero(zeroThreshold)) {
velocity.angular = 0;
return;
}
// Calculate the orientation based on the velocity of the owner | float targetOrientation = VectorUtil.vectorToAngle(velocity.linear); |
MiniDigger/projecttd | core/src/me/minidigger/projecttd/components/MinionComponent.java | // Path: core/src/me/minidigger/projecttd/entities/Minion.java
// public class Minion {
//
// public static PooledEngine ENGINE;
// public static Sprite SPRITE;
//
// public static Entity newMinion(Vector2 spawn) {
// Entity entity = ENGINE.createEntity();
//
// SpriteComponent spriteComponent = ENGINE.createComponent(SpriteComponent.class);
// spriteComponent.sprite = SPRITE;
// entity.add(spriteComponent);
//
// VelocityComponent velocityComponent = ENGINE.createComponent(VelocityComponent.class);
// entity.add(velocityComponent);
//
// TransformComponent transformComponent = ENGINE.createComponent(TransformComponent.class);
// transformComponent.position = spawn;
// entity.add(transformComponent);
//
// HealthComponent healthComponent = ENGINE.createComponent(HealthComponent.class);
// healthComponent.health = 100;
// entity.add(healthComponent);
//
// PathComponent pathComponent = ENGINE.createComponent(PathComponent.class);
// entity.add(pathComponent);
//
// MinionComponent minionComponent = ENGINE.createComponent(MinionComponent.class);
// entity.add(minionComponent);
//
// ENGINE.addEntity(entity);
// return entity;
// }
//
// public enum MinionType{
// LAND,
// WATER,
// AIR;
// }
// }
| import com.badlogic.ashley.core.Component;
import com.badlogic.gdx.utils.Pool;
import me.minidigger.projecttd.entities.Minion; | package me.minidigger.projecttd.components;
/**
* Created by Martin on 01/05/2017.
*/
public class MinionComponent implements Component, Pool.Poolable {
public int money = 1;
public float speed = 1f; | // Path: core/src/me/minidigger/projecttd/entities/Minion.java
// public class Minion {
//
// public static PooledEngine ENGINE;
// public static Sprite SPRITE;
//
// public static Entity newMinion(Vector2 spawn) {
// Entity entity = ENGINE.createEntity();
//
// SpriteComponent spriteComponent = ENGINE.createComponent(SpriteComponent.class);
// spriteComponent.sprite = SPRITE;
// entity.add(spriteComponent);
//
// VelocityComponent velocityComponent = ENGINE.createComponent(VelocityComponent.class);
// entity.add(velocityComponent);
//
// TransformComponent transformComponent = ENGINE.createComponent(TransformComponent.class);
// transformComponent.position = spawn;
// entity.add(transformComponent);
//
// HealthComponent healthComponent = ENGINE.createComponent(HealthComponent.class);
// healthComponent.health = 100;
// entity.add(healthComponent);
//
// PathComponent pathComponent = ENGINE.createComponent(PathComponent.class);
// entity.add(pathComponent);
//
// MinionComponent minionComponent = ENGINE.createComponent(MinionComponent.class);
// entity.add(minionComponent);
//
// ENGINE.addEntity(entity);
// return entity;
// }
//
// public enum MinionType{
// LAND,
// WATER,
// AIR;
// }
// }
// Path: core/src/me/minidigger/projecttd/components/MinionComponent.java
import com.badlogic.ashley.core.Component;
import com.badlogic.gdx.utils.Pool;
import me.minidigger.projecttd.entities.Minion;
package me.minidigger.projecttd.components;
/**
* Created by Martin on 01/05/2017.
*/
public class MinionComponent implements Component, Pool.Poolable {
public int money = 1;
public float speed = 1f; | public Minion.MinionType type = Minion.MinionType.LAND; |
MiniDigger/projecttd | core/src/me/minidigger/projecttd/systems/RenderSystem.java | // Path: core/src/me/minidigger/projecttd/components/SpriteComponent.java
// public class SpriteComponent implements Component, Pool.Poolable {
//
// public Sprite sprite;
//
// @Override
// public void reset() {
// sprite = null;
// }
// }
//
// Path: core/src/me/minidigger/projecttd/components/TransformComponent.java
// public class TransformComponent implements Component, Pool.Poolable {
//
// public Vector2 position;
// public float rotation = 0f;
//
// @Override
// public void reset() {
// position = new Vector2();
// rotation = 0f;
// }
// }
| import com.badlogic.ashley.core.ComponentMapper;
import com.badlogic.ashley.core.Entity;
import com.badlogic.ashley.core.Family;
import com.badlogic.ashley.systems.IteratingSystem;
import com.badlogic.gdx.graphics.Camera;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import me.minidigger.projecttd.components.SpriteComponent;
import me.minidigger.projecttd.components.TransformComponent; | package me.minidigger.projecttd.systems;
/**
* Created by Martin on 02.04.2017.
*/
public class RenderSystem extends IteratingSystem {
private SpriteBatch batch;
private Camera camera;
| // Path: core/src/me/minidigger/projecttd/components/SpriteComponent.java
// public class SpriteComponent implements Component, Pool.Poolable {
//
// public Sprite sprite;
//
// @Override
// public void reset() {
// sprite = null;
// }
// }
//
// Path: core/src/me/minidigger/projecttd/components/TransformComponent.java
// public class TransformComponent implements Component, Pool.Poolable {
//
// public Vector2 position;
// public float rotation = 0f;
//
// @Override
// public void reset() {
// position = new Vector2();
// rotation = 0f;
// }
// }
// Path: core/src/me/minidigger/projecttd/systems/RenderSystem.java
import com.badlogic.ashley.core.ComponentMapper;
import com.badlogic.ashley.core.Entity;
import com.badlogic.ashley.core.Family;
import com.badlogic.ashley.systems.IteratingSystem;
import com.badlogic.gdx.graphics.Camera;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import me.minidigger.projecttd.components.SpriteComponent;
import me.minidigger.projecttd.components.TransformComponent;
package me.minidigger.projecttd.systems;
/**
* Created by Martin on 02.04.2017.
*/
public class RenderSystem extends IteratingSystem {
private SpriteBatch batch;
private Camera camera;
| private ComponentMapper<SpriteComponent> spriteM; |
MiniDigger/projecttd | core/src/me/minidigger/projecttd/systems/RenderSystem.java | // Path: core/src/me/minidigger/projecttd/components/SpriteComponent.java
// public class SpriteComponent implements Component, Pool.Poolable {
//
// public Sprite sprite;
//
// @Override
// public void reset() {
// sprite = null;
// }
// }
//
// Path: core/src/me/minidigger/projecttd/components/TransformComponent.java
// public class TransformComponent implements Component, Pool.Poolable {
//
// public Vector2 position;
// public float rotation = 0f;
//
// @Override
// public void reset() {
// position = new Vector2();
// rotation = 0f;
// }
// }
| import com.badlogic.ashley.core.ComponentMapper;
import com.badlogic.ashley.core.Entity;
import com.badlogic.ashley.core.Family;
import com.badlogic.ashley.systems.IteratingSystem;
import com.badlogic.gdx.graphics.Camera;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import me.minidigger.projecttd.components.SpriteComponent;
import me.minidigger.projecttd.components.TransformComponent; | package me.minidigger.projecttd.systems;
/**
* Created by Martin on 02.04.2017.
*/
public class RenderSystem extends IteratingSystem {
private SpriteBatch batch;
private Camera camera;
private ComponentMapper<SpriteComponent> spriteM; | // Path: core/src/me/minidigger/projecttd/components/SpriteComponent.java
// public class SpriteComponent implements Component, Pool.Poolable {
//
// public Sprite sprite;
//
// @Override
// public void reset() {
// sprite = null;
// }
// }
//
// Path: core/src/me/minidigger/projecttd/components/TransformComponent.java
// public class TransformComponent implements Component, Pool.Poolable {
//
// public Vector2 position;
// public float rotation = 0f;
//
// @Override
// public void reset() {
// position = new Vector2();
// rotation = 0f;
// }
// }
// Path: core/src/me/minidigger/projecttd/systems/RenderSystem.java
import com.badlogic.ashley.core.ComponentMapper;
import com.badlogic.ashley.core.Entity;
import com.badlogic.ashley.core.Family;
import com.badlogic.ashley.systems.IteratingSystem;
import com.badlogic.gdx.graphics.Camera;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import me.minidigger.projecttd.components.SpriteComponent;
import me.minidigger.projecttd.components.TransformComponent;
package me.minidigger.projecttd.systems;
/**
* Created by Martin on 02.04.2017.
*/
public class RenderSystem extends IteratingSystem {
private SpriteBatch batch;
private Camera camera;
private ComponentMapper<SpriteComponent> spriteM; | private ComponentMapper<TransformComponent> positionM; |
architjn/YAAB | app/src/main/java/com/architjn/audiobook/adapter/AudioBookAdapter.java | // Path: app/src/main/java/com/architjn/audiobook/bean/AudioBook.java
// public class AudioBook implements Serializable {
// private String albumId;
// private String albumKey;
// private String albumName;
// private String artistName;
// private String albumArt;
// private int status;
// private long duration;
// private long currentDuration;
// private ArrayList<BookChapter> chapters;
//
// public AudioBook() {
// //for serializable
// }
//
// public AudioBook(String albumId, String albumKey, String albumName, String artistName,
// String albumArt, int status, long duration, long currentDuration) {
// this.albumId = albumId;
// this.albumKey = albumKey;
// this.albumName = albumName;
// this.artistName = artistName;
// this.albumArt = albumArt;
// this.status = status;
// this.duration = duration;
// this.currentDuration = currentDuration;
// }
//
// public String getAlbumKey() {
// return albumKey;
// }
//
// public String getAlbumId() {
// return albumId;
// }
//
// public String getAlbumName() {
// return albumName;
// }
//
// public String getArtistName() {
// return artistName;
// }
//
// public long getDuration() {
// return duration;
// }
//
// public void setChapters(ArrayList<BookChapter> chapters) {
// this.chapters = chapters;
// }
//
// public ArrayList<BookChapter> getChapters() {
// return chapters;
// }
//
// public String getAlbumArt() {
// return albumArt;
// }
//
// public int getStatus() {
// return status;
// }
//
// public void setStatus(int status) {
// this.status = status;
// }
//
// public void setAlbumId(String albumId) {
// this.albumId = albumId;
// }
//
// public void setAlbumKey(String albumKey) {
// this.albumKey = albumKey;
// }
//
// public void setAlbumName(String albumName) {
// this.albumName = albumName;
// }
//
// public void setArtistName(String artistName) {
// this.artistName = artistName;
// }
//
// public void setAlbumArt(String albumArt) {
// this.albumArt = albumArt;
// }
//
// public void setDuration(long duration) {
// this.duration = duration;
// }
//
// public long getCurrentDuration() {
// return currentDuration;
// }
//
// public void setCurrentDuration(long currentDuration) {
// this.currentDuration = currentDuration;
// }
// }
//
// Path: app/src/main/java/com/architjn/audiobook/utils/Utils.java
// public class Utils {
//
// public static void log(String msg) {
// if (BuildConfig.DEBUG)
// Log.e("YAAB-TAG", msg);
// }
//
// public static Uri getUriOfMedia(String albumId) {
// return ContentUris.withAppendedId(Uri.parse("content://media/external/audio/albumart"),
// Long.parseLong(albumId));
// }
//
// public static int getStatusBarHeight() {
// int result = 0;
// int resourceId = Resources.getSystem().getIdentifier("status_bar_height", "dimen", "android");
// if (resourceId > 0) {
// result = Resources.getSystem().getDimensionPixelSize(resourceId);
// }
// return result;
// }
//
// public static int getScreenWidth() {
// return Resources.getSystem().getDisplayMetrics().widthPixels;
// }
//
// public static int getScreenHeight() {
// return Resources.getSystem().getDisplayMetrics().heightPixels;
// }
//
// public static int dpToPx(int dp) {
// DisplayMetrics displayMetrics = Resources.getSystem().getDisplayMetrics();
// return round(dp * (displayMetrics.xdpi / DisplayMetrics.DENSITY_DEFAULT));
// }
//
// public static String formatTime(long millis) {
// return String.format(Locale.ENGLISH, "%02d:%02d:%02d",
// TimeUnit.MILLISECONDS.toHours(millis),
// TimeUnit.MILLISECONDS.toMinutes(millis) -
// TimeUnit.HOURS.toMinutes(TimeUnit.MILLISECONDS.toHours(millis)),
// TimeUnit.MILLISECONDS.toSeconds(millis) -
// TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(millis)));
// }
// }
| import android.content.Context;
import android.graphics.Color;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.architjn.audiobook.R;
import com.architjn.audiobook.bean.AudioBook;
import com.architjn.audiobook.utils.Utils;
import com.github.lzyzsd.circleprogress.DonutProgress;
import com.squareup.picasso.Picasso;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.Random;
import de.hdodenhof.circleimageview.CircleImageView; | package com.architjn.audiobook.adapter;
/**
* Created by Wiz@rd on 11/23/2016.
*/
public class AudioBookAdapter extends RecyclerView.Adapter<AudioBookAdapter.ViewHolder> {
private Context context; | // Path: app/src/main/java/com/architjn/audiobook/bean/AudioBook.java
// public class AudioBook implements Serializable {
// private String albumId;
// private String albumKey;
// private String albumName;
// private String artistName;
// private String albumArt;
// private int status;
// private long duration;
// private long currentDuration;
// private ArrayList<BookChapter> chapters;
//
// public AudioBook() {
// //for serializable
// }
//
// public AudioBook(String albumId, String albumKey, String albumName, String artistName,
// String albumArt, int status, long duration, long currentDuration) {
// this.albumId = albumId;
// this.albumKey = albumKey;
// this.albumName = albumName;
// this.artistName = artistName;
// this.albumArt = albumArt;
// this.status = status;
// this.duration = duration;
// this.currentDuration = currentDuration;
// }
//
// public String getAlbumKey() {
// return albumKey;
// }
//
// public String getAlbumId() {
// return albumId;
// }
//
// public String getAlbumName() {
// return albumName;
// }
//
// public String getArtistName() {
// return artistName;
// }
//
// public long getDuration() {
// return duration;
// }
//
// public void setChapters(ArrayList<BookChapter> chapters) {
// this.chapters = chapters;
// }
//
// public ArrayList<BookChapter> getChapters() {
// return chapters;
// }
//
// public String getAlbumArt() {
// return albumArt;
// }
//
// public int getStatus() {
// return status;
// }
//
// public void setStatus(int status) {
// this.status = status;
// }
//
// public void setAlbumId(String albumId) {
// this.albumId = albumId;
// }
//
// public void setAlbumKey(String albumKey) {
// this.albumKey = albumKey;
// }
//
// public void setAlbumName(String albumName) {
// this.albumName = albumName;
// }
//
// public void setArtistName(String artistName) {
// this.artistName = artistName;
// }
//
// public void setAlbumArt(String albumArt) {
// this.albumArt = albumArt;
// }
//
// public void setDuration(long duration) {
// this.duration = duration;
// }
//
// public long getCurrentDuration() {
// return currentDuration;
// }
//
// public void setCurrentDuration(long currentDuration) {
// this.currentDuration = currentDuration;
// }
// }
//
// Path: app/src/main/java/com/architjn/audiobook/utils/Utils.java
// public class Utils {
//
// public static void log(String msg) {
// if (BuildConfig.DEBUG)
// Log.e("YAAB-TAG", msg);
// }
//
// public static Uri getUriOfMedia(String albumId) {
// return ContentUris.withAppendedId(Uri.parse("content://media/external/audio/albumart"),
// Long.parseLong(albumId));
// }
//
// public static int getStatusBarHeight() {
// int result = 0;
// int resourceId = Resources.getSystem().getIdentifier("status_bar_height", "dimen", "android");
// if (resourceId > 0) {
// result = Resources.getSystem().getDimensionPixelSize(resourceId);
// }
// return result;
// }
//
// public static int getScreenWidth() {
// return Resources.getSystem().getDisplayMetrics().widthPixels;
// }
//
// public static int getScreenHeight() {
// return Resources.getSystem().getDisplayMetrics().heightPixels;
// }
//
// public static int dpToPx(int dp) {
// DisplayMetrics displayMetrics = Resources.getSystem().getDisplayMetrics();
// return round(dp * (displayMetrics.xdpi / DisplayMetrics.DENSITY_DEFAULT));
// }
//
// public static String formatTime(long millis) {
// return String.format(Locale.ENGLISH, "%02d:%02d:%02d",
// TimeUnit.MILLISECONDS.toHours(millis),
// TimeUnit.MILLISECONDS.toMinutes(millis) -
// TimeUnit.HOURS.toMinutes(TimeUnit.MILLISECONDS.toHours(millis)),
// TimeUnit.MILLISECONDS.toSeconds(millis) -
// TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(millis)));
// }
// }
// Path: app/src/main/java/com/architjn/audiobook/adapter/AudioBookAdapter.java
import android.content.Context;
import android.graphics.Color;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.architjn.audiobook.R;
import com.architjn.audiobook.bean.AudioBook;
import com.architjn.audiobook.utils.Utils;
import com.github.lzyzsd.circleprogress.DonutProgress;
import com.squareup.picasso.Picasso;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.Random;
import de.hdodenhof.circleimageview.CircleImageView;
package com.architjn.audiobook.adapter;
/**
* Created by Wiz@rd on 11/23/2016.
*/
public class AudioBookAdapter extends RecyclerView.Adapter<AudioBookAdapter.ViewHolder> {
private Context context; | private List<AudioBook> items; |
architjn/YAAB | app/src/main/java/com/architjn/audiobook/adapter/FolderChooserAdapter.java | // Path: app/src/main/java/com/architjn/audiobook/bean/Folder.java
// public class Folder {
// private final String absolutePath;
// private final String name;
//
// public Folder(String absolutePath, String name) {
// this.absolutePath = absolutePath;
// this.name = name;
// }
//
// public String getAbsolutePath() {
// return absolutePath;
// }
//
// public String getName() {
// return name;
// }
// }
| import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.architjn.audiobook.R;
import com.architjn.audiobook.bean.Folder;
import java.util.ArrayList;
import java.util.List; | package com.architjn.audiobook.adapter;
/**
* Created by Wiz@rd on 11/23/2016.
*/
public class FolderChooserAdapter extends RecyclerView.Adapter<FolderChooserAdapter.ViewHolder> {
private Context context; | // Path: app/src/main/java/com/architjn/audiobook/bean/Folder.java
// public class Folder {
// private final String absolutePath;
// private final String name;
//
// public Folder(String absolutePath, String name) {
// this.absolutePath = absolutePath;
// this.name = name;
// }
//
// public String getAbsolutePath() {
// return absolutePath;
// }
//
// public String getName() {
// return name;
// }
// }
// Path: app/src/main/java/com/architjn/audiobook/adapter/FolderChooserAdapter.java
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.architjn.audiobook.R;
import com.architjn.audiobook.bean.Folder;
import java.util.ArrayList;
import java.util.List;
package com.architjn.audiobook.adapter;
/**
* Created by Wiz@rd on 11/23/2016.
*/
public class FolderChooserAdapter extends RecyclerView.Adapter<FolderChooserAdapter.ViewHolder> {
private Context context; | private List<Folder> items; |
architjn/YAAB | app/src/main/java/com/architjn/audiobook/service/PlayerService.java | // Path: app/src/main/java/com/architjn/audiobook/bean/BookChapter.java
// public class BookChapter implements Serializable{
// private String id;
// private String title;
// private long duration;
// private String data;
// private long currDuration;
//
// public BookChapter() {
// //for serializable
// }
//
// public BookChapter(String id, String title, long duration, String data, long currDuration) {
// this.id = id;
// this.title = title;
// this.duration = duration;
// this.data = data;
// this.currDuration = currDuration;
// }
//
// public String getId() {
// return id;
// }
//
// public String getTitle() {
// return title;
// }
//
// public long getDuration() {
// return duration;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public void setTitle(String title) {
// this.title = title;
// }
//
// public void setDuration(long duration) {
// this.duration = duration;
// }
//
// public String getData() {
// return data;
// }
//
// public void setData(String data) {
// this.data = data;
// }
//
// public long getCurrDuration() {
// return currDuration;
// }
//
// public void setCurrDuration(long currDuration) {
// this.currDuration = currDuration;
// }
// }
//
// Path: app/src/main/java/com/architjn/audiobook/interactor/PlayerInteractor.java
// public class PlayerInteractor {
//
// private static PlayerInteractor instance;
//
// private final Context context;
// private final DBHelper db;
// private IPlayerPresenter presenter;
// private IPlayerService service;
// private Status status;
// private AudioBook audiobook;
// private int chapterNo = 0;
//
// public static PlayerInteractor getInstance(Context context) {
// if (instance == null)
// instance = new PlayerInteractor(context);
// return instance;
// }
//
// private PlayerInteractor(Context context) {
// this.context = context;
// this.db = DBHelper.getInstance(context);
// }
//
// public void setPresenterListener(IPlayerPresenter presenter) {
// this.presenter = presenter;
// }
//
// public void setServiceListener(IPlayerService service) {
// this.service = service;
// }
//
// public AudioBook loadBook(String albumId) {
// audiobook = db.getAudioBookViaId(albumId);
// if (service != null && audiobook != null)
// service.setSource(audiobook.getChapters().get(chapterNo));
// return audiobook;
// }
//
// public int playBook() {
// if (service != null)
// return service.play();
// else return -1;
// }
//
// public void setStatus(Status status) {
// this.status = status;
// }
//
// public Status getStatus() {
// return status;
// }
//
// public BookChapter getNextChapter() {
// if (audiobook != null && audiobook.getChapters().size() > chapterNo)
// return audiobook.getChapters().get(chapterNo);
// else return null;
// }
//
// public void askToPlay() {
// presenter.playSong();
// }
//
// public void updateSeek(int progress) {
// if (service!=null)
// service.onSeekChange(progress*1000);
// }
//
// public enum Status {
// PLAYING, STOPPED, PAUSED
// }
// }
//
// Path: app/src/main/java/com/architjn/audiobook/interfaces/IPlayerService.java
// public interface IPlayerService {
// void setSource(BookChapter audiobook);
//
// int play();
//
// void onSeekChange(int progress);
// }
| import android.app.Service;
import android.content.Intent;
import android.media.MediaPlayer;
import android.os.IBinder;
import android.support.annotation.Nullable;
import com.architjn.audiobook.bean.BookChapter;
import com.architjn.audiobook.interactor.PlayerInteractor;
import com.architjn.audiobook.interfaces.IPlayerService;
import java.io.IOException;
import static com.architjn.audiobook.interactor.PlayerInteractor.Status.PAUSED;
import static com.architjn.audiobook.interactor.PlayerInteractor.Status.PLAYING; | package com.architjn.audiobook.service;
/**
* Created by HP on 30-07-2017.
*/
public class PlayerService extends Service implements IPlayerService {
private MediaPlayer mediaPlayer;
private boolean gotContent; | // Path: app/src/main/java/com/architjn/audiobook/bean/BookChapter.java
// public class BookChapter implements Serializable{
// private String id;
// private String title;
// private long duration;
// private String data;
// private long currDuration;
//
// public BookChapter() {
// //for serializable
// }
//
// public BookChapter(String id, String title, long duration, String data, long currDuration) {
// this.id = id;
// this.title = title;
// this.duration = duration;
// this.data = data;
// this.currDuration = currDuration;
// }
//
// public String getId() {
// return id;
// }
//
// public String getTitle() {
// return title;
// }
//
// public long getDuration() {
// return duration;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public void setTitle(String title) {
// this.title = title;
// }
//
// public void setDuration(long duration) {
// this.duration = duration;
// }
//
// public String getData() {
// return data;
// }
//
// public void setData(String data) {
// this.data = data;
// }
//
// public long getCurrDuration() {
// return currDuration;
// }
//
// public void setCurrDuration(long currDuration) {
// this.currDuration = currDuration;
// }
// }
//
// Path: app/src/main/java/com/architjn/audiobook/interactor/PlayerInteractor.java
// public class PlayerInteractor {
//
// private static PlayerInteractor instance;
//
// private final Context context;
// private final DBHelper db;
// private IPlayerPresenter presenter;
// private IPlayerService service;
// private Status status;
// private AudioBook audiobook;
// private int chapterNo = 0;
//
// public static PlayerInteractor getInstance(Context context) {
// if (instance == null)
// instance = new PlayerInteractor(context);
// return instance;
// }
//
// private PlayerInteractor(Context context) {
// this.context = context;
// this.db = DBHelper.getInstance(context);
// }
//
// public void setPresenterListener(IPlayerPresenter presenter) {
// this.presenter = presenter;
// }
//
// public void setServiceListener(IPlayerService service) {
// this.service = service;
// }
//
// public AudioBook loadBook(String albumId) {
// audiobook = db.getAudioBookViaId(albumId);
// if (service != null && audiobook != null)
// service.setSource(audiobook.getChapters().get(chapterNo));
// return audiobook;
// }
//
// public int playBook() {
// if (service != null)
// return service.play();
// else return -1;
// }
//
// public void setStatus(Status status) {
// this.status = status;
// }
//
// public Status getStatus() {
// return status;
// }
//
// public BookChapter getNextChapter() {
// if (audiobook != null && audiobook.getChapters().size() > chapterNo)
// return audiobook.getChapters().get(chapterNo);
// else return null;
// }
//
// public void askToPlay() {
// presenter.playSong();
// }
//
// public void updateSeek(int progress) {
// if (service!=null)
// service.onSeekChange(progress*1000);
// }
//
// public enum Status {
// PLAYING, STOPPED, PAUSED
// }
// }
//
// Path: app/src/main/java/com/architjn/audiobook/interfaces/IPlayerService.java
// public interface IPlayerService {
// void setSource(BookChapter audiobook);
//
// int play();
//
// void onSeekChange(int progress);
// }
// Path: app/src/main/java/com/architjn/audiobook/service/PlayerService.java
import android.app.Service;
import android.content.Intent;
import android.media.MediaPlayer;
import android.os.IBinder;
import android.support.annotation.Nullable;
import com.architjn.audiobook.bean.BookChapter;
import com.architjn.audiobook.interactor.PlayerInteractor;
import com.architjn.audiobook.interfaces.IPlayerService;
import java.io.IOException;
import static com.architjn.audiobook.interactor.PlayerInteractor.Status.PAUSED;
import static com.architjn.audiobook.interactor.PlayerInteractor.Status.PLAYING;
package com.architjn.audiobook.service;
/**
* Created by HP on 30-07-2017.
*/
public class PlayerService extends Service implements IPlayerService {
private MediaPlayer mediaPlayer;
private boolean gotContent; | private PlayerInteractor interactor; |
architjn/YAAB | app/src/main/java/com/architjn/audiobook/service/PlayerService.java | // Path: app/src/main/java/com/architjn/audiobook/bean/BookChapter.java
// public class BookChapter implements Serializable{
// private String id;
// private String title;
// private long duration;
// private String data;
// private long currDuration;
//
// public BookChapter() {
// //for serializable
// }
//
// public BookChapter(String id, String title, long duration, String data, long currDuration) {
// this.id = id;
// this.title = title;
// this.duration = duration;
// this.data = data;
// this.currDuration = currDuration;
// }
//
// public String getId() {
// return id;
// }
//
// public String getTitle() {
// return title;
// }
//
// public long getDuration() {
// return duration;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public void setTitle(String title) {
// this.title = title;
// }
//
// public void setDuration(long duration) {
// this.duration = duration;
// }
//
// public String getData() {
// return data;
// }
//
// public void setData(String data) {
// this.data = data;
// }
//
// public long getCurrDuration() {
// return currDuration;
// }
//
// public void setCurrDuration(long currDuration) {
// this.currDuration = currDuration;
// }
// }
//
// Path: app/src/main/java/com/architjn/audiobook/interactor/PlayerInteractor.java
// public class PlayerInteractor {
//
// private static PlayerInteractor instance;
//
// private final Context context;
// private final DBHelper db;
// private IPlayerPresenter presenter;
// private IPlayerService service;
// private Status status;
// private AudioBook audiobook;
// private int chapterNo = 0;
//
// public static PlayerInteractor getInstance(Context context) {
// if (instance == null)
// instance = new PlayerInteractor(context);
// return instance;
// }
//
// private PlayerInteractor(Context context) {
// this.context = context;
// this.db = DBHelper.getInstance(context);
// }
//
// public void setPresenterListener(IPlayerPresenter presenter) {
// this.presenter = presenter;
// }
//
// public void setServiceListener(IPlayerService service) {
// this.service = service;
// }
//
// public AudioBook loadBook(String albumId) {
// audiobook = db.getAudioBookViaId(albumId);
// if (service != null && audiobook != null)
// service.setSource(audiobook.getChapters().get(chapterNo));
// return audiobook;
// }
//
// public int playBook() {
// if (service != null)
// return service.play();
// else return -1;
// }
//
// public void setStatus(Status status) {
// this.status = status;
// }
//
// public Status getStatus() {
// return status;
// }
//
// public BookChapter getNextChapter() {
// if (audiobook != null && audiobook.getChapters().size() > chapterNo)
// return audiobook.getChapters().get(chapterNo);
// else return null;
// }
//
// public void askToPlay() {
// presenter.playSong();
// }
//
// public void updateSeek(int progress) {
// if (service!=null)
// service.onSeekChange(progress*1000);
// }
//
// public enum Status {
// PLAYING, STOPPED, PAUSED
// }
// }
//
// Path: app/src/main/java/com/architjn/audiobook/interfaces/IPlayerService.java
// public interface IPlayerService {
// void setSource(BookChapter audiobook);
//
// int play();
//
// void onSeekChange(int progress);
// }
| import android.app.Service;
import android.content.Intent;
import android.media.MediaPlayer;
import android.os.IBinder;
import android.support.annotation.Nullable;
import com.architjn.audiobook.bean.BookChapter;
import com.architjn.audiobook.interactor.PlayerInteractor;
import com.architjn.audiobook.interfaces.IPlayerService;
import java.io.IOException;
import static com.architjn.audiobook.interactor.PlayerInteractor.Status.PAUSED;
import static com.architjn.audiobook.interactor.PlayerInteractor.Status.PLAYING; | package com.architjn.audiobook.service;
/**
* Created by HP on 30-07-2017.
*/
public class PlayerService extends Service implements IPlayerService {
private MediaPlayer mediaPlayer;
private boolean gotContent;
private PlayerInteractor interactor;
@Nullable
@Override
public IBinder onBind(Intent intent) {
return null;
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
interactor = PlayerInteractor.getInstance(this);
interactor.setServiceListener(this);
mediaPlayer = new MediaPlayer();
gotContent = false;
return START_STICKY;
}
@Override | // Path: app/src/main/java/com/architjn/audiobook/bean/BookChapter.java
// public class BookChapter implements Serializable{
// private String id;
// private String title;
// private long duration;
// private String data;
// private long currDuration;
//
// public BookChapter() {
// //for serializable
// }
//
// public BookChapter(String id, String title, long duration, String data, long currDuration) {
// this.id = id;
// this.title = title;
// this.duration = duration;
// this.data = data;
// this.currDuration = currDuration;
// }
//
// public String getId() {
// return id;
// }
//
// public String getTitle() {
// return title;
// }
//
// public long getDuration() {
// return duration;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public void setTitle(String title) {
// this.title = title;
// }
//
// public void setDuration(long duration) {
// this.duration = duration;
// }
//
// public String getData() {
// return data;
// }
//
// public void setData(String data) {
// this.data = data;
// }
//
// public long getCurrDuration() {
// return currDuration;
// }
//
// public void setCurrDuration(long currDuration) {
// this.currDuration = currDuration;
// }
// }
//
// Path: app/src/main/java/com/architjn/audiobook/interactor/PlayerInteractor.java
// public class PlayerInteractor {
//
// private static PlayerInteractor instance;
//
// private final Context context;
// private final DBHelper db;
// private IPlayerPresenter presenter;
// private IPlayerService service;
// private Status status;
// private AudioBook audiobook;
// private int chapterNo = 0;
//
// public static PlayerInteractor getInstance(Context context) {
// if (instance == null)
// instance = new PlayerInteractor(context);
// return instance;
// }
//
// private PlayerInteractor(Context context) {
// this.context = context;
// this.db = DBHelper.getInstance(context);
// }
//
// public void setPresenterListener(IPlayerPresenter presenter) {
// this.presenter = presenter;
// }
//
// public void setServiceListener(IPlayerService service) {
// this.service = service;
// }
//
// public AudioBook loadBook(String albumId) {
// audiobook = db.getAudioBookViaId(albumId);
// if (service != null && audiobook != null)
// service.setSource(audiobook.getChapters().get(chapterNo));
// return audiobook;
// }
//
// public int playBook() {
// if (service != null)
// return service.play();
// else return -1;
// }
//
// public void setStatus(Status status) {
// this.status = status;
// }
//
// public Status getStatus() {
// return status;
// }
//
// public BookChapter getNextChapter() {
// if (audiobook != null && audiobook.getChapters().size() > chapterNo)
// return audiobook.getChapters().get(chapterNo);
// else return null;
// }
//
// public void askToPlay() {
// presenter.playSong();
// }
//
// public void updateSeek(int progress) {
// if (service!=null)
// service.onSeekChange(progress*1000);
// }
//
// public enum Status {
// PLAYING, STOPPED, PAUSED
// }
// }
//
// Path: app/src/main/java/com/architjn/audiobook/interfaces/IPlayerService.java
// public interface IPlayerService {
// void setSource(BookChapter audiobook);
//
// int play();
//
// void onSeekChange(int progress);
// }
// Path: app/src/main/java/com/architjn/audiobook/service/PlayerService.java
import android.app.Service;
import android.content.Intent;
import android.media.MediaPlayer;
import android.os.IBinder;
import android.support.annotation.Nullable;
import com.architjn.audiobook.bean.BookChapter;
import com.architjn.audiobook.interactor.PlayerInteractor;
import com.architjn.audiobook.interfaces.IPlayerService;
import java.io.IOException;
import static com.architjn.audiobook.interactor.PlayerInteractor.Status.PAUSED;
import static com.architjn.audiobook.interactor.PlayerInteractor.Status.PLAYING;
package com.architjn.audiobook.service;
/**
* Created by HP on 30-07-2017.
*/
public class PlayerService extends Service implements IPlayerService {
private MediaPlayer mediaPlayer;
private boolean gotContent;
private PlayerInteractor interactor;
@Nullable
@Override
public IBinder onBind(Intent intent) {
return null;
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
interactor = PlayerInteractor.getInstance(this);
interactor.setServiceListener(this);
mediaPlayer = new MediaPlayer();
gotContent = false;
return START_STICKY;
}
@Override | public void setSource(BookChapter chapter) { |
architjn/YAAB | app/src/main/java/com/architjn/audiobook/database/AudioBookTable.java | // Path: app/src/main/java/com/architjn/audiobook/bean/AudioBook.java
// public class AudioBook implements Serializable {
// private String albumId;
// private String albumKey;
// private String albumName;
// private String artistName;
// private String albumArt;
// private int status;
// private long duration;
// private long currentDuration;
// private ArrayList<BookChapter> chapters;
//
// public AudioBook() {
// //for serializable
// }
//
// public AudioBook(String albumId, String albumKey, String albumName, String artistName,
// String albumArt, int status, long duration, long currentDuration) {
// this.albumId = albumId;
// this.albumKey = albumKey;
// this.albumName = albumName;
// this.artistName = artistName;
// this.albumArt = albumArt;
// this.status = status;
// this.duration = duration;
// this.currentDuration = currentDuration;
// }
//
// public String getAlbumKey() {
// return albumKey;
// }
//
// public String getAlbumId() {
// return albumId;
// }
//
// public String getAlbumName() {
// return albumName;
// }
//
// public String getArtistName() {
// return artistName;
// }
//
// public long getDuration() {
// return duration;
// }
//
// public void setChapters(ArrayList<BookChapter> chapters) {
// this.chapters = chapters;
// }
//
// public ArrayList<BookChapter> getChapters() {
// return chapters;
// }
//
// public String getAlbumArt() {
// return albumArt;
// }
//
// public int getStatus() {
// return status;
// }
//
// public void setStatus(int status) {
// this.status = status;
// }
//
// public void setAlbumId(String albumId) {
// this.albumId = albumId;
// }
//
// public void setAlbumKey(String albumKey) {
// this.albumKey = albumKey;
// }
//
// public void setAlbumName(String albumName) {
// this.albumName = albumName;
// }
//
// public void setArtistName(String artistName) {
// this.artistName = artistName;
// }
//
// public void setAlbumArt(String albumArt) {
// this.albumArt = albumArt;
// }
//
// public void setDuration(long duration) {
// this.duration = duration;
// }
//
// public long getCurrentDuration() {
// return currentDuration;
// }
//
// public void setCurrentDuration(long currentDuration) {
// this.currentDuration = currentDuration;
// }
// }
//
// Path: app/src/main/java/com/architjn/audiobook/bean/BookChapter.java
// public class BookChapter implements Serializable{
// private String id;
// private String title;
// private long duration;
// private String data;
// private long currDuration;
//
// public BookChapter() {
// //for serializable
// }
//
// public BookChapter(String id, String title, long duration, String data, long currDuration) {
// this.id = id;
// this.title = title;
// this.duration = duration;
// this.data = data;
// this.currDuration = currDuration;
// }
//
// public String getId() {
// return id;
// }
//
// public String getTitle() {
// return title;
// }
//
// public long getDuration() {
// return duration;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public void setTitle(String title) {
// this.title = title;
// }
//
// public void setDuration(long duration) {
// this.duration = duration;
// }
//
// public String getData() {
// return data;
// }
//
// public void setData(String data) {
// this.data = data;
// }
//
// public long getCurrDuration() {
// return currDuration;
// }
//
// public void setCurrDuration(long currDuration) {
// this.currDuration = currDuration;
// }
// }
| import android.content.ContentValues;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import com.architjn.audiobook.bean.AudioBook;
import com.architjn.audiobook.bean.BookChapter;
import java.util.ArrayList; | package com.architjn.audiobook.database;
/**
* Created by Archit on 25-07-2017.
*/
public class AudioBookTable {
private static String TABLE_NAME = "audiobook";
private static final String ALBUM_ID = "album_id";
private static final String ALBUM_KEY = "album_key";
private static final String ALBUM_NAME = "album_name";
private static final String ALBUM_ART = "album_art";
private static final String ALBUM_STATUS = "album_status";
private static final String ARTIST_NAME = "artist_name";
private static final String COMPLETE_DURATION = "complete_duration";
private static final String CURRENT_DURATION = "current_duration";
public static void onCreate(SQLiteDatabase db) {
String CREATE_TABLE = "CREATE TABLE " + TABLE_NAME + " (" +
ALBUM_ID + " TEXT PRIMARY KEY," +
ALBUM_KEY + " TEXT," +
ALBUM_NAME + " TEXT," +
ALBUM_ART + " TEXT," +
ARTIST_NAME + " TEXT," +
CURRENT_DURATION + " TEXT DEFAULT 0," +
ALBUM_STATUS + " INTEGER DEFAULT 0," +
COMPLETE_DURATION + " TEXT)";
db.execSQL(CREATE_TABLE);
}
| // Path: app/src/main/java/com/architjn/audiobook/bean/AudioBook.java
// public class AudioBook implements Serializable {
// private String albumId;
// private String albumKey;
// private String albumName;
// private String artistName;
// private String albumArt;
// private int status;
// private long duration;
// private long currentDuration;
// private ArrayList<BookChapter> chapters;
//
// public AudioBook() {
// //for serializable
// }
//
// public AudioBook(String albumId, String albumKey, String albumName, String artistName,
// String albumArt, int status, long duration, long currentDuration) {
// this.albumId = albumId;
// this.albumKey = albumKey;
// this.albumName = albumName;
// this.artistName = artistName;
// this.albumArt = albumArt;
// this.status = status;
// this.duration = duration;
// this.currentDuration = currentDuration;
// }
//
// public String getAlbumKey() {
// return albumKey;
// }
//
// public String getAlbumId() {
// return albumId;
// }
//
// public String getAlbumName() {
// return albumName;
// }
//
// public String getArtistName() {
// return artistName;
// }
//
// public long getDuration() {
// return duration;
// }
//
// public void setChapters(ArrayList<BookChapter> chapters) {
// this.chapters = chapters;
// }
//
// public ArrayList<BookChapter> getChapters() {
// return chapters;
// }
//
// public String getAlbumArt() {
// return albumArt;
// }
//
// public int getStatus() {
// return status;
// }
//
// public void setStatus(int status) {
// this.status = status;
// }
//
// public void setAlbumId(String albumId) {
// this.albumId = albumId;
// }
//
// public void setAlbumKey(String albumKey) {
// this.albumKey = albumKey;
// }
//
// public void setAlbumName(String albumName) {
// this.albumName = albumName;
// }
//
// public void setArtistName(String artistName) {
// this.artistName = artistName;
// }
//
// public void setAlbumArt(String albumArt) {
// this.albumArt = albumArt;
// }
//
// public void setDuration(long duration) {
// this.duration = duration;
// }
//
// public long getCurrentDuration() {
// return currentDuration;
// }
//
// public void setCurrentDuration(long currentDuration) {
// this.currentDuration = currentDuration;
// }
// }
//
// Path: app/src/main/java/com/architjn/audiobook/bean/BookChapter.java
// public class BookChapter implements Serializable{
// private String id;
// private String title;
// private long duration;
// private String data;
// private long currDuration;
//
// public BookChapter() {
// //for serializable
// }
//
// public BookChapter(String id, String title, long duration, String data, long currDuration) {
// this.id = id;
// this.title = title;
// this.duration = duration;
// this.data = data;
// this.currDuration = currDuration;
// }
//
// public String getId() {
// return id;
// }
//
// public String getTitle() {
// return title;
// }
//
// public long getDuration() {
// return duration;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public void setTitle(String title) {
// this.title = title;
// }
//
// public void setDuration(long duration) {
// this.duration = duration;
// }
//
// public String getData() {
// return data;
// }
//
// public void setData(String data) {
// this.data = data;
// }
//
// public long getCurrDuration() {
// return currDuration;
// }
//
// public void setCurrDuration(long currDuration) {
// this.currDuration = currDuration;
// }
// }
// Path: app/src/main/java/com/architjn/audiobook/database/AudioBookTable.java
import android.content.ContentValues;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import com.architjn.audiobook.bean.AudioBook;
import com.architjn.audiobook.bean.BookChapter;
import java.util.ArrayList;
package com.architjn.audiobook.database;
/**
* Created by Archit on 25-07-2017.
*/
public class AudioBookTable {
private static String TABLE_NAME = "audiobook";
private static final String ALBUM_ID = "album_id";
private static final String ALBUM_KEY = "album_key";
private static final String ALBUM_NAME = "album_name";
private static final String ALBUM_ART = "album_art";
private static final String ALBUM_STATUS = "album_status";
private static final String ARTIST_NAME = "artist_name";
private static final String COMPLETE_DURATION = "complete_duration";
private static final String CURRENT_DURATION = "current_duration";
public static void onCreate(SQLiteDatabase db) {
String CREATE_TABLE = "CREATE TABLE " + TABLE_NAME + " (" +
ALBUM_ID + " TEXT PRIMARY KEY," +
ALBUM_KEY + " TEXT," +
ALBUM_NAME + " TEXT," +
ALBUM_ART + " TEXT," +
ARTIST_NAME + " TEXT," +
CURRENT_DURATION + " TEXT DEFAULT 0," +
ALBUM_STATUS + " INTEGER DEFAULT 0," +
COMPLETE_DURATION + " TEXT)";
db.execSQL(CREATE_TABLE);
}
| public static long addBook(SQLiteDatabase db, AudioBook audioBook) { |
architjn/YAAB | app/src/main/java/com/architjn/audiobook/database/AudioBookTable.java | // Path: app/src/main/java/com/architjn/audiobook/bean/AudioBook.java
// public class AudioBook implements Serializable {
// private String albumId;
// private String albumKey;
// private String albumName;
// private String artistName;
// private String albumArt;
// private int status;
// private long duration;
// private long currentDuration;
// private ArrayList<BookChapter> chapters;
//
// public AudioBook() {
// //for serializable
// }
//
// public AudioBook(String albumId, String albumKey, String albumName, String artistName,
// String albumArt, int status, long duration, long currentDuration) {
// this.albumId = albumId;
// this.albumKey = albumKey;
// this.albumName = albumName;
// this.artistName = artistName;
// this.albumArt = albumArt;
// this.status = status;
// this.duration = duration;
// this.currentDuration = currentDuration;
// }
//
// public String getAlbumKey() {
// return albumKey;
// }
//
// public String getAlbumId() {
// return albumId;
// }
//
// public String getAlbumName() {
// return albumName;
// }
//
// public String getArtistName() {
// return artistName;
// }
//
// public long getDuration() {
// return duration;
// }
//
// public void setChapters(ArrayList<BookChapter> chapters) {
// this.chapters = chapters;
// }
//
// public ArrayList<BookChapter> getChapters() {
// return chapters;
// }
//
// public String getAlbumArt() {
// return albumArt;
// }
//
// public int getStatus() {
// return status;
// }
//
// public void setStatus(int status) {
// this.status = status;
// }
//
// public void setAlbumId(String albumId) {
// this.albumId = albumId;
// }
//
// public void setAlbumKey(String albumKey) {
// this.albumKey = albumKey;
// }
//
// public void setAlbumName(String albumName) {
// this.albumName = albumName;
// }
//
// public void setArtistName(String artistName) {
// this.artistName = artistName;
// }
//
// public void setAlbumArt(String albumArt) {
// this.albumArt = albumArt;
// }
//
// public void setDuration(long duration) {
// this.duration = duration;
// }
//
// public long getCurrentDuration() {
// return currentDuration;
// }
//
// public void setCurrentDuration(long currentDuration) {
// this.currentDuration = currentDuration;
// }
// }
//
// Path: app/src/main/java/com/architjn/audiobook/bean/BookChapter.java
// public class BookChapter implements Serializable{
// private String id;
// private String title;
// private long duration;
// private String data;
// private long currDuration;
//
// public BookChapter() {
// //for serializable
// }
//
// public BookChapter(String id, String title, long duration, String data, long currDuration) {
// this.id = id;
// this.title = title;
// this.duration = duration;
// this.data = data;
// this.currDuration = currDuration;
// }
//
// public String getId() {
// return id;
// }
//
// public String getTitle() {
// return title;
// }
//
// public long getDuration() {
// return duration;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public void setTitle(String title) {
// this.title = title;
// }
//
// public void setDuration(long duration) {
// this.duration = duration;
// }
//
// public String getData() {
// return data;
// }
//
// public void setData(String data) {
// this.data = data;
// }
//
// public long getCurrDuration() {
// return currDuration;
// }
//
// public void setCurrDuration(long currDuration) {
// this.currDuration = currDuration;
// }
// }
| import android.content.ContentValues;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import com.architjn.audiobook.bean.AudioBook;
import com.architjn.audiobook.bean.BookChapter;
import java.util.ArrayList; | COMPLETE_DURATION + " TEXT)";
db.execSQL(CREATE_TABLE);
}
public static long addBook(SQLiteDatabase db, AudioBook audioBook) {
ContentValues values = new ContentValues();
values.put(ALBUM_ID, audioBook.getAlbumId());
values.put(ALBUM_KEY, audioBook.getAlbumKey());
values.put(ALBUM_NAME, audioBook.getAlbumName());
values.put(ALBUM_ART, audioBook.getAlbumArt());
values.put(ARTIST_NAME, audioBook.getArtistName());
values.put(COMPLETE_DURATION, audioBook.getDuration());
return db.insertWithOnConflict(TABLE_NAME, null, values, SQLiteDatabase.CONFLICT_IGNORE);
}
public static ArrayList<AudioBook> getAllBooks(SQLiteDatabase db) {
String query = "SELECT * FROM " + TABLE_NAME;
Cursor cursor = db.rawQuery(query, null);
ArrayList<AudioBook> books = new ArrayList<>();
if (cursor != null && cursor.moveToFirst()) {
do {
AudioBook audiobook = new AudioBook(
cursor.getString(cursor.getColumnIndex(ALBUM_ID)),
cursor.getString(cursor.getColumnIndex(ALBUM_KEY)),
cursor.getString(cursor.getColumnIndex(ALBUM_NAME)),
cursor.getString(cursor.getColumnIndex(ARTIST_NAME)),
cursor.getString(cursor.getColumnIndex(ALBUM_ART)),
cursor.getInt(cursor.getColumnIndex(ALBUM_STATUS)),
Long.parseLong(cursor.getString(cursor.getColumnIndex(COMPLETE_DURATION))),
Long.parseLong(cursor.getString(cursor.getColumnIndex(CURRENT_DURATION)))); | // Path: app/src/main/java/com/architjn/audiobook/bean/AudioBook.java
// public class AudioBook implements Serializable {
// private String albumId;
// private String albumKey;
// private String albumName;
// private String artistName;
// private String albumArt;
// private int status;
// private long duration;
// private long currentDuration;
// private ArrayList<BookChapter> chapters;
//
// public AudioBook() {
// //for serializable
// }
//
// public AudioBook(String albumId, String albumKey, String albumName, String artistName,
// String albumArt, int status, long duration, long currentDuration) {
// this.albumId = albumId;
// this.albumKey = albumKey;
// this.albumName = albumName;
// this.artistName = artistName;
// this.albumArt = albumArt;
// this.status = status;
// this.duration = duration;
// this.currentDuration = currentDuration;
// }
//
// public String getAlbumKey() {
// return albumKey;
// }
//
// public String getAlbumId() {
// return albumId;
// }
//
// public String getAlbumName() {
// return albumName;
// }
//
// public String getArtistName() {
// return artistName;
// }
//
// public long getDuration() {
// return duration;
// }
//
// public void setChapters(ArrayList<BookChapter> chapters) {
// this.chapters = chapters;
// }
//
// public ArrayList<BookChapter> getChapters() {
// return chapters;
// }
//
// public String getAlbumArt() {
// return albumArt;
// }
//
// public int getStatus() {
// return status;
// }
//
// public void setStatus(int status) {
// this.status = status;
// }
//
// public void setAlbumId(String albumId) {
// this.albumId = albumId;
// }
//
// public void setAlbumKey(String albumKey) {
// this.albumKey = albumKey;
// }
//
// public void setAlbumName(String albumName) {
// this.albumName = albumName;
// }
//
// public void setArtistName(String artistName) {
// this.artistName = artistName;
// }
//
// public void setAlbumArt(String albumArt) {
// this.albumArt = albumArt;
// }
//
// public void setDuration(long duration) {
// this.duration = duration;
// }
//
// public long getCurrentDuration() {
// return currentDuration;
// }
//
// public void setCurrentDuration(long currentDuration) {
// this.currentDuration = currentDuration;
// }
// }
//
// Path: app/src/main/java/com/architjn/audiobook/bean/BookChapter.java
// public class BookChapter implements Serializable{
// private String id;
// private String title;
// private long duration;
// private String data;
// private long currDuration;
//
// public BookChapter() {
// //for serializable
// }
//
// public BookChapter(String id, String title, long duration, String data, long currDuration) {
// this.id = id;
// this.title = title;
// this.duration = duration;
// this.data = data;
// this.currDuration = currDuration;
// }
//
// public String getId() {
// return id;
// }
//
// public String getTitle() {
// return title;
// }
//
// public long getDuration() {
// return duration;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public void setTitle(String title) {
// this.title = title;
// }
//
// public void setDuration(long duration) {
// this.duration = duration;
// }
//
// public String getData() {
// return data;
// }
//
// public void setData(String data) {
// this.data = data;
// }
//
// public long getCurrDuration() {
// return currDuration;
// }
//
// public void setCurrDuration(long currDuration) {
// this.currDuration = currDuration;
// }
// }
// Path: app/src/main/java/com/architjn/audiobook/database/AudioBookTable.java
import android.content.ContentValues;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import com.architjn.audiobook.bean.AudioBook;
import com.architjn.audiobook.bean.BookChapter;
import java.util.ArrayList;
COMPLETE_DURATION + " TEXT)";
db.execSQL(CREATE_TABLE);
}
public static long addBook(SQLiteDatabase db, AudioBook audioBook) {
ContentValues values = new ContentValues();
values.put(ALBUM_ID, audioBook.getAlbumId());
values.put(ALBUM_KEY, audioBook.getAlbumKey());
values.put(ALBUM_NAME, audioBook.getAlbumName());
values.put(ALBUM_ART, audioBook.getAlbumArt());
values.put(ARTIST_NAME, audioBook.getArtistName());
values.put(COMPLETE_DURATION, audioBook.getDuration());
return db.insertWithOnConflict(TABLE_NAME, null, values, SQLiteDatabase.CONFLICT_IGNORE);
}
public static ArrayList<AudioBook> getAllBooks(SQLiteDatabase db) {
String query = "SELECT * FROM " + TABLE_NAME;
Cursor cursor = db.rawQuery(query, null);
ArrayList<AudioBook> books = new ArrayList<>();
if (cursor != null && cursor.moveToFirst()) {
do {
AudioBook audiobook = new AudioBook(
cursor.getString(cursor.getColumnIndex(ALBUM_ID)),
cursor.getString(cursor.getColumnIndex(ALBUM_KEY)),
cursor.getString(cursor.getColumnIndex(ALBUM_NAME)),
cursor.getString(cursor.getColumnIndex(ARTIST_NAME)),
cursor.getString(cursor.getColumnIndex(ALBUM_ART)),
cursor.getInt(cursor.getColumnIndex(ALBUM_STATUS)),
Long.parseLong(cursor.getString(cursor.getColumnIndex(COMPLETE_DURATION))),
Long.parseLong(cursor.getString(cursor.getColumnIndex(CURRENT_DURATION)))); | ArrayList<BookChapter> chapters = |
architjn/YAAB | app/src/main/java/com/architjn/audiobook/database/ChapterTable.java | // Path: app/src/main/java/com/architjn/audiobook/bean/AudioBook.java
// public class AudioBook implements Serializable {
// private String albumId;
// private String albumKey;
// private String albumName;
// private String artistName;
// private String albumArt;
// private int status;
// private long duration;
// private long currentDuration;
// private ArrayList<BookChapter> chapters;
//
// public AudioBook() {
// //for serializable
// }
//
// public AudioBook(String albumId, String albumKey, String albumName, String artistName,
// String albumArt, int status, long duration, long currentDuration) {
// this.albumId = albumId;
// this.albumKey = albumKey;
// this.albumName = albumName;
// this.artistName = artistName;
// this.albumArt = albumArt;
// this.status = status;
// this.duration = duration;
// this.currentDuration = currentDuration;
// }
//
// public String getAlbumKey() {
// return albumKey;
// }
//
// public String getAlbumId() {
// return albumId;
// }
//
// public String getAlbumName() {
// return albumName;
// }
//
// public String getArtistName() {
// return artistName;
// }
//
// public long getDuration() {
// return duration;
// }
//
// public void setChapters(ArrayList<BookChapter> chapters) {
// this.chapters = chapters;
// }
//
// public ArrayList<BookChapter> getChapters() {
// return chapters;
// }
//
// public String getAlbumArt() {
// return albumArt;
// }
//
// public int getStatus() {
// return status;
// }
//
// public void setStatus(int status) {
// this.status = status;
// }
//
// public void setAlbumId(String albumId) {
// this.albumId = albumId;
// }
//
// public void setAlbumKey(String albumKey) {
// this.albumKey = albumKey;
// }
//
// public void setAlbumName(String albumName) {
// this.albumName = albumName;
// }
//
// public void setArtistName(String artistName) {
// this.artistName = artistName;
// }
//
// public void setAlbumArt(String albumArt) {
// this.albumArt = albumArt;
// }
//
// public void setDuration(long duration) {
// this.duration = duration;
// }
//
// public long getCurrentDuration() {
// return currentDuration;
// }
//
// public void setCurrentDuration(long currentDuration) {
// this.currentDuration = currentDuration;
// }
// }
//
// Path: app/src/main/java/com/architjn/audiobook/bean/BookChapter.java
// public class BookChapter implements Serializable{
// private String id;
// private String title;
// private long duration;
// private String data;
// private long currDuration;
//
// public BookChapter() {
// //for serializable
// }
//
// public BookChapter(String id, String title, long duration, String data, long currDuration) {
// this.id = id;
// this.title = title;
// this.duration = duration;
// this.data = data;
// this.currDuration = currDuration;
// }
//
// public String getId() {
// return id;
// }
//
// public String getTitle() {
// return title;
// }
//
// public long getDuration() {
// return duration;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public void setTitle(String title) {
// this.title = title;
// }
//
// public void setDuration(long duration) {
// this.duration = duration;
// }
//
// public String getData() {
// return data;
// }
//
// public void setData(String data) {
// this.data = data;
// }
//
// public long getCurrDuration() {
// return currDuration;
// }
//
// public void setCurrDuration(long currDuration) {
// this.currDuration = currDuration;
// }
// }
| import android.content.ContentValues;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.nfc.tech.NfcA;
import com.architjn.audiobook.bean.AudioBook;
import com.architjn.audiobook.bean.BookChapter;
import java.util.ArrayList; | package com.architjn.audiobook.database;
/**
* Created by Archit on 25-07-2017.
*/
public class ChapterTable {
private static final String ID = "chapter_id";
private static final String TITLE = "chapter_title";
private static final String ALBUM_ID = "chapter_album_id";
private static final String DURATION = "chapter_duration";
private static final String CURRENT_DURATION = "chapter_curr_duration";
private static final String PATH = "path";
private static String TABLE_NAME = "chapter";
public static void onCreate(SQLiteDatabase db) {
String CREATE_TABLE = "CREATE TABLE " + TABLE_NAME + " (" +
ID + " TEXT PRIMARY KEY," +
TITLE + " TEXT," +
ALBUM_ID + " TEXT," +
PATH + " TEXT," +
CURRENT_DURATION + " TEXT DEFAULT 0," +
DURATION + " TEXT)";
db.execSQL(CREATE_TABLE);
}
public static void addChapters(SQLiteDatabase db, String albumId, | // Path: app/src/main/java/com/architjn/audiobook/bean/AudioBook.java
// public class AudioBook implements Serializable {
// private String albumId;
// private String albumKey;
// private String albumName;
// private String artistName;
// private String albumArt;
// private int status;
// private long duration;
// private long currentDuration;
// private ArrayList<BookChapter> chapters;
//
// public AudioBook() {
// //for serializable
// }
//
// public AudioBook(String albumId, String albumKey, String albumName, String artistName,
// String albumArt, int status, long duration, long currentDuration) {
// this.albumId = albumId;
// this.albumKey = albumKey;
// this.albumName = albumName;
// this.artistName = artistName;
// this.albumArt = albumArt;
// this.status = status;
// this.duration = duration;
// this.currentDuration = currentDuration;
// }
//
// public String getAlbumKey() {
// return albumKey;
// }
//
// public String getAlbumId() {
// return albumId;
// }
//
// public String getAlbumName() {
// return albumName;
// }
//
// public String getArtistName() {
// return artistName;
// }
//
// public long getDuration() {
// return duration;
// }
//
// public void setChapters(ArrayList<BookChapter> chapters) {
// this.chapters = chapters;
// }
//
// public ArrayList<BookChapter> getChapters() {
// return chapters;
// }
//
// public String getAlbumArt() {
// return albumArt;
// }
//
// public int getStatus() {
// return status;
// }
//
// public void setStatus(int status) {
// this.status = status;
// }
//
// public void setAlbumId(String albumId) {
// this.albumId = albumId;
// }
//
// public void setAlbumKey(String albumKey) {
// this.albumKey = albumKey;
// }
//
// public void setAlbumName(String albumName) {
// this.albumName = albumName;
// }
//
// public void setArtistName(String artistName) {
// this.artistName = artistName;
// }
//
// public void setAlbumArt(String albumArt) {
// this.albumArt = albumArt;
// }
//
// public void setDuration(long duration) {
// this.duration = duration;
// }
//
// public long getCurrentDuration() {
// return currentDuration;
// }
//
// public void setCurrentDuration(long currentDuration) {
// this.currentDuration = currentDuration;
// }
// }
//
// Path: app/src/main/java/com/architjn/audiobook/bean/BookChapter.java
// public class BookChapter implements Serializable{
// private String id;
// private String title;
// private long duration;
// private String data;
// private long currDuration;
//
// public BookChapter() {
// //for serializable
// }
//
// public BookChapter(String id, String title, long duration, String data, long currDuration) {
// this.id = id;
// this.title = title;
// this.duration = duration;
// this.data = data;
// this.currDuration = currDuration;
// }
//
// public String getId() {
// return id;
// }
//
// public String getTitle() {
// return title;
// }
//
// public long getDuration() {
// return duration;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public void setTitle(String title) {
// this.title = title;
// }
//
// public void setDuration(long duration) {
// this.duration = duration;
// }
//
// public String getData() {
// return data;
// }
//
// public void setData(String data) {
// this.data = data;
// }
//
// public long getCurrDuration() {
// return currDuration;
// }
//
// public void setCurrDuration(long currDuration) {
// this.currDuration = currDuration;
// }
// }
// Path: app/src/main/java/com/architjn/audiobook/database/ChapterTable.java
import android.content.ContentValues;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.nfc.tech.NfcA;
import com.architjn.audiobook.bean.AudioBook;
import com.architjn.audiobook.bean.BookChapter;
import java.util.ArrayList;
package com.architjn.audiobook.database;
/**
* Created by Archit on 25-07-2017.
*/
public class ChapterTable {
private static final String ID = "chapter_id";
private static final String TITLE = "chapter_title";
private static final String ALBUM_ID = "chapter_album_id";
private static final String DURATION = "chapter_duration";
private static final String CURRENT_DURATION = "chapter_curr_duration";
private static final String PATH = "path";
private static String TABLE_NAME = "chapter";
public static void onCreate(SQLiteDatabase db) {
String CREATE_TABLE = "CREATE TABLE " + TABLE_NAME + " (" +
ID + " TEXT PRIMARY KEY," +
TITLE + " TEXT," +
ALBUM_ID + " TEXT," +
PATH + " TEXT," +
CURRENT_DURATION + " TEXT DEFAULT 0," +
DURATION + " TEXT)";
db.execSQL(CREATE_TABLE);
}
public static void addChapters(SQLiteDatabase db, String albumId, | ArrayList<BookChapter> chapters) { |
architjn/YAAB | app/src/main/java/com/architjn/audiobook/interactor/AllAudioBookInteractor.java | // Path: app/src/main/java/com/architjn/audiobook/bean/AudioBook.java
// public class AudioBook implements Serializable {
// private String albumId;
// private String albumKey;
// private String albumName;
// private String artistName;
// private String albumArt;
// private int status;
// private long duration;
// private long currentDuration;
// private ArrayList<BookChapter> chapters;
//
// public AudioBook() {
// //for serializable
// }
//
// public AudioBook(String albumId, String albumKey, String albumName, String artistName,
// String albumArt, int status, long duration, long currentDuration) {
// this.albumId = albumId;
// this.albumKey = albumKey;
// this.albumName = albumName;
// this.artistName = artistName;
// this.albumArt = albumArt;
// this.status = status;
// this.duration = duration;
// this.currentDuration = currentDuration;
// }
//
// public String getAlbumKey() {
// return albumKey;
// }
//
// public String getAlbumId() {
// return albumId;
// }
//
// public String getAlbumName() {
// return albumName;
// }
//
// public String getArtistName() {
// return artistName;
// }
//
// public long getDuration() {
// return duration;
// }
//
// public void setChapters(ArrayList<BookChapter> chapters) {
// this.chapters = chapters;
// }
//
// public ArrayList<BookChapter> getChapters() {
// return chapters;
// }
//
// public String getAlbumArt() {
// return albumArt;
// }
//
// public int getStatus() {
// return status;
// }
//
// public void setStatus(int status) {
// this.status = status;
// }
//
// public void setAlbumId(String albumId) {
// this.albumId = albumId;
// }
//
// public void setAlbumKey(String albumKey) {
// this.albumKey = albumKey;
// }
//
// public void setAlbumName(String albumName) {
// this.albumName = albumName;
// }
//
// public void setArtistName(String artistName) {
// this.artistName = artistName;
// }
//
// public void setAlbumArt(String albumArt) {
// this.albumArt = albumArt;
// }
//
// public void setDuration(long duration) {
// this.duration = duration;
// }
//
// public long getCurrentDuration() {
// return currentDuration;
// }
//
// public void setCurrentDuration(long currentDuration) {
// this.currentDuration = currentDuration;
// }
// }
//
// Path: app/src/main/java/com/architjn/audiobook/database/DBHelper.java
// public class DBHelper extends SQLiteOpenHelper {
//
// private static final String DATABASE_NAME = "yaab-db";
// private static final int DATABASE_VERSION = 1;
//
// private static DBHelper instance;
//
// private final Context context;
//
// public static DBHelper getInstance(Context context) {
// if (instance == null)
// instance = new DBHelper(context);
// return instance;
// }
//
// private DBHelper(Context context) {
// super(context, DATABASE_NAME, null, DATABASE_VERSION);
// this.context = context;
// }
//
// @Override
// public void onCreate(SQLiteDatabase db) {
// AudioBookTable.onCreate(db);
// ChapterTable.onCreate(db);
// }
//
// @Override
// public void onUpgrade(SQLiteDatabase sqLiteDatabase, int i, int i1) {
//
// }
//
// public boolean addAudioBook(AudioBook audioBook) {
// if (AudioBookTable.addBook(this.getWritableDatabase(), audioBook) != -1) {
// ChapterTable.addChapters(this.getWritableDatabase(), audioBook.getAlbumId(),
// audioBook.getChapters());
// return true;
// } else return false;
// }
//
// public ArrayList<AudioBook> loadAllAudioBooks() {
// return AudioBookTable.getAllBooks(this.getReadableDatabase());
// }
//
// public ArrayList<AudioBook> loadNewAudioBooks() {
// return AudioBookTable.getNewBooks(this.getReadableDatabase());
// }
//
// public ArrayList<AudioBook> loadOnGoingAudioBooks() {
// return AudioBookTable.getOnGoingBooks(this.getReadableDatabase());
// }
//
// public void updateBookStatus(String albumId, int status) {
// AudioBookTable.setBookStatus(this.getWritableDatabase(), albumId, status);
// }
//
// public int getOnGoingBooksCount() {
// return AudioBookTable.getOnGoingDataCount(this.getWritableDatabase());
// }
// public int getNewBooksCount() {
// return AudioBookTable.getNewDataCount(this.getWritableDatabase());
// }
//
// public AudioBook getAudioBookViaId(String albumId) {
// return AudioBookTable.getAudioBook(this.getReadableDatabase(), albumId);
// }
// }
//
// Path: app/src/main/java/com/architjn/audiobook/interfaces/IAllAudioBookPresenter.java
// public interface IAllAudioBookPresenter {
// void onAudioBooksLoaded(ArrayList<AudioBook> books);
// }
| import android.content.Context;
import android.os.Handler;
import com.architjn.audiobook.bean.AudioBook;
import com.architjn.audiobook.database.DBHelper;
import com.architjn.audiobook.interfaces.IAllAudioBookPresenter;
import java.util.ArrayList; | package com.architjn.audiobook.interactor;
/**
* Created by Archit on 25-07-2017.
*/
public class AllAudioBookInteractor {
private final DBHelper dbHandler; | // Path: app/src/main/java/com/architjn/audiobook/bean/AudioBook.java
// public class AudioBook implements Serializable {
// private String albumId;
// private String albumKey;
// private String albumName;
// private String artistName;
// private String albumArt;
// private int status;
// private long duration;
// private long currentDuration;
// private ArrayList<BookChapter> chapters;
//
// public AudioBook() {
// //for serializable
// }
//
// public AudioBook(String albumId, String albumKey, String albumName, String artistName,
// String albumArt, int status, long duration, long currentDuration) {
// this.albumId = albumId;
// this.albumKey = albumKey;
// this.albumName = albumName;
// this.artistName = artistName;
// this.albumArt = albumArt;
// this.status = status;
// this.duration = duration;
// this.currentDuration = currentDuration;
// }
//
// public String getAlbumKey() {
// return albumKey;
// }
//
// public String getAlbumId() {
// return albumId;
// }
//
// public String getAlbumName() {
// return albumName;
// }
//
// public String getArtistName() {
// return artistName;
// }
//
// public long getDuration() {
// return duration;
// }
//
// public void setChapters(ArrayList<BookChapter> chapters) {
// this.chapters = chapters;
// }
//
// public ArrayList<BookChapter> getChapters() {
// return chapters;
// }
//
// public String getAlbumArt() {
// return albumArt;
// }
//
// public int getStatus() {
// return status;
// }
//
// public void setStatus(int status) {
// this.status = status;
// }
//
// public void setAlbumId(String albumId) {
// this.albumId = albumId;
// }
//
// public void setAlbumKey(String albumKey) {
// this.albumKey = albumKey;
// }
//
// public void setAlbumName(String albumName) {
// this.albumName = albumName;
// }
//
// public void setArtistName(String artistName) {
// this.artistName = artistName;
// }
//
// public void setAlbumArt(String albumArt) {
// this.albumArt = albumArt;
// }
//
// public void setDuration(long duration) {
// this.duration = duration;
// }
//
// public long getCurrentDuration() {
// return currentDuration;
// }
//
// public void setCurrentDuration(long currentDuration) {
// this.currentDuration = currentDuration;
// }
// }
//
// Path: app/src/main/java/com/architjn/audiobook/database/DBHelper.java
// public class DBHelper extends SQLiteOpenHelper {
//
// private static final String DATABASE_NAME = "yaab-db";
// private static final int DATABASE_VERSION = 1;
//
// private static DBHelper instance;
//
// private final Context context;
//
// public static DBHelper getInstance(Context context) {
// if (instance == null)
// instance = new DBHelper(context);
// return instance;
// }
//
// private DBHelper(Context context) {
// super(context, DATABASE_NAME, null, DATABASE_VERSION);
// this.context = context;
// }
//
// @Override
// public void onCreate(SQLiteDatabase db) {
// AudioBookTable.onCreate(db);
// ChapterTable.onCreate(db);
// }
//
// @Override
// public void onUpgrade(SQLiteDatabase sqLiteDatabase, int i, int i1) {
//
// }
//
// public boolean addAudioBook(AudioBook audioBook) {
// if (AudioBookTable.addBook(this.getWritableDatabase(), audioBook) != -1) {
// ChapterTable.addChapters(this.getWritableDatabase(), audioBook.getAlbumId(),
// audioBook.getChapters());
// return true;
// } else return false;
// }
//
// public ArrayList<AudioBook> loadAllAudioBooks() {
// return AudioBookTable.getAllBooks(this.getReadableDatabase());
// }
//
// public ArrayList<AudioBook> loadNewAudioBooks() {
// return AudioBookTable.getNewBooks(this.getReadableDatabase());
// }
//
// public ArrayList<AudioBook> loadOnGoingAudioBooks() {
// return AudioBookTable.getOnGoingBooks(this.getReadableDatabase());
// }
//
// public void updateBookStatus(String albumId, int status) {
// AudioBookTable.setBookStatus(this.getWritableDatabase(), albumId, status);
// }
//
// public int getOnGoingBooksCount() {
// return AudioBookTable.getOnGoingDataCount(this.getWritableDatabase());
// }
// public int getNewBooksCount() {
// return AudioBookTable.getNewDataCount(this.getWritableDatabase());
// }
//
// public AudioBook getAudioBookViaId(String albumId) {
// return AudioBookTable.getAudioBook(this.getReadableDatabase(), albumId);
// }
// }
//
// Path: app/src/main/java/com/architjn/audiobook/interfaces/IAllAudioBookPresenter.java
// public interface IAllAudioBookPresenter {
// void onAudioBooksLoaded(ArrayList<AudioBook> books);
// }
// Path: app/src/main/java/com/architjn/audiobook/interactor/AllAudioBookInteractor.java
import android.content.Context;
import android.os.Handler;
import com.architjn.audiobook.bean.AudioBook;
import com.architjn.audiobook.database.DBHelper;
import com.architjn.audiobook.interfaces.IAllAudioBookPresenter;
import java.util.ArrayList;
package com.architjn.audiobook.interactor;
/**
* Created by Archit on 25-07-2017.
*/
public class AllAudioBookInteractor {
private final DBHelper dbHandler; | private IAllAudioBookPresenter presenter; |
architjn/YAAB | app/src/main/java/com/architjn/audiobook/interactor/AllAudioBookInteractor.java | // Path: app/src/main/java/com/architjn/audiobook/bean/AudioBook.java
// public class AudioBook implements Serializable {
// private String albumId;
// private String albumKey;
// private String albumName;
// private String artistName;
// private String albumArt;
// private int status;
// private long duration;
// private long currentDuration;
// private ArrayList<BookChapter> chapters;
//
// public AudioBook() {
// //for serializable
// }
//
// public AudioBook(String albumId, String albumKey, String albumName, String artistName,
// String albumArt, int status, long duration, long currentDuration) {
// this.albumId = albumId;
// this.albumKey = albumKey;
// this.albumName = albumName;
// this.artistName = artistName;
// this.albumArt = albumArt;
// this.status = status;
// this.duration = duration;
// this.currentDuration = currentDuration;
// }
//
// public String getAlbumKey() {
// return albumKey;
// }
//
// public String getAlbumId() {
// return albumId;
// }
//
// public String getAlbumName() {
// return albumName;
// }
//
// public String getArtistName() {
// return artistName;
// }
//
// public long getDuration() {
// return duration;
// }
//
// public void setChapters(ArrayList<BookChapter> chapters) {
// this.chapters = chapters;
// }
//
// public ArrayList<BookChapter> getChapters() {
// return chapters;
// }
//
// public String getAlbumArt() {
// return albumArt;
// }
//
// public int getStatus() {
// return status;
// }
//
// public void setStatus(int status) {
// this.status = status;
// }
//
// public void setAlbumId(String albumId) {
// this.albumId = albumId;
// }
//
// public void setAlbumKey(String albumKey) {
// this.albumKey = albumKey;
// }
//
// public void setAlbumName(String albumName) {
// this.albumName = albumName;
// }
//
// public void setArtistName(String artistName) {
// this.artistName = artistName;
// }
//
// public void setAlbumArt(String albumArt) {
// this.albumArt = albumArt;
// }
//
// public void setDuration(long duration) {
// this.duration = duration;
// }
//
// public long getCurrentDuration() {
// return currentDuration;
// }
//
// public void setCurrentDuration(long currentDuration) {
// this.currentDuration = currentDuration;
// }
// }
//
// Path: app/src/main/java/com/architjn/audiobook/database/DBHelper.java
// public class DBHelper extends SQLiteOpenHelper {
//
// private static final String DATABASE_NAME = "yaab-db";
// private static final int DATABASE_VERSION = 1;
//
// private static DBHelper instance;
//
// private final Context context;
//
// public static DBHelper getInstance(Context context) {
// if (instance == null)
// instance = new DBHelper(context);
// return instance;
// }
//
// private DBHelper(Context context) {
// super(context, DATABASE_NAME, null, DATABASE_VERSION);
// this.context = context;
// }
//
// @Override
// public void onCreate(SQLiteDatabase db) {
// AudioBookTable.onCreate(db);
// ChapterTable.onCreate(db);
// }
//
// @Override
// public void onUpgrade(SQLiteDatabase sqLiteDatabase, int i, int i1) {
//
// }
//
// public boolean addAudioBook(AudioBook audioBook) {
// if (AudioBookTable.addBook(this.getWritableDatabase(), audioBook) != -1) {
// ChapterTable.addChapters(this.getWritableDatabase(), audioBook.getAlbumId(),
// audioBook.getChapters());
// return true;
// } else return false;
// }
//
// public ArrayList<AudioBook> loadAllAudioBooks() {
// return AudioBookTable.getAllBooks(this.getReadableDatabase());
// }
//
// public ArrayList<AudioBook> loadNewAudioBooks() {
// return AudioBookTable.getNewBooks(this.getReadableDatabase());
// }
//
// public ArrayList<AudioBook> loadOnGoingAudioBooks() {
// return AudioBookTable.getOnGoingBooks(this.getReadableDatabase());
// }
//
// public void updateBookStatus(String albumId, int status) {
// AudioBookTable.setBookStatus(this.getWritableDatabase(), albumId, status);
// }
//
// public int getOnGoingBooksCount() {
// return AudioBookTable.getOnGoingDataCount(this.getWritableDatabase());
// }
// public int getNewBooksCount() {
// return AudioBookTable.getNewDataCount(this.getWritableDatabase());
// }
//
// public AudioBook getAudioBookViaId(String albumId) {
// return AudioBookTable.getAudioBook(this.getReadableDatabase(), albumId);
// }
// }
//
// Path: app/src/main/java/com/architjn/audiobook/interfaces/IAllAudioBookPresenter.java
// public interface IAllAudioBookPresenter {
// void onAudioBooksLoaded(ArrayList<AudioBook> books);
// }
| import android.content.Context;
import android.os.Handler;
import com.architjn.audiobook.bean.AudioBook;
import com.architjn.audiobook.database.DBHelper;
import com.architjn.audiobook.interfaces.IAllAudioBookPresenter;
import java.util.ArrayList; | package com.architjn.audiobook.interactor;
/**
* Created by Archit on 25-07-2017.
*/
public class AllAudioBookInteractor {
private final DBHelper dbHandler;
private IAllAudioBookPresenter presenter; | // Path: app/src/main/java/com/architjn/audiobook/bean/AudioBook.java
// public class AudioBook implements Serializable {
// private String albumId;
// private String albumKey;
// private String albumName;
// private String artistName;
// private String albumArt;
// private int status;
// private long duration;
// private long currentDuration;
// private ArrayList<BookChapter> chapters;
//
// public AudioBook() {
// //for serializable
// }
//
// public AudioBook(String albumId, String albumKey, String albumName, String artistName,
// String albumArt, int status, long duration, long currentDuration) {
// this.albumId = albumId;
// this.albumKey = albumKey;
// this.albumName = albumName;
// this.artistName = artistName;
// this.albumArt = albumArt;
// this.status = status;
// this.duration = duration;
// this.currentDuration = currentDuration;
// }
//
// public String getAlbumKey() {
// return albumKey;
// }
//
// public String getAlbumId() {
// return albumId;
// }
//
// public String getAlbumName() {
// return albumName;
// }
//
// public String getArtistName() {
// return artistName;
// }
//
// public long getDuration() {
// return duration;
// }
//
// public void setChapters(ArrayList<BookChapter> chapters) {
// this.chapters = chapters;
// }
//
// public ArrayList<BookChapter> getChapters() {
// return chapters;
// }
//
// public String getAlbumArt() {
// return albumArt;
// }
//
// public int getStatus() {
// return status;
// }
//
// public void setStatus(int status) {
// this.status = status;
// }
//
// public void setAlbumId(String albumId) {
// this.albumId = albumId;
// }
//
// public void setAlbumKey(String albumKey) {
// this.albumKey = albumKey;
// }
//
// public void setAlbumName(String albumName) {
// this.albumName = albumName;
// }
//
// public void setArtistName(String artistName) {
// this.artistName = artistName;
// }
//
// public void setAlbumArt(String albumArt) {
// this.albumArt = albumArt;
// }
//
// public void setDuration(long duration) {
// this.duration = duration;
// }
//
// public long getCurrentDuration() {
// return currentDuration;
// }
//
// public void setCurrentDuration(long currentDuration) {
// this.currentDuration = currentDuration;
// }
// }
//
// Path: app/src/main/java/com/architjn/audiobook/database/DBHelper.java
// public class DBHelper extends SQLiteOpenHelper {
//
// private static final String DATABASE_NAME = "yaab-db";
// private static final int DATABASE_VERSION = 1;
//
// private static DBHelper instance;
//
// private final Context context;
//
// public static DBHelper getInstance(Context context) {
// if (instance == null)
// instance = new DBHelper(context);
// return instance;
// }
//
// private DBHelper(Context context) {
// super(context, DATABASE_NAME, null, DATABASE_VERSION);
// this.context = context;
// }
//
// @Override
// public void onCreate(SQLiteDatabase db) {
// AudioBookTable.onCreate(db);
// ChapterTable.onCreate(db);
// }
//
// @Override
// public void onUpgrade(SQLiteDatabase sqLiteDatabase, int i, int i1) {
//
// }
//
// public boolean addAudioBook(AudioBook audioBook) {
// if (AudioBookTable.addBook(this.getWritableDatabase(), audioBook) != -1) {
// ChapterTable.addChapters(this.getWritableDatabase(), audioBook.getAlbumId(),
// audioBook.getChapters());
// return true;
// } else return false;
// }
//
// public ArrayList<AudioBook> loadAllAudioBooks() {
// return AudioBookTable.getAllBooks(this.getReadableDatabase());
// }
//
// public ArrayList<AudioBook> loadNewAudioBooks() {
// return AudioBookTable.getNewBooks(this.getReadableDatabase());
// }
//
// public ArrayList<AudioBook> loadOnGoingAudioBooks() {
// return AudioBookTable.getOnGoingBooks(this.getReadableDatabase());
// }
//
// public void updateBookStatus(String albumId, int status) {
// AudioBookTable.setBookStatus(this.getWritableDatabase(), albumId, status);
// }
//
// public int getOnGoingBooksCount() {
// return AudioBookTable.getOnGoingDataCount(this.getWritableDatabase());
// }
// public int getNewBooksCount() {
// return AudioBookTable.getNewDataCount(this.getWritableDatabase());
// }
//
// public AudioBook getAudioBookViaId(String albumId) {
// return AudioBookTable.getAudioBook(this.getReadableDatabase(), albumId);
// }
// }
//
// Path: app/src/main/java/com/architjn/audiobook/interfaces/IAllAudioBookPresenter.java
// public interface IAllAudioBookPresenter {
// void onAudioBooksLoaded(ArrayList<AudioBook> books);
// }
// Path: app/src/main/java/com/architjn/audiobook/interactor/AllAudioBookInteractor.java
import android.content.Context;
import android.os.Handler;
import com.architjn.audiobook.bean.AudioBook;
import com.architjn.audiobook.database.DBHelper;
import com.architjn.audiobook.interfaces.IAllAudioBookPresenter;
import java.util.ArrayList;
package com.architjn.audiobook.interactor;
/**
* Created by Archit on 25-07-2017.
*/
public class AllAudioBookInteractor {
private final DBHelper dbHandler;
private IAllAudioBookPresenter presenter; | private ArrayList<AudioBook> books; |
architjn/YAAB | app/src/main/java/com/architjn/audiobook/utils/BookUtils.java | // Path: app/src/main/java/com/architjn/audiobook/bean/AudioBook.java
// public class AudioBook implements Serializable {
// private String albumId;
// private String albumKey;
// private String albumName;
// private String artistName;
// private String albumArt;
// private int status;
// private long duration;
// private long currentDuration;
// private ArrayList<BookChapter> chapters;
//
// public AudioBook() {
// //for serializable
// }
//
// public AudioBook(String albumId, String albumKey, String albumName, String artistName,
// String albumArt, int status, long duration, long currentDuration) {
// this.albumId = albumId;
// this.albumKey = albumKey;
// this.albumName = albumName;
// this.artistName = artistName;
// this.albumArt = albumArt;
// this.status = status;
// this.duration = duration;
// this.currentDuration = currentDuration;
// }
//
// public String getAlbumKey() {
// return albumKey;
// }
//
// public String getAlbumId() {
// return albumId;
// }
//
// public String getAlbumName() {
// return albumName;
// }
//
// public String getArtistName() {
// return artistName;
// }
//
// public long getDuration() {
// return duration;
// }
//
// public void setChapters(ArrayList<BookChapter> chapters) {
// this.chapters = chapters;
// }
//
// public ArrayList<BookChapter> getChapters() {
// return chapters;
// }
//
// public String getAlbumArt() {
// return albumArt;
// }
//
// public int getStatus() {
// return status;
// }
//
// public void setStatus(int status) {
// this.status = status;
// }
//
// public void setAlbumId(String albumId) {
// this.albumId = albumId;
// }
//
// public void setAlbumKey(String albumKey) {
// this.albumKey = albumKey;
// }
//
// public void setAlbumName(String albumName) {
// this.albumName = albumName;
// }
//
// public void setArtistName(String artistName) {
// this.artistName = artistName;
// }
//
// public void setAlbumArt(String albumArt) {
// this.albumArt = albumArt;
// }
//
// public void setDuration(long duration) {
// this.duration = duration;
// }
//
// public long getCurrentDuration() {
// return currentDuration;
// }
//
// public void setCurrentDuration(long currentDuration) {
// this.currentDuration = currentDuration;
// }
// }
//
// Path: app/src/main/java/com/architjn/audiobook/bean/BookChapter.java
// public class BookChapter implements Serializable{
// private String id;
// private String title;
// private long duration;
// private String data;
// private long currDuration;
//
// public BookChapter() {
// //for serializable
// }
//
// public BookChapter(String id, String title, long duration, String data, long currDuration) {
// this.id = id;
// this.title = title;
// this.duration = duration;
// this.data = data;
// this.currDuration = currDuration;
// }
//
// public String getId() {
// return id;
// }
//
// public String getTitle() {
// return title;
// }
//
// public long getDuration() {
// return duration;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public void setTitle(String title) {
// this.title = title;
// }
//
// public void setDuration(long duration) {
// this.duration = duration;
// }
//
// public String getData() {
// return data;
// }
//
// public void setData(String data) {
// this.data = data;
// }
//
// public long getCurrDuration() {
// return currDuration;
// }
//
// public void setCurrDuration(long currDuration) {
// this.currDuration = currDuration;
// }
// }
| import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
import android.provider.MediaStore;
import com.architjn.audiobook.bean.AudioBook;
import com.architjn.audiobook.bean.BookChapter;
import java.util.ArrayList; | package com.architjn.audiobook.utils;
/**
* Created by Archit on 25-07-2017.
*/
public class BookUtils {
private static Uri MEDIA_PROVIDER = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
| // Path: app/src/main/java/com/architjn/audiobook/bean/AudioBook.java
// public class AudioBook implements Serializable {
// private String albumId;
// private String albumKey;
// private String albumName;
// private String artistName;
// private String albumArt;
// private int status;
// private long duration;
// private long currentDuration;
// private ArrayList<BookChapter> chapters;
//
// public AudioBook() {
// //for serializable
// }
//
// public AudioBook(String albumId, String albumKey, String albumName, String artistName,
// String albumArt, int status, long duration, long currentDuration) {
// this.albumId = albumId;
// this.albumKey = albumKey;
// this.albumName = albumName;
// this.artistName = artistName;
// this.albumArt = albumArt;
// this.status = status;
// this.duration = duration;
// this.currentDuration = currentDuration;
// }
//
// public String getAlbumKey() {
// return albumKey;
// }
//
// public String getAlbumId() {
// return albumId;
// }
//
// public String getAlbumName() {
// return albumName;
// }
//
// public String getArtistName() {
// return artistName;
// }
//
// public long getDuration() {
// return duration;
// }
//
// public void setChapters(ArrayList<BookChapter> chapters) {
// this.chapters = chapters;
// }
//
// public ArrayList<BookChapter> getChapters() {
// return chapters;
// }
//
// public String getAlbumArt() {
// return albumArt;
// }
//
// public int getStatus() {
// return status;
// }
//
// public void setStatus(int status) {
// this.status = status;
// }
//
// public void setAlbumId(String albumId) {
// this.albumId = albumId;
// }
//
// public void setAlbumKey(String albumKey) {
// this.albumKey = albumKey;
// }
//
// public void setAlbumName(String albumName) {
// this.albumName = albumName;
// }
//
// public void setArtistName(String artistName) {
// this.artistName = artistName;
// }
//
// public void setAlbumArt(String albumArt) {
// this.albumArt = albumArt;
// }
//
// public void setDuration(long duration) {
// this.duration = duration;
// }
//
// public long getCurrentDuration() {
// return currentDuration;
// }
//
// public void setCurrentDuration(long currentDuration) {
// this.currentDuration = currentDuration;
// }
// }
//
// Path: app/src/main/java/com/architjn/audiobook/bean/BookChapter.java
// public class BookChapter implements Serializable{
// private String id;
// private String title;
// private long duration;
// private String data;
// private long currDuration;
//
// public BookChapter() {
// //for serializable
// }
//
// public BookChapter(String id, String title, long duration, String data, long currDuration) {
// this.id = id;
// this.title = title;
// this.duration = duration;
// this.data = data;
// this.currDuration = currDuration;
// }
//
// public String getId() {
// return id;
// }
//
// public String getTitle() {
// return title;
// }
//
// public long getDuration() {
// return duration;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public void setTitle(String title) {
// this.title = title;
// }
//
// public void setDuration(long duration) {
// this.duration = duration;
// }
//
// public String getData() {
// return data;
// }
//
// public void setData(String data) {
// this.data = data;
// }
//
// public long getCurrDuration() {
// return currDuration;
// }
//
// public void setCurrDuration(long currDuration) {
// this.currDuration = currDuration;
// }
// }
// Path: app/src/main/java/com/architjn/audiobook/utils/BookUtils.java
import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
import android.provider.MediaStore;
import com.architjn.audiobook.bean.AudioBook;
import com.architjn.audiobook.bean.BookChapter;
import java.util.ArrayList;
package com.architjn.audiobook.utils;
/**
* Created by Archit on 25-07-2017.
*/
public class BookUtils {
private static Uri MEDIA_PROVIDER = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
| public static ArrayList<AudioBook> scanForBooks(Context context, String path) { |
architjn/YAAB | app/src/main/java/com/architjn/audiobook/utils/BookUtils.java | // Path: app/src/main/java/com/architjn/audiobook/bean/AudioBook.java
// public class AudioBook implements Serializable {
// private String albumId;
// private String albumKey;
// private String albumName;
// private String artistName;
// private String albumArt;
// private int status;
// private long duration;
// private long currentDuration;
// private ArrayList<BookChapter> chapters;
//
// public AudioBook() {
// //for serializable
// }
//
// public AudioBook(String albumId, String albumKey, String albumName, String artistName,
// String albumArt, int status, long duration, long currentDuration) {
// this.albumId = albumId;
// this.albumKey = albumKey;
// this.albumName = albumName;
// this.artistName = artistName;
// this.albumArt = albumArt;
// this.status = status;
// this.duration = duration;
// this.currentDuration = currentDuration;
// }
//
// public String getAlbumKey() {
// return albumKey;
// }
//
// public String getAlbumId() {
// return albumId;
// }
//
// public String getAlbumName() {
// return albumName;
// }
//
// public String getArtistName() {
// return artistName;
// }
//
// public long getDuration() {
// return duration;
// }
//
// public void setChapters(ArrayList<BookChapter> chapters) {
// this.chapters = chapters;
// }
//
// public ArrayList<BookChapter> getChapters() {
// return chapters;
// }
//
// public String getAlbumArt() {
// return albumArt;
// }
//
// public int getStatus() {
// return status;
// }
//
// public void setStatus(int status) {
// this.status = status;
// }
//
// public void setAlbumId(String albumId) {
// this.albumId = albumId;
// }
//
// public void setAlbumKey(String albumKey) {
// this.albumKey = albumKey;
// }
//
// public void setAlbumName(String albumName) {
// this.albumName = albumName;
// }
//
// public void setArtistName(String artistName) {
// this.artistName = artistName;
// }
//
// public void setAlbumArt(String albumArt) {
// this.albumArt = albumArt;
// }
//
// public void setDuration(long duration) {
// this.duration = duration;
// }
//
// public long getCurrentDuration() {
// return currentDuration;
// }
//
// public void setCurrentDuration(long currentDuration) {
// this.currentDuration = currentDuration;
// }
// }
//
// Path: app/src/main/java/com/architjn/audiobook/bean/BookChapter.java
// public class BookChapter implements Serializable{
// private String id;
// private String title;
// private long duration;
// private String data;
// private long currDuration;
//
// public BookChapter() {
// //for serializable
// }
//
// public BookChapter(String id, String title, long duration, String data, long currDuration) {
// this.id = id;
// this.title = title;
// this.duration = duration;
// this.data = data;
// this.currDuration = currDuration;
// }
//
// public String getId() {
// return id;
// }
//
// public String getTitle() {
// return title;
// }
//
// public long getDuration() {
// return duration;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public void setTitle(String title) {
// this.title = title;
// }
//
// public void setDuration(long duration) {
// this.duration = duration;
// }
//
// public String getData() {
// return data;
// }
//
// public void setData(String data) {
// this.data = data;
// }
//
// public long getCurrDuration() {
// return currDuration;
// }
//
// public void setCurrDuration(long currDuration) {
// this.currDuration = currDuration;
// }
// }
| import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
import android.provider.MediaStore;
import com.architjn.audiobook.bean.AudioBook;
import com.architjn.audiobook.bean.BookChapter;
import java.util.ArrayList; | Cursor cursor1 = context.getContentResolver().query(MediaStore.Audio.Albums.EXTERNAL_CONTENT_URI,
new String[]{MediaStore.Audio.Albums._ID, MediaStore.Audio.Albums.ALBUM_ART},
MediaStore.Audio.Albums._ID + "=?",
new String[]{String.valueOf(albumId)},
null);
String albumArt = null;
if (cursor1 != null && cursor1.moveToFirst()) {
try {
albumArt = cursor1.getString(cursor1.getColumnIndex(MediaStore.Audio.Albums.ALBUM_ART));
} catch (IllegalStateException e) {
e.printStackTrace();
} finally {
cursor1.close();
}
}
books.add(new AudioBook(
albumId,
cursor.getString(cursor.getColumnIndex(strArr[1])),
cursor.getString(cursor.getColumnIndex(strArr[2])),
cursor.getString(cursor.getColumnIndex(strArr[3])),
albumArt, 0,
cursor.getLong(cursor.getColumnIndex(strArr[4])), 0));
} while (cursor.moveToNext());
cursor.close();
}
return books;
}
public static AudioBook loadAlbumDetails(Context context, AudioBook audioBook) { | // Path: app/src/main/java/com/architjn/audiobook/bean/AudioBook.java
// public class AudioBook implements Serializable {
// private String albumId;
// private String albumKey;
// private String albumName;
// private String artistName;
// private String albumArt;
// private int status;
// private long duration;
// private long currentDuration;
// private ArrayList<BookChapter> chapters;
//
// public AudioBook() {
// //for serializable
// }
//
// public AudioBook(String albumId, String albumKey, String albumName, String artistName,
// String albumArt, int status, long duration, long currentDuration) {
// this.albumId = albumId;
// this.albumKey = albumKey;
// this.albumName = albumName;
// this.artistName = artistName;
// this.albumArt = albumArt;
// this.status = status;
// this.duration = duration;
// this.currentDuration = currentDuration;
// }
//
// public String getAlbumKey() {
// return albumKey;
// }
//
// public String getAlbumId() {
// return albumId;
// }
//
// public String getAlbumName() {
// return albumName;
// }
//
// public String getArtistName() {
// return artistName;
// }
//
// public long getDuration() {
// return duration;
// }
//
// public void setChapters(ArrayList<BookChapter> chapters) {
// this.chapters = chapters;
// }
//
// public ArrayList<BookChapter> getChapters() {
// return chapters;
// }
//
// public String getAlbumArt() {
// return albumArt;
// }
//
// public int getStatus() {
// return status;
// }
//
// public void setStatus(int status) {
// this.status = status;
// }
//
// public void setAlbumId(String albumId) {
// this.albumId = albumId;
// }
//
// public void setAlbumKey(String albumKey) {
// this.albumKey = albumKey;
// }
//
// public void setAlbumName(String albumName) {
// this.albumName = albumName;
// }
//
// public void setArtistName(String artistName) {
// this.artistName = artistName;
// }
//
// public void setAlbumArt(String albumArt) {
// this.albumArt = albumArt;
// }
//
// public void setDuration(long duration) {
// this.duration = duration;
// }
//
// public long getCurrentDuration() {
// return currentDuration;
// }
//
// public void setCurrentDuration(long currentDuration) {
// this.currentDuration = currentDuration;
// }
// }
//
// Path: app/src/main/java/com/architjn/audiobook/bean/BookChapter.java
// public class BookChapter implements Serializable{
// private String id;
// private String title;
// private long duration;
// private String data;
// private long currDuration;
//
// public BookChapter() {
// //for serializable
// }
//
// public BookChapter(String id, String title, long duration, String data, long currDuration) {
// this.id = id;
// this.title = title;
// this.duration = duration;
// this.data = data;
// this.currDuration = currDuration;
// }
//
// public String getId() {
// return id;
// }
//
// public String getTitle() {
// return title;
// }
//
// public long getDuration() {
// return duration;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public void setTitle(String title) {
// this.title = title;
// }
//
// public void setDuration(long duration) {
// this.duration = duration;
// }
//
// public String getData() {
// return data;
// }
//
// public void setData(String data) {
// this.data = data;
// }
//
// public long getCurrDuration() {
// return currDuration;
// }
//
// public void setCurrDuration(long currDuration) {
// this.currDuration = currDuration;
// }
// }
// Path: app/src/main/java/com/architjn/audiobook/utils/BookUtils.java
import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
import android.provider.MediaStore;
import com.architjn.audiobook.bean.AudioBook;
import com.architjn.audiobook.bean.BookChapter;
import java.util.ArrayList;
Cursor cursor1 = context.getContentResolver().query(MediaStore.Audio.Albums.EXTERNAL_CONTENT_URI,
new String[]{MediaStore.Audio.Albums._ID, MediaStore.Audio.Albums.ALBUM_ART},
MediaStore.Audio.Albums._ID + "=?",
new String[]{String.valueOf(albumId)},
null);
String albumArt = null;
if (cursor1 != null && cursor1.moveToFirst()) {
try {
albumArt = cursor1.getString(cursor1.getColumnIndex(MediaStore.Audio.Albums.ALBUM_ART));
} catch (IllegalStateException e) {
e.printStackTrace();
} finally {
cursor1.close();
}
}
books.add(new AudioBook(
albumId,
cursor.getString(cursor.getColumnIndex(strArr[1])),
cursor.getString(cursor.getColumnIndex(strArr[2])),
cursor.getString(cursor.getColumnIndex(strArr[3])),
albumArt, 0,
cursor.getLong(cursor.getColumnIndex(strArr[4])), 0));
} while (cursor.moveToNext());
cursor.close();
}
return books;
}
public static AudioBook loadAlbumDetails(Context context, AudioBook audioBook) { | ArrayList<BookChapter> chapters = new ArrayList<>(); |
architjn/YAAB | app/src/main/java/com/architjn/audiobook/ui/activity/MainActivity.java | // Path: app/src/main/java/com/architjn/audiobook/presenter/MainPresenter.java
// public class MainPresenter implements IMainPresenter {
// private final Context context;
// private final PrefUtils pref;
// private MainInteractor interactor;
// private IMainView view;
// private ViewPager viewPager;
// private AllAudioBookViewFragment allFrag;
// private NewAudioBookFragment newFrag;
// private OnGoingAudioBookFragment ongoingFrag;
// private FinishedAudioBookFragment finishedFrag;
//
// public MainPresenter(Context context) {
// this.view = (IMainView) context;
// this.context = context;
// this.interactor = new MainInteractor(context, this);
// pref = PrefUtils.getInstance(context);
// init();
// }
//
// private void init() {
// if (pref.getAudioBookFolderPath() == null) {
// AlertDialog.Builder dialog = new AlertDialog.Builder(context);
// dialog.setTitle(R.string.select_directory)
// .setMessage(R.string.select_directory_dialog_msg)
// .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
// @Override
// public void onClick(DialogInterface dialogInterface, int i) {
// if (view != null)
// if (PermissionChecker.requestForPermission(context,
// Manifest.permission.READ_EXTERNAL_STORAGE,
// R.string.read_permission_request, MainActivity.READ_PERMISSION_REQUEST))
// view.startFolderChooser();
// }
// })
// .create().show();
// } else interactor.scanForNewAudioBooks();
// }
//
// public void setupViewPager(ViewPager viewPager, FragmentManager supportFragmentManager) {
// this.viewPager = viewPager;
// allFrag = new AllAudioBookViewFragment();
// newFrag = new NewAudioBookFragment();
// ongoingFrag = new OnGoingAudioBookFragment();
// finishedFrag = new FinishedAudioBookFragment();
// ViewPagerAdapter adapter = new ViewPagerAdapter(context, supportFragmentManager);
// adapter.addFragment(allFrag, R.string.all);
// adapter.addFragment(newFrag, R.string.new_txt);
// adapter.addFragment(ongoingFrag, R.string.ongoing);
// adapter.addFragment(finishedFrag, R.string.finished);
// viewPager.setAdapter(adapter);
// viewPager.setCurrentItem(interactor.getPageWithSomeData());
// }
//
// public void setTabLayout(TabLayout tabLayout) {
// tabLayout.setupWithViewPager(viewPager);
// }
//
// @Override
// public void startFolderChooser() {
// if (view != null)
// view.startFolderChooser();
// }
//
// @Override
// public void onNewAudioBookLoaded() {
// allFrag.updateBookList();
// newFrag.updateBookList();
// }
//
// public MainInteractor getInteractor() {
// return interactor;
// }
// }
//
// Path: app/src/main/java/com/architjn/audiobook/interfaces/IMainView.java
// public interface IMainView {
// void startFolderChooser();
// }
//
// Path: app/src/main/java/com/architjn/audiobook/service/PlayerService.java
// public class PlayerService extends Service implements IPlayerService {
//
// private MediaPlayer mediaPlayer;
// private boolean gotContent;
// private PlayerInteractor interactor;
//
// @Nullable
// @Override
// public IBinder onBind(Intent intent) {
// return null;
// }
//
// @Override
// public int onStartCommand(Intent intent, int flags, int startId) {
// interactor = PlayerInteractor.getInstance(this);
// interactor.setServiceListener(this);
// mediaPlayer = new MediaPlayer();
// gotContent = false;
// return START_STICKY;
// }
//
// @Override
// public void setSource(BookChapter chapter) {
// try {
// gotContent = false;
// mediaPlayer.reset();
// mediaPlayer.setDataSource(chapter.getData());
// gotContent = true;
// mediaPlayer.prepare();
// mediaPlayer.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
// @Override
// public void onCompletion(MediaPlayer mp) {
// if (interactor != null) {
// changeAudioFile(interactor.getNextChapter());
// }
// }
// });
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
//
// private void changeAudioFile(BookChapter nextChapter) {
// try {
// if (mediaPlayer != null && nextChapter != null) {
// mediaPlayer.reset();
// mediaPlayer.setDataSource(nextChapter.getData());
// interactor.askToPlay();
// }
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
//
// @Override
// public int play() {
// if (mediaPlayer != null && gotContent) {
// if (!mediaPlayer.isPlaying()) {
// mediaPlayer.start();
// interactor.setStatus(PLAYING);
// } else if (mediaPlayer != null) {
// mediaPlayer.pause();
// interactor.setStatus(PAUSED);
// }
// return mediaPlayer.getCurrentPosition();
// }
// return -1;
// }
//
// @Override
// public void onSeekChange(int progress) {
// if (mediaPlayer != null && gotContent)
// mediaPlayer.seekTo(progress);
// }
// }
| import android.content.Intent;
import android.support.annotation.NonNull;
import android.support.design.widget.TabLayout;
import android.support.v4.content.PermissionChecker;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import com.architjn.audiobook.R;
import com.architjn.audiobook.presenter.MainPresenter;
import com.architjn.audiobook.interfaces.IMainView;
import com.architjn.audiobook.service.PlayerService;
import butterknife.BindView;
import butterknife.ButterKnife; | package com.architjn.audiobook.ui.activity;
public class MainActivity extends AppCompatActivity implements IMainView {
private static final int FOLDER_CHOOSER = 3231;
public static final int READ_PERMISSION_REQUEST = 7766;
@BindView(R.id.viewpager)
ViewPager viewPager;
@BindView(R.id.tabs)
TabLayout tabLayout; | // Path: app/src/main/java/com/architjn/audiobook/presenter/MainPresenter.java
// public class MainPresenter implements IMainPresenter {
// private final Context context;
// private final PrefUtils pref;
// private MainInteractor interactor;
// private IMainView view;
// private ViewPager viewPager;
// private AllAudioBookViewFragment allFrag;
// private NewAudioBookFragment newFrag;
// private OnGoingAudioBookFragment ongoingFrag;
// private FinishedAudioBookFragment finishedFrag;
//
// public MainPresenter(Context context) {
// this.view = (IMainView) context;
// this.context = context;
// this.interactor = new MainInteractor(context, this);
// pref = PrefUtils.getInstance(context);
// init();
// }
//
// private void init() {
// if (pref.getAudioBookFolderPath() == null) {
// AlertDialog.Builder dialog = new AlertDialog.Builder(context);
// dialog.setTitle(R.string.select_directory)
// .setMessage(R.string.select_directory_dialog_msg)
// .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
// @Override
// public void onClick(DialogInterface dialogInterface, int i) {
// if (view != null)
// if (PermissionChecker.requestForPermission(context,
// Manifest.permission.READ_EXTERNAL_STORAGE,
// R.string.read_permission_request, MainActivity.READ_PERMISSION_REQUEST))
// view.startFolderChooser();
// }
// })
// .create().show();
// } else interactor.scanForNewAudioBooks();
// }
//
// public void setupViewPager(ViewPager viewPager, FragmentManager supportFragmentManager) {
// this.viewPager = viewPager;
// allFrag = new AllAudioBookViewFragment();
// newFrag = new NewAudioBookFragment();
// ongoingFrag = new OnGoingAudioBookFragment();
// finishedFrag = new FinishedAudioBookFragment();
// ViewPagerAdapter adapter = new ViewPagerAdapter(context, supportFragmentManager);
// adapter.addFragment(allFrag, R.string.all);
// adapter.addFragment(newFrag, R.string.new_txt);
// adapter.addFragment(ongoingFrag, R.string.ongoing);
// adapter.addFragment(finishedFrag, R.string.finished);
// viewPager.setAdapter(adapter);
// viewPager.setCurrentItem(interactor.getPageWithSomeData());
// }
//
// public void setTabLayout(TabLayout tabLayout) {
// tabLayout.setupWithViewPager(viewPager);
// }
//
// @Override
// public void startFolderChooser() {
// if (view != null)
// view.startFolderChooser();
// }
//
// @Override
// public void onNewAudioBookLoaded() {
// allFrag.updateBookList();
// newFrag.updateBookList();
// }
//
// public MainInteractor getInteractor() {
// return interactor;
// }
// }
//
// Path: app/src/main/java/com/architjn/audiobook/interfaces/IMainView.java
// public interface IMainView {
// void startFolderChooser();
// }
//
// Path: app/src/main/java/com/architjn/audiobook/service/PlayerService.java
// public class PlayerService extends Service implements IPlayerService {
//
// private MediaPlayer mediaPlayer;
// private boolean gotContent;
// private PlayerInteractor interactor;
//
// @Nullable
// @Override
// public IBinder onBind(Intent intent) {
// return null;
// }
//
// @Override
// public int onStartCommand(Intent intent, int flags, int startId) {
// interactor = PlayerInteractor.getInstance(this);
// interactor.setServiceListener(this);
// mediaPlayer = new MediaPlayer();
// gotContent = false;
// return START_STICKY;
// }
//
// @Override
// public void setSource(BookChapter chapter) {
// try {
// gotContent = false;
// mediaPlayer.reset();
// mediaPlayer.setDataSource(chapter.getData());
// gotContent = true;
// mediaPlayer.prepare();
// mediaPlayer.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
// @Override
// public void onCompletion(MediaPlayer mp) {
// if (interactor != null) {
// changeAudioFile(interactor.getNextChapter());
// }
// }
// });
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
//
// private void changeAudioFile(BookChapter nextChapter) {
// try {
// if (mediaPlayer != null && nextChapter != null) {
// mediaPlayer.reset();
// mediaPlayer.setDataSource(nextChapter.getData());
// interactor.askToPlay();
// }
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
//
// @Override
// public int play() {
// if (mediaPlayer != null && gotContent) {
// if (!mediaPlayer.isPlaying()) {
// mediaPlayer.start();
// interactor.setStatus(PLAYING);
// } else if (mediaPlayer != null) {
// mediaPlayer.pause();
// interactor.setStatus(PAUSED);
// }
// return mediaPlayer.getCurrentPosition();
// }
// return -1;
// }
//
// @Override
// public void onSeekChange(int progress) {
// if (mediaPlayer != null && gotContent)
// mediaPlayer.seekTo(progress);
// }
// }
// Path: app/src/main/java/com/architjn/audiobook/ui/activity/MainActivity.java
import android.content.Intent;
import android.support.annotation.NonNull;
import android.support.design.widget.TabLayout;
import android.support.v4.content.PermissionChecker;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import com.architjn.audiobook.R;
import com.architjn.audiobook.presenter.MainPresenter;
import com.architjn.audiobook.interfaces.IMainView;
import com.architjn.audiobook.service.PlayerService;
import butterknife.BindView;
import butterknife.ButterKnife;
package com.architjn.audiobook.ui.activity;
public class MainActivity extends AppCompatActivity implements IMainView {
private static final int FOLDER_CHOOSER = 3231;
public static final int READ_PERMISSION_REQUEST = 7766;
@BindView(R.id.viewpager)
ViewPager viewPager;
@BindView(R.id.tabs)
TabLayout tabLayout; | private MainPresenter presenter; |
architjn/YAAB | app/src/main/java/com/architjn/audiobook/interactor/OnGoingAudioBookInteractor.java | // Path: app/src/main/java/com/architjn/audiobook/bean/AudioBook.java
// public class AudioBook implements Serializable {
// private String albumId;
// private String albumKey;
// private String albumName;
// private String artistName;
// private String albumArt;
// private int status;
// private long duration;
// private long currentDuration;
// private ArrayList<BookChapter> chapters;
//
// public AudioBook() {
// //for serializable
// }
//
// public AudioBook(String albumId, String albumKey, String albumName, String artistName,
// String albumArt, int status, long duration, long currentDuration) {
// this.albumId = albumId;
// this.albumKey = albumKey;
// this.albumName = albumName;
// this.artistName = artistName;
// this.albumArt = albumArt;
// this.status = status;
// this.duration = duration;
// this.currentDuration = currentDuration;
// }
//
// public String getAlbumKey() {
// return albumKey;
// }
//
// public String getAlbumId() {
// return albumId;
// }
//
// public String getAlbumName() {
// return albumName;
// }
//
// public String getArtistName() {
// return artistName;
// }
//
// public long getDuration() {
// return duration;
// }
//
// public void setChapters(ArrayList<BookChapter> chapters) {
// this.chapters = chapters;
// }
//
// public ArrayList<BookChapter> getChapters() {
// return chapters;
// }
//
// public String getAlbumArt() {
// return albumArt;
// }
//
// public int getStatus() {
// return status;
// }
//
// public void setStatus(int status) {
// this.status = status;
// }
//
// public void setAlbumId(String albumId) {
// this.albumId = albumId;
// }
//
// public void setAlbumKey(String albumKey) {
// this.albumKey = albumKey;
// }
//
// public void setAlbumName(String albumName) {
// this.albumName = albumName;
// }
//
// public void setArtistName(String artistName) {
// this.artistName = artistName;
// }
//
// public void setAlbumArt(String albumArt) {
// this.albumArt = albumArt;
// }
//
// public void setDuration(long duration) {
// this.duration = duration;
// }
//
// public long getCurrentDuration() {
// return currentDuration;
// }
//
// public void setCurrentDuration(long currentDuration) {
// this.currentDuration = currentDuration;
// }
// }
//
// Path: app/src/main/java/com/architjn/audiobook/database/DBHelper.java
// public class DBHelper extends SQLiteOpenHelper {
//
// private static final String DATABASE_NAME = "yaab-db";
// private static final int DATABASE_VERSION = 1;
//
// private static DBHelper instance;
//
// private final Context context;
//
// public static DBHelper getInstance(Context context) {
// if (instance == null)
// instance = new DBHelper(context);
// return instance;
// }
//
// private DBHelper(Context context) {
// super(context, DATABASE_NAME, null, DATABASE_VERSION);
// this.context = context;
// }
//
// @Override
// public void onCreate(SQLiteDatabase db) {
// AudioBookTable.onCreate(db);
// ChapterTable.onCreate(db);
// }
//
// @Override
// public void onUpgrade(SQLiteDatabase sqLiteDatabase, int i, int i1) {
//
// }
//
// public boolean addAudioBook(AudioBook audioBook) {
// if (AudioBookTable.addBook(this.getWritableDatabase(), audioBook) != -1) {
// ChapterTable.addChapters(this.getWritableDatabase(), audioBook.getAlbumId(),
// audioBook.getChapters());
// return true;
// } else return false;
// }
//
// public ArrayList<AudioBook> loadAllAudioBooks() {
// return AudioBookTable.getAllBooks(this.getReadableDatabase());
// }
//
// public ArrayList<AudioBook> loadNewAudioBooks() {
// return AudioBookTable.getNewBooks(this.getReadableDatabase());
// }
//
// public ArrayList<AudioBook> loadOnGoingAudioBooks() {
// return AudioBookTable.getOnGoingBooks(this.getReadableDatabase());
// }
//
// public void updateBookStatus(String albumId, int status) {
// AudioBookTable.setBookStatus(this.getWritableDatabase(), albumId, status);
// }
//
// public int getOnGoingBooksCount() {
// return AudioBookTable.getOnGoingDataCount(this.getWritableDatabase());
// }
// public int getNewBooksCount() {
// return AudioBookTable.getNewDataCount(this.getWritableDatabase());
// }
//
// public AudioBook getAudioBookViaId(String albumId) {
// return AudioBookTable.getAudioBook(this.getReadableDatabase(), albumId);
// }
// }
//
// Path: app/src/main/java/com/architjn/audiobook/interfaces/IAllAudioBookPresenter.java
// public interface IAllAudioBookPresenter {
// void onAudioBooksLoaded(ArrayList<AudioBook> books);
// }
| import android.content.Context;
import android.os.Handler;
import com.architjn.audiobook.bean.AudioBook;
import com.architjn.audiobook.database.DBHelper;
import com.architjn.audiobook.interfaces.IAllAudioBookPresenter;
import java.util.ArrayList; | package com.architjn.audiobook.interactor;
/**
* Created by Archit on 25-07-2017.
*/
public class OnGoingAudioBookInteractor {
private final DBHelper dbHandler; | // Path: app/src/main/java/com/architjn/audiobook/bean/AudioBook.java
// public class AudioBook implements Serializable {
// private String albumId;
// private String albumKey;
// private String albumName;
// private String artistName;
// private String albumArt;
// private int status;
// private long duration;
// private long currentDuration;
// private ArrayList<BookChapter> chapters;
//
// public AudioBook() {
// //for serializable
// }
//
// public AudioBook(String albumId, String albumKey, String albumName, String artistName,
// String albumArt, int status, long duration, long currentDuration) {
// this.albumId = albumId;
// this.albumKey = albumKey;
// this.albumName = albumName;
// this.artistName = artistName;
// this.albumArt = albumArt;
// this.status = status;
// this.duration = duration;
// this.currentDuration = currentDuration;
// }
//
// public String getAlbumKey() {
// return albumKey;
// }
//
// public String getAlbumId() {
// return albumId;
// }
//
// public String getAlbumName() {
// return albumName;
// }
//
// public String getArtistName() {
// return artistName;
// }
//
// public long getDuration() {
// return duration;
// }
//
// public void setChapters(ArrayList<BookChapter> chapters) {
// this.chapters = chapters;
// }
//
// public ArrayList<BookChapter> getChapters() {
// return chapters;
// }
//
// public String getAlbumArt() {
// return albumArt;
// }
//
// public int getStatus() {
// return status;
// }
//
// public void setStatus(int status) {
// this.status = status;
// }
//
// public void setAlbumId(String albumId) {
// this.albumId = albumId;
// }
//
// public void setAlbumKey(String albumKey) {
// this.albumKey = albumKey;
// }
//
// public void setAlbumName(String albumName) {
// this.albumName = albumName;
// }
//
// public void setArtistName(String artistName) {
// this.artistName = artistName;
// }
//
// public void setAlbumArt(String albumArt) {
// this.albumArt = albumArt;
// }
//
// public void setDuration(long duration) {
// this.duration = duration;
// }
//
// public long getCurrentDuration() {
// return currentDuration;
// }
//
// public void setCurrentDuration(long currentDuration) {
// this.currentDuration = currentDuration;
// }
// }
//
// Path: app/src/main/java/com/architjn/audiobook/database/DBHelper.java
// public class DBHelper extends SQLiteOpenHelper {
//
// private static final String DATABASE_NAME = "yaab-db";
// private static final int DATABASE_VERSION = 1;
//
// private static DBHelper instance;
//
// private final Context context;
//
// public static DBHelper getInstance(Context context) {
// if (instance == null)
// instance = new DBHelper(context);
// return instance;
// }
//
// private DBHelper(Context context) {
// super(context, DATABASE_NAME, null, DATABASE_VERSION);
// this.context = context;
// }
//
// @Override
// public void onCreate(SQLiteDatabase db) {
// AudioBookTable.onCreate(db);
// ChapterTable.onCreate(db);
// }
//
// @Override
// public void onUpgrade(SQLiteDatabase sqLiteDatabase, int i, int i1) {
//
// }
//
// public boolean addAudioBook(AudioBook audioBook) {
// if (AudioBookTable.addBook(this.getWritableDatabase(), audioBook) != -1) {
// ChapterTable.addChapters(this.getWritableDatabase(), audioBook.getAlbumId(),
// audioBook.getChapters());
// return true;
// } else return false;
// }
//
// public ArrayList<AudioBook> loadAllAudioBooks() {
// return AudioBookTable.getAllBooks(this.getReadableDatabase());
// }
//
// public ArrayList<AudioBook> loadNewAudioBooks() {
// return AudioBookTable.getNewBooks(this.getReadableDatabase());
// }
//
// public ArrayList<AudioBook> loadOnGoingAudioBooks() {
// return AudioBookTable.getOnGoingBooks(this.getReadableDatabase());
// }
//
// public void updateBookStatus(String albumId, int status) {
// AudioBookTable.setBookStatus(this.getWritableDatabase(), albumId, status);
// }
//
// public int getOnGoingBooksCount() {
// return AudioBookTable.getOnGoingDataCount(this.getWritableDatabase());
// }
// public int getNewBooksCount() {
// return AudioBookTable.getNewDataCount(this.getWritableDatabase());
// }
//
// public AudioBook getAudioBookViaId(String albumId) {
// return AudioBookTable.getAudioBook(this.getReadableDatabase(), albumId);
// }
// }
//
// Path: app/src/main/java/com/architjn/audiobook/interfaces/IAllAudioBookPresenter.java
// public interface IAllAudioBookPresenter {
// void onAudioBooksLoaded(ArrayList<AudioBook> books);
// }
// Path: app/src/main/java/com/architjn/audiobook/interactor/OnGoingAudioBookInteractor.java
import android.content.Context;
import android.os.Handler;
import com.architjn.audiobook.bean.AudioBook;
import com.architjn.audiobook.database.DBHelper;
import com.architjn.audiobook.interfaces.IAllAudioBookPresenter;
import java.util.ArrayList;
package com.architjn.audiobook.interactor;
/**
* Created by Archit on 25-07-2017.
*/
public class OnGoingAudioBookInteractor {
private final DBHelper dbHandler; | private IAllAudioBookPresenter presenter; |
architjn/YAAB | app/src/main/java/com/architjn/audiobook/interactor/OnGoingAudioBookInteractor.java | // Path: app/src/main/java/com/architjn/audiobook/bean/AudioBook.java
// public class AudioBook implements Serializable {
// private String albumId;
// private String albumKey;
// private String albumName;
// private String artistName;
// private String albumArt;
// private int status;
// private long duration;
// private long currentDuration;
// private ArrayList<BookChapter> chapters;
//
// public AudioBook() {
// //for serializable
// }
//
// public AudioBook(String albumId, String albumKey, String albumName, String artistName,
// String albumArt, int status, long duration, long currentDuration) {
// this.albumId = albumId;
// this.albumKey = albumKey;
// this.albumName = albumName;
// this.artistName = artistName;
// this.albumArt = albumArt;
// this.status = status;
// this.duration = duration;
// this.currentDuration = currentDuration;
// }
//
// public String getAlbumKey() {
// return albumKey;
// }
//
// public String getAlbumId() {
// return albumId;
// }
//
// public String getAlbumName() {
// return albumName;
// }
//
// public String getArtistName() {
// return artistName;
// }
//
// public long getDuration() {
// return duration;
// }
//
// public void setChapters(ArrayList<BookChapter> chapters) {
// this.chapters = chapters;
// }
//
// public ArrayList<BookChapter> getChapters() {
// return chapters;
// }
//
// public String getAlbumArt() {
// return albumArt;
// }
//
// public int getStatus() {
// return status;
// }
//
// public void setStatus(int status) {
// this.status = status;
// }
//
// public void setAlbumId(String albumId) {
// this.albumId = albumId;
// }
//
// public void setAlbumKey(String albumKey) {
// this.albumKey = albumKey;
// }
//
// public void setAlbumName(String albumName) {
// this.albumName = albumName;
// }
//
// public void setArtistName(String artistName) {
// this.artistName = artistName;
// }
//
// public void setAlbumArt(String albumArt) {
// this.albumArt = albumArt;
// }
//
// public void setDuration(long duration) {
// this.duration = duration;
// }
//
// public long getCurrentDuration() {
// return currentDuration;
// }
//
// public void setCurrentDuration(long currentDuration) {
// this.currentDuration = currentDuration;
// }
// }
//
// Path: app/src/main/java/com/architjn/audiobook/database/DBHelper.java
// public class DBHelper extends SQLiteOpenHelper {
//
// private static final String DATABASE_NAME = "yaab-db";
// private static final int DATABASE_VERSION = 1;
//
// private static DBHelper instance;
//
// private final Context context;
//
// public static DBHelper getInstance(Context context) {
// if (instance == null)
// instance = new DBHelper(context);
// return instance;
// }
//
// private DBHelper(Context context) {
// super(context, DATABASE_NAME, null, DATABASE_VERSION);
// this.context = context;
// }
//
// @Override
// public void onCreate(SQLiteDatabase db) {
// AudioBookTable.onCreate(db);
// ChapterTable.onCreate(db);
// }
//
// @Override
// public void onUpgrade(SQLiteDatabase sqLiteDatabase, int i, int i1) {
//
// }
//
// public boolean addAudioBook(AudioBook audioBook) {
// if (AudioBookTable.addBook(this.getWritableDatabase(), audioBook) != -1) {
// ChapterTable.addChapters(this.getWritableDatabase(), audioBook.getAlbumId(),
// audioBook.getChapters());
// return true;
// } else return false;
// }
//
// public ArrayList<AudioBook> loadAllAudioBooks() {
// return AudioBookTable.getAllBooks(this.getReadableDatabase());
// }
//
// public ArrayList<AudioBook> loadNewAudioBooks() {
// return AudioBookTable.getNewBooks(this.getReadableDatabase());
// }
//
// public ArrayList<AudioBook> loadOnGoingAudioBooks() {
// return AudioBookTable.getOnGoingBooks(this.getReadableDatabase());
// }
//
// public void updateBookStatus(String albumId, int status) {
// AudioBookTable.setBookStatus(this.getWritableDatabase(), albumId, status);
// }
//
// public int getOnGoingBooksCount() {
// return AudioBookTable.getOnGoingDataCount(this.getWritableDatabase());
// }
// public int getNewBooksCount() {
// return AudioBookTable.getNewDataCount(this.getWritableDatabase());
// }
//
// public AudioBook getAudioBookViaId(String albumId) {
// return AudioBookTable.getAudioBook(this.getReadableDatabase(), albumId);
// }
// }
//
// Path: app/src/main/java/com/architjn/audiobook/interfaces/IAllAudioBookPresenter.java
// public interface IAllAudioBookPresenter {
// void onAudioBooksLoaded(ArrayList<AudioBook> books);
// }
| import android.content.Context;
import android.os.Handler;
import com.architjn.audiobook.bean.AudioBook;
import com.architjn.audiobook.database.DBHelper;
import com.architjn.audiobook.interfaces.IAllAudioBookPresenter;
import java.util.ArrayList; | package com.architjn.audiobook.interactor;
/**
* Created by Archit on 25-07-2017.
*/
public class OnGoingAudioBookInteractor {
private final DBHelper dbHandler;
private IAllAudioBookPresenter presenter; | // Path: app/src/main/java/com/architjn/audiobook/bean/AudioBook.java
// public class AudioBook implements Serializable {
// private String albumId;
// private String albumKey;
// private String albumName;
// private String artistName;
// private String albumArt;
// private int status;
// private long duration;
// private long currentDuration;
// private ArrayList<BookChapter> chapters;
//
// public AudioBook() {
// //for serializable
// }
//
// public AudioBook(String albumId, String albumKey, String albumName, String artistName,
// String albumArt, int status, long duration, long currentDuration) {
// this.albumId = albumId;
// this.albumKey = albumKey;
// this.albumName = albumName;
// this.artistName = artistName;
// this.albumArt = albumArt;
// this.status = status;
// this.duration = duration;
// this.currentDuration = currentDuration;
// }
//
// public String getAlbumKey() {
// return albumKey;
// }
//
// public String getAlbumId() {
// return albumId;
// }
//
// public String getAlbumName() {
// return albumName;
// }
//
// public String getArtistName() {
// return artistName;
// }
//
// public long getDuration() {
// return duration;
// }
//
// public void setChapters(ArrayList<BookChapter> chapters) {
// this.chapters = chapters;
// }
//
// public ArrayList<BookChapter> getChapters() {
// return chapters;
// }
//
// public String getAlbumArt() {
// return albumArt;
// }
//
// public int getStatus() {
// return status;
// }
//
// public void setStatus(int status) {
// this.status = status;
// }
//
// public void setAlbumId(String albumId) {
// this.albumId = albumId;
// }
//
// public void setAlbumKey(String albumKey) {
// this.albumKey = albumKey;
// }
//
// public void setAlbumName(String albumName) {
// this.albumName = albumName;
// }
//
// public void setArtistName(String artistName) {
// this.artistName = artistName;
// }
//
// public void setAlbumArt(String albumArt) {
// this.albumArt = albumArt;
// }
//
// public void setDuration(long duration) {
// this.duration = duration;
// }
//
// public long getCurrentDuration() {
// return currentDuration;
// }
//
// public void setCurrentDuration(long currentDuration) {
// this.currentDuration = currentDuration;
// }
// }
//
// Path: app/src/main/java/com/architjn/audiobook/database/DBHelper.java
// public class DBHelper extends SQLiteOpenHelper {
//
// private static final String DATABASE_NAME = "yaab-db";
// private static final int DATABASE_VERSION = 1;
//
// private static DBHelper instance;
//
// private final Context context;
//
// public static DBHelper getInstance(Context context) {
// if (instance == null)
// instance = new DBHelper(context);
// return instance;
// }
//
// private DBHelper(Context context) {
// super(context, DATABASE_NAME, null, DATABASE_VERSION);
// this.context = context;
// }
//
// @Override
// public void onCreate(SQLiteDatabase db) {
// AudioBookTable.onCreate(db);
// ChapterTable.onCreate(db);
// }
//
// @Override
// public void onUpgrade(SQLiteDatabase sqLiteDatabase, int i, int i1) {
//
// }
//
// public boolean addAudioBook(AudioBook audioBook) {
// if (AudioBookTable.addBook(this.getWritableDatabase(), audioBook) != -1) {
// ChapterTable.addChapters(this.getWritableDatabase(), audioBook.getAlbumId(),
// audioBook.getChapters());
// return true;
// } else return false;
// }
//
// public ArrayList<AudioBook> loadAllAudioBooks() {
// return AudioBookTable.getAllBooks(this.getReadableDatabase());
// }
//
// public ArrayList<AudioBook> loadNewAudioBooks() {
// return AudioBookTable.getNewBooks(this.getReadableDatabase());
// }
//
// public ArrayList<AudioBook> loadOnGoingAudioBooks() {
// return AudioBookTable.getOnGoingBooks(this.getReadableDatabase());
// }
//
// public void updateBookStatus(String albumId, int status) {
// AudioBookTable.setBookStatus(this.getWritableDatabase(), albumId, status);
// }
//
// public int getOnGoingBooksCount() {
// return AudioBookTable.getOnGoingDataCount(this.getWritableDatabase());
// }
// public int getNewBooksCount() {
// return AudioBookTable.getNewDataCount(this.getWritableDatabase());
// }
//
// public AudioBook getAudioBookViaId(String albumId) {
// return AudioBookTable.getAudioBook(this.getReadableDatabase(), albumId);
// }
// }
//
// Path: app/src/main/java/com/architjn/audiobook/interfaces/IAllAudioBookPresenter.java
// public interface IAllAudioBookPresenter {
// void onAudioBooksLoaded(ArrayList<AudioBook> books);
// }
// Path: app/src/main/java/com/architjn/audiobook/interactor/OnGoingAudioBookInteractor.java
import android.content.Context;
import android.os.Handler;
import com.architjn.audiobook.bean.AudioBook;
import com.architjn.audiobook.database.DBHelper;
import com.architjn.audiobook.interfaces.IAllAudioBookPresenter;
import java.util.ArrayList;
package com.architjn.audiobook.interactor;
/**
* Created by Archit on 25-07-2017.
*/
public class OnGoingAudioBookInteractor {
private final DBHelper dbHandler;
private IAllAudioBookPresenter presenter; | private ArrayList<AudioBook> books; |
architjn/YAAB | app/src/main/java/com/architjn/audiobook/interactor/NewAudioBookInteractor.java | // Path: app/src/main/java/com/architjn/audiobook/bean/AudioBook.java
// public class AudioBook implements Serializable {
// private String albumId;
// private String albumKey;
// private String albumName;
// private String artistName;
// private String albumArt;
// private int status;
// private long duration;
// private long currentDuration;
// private ArrayList<BookChapter> chapters;
//
// public AudioBook() {
// //for serializable
// }
//
// public AudioBook(String albumId, String albumKey, String albumName, String artistName,
// String albumArt, int status, long duration, long currentDuration) {
// this.albumId = albumId;
// this.albumKey = albumKey;
// this.albumName = albumName;
// this.artistName = artistName;
// this.albumArt = albumArt;
// this.status = status;
// this.duration = duration;
// this.currentDuration = currentDuration;
// }
//
// public String getAlbumKey() {
// return albumKey;
// }
//
// public String getAlbumId() {
// return albumId;
// }
//
// public String getAlbumName() {
// return albumName;
// }
//
// public String getArtistName() {
// return artistName;
// }
//
// public long getDuration() {
// return duration;
// }
//
// public void setChapters(ArrayList<BookChapter> chapters) {
// this.chapters = chapters;
// }
//
// public ArrayList<BookChapter> getChapters() {
// return chapters;
// }
//
// public String getAlbumArt() {
// return albumArt;
// }
//
// public int getStatus() {
// return status;
// }
//
// public void setStatus(int status) {
// this.status = status;
// }
//
// public void setAlbumId(String albumId) {
// this.albumId = albumId;
// }
//
// public void setAlbumKey(String albumKey) {
// this.albumKey = albumKey;
// }
//
// public void setAlbumName(String albumName) {
// this.albumName = albumName;
// }
//
// public void setArtistName(String artistName) {
// this.artistName = artistName;
// }
//
// public void setAlbumArt(String albumArt) {
// this.albumArt = albumArt;
// }
//
// public void setDuration(long duration) {
// this.duration = duration;
// }
//
// public long getCurrentDuration() {
// return currentDuration;
// }
//
// public void setCurrentDuration(long currentDuration) {
// this.currentDuration = currentDuration;
// }
// }
//
// Path: app/src/main/java/com/architjn/audiobook/database/DBHelper.java
// public class DBHelper extends SQLiteOpenHelper {
//
// private static final String DATABASE_NAME = "yaab-db";
// private static final int DATABASE_VERSION = 1;
//
// private static DBHelper instance;
//
// private final Context context;
//
// public static DBHelper getInstance(Context context) {
// if (instance == null)
// instance = new DBHelper(context);
// return instance;
// }
//
// private DBHelper(Context context) {
// super(context, DATABASE_NAME, null, DATABASE_VERSION);
// this.context = context;
// }
//
// @Override
// public void onCreate(SQLiteDatabase db) {
// AudioBookTable.onCreate(db);
// ChapterTable.onCreate(db);
// }
//
// @Override
// public void onUpgrade(SQLiteDatabase sqLiteDatabase, int i, int i1) {
//
// }
//
// public boolean addAudioBook(AudioBook audioBook) {
// if (AudioBookTable.addBook(this.getWritableDatabase(), audioBook) != -1) {
// ChapterTable.addChapters(this.getWritableDatabase(), audioBook.getAlbumId(),
// audioBook.getChapters());
// return true;
// } else return false;
// }
//
// public ArrayList<AudioBook> loadAllAudioBooks() {
// return AudioBookTable.getAllBooks(this.getReadableDatabase());
// }
//
// public ArrayList<AudioBook> loadNewAudioBooks() {
// return AudioBookTable.getNewBooks(this.getReadableDatabase());
// }
//
// public ArrayList<AudioBook> loadOnGoingAudioBooks() {
// return AudioBookTable.getOnGoingBooks(this.getReadableDatabase());
// }
//
// public void updateBookStatus(String albumId, int status) {
// AudioBookTable.setBookStatus(this.getWritableDatabase(), albumId, status);
// }
//
// public int getOnGoingBooksCount() {
// return AudioBookTable.getOnGoingDataCount(this.getWritableDatabase());
// }
// public int getNewBooksCount() {
// return AudioBookTable.getNewDataCount(this.getWritableDatabase());
// }
//
// public AudioBook getAudioBookViaId(String albumId) {
// return AudioBookTable.getAudioBook(this.getReadableDatabase(), albumId);
// }
// }
//
// Path: app/src/main/java/com/architjn/audiobook/interfaces/IAllAudioBookPresenter.java
// public interface IAllAudioBookPresenter {
// void onAudioBooksLoaded(ArrayList<AudioBook> books);
// }
| import android.content.Context;
import android.os.Handler;
import com.architjn.audiobook.bean.AudioBook;
import com.architjn.audiobook.database.DBHelper;
import com.architjn.audiobook.interfaces.IAllAudioBookPresenter;
import java.util.ArrayList; | package com.architjn.audiobook.interactor;
/**
* Created by Archit on 25-07-2017.
*/
public class NewAudioBookInteractor {
private final DBHelper dbHandler; | // Path: app/src/main/java/com/architjn/audiobook/bean/AudioBook.java
// public class AudioBook implements Serializable {
// private String albumId;
// private String albumKey;
// private String albumName;
// private String artistName;
// private String albumArt;
// private int status;
// private long duration;
// private long currentDuration;
// private ArrayList<BookChapter> chapters;
//
// public AudioBook() {
// //for serializable
// }
//
// public AudioBook(String albumId, String albumKey, String albumName, String artistName,
// String albumArt, int status, long duration, long currentDuration) {
// this.albumId = albumId;
// this.albumKey = albumKey;
// this.albumName = albumName;
// this.artistName = artistName;
// this.albumArt = albumArt;
// this.status = status;
// this.duration = duration;
// this.currentDuration = currentDuration;
// }
//
// public String getAlbumKey() {
// return albumKey;
// }
//
// public String getAlbumId() {
// return albumId;
// }
//
// public String getAlbumName() {
// return albumName;
// }
//
// public String getArtistName() {
// return artistName;
// }
//
// public long getDuration() {
// return duration;
// }
//
// public void setChapters(ArrayList<BookChapter> chapters) {
// this.chapters = chapters;
// }
//
// public ArrayList<BookChapter> getChapters() {
// return chapters;
// }
//
// public String getAlbumArt() {
// return albumArt;
// }
//
// public int getStatus() {
// return status;
// }
//
// public void setStatus(int status) {
// this.status = status;
// }
//
// public void setAlbumId(String albumId) {
// this.albumId = albumId;
// }
//
// public void setAlbumKey(String albumKey) {
// this.albumKey = albumKey;
// }
//
// public void setAlbumName(String albumName) {
// this.albumName = albumName;
// }
//
// public void setArtistName(String artistName) {
// this.artistName = artistName;
// }
//
// public void setAlbumArt(String albumArt) {
// this.albumArt = albumArt;
// }
//
// public void setDuration(long duration) {
// this.duration = duration;
// }
//
// public long getCurrentDuration() {
// return currentDuration;
// }
//
// public void setCurrentDuration(long currentDuration) {
// this.currentDuration = currentDuration;
// }
// }
//
// Path: app/src/main/java/com/architjn/audiobook/database/DBHelper.java
// public class DBHelper extends SQLiteOpenHelper {
//
// private static final String DATABASE_NAME = "yaab-db";
// private static final int DATABASE_VERSION = 1;
//
// private static DBHelper instance;
//
// private final Context context;
//
// public static DBHelper getInstance(Context context) {
// if (instance == null)
// instance = new DBHelper(context);
// return instance;
// }
//
// private DBHelper(Context context) {
// super(context, DATABASE_NAME, null, DATABASE_VERSION);
// this.context = context;
// }
//
// @Override
// public void onCreate(SQLiteDatabase db) {
// AudioBookTable.onCreate(db);
// ChapterTable.onCreate(db);
// }
//
// @Override
// public void onUpgrade(SQLiteDatabase sqLiteDatabase, int i, int i1) {
//
// }
//
// public boolean addAudioBook(AudioBook audioBook) {
// if (AudioBookTable.addBook(this.getWritableDatabase(), audioBook) != -1) {
// ChapterTable.addChapters(this.getWritableDatabase(), audioBook.getAlbumId(),
// audioBook.getChapters());
// return true;
// } else return false;
// }
//
// public ArrayList<AudioBook> loadAllAudioBooks() {
// return AudioBookTable.getAllBooks(this.getReadableDatabase());
// }
//
// public ArrayList<AudioBook> loadNewAudioBooks() {
// return AudioBookTable.getNewBooks(this.getReadableDatabase());
// }
//
// public ArrayList<AudioBook> loadOnGoingAudioBooks() {
// return AudioBookTable.getOnGoingBooks(this.getReadableDatabase());
// }
//
// public void updateBookStatus(String albumId, int status) {
// AudioBookTable.setBookStatus(this.getWritableDatabase(), albumId, status);
// }
//
// public int getOnGoingBooksCount() {
// return AudioBookTable.getOnGoingDataCount(this.getWritableDatabase());
// }
// public int getNewBooksCount() {
// return AudioBookTable.getNewDataCount(this.getWritableDatabase());
// }
//
// public AudioBook getAudioBookViaId(String albumId) {
// return AudioBookTable.getAudioBook(this.getReadableDatabase(), albumId);
// }
// }
//
// Path: app/src/main/java/com/architjn/audiobook/interfaces/IAllAudioBookPresenter.java
// public interface IAllAudioBookPresenter {
// void onAudioBooksLoaded(ArrayList<AudioBook> books);
// }
// Path: app/src/main/java/com/architjn/audiobook/interactor/NewAudioBookInteractor.java
import android.content.Context;
import android.os.Handler;
import com.architjn.audiobook.bean.AudioBook;
import com.architjn.audiobook.database.DBHelper;
import com.architjn.audiobook.interfaces.IAllAudioBookPresenter;
import java.util.ArrayList;
package com.architjn.audiobook.interactor;
/**
* Created by Archit on 25-07-2017.
*/
public class NewAudioBookInteractor {
private final DBHelper dbHandler; | private IAllAudioBookPresenter presenter; |
architjn/YAAB | app/src/main/java/com/architjn/audiobook/interactor/NewAudioBookInteractor.java | // Path: app/src/main/java/com/architjn/audiobook/bean/AudioBook.java
// public class AudioBook implements Serializable {
// private String albumId;
// private String albumKey;
// private String albumName;
// private String artistName;
// private String albumArt;
// private int status;
// private long duration;
// private long currentDuration;
// private ArrayList<BookChapter> chapters;
//
// public AudioBook() {
// //for serializable
// }
//
// public AudioBook(String albumId, String albumKey, String albumName, String artistName,
// String albumArt, int status, long duration, long currentDuration) {
// this.albumId = albumId;
// this.albumKey = albumKey;
// this.albumName = albumName;
// this.artistName = artistName;
// this.albumArt = albumArt;
// this.status = status;
// this.duration = duration;
// this.currentDuration = currentDuration;
// }
//
// public String getAlbumKey() {
// return albumKey;
// }
//
// public String getAlbumId() {
// return albumId;
// }
//
// public String getAlbumName() {
// return albumName;
// }
//
// public String getArtistName() {
// return artistName;
// }
//
// public long getDuration() {
// return duration;
// }
//
// public void setChapters(ArrayList<BookChapter> chapters) {
// this.chapters = chapters;
// }
//
// public ArrayList<BookChapter> getChapters() {
// return chapters;
// }
//
// public String getAlbumArt() {
// return albumArt;
// }
//
// public int getStatus() {
// return status;
// }
//
// public void setStatus(int status) {
// this.status = status;
// }
//
// public void setAlbumId(String albumId) {
// this.albumId = albumId;
// }
//
// public void setAlbumKey(String albumKey) {
// this.albumKey = albumKey;
// }
//
// public void setAlbumName(String albumName) {
// this.albumName = albumName;
// }
//
// public void setArtistName(String artistName) {
// this.artistName = artistName;
// }
//
// public void setAlbumArt(String albumArt) {
// this.albumArt = albumArt;
// }
//
// public void setDuration(long duration) {
// this.duration = duration;
// }
//
// public long getCurrentDuration() {
// return currentDuration;
// }
//
// public void setCurrentDuration(long currentDuration) {
// this.currentDuration = currentDuration;
// }
// }
//
// Path: app/src/main/java/com/architjn/audiobook/database/DBHelper.java
// public class DBHelper extends SQLiteOpenHelper {
//
// private static final String DATABASE_NAME = "yaab-db";
// private static final int DATABASE_VERSION = 1;
//
// private static DBHelper instance;
//
// private final Context context;
//
// public static DBHelper getInstance(Context context) {
// if (instance == null)
// instance = new DBHelper(context);
// return instance;
// }
//
// private DBHelper(Context context) {
// super(context, DATABASE_NAME, null, DATABASE_VERSION);
// this.context = context;
// }
//
// @Override
// public void onCreate(SQLiteDatabase db) {
// AudioBookTable.onCreate(db);
// ChapterTable.onCreate(db);
// }
//
// @Override
// public void onUpgrade(SQLiteDatabase sqLiteDatabase, int i, int i1) {
//
// }
//
// public boolean addAudioBook(AudioBook audioBook) {
// if (AudioBookTable.addBook(this.getWritableDatabase(), audioBook) != -1) {
// ChapterTable.addChapters(this.getWritableDatabase(), audioBook.getAlbumId(),
// audioBook.getChapters());
// return true;
// } else return false;
// }
//
// public ArrayList<AudioBook> loadAllAudioBooks() {
// return AudioBookTable.getAllBooks(this.getReadableDatabase());
// }
//
// public ArrayList<AudioBook> loadNewAudioBooks() {
// return AudioBookTable.getNewBooks(this.getReadableDatabase());
// }
//
// public ArrayList<AudioBook> loadOnGoingAudioBooks() {
// return AudioBookTable.getOnGoingBooks(this.getReadableDatabase());
// }
//
// public void updateBookStatus(String albumId, int status) {
// AudioBookTable.setBookStatus(this.getWritableDatabase(), albumId, status);
// }
//
// public int getOnGoingBooksCount() {
// return AudioBookTable.getOnGoingDataCount(this.getWritableDatabase());
// }
// public int getNewBooksCount() {
// return AudioBookTable.getNewDataCount(this.getWritableDatabase());
// }
//
// public AudioBook getAudioBookViaId(String albumId) {
// return AudioBookTable.getAudioBook(this.getReadableDatabase(), albumId);
// }
// }
//
// Path: app/src/main/java/com/architjn/audiobook/interfaces/IAllAudioBookPresenter.java
// public interface IAllAudioBookPresenter {
// void onAudioBooksLoaded(ArrayList<AudioBook> books);
// }
| import android.content.Context;
import android.os.Handler;
import com.architjn.audiobook.bean.AudioBook;
import com.architjn.audiobook.database.DBHelper;
import com.architjn.audiobook.interfaces.IAllAudioBookPresenter;
import java.util.ArrayList; | package com.architjn.audiobook.interactor;
/**
* Created by Archit on 25-07-2017.
*/
public class NewAudioBookInteractor {
private final DBHelper dbHandler;
private IAllAudioBookPresenter presenter; | // Path: app/src/main/java/com/architjn/audiobook/bean/AudioBook.java
// public class AudioBook implements Serializable {
// private String albumId;
// private String albumKey;
// private String albumName;
// private String artistName;
// private String albumArt;
// private int status;
// private long duration;
// private long currentDuration;
// private ArrayList<BookChapter> chapters;
//
// public AudioBook() {
// //for serializable
// }
//
// public AudioBook(String albumId, String albumKey, String albumName, String artistName,
// String albumArt, int status, long duration, long currentDuration) {
// this.albumId = albumId;
// this.albumKey = albumKey;
// this.albumName = albumName;
// this.artistName = artistName;
// this.albumArt = albumArt;
// this.status = status;
// this.duration = duration;
// this.currentDuration = currentDuration;
// }
//
// public String getAlbumKey() {
// return albumKey;
// }
//
// public String getAlbumId() {
// return albumId;
// }
//
// public String getAlbumName() {
// return albumName;
// }
//
// public String getArtistName() {
// return artistName;
// }
//
// public long getDuration() {
// return duration;
// }
//
// public void setChapters(ArrayList<BookChapter> chapters) {
// this.chapters = chapters;
// }
//
// public ArrayList<BookChapter> getChapters() {
// return chapters;
// }
//
// public String getAlbumArt() {
// return albumArt;
// }
//
// public int getStatus() {
// return status;
// }
//
// public void setStatus(int status) {
// this.status = status;
// }
//
// public void setAlbumId(String albumId) {
// this.albumId = albumId;
// }
//
// public void setAlbumKey(String albumKey) {
// this.albumKey = albumKey;
// }
//
// public void setAlbumName(String albumName) {
// this.albumName = albumName;
// }
//
// public void setArtistName(String artistName) {
// this.artistName = artistName;
// }
//
// public void setAlbumArt(String albumArt) {
// this.albumArt = albumArt;
// }
//
// public void setDuration(long duration) {
// this.duration = duration;
// }
//
// public long getCurrentDuration() {
// return currentDuration;
// }
//
// public void setCurrentDuration(long currentDuration) {
// this.currentDuration = currentDuration;
// }
// }
//
// Path: app/src/main/java/com/architjn/audiobook/database/DBHelper.java
// public class DBHelper extends SQLiteOpenHelper {
//
// private static final String DATABASE_NAME = "yaab-db";
// private static final int DATABASE_VERSION = 1;
//
// private static DBHelper instance;
//
// private final Context context;
//
// public static DBHelper getInstance(Context context) {
// if (instance == null)
// instance = new DBHelper(context);
// return instance;
// }
//
// private DBHelper(Context context) {
// super(context, DATABASE_NAME, null, DATABASE_VERSION);
// this.context = context;
// }
//
// @Override
// public void onCreate(SQLiteDatabase db) {
// AudioBookTable.onCreate(db);
// ChapterTable.onCreate(db);
// }
//
// @Override
// public void onUpgrade(SQLiteDatabase sqLiteDatabase, int i, int i1) {
//
// }
//
// public boolean addAudioBook(AudioBook audioBook) {
// if (AudioBookTable.addBook(this.getWritableDatabase(), audioBook) != -1) {
// ChapterTable.addChapters(this.getWritableDatabase(), audioBook.getAlbumId(),
// audioBook.getChapters());
// return true;
// } else return false;
// }
//
// public ArrayList<AudioBook> loadAllAudioBooks() {
// return AudioBookTable.getAllBooks(this.getReadableDatabase());
// }
//
// public ArrayList<AudioBook> loadNewAudioBooks() {
// return AudioBookTable.getNewBooks(this.getReadableDatabase());
// }
//
// public ArrayList<AudioBook> loadOnGoingAudioBooks() {
// return AudioBookTable.getOnGoingBooks(this.getReadableDatabase());
// }
//
// public void updateBookStatus(String albumId, int status) {
// AudioBookTable.setBookStatus(this.getWritableDatabase(), albumId, status);
// }
//
// public int getOnGoingBooksCount() {
// return AudioBookTable.getOnGoingDataCount(this.getWritableDatabase());
// }
// public int getNewBooksCount() {
// return AudioBookTable.getNewDataCount(this.getWritableDatabase());
// }
//
// public AudioBook getAudioBookViaId(String albumId) {
// return AudioBookTable.getAudioBook(this.getReadableDatabase(), albumId);
// }
// }
//
// Path: app/src/main/java/com/architjn/audiobook/interfaces/IAllAudioBookPresenter.java
// public interface IAllAudioBookPresenter {
// void onAudioBooksLoaded(ArrayList<AudioBook> books);
// }
// Path: app/src/main/java/com/architjn/audiobook/interactor/NewAudioBookInteractor.java
import android.content.Context;
import android.os.Handler;
import com.architjn.audiobook.bean.AudioBook;
import com.architjn.audiobook.database.DBHelper;
import com.architjn.audiobook.interfaces.IAllAudioBookPresenter;
import java.util.ArrayList;
package com.architjn.audiobook.interactor;
/**
* Created by Archit on 25-07-2017.
*/
public class NewAudioBookInteractor {
private final DBHelper dbHandler;
private IAllAudioBookPresenter presenter; | private ArrayList<AudioBook> books; |
architjn/YAAB | app/src/main/java/com/architjn/audiobook/database/DBHelper.java | // Path: app/src/main/java/com/architjn/audiobook/bean/AudioBook.java
// public class AudioBook implements Serializable {
// private String albumId;
// private String albumKey;
// private String albumName;
// private String artistName;
// private String albumArt;
// private int status;
// private long duration;
// private long currentDuration;
// private ArrayList<BookChapter> chapters;
//
// public AudioBook() {
// //for serializable
// }
//
// public AudioBook(String albumId, String albumKey, String albumName, String artistName,
// String albumArt, int status, long duration, long currentDuration) {
// this.albumId = albumId;
// this.albumKey = albumKey;
// this.albumName = albumName;
// this.artistName = artistName;
// this.albumArt = albumArt;
// this.status = status;
// this.duration = duration;
// this.currentDuration = currentDuration;
// }
//
// public String getAlbumKey() {
// return albumKey;
// }
//
// public String getAlbumId() {
// return albumId;
// }
//
// public String getAlbumName() {
// return albumName;
// }
//
// public String getArtistName() {
// return artistName;
// }
//
// public long getDuration() {
// return duration;
// }
//
// public void setChapters(ArrayList<BookChapter> chapters) {
// this.chapters = chapters;
// }
//
// public ArrayList<BookChapter> getChapters() {
// return chapters;
// }
//
// public String getAlbumArt() {
// return albumArt;
// }
//
// public int getStatus() {
// return status;
// }
//
// public void setStatus(int status) {
// this.status = status;
// }
//
// public void setAlbumId(String albumId) {
// this.albumId = albumId;
// }
//
// public void setAlbumKey(String albumKey) {
// this.albumKey = albumKey;
// }
//
// public void setAlbumName(String albumName) {
// this.albumName = albumName;
// }
//
// public void setArtistName(String artistName) {
// this.artistName = artistName;
// }
//
// public void setAlbumArt(String albumArt) {
// this.albumArt = albumArt;
// }
//
// public void setDuration(long duration) {
// this.duration = duration;
// }
//
// public long getCurrentDuration() {
// return currentDuration;
// }
//
// public void setCurrentDuration(long currentDuration) {
// this.currentDuration = currentDuration;
// }
// }
| import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import com.architjn.audiobook.bean.AudioBook;
import java.util.ArrayList; | package com.architjn.audiobook.database;
/**
* Created by Archit on 25-07-2017.
*/
public class DBHelper extends SQLiteOpenHelper {
private static final String DATABASE_NAME = "yaab-db";
private static final int DATABASE_VERSION = 1;
private static DBHelper instance;
private final Context context;
public static DBHelper getInstance(Context context) {
if (instance == null)
instance = new DBHelper(context);
return instance;
}
private DBHelper(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
this.context = context;
}
@Override
public void onCreate(SQLiteDatabase db) {
AudioBookTable.onCreate(db);
ChapterTable.onCreate(db);
}
@Override
public void onUpgrade(SQLiteDatabase sqLiteDatabase, int i, int i1) {
}
| // Path: app/src/main/java/com/architjn/audiobook/bean/AudioBook.java
// public class AudioBook implements Serializable {
// private String albumId;
// private String albumKey;
// private String albumName;
// private String artistName;
// private String albumArt;
// private int status;
// private long duration;
// private long currentDuration;
// private ArrayList<BookChapter> chapters;
//
// public AudioBook() {
// //for serializable
// }
//
// public AudioBook(String albumId, String albumKey, String albumName, String artistName,
// String albumArt, int status, long duration, long currentDuration) {
// this.albumId = albumId;
// this.albumKey = albumKey;
// this.albumName = albumName;
// this.artistName = artistName;
// this.albumArt = albumArt;
// this.status = status;
// this.duration = duration;
// this.currentDuration = currentDuration;
// }
//
// public String getAlbumKey() {
// return albumKey;
// }
//
// public String getAlbumId() {
// return albumId;
// }
//
// public String getAlbumName() {
// return albumName;
// }
//
// public String getArtistName() {
// return artistName;
// }
//
// public long getDuration() {
// return duration;
// }
//
// public void setChapters(ArrayList<BookChapter> chapters) {
// this.chapters = chapters;
// }
//
// public ArrayList<BookChapter> getChapters() {
// return chapters;
// }
//
// public String getAlbumArt() {
// return albumArt;
// }
//
// public int getStatus() {
// return status;
// }
//
// public void setStatus(int status) {
// this.status = status;
// }
//
// public void setAlbumId(String albumId) {
// this.albumId = albumId;
// }
//
// public void setAlbumKey(String albumKey) {
// this.albumKey = albumKey;
// }
//
// public void setAlbumName(String albumName) {
// this.albumName = albumName;
// }
//
// public void setArtistName(String artistName) {
// this.artistName = artistName;
// }
//
// public void setAlbumArt(String albumArt) {
// this.albumArt = albumArt;
// }
//
// public void setDuration(long duration) {
// this.duration = duration;
// }
//
// public long getCurrentDuration() {
// return currentDuration;
// }
//
// public void setCurrentDuration(long currentDuration) {
// this.currentDuration = currentDuration;
// }
// }
// Path: app/src/main/java/com/architjn/audiobook/database/DBHelper.java
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import com.architjn.audiobook.bean.AudioBook;
import java.util.ArrayList;
package com.architjn.audiobook.database;
/**
* Created by Archit on 25-07-2017.
*/
public class DBHelper extends SQLiteOpenHelper {
private static final String DATABASE_NAME = "yaab-db";
private static final int DATABASE_VERSION = 1;
private static DBHelper instance;
private final Context context;
public static DBHelper getInstance(Context context) {
if (instance == null)
instance = new DBHelper(context);
return instance;
}
private DBHelper(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
this.context = context;
}
@Override
public void onCreate(SQLiteDatabase db) {
AudioBookTable.onCreate(db);
ChapterTable.onCreate(db);
}
@Override
public void onUpgrade(SQLiteDatabase sqLiteDatabase, int i, int i1) {
}
| public boolean addAudioBook(AudioBook audioBook) { |
architjn/YAAB | app/src/main/java/com/architjn/audiobook/ui/fragment/AllAudioBookViewFragment.java | // Path: app/src/main/java/com/architjn/audiobook/bean/AudioBook.java
// public class AudioBook implements Serializable {
// private String albumId;
// private String albumKey;
// private String albumName;
// private String artistName;
// private String albumArt;
// private int status;
// private long duration;
// private long currentDuration;
// private ArrayList<BookChapter> chapters;
//
// public AudioBook() {
// //for serializable
// }
//
// public AudioBook(String albumId, String albumKey, String albumName, String artistName,
// String albumArt, int status, long duration, long currentDuration) {
// this.albumId = albumId;
// this.albumKey = albumKey;
// this.albumName = albumName;
// this.artistName = artistName;
// this.albumArt = albumArt;
// this.status = status;
// this.duration = duration;
// this.currentDuration = currentDuration;
// }
//
// public String getAlbumKey() {
// return albumKey;
// }
//
// public String getAlbumId() {
// return albumId;
// }
//
// public String getAlbumName() {
// return albumName;
// }
//
// public String getArtistName() {
// return artistName;
// }
//
// public long getDuration() {
// return duration;
// }
//
// public void setChapters(ArrayList<BookChapter> chapters) {
// this.chapters = chapters;
// }
//
// public ArrayList<BookChapter> getChapters() {
// return chapters;
// }
//
// public String getAlbumArt() {
// return albumArt;
// }
//
// public int getStatus() {
// return status;
// }
//
// public void setStatus(int status) {
// this.status = status;
// }
//
// public void setAlbumId(String albumId) {
// this.albumId = albumId;
// }
//
// public void setAlbumKey(String albumKey) {
// this.albumKey = albumKey;
// }
//
// public void setAlbumName(String albumName) {
// this.albumName = albumName;
// }
//
// public void setArtistName(String artistName) {
// this.artistName = artistName;
// }
//
// public void setAlbumArt(String albumArt) {
// this.albumArt = albumArt;
// }
//
// public void setDuration(long duration) {
// this.duration = duration;
// }
//
// public long getCurrentDuration() {
// return currentDuration;
// }
//
// public void setCurrentDuration(long currentDuration) {
// this.currentDuration = currentDuration;
// }
// }
//
// Path: app/src/main/java/com/architjn/audiobook/presenter/AllAudioBookPresenter.java
// public class AllAudioBookPresenter implements IAdapterItemClick<AudioBook>, IAllAudioBookPresenter {
// private final PrefUtils pref;
// private final AllAudioBookInteractor interactor;
// private IAudioBookView view;
// private Context context;
// private AudioBookAdapter adapter;
//
// public AllAudioBookPresenter(Context context, IAudioBookView view) {
// this.view = view;
// this.context = context;
// this.pref = PrefUtils.getInstance(context);
// this.interactor = new AllAudioBookInteractor(context, this);
// }
//
// public void setRecycler(RecyclerView rv) {
// LinearLayoutManager lm = new LinearLayoutManager(context);
// rv.setLayoutManager(lm);
// DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(rv.getContext(),
// lm.getOrientation());
// rv.addItemDecoration(dividerItemDecoration);
// ArrayList<AudioBook> items = new ArrayList<>();
// adapter = new AudioBookAdapter(context, items, this);
// rv.setAdapter(adapter);
// interactor.loadAllAudioBooks();
// }
//
// @Override
// public void onItemSelected(int position, AudioBook item) {
// Intent intent = new Intent(context, PlayerActivity.class);
// intent.putExtra("id", item.getAlbumId());
// context.startActivity(intent);
// }
//
// @Override
// public void onAudioBooksLoaded(ArrayList<AudioBook> books) {
// if (adapter != null)
// adapter.updateList(books);
// }
//
// public void updateBookList() {
// interactor.loadAllAudioBooks();
// }
// }
//
// Path: app/src/main/java/com/architjn/audiobook/interfaces/IAudioBookView.java
// public interface IAudioBookView {
// }
| import android.content.Context;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.architjn.audiobook.R;
import com.architjn.audiobook.bean.AudioBook;
import com.architjn.audiobook.presenter.AllAudioBookPresenter;
import com.architjn.audiobook.interfaces.IAudioBookView;
import butterknife.BindView;
import butterknife.ButterKnife; | package com.architjn.audiobook.ui.fragment;
/**
* Created by HP on 18-07-2017.
*/
public class AllAudioBookViewFragment extends Fragment implements IAudioBookView {
private View mainView;
private Context context;
private boolean viewDestroyed = true; | // Path: app/src/main/java/com/architjn/audiobook/bean/AudioBook.java
// public class AudioBook implements Serializable {
// private String albumId;
// private String albumKey;
// private String albumName;
// private String artistName;
// private String albumArt;
// private int status;
// private long duration;
// private long currentDuration;
// private ArrayList<BookChapter> chapters;
//
// public AudioBook() {
// //for serializable
// }
//
// public AudioBook(String albumId, String albumKey, String albumName, String artistName,
// String albumArt, int status, long duration, long currentDuration) {
// this.albumId = albumId;
// this.albumKey = albumKey;
// this.albumName = albumName;
// this.artistName = artistName;
// this.albumArt = albumArt;
// this.status = status;
// this.duration = duration;
// this.currentDuration = currentDuration;
// }
//
// public String getAlbumKey() {
// return albumKey;
// }
//
// public String getAlbumId() {
// return albumId;
// }
//
// public String getAlbumName() {
// return albumName;
// }
//
// public String getArtistName() {
// return artistName;
// }
//
// public long getDuration() {
// return duration;
// }
//
// public void setChapters(ArrayList<BookChapter> chapters) {
// this.chapters = chapters;
// }
//
// public ArrayList<BookChapter> getChapters() {
// return chapters;
// }
//
// public String getAlbumArt() {
// return albumArt;
// }
//
// public int getStatus() {
// return status;
// }
//
// public void setStatus(int status) {
// this.status = status;
// }
//
// public void setAlbumId(String albumId) {
// this.albumId = albumId;
// }
//
// public void setAlbumKey(String albumKey) {
// this.albumKey = albumKey;
// }
//
// public void setAlbumName(String albumName) {
// this.albumName = albumName;
// }
//
// public void setArtistName(String artistName) {
// this.artistName = artistName;
// }
//
// public void setAlbumArt(String albumArt) {
// this.albumArt = albumArt;
// }
//
// public void setDuration(long duration) {
// this.duration = duration;
// }
//
// public long getCurrentDuration() {
// return currentDuration;
// }
//
// public void setCurrentDuration(long currentDuration) {
// this.currentDuration = currentDuration;
// }
// }
//
// Path: app/src/main/java/com/architjn/audiobook/presenter/AllAudioBookPresenter.java
// public class AllAudioBookPresenter implements IAdapterItemClick<AudioBook>, IAllAudioBookPresenter {
// private final PrefUtils pref;
// private final AllAudioBookInteractor interactor;
// private IAudioBookView view;
// private Context context;
// private AudioBookAdapter adapter;
//
// public AllAudioBookPresenter(Context context, IAudioBookView view) {
// this.view = view;
// this.context = context;
// this.pref = PrefUtils.getInstance(context);
// this.interactor = new AllAudioBookInteractor(context, this);
// }
//
// public void setRecycler(RecyclerView rv) {
// LinearLayoutManager lm = new LinearLayoutManager(context);
// rv.setLayoutManager(lm);
// DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(rv.getContext(),
// lm.getOrientation());
// rv.addItemDecoration(dividerItemDecoration);
// ArrayList<AudioBook> items = new ArrayList<>();
// adapter = new AudioBookAdapter(context, items, this);
// rv.setAdapter(adapter);
// interactor.loadAllAudioBooks();
// }
//
// @Override
// public void onItemSelected(int position, AudioBook item) {
// Intent intent = new Intent(context, PlayerActivity.class);
// intent.putExtra("id", item.getAlbumId());
// context.startActivity(intent);
// }
//
// @Override
// public void onAudioBooksLoaded(ArrayList<AudioBook> books) {
// if (adapter != null)
// adapter.updateList(books);
// }
//
// public void updateBookList() {
// interactor.loadAllAudioBooks();
// }
// }
//
// Path: app/src/main/java/com/architjn/audiobook/interfaces/IAudioBookView.java
// public interface IAudioBookView {
// }
// Path: app/src/main/java/com/architjn/audiobook/ui/fragment/AllAudioBookViewFragment.java
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.architjn.audiobook.R;
import com.architjn.audiobook.bean.AudioBook;
import com.architjn.audiobook.presenter.AllAudioBookPresenter;
import com.architjn.audiobook.interfaces.IAudioBookView;
import butterknife.BindView;
import butterknife.ButterKnife;
package com.architjn.audiobook.ui.fragment;
/**
* Created by HP on 18-07-2017.
*/
public class AllAudioBookViewFragment extends Fragment implements IAudioBookView {
private View mainView;
private Context context;
private boolean viewDestroyed = true; | private AllAudioBookPresenter presenter; |
architjn/YAAB | app/src/main/java/com/architjn/audiobook/interactor/FolderChooserInteractor.java | // Path: app/src/main/java/com/architjn/audiobook/bean/Folder.java
// public class Folder {
// private final String absolutePath;
// private final String name;
//
// public Folder(String absolutePath, String name) {
// this.absolutePath = absolutePath;
// this.name = name;
// }
//
// public String getAbsolutePath() {
// return absolutePath;
// }
//
// public String getName() {
// return name;
// }
// }
//
// Path: app/src/main/java/com/architjn/audiobook/interfaces/IFolderChooserPresenter.java
// public interface IFolderChooserPresenter {
// void foldersLoaded(String currFolder, ArrayList<Folder> folders);
// }
| import android.os.Environment;
import com.architjn.audiobook.bean.Folder;
import com.architjn.audiobook.interfaces.IFolderChooserPresenter;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays; | package com.architjn.audiobook.interactor;
/**
* Created by HP on 23-07-2017.
*/
public class FolderChooserInteractor {
private IFolderChooserPresenter presenter;
public FolderChooserInteractor(IFolderChooserPresenter presenter) {
this.presenter = presenter;
}
public void loadFolders(String path) { | // Path: app/src/main/java/com/architjn/audiobook/bean/Folder.java
// public class Folder {
// private final String absolutePath;
// private final String name;
//
// public Folder(String absolutePath, String name) {
// this.absolutePath = absolutePath;
// this.name = name;
// }
//
// public String getAbsolutePath() {
// return absolutePath;
// }
//
// public String getName() {
// return name;
// }
// }
//
// Path: app/src/main/java/com/architjn/audiobook/interfaces/IFolderChooserPresenter.java
// public interface IFolderChooserPresenter {
// void foldersLoaded(String currFolder, ArrayList<Folder> folders);
// }
// Path: app/src/main/java/com/architjn/audiobook/interactor/FolderChooserInteractor.java
import android.os.Environment;
import com.architjn.audiobook.bean.Folder;
import com.architjn.audiobook.interfaces.IFolderChooserPresenter;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
package com.architjn.audiobook.interactor;
/**
* Created by HP on 23-07-2017.
*/
public class FolderChooserInteractor {
private IFolderChooserPresenter presenter;
public FolderChooserInteractor(IFolderChooserPresenter presenter) {
this.presenter = presenter;
}
public void loadFolders(String path) { | ArrayList<Folder> folders = new ArrayList<>(); |
androrm/androrm | src/src/com/orm/androrm/Filter.java | // Path: src/src/com/orm/androrm/statement/InStatement.java
// public class InStatement extends Statement {
//
// private List<Object> mValues;
//
// public InStatement(String key, List<Object> values) {
// mKey = key;
// mValues = values;
// }
//
// private String getList() {
// return StringUtils.join(mValues, "','");
// }
//
// @Override
// public String toString() {
// return mKey + " IN ('" + getList() + "')";
// }
//
// }
//
// Path: src/src/com/orm/androrm/statement/Statement.java
// public class Statement {
//
// /**
// * Key of the statement.
// */
// protected String mKey;
// /**
// * Key of the statement.
// */
// protected String mOperator;
// /**
// * Value of the statement.
// */
// protected String mValue;
//
// /**
// * Empty constructor.
// */
// public Statement() {}
//
// public Statement(String key, int value) {
// mKey = key;
// mOperator = "=";
// mValue = String.valueOf(value);
// }
//
// public Statement(String key, String operator, int value) {
// mKey = key;
// mOperator = operator;
// mValue = String.valueOf(value);
// }
//
// /**
// * This constructor sets the key and value field of this
// * statement.
// *
// * @param key Database column.
// * @param value Expected value of this column.
// */
// public Statement(String key, String value) {
// mKey = key;
// mOperator = "=";
// mValue = value;
// }
//
// public Statement(String key, String operator, String value) {
// mKey = key;
// mOperator = operator;
// mValue = value;
// }
//
// /**
// * Get all keys that are used in this statement.
// *
// * @return All keys i.e. the affected database columns.
// */
// public Set<String> getKeys() {
// Set<String> keys = new HashSet<String>();
// keys.add(mKey);
//
// return keys;
// }
//
// public void setKey(String key) {
// mKey = key;
// }
//
// @Override
// public String toString() {
// return mKey + " " + mOperator + " '" + mValue + "'";
// }
// }
| import java.util.ArrayList;
import java.util.List;
import com.orm.androrm.statement.InStatement;
import com.orm.androrm.statement.LikeStatement;
import com.orm.androrm.statement.Statement; | * Retrieves the last field in the chain,
* to gather the correct field name for the
* statement.
*
* @param sequence List of field names separated by __
* @return The last field name in the chain.
*/
private String getFieldName(String sequence) {
String[] fields = sequence.split("__");
return fields[fields.length - 1];
}
public List<Rule> getRules() {
return mRules;
}
/**
* Use this function, if you want the value of the field
* to be in the {@link List} of values you hand in.
* <br /><br />
*
* This can either be a list of {@link Integer integers} or
* a list of model classes. (Classes inheriting from {@link Model})
*
* @param key Chain to the field.
* @param values {@link List} of values.
* @return <code>this</code> for chaining.
*/
public Filter in(String key, List<?> values) { | // Path: src/src/com/orm/androrm/statement/InStatement.java
// public class InStatement extends Statement {
//
// private List<Object> mValues;
//
// public InStatement(String key, List<Object> values) {
// mKey = key;
// mValues = values;
// }
//
// private String getList() {
// return StringUtils.join(mValues, "','");
// }
//
// @Override
// public String toString() {
// return mKey + " IN ('" + getList() + "')";
// }
//
// }
//
// Path: src/src/com/orm/androrm/statement/Statement.java
// public class Statement {
//
// /**
// * Key of the statement.
// */
// protected String mKey;
// /**
// * Key of the statement.
// */
// protected String mOperator;
// /**
// * Value of the statement.
// */
// protected String mValue;
//
// /**
// * Empty constructor.
// */
// public Statement() {}
//
// public Statement(String key, int value) {
// mKey = key;
// mOperator = "=";
// mValue = String.valueOf(value);
// }
//
// public Statement(String key, String operator, int value) {
// mKey = key;
// mOperator = operator;
// mValue = String.valueOf(value);
// }
//
// /**
// * This constructor sets the key and value field of this
// * statement.
// *
// * @param key Database column.
// * @param value Expected value of this column.
// */
// public Statement(String key, String value) {
// mKey = key;
// mOperator = "=";
// mValue = value;
// }
//
// public Statement(String key, String operator, String value) {
// mKey = key;
// mOperator = operator;
// mValue = value;
// }
//
// /**
// * Get all keys that are used in this statement.
// *
// * @return All keys i.e. the affected database columns.
// */
// public Set<String> getKeys() {
// Set<String> keys = new HashSet<String>();
// keys.add(mKey);
//
// return keys;
// }
//
// public void setKey(String key) {
// mKey = key;
// }
//
// @Override
// public String toString() {
// return mKey + " " + mOperator + " '" + mValue + "'";
// }
// }
// Path: src/src/com/orm/androrm/Filter.java
import java.util.ArrayList;
import java.util.List;
import com.orm.androrm.statement.InStatement;
import com.orm.androrm.statement.LikeStatement;
import com.orm.androrm.statement.Statement;
* Retrieves the last field in the chain,
* to gather the correct field name for the
* statement.
*
* @param sequence List of field names separated by __
* @return The last field name in the chain.
*/
private String getFieldName(String sequence) {
String[] fields = sequence.split("__");
return fields[fields.length - 1];
}
public List<Rule> getRules() {
return mRules;
}
/**
* Use this function, if you want the value of the field
* to be in the {@link List} of values you hand in.
* <br /><br />
*
* This can either be a list of {@link Integer integers} or
* a list of model classes. (Classes inheriting from {@link Model})
*
* @param key Chain to the field.
* @param values {@link List} of values.
* @return <code>this</code> for chaining.
*/
public Filter in(String key, List<?> values) { | mRules.add(new Rule(key, new InStatement(getFieldName(key), filterValues(values)))); |
androrm/androrm | src/src/com/orm/androrm/Filter.java | // Path: src/src/com/orm/androrm/statement/InStatement.java
// public class InStatement extends Statement {
//
// private List<Object> mValues;
//
// public InStatement(String key, List<Object> values) {
// mKey = key;
// mValues = values;
// }
//
// private String getList() {
// return StringUtils.join(mValues, "','");
// }
//
// @Override
// public String toString() {
// return mKey + " IN ('" + getList() + "')";
// }
//
// }
//
// Path: src/src/com/orm/androrm/statement/Statement.java
// public class Statement {
//
// /**
// * Key of the statement.
// */
// protected String mKey;
// /**
// * Key of the statement.
// */
// protected String mOperator;
// /**
// * Value of the statement.
// */
// protected String mValue;
//
// /**
// * Empty constructor.
// */
// public Statement() {}
//
// public Statement(String key, int value) {
// mKey = key;
// mOperator = "=";
// mValue = String.valueOf(value);
// }
//
// public Statement(String key, String operator, int value) {
// mKey = key;
// mOperator = operator;
// mValue = String.valueOf(value);
// }
//
// /**
// * This constructor sets the key and value field of this
// * statement.
// *
// * @param key Database column.
// * @param value Expected value of this column.
// */
// public Statement(String key, String value) {
// mKey = key;
// mOperator = "=";
// mValue = value;
// }
//
// public Statement(String key, String operator, String value) {
// mKey = key;
// mOperator = operator;
// mValue = value;
// }
//
// /**
// * Get all keys that are used in this statement.
// *
// * @return All keys i.e. the affected database columns.
// */
// public Set<String> getKeys() {
// Set<String> keys = new HashSet<String>();
// keys.add(mKey);
//
// return keys;
// }
//
// public void setKey(String key) {
// mKey = key;
// }
//
// @Override
// public String toString() {
// return mKey + " " + mOperator + " '" + mValue + "'";
// }
// }
| import java.util.ArrayList;
import java.util.List;
import com.orm.androrm.statement.InStatement;
import com.orm.androrm.statement.LikeStatement;
import com.orm.androrm.statement.Statement; | * See {@link Filter#is(String, String)}.
*/
public Filter is(String key, Integer value) {
return is(key, String.valueOf(value));
}
public Filter is(String key, String operator, Integer value) {
return is(key, operator, String.valueOf(value));
}
/**
* See {@link Filter#is(String, String)}.
*/
public Filter is(String key, Model value) {
return is(key, value.getId());
}
public Filter is(String key, String operator, Model value) {
return is(key, operator, value.getId());
}
/**
* Use this function, if you want to express, that the value
* of the field should be <b>exactly</b> the given value.
*
* @param key Chain leading to the field.
* @param value Desired value of the field.
* @return <code>this</code> for chaining.
*/
public Filter is(String key, String value) { | // Path: src/src/com/orm/androrm/statement/InStatement.java
// public class InStatement extends Statement {
//
// private List<Object> mValues;
//
// public InStatement(String key, List<Object> values) {
// mKey = key;
// mValues = values;
// }
//
// private String getList() {
// return StringUtils.join(mValues, "','");
// }
//
// @Override
// public String toString() {
// return mKey + " IN ('" + getList() + "')";
// }
//
// }
//
// Path: src/src/com/orm/androrm/statement/Statement.java
// public class Statement {
//
// /**
// * Key of the statement.
// */
// protected String mKey;
// /**
// * Key of the statement.
// */
// protected String mOperator;
// /**
// * Value of the statement.
// */
// protected String mValue;
//
// /**
// * Empty constructor.
// */
// public Statement() {}
//
// public Statement(String key, int value) {
// mKey = key;
// mOperator = "=";
// mValue = String.valueOf(value);
// }
//
// public Statement(String key, String operator, int value) {
// mKey = key;
// mOperator = operator;
// mValue = String.valueOf(value);
// }
//
// /**
// * This constructor sets the key and value field of this
// * statement.
// *
// * @param key Database column.
// * @param value Expected value of this column.
// */
// public Statement(String key, String value) {
// mKey = key;
// mOperator = "=";
// mValue = value;
// }
//
// public Statement(String key, String operator, String value) {
// mKey = key;
// mOperator = operator;
// mValue = value;
// }
//
// /**
// * Get all keys that are used in this statement.
// *
// * @return All keys i.e. the affected database columns.
// */
// public Set<String> getKeys() {
// Set<String> keys = new HashSet<String>();
// keys.add(mKey);
//
// return keys;
// }
//
// public void setKey(String key) {
// mKey = key;
// }
//
// @Override
// public String toString() {
// return mKey + " " + mOperator + " '" + mValue + "'";
// }
// }
// Path: src/src/com/orm/androrm/Filter.java
import java.util.ArrayList;
import java.util.List;
import com.orm.androrm.statement.InStatement;
import com.orm.androrm.statement.LikeStatement;
import com.orm.androrm.statement.Statement;
* See {@link Filter#is(String, String)}.
*/
public Filter is(String key, Integer value) {
return is(key, String.valueOf(value));
}
public Filter is(String key, String operator, Integer value) {
return is(key, operator, String.valueOf(value));
}
/**
* See {@link Filter#is(String, String)}.
*/
public Filter is(String key, Model value) {
return is(key, value.getId());
}
public Filter is(String key, String operator, Model value) {
return is(key, operator, value.getId());
}
/**
* Use this function, if you want to express, that the value
* of the field should be <b>exactly</b> the given value.
*
* @param key Chain leading to the field.
* @param value Desired value of the field.
* @return <code>this</code> for chaining.
*/
public Filter is(String key, String value) { | mRules.add(new Rule(key, new Statement(getFieldName(key), value))); |
androrm/androrm | test/src/com/orm/androrm/test/regression/QueryRegression.java | // Path: test/src/com/orm/androrm/impl/Transaction.java
// public class Transaction extends Model {
//
// public Transaction() {
// super();
// }
//
// }
| import java.util.ArrayList;
import java.util.List;
import com.orm.androrm.DatabaseAdapter;
import com.orm.androrm.Model;
import com.orm.androrm.impl.Transaction;
import android.test.AndroidTestCase; | package com.orm.androrm.test.regression;
public class QueryRegression extends AndroidTestCase {
public void testDumbClassName() {
List<Class<? extends Model>> models = new ArrayList<Class<? extends Model>>(); | // Path: test/src/com/orm/androrm/impl/Transaction.java
// public class Transaction extends Model {
//
// public Transaction() {
// super();
// }
//
// }
// Path: test/src/com/orm/androrm/test/regression/QueryRegression.java
import java.util.ArrayList;
import java.util.List;
import com.orm.androrm.DatabaseAdapter;
import com.orm.androrm.Model;
import com.orm.androrm.impl.Transaction;
import android.test.AndroidTestCase;
package com.orm.androrm.test.regression;
public class QueryRegression extends AndroidTestCase {
public void testDumbClassName() {
List<Class<? extends Model>> models = new ArrayList<Class<? extends Model>>(); | models.add(Transaction.class); |
androrm/androrm | test/src/com/orm/androrm/test/migration/ModelTest.java | // Path: test/src/com/orm/androrm/impl/migration/ModelWithMigration.java
// public class ModelWithMigration extends Model {
//
// public ModelWithMigration() {
// super();
// }
//
// @Override
// protected void migrate(Context context) {
// Migrator<ModelWithMigration> migrator = new Migrator<ModelWithMigration>(ModelWithMigration.class);
// migrator.addField("mTestField", new CharField());
// migrator.migrate(context);
// }
//
// }
| import java.util.ArrayList;
import java.util.List;
import com.orm.androrm.DatabaseAdapter;
import com.orm.androrm.Model;
import com.orm.androrm.impl.migration.ModelWithMigration; | package com.orm.androrm.test.migration;
public class ModelTest extends AbstractMigrationTest {
public void testMigrationsRun() {
List<Class<? extends Model>> models = new ArrayList<Class<? extends Model>>(); | // Path: test/src/com/orm/androrm/impl/migration/ModelWithMigration.java
// public class ModelWithMigration extends Model {
//
// public ModelWithMigration() {
// super();
// }
//
// @Override
// protected void migrate(Context context) {
// Migrator<ModelWithMigration> migrator = new Migrator<ModelWithMigration>(ModelWithMigration.class);
// migrator.addField("mTestField", new CharField());
// migrator.migrate(context);
// }
//
// }
// Path: test/src/com/orm/androrm/test/migration/ModelTest.java
import java.util.ArrayList;
import java.util.List;
import com.orm.androrm.DatabaseAdapter;
import com.orm.androrm.Model;
import com.orm.androrm.impl.migration.ModelWithMigration;
package com.orm.androrm.test.migration;
public class ModelTest extends AbstractMigrationTest {
public void testMigrationsRun() {
List<Class<? extends Model>> models = new ArrayList<Class<? extends Model>>(); | models.add(ModelWithMigration.class); |
androrm/androrm | src/src/com/orm/androrm/statement/DeleteStatement.java | // Path: src/src/com/orm/androrm/Query.java
// public interface Query {
//
// /**
// * In order to work properly, each query has to override
// * the <code>toString</code> method of {@link Object}.
// *
// * @return String representation of the query.
// */
// public String toString();
//
// }
//
// Path: src/src/com/orm/androrm/Where.java
// public class Where {
// /**
// * All constraints that shall be applied.
// */
// private Statement mStatement;
// /**
// * Used for quick look up, if the where clause has a certain constraint for
// * a given key.
// */
// private Set<String> mKeys;
//
// public Where() {
// mKeys = new HashSet<String>();
// }
//
// /**
// * Attaches the given {@link Statement} as the right side of the
// * AND statement.
// *
// * @param stmt {@link Statement} to attach.
// * @return <code>this</code> for chaining.
// */
// public Where and(Statement stmt) {
// mKeys.addAll(stmt.getKeys());
//
// if(mStatement == null) {
// mStatement = stmt;
// } else {
// mStatement = new AndStatement(mStatement, stmt);
// }
//
// return this;
// }
//
// /**
// * See {@link Where#and(String, String)}.
// */
// public Where and(String key, int value) {
// return and(key, String.valueOf(value));
// }
//
// /**
// * Adds an AND constraint.
// *
// * @param key Name of the table column.
// * @param value Value of this column.
// */
// public Where and(String key, String value) {
// return and(new Statement(key, value));
// }
//
// /**
// * Checks if there is a constraint for the given column.
// *
// * @param key Column name.
// * @return True if one exists. False otherwise.
// */
// public boolean hasConstraint(String key) {
// return mKeys.contains(key);
// }
//
// /**
// * Attaches the given {@link Statement} as the right side of the
// * OR statement.
// *
// * @param stmt {@link Statement} to attach.
// * @return <code>this</code> for chaining.
// */
// public Where or(Statement stmt) {
// mKeys.addAll(stmt.getKeys());
//
// if(mStatement == null) {
// mStatement = stmt;
// } else {
// mStatement = new OrStatement(mStatement, stmt);
// }
//
// return this;
// }
//
// /**
// * See {@link Where#or(String, String)}.
// */
// public Where or(String key, int value) {
// return or(key, String.valueOf(value));
// }
//
// /**
// * Adds and OR constraint.
// *
// * @param key Name of the table column.
// * @param value Expected value of the column.
// * @return <code>this</code> for chaining.
// */
// public Where or(String key, String value) {
// return or(new Statement(key, value));
// }
//
// /**
// * Overwrite or set the current statement represented by this
// * where clause. In order to create AND or OR statements rather
// * use the respective functions.
// *
// * @param stmt {@link Statement} to apply.
// */
// public void setStatement(Statement stmt) {
// mKeys = stmt.getKeys();
// mStatement = stmt;
// }
//
// public Statement getStatement() {
// return mStatement;
// }
//
// @Override
// public String toString() {
// if(mStatement != null) {
// return " WHERE " + mStatement;
// }
//
// return null;
// }
// }
| import com.orm.androrm.Query;
import com.orm.androrm.Where; | /**
* Copyright (c) 2011 Philipp Giese
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package com.orm.androrm.statement;
/**
* Implements a <code>DELETE</code> on the database.
*
* @author Philipp Giese
*/
public class DeleteStatement implements Query {
private String mFrom; | // Path: src/src/com/orm/androrm/Query.java
// public interface Query {
//
// /**
// * In order to work properly, each query has to override
// * the <code>toString</code> method of {@link Object}.
// *
// * @return String representation of the query.
// */
// public String toString();
//
// }
//
// Path: src/src/com/orm/androrm/Where.java
// public class Where {
// /**
// * All constraints that shall be applied.
// */
// private Statement mStatement;
// /**
// * Used for quick look up, if the where clause has a certain constraint for
// * a given key.
// */
// private Set<String> mKeys;
//
// public Where() {
// mKeys = new HashSet<String>();
// }
//
// /**
// * Attaches the given {@link Statement} as the right side of the
// * AND statement.
// *
// * @param stmt {@link Statement} to attach.
// * @return <code>this</code> for chaining.
// */
// public Where and(Statement stmt) {
// mKeys.addAll(stmt.getKeys());
//
// if(mStatement == null) {
// mStatement = stmt;
// } else {
// mStatement = new AndStatement(mStatement, stmt);
// }
//
// return this;
// }
//
// /**
// * See {@link Where#and(String, String)}.
// */
// public Where and(String key, int value) {
// return and(key, String.valueOf(value));
// }
//
// /**
// * Adds an AND constraint.
// *
// * @param key Name of the table column.
// * @param value Value of this column.
// */
// public Where and(String key, String value) {
// return and(new Statement(key, value));
// }
//
// /**
// * Checks if there is a constraint for the given column.
// *
// * @param key Column name.
// * @return True if one exists. False otherwise.
// */
// public boolean hasConstraint(String key) {
// return mKeys.contains(key);
// }
//
// /**
// * Attaches the given {@link Statement} as the right side of the
// * OR statement.
// *
// * @param stmt {@link Statement} to attach.
// * @return <code>this</code> for chaining.
// */
// public Where or(Statement stmt) {
// mKeys.addAll(stmt.getKeys());
//
// if(mStatement == null) {
// mStatement = stmt;
// } else {
// mStatement = new OrStatement(mStatement, stmt);
// }
//
// return this;
// }
//
// /**
// * See {@link Where#or(String, String)}.
// */
// public Where or(String key, int value) {
// return or(key, String.valueOf(value));
// }
//
// /**
// * Adds and OR constraint.
// *
// * @param key Name of the table column.
// * @param value Expected value of the column.
// * @return <code>this</code> for chaining.
// */
// public Where or(String key, String value) {
// return or(new Statement(key, value));
// }
//
// /**
// * Overwrite or set the current statement represented by this
// * where clause. In order to create AND or OR statements rather
// * use the respective functions.
// *
// * @param stmt {@link Statement} to apply.
// */
// public void setStatement(Statement stmt) {
// mKeys = stmt.getKeys();
// mStatement = stmt;
// }
//
// public Statement getStatement() {
// return mStatement;
// }
//
// @Override
// public String toString() {
// if(mStatement != null) {
// return " WHERE " + mStatement;
// }
//
// return null;
// }
// }
// Path: src/src/com/orm/androrm/statement/DeleteStatement.java
import com.orm.androrm.Query;
import com.orm.androrm.Where;
/**
* Copyright (c) 2011 Philipp Giese
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package com.orm.androrm.statement;
/**
* Implements a <code>DELETE</code> on the database.
*
* @author Philipp Giese
*/
public class DeleteStatement implements Query {
private String mFrom; | private Where mWhere; |
androrm/androrm | test/src/com/orm/androrm/test/field/CharFieldTest.java | // Path: src/src/com/orm/androrm/field/CharField.java
// public class CharField extends DataField<String> {
//
// /**
// * Initializes a standard field with implicit
// * maximum length of 255 characters.
// */
// public CharField() {
// mType = "varchar";
// }
//
// /**
// * Initializes a field and sets the maximum length,
// * if this value is greater than 0 and less than or equal
// * to 255.
// *
// * @param maxLength Maximum number of characters allowed for this field.
// */
// public CharField(int maxLength) {
// mType = "varchar";
//
// if(maxLength > 0
// && maxLength <= 255) {
//
// mMaxLength = maxLength;
// }
// }
//
// @Override
// public void putData(String key, ContentValues values) {
// values.put(key, get());
// }
//
// @Override
// public void set(Cursor c, String fieldName) {
// set(c.getString(c.getColumnIndexOrThrow(fieldName)));
// }
//
// @Override
// public void reset() {
// mValue = null;
// }
//
// }
| import com.orm.androrm.field.CharField;
import android.test.AndroidTestCase; | package com.orm.androrm.test.field;
public class CharFieldTest extends AndroidTestCase {
public void testDefaults() { | // Path: src/src/com/orm/androrm/field/CharField.java
// public class CharField extends DataField<String> {
//
// /**
// * Initializes a standard field with implicit
// * maximum length of 255 characters.
// */
// public CharField() {
// mType = "varchar";
// }
//
// /**
// * Initializes a field and sets the maximum length,
// * if this value is greater than 0 and less than or equal
// * to 255.
// *
// * @param maxLength Maximum number of characters allowed for this field.
// */
// public CharField(int maxLength) {
// mType = "varchar";
//
// if(maxLength > 0
// && maxLength <= 255) {
//
// mMaxLength = maxLength;
// }
// }
//
// @Override
// public void putData(String key, ContentValues values) {
// values.put(key, get());
// }
//
// @Override
// public void set(Cursor c, String fieldName) {
// set(c.getString(c.getColumnIndexOrThrow(fieldName)));
// }
//
// @Override
// public void reset() {
// mValue = null;
// }
//
// }
// Path: test/src/com/orm/androrm/test/field/CharFieldTest.java
import com.orm.androrm.field.CharField;
import android.test.AndroidTestCase;
package com.orm.androrm.test.field;
public class CharFieldTest extends AndroidTestCase {
public void testDefaults() { | CharField c = new CharField(); |
androrm/androrm | test/src/com/orm/androrm/test/ModelTest.java | // Path: test/src/com/orm/androrm/impl/BlankModel.java
// public class BlankModel extends Model {
//
// public static final QuerySet<BlankModel> objects(Context context) {
// return objects(context, BlankModel.class);
// }
//
// protected CharField mName;
// protected LocationField mLocation;
// protected DateField mDate;
//
// public BlankModel() {
// super();
//
// mName = new CharField();
// mLocation = new LocationField();
// mDate = new DateField();
// }
//
// public void setName(String name) {
// mName.set(name);
// }
//
// public String getName() {
// return mName.get();
// }
//
// public void setLocation(Location l) {
// mLocation.set(l);
// }
//
// public Location getLocation() {
// return mLocation.get();
// }
//
// public Date getDate() {
// return mDate.get();
// }
//
// public void setDate(Date date) {
// mDate.set(date);
// }
// }
//
// Path: test/src/com/orm/androrm/impl/BlankModelNoAutoincrement.java
// public class BlankModelNoAutoincrement extends Model {
//
// protected CharField mName;
//
// public BlankModelNoAutoincrement() {
// super(true);
//
// mName = new CharField();
// }
// }
| import java.util.ArrayList;
import java.util.List;
import android.test.AndroidTestCase;
import com.orm.androrm.DatabaseAdapter;
import com.orm.androrm.Model;
import com.orm.androrm.impl.BlankModel;
import com.orm.androrm.impl.BlankModelNoAutoincrement; | package com.orm.androrm.test;
public class ModelTest extends AndroidTestCase {
@Override
public void setUp() {
List<Class<? extends Model>> models = new ArrayList<Class<? extends Model>>(); | // Path: test/src/com/orm/androrm/impl/BlankModel.java
// public class BlankModel extends Model {
//
// public static final QuerySet<BlankModel> objects(Context context) {
// return objects(context, BlankModel.class);
// }
//
// protected CharField mName;
// protected LocationField mLocation;
// protected DateField mDate;
//
// public BlankModel() {
// super();
//
// mName = new CharField();
// mLocation = new LocationField();
// mDate = new DateField();
// }
//
// public void setName(String name) {
// mName.set(name);
// }
//
// public String getName() {
// return mName.get();
// }
//
// public void setLocation(Location l) {
// mLocation.set(l);
// }
//
// public Location getLocation() {
// return mLocation.get();
// }
//
// public Date getDate() {
// return mDate.get();
// }
//
// public void setDate(Date date) {
// mDate.set(date);
// }
// }
//
// Path: test/src/com/orm/androrm/impl/BlankModelNoAutoincrement.java
// public class BlankModelNoAutoincrement extends Model {
//
// protected CharField mName;
//
// public BlankModelNoAutoincrement() {
// super(true);
//
// mName = new CharField();
// }
// }
// Path: test/src/com/orm/androrm/test/ModelTest.java
import java.util.ArrayList;
import java.util.List;
import android.test.AndroidTestCase;
import com.orm.androrm.DatabaseAdapter;
import com.orm.androrm.Model;
import com.orm.androrm.impl.BlankModel;
import com.orm.androrm.impl.BlankModelNoAutoincrement;
package com.orm.androrm.test;
public class ModelTest extends AndroidTestCase {
@Override
public void setUp() {
List<Class<? extends Model>> models = new ArrayList<Class<? extends Model>>(); | models.add(BlankModel.class); |
androrm/androrm | test/src/com/orm/androrm/test/ModelTest.java | // Path: test/src/com/orm/androrm/impl/BlankModel.java
// public class BlankModel extends Model {
//
// public static final QuerySet<BlankModel> objects(Context context) {
// return objects(context, BlankModel.class);
// }
//
// protected CharField mName;
// protected LocationField mLocation;
// protected DateField mDate;
//
// public BlankModel() {
// super();
//
// mName = new CharField();
// mLocation = new LocationField();
// mDate = new DateField();
// }
//
// public void setName(String name) {
// mName.set(name);
// }
//
// public String getName() {
// return mName.get();
// }
//
// public void setLocation(Location l) {
// mLocation.set(l);
// }
//
// public Location getLocation() {
// return mLocation.get();
// }
//
// public Date getDate() {
// return mDate.get();
// }
//
// public void setDate(Date date) {
// mDate.set(date);
// }
// }
//
// Path: test/src/com/orm/androrm/impl/BlankModelNoAutoincrement.java
// public class BlankModelNoAutoincrement extends Model {
//
// protected CharField mName;
//
// public BlankModelNoAutoincrement() {
// super(true);
//
// mName = new CharField();
// }
// }
| import java.util.ArrayList;
import java.util.List;
import android.test.AndroidTestCase;
import com.orm.androrm.DatabaseAdapter;
import com.orm.androrm.Model;
import com.orm.androrm.impl.BlankModel;
import com.orm.androrm.impl.BlankModelNoAutoincrement; | package com.orm.androrm.test;
public class ModelTest extends AndroidTestCase {
@Override
public void setUp() {
List<Class<? extends Model>> models = new ArrayList<Class<? extends Model>>();
models.add(BlankModel.class); | // Path: test/src/com/orm/androrm/impl/BlankModel.java
// public class BlankModel extends Model {
//
// public static final QuerySet<BlankModel> objects(Context context) {
// return objects(context, BlankModel.class);
// }
//
// protected CharField mName;
// protected LocationField mLocation;
// protected DateField mDate;
//
// public BlankModel() {
// super();
//
// mName = new CharField();
// mLocation = new LocationField();
// mDate = new DateField();
// }
//
// public void setName(String name) {
// mName.set(name);
// }
//
// public String getName() {
// return mName.get();
// }
//
// public void setLocation(Location l) {
// mLocation.set(l);
// }
//
// public Location getLocation() {
// return mLocation.get();
// }
//
// public Date getDate() {
// return mDate.get();
// }
//
// public void setDate(Date date) {
// mDate.set(date);
// }
// }
//
// Path: test/src/com/orm/androrm/impl/BlankModelNoAutoincrement.java
// public class BlankModelNoAutoincrement extends Model {
//
// protected CharField mName;
//
// public BlankModelNoAutoincrement() {
// super(true);
//
// mName = new CharField();
// }
// }
// Path: test/src/com/orm/androrm/test/ModelTest.java
import java.util.ArrayList;
import java.util.List;
import android.test.AndroidTestCase;
import com.orm.androrm.DatabaseAdapter;
import com.orm.androrm.Model;
import com.orm.androrm.impl.BlankModel;
import com.orm.androrm.impl.BlankModelNoAutoincrement;
package com.orm.androrm.test;
public class ModelTest extends AndroidTestCase {
@Override
public void setUp() {
List<Class<? extends Model>> models = new ArrayList<Class<? extends Model>>();
models.add(BlankModel.class); | models.add(BlankModelNoAutoincrement.class); |
androrm/androrm | test/src/com/orm/androrm/test/field/BlobFieldTest.java | // Path: src/src/com/orm/androrm/field/BlobField.java
// public class BlobField extends DataField<byte[]> {
//
// public BlobField() {
// mType = "blob";
// }
//
// @Override
// public void putData(String fieldName, ContentValues values) {
// values.put(fieldName, get());
// }
//
// @Override
// public void set(Cursor c, String fieldName) {
// mValue = c.getBlob(c.getColumnIndexOrThrow(fieldName));
// }
//
// @Override
// public void reset() {
// mValue = null;
// }
//
// }
| import android.test.AndroidTestCase;
import com.orm.androrm.field.BlobField; | package com.orm.androrm.test.field;
public class BlobFieldTest extends AndroidTestCase {
public void testDefaults() { | // Path: src/src/com/orm/androrm/field/BlobField.java
// public class BlobField extends DataField<byte[]> {
//
// public BlobField() {
// mType = "blob";
// }
//
// @Override
// public void putData(String fieldName, ContentValues values) {
// values.put(fieldName, get());
// }
//
// @Override
// public void set(Cursor c, String fieldName) {
// mValue = c.getBlob(c.getColumnIndexOrThrow(fieldName));
// }
//
// @Override
// public void reset() {
// mValue = null;
// }
//
// }
// Path: test/src/com/orm/androrm/test/field/BlobFieldTest.java
import android.test.AndroidTestCase;
import com.orm.androrm.field.BlobField;
package com.orm.androrm.test.field;
public class BlobFieldTest extends AndroidTestCase {
public void testDefaults() { | BlobField b = new BlobField(); |
androrm/androrm | test/src/com/orm/androrm/test/field/LocationFieldTest.java | // Path: src/src/com/orm/androrm/field/LocationField.java
// public class LocationField extends DataField<Location> {
//
// public LocationField() {
// mType = "numeric";
// }
//
// /**
// * As a location consists of longitude and latitude,
// * this field will create 2 fields in the database.
// */
// @Override
// public String getDefinition(String fieldName) {
// String definition = latName(fieldName) + " " + mType + ", ";
// definition += lngName(fieldName) + " " + mType;
//
// return definition;
// }
//
// private String latName(String fieldName) {
// return fieldName + "Lat";
// }
//
// private String lngName(String fieldName) {
// return fieldName + "Lng";
// }
//
// @Override
// public void putData(String fieldName, ContentValues values) {
// double lat = 0.0;
// double lng = 0.0;
//
// if(mValue != null) {
// lat = mValue.getLatitude();
// lng = mValue.getLongitude();
// }
//
// values.put(latName(fieldName), lat);
// values.put(lngName(fieldName), lng);
// }
//
// @Override
// public void set(Cursor c, String fieldName) {
// double lat = c.getDouble(c.getColumnIndexOrThrow(latName(fieldName)));
// double lng = c.getDouble(c.getColumnIndexOrThrow(lngName(fieldName)));
//
// Location l = new Location(LocationManager.GPS_PROVIDER);
// l.setLatitude(lat);
// l.setLongitude(lng);
//
// mValue = l;
// }
//
// @Override
// public void reset() {
// mValue = null;
// }
//
// @Override
// public boolean addToAs(Context context, Class<? extends Model> model, String name) {
// String latSQL = "ALTER TABLE `" + DatabaseBuilder.getTableName(model) + "` "
// + "ADD COLUMN `" + latName(name) + "` " + mType;
//
// String lngSQL = "ALTER TABLE `" + DatabaseBuilder.getTableName(model) + "` "
// + "ADD COLUMN `" + lngName(name) + "` " + mType;
//
//
// return exec(context, model, latSQL) && exec(context, model, lngSQL);
// }
//
// }
//
// Path: test/src/com/orm/androrm/impl/BlankModel.java
// public class BlankModel extends Model {
//
// public static final QuerySet<BlankModel> objects(Context context) {
// return objects(context, BlankModel.class);
// }
//
// protected CharField mName;
// protected LocationField mLocation;
// protected DateField mDate;
//
// public BlankModel() {
// super();
//
// mName = new CharField();
// mLocation = new LocationField();
// mDate = new DateField();
// }
//
// public void setName(String name) {
// mName.set(name);
// }
//
// public String getName() {
// return mName.get();
// }
//
// public void setLocation(Location l) {
// mLocation.set(l);
// }
//
// public Location getLocation() {
// return mLocation.get();
// }
//
// public Date getDate() {
// return mDate.get();
// }
//
// public void setDate(Date date) {
// mDate.set(date);
// }
// }
| import java.util.ArrayList;
import java.util.List;
import android.location.Location;
import android.location.LocationManager;
import android.test.AndroidTestCase;
import com.orm.androrm.DatabaseAdapter;
import com.orm.androrm.Model;
import com.orm.androrm.field.LocationField;
import com.orm.androrm.impl.BlankModel; | package com.orm.androrm.test.field;
public class LocationFieldTest extends AndroidTestCase {
@Override
public void setUp() {
List<Class<? extends Model>> models = new ArrayList<Class<? extends Model>>(); | // Path: src/src/com/orm/androrm/field/LocationField.java
// public class LocationField extends DataField<Location> {
//
// public LocationField() {
// mType = "numeric";
// }
//
// /**
// * As a location consists of longitude and latitude,
// * this field will create 2 fields in the database.
// */
// @Override
// public String getDefinition(String fieldName) {
// String definition = latName(fieldName) + " " + mType + ", ";
// definition += lngName(fieldName) + " " + mType;
//
// return definition;
// }
//
// private String latName(String fieldName) {
// return fieldName + "Lat";
// }
//
// private String lngName(String fieldName) {
// return fieldName + "Lng";
// }
//
// @Override
// public void putData(String fieldName, ContentValues values) {
// double lat = 0.0;
// double lng = 0.0;
//
// if(mValue != null) {
// lat = mValue.getLatitude();
// lng = mValue.getLongitude();
// }
//
// values.put(latName(fieldName), lat);
// values.put(lngName(fieldName), lng);
// }
//
// @Override
// public void set(Cursor c, String fieldName) {
// double lat = c.getDouble(c.getColumnIndexOrThrow(latName(fieldName)));
// double lng = c.getDouble(c.getColumnIndexOrThrow(lngName(fieldName)));
//
// Location l = new Location(LocationManager.GPS_PROVIDER);
// l.setLatitude(lat);
// l.setLongitude(lng);
//
// mValue = l;
// }
//
// @Override
// public void reset() {
// mValue = null;
// }
//
// @Override
// public boolean addToAs(Context context, Class<? extends Model> model, String name) {
// String latSQL = "ALTER TABLE `" + DatabaseBuilder.getTableName(model) + "` "
// + "ADD COLUMN `" + latName(name) + "` " + mType;
//
// String lngSQL = "ALTER TABLE `" + DatabaseBuilder.getTableName(model) + "` "
// + "ADD COLUMN `" + lngName(name) + "` " + mType;
//
//
// return exec(context, model, latSQL) && exec(context, model, lngSQL);
// }
//
// }
//
// Path: test/src/com/orm/androrm/impl/BlankModel.java
// public class BlankModel extends Model {
//
// public static final QuerySet<BlankModel> objects(Context context) {
// return objects(context, BlankModel.class);
// }
//
// protected CharField mName;
// protected LocationField mLocation;
// protected DateField mDate;
//
// public BlankModel() {
// super();
//
// mName = new CharField();
// mLocation = new LocationField();
// mDate = new DateField();
// }
//
// public void setName(String name) {
// mName.set(name);
// }
//
// public String getName() {
// return mName.get();
// }
//
// public void setLocation(Location l) {
// mLocation.set(l);
// }
//
// public Location getLocation() {
// return mLocation.get();
// }
//
// public Date getDate() {
// return mDate.get();
// }
//
// public void setDate(Date date) {
// mDate.set(date);
// }
// }
// Path: test/src/com/orm/androrm/test/field/LocationFieldTest.java
import java.util.ArrayList;
import java.util.List;
import android.location.Location;
import android.location.LocationManager;
import android.test.AndroidTestCase;
import com.orm.androrm.DatabaseAdapter;
import com.orm.androrm.Model;
import com.orm.androrm.field.LocationField;
import com.orm.androrm.impl.BlankModel;
package com.orm.androrm.test.field;
public class LocationFieldTest extends AndroidTestCase {
@Override
public void setUp() {
List<Class<? extends Model>> models = new ArrayList<Class<? extends Model>>(); | models.add(BlankModel.class); |
androrm/androrm | test/src/com/orm/androrm/test/field/LocationFieldTest.java | // Path: src/src/com/orm/androrm/field/LocationField.java
// public class LocationField extends DataField<Location> {
//
// public LocationField() {
// mType = "numeric";
// }
//
// /**
// * As a location consists of longitude and latitude,
// * this field will create 2 fields in the database.
// */
// @Override
// public String getDefinition(String fieldName) {
// String definition = latName(fieldName) + " " + mType + ", ";
// definition += lngName(fieldName) + " " + mType;
//
// return definition;
// }
//
// private String latName(String fieldName) {
// return fieldName + "Lat";
// }
//
// private String lngName(String fieldName) {
// return fieldName + "Lng";
// }
//
// @Override
// public void putData(String fieldName, ContentValues values) {
// double lat = 0.0;
// double lng = 0.0;
//
// if(mValue != null) {
// lat = mValue.getLatitude();
// lng = mValue.getLongitude();
// }
//
// values.put(latName(fieldName), lat);
// values.put(lngName(fieldName), lng);
// }
//
// @Override
// public void set(Cursor c, String fieldName) {
// double lat = c.getDouble(c.getColumnIndexOrThrow(latName(fieldName)));
// double lng = c.getDouble(c.getColumnIndexOrThrow(lngName(fieldName)));
//
// Location l = new Location(LocationManager.GPS_PROVIDER);
// l.setLatitude(lat);
// l.setLongitude(lng);
//
// mValue = l;
// }
//
// @Override
// public void reset() {
// mValue = null;
// }
//
// @Override
// public boolean addToAs(Context context, Class<? extends Model> model, String name) {
// String latSQL = "ALTER TABLE `" + DatabaseBuilder.getTableName(model) + "` "
// + "ADD COLUMN `" + latName(name) + "` " + mType;
//
// String lngSQL = "ALTER TABLE `" + DatabaseBuilder.getTableName(model) + "` "
// + "ADD COLUMN `" + lngName(name) + "` " + mType;
//
//
// return exec(context, model, latSQL) && exec(context, model, lngSQL);
// }
//
// }
//
// Path: test/src/com/orm/androrm/impl/BlankModel.java
// public class BlankModel extends Model {
//
// public static final QuerySet<BlankModel> objects(Context context) {
// return objects(context, BlankModel.class);
// }
//
// protected CharField mName;
// protected LocationField mLocation;
// protected DateField mDate;
//
// public BlankModel() {
// super();
//
// mName = new CharField();
// mLocation = new LocationField();
// mDate = new DateField();
// }
//
// public void setName(String name) {
// mName.set(name);
// }
//
// public String getName() {
// return mName.get();
// }
//
// public void setLocation(Location l) {
// mLocation.set(l);
// }
//
// public Location getLocation() {
// return mLocation.get();
// }
//
// public Date getDate() {
// return mDate.get();
// }
//
// public void setDate(Date date) {
// mDate.set(date);
// }
// }
| import java.util.ArrayList;
import java.util.List;
import android.location.Location;
import android.location.LocationManager;
import android.test.AndroidTestCase;
import com.orm.androrm.DatabaseAdapter;
import com.orm.androrm.Model;
import com.orm.androrm.field.LocationField;
import com.orm.androrm.impl.BlankModel; | package com.orm.androrm.test.field;
public class LocationFieldTest extends AndroidTestCase {
@Override
public void setUp() {
List<Class<? extends Model>> models = new ArrayList<Class<? extends Model>>();
models.add(BlankModel.class);
DatabaseAdapter adapter = DatabaseAdapter.getInstance(getContext());
adapter.setModels(models);
}
@Override
public void tearDown() {
DatabaseAdapter adapter = DatabaseAdapter.getInstance(getContext());
adapter.drop();
}
public void testDefinition() { | // Path: src/src/com/orm/androrm/field/LocationField.java
// public class LocationField extends DataField<Location> {
//
// public LocationField() {
// mType = "numeric";
// }
//
// /**
// * As a location consists of longitude and latitude,
// * this field will create 2 fields in the database.
// */
// @Override
// public String getDefinition(String fieldName) {
// String definition = latName(fieldName) + " " + mType + ", ";
// definition += lngName(fieldName) + " " + mType;
//
// return definition;
// }
//
// private String latName(String fieldName) {
// return fieldName + "Lat";
// }
//
// private String lngName(String fieldName) {
// return fieldName + "Lng";
// }
//
// @Override
// public void putData(String fieldName, ContentValues values) {
// double lat = 0.0;
// double lng = 0.0;
//
// if(mValue != null) {
// lat = mValue.getLatitude();
// lng = mValue.getLongitude();
// }
//
// values.put(latName(fieldName), lat);
// values.put(lngName(fieldName), lng);
// }
//
// @Override
// public void set(Cursor c, String fieldName) {
// double lat = c.getDouble(c.getColumnIndexOrThrow(latName(fieldName)));
// double lng = c.getDouble(c.getColumnIndexOrThrow(lngName(fieldName)));
//
// Location l = new Location(LocationManager.GPS_PROVIDER);
// l.setLatitude(lat);
// l.setLongitude(lng);
//
// mValue = l;
// }
//
// @Override
// public void reset() {
// mValue = null;
// }
//
// @Override
// public boolean addToAs(Context context, Class<? extends Model> model, String name) {
// String latSQL = "ALTER TABLE `" + DatabaseBuilder.getTableName(model) + "` "
// + "ADD COLUMN `" + latName(name) + "` " + mType;
//
// String lngSQL = "ALTER TABLE `" + DatabaseBuilder.getTableName(model) + "` "
// + "ADD COLUMN `" + lngName(name) + "` " + mType;
//
//
// return exec(context, model, latSQL) && exec(context, model, lngSQL);
// }
//
// }
//
// Path: test/src/com/orm/androrm/impl/BlankModel.java
// public class BlankModel extends Model {
//
// public static final QuerySet<BlankModel> objects(Context context) {
// return objects(context, BlankModel.class);
// }
//
// protected CharField mName;
// protected LocationField mLocation;
// protected DateField mDate;
//
// public BlankModel() {
// super();
//
// mName = new CharField();
// mLocation = new LocationField();
// mDate = new DateField();
// }
//
// public void setName(String name) {
// mName.set(name);
// }
//
// public String getName() {
// return mName.get();
// }
//
// public void setLocation(Location l) {
// mLocation.set(l);
// }
//
// public Location getLocation() {
// return mLocation.get();
// }
//
// public Date getDate() {
// return mDate.get();
// }
//
// public void setDate(Date date) {
// mDate.set(date);
// }
// }
// Path: test/src/com/orm/androrm/test/field/LocationFieldTest.java
import java.util.ArrayList;
import java.util.List;
import android.location.Location;
import android.location.LocationManager;
import android.test.AndroidTestCase;
import com.orm.androrm.DatabaseAdapter;
import com.orm.androrm.Model;
import com.orm.androrm.field.LocationField;
import com.orm.androrm.impl.BlankModel;
package com.orm.androrm.test.field;
public class LocationFieldTest extends AndroidTestCase {
@Override
public void setUp() {
List<Class<? extends Model>> models = new ArrayList<Class<? extends Model>>();
models.add(BlankModel.class);
DatabaseAdapter adapter = DatabaseAdapter.getInstance(getContext());
adapter.setModels(models);
}
@Override
public void tearDown() {
DatabaseAdapter adapter = DatabaseAdapter.getInstance(getContext());
adapter.drop();
}
public void testDefinition() { | LocationField field = new LocationField(); |
androrm/androrm | test/src/com/orm/androrm/test/migration/MigrationHelperTest.java | // Path: test/src/com/orm/androrm/impl/migration/EmptyModel.java
// public class EmptyModel extends Model {
//
// public static QuerySet<EmptyModel> objects(Context context) {
// return objects(context, EmptyModel.class);
// }
//
// protected ManyToManyField<EmptyModel, NewEmptyModel> mM2M;
//
// public EmptyModel() {
// super();
//
// mM2M = new ManyToManyField<EmptyModel, NewEmptyModel>(EmptyModel.class, NewEmptyModel.class);
// }
//
// }
//
// Path: test/src/com/orm/androrm/impl/migration/ModelWithRelation.java
// public class ModelWithRelation extends Model {
//
// protected ManyToManyField<ModelWithRelation, EmptyModel> mRelation;
//
// public ModelWithRelation() {
// super();
//
// mRelation = new ManyToManyField<ModelWithRelation, EmptyModel>(ModelWithRelation.class, EmptyModel.class);
// }
//
// public void addRelation(EmptyModel model) {
// mRelation.add(model);
// }
//
// public QuerySet<EmptyModel> getRelations(Context context) {
// return mRelation.get(context, this);
// }
// }
//
// Path: test/src/com/orm/androrm/impl/migration/OneFieldModel.java
// public class OneFieldModel extends Model {
//
// protected CharField mName;
//
// public OneFieldModel() {
// super();
//
// mName = new CharField();
// }
//
// }
| import java.util.ArrayList;
import java.util.List;
import com.orm.androrm.DatabaseAdapter;
import com.orm.androrm.Model;
import com.orm.androrm.impl.migration.EmptyModel;
import com.orm.androrm.impl.migration.ModelWithRelation;
import com.orm.androrm.impl.migration.OneFieldModel; | package com.orm.androrm.test.migration;
public class MigrationHelperTest extends AbstractMigrationTest {
@Override
public void setUp() {
List<Class<? extends Model>> models = new ArrayList<Class<? extends Model>>(); | // Path: test/src/com/orm/androrm/impl/migration/EmptyModel.java
// public class EmptyModel extends Model {
//
// public static QuerySet<EmptyModel> objects(Context context) {
// return objects(context, EmptyModel.class);
// }
//
// protected ManyToManyField<EmptyModel, NewEmptyModel> mM2M;
//
// public EmptyModel() {
// super();
//
// mM2M = new ManyToManyField<EmptyModel, NewEmptyModel>(EmptyModel.class, NewEmptyModel.class);
// }
//
// }
//
// Path: test/src/com/orm/androrm/impl/migration/ModelWithRelation.java
// public class ModelWithRelation extends Model {
//
// protected ManyToManyField<ModelWithRelation, EmptyModel> mRelation;
//
// public ModelWithRelation() {
// super();
//
// mRelation = new ManyToManyField<ModelWithRelation, EmptyModel>(ModelWithRelation.class, EmptyModel.class);
// }
//
// public void addRelation(EmptyModel model) {
// mRelation.add(model);
// }
//
// public QuerySet<EmptyModel> getRelations(Context context) {
// return mRelation.get(context, this);
// }
// }
//
// Path: test/src/com/orm/androrm/impl/migration/OneFieldModel.java
// public class OneFieldModel extends Model {
//
// protected CharField mName;
//
// public OneFieldModel() {
// super();
//
// mName = new CharField();
// }
//
// }
// Path: test/src/com/orm/androrm/test/migration/MigrationHelperTest.java
import java.util.ArrayList;
import java.util.List;
import com.orm.androrm.DatabaseAdapter;
import com.orm.androrm.Model;
import com.orm.androrm.impl.migration.EmptyModel;
import com.orm.androrm.impl.migration.ModelWithRelation;
import com.orm.androrm.impl.migration.OneFieldModel;
package com.orm.androrm.test.migration;
public class MigrationHelperTest extends AbstractMigrationTest {
@Override
public void setUp() {
List<Class<? extends Model>> models = new ArrayList<Class<? extends Model>>(); | models.add(EmptyModel.class); |
androrm/androrm | test/src/com/orm/androrm/test/migration/MigrationHelperTest.java | // Path: test/src/com/orm/androrm/impl/migration/EmptyModel.java
// public class EmptyModel extends Model {
//
// public static QuerySet<EmptyModel> objects(Context context) {
// return objects(context, EmptyModel.class);
// }
//
// protected ManyToManyField<EmptyModel, NewEmptyModel> mM2M;
//
// public EmptyModel() {
// super();
//
// mM2M = new ManyToManyField<EmptyModel, NewEmptyModel>(EmptyModel.class, NewEmptyModel.class);
// }
//
// }
//
// Path: test/src/com/orm/androrm/impl/migration/ModelWithRelation.java
// public class ModelWithRelation extends Model {
//
// protected ManyToManyField<ModelWithRelation, EmptyModel> mRelation;
//
// public ModelWithRelation() {
// super();
//
// mRelation = new ManyToManyField<ModelWithRelation, EmptyModel>(ModelWithRelation.class, EmptyModel.class);
// }
//
// public void addRelation(EmptyModel model) {
// mRelation.add(model);
// }
//
// public QuerySet<EmptyModel> getRelations(Context context) {
// return mRelation.get(context, this);
// }
// }
//
// Path: test/src/com/orm/androrm/impl/migration/OneFieldModel.java
// public class OneFieldModel extends Model {
//
// protected CharField mName;
//
// public OneFieldModel() {
// super();
//
// mName = new CharField();
// }
//
// }
| import java.util.ArrayList;
import java.util.List;
import com.orm.androrm.DatabaseAdapter;
import com.orm.androrm.Model;
import com.orm.androrm.impl.migration.EmptyModel;
import com.orm.androrm.impl.migration.ModelWithRelation;
import com.orm.androrm.impl.migration.OneFieldModel; | package com.orm.androrm.test.migration;
public class MigrationHelperTest extends AbstractMigrationTest {
@Override
public void setUp() {
List<Class<? extends Model>> models = new ArrayList<Class<? extends Model>>();
models.add(EmptyModel.class); | // Path: test/src/com/orm/androrm/impl/migration/EmptyModel.java
// public class EmptyModel extends Model {
//
// public static QuerySet<EmptyModel> objects(Context context) {
// return objects(context, EmptyModel.class);
// }
//
// protected ManyToManyField<EmptyModel, NewEmptyModel> mM2M;
//
// public EmptyModel() {
// super();
//
// mM2M = new ManyToManyField<EmptyModel, NewEmptyModel>(EmptyModel.class, NewEmptyModel.class);
// }
//
// }
//
// Path: test/src/com/orm/androrm/impl/migration/ModelWithRelation.java
// public class ModelWithRelation extends Model {
//
// protected ManyToManyField<ModelWithRelation, EmptyModel> mRelation;
//
// public ModelWithRelation() {
// super();
//
// mRelation = new ManyToManyField<ModelWithRelation, EmptyModel>(ModelWithRelation.class, EmptyModel.class);
// }
//
// public void addRelation(EmptyModel model) {
// mRelation.add(model);
// }
//
// public QuerySet<EmptyModel> getRelations(Context context) {
// return mRelation.get(context, this);
// }
// }
//
// Path: test/src/com/orm/androrm/impl/migration/OneFieldModel.java
// public class OneFieldModel extends Model {
//
// protected CharField mName;
//
// public OneFieldModel() {
// super();
//
// mName = new CharField();
// }
//
// }
// Path: test/src/com/orm/androrm/test/migration/MigrationHelperTest.java
import java.util.ArrayList;
import java.util.List;
import com.orm.androrm.DatabaseAdapter;
import com.orm.androrm.Model;
import com.orm.androrm.impl.migration.EmptyModel;
import com.orm.androrm.impl.migration.ModelWithRelation;
import com.orm.androrm.impl.migration.OneFieldModel;
package com.orm.androrm.test.migration;
public class MigrationHelperTest extends AbstractMigrationTest {
@Override
public void setUp() {
List<Class<? extends Model>> models = new ArrayList<Class<? extends Model>>();
models.add(EmptyModel.class); | models.add(OneFieldModel.class); |
androrm/androrm | test/src/com/orm/androrm/test/migration/MigrationHelperTest.java | // Path: test/src/com/orm/androrm/impl/migration/EmptyModel.java
// public class EmptyModel extends Model {
//
// public static QuerySet<EmptyModel> objects(Context context) {
// return objects(context, EmptyModel.class);
// }
//
// protected ManyToManyField<EmptyModel, NewEmptyModel> mM2M;
//
// public EmptyModel() {
// super();
//
// mM2M = new ManyToManyField<EmptyModel, NewEmptyModel>(EmptyModel.class, NewEmptyModel.class);
// }
//
// }
//
// Path: test/src/com/orm/androrm/impl/migration/ModelWithRelation.java
// public class ModelWithRelation extends Model {
//
// protected ManyToManyField<ModelWithRelation, EmptyModel> mRelation;
//
// public ModelWithRelation() {
// super();
//
// mRelation = new ManyToManyField<ModelWithRelation, EmptyModel>(ModelWithRelation.class, EmptyModel.class);
// }
//
// public void addRelation(EmptyModel model) {
// mRelation.add(model);
// }
//
// public QuerySet<EmptyModel> getRelations(Context context) {
// return mRelation.get(context, this);
// }
// }
//
// Path: test/src/com/orm/androrm/impl/migration/OneFieldModel.java
// public class OneFieldModel extends Model {
//
// protected CharField mName;
//
// public OneFieldModel() {
// super();
//
// mName = new CharField();
// }
//
// }
| import java.util.ArrayList;
import java.util.List;
import com.orm.androrm.DatabaseAdapter;
import com.orm.androrm.Model;
import com.orm.androrm.impl.migration.EmptyModel;
import com.orm.androrm.impl.migration.ModelWithRelation;
import com.orm.androrm.impl.migration.OneFieldModel; | package com.orm.androrm.test.migration;
public class MigrationHelperTest extends AbstractMigrationTest {
@Override
public void setUp() {
List<Class<? extends Model>> models = new ArrayList<Class<? extends Model>>();
models.add(EmptyModel.class);
models.add(OneFieldModel.class); | // Path: test/src/com/orm/androrm/impl/migration/EmptyModel.java
// public class EmptyModel extends Model {
//
// public static QuerySet<EmptyModel> objects(Context context) {
// return objects(context, EmptyModel.class);
// }
//
// protected ManyToManyField<EmptyModel, NewEmptyModel> mM2M;
//
// public EmptyModel() {
// super();
//
// mM2M = new ManyToManyField<EmptyModel, NewEmptyModel>(EmptyModel.class, NewEmptyModel.class);
// }
//
// }
//
// Path: test/src/com/orm/androrm/impl/migration/ModelWithRelation.java
// public class ModelWithRelation extends Model {
//
// protected ManyToManyField<ModelWithRelation, EmptyModel> mRelation;
//
// public ModelWithRelation() {
// super();
//
// mRelation = new ManyToManyField<ModelWithRelation, EmptyModel>(ModelWithRelation.class, EmptyModel.class);
// }
//
// public void addRelation(EmptyModel model) {
// mRelation.add(model);
// }
//
// public QuerySet<EmptyModel> getRelations(Context context) {
// return mRelation.get(context, this);
// }
// }
//
// Path: test/src/com/orm/androrm/impl/migration/OneFieldModel.java
// public class OneFieldModel extends Model {
//
// protected CharField mName;
//
// public OneFieldModel() {
// super();
//
// mName = new CharField();
// }
//
// }
// Path: test/src/com/orm/androrm/test/migration/MigrationHelperTest.java
import java.util.ArrayList;
import java.util.List;
import com.orm.androrm.DatabaseAdapter;
import com.orm.androrm.Model;
import com.orm.androrm.impl.migration.EmptyModel;
import com.orm.androrm.impl.migration.ModelWithRelation;
import com.orm.androrm.impl.migration.OneFieldModel;
package com.orm.androrm.test.migration;
public class MigrationHelperTest extends AbstractMigrationTest {
@Override
public void setUp() {
List<Class<? extends Model>> models = new ArrayList<Class<? extends Model>>();
models.add(EmptyModel.class);
models.add(OneFieldModel.class); | models.add(ModelWithRelation.class); |
androrm/androrm | test/src/com/orm/androrm/test/definition/TableDefinitionTest.java | // Path: src/src/com/orm/androrm/field/IntegerField.java
// public class IntegerField extends DataField<Integer> {
//
// /**
// * Initializes a new {@link IntegerField} with default
// * value 0.
// */
// public IntegerField() {
// mType = "integer";
// mValue = 0;
// }
//
// /**
// * Initializes a new {@link IntegerField} with default
// * value 0 and sets the maximum length to maxLength if
// * it is greater than 0 and less than or equal to 16.
// *
// * @param maxLength Maximum length of this field.
// */
// public IntegerField(int maxLength) {
// mType = "integer";
//
// if(maxLength > 0
// && maxLength <= 16) {
//
// mMaxLength = maxLength;
// }
// }
//
// @Override
// public void putData(String key, ContentValues values) {
// values.put(key, get());
// }
//
// @Override
// public void set(Cursor c, String fieldName) {
// set(c.getInt(c.getColumnIndexOrThrow(fieldName)));
// }
//
// @Override
// public void reset() {
// mValue = 0;
// }
//
// }
//
// Path: test/src/com/orm/androrm/impl/Product.java
// public class Product extends Model {
//
// public static final QuerySet<Product> objects(Context context) {
// return objects(context, Product.class);
// }
//
// protected CharField mName;
// protected ManyToManyField<Product, Branch> mBranches;
//
// public Product() {
// super();
//
// mName = new CharField(50);
// mBranches = new ManyToManyField<Product, Branch>(Product.class, Branch.class);
// }
//
// public void setName(String name) {
// mName.set(name);
// }
//
// public String getName() {
// return mName.get();
// }
//
// public void addBranch(Branch branch) {
// mBranches.add(branch);
// }
//
// public void addBranches(List<Branch> branches) {
// mBranches.addAll(branches);
// }
//
// public QuerySet<Branch> getBranches(Context context) {
// return mBranches.get(context, this);
// }
//
// public int branchCount(Context context) {
// return mBranches.get(context, this).count();
// }
//
// }
| import java.util.List;
import android.test.AndroidTestCase;
import com.orm.androrm.Model;
import com.orm.androrm.TableDefinition;
import com.orm.androrm.field.ForeignKeyField;
import com.orm.androrm.field.IntegerField;
import com.orm.androrm.impl.Product; | package com.orm.androrm.test.definition;
public class TableDefinitionTest extends AndroidTestCase {
public void testTableName() {
TableDefinition def = new TableDefinition("foo");
assertEquals("foo", def.getTableName());
assertEquals("CREATE TABLE IF NOT EXISTS `foo` ();", def.toString());
}
public void testAddSimpleField() {
TableDefinition def = new TableDefinition("foo"); | // Path: src/src/com/orm/androrm/field/IntegerField.java
// public class IntegerField extends DataField<Integer> {
//
// /**
// * Initializes a new {@link IntegerField} with default
// * value 0.
// */
// public IntegerField() {
// mType = "integer";
// mValue = 0;
// }
//
// /**
// * Initializes a new {@link IntegerField} with default
// * value 0 and sets the maximum length to maxLength if
// * it is greater than 0 and less than or equal to 16.
// *
// * @param maxLength Maximum length of this field.
// */
// public IntegerField(int maxLength) {
// mType = "integer";
//
// if(maxLength > 0
// && maxLength <= 16) {
//
// mMaxLength = maxLength;
// }
// }
//
// @Override
// public void putData(String key, ContentValues values) {
// values.put(key, get());
// }
//
// @Override
// public void set(Cursor c, String fieldName) {
// set(c.getInt(c.getColumnIndexOrThrow(fieldName)));
// }
//
// @Override
// public void reset() {
// mValue = 0;
// }
//
// }
//
// Path: test/src/com/orm/androrm/impl/Product.java
// public class Product extends Model {
//
// public static final QuerySet<Product> objects(Context context) {
// return objects(context, Product.class);
// }
//
// protected CharField mName;
// protected ManyToManyField<Product, Branch> mBranches;
//
// public Product() {
// super();
//
// mName = new CharField(50);
// mBranches = new ManyToManyField<Product, Branch>(Product.class, Branch.class);
// }
//
// public void setName(String name) {
// mName.set(name);
// }
//
// public String getName() {
// return mName.get();
// }
//
// public void addBranch(Branch branch) {
// mBranches.add(branch);
// }
//
// public void addBranches(List<Branch> branches) {
// mBranches.addAll(branches);
// }
//
// public QuerySet<Branch> getBranches(Context context) {
// return mBranches.get(context, this);
// }
//
// public int branchCount(Context context) {
// return mBranches.get(context, this).count();
// }
//
// }
// Path: test/src/com/orm/androrm/test/definition/TableDefinitionTest.java
import java.util.List;
import android.test.AndroidTestCase;
import com.orm.androrm.Model;
import com.orm.androrm.TableDefinition;
import com.orm.androrm.field.ForeignKeyField;
import com.orm.androrm.field.IntegerField;
import com.orm.androrm.impl.Product;
package com.orm.androrm.test.definition;
public class TableDefinitionTest extends AndroidTestCase {
public void testTableName() {
TableDefinition def = new TableDefinition("foo");
assertEquals("foo", def.getTableName());
assertEquals("CREATE TABLE IF NOT EXISTS `foo` ();", def.toString());
}
public void testAddSimpleField() {
TableDefinition def = new TableDefinition("foo"); | IntegerField i = new IntegerField(); |
androrm/androrm | test/src/com/orm/androrm/test/definition/TableDefinitionTest.java | // Path: src/src/com/orm/androrm/field/IntegerField.java
// public class IntegerField extends DataField<Integer> {
//
// /**
// * Initializes a new {@link IntegerField} with default
// * value 0.
// */
// public IntegerField() {
// mType = "integer";
// mValue = 0;
// }
//
// /**
// * Initializes a new {@link IntegerField} with default
// * value 0 and sets the maximum length to maxLength if
// * it is greater than 0 and less than or equal to 16.
// *
// * @param maxLength Maximum length of this field.
// */
// public IntegerField(int maxLength) {
// mType = "integer";
//
// if(maxLength > 0
// && maxLength <= 16) {
//
// mMaxLength = maxLength;
// }
// }
//
// @Override
// public void putData(String key, ContentValues values) {
// values.put(key, get());
// }
//
// @Override
// public void set(Cursor c, String fieldName) {
// set(c.getInt(c.getColumnIndexOrThrow(fieldName)));
// }
//
// @Override
// public void reset() {
// mValue = 0;
// }
//
// }
//
// Path: test/src/com/orm/androrm/impl/Product.java
// public class Product extends Model {
//
// public static final QuerySet<Product> objects(Context context) {
// return objects(context, Product.class);
// }
//
// protected CharField mName;
// protected ManyToManyField<Product, Branch> mBranches;
//
// public Product() {
// super();
//
// mName = new CharField(50);
// mBranches = new ManyToManyField<Product, Branch>(Product.class, Branch.class);
// }
//
// public void setName(String name) {
// mName.set(name);
// }
//
// public String getName() {
// return mName.get();
// }
//
// public void addBranch(Branch branch) {
// mBranches.add(branch);
// }
//
// public void addBranches(List<Branch> branches) {
// mBranches.addAll(branches);
// }
//
// public QuerySet<Branch> getBranches(Context context) {
// return mBranches.get(context, this);
// }
//
// public int branchCount(Context context) {
// return mBranches.get(context, this).count();
// }
//
// }
| import java.util.List;
import android.test.AndroidTestCase;
import com.orm.androrm.Model;
import com.orm.androrm.TableDefinition;
import com.orm.androrm.field.ForeignKeyField;
import com.orm.androrm.field.IntegerField;
import com.orm.androrm.impl.Product; | package com.orm.androrm.test.definition;
public class TableDefinitionTest extends AndroidTestCase {
public void testTableName() {
TableDefinition def = new TableDefinition("foo");
assertEquals("foo", def.getTableName());
assertEquals("CREATE TABLE IF NOT EXISTS `foo` ();", def.toString());
}
public void testAddSimpleField() {
TableDefinition def = new TableDefinition("foo");
IntegerField i = new IntegerField();
def.addField("pk", i);
assertEquals("CREATE TABLE IF NOT EXISTS `foo` (`pk` integer);", def.toString());
}
public void testForeignKeyField() {
TableDefinition def = new TableDefinition("foo"); | // Path: src/src/com/orm/androrm/field/IntegerField.java
// public class IntegerField extends DataField<Integer> {
//
// /**
// * Initializes a new {@link IntegerField} with default
// * value 0.
// */
// public IntegerField() {
// mType = "integer";
// mValue = 0;
// }
//
// /**
// * Initializes a new {@link IntegerField} with default
// * value 0 and sets the maximum length to maxLength if
// * it is greater than 0 and less than or equal to 16.
// *
// * @param maxLength Maximum length of this field.
// */
// public IntegerField(int maxLength) {
// mType = "integer";
//
// if(maxLength > 0
// && maxLength <= 16) {
//
// mMaxLength = maxLength;
// }
// }
//
// @Override
// public void putData(String key, ContentValues values) {
// values.put(key, get());
// }
//
// @Override
// public void set(Cursor c, String fieldName) {
// set(c.getInt(c.getColumnIndexOrThrow(fieldName)));
// }
//
// @Override
// public void reset() {
// mValue = 0;
// }
//
// }
//
// Path: test/src/com/orm/androrm/impl/Product.java
// public class Product extends Model {
//
// public static final QuerySet<Product> objects(Context context) {
// return objects(context, Product.class);
// }
//
// protected CharField mName;
// protected ManyToManyField<Product, Branch> mBranches;
//
// public Product() {
// super();
//
// mName = new CharField(50);
// mBranches = new ManyToManyField<Product, Branch>(Product.class, Branch.class);
// }
//
// public void setName(String name) {
// mName.set(name);
// }
//
// public String getName() {
// return mName.get();
// }
//
// public void addBranch(Branch branch) {
// mBranches.add(branch);
// }
//
// public void addBranches(List<Branch> branches) {
// mBranches.addAll(branches);
// }
//
// public QuerySet<Branch> getBranches(Context context) {
// return mBranches.get(context, this);
// }
//
// public int branchCount(Context context) {
// return mBranches.get(context, this).count();
// }
//
// }
// Path: test/src/com/orm/androrm/test/definition/TableDefinitionTest.java
import java.util.List;
import android.test.AndroidTestCase;
import com.orm.androrm.Model;
import com.orm.androrm.TableDefinition;
import com.orm.androrm.field.ForeignKeyField;
import com.orm.androrm.field.IntegerField;
import com.orm.androrm.impl.Product;
package com.orm.androrm.test.definition;
public class TableDefinitionTest extends AndroidTestCase {
public void testTableName() {
TableDefinition def = new TableDefinition("foo");
assertEquals("foo", def.getTableName());
assertEquals("CREATE TABLE IF NOT EXISTS `foo` ();", def.toString());
}
public void testAddSimpleField() {
TableDefinition def = new TableDefinition("foo");
IntegerField i = new IntegerField();
def.addField("pk", i);
assertEquals("CREATE TABLE IF NOT EXISTS `foo` (`pk` integer);", def.toString());
}
public void testForeignKeyField() {
TableDefinition def = new TableDefinition("foo"); | ForeignKeyField<Product> fk = new ForeignKeyField<Product>(Product.class); |
androrm/androrm | test/src/com/orm/androrm/test/statement/LimitTest.java | // Path: src/src/com/orm/androrm/Limit.java
// public class Limit {
// /**
// * Start offset.
// */
// private int mOffset;
// /**
// * Number of items to fetch.
// */
// private int mLimit;
//
// public Limit() {
// mLimit = 0;
// mOffset = 0;
// }
//
// public Limit(int limit) {
// mLimit = limit;
// mOffset = 0;
// }
//
// public Limit(int offset, int limit) {
// mOffset = offset;
// mLimit = limit;
// }
//
// /**
// * The computed limit is the offset plus the number of items, that
// * shall be fetched. These numbers are handed to the database.
// *
// * @return The computed limit for the query.
// */
// public int getComputedLimit() {
// return mOffset + mLimit;
// }
//
// /**
// * @return The offset to start.
// */
// public int getOffset() {
// return mOffset;
// }
//
// /**
// * The raw limit is simply the count of objects that shall be fetched.
// *
// * @return The raw limit.
// */
// public int getRawLimit() {
// return mLimit;
// }
//
// @Override
// public String toString() {
// if(mLimit != 0) {
//
// if(mOffset == 0) {
// return " LIMIT " + String.valueOf(mLimit);
// }
//
// return " LIMIT " + mOffset + " , " + (mOffset + mLimit);
// }
//
// return null;
// }
// }
| import android.test.AndroidTestCase;
import com.orm.androrm.Limit;
| /**
*
*/
package com.orm.androrm.test.statement;
/**
* @author Philipp Giese
*/
public class LimitTest extends AndroidTestCase {
public void testLimitOnly() {
| // Path: src/src/com/orm/androrm/Limit.java
// public class Limit {
// /**
// * Start offset.
// */
// private int mOffset;
// /**
// * Number of items to fetch.
// */
// private int mLimit;
//
// public Limit() {
// mLimit = 0;
// mOffset = 0;
// }
//
// public Limit(int limit) {
// mLimit = limit;
// mOffset = 0;
// }
//
// public Limit(int offset, int limit) {
// mOffset = offset;
// mLimit = limit;
// }
//
// /**
// * The computed limit is the offset plus the number of items, that
// * shall be fetched. These numbers are handed to the database.
// *
// * @return The computed limit for the query.
// */
// public int getComputedLimit() {
// return mOffset + mLimit;
// }
//
// /**
// * @return The offset to start.
// */
// public int getOffset() {
// return mOffset;
// }
//
// /**
// * The raw limit is simply the count of objects that shall be fetched.
// *
// * @return The raw limit.
// */
// public int getRawLimit() {
// return mLimit;
// }
//
// @Override
// public String toString() {
// if(mLimit != 0) {
//
// if(mOffset == 0) {
// return " LIMIT " + String.valueOf(mLimit);
// }
//
// return " LIMIT " + mOffset + " , " + (mOffset + mLimit);
// }
//
// return null;
// }
// }
// Path: test/src/com/orm/androrm/test/statement/LimitTest.java
import android.test.AndroidTestCase;
import com.orm.androrm.Limit;
/**
*
*/
package com.orm.androrm.test.statement;
/**
* @author Philipp Giese
*/
public class LimitTest extends AndroidTestCase {
public void testLimitOnly() {
| Limit limit = new Limit(2);
|
androrm/androrm | test/src/com/orm/androrm/test/database/TransactionTest.java | // Path: test/src/com/orm/androrm/impl/BlankModel.java
// public class BlankModel extends Model {
//
// public static final QuerySet<BlankModel> objects(Context context) {
// return objects(context, BlankModel.class);
// }
//
// protected CharField mName;
// protected LocationField mLocation;
// protected DateField mDate;
//
// public BlankModel() {
// super();
//
// mName = new CharField();
// mLocation = new LocationField();
// mDate = new DateField();
// }
//
// public void setName(String name) {
// mName.set(name);
// }
//
// public String getName() {
// return mName.get();
// }
//
// public void setLocation(Location l) {
// mLocation.set(l);
// }
//
// public Location getLocation() {
// return mLocation.get();
// }
//
// public Date getDate() {
// return mDate.get();
// }
//
// public void setDate(Date date) {
// mDate.set(date);
// }
// }
| import java.util.ArrayList;
import java.util.List;
import com.orm.androrm.DatabaseAdapter;
import com.orm.androrm.Model;
import com.orm.androrm.impl.BlankModel;
import android.test.AndroidTestCase; | package com.orm.androrm.test.database;
public class TransactionTest extends AndroidTestCase {
@Override
public void setUp() {
List<Class<? extends Model>> models = new ArrayList<Class<? extends Model>>(); | // Path: test/src/com/orm/androrm/impl/BlankModel.java
// public class BlankModel extends Model {
//
// public static final QuerySet<BlankModel> objects(Context context) {
// return objects(context, BlankModel.class);
// }
//
// protected CharField mName;
// protected LocationField mLocation;
// protected DateField mDate;
//
// public BlankModel() {
// super();
//
// mName = new CharField();
// mLocation = new LocationField();
// mDate = new DateField();
// }
//
// public void setName(String name) {
// mName.set(name);
// }
//
// public String getName() {
// return mName.get();
// }
//
// public void setLocation(Location l) {
// mLocation.set(l);
// }
//
// public Location getLocation() {
// return mLocation.get();
// }
//
// public Date getDate() {
// return mDate.get();
// }
//
// public void setDate(Date date) {
// mDate.set(date);
// }
// }
// Path: test/src/com/orm/androrm/test/database/TransactionTest.java
import java.util.ArrayList;
import java.util.List;
import com.orm.androrm.DatabaseAdapter;
import com.orm.androrm.Model;
import com.orm.androrm.impl.BlankModel;
import android.test.AndroidTestCase;
package com.orm.androrm.test.database;
public class TransactionTest extends AndroidTestCase {
@Override
public void setUp() {
List<Class<? extends Model>> models = new ArrayList<Class<? extends Model>>(); | models.add(BlankModel.class); |
androrm/androrm | src/src/com/orm/androrm/Rule.java | // Path: src/src/com/orm/androrm/statement/Statement.java
// public class Statement {
//
// /**
// * Key of the statement.
// */
// protected String mKey;
// /**
// * Key of the statement.
// */
// protected String mOperator;
// /**
// * Value of the statement.
// */
// protected String mValue;
//
// /**
// * Empty constructor.
// */
// public Statement() {}
//
// public Statement(String key, int value) {
// mKey = key;
// mOperator = "=";
// mValue = String.valueOf(value);
// }
//
// public Statement(String key, String operator, int value) {
// mKey = key;
// mOperator = operator;
// mValue = String.valueOf(value);
// }
//
// /**
// * This constructor sets the key and value field of this
// * statement.
// *
// * @param key Database column.
// * @param value Expected value of this column.
// */
// public Statement(String key, String value) {
// mKey = key;
// mOperator = "=";
// mValue = value;
// }
//
// public Statement(String key, String operator, String value) {
// mKey = key;
// mOperator = operator;
// mValue = value;
// }
//
// /**
// * Get all keys that are used in this statement.
// *
// * @return All keys i.e. the affected database columns.
// */
// public Set<String> getKeys() {
// Set<String> keys = new HashSet<String>();
// keys.add(mKey);
//
// return keys;
// }
//
// public void setKey(String key) {
// mKey = key;
// }
//
// @Override
// public String toString() {
// return mKey + " " + mOperator + " '" + mValue + "'";
// }
// }
| import com.orm.androrm.statement.Statement; | /**
* Copyright (c) 2010 Philipp Giese
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package com.orm.androrm;
/**
* A {@link Rule} is used by {@link Filter Filter Sets}
* to create complex queries on the database. Each filter consists
* of a certain key leading to the field is applied to and
* the {@link Statement}, that will be used for the query.
*
* @author Philipp Giese
*/
public class Rule {
/**
* The key leads to the field this filter
* is applied on. This can be the plain name
* of a field like "mName" or a series of
* field names like "mSupplier__mBranches__mName".
*/
private String mKey;
/**
* The statement of a field is only valid for the
* last field name in {@link Rule#mKey}.
*/ | // Path: src/src/com/orm/androrm/statement/Statement.java
// public class Statement {
//
// /**
// * Key of the statement.
// */
// protected String mKey;
// /**
// * Key of the statement.
// */
// protected String mOperator;
// /**
// * Value of the statement.
// */
// protected String mValue;
//
// /**
// * Empty constructor.
// */
// public Statement() {}
//
// public Statement(String key, int value) {
// mKey = key;
// mOperator = "=";
// mValue = String.valueOf(value);
// }
//
// public Statement(String key, String operator, int value) {
// mKey = key;
// mOperator = operator;
// mValue = String.valueOf(value);
// }
//
// /**
// * This constructor sets the key and value field of this
// * statement.
// *
// * @param key Database column.
// * @param value Expected value of this column.
// */
// public Statement(String key, String value) {
// mKey = key;
// mOperator = "=";
// mValue = value;
// }
//
// public Statement(String key, String operator, String value) {
// mKey = key;
// mOperator = operator;
// mValue = value;
// }
//
// /**
// * Get all keys that are used in this statement.
// *
// * @return All keys i.e. the affected database columns.
// */
// public Set<String> getKeys() {
// Set<String> keys = new HashSet<String>();
// keys.add(mKey);
//
// return keys;
// }
//
// public void setKey(String key) {
// mKey = key;
// }
//
// @Override
// public String toString() {
// return mKey + " " + mOperator + " '" + mValue + "'";
// }
// }
// Path: src/src/com/orm/androrm/Rule.java
import com.orm.androrm.statement.Statement;
/**
* Copyright (c) 2010 Philipp Giese
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package com.orm.androrm;
/**
* A {@link Rule} is used by {@link Filter Filter Sets}
* to create complex queries on the database. Each filter consists
* of a certain key leading to the field is applied to and
* the {@link Statement}, that will be used for the query.
*
* @author Philipp Giese
*/
public class Rule {
/**
* The key leads to the field this filter
* is applied on. This can be the plain name
* of a field like "mName" or a series of
* field names like "mSupplier__mBranches__mName".
*/
private String mKey;
/**
* The statement of a field is only valid for the
* last field name in {@link Rule#mKey}.
*/ | private Statement mStatement; |
androrm/androrm | test/src/com/orm/androrm/test/statement/StatementTest.java | // Path: src/src/com/orm/androrm/statement/Statement.java
// public class Statement {
//
// /**
// * Key of the statement.
// */
// protected String mKey;
// /**
// * Key of the statement.
// */
// protected String mOperator;
// /**
// * Value of the statement.
// */
// protected String mValue;
//
// /**
// * Empty constructor.
// */
// public Statement() {}
//
// public Statement(String key, int value) {
// mKey = key;
// mOperator = "=";
// mValue = String.valueOf(value);
// }
//
// public Statement(String key, String operator, int value) {
// mKey = key;
// mOperator = operator;
// mValue = String.valueOf(value);
// }
//
// /**
// * This constructor sets the key and value field of this
// * statement.
// *
// * @param key Database column.
// * @param value Expected value of this column.
// */
// public Statement(String key, String value) {
// mKey = key;
// mOperator = "=";
// mValue = value;
// }
//
// public Statement(String key, String operator, String value) {
// mKey = key;
// mOperator = operator;
// mValue = value;
// }
//
// /**
// * Get all keys that are used in this statement.
// *
// * @return All keys i.e. the affected database columns.
// */
// public Set<String> getKeys() {
// Set<String> keys = new HashSet<String>();
// keys.add(mKey);
//
// return keys;
// }
//
// public void setKey(String key) {
// mKey = key;
// }
//
// @Override
// public String toString() {
// return mKey + " " + mOperator + " '" + mValue + "'";
// }
// }
| import java.util.Set;
import android.test.AndroidTestCase;
import com.orm.androrm.statement.Statement;
| package com.orm.androrm.test.statement;
public class StatementTest extends AndroidTestCase {
public void testPlainStatement() {
| // Path: src/src/com/orm/androrm/statement/Statement.java
// public class Statement {
//
// /**
// * Key of the statement.
// */
// protected String mKey;
// /**
// * Key of the statement.
// */
// protected String mOperator;
// /**
// * Value of the statement.
// */
// protected String mValue;
//
// /**
// * Empty constructor.
// */
// public Statement() {}
//
// public Statement(String key, int value) {
// mKey = key;
// mOperator = "=";
// mValue = String.valueOf(value);
// }
//
// public Statement(String key, String operator, int value) {
// mKey = key;
// mOperator = operator;
// mValue = String.valueOf(value);
// }
//
// /**
// * This constructor sets the key and value field of this
// * statement.
// *
// * @param key Database column.
// * @param value Expected value of this column.
// */
// public Statement(String key, String value) {
// mKey = key;
// mOperator = "=";
// mValue = value;
// }
//
// public Statement(String key, String operator, String value) {
// mKey = key;
// mOperator = operator;
// mValue = value;
// }
//
// /**
// * Get all keys that are used in this statement.
// *
// * @return All keys i.e. the affected database columns.
// */
// public Set<String> getKeys() {
// Set<String> keys = new HashSet<String>();
// keys.add(mKey);
//
// return keys;
// }
//
// public void setKey(String key) {
// mKey = key;
// }
//
// @Override
// public String toString() {
// return mKey + " " + mOperator + " '" + mValue + "'";
// }
// }
// Path: test/src/com/orm/androrm/test/statement/StatementTest.java
import java.util.Set;
import android.test.AndroidTestCase;
import com.orm.androrm.statement.Statement;
package com.orm.androrm.test.statement;
public class StatementTest extends AndroidTestCase {
public void testPlainStatement() {
| Statement stmt = new Statement("foo", "bar");
|
androrm/androrm | src/src/com/orm/androrm/Where.java | // Path: src/src/com/orm/androrm/statement/AndStatement.java
// public class AndStatement extends ComposedStatement{
//
// /**
// * Use this constructor to initialize a new AND
// * statement. The left {@link Statement} and the
// * right {@link Statement} will be separated by
// * the keyword AND.
// *
// * @param left
// * @param right
// */
// public AndStatement(Statement left, Statement right) {
// super(left, right);
//
// mSeparator = " AND ";
// }
// }
//
// Path: src/src/com/orm/androrm/statement/Statement.java
// public class Statement {
//
// /**
// * Key of the statement.
// */
// protected String mKey;
// /**
// * Key of the statement.
// */
// protected String mOperator;
// /**
// * Value of the statement.
// */
// protected String mValue;
//
// /**
// * Empty constructor.
// */
// public Statement() {}
//
// public Statement(String key, int value) {
// mKey = key;
// mOperator = "=";
// mValue = String.valueOf(value);
// }
//
// public Statement(String key, String operator, int value) {
// mKey = key;
// mOperator = operator;
// mValue = String.valueOf(value);
// }
//
// /**
// * This constructor sets the key and value field of this
// * statement.
// *
// * @param key Database column.
// * @param value Expected value of this column.
// */
// public Statement(String key, String value) {
// mKey = key;
// mOperator = "=";
// mValue = value;
// }
//
// public Statement(String key, String operator, String value) {
// mKey = key;
// mOperator = operator;
// mValue = value;
// }
//
// /**
// * Get all keys that are used in this statement.
// *
// * @return All keys i.e. the affected database columns.
// */
// public Set<String> getKeys() {
// Set<String> keys = new HashSet<String>();
// keys.add(mKey);
//
// return keys;
// }
//
// public void setKey(String key) {
// mKey = key;
// }
//
// @Override
// public String toString() {
// return mKey + " " + mOperator + " '" + mValue + "'";
// }
// }
| import java.util.HashSet;
import java.util.Set;
import com.orm.androrm.statement.AndStatement;
import com.orm.androrm.statement.OrStatement;
import com.orm.androrm.statement.Statement;
import android.database.sqlite.SQLiteDatabase;
| /**
* Copyright (c) 2010 Philipp Giese
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package com.orm.androrm;
/**
* Class representing the WHERE clause of the database.
* <br /><br />
* NOTE THAT THIS CLASS WORKS ACCORDING TO THE RULES DEFINED
* BY THE query FUNCTION OF {@link SQLiteDatabase}.
*
* @author Philipp Giese
*/
public class Where {
/**
* All constraints that shall be applied.
*/
private Statement mStatement;
/**
* Used for quick look up, if the where clause has a certain constraint for
* a given key.
*/
private Set<String> mKeys;
public Where() {
mKeys = new HashSet<String>();
}
/**
* Attaches the given {@link Statement} as the right side of the
* AND statement.
*
* @param stmt {@link Statement} to attach.
* @return <code>this</code> for chaining.
*/
public Where and(Statement stmt) {
mKeys.addAll(stmt.getKeys());
if(mStatement == null) {
mStatement = stmt;
} else {
| // Path: src/src/com/orm/androrm/statement/AndStatement.java
// public class AndStatement extends ComposedStatement{
//
// /**
// * Use this constructor to initialize a new AND
// * statement. The left {@link Statement} and the
// * right {@link Statement} will be separated by
// * the keyword AND.
// *
// * @param left
// * @param right
// */
// public AndStatement(Statement left, Statement right) {
// super(left, right);
//
// mSeparator = " AND ";
// }
// }
//
// Path: src/src/com/orm/androrm/statement/Statement.java
// public class Statement {
//
// /**
// * Key of the statement.
// */
// protected String mKey;
// /**
// * Key of the statement.
// */
// protected String mOperator;
// /**
// * Value of the statement.
// */
// protected String mValue;
//
// /**
// * Empty constructor.
// */
// public Statement() {}
//
// public Statement(String key, int value) {
// mKey = key;
// mOperator = "=";
// mValue = String.valueOf(value);
// }
//
// public Statement(String key, String operator, int value) {
// mKey = key;
// mOperator = operator;
// mValue = String.valueOf(value);
// }
//
// /**
// * This constructor sets the key and value field of this
// * statement.
// *
// * @param key Database column.
// * @param value Expected value of this column.
// */
// public Statement(String key, String value) {
// mKey = key;
// mOperator = "=";
// mValue = value;
// }
//
// public Statement(String key, String operator, String value) {
// mKey = key;
// mOperator = operator;
// mValue = value;
// }
//
// /**
// * Get all keys that are used in this statement.
// *
// * @return All keys i.e. the affected database columns.
// */
// public Set<String> getKeys() {
// Set<String> keys = new HashSet<String>();
// keys.add(mKey);
//
// return keys;
// }
//
// public void setKey(String key) {
// mKey = key;
// }
//
// @Override
// public String toString() {
// return mKey + " " + mOperator + " '" + mValue + "'";
// }
// }
// Path: src/src/com/orm/androrm/Where.java
import java.util.HashSet;
import java.util.Set;
import com.orm.androrm.statement.AndStatement;
import com.orm.androrm.statement.OrStatement;
import com.orm.androrm.statement.Statement;
import android.database.sqlite.SQLiteDatabase;
/**
* Copyright (c) 2010 Philipp Giese
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package com.orm.androrm;
/**
* Class representing the WHERE clause of the database.
* <br /><br />
* NOTE THAT THIS CLASS WORKS ACCORDING TO THE RULES DEFINED
* BY THE query FUNCTION OF {@link SQLiteDatabase}.
*
* @author Philipp Giese
*/
public class Where {
/**
* All constraints that shall be applied.
*/
private Statement mStatement;
/**
* Used for quick look up, if the where clause has a certain constraint for
* a given key.
*/
private Set<String> mKeys;
public Where() {
mKeys = new HashSet<String>();
}
/**
* Attaches the given {@link Statement} as the right side of the
* AND statement.
*
* @param stmt {@link Statement} to attach.
* @return <code>this</code> for chaining.
*/
public Where and(Statement stmt) {
mKeys.addAll(stmt.getKeys());
if(mStatement == null) {
mStatement = stmt;
} else {
| mStatement = new AndStatement(mStatement, stmt);
|
androrm/androrm | test/src/com/orm/androrm/test/field/DateFieldTest.java | // Path: src/src/com/orm/androrm/field/DateField.java
// public class DateField extends DataField<Date> {
//
// /**
// * Initializes this field. Note, that dates will be
// * stored as strings into the database. Therefore
// * the database type of this field is <b>varchar</b>
// * and it's length is set to 19 characters, as this
// * is the exact length of the date string.
// */
// public DateField() {
// mType = "varchar";
// mMaxLength = 19;
// }
//
// /**
// * Constructs a {@link Date} object from the given string. <br />
// * The String must be in the format: YYYY-MM-DDTHH:MM:SS.
// *
// * @param date String representing the date.
// */
// public void fromString(String date) {
// Pattern pattern = Pattern.compile("(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2}):(\\d{2})");
//
// if(date != null) {
// Matcher matcher = pattern.matcher(date);
//
// if(matcher.matches()) {
// int year = Integer.valueOf(matcher.group(1));
// int month = Integer.valueOf(matcher.group(2)) - 1;
// int day = Integer.valueOf(matcher.group(3));
// int hour = Integer.valueOf(matcher.group(4));
// int minute = Integer.valueOf(matcher.group(5));
// int second = Integer.valueOf(matcher.group(6));
//
// GregorianCalendar cal = new GregorianCalendar(year, month, day, hour, minute, second);
//
// mValue = cal.getTime();
// }
// }
// }
//
// /**
// * Creates the string representation of the date
// * {@link DataField#mValue} is currently set to.
// * <br /><br />
// * Format of that string is:<br />
// * YYYY-MM-DDTHH:MM:SS
// *
// * @return String representation of {@link DataField#mValue}.
// */
// public String getDateString() {
// if(mValue != null) {
// Calendar cal = Calendar.getInstance();
// cal.setTime(mValue);
//
// int year = cal.get(Calendar.YEAR);
// int month = cal.get(Calendar.MONTH) + 1;
// int day = cal.get(Calendar.DAY_OF_MONTH);
// int hour = cal.get(Calendar.HOUR_OF_DAY);
// int minute = cal.get(Calendar.MINUTE);
// int second = cal.get(Calendar.SECOND);
//
// String dayString = String.valueOf(day);
// String monthString = String.valueOf(month);
// String hourString = String.valueOf(hour);
// String minuteString = String.valueOf(minute);
// String secondString = String.valueOf(second);
//
// if(day < 10) {
// dayString = "0" + dayString;
// }
//
// if(month < 10) {
// monthString = "0" + monthString;
// }
//
// if(hour < 10) {
// hourString = "0" + hourString;
// }
//
// if(minute < 10) {
// minuteString = "0" + minuteString;
// }
//
// if(second < 10) {
// secondString = "0" + secondString;
// }
//
// return year + "-" + monthString + "-" + dayString
// + "T"
// + hourString + ":" + minuteString + ":" + secondString;
// }
//
// return null;
// }
//
// @Override
// public void putData(String key, ContentValues values) {
// values.put(key, getDateString());
// }
//
// @Override
// public void set(Cursor c, String fieldName) {
// fromString(c.getString(c.getColumnIndexOrThrow(fieldName)));
// }
//
// @Override
// public void reset() {
// mValue = null;
// }
// }
//
// Path: test/src/com/orm/androrm/impl/BlankModel.java
// public class BlankModel extends Model {
//
// public static final QuerySet<BlankModel> objects(Context context) {
// return objects(context, BlankModel.class);
// }
//
// protected CharField mName;
// protected LocationField mLocation;
// protected DateField mDate;
//
// public BlankModel() {
// super();
//
// mName = new CharField();
// mLocation = new LocationField();
// mDate = new DateField();
// }
//
// public void setName(String name) {
// mName.set(name);
// }
//
// public String getName() {
// return mName.get();
// }
//
// public void setLocation(Location l) {
// mLocation.set(l);
// }
//
// public Location getLocation() {
// return mLocation.get();
// }
//
// public Date getDate() {
// return mDate.get();
// }
//
// public void setDate(Date date) {
// mDate.set(date);
// }
// }
| import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import android.test.AndroidTestCase;
import com.orm.androrm.DatabaseAdapter;
import com.orm.androrm.Model;
import com.orm.androrm.field.DateField;
import com.orm.androrm.impl.BlankModel; | package com.orm.androrm.test.field;
public class DateFieldTest extends AndroidTestCase {
@Override
public void setUp() {
List<Class<? extends Model>> models = new ArrayList<Class<? extends Model>>(); | // Path: src/src/com/orm/androrm/field/DateField.java
// public class DateField extends DataField<Date> {
//
// /**
// * Initializes this field. Note, that dates will be
// * stored as strings into the database. Therefore
// * the database type of this field is <b>varchar</b>
// * and it's length is set to 19 characters, as this
// * is the exact length of the date string.
// */
// public DateField() {
// mType = "varchar";
// mMaxLength = 19;
// }
//
// /**
// * Constructs a {@link Date} object from the given string. <br />
// * The String must be in the format: YYYY-MM-DDTHH:MM:SS.
// *
// * @param date String representing the date.
// */
// public void fromString(String date) {
// Pattern pattern = Pattern.compile("(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2}):(\\d{2})");
//
// if(date != null) {
// Matcher matcher = pattern.matcher(date);
//
// if(matcher.matches()) {
// int year = Integer.valueOf(matcher.group(1));
// int month = Integer.valueOf(matcher.group(2)) - 1;
// int day = Integer.valueOf(matcher.group(3));
// int hour = Integer.valueOf(matcher.group(4));
// int minute = Integer.valueOf(matcher.group(5));
// int second = Integer.valueOf(matcher.group(6));
//
// GregorianCalendar cal = new GregorianCalendar(year, month, day, hour, minute, second);
//
// mValue = cal.getTime();
// }
// }
// }
//
// /**
// * Creates the string representation of the date
// * {@link DataField#mValue} is currently set to.
// * <br /><br />
// * Format of that string is:<br />
// * YYYY-MM-DDTHH:MM:SS
// *
// * @return String representation of {@link DataField#mValue}.
// */
// public String getDateString() {
// if(mValue != null) {
// Calendar cal = Calendar.getInstance();
// cal.setTime(mValue);
//
// int year = cal.get(Calendar.YEAR);
// int month = cal.get(Calendar.MONTH) + 1;
// int day = cal.get(Calendar.DAY_OF_MONTH);
// int hour = cal.get(Calendar.HOUR_OF_DAY);
// int minute = cal.get(Calendar.MINUTE);
// int second = cal.get(Calendar.SECOND);
//
// String dayString = String.valueOf(day);
// String monthString = String.valueOf(month);
// String hourString = String.valueOf(hour);
// String minuteString = String.valueOf(minute);
// String secondString = String.valueOf(second);
//
// if(day < 10) {
// dayString = "0" + dayString;
// }
//
// if(month < 10) {
// monthString = "0" + monthString;
// }
//
// if(hour < 10) {
// hourString = "0" + hourString;
// }
//
// if(minute < 10) {
// minuteString = "0" + minuteString;
// }
//
// if(second < 10) {
// secondString = "0" + secondString;
// }
//
// return year + "-" + monthString + "-" + dayString
// + "T"
// + hourString + ":" + minuteString + ":" + secondString;
// }
//
// return null;
// }
//
// @Override
// public void putData(String key, ContentValues values) {
// values.put(key, getDateString());
// }
//
// @Override
// public void set(Cursor c, String fieldName) {
// fromString(c.getString(c.getColumnIndexOrThrow(fieldName)));
// }
//
// @Override
// public void reset() {
// mValue = null;
// }
// }
//
// Path: test/src/com/orm/androrm/impl/BlankModel.java
// public class BlankModel extends Model {
//
// public static final QuerySet<BlankModel> objects(Context context) {
// return objects(context, BlankModel.class);
// }
//
// protected CharField mName;
// protected LocationField mLocation;
// protected DateField mDate;
//
// public BlankModel() {
// super();
//
// mName = new CharField();
// mLocation = new LocationField();
// mDate = new DateField();
// }
//
// public void setName(String name) {
// mName.set(name);
// }
//
// public String getName() {
// return mName.get();
// }
//
// public void setLocation(Location l) {
// mLocation.set(l);
// }
//
// public Location getLocation() {
// return mLocation.get();
// }
//
// public Date getDate() {
// return mDate.get();
// }
//
// public void setDate(Date date) {
// mDate.set(date);
// }
// }
// Path: test/src/com/orm/androrm/test/field/DateFieldTest.java
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import android.test.AndroidTestCase;
import com.orm.androrm.DatabaseAdapter;
import com.orm.androrm.Model;
import com.orm.androrm.field.DateField;
import com.orm.androrm.impl.BlankModel;
package com.orm.androrm.test.field;
public class DateFieldTest extends AndroidTestCase {
@Override
public void setUp() {
List<Class<? extends Model>> models = new ArrayList<Class<? extends Model>>(); | models.add(BlankModel.class); |
androrm/androrm | test/src/com/orm/androrm/test/field/DateFieldTest.java | // Path: src/src/com/orm/androrm/field/DateField.java
// public class DateField extends DataField<Date> {
//
// /**
// * Initializes this field. Note, that dates will be
// * stored as strings into the database. Therefore
// * the database type of this field is <b>varchar</b>
// * and it's length is set to 19 characters, as this
// * is the exact length of the date string.
// */
// public DateField() {
// mType = "varchar";
// mMaxLength = 19;
// }
//
// /**
// * Constructs a {@link Date} object from the given string. <br />
// * The String must be in the format: YYYY-MM-DDTHH:MM:SS.
// *
// * @param date String representing the date.
// */
// public void fromString(String date) {
// Pattern pattern = Pattern.compile("(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2}):(\\d{2})");
//
// if(date != null) {
// Matcher matcher = pattern.matcher(date);
//
// if(matcher.matches()) {
// int year = Integer.valueOf(matcher.group(1));
// int month = Integer.valueOf(matcher.group(2)) - 1;
// int day = Integer.valueOf(matcher.group(3));
// int hour = Integer.valueOf(matcher.group(4));
// int minute = Integer.valueOf(matcher.group(5));
// int second = Integer.valueOf(matcher.group(6));
//
// GregorianCalendar cal = new GregorianCalendar(year, month, day, hour, minute, second);
//
// mValue = cal.getTime();
// }
// }
// }
//
// /**
// * Creates the string representation of the date
// * {@link DataField#mValue} is currently set to.
// * <br /><br />
// * Format of that string is:<br />
// * YYYY-MM-DDTHH:MM:SS
// *
// * @return String representation of {@link DataField#mValue}.
// */
// public String getDateString() {
// if(mValue != null) {
// Calendar cal = Calendar.getInstance();
// cal.setTime(mValue);
//
// int year = cal.get(Calendar.YEAR);
// int month = cal.get(Calendar.MONTH) + 1;
// int day = cal.get(Calendar.DAY_OF_MONTH);
// int hour = cal.get(Calendar.HOUR_OF_DAY);
// int minute = cal.get(Calendar.MINUTE);
// int second = cal.get(Calendar.SECOND);
//
// String dayString = String.valueOf(day);
// String monthString = String.valueOf(month);
// String hourString = String.valueOf(hour);
// String minuteString = String.valueOf(minute);
// String secondString = String.valueOf(second);
//
// if(day < 10) {
// dayString = "0" + dayString;
// }
//
// if(month < 10) {
// monthString = "0" + monthString;
// }
//
// if(hour < 10) {
// hourString = "0" + hourString;
// }
//
// if(minute < 10) {
// minuteString = "0" + minuteString;
// }
//
// if(second < 10) {
// secondString = "0" + secondString;
// }
//
// return year + "-" + monthString + "-" + dayString
// + "T"
// + hourString + ":" + minuteString + ":" + secondString;
// }
//
// return null;
// }
//
// @Override
// public void putData(String key, ContentValues values) {
// values.put(key, getDateString());
// }
//
// @Override
// public void set(Cursor c, String fieldName) {
// fromString(c.getString(c.getColumnIndexOrThrow(fieldName)));
// }
//
// @Override
// public void reset() {
// mValue = null;
// }
// }
//
// Path: test/src/com/orm/androrm/impl/BlankModel.java
// public class BlankModel extends Model {
//
// public static final QuerySet<BlankModel> objects(Context context) {
// return objects(context, BlankModel.class);
// }
//
// protected CharField mName;
// protected LocationField mLocation;
// protected DateField mDate;
//
// public BlankModel() {
// super();
//
// mName = new CharField();
// mLocation = new LocationField();
// mDate = new DateField();
// }
//
// public void setName(String name) {
// mName.set(name);
// }
//
// public String getName() {
// return mName.get();
// }
//
// public void setLocation(Location l) {
// mLocation.set(l);
// }
//
// public Location getLocation() {
// return mLocation.get();
// }
//
// public Date getDate() {
// return mDate.get();
// }
//
// public void setDate(Date date) {
// mDate.set(date);
// }
// }
| import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import android.test.AndroidTestCase;
import com.orm.androrm.DatabaseAdapter;
import com.orm.androrm.Model;
import com.orm.androrm.field.DateField;
import com.orm.androrm.impl.BlankModel; | package com.orm.androrm.test.field;
public class DateFieldTest extends AndroidTestCase {
@Override
public void setUp() {
List<Class<? extends Model>> models = new ArrayList<Class<? extends Model>>();
models.add(BlankModel.class);
DatabaseAdapter adapter = DatabaseAdapter.getInstance(getContext());
adapter.setModels(models);
}
@Override
public void tearDown() {
DatabaseAdapter adapter = DatabaseAdapter.getInstance(getContext());
adapter.drop();
}
public void testDefaults() { | // Path: src/src/com/orm/androrm/field/DateField.java
// public class DateField extends DataField<Date> {
//
// /**
// * Initializes this field. Note, that dates will be
// * stored as strings into the database. Therefore
// * the database type of this field is <b>varchar</b>
// * and it's length is set to 19 characters, as this
// * is the exact length of the date string.
// */
// public DateField() {
// mType = "varchar";
// mMaxLength = 19;
// }
//
// /**
// * Constructs a {@link Date} object from the given string. <br />
// * The String must be in the format: YYYY-MM-DDTHH:MM:SS.
// *
// * @param date String representing the date.
// */
// public void fromString(String date) {
// Pattern pattern = Pattern.compile("(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2}):(\\d{2})");
//
// if(date != null) {
// Matcher matcher = pattern.matcher(date);
//
// if(matcher.matches()) {
// int year = Integer.valueOf(matcher.group(1));
// int month = Integer.valueOf(matcher.group(2)) - 1;
// int day = Integer.valueOf(matcher.group(3));
// int hour = Integer.valueOf(matcher.group(4));
// int minute = Integer.valueOf(matcher.group(5));
// int second = Integer.valueOf(matcher.group(6));
//
// GregorianCalendar cal = new GregorianCalendar(year, month, day, hour, minute, second);
//
// mValue = cal.getTime();
// }
// }
// }
//
// /**
// * Creates the string representation of the date
// * {@link DataField#mValue} is currently set to.
// * <br /><br />
// * Format of that string is:<br />
// * YYYY-MM-DDTHH:MM:SS
// *
// * @return String representation of {@link DataField#mValue}.
// */
// public String getDateString() {
// if(mValue != null) {
// Calendar cal = Calendar.getInstance();
// cal.setTime(mValue);
//
// int year = cal.get(Calendar.YEAR);
// int month = cal.get(Calendar.MONTH) + 1;
// int day = cal.get(Calendar.DAY_OF_MONTH);
// int hour = cal.get(Calendar.HOUR_OF_DAY);
// int minute = cal.get(Calendar.MINUTE);
// int second = cal.get(Calendar.SECOND);
//
// String dayString = String.valueOf(day);
// String monthString = String.valueOf(month);
// String hourString = String.valueOf(hour);
// String minuteString = String.valueOf(minute);
// String secondString = String.valueOf(second);
//
// if(day < 10) {
// dayString = "0" + dayString;
// }
//
// if(month < 10) {
// monthString = "0" + monthString;
// }
//
// if(hour < 10) {
// hourString = "0" + hourString;
// }
//
// if(minute < 10) {
// minuteString = "0" + minuteString;
// }
//
// if(second < 10) {
// secondString = "0" + secondString;
// }
//
// return year + "-" + monthString + "-" + dayString
// + "T"
// + hourString + ":" + minuteString + ":" + secondString;
// }
//
// return null;
// }
//
// @Override
// public void putData(String key, ContentValues values) {
// values.put(key, getDateString());
// }
//
// @Override
// public void set(Cursor c, String fieldName) {
// fromString(c.getString(c.getColumnIndexOrThrow(fieldName)));
// }
//
// @Override
// public void reset() {
// mValue = null;
// }
// }
//
// Path: test/src/com/orm/androrm/impl/BlankModel.java
// public class BlankModel extends Model {
//
// public static final QuerySet<BlankModel> objects(Context context) {
// return objects(context, BlankModel.class);
// }
//
// protected CharField mName;
// protected LocationField mLocation;
// protected DateField mDate;
//
// public BlankModel() {
// super();
//
// mName = new CharField();
// mLocation = new LocationField();
// mDate = new DateField();
// }
//
// public void setName(String name) {
// mName.set(name);
// }
//
// public String getName() {
// return mName.get();
// }
//
// public void setLocation(Location l) {
// mLocation.set(l);
// }
//
// public Location getLocation() {
// return mLocation.get();
// }
//
// public Date getDate() {
// return mDate.get();
// }
//
// public void setDate(Date date) {
// mDate.set(date);
// }
// }
// Path: test/src/com/orm/androrm/test/field/DateFieldTest.java
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import android.test.AndroidTestCase;
import com.orm.androrm.DatabaseAdapter;
import com.orm.androrm.Model;
import com.orm.androrm.field.DateField;
import com.orm.androrm.impl.BlankModel;
package com.orm.androrm.test.field;
public class DateFieldTest extends AndroidTestCase {
@Override
public void setUp() {
List<Class<? extends Model>> models = new ArrayList<Class<? extends Model>>();
models.add(BlankModel.class);
DatabaseAdapter adapter = DatabaseAdapter.getInstance(getContext());
adapter.setModels(models);
}
@Override
public void tearDown() {
DatabaseAdapter adapter = DatabaseAdapter.getInstance(getContext());
adapter.drop();
}
public void testDefaults() { | DateField d = new DateField(); |
androrm/androrm | test/src/com/orm/androrm/test/statement/WhereTest.java | // Path: src/src/com/orm/androrm/Where.java
// public class Where {
// /**
// * All constraints that shall be applied.
// */
// private Statement mStatement;
// /**
// * Used for quick look up, if the where clause has a certain constraint for
// * a given key.
// */
// private Set<String> mKeys;
//
// public Where() {
// mKeys = new HashSet<String>();
// }
//
// /**
// * Attaches the given {@link Statement} as the right side of the
// * AND statement.
// *
// * @param stmt {@link Statement} to attach.
// * @return <code>this</code> for chaining.
// */
// public Where and(Statement stmt) {
// mKeys.addAll(stmt.getKeys());
//
// if(mStatement == null) {
// mStatement = stmt;
// } else {
// mStatement = new AndStatement(mStatement, stmt);
// }
//
// return this;
// }
//
// /**
// * See {@link Where#and(String, String)}.
// */
// public Where and(String key, int value) {
// return and(key, String.valueOf(value));
// }
//
// /**
// * Adds an AND constraint.
// *
// * @param key Name of the table column.
// * @param value Value of this column.
// */
// public Where and(String key, String value) {
// return and(new Statement(key, value));
// }
//
// /**
// * Checks if there is a constraint for the given column.
// *
// * @param key Column name.
// * @return True if one exists. False otherwise.
// */
// public boolean hasConstraint(String key) {
// return mKeys.contains(key);
// }
//
// /**
// * Attaches the given {@link Statement} as the right side of the
// * OR statement.
// *
// * @param stmt {@link Statement} to attach.
// * @return <code>this</code> for chaining.
// */
// public Where or(Statement stmt) {
// mKeys.addAll(stmt.getKeys());
//
// if(mStatement == null) {
// mStatement = stmt;
// } else {
// mStatement = new OrStatement(mStatement, stmt);
// }
//
// return this;
// }
//
// /**
// * See {@link Where#or(String, String)}.
// */
// public Where or(String key, int value) {
// return or(key, String.valueOf(value));
// }
//
// /**
// * Adds and OR constraint.
// *
// * @param key Name of the table column.
// * @param value Expected value of the column.
// * @return <code>this</code> for chaining.
// */
// public Where or(String key, String value) {
// return or(new Statement(key, value));
// }
//
// /**
// * Overwrite or set the current statement represented by this
// * where clause. In order to create AND or OR statements rather
// * use the respective functions.
// *
// * @param stmt {@link Statement} to apply.
// */
// public void setStatement(Statement stmt) {
// mKeys = stmt.getKeys();
// mStatement = stmt;
// }
//
// public Statement getStatement() {
// return mStatement;
// }
//
// @Override
// public String toString() {
// if(mStatement != null) {
// return " WHERE " + mStatement;
// }
//
// return null;
// }
// }
| import android.test.AndroidTestCase;
import com.orm.androrm.Where;
| /**
*
*/
package com.orm.androrm.test.statement;
/**
* @author Philipp Giese
*/
public class WhereTest extends AndroidTestCase {
public void testEmptyWhere() {
| // Path: src/src/com/orm/androrm/Where.java
// public class Where {
// /**
// * All constraints that shall be applied.
// */
// private Statement mStatement;
// /**
// * Used for quick look up, if the where clause has a certain constraint for
// * a given key.
// */
// private Set<String> mKeys;
//
// public Where() {
// mKeys = new HashSet<String>();
// }
//
// /**
// * Attaches the given {@link Statement} as the right side of the
// * AND statement.
// *
// * @param stmt {@link Statement} to attach.
// * @return <code>this</code> for chaining.
// */
// public Where and(Statement stmt) {
// mKeys.addAll(stmt.getKeys());
//
// if(mStatement == null) {
// mStatement = stmt;
// } else {
// mStatement = new AndStatement(mStatement, stmt);
// }
//
// return this;
// }
//
// /**
// * See {@link Where#and(String, String)}.
// */
// public Where and(String key, int value) {
// return and(key, String.valueOf(value));
// }
//
// /**
// * Adds an AND constraint.
// *
// * @param key Name of the table column.
// * @param value Value of this column.
// */
// public Where and(String key, String value) {
// return and(new Statement(key, value));
// }
//
// /**
// * Checks if there is a constraint for the given column.
// *
// * @param key Column name.
// * @return True if one exists. False otherwise.
// */
// public boolean hasConstraint(String key) {
// return mKeys.contains(key);
// }
//
// /**
// * Attaches the given {@link Statement} as the right side of the
// * OR statement.
// *
// * @param stmt {@link Statement} to attach.
// * @return <code>this</code> for chaining.
// */
// public Where or(Statement stmt) {
// mKeys.addAll(stmt.getKeys());
//
// if(mStatement == null) {
// mStatement = stmt;
// } else {
// mStatement = new OrStatement(mStatement, stmt);
// }
//
// return this;
// }
//
// /**
// * See {@link Where#or(String, String)}.
// */
// public Where or(String key, int value) {
// return or(key, String.valueOf(value));
// }
//
// /**
// * Adds and OR constraint.
// *
// * @param key Name of the table column.
// * @param value Expected value of the column.
// * @return <code>this</code> for chaining.
// */
// public Where or(String key, String value) {
// return or(new Statement(key, value));
// }
//
// /**
// * Overwrite or set the current statement represented by this
// * where clause. In order to create AND or OR statements rather
// * use the respective functions.
// *
// * @param stmt {@link Statement} to apply.
// */
// public void setStatement(Statement stmt) {
// mKeys = stmt.getKeys();
// mStatement = stmt;
// }
//
// public Statement getStatement() {
// return mStatement;
// }
//
// @Override
// public String toString() {
// if(mStatement != null) {
// return " WHERE " + mStatement;
// }
//
// return null;
// }
// }
// Path: test/src/com/orm/androrm/test/statement/WhereTest.java
import android.test.AndroidTestCase;
import com.orm.androrm.Where;
/**
*
*/
package com.orm.androrm.test.statement;
/**
* @author Philipp Giese
*/
public class WhereTest extends AndroidTestCase {
public void testEmptyWhere() {
| Where where = new Where();
|
androrm/androrm | test/src/com/orm/androrm/impl/migration/ModelWithMigration.java | // Path: src/src/com/orm/androrm/field/CharField.java
// public class CharField extends DataField<String> {
//
// /**
// * Initializes a standard field with implicit
// * maximum length of 255 characters.
// */
// public CharField() {
// mType = "varchar";
// }
//
// /**
// * Initializes a field and sets the maximum length,
// * if this value is greater than 0 and less than or equal
// * to 255.
// *
// * @param maxLength Maximum number of characters allowed for this field.
// */
// public CharField(int maxLength) {
// mType = "varchar";
//
// if(maxLength > 0
// && maxLength <= 255) {
//
// mMaxLength = maxLength;
// }
// }
//
// @Override
// public void putData(String key, ContentValues values) {
// values.put(key, get());
// }
//
// @Override
// public void set(Cursor c, String fieldName) {
// set(c.getString(c.getColumnIndexOrThrow(fieldName)));
// }
//
// @Override
// public void reset() {
// mValue = null;
// }
//
// }
//
// Path: src/src/com/orm/androrm/migration/Migrator.java
// public class Migrator<T extends Model> {
//
// private Class<T> mModel;
// private List<Migratable<T>> mMigrations;
//
// public Migrator(Class<T> model) {
// mModel = model;
// mMigrations = new ArrayList<Migratable<T>>();
// }
//
// public void addField(String name, DatabaseField<?> field) {
// AddFieldMigration<T> migration = new AddFieldMigration<T>(name, field);
//
// mMigrations.add(migration);
// }
//
// public <R extends Model> void addField(String name, ManyToManyField<T, R> field) {
// // Tables for M2M relations are created anyway. This stub is only here,
// // so that users aren't confused, if they try to add a M2M field. We let
// // them believe "they" did it :)
// return;
// }
//
// public void renameModel(String old, Class<? extends Model> updated) {
// RenameModelMigration<T> migration = new RenameModelMigration<T>(old);
//
// mMigrations.add(migration);
// }
//
// public void renameRelation(String old, Class<? extends Model> updated) {
// RenameRelationMigration<T> migration = new RenameRelationMigration<T>(old);
//
// mMigrations.add(migration);
// }
//
// public void migrate(Context context) {
// for(Migratable<T> migration : mMigrations) {
// if(migration.execute(context, mModel)) {
// Migration.create(mModel, migration).save(context);
// }
// }
// }
//
// }
| import android.content.Context;
import com.orm.androrm.Model;
import com.orm.androrm.field.CharField;
import com.orm.androrm.migration.Migrator; | package com.orm.androrm.impl.migration;
public class ModelWithMigration extends Model {
public ModelWithMigration() {
super();
}
@Override
protected void migrate(Context context) { | // Path: src/src/com/orm/androrm/field/CharField.java
// public class CharField extends DataField<String> {
//
// /**
// * Initializes a standard field with implicit
// * maximum length of 255 characters.
// */
// public CharField() {
// mType = "varchar";
// }
//
// /**
// * Initializes a field and sets the maximum length,
// * if this value is greater than 0 and less than or equal
// * to 255.
// *
// * @param maxLength Maximum number of characters allowed for this field.
// */
// public CharField(int maxLength) {
// mType = "varchar";
//
// if(maxLength > 0
// && maxLength <= 255) {
//
// mMaxLength = maxLength;
// }
// }
//
// @Override
// public void putData(String key, ContentValues values) {
// values.put(key, get());
// }
//
// @Override
// public void set(Cursor c, String fieldName) {
// set(c.getString(c.getColumnIndexOrThrow(fieldName)));
// }
//
// @Override
// public void reset() {
// mValue = null;
// }
//
// }
//
// Path: src/src/com/orm/androrm/migration/Migrator.java
// public class Migrator<T extends Model> {
//
// private Class<T> mModel;
// private List<Migratable<T>> mMigrations;
//
// public Migrator(Class<T> model) {
// mModel = model;
// mMigrations = new ArrayList<Migratable<T>>();
// }
//
// public void addField(String name, DatabaseField<?> field) {
// AddFieldMigration<T> migration = new AddFieldMigration<T>(name, field);
//
// mMigrations.add(migration);
// }
//
// public <R extends Model> void addField(String name, ManyToManyField<T, R> field) {
// // Tables for M2M relations are created anyway. This stub is only here,
// // so that users aren't confused, if they try to add a M2M field. We let
// // them believe "they" did it :)
// return;
// }
//
// public void renameModel(String old, Class<? extends Model> updated) {
// RenameModelMigration<T> migration = new RenameModelMigration<T>(old);
//
// mMigrations.add(migration);
// }
//
// public void renameRelation(String old, Class<? extends Model> updated) {
// RenameRelationMigration<T> migration = new RenameRelationMigration<T>(old);
//
// mMigrations.add(migration);
// }
//
// public void migrate(Context context) {
// for(Migratable<T> migration : mMigrations) {
// if(migration.execute(context, mModel)) {
// Migration.create(mModel, migration).save(context);
// }
// }
// }
//
// }
// Path: test/src/com/orm/androrm/impl/migration/ModelWithMigration.java
import android.content.Context;
import com.orm.androrm.Model;
import com.orm.androrm.field.CharField;
import com.orm.androrm.migration.Migrator;
package com.orm.androrm.impl.migration;
public class ModelWithMigration extends Model {
public ModelWithMigration() {
super();
}
@Override
protected void migrate(Context context) { | Migrator<ModelWithMigration> migrator = new Migrator<ModelWithMigration>(ModelWithMigration.class); |
androrm/androrm | test/src/com/orm/androrm/impl/migration/ModelWithMigration.java | // Path: src/src/com/orm/androrm/field/CharField.java
// public class CharField extends DataField<String> {
//
// /**
// * Initializes a standard field with implicit
// * maximum length of 255 characters.
// */
// public CharField() {
// mType = "varchar";
// }
//
// /**
// * Initializes a field and sets the maximum length,
// * if this value is greater than 0 and less than or equal
// * to 255.
// *
// * @param maxLength Maximum number of characters allowed for this field.
// */
// public CharField(int maxLength) {
// mType = "varchar";
//
// if(maxLength > 0
// && maxLength <= 255) {
//
// mMaxLength = maxLength;
// }
// }
//
// @Override
// public void putData(String key, ContentValues values) {
// values.put(key, get());
// }
//
// @Override
// public void set(Cursor c, String fieldName) {
// set(c.getString(c.getColumnIndexOrThrow(fieldName)));
// }
//
// @Override
// public void reset() {
// mValue = null;
// }
//
// }
//
// Path: src/src/com/orm/androrm/migration/Migrator.java
// public class Migrator<T extends Model> {
//
// private Class<T> mModel;
// private List<Migratable<T>> mMigrations;
//
// public Migrator(Class<T> model) {
// mModel = model;
// mMigrations = new ArrayList<Migratable<T>>();
// }
//
// public void addField(String name, DatabaseField<?> field) {
// AddFieldMigration<T> migration = new AddFieldMigration<T>(name, field);
//
// mMigrations.add(migration);
// }
//
// public <R extends Model> void addField(String name, ManyToManyField<T, R> field) {
// // Tables for M2M relations are created anyway. This stub is only here,
// // so that users aren't confused, if they try to add a M2M field. We let
// // them believe "they" did it :)
// return;
// }
//
// public void renameModel(String old, Class<? extends Model> updated) {
// RenameModelMigration<T> migration = new RenameModelMigration<T>(old);
//
// mMigrations.add(migration);
// }
//
// public void renameRelation(String old, Class<? extends Model> updated) {
// RenameRelationMigration<T> migration = new RenameRelationMigration<T>(old);
//
// mMigrations.add(migration);
// }
//
// public void migrate(Context context) {
// for(Migratable<T> migration : mMigrations) {
// if(migration.execute(context, mModel)) {
// Migration.create(mModel, migration).save(context);
// }
// }
// }
//
// }
| import android.content.Context;
import com.orm.androrm.Model;
import com.orm.androrm.field.CharField;
import com.orm.androrm.migration.Migrator; | package com.orm.androrm.impl.migration;
public class ModelWithMigration extends Model {
public ModelWithMigration() {
super();
}
@Override
protected void migrate(Context context) {
Migrator<ModelWithMigration> migrator = new Migrator<ModelWithMigration>(ModelWithMigration.class); | // Path: src/src/com/orm/androrm/field/CharField.java
// public class CharField extends DataField<String> {
//
// /**
// * Initializes a standard field with implicit
// * maximum length of 255 characters.
// */
// public CharField() {
// mType = "varchar";
// }
//
// /**
// * Initializes a field and sets the maximum length,
// * if this value is greater than 0 and less than or equal
// * to 255.
// *
// * @param maxLength Maximum number of characters allowed for this field.
// */
// public CharField(int maxLength) {
// mType = "varchar";
//
// if(maxLength > 0
// && maxLength <= 255) {
//
// mMaxLength = maxLength;
// }
// }
//
// @Override
// public void putData(String key, ContentValues values) {
// values.put(key, get());
// }
//
// @Override
// public void set(Cursor c, String fieldName) {
// set(c.getString(c.getColumnIndexOrThrow(fieldName)));
// }
//
// @Override
// public void reset() {
// mValue = null;
// }
//
// }
//
// Path: src/src/com/orm/androrm/migration/Migrator.java
// public class Migrator<T extends Model> {
//
// private Class<T> mModel;
// private List<Migratable<T>> mMigrations;
//
// public Migrator(Class<T> model) {
// mModel = model;
// mMigrations = new ArrayList<Migratable<T>>();
// }
//
// public void addField(String name, DatabaseField<?> field) {
// AddFieldMigration<T> migration = new AddFieldMigration<T>(name, field);
//
// mMigrations.add(migration);
// }
//
// public <R extends Model> void addField(String name, ManyToManyField<T, R> field) {
// // Tables for M2M relations are created anyway. This stub is only here,
// // so that users aren't confused, if they try to add a M2M field. We let
// // them believe "they" did it :)
// return;
// }
//
// public void renameModel(String old, Class<? extends Model> updated) {
// RenameModelMigration<T> migration = new RenameModelMigration<T>(old);
//
// mMigrations.add(migration);
// }
//
// public void renameRelation(String old, Class<? extends Model> updated) {
// RenameRelationMigration<T> migration = new RenameRelationMigration<T>(old);
//
// mMigrations.add(migration);
// }
//
// public void migrate(Context context) {
// for(Migratable<T> migration : mMigrations) {
// if(migration.execute(context, mModel)) {
// Migration.create(mModel, migration).save(context);
// }
// }
// }
//
// }
// Path: test/src/com/orm/androrm/impl/migration/ModelWithMigration.java
import android.content.Context;
import com.orm.androrm.Model;
import com.orm.androrm.field.CharField;
import com.orm.androrm.migration.Migrator;
package com.orm.androrm.impl.migration;
public class ModelWithMigration extends Model {
public ModelWithMigration() {
super();
}
@Override
protected void migrate(Context context) {
Migrator<ModelWithMigration> migrator = new Migrator<ModelWithMigration>(ModelWithMigration.class); | migrator.addField("mTestField", new CharField()); |
androrm/androrm | test/src/com/orm/androrm/test/migration/ForeignKeyMigrationTest.java | // Path: test/src/com/orm/androrm/impl/Product.java
// public class Product extends Model {
//
// public static final QuerySet<Product> objects(Context context) {
// return objects(context, Product.class);
// }
//
// protected CharField mName;
// protected ManyToManyField<Product, Branch> mBranches;
//
// public Product() {
// super();
//
// mName = new CharField(50);
// mBranches = new ManyToManyField<Product, Branch>(Product.class, Branch.class);
// }
//
// public void setName(String name) {
// mName.set(name);
// }
//
// public String getName() {
// return mName.get();
// }
//
// public void addBranch(Branch branch) {
// mBranches.add(branch);
// }
//
// public void addBranches(List<Branch> branches) {
// mBranches.addAll(branches);
// }
//
// public QuerySet<Branch> getBranches(Context context) {
// return mBranches.get(context, this);
// }
//
// public int branchCount(Context context) {
// return mBranches.get(context, this).count();
// }
//
// }
//
// Path: test/src/com/orm/androrm/impl/migration/EmptyModel.java
// public class EmptyModel extends Model {
//
// public static QuerySet<EmptyModel> objects(Context context) {
// return objects(context, EmptyModel.class);
// }
//
// protected ManyToManyField<EmptyModel, NewEmptyModel> mM2M;
//
// public EmptyModel() {
// super();
//
// mM2M = new ManyToManyField<EmptyModel, NewEmptyModel>(EmptyModel.class, NewEmptyModel.class);
// }
//
// }
//
// Path: src/src/com/orm/androrm/migration/Migrator.java
// public class Migrator<T extends Model> {
//
// private Class<T> mModel;
// private List<Migratable<T>> mMigrations;
//
// public Migrator(Class<T> model) {
// mModel = model;
// mMigrations = new ArrayList<Migratable<T>>();
// }
//
// public void addField(String name, DatabaseField<?> field) {
// AddFieldMigration<T> migration = new AddFieldMigration<T>(name, field);
//
// mMigrations.add(migration);
// }
//
// public <R extends Model> void addField(String name, ManyToManyField<T, R> field) {
// // Tables for M2M relations are created anyway. This stub is only here,
// // so that users aren't confused, if they try to add a M2M field. We let
// // them believe "they" did it :)
// return;
// }
//
// public void renameModel(String old, Class<? extends Model> updated) {
// RenameModelMigration<T> migration = new RenameModelMigration<T>(old);
//
// mMigrations.add(migration);
// }
//
// public void renameRelation(String old, Class<? extends Model> updated) {
// RenameRelationMigration<T> migration = new RenameRelationMigration<T>(old);
//
// mMigrations.add(migration);
// }
//
// public void migrate(Context context) {
// for(Migratable<T> migration : mMigrations) {
// if(migration.execute(context, mModel)) {
// Migration.create(mModel, migration).save(context);
// }
// }
// }
//
// }
| import java.util.ArrayList;
import java.util.List;
import com.orm.androrm.DatabaseAdapter;
import com.orm.androrm.Model;
import com.orm.androrm.field.ForeignKeyField;
import com.orm.androrm.impl.Product;
import com.orm.androrm.impl.migration.EmptyModel;
import com.orm.androrm.migration.Migrator; | package com.orm.androrm.test.migration;
public class ForeignKeyMigrationTest extends AbstractMigrationTest {
@Override
public void setUp() {
List<Class<? extends Model>> models = new ArrayList<Class<? extends Model>>(); | // Path: test/src/com/orm/androrm/impl/Product.java
// public class Product extends Model {
//
// public static final QuerySet<Product> objects(Context context) {
// return objects(context, Product.class);
// }
//
// protected CharField mName;
// protected ManyToManyField<Product, Branch> mBranches;
//
// public Product() {
// super();
//
// mName = new CharField(50);
// mBranches = new ManyToManyField<Product, Branch>(Product.class, Branch.class);
// }
//
// public void setName(String name) {
// mName.set(name);
// }
//
// public String getName() {
// return mName.get();
// }
//
// public void addBranch(Branch branch) {
// mBranches.add(branch);
// }
//
// public void addBranches(List<Branch> branches) {
// mBranches.addAll(branches);
// }
//
// public QuerySet<Branch> getBranches(Context context) {
// return mBranches.get(context, this);
// }
//
// public int branchCount(Context context) {
// return mBranches.get(context, this).count();
// }
//
// }
//
// Path: test/src/com/orm/androrm/impl/migration/EmptyModel.java
// public class EmptyModel extends Model {
//
// public static QuerySet<EmptyModel> objects(Context context) {
// return objects(context, EmptyModel.class);
// }
//
// protected ManyToManyField<EmptyModel, NewEmptyModel> mM2M;
//
// public EmptyModel() {
// super();
//
// mM2M = new ManyToManyField<EmptyModel, NewEmptyModel>(EmptyModel.class, NewEmptyModel.class);
// }
//
// }
//
// Path: src/src/com/orm/androrm/migration/Migrator.java
// public class Migrator<T extends Model> {
//
// private Class<T> mModel;
// private List<Migratable<T>> mMigrations;
//
// public Migrator(Class<T> model) {
// mModel = model;
// mMigrations = new ArrayList<Migratable<T>>();
// }
//
// public void addField(String name, DatabaseField<?> field) {
// AddFieldMigration<T> migration = new AddFieldMigration<T>(name, field);
//
// mMigrations.add(migration);
// }
//
// public <R extends Model> void addField(String name, ManyToManyField<T, R> field) {
// // Tables for M2M relations are created anyway. This stub is only here,
// // so that users aren't confused, if they try to add a M2M field. We let
// // them believe "they" did it :)
// return;
// }
//
// public void renameModel(String old, Class<? extends Model> updated) {
// RenameModelMigration<T> migration = new RenameModelMigration<T>(old);
//
// mMigrations.add(migration);
// }
//
// public void renameRelation(String old, Class<? extends Model> updated) {
// RenameRelationMigration<T> migration = new RenameRelationMigration<T>(old);
//
// mMigrations.add(migration);
// }
//
// public void migrate(Context context) {
// for(Migratable<T> migration : mMigrations) {
// if(migration.execute(context, mModel)) {
// Migration.create(mModel, migration).save(context);
// }
// }
// }
//
// }
// Path: test/src/com/orm/androrm/test/migration/ForeignKeyMigrationTest.java
import java.util.ArrayList;
import java.util.List;
import com.orm.androrm.DatabaseAdapter;
import com.orm.androrm.Model;
import com.orm.androrm.field.ForeignKeyField;
import com.orm.androrm.impl.Product;
import com.orm.androrm.impl.migration.EmptyModel;
import com.orm.androrm.migration.Migrator;
package com.orm.androrm.test.migration;
public class ForeignKeyMigrationTest extends AbstractMigrationTest {
@Override
public void setUp() {
List<Class<? extends Model>> models = new ArrayList<Class<? extends Model>>(); | models.add(EmptyModel.class); |
androrm/androrm | test/src/com/orm/androrm/test/migration/ForeignKeyMigrationTest.java | // Path: test/src/com/orm/androrm/impl/Product.java
// public class Product extends Model {
//
// public static final QuerySet<Product> objects(Context context) {
// return objects(context, Product.class);
// }
//
// protected CharField mName;
// protected ManyToManyField<Product, Branch> mBranches;
//
// public Product() {
// super();
//
// mName = new CharField(50);
// mBranches = new ManyToManyField<Product, Branch>(Product.class, Branch.class);
// }
//
// public void setName(String name) {
// mName.set(name);
// }
//
// public String getName() {
// return mName.get();
// }
//
// public void addBranch(Branch branch) {
// mBranches.add(branch);
// }
//
// public void addBranches(List<Branch> branches) {
// mBranches.addAll(branches);
// }
//
// public QuerySet<Branch> getBranches(Context context) {
// return mBranches.get(context, this);
// }
//
// public int branchCount(Context context) {
// return mBranches.get(context, this).count();
// }
//
// }
//
// Path: test/src/com/orm/androrm/impl/migration/EmptyModel.java
// public class EmptyModel extends Model {
//
// public static QuerySet<EmptyModel> objects(Context context) {
// return objects(context, EmptyModel.class);
// }
//
// protected ManyToManyField<EmptyModel, NewEmptyModel> mM2M;
//
// public EmptyModel() {
// super();
//
// mM2M = new ManyToManyField<EmptyModel, NewEmptyModel>(EmptyModel.class, NewEmptyModel.class);
// }
//
// }
//
// Path: src/src/com/orm/androrm/migration/Migrator.java
// public class Migrator<T extends Model> {
//
// private Class<T> mModel;
// private List<Migratable<T>> mMigrations;
//
// public Migrator(Class<T> model) {
// mModel = model;
// mMigrations = new ArrayList<Migratable<T>>();
// }
//
// public void addField(String name, DatabaseField<?> field) {
// AddFieldMigration<T> migration = new AddFieldMigration<T>(name, field);
//
// mMigrations.add(migration);
// }
//
// public <R extends Model> void addField(String name, ManyToManyField<T, R> field) {
// // Tables for M2M relations are created anyway. This stub is only here,
// // so that users aren't confused, if they try to add a M2M field. We let
// // them believe "they" did it :)
// return;
// }
//
// public void renameModel(String old, Class<? extends Model> updated) {
// RenameModelMigration<T> migration = new RenameModelMigration<T>(old);
//
// mMigrations.add(migration);
// }
//
// public void renameRelation(String old, Class<? extends Model> updated) {
// RenameRelationMigration<T> migration = new RenameRelationMigration<T>(old);
//
// mMigrations.add(migration);
// }
//
// public void migrate(Context context) {
// for(Migratable<T> migration : mMigrations) {
// if(migration.execute(context, mModel)) {
// Migration.create(mModel, migration).save(context);
// }
// }
// }
//
// }
| import java.util.ArrayList;
import java.util.List;
import com.orm.androrm.DatabaseAdapter;
import com.orm.androrm.Model;
import com.orm.androrm.field.ForeignKeyField;
import com.orm.androrm.impl.Product;
import com.orm.androrm.impl.migration.EmptyModel;
import com.orm.androrm.migration.Migrator; | package com.orm.androrm.test.migration;
public class ForeignKeyMigrationTest extends AbstractMigrationTest {
@Override
public void setUp() {
List<Class<? extends Model>> models = new ArrayList<Class<? extends Model>>();
models.add(EmptyModel.class);
DatabaseAdapter adapter = DatabaseAdapter.getInstance(getContext());
adapter.setModels(models);
super.setUp();
}
public void testForeignKeyAdd() {
assertFalse(mHelper.hasField(EmptyModel.class, "mProduct"));
| // Path: test/src/com/orm/androrm/impl/Product.java
// public class Product extends Model {
//
// public static final QuerySet<Product> objects(Context context) {
// return objects(context, Product.class);
// }
//
// protected CharField mName;
// protected ManyToManyField<Product, Branch> mBranches;
//
// public Product() {
// super();
//
// mName = new CharField(50);
// mBranches = new ManyToManyField<Product, Branch>(Product.class, Branch.class);
// }
//
// public void setName(String name) {
// mName.set(name);
// }
//
// public String getName() {
// return mName.get();
// }
//
// public void addBranch(Branch branch) {
// mBranches.add(branch);
// }
//
// public void addBranches(List<Branch> branches) {
// mBranches.addAll(branches);
// }
//
// public QuerySet<Branch> getBranches(Context context) {
// return mBranches.get(context, this);
// }
//
// public int branchCount(Context context) {
// return mBranches.get(context, this).count();
// }
//
// }
//
// Path: test/src/com/orm/androrm/impl/migration/EmptyModel.java
// public class EmptyModel extends Model {
//
// public static QuerySet<EmptyModel> objects(Context context) {
// return objects(context, EmptyModel.class);
// }
//
// protected ManyToManyField<EmptyModel, NewEmptyModel> mM2M;
//
// public EmptyModel() {
// super();
//
// mM2M = new ManyToManyField<EmptyModel, NewEmptyModel>(EmptyModel.class, NewEmptyModel.class);
// }
//
// }
//
// Path: src/src/com/orm/androrm/migration/Migrator.java
// public class Migrator<T extends Model> {
//
// private Class<T> mModel;
// private List<Migratable<T>> mMigrations;
//
// public Migrator(Class<T> model) {
// mModel = model;
// mMigrations = new ArrayList<Migratable<T>>();
// }
//
// public void addField(String name, DatabaseField<?> field) {
// AddFieldMigration<T> migration = new AddFieldMigration<T>(name, field);
//
// mMigrations.add(migration);
// }
//
// public <R extends Model> void addField(String name, ManyToManyField<T, R> field) {
// // Tables for M2M relations are created anyway. This stub is only here,
// // so that users aren't confused, if they try to add a M2M field. We let
// // them believe "they" did it :)
// return;
// }
//
// public void renameModel(String old, Class<? extends Model> updated) {
// RenameModelMigration<T> migration = new RenameModelMigration<T>(old);
//
// mMigrations.add(migration);
// }
//
// public void renameRelation(String old, Class<? extends Model> updated) {
// RenameRelationMigration<T> migration = new RenameRelationMigration<T>(old);
//
// mMigrations.add(migration);
// }
//
// public void migrate(Context context) {
// for(Migratable<T> migration : mMigrations) {
// if(migration.execute(context, mModel)) {
// Migration.create(mModel, migration).save(context);
// }
// }
// }
//
// }
// Path: test/src/com/orm/androrm/test/migration/ForeignKeyMigrationTest.java
import java.util.ArrayList;
import java.util.List;
import com.orm.androrm.DatabaseAdapter;
import com.orm.androrm.Model;
import com.orm.androrm.field.ForeignKeyField;
import com.orm.androrm.impl.Product;
import com.orm.androrm.impl.migration.EmptyModel;
import com.orm.androrm.migration.Migrator;
package com.orm.androrm.test.migration;
public class ForeignKeyMigrationTest extends AbstractMigrationTest {
@Override
public void setUp() {
List<Class<? extends Model>> models = new ArrayList<Class<? extends Model>>();
models.add(EmptyModel.class);
DatabaseAdapter adapter = DatabaseAdapter.getInstance(getContext());
adapter.setModels(models);
super.setUp();
}
public void testForeignKeyAdd() {
assertFalse(mHelper.hasField(EmptyModel.class, "mProduct"));
| Migrator<EmptyModel> migrator = new Migrator<EmptyModel>(EmptyModel.class); |
androrm/androrm | test/src/com/orm/androrm/test/migration/ForeignKeyMigrationTest.java | // Path: test/src/com/orm/androrm/impl/Product.java
// public class Product extends Model {
//
// public static final QuerySet<Product> objects(Context context) {
// return objects(context, Product.class);
// }
//
// protected CharField mName;
// protected ManyToManyField<Product, Branch> mBranches;
//
// public Product() {
// super();
//
// mName = new CharField(50);
// mBranches = new ManyToManyField<Product, Branch>(Product.class, Branch.class);
// }
//
// public void setName(String name) {
// mName.set(name);
// }
//
// public String getName() {
// return mName.get();
// }
//
// public void addBranch(Branch branch) {
// mBranches.add(branch);
// }
//
// public void addBranches(List<Branch> branches) {
// mBranches.addAll(branches);
// }
//
// public QuerySet<Branch> getBranches(Context context) {
// return mBranches.get(context, this);
// }
//
// public int branchCount(Context context) {
// return mBranches.get(context, this).count();
// }
//
// }
//
// Path: test/src/com/orm/androrm/impl/migration/EmptyModel.java
// public class EmptyModel extends Model {
//
// public static QuerySet<EmptyModel> objects(Context context) {
// return objects(context, EmptyModel.class);
// }
//
// protected ManyToManyField<EmptyModel, NewEmptyModel> mM2M;
//
// public EmptyModel() {
// super();
//
// mM2M = new ManyToManyField<EmptyModel, NewEmptyModel>(EmptyModel.class, NewEmptyModel.class);
// }
//
// }
//
// Path: src/src/com/orm/androrm/migration/Migrator.java
// public class Migrator<T extends Model> {
//
// private Class<T> mModel;
// private List<Migratable<T>> mMigrations;
//
// public Migrator(Class<T> model) {
// mModel = model;
// mMigrations = new ArrayList<Migratable<T>>();
// }
//
// public void addField(String name, DatabaseField<?> field) {
// AddFieldMigration<T> migration = new AddFieldMigration<T>(name, field);
//
// mMigrations.add(migration);
// }
//
// public <R extends Model> void addField(String name, ManyToManyField<T, R> field) {
// // Tables for M2M relations are created anyway. This stub is only here,
// // so that users aren't confused, if they try to add a M2M field. We let
// // them believe "they" did it :)
// return;
// }
//
// public void renameModel(String old, Class<? extends Model> updated) {
// RenameModelMigration<T> migration = new RenameModelMigration<T>(old);
//
// mMigrations.add(migration);
// }
//
// public void renameRelation(String old, Class<? extends Model> updated) {
// RenameRelationMigration<T> migration = new RenameRelationMigration<T>(old);
//
// mMigrations.add(migration);
// }
//
// public void migrate(Context context) {
// for(Migratable<T> migration : mMigrations) {
// if(migration.execute(context, mModel)) {
// Migration.create(mModel, migration).save(context);
// }
// }
// }
//
// }
| import java.util.ArrayList;
import java.util.List;
import com.orm.androrm.DatabaseAdapter;
import com.orm.androrm.Model;
import com.orm.androrm.field.ForeignKeyField;
import com.orm.androrm.impl.Product;
import com.orm.androrm.impl.migration.EmptyModel;
import com.orm.androrm.migration.Migrator; | package com.orm.androrm.test.migration;
public class ForeignKeyMigrationTest extends AbstractMigrationTest {
@Override
public void setUp() {
List<Class<? extends Model>> models = new ArrayList<Class<? extends Model>>();
models.add(EmptyModel.class);
DatabaseAdapter adapter = DatabaseAdapter.getInstance(getContext());
adapter.setModels(models);
super.setUp();
}
public void testForeignKeyAdd() {
assertFalse(mHelper.hasField(EmptyModel.class, "mProduct"));
Migrator<EmptyModel> migrator = new Migrator<EmptyModel>(EmptyModel.class); | // Path: test/src/com/orm/androrm/impl/Product.java
// public class Product extends Model {
//
// public static final QuerySet<Product> objects(Context context) {
// return objects(context, Product.class);
// }
//
// protected CharField mName;
// protected ManyToManyField<Product, Branch> mBranches;
//
// public Product() {
// super();
//
// mName = new CharField(50);
// mBranches = new ManyToManyField<Product, Branch>(Product.class, Branch.class);
// }
//
// public void setName(String name) {
// mName.set(name);
// }
//
// public String getName() {
// return mName.get();
// }
//
// public void addBranch(Branch branch) {
// mBranches.add(branch);
// }
//
// public void addBranches(List<Branch> branches) {
// mBranches.addAll(branches);
// }
//
// public QuerySet<Branch> getBranches(Context context) {
// return mBranches.get(context, this);
// }
//
// public int branchCount(Context context) {
// return mBranches.get(context, this).count();
// }
//
// }
//
// Path: test/src/com/orm/androrm/impl/migration/EmptyModel.java
// public class EmptyModel extends Model {
//
// public static QuerySet<EmptyModel> objects(Context context) {
// return objects(context, EmptyModel.class);
// }
//
// protected ManyToManyField<EmptyModel, NewEmptyModel> mM2M;
//
// public EmptyModel() {
// super();
//
// mM2M = new ManyToManyField<EmptyModel, NewEmptyModel>(EmptyModel.class, NewEmptyModel.class);
// }
//
// }
//
// Path: src/src/com/orm/androrm/migration/Migrator.java
// public class Migrator<T extends Model> {
//
// private Class<T> mModel;
// private List<Migratable<T>> mMigrations;
//
// public Migrator(Class<T> model) {
// mModel = model;
// mMigrations = new ArrayList<Migratable<T>>();
// }
//
// public void addField(String name, DatabaseField<?> field) {
// AddFieldMigration<T> migration = new AddFieldMigration<T>(name, field);
//
// mMigrations.add(migration);
// }
//
// public <R extends Model> void addField(String name, ManyToManyField<T, R> field) {
// // Tables for M2M relations are created anyway. This stub is only here,
// // so that users aren't confused, if they try to add a M2M field. We let
// // them believe "they" did it :)
// return;
// }
//
// public void renameModel(String old, Class<? extends Model> updated) {
// RenameModelMigration<T> migration = new RenameModelMigration<T>(old);
//
// mMigrations.add(migration);
// }
//
// public void renameRelation(String old, Class<? extends Model> updated) {
// RenameRelationMigration<T> migration = new RenameRelationMigration<T>(old);
//
// mMigrations.add(migration);
// }
//
// public void migrate(Context context) {
// for(Migratable<T> migration : mMigrations) {
// if(migration.execute(context, mModel)) {
// Migration.create(mModel, migration).save(context);
// }
// }
// }
//
// }
// Path: test/src/com/orm/androrm/test/migration/ForeignKeyMigrationTest.java
import java.util.ArrayList;
import java.util.List;
import com.orm.androrm.DatabaseAdapter;
import com.orm.androrm.Model;
import com.orm.androrm.field.ForeignKeyField;
import com.orm.androrm.impl.Product;
import com.orm.androrm.impl.migration.EmptyModel;
import com.orm.androrm.migration.Migrator;
package com.orm.androrm.test.migration;
public class ForeignKeyMigrationTest extends AbstractMigrationTest {
@Override
public void setUp() {
List<Class<? extends Model>> models = new ArrayList<Class<? extends Model>>();
models.add(EmptyModel.class);
DatabaseAdapter adapter = DatabaseAdapter.getInstance(getContext());
adapter.setModels(models);
super.setUp();
}
public void testForeignKeyAdd() {
assertFalse(mHelper.hasField(EmptyModel.class, "mProduct"));
Migrator<EmptyModel> migrator = new Migrator<EmptyModel>(EmptyModel.class); | migrator.addField("mProduct", new ForeignKeyField<Product>(Product.class)); |
androrm/androrm | test/src/com/orm/androrm/test/field/DoubleFieldTest.java | // Path: src/src/com/orm/androrm/field/DoubleField.java
// public class DoubleField extends DataField<Double> {
//
// /**
// * Initializes a standard double field without
// * restrictions. The maximum length of double
// * values is 16.
// */
// public DoubleField() {
// setUp();
// }
//
// /**
// * Initializes the field and sets the maximum length
// * to the given value, if this value is greater than
// * 0 and less then or equal to 16.
// *
// * @param maxLength
// */
// public DoubleField(int maxLength) {
// setUp();
//
// if(maxLength > 0
// && maxLength <= 16) {
//
// mMaxLength = maxLength;
// }
// }
//
// @Override
// public void putData(String key, ContentValues values) {
// values.put(key, get());
// }
//
// @Override
// public void set(Cursor c, String fieldName) {
// set(c.getDouble(c.getColumnIndexOrThrow(fieldName)));
// }
//
// private void setUp() {
// mType = "numeric";
// mValue = 0.0;
// }
//
// @Override
// public void reset() {
// mValue = 0.0;
// }
//
// }
| import com.orm.androrm.field.DoubleField;
import android.content.ContentValues;
import android.test.AndroidTestCase; | package com.orm.androrm.test.field;
public class DoubleFieldTest extends AndroidTestCase {
public void testDefaults() { | // Path: src/src/com/orm/androrm/field/DoubleField.java
// public class DoubleField extends DataField<Double> {
//
// /**
// * Initializes a standard double field without
// * restrictions. The maximum length of double
// * values is 16.
// */
// public DoubleField() {
// setUp();
// }
//
// /**
// * Initializes the field and sets the maximum length
// * to the given value, if this value is greater than
// * 0 and less then or equal to 16.
// *
// * @param maxLength
// */
// public DoubleField(int maxLength) {
// setUp();
//
// if(maxLength > 0
// && maxLength <= 16) {
//
// mMaxLength = maxLength;
// }
// }
//
// @Override
// public void putData(String key, ContentValues values) {
// values.put(key, get());
// }
//
// @Override
// public void set(Cursor c, String fieldName) {
// set(c.getDouble(c.getColumnIndexOrThrow(fieldName)));
// }
//
// private void setUp() {
// mType = "numeric";
// mValue = 0.0;
// }
//
// @Override
// public void reset() {
// mValue = 0.0;
// }
//
// }
// Path: test/src/com/orm/androrm/test/field/DoubleFieldTest.java
import com.orm.androrm.field.DoubleField;
import android.content.ContentValues;
import android.test.AndroidTestCase;
package com.orm.androrm.test.field;
public class DoubleFieldTest extends AndroidTestCase {
public void testDefaults() { | DoubleField d = new DoubleField(); |
androrm/androrm | test/src/com/orm/androrm/test/statement/AndStatementTest.java | // Path: src/src/com/orm/androrm/statement/AndStatement.java
// public class AndStatement extends ComposedStatement{
//
// /**
// * Use this constructor to initialize a new AND
// * statement. The left {@link Statement} and the
// * right {@link Statement} will be separated by
// * the keyword AND.
// *
// * @param left
// * @param right
// */
// public AndStatement(Statement left, Statement right) {
// super(left, right);
//
// mSeparator = " AND ";
// }
// }
//
// Path: src/src/com/orm/androrm/statement/Statement.java
// public class Statement {
//
// /**
// * Key of the statement.
// */
// protected String mKey;
// /**
// * Key of the statement.
// */
// protected String mOperator;
// /**
// * Value of the statement.
// */
// protected String mValue;
//
// /**
// * Empty constructor.
// */
// public Statement() {}
//
// public Statement(String key, int value) {
// mKey = key;
// mOperator = "=";
// mValue = String.valueOf(value);
// }
//
// public Statement(String key, String operator, int value) {
// mKey = key;
// mOperator = operator;
// mValue = String.valueOf(value);
// }
//
// /**
// * This constructor sets the key and value field of this
// * statement.
// *
// * @param key Database column.
// * @param value Expected value of this column.
// */
// public Statement(String key, String value) {
// mKey = key;
// mOperator = "=";
// mValue = value;
// }
//
// public Statement(String key, String operator, String value) {
// mKey = key;
// mOperator = operator;
// mValue = value;
// }
//
// /**
// * Get all keys that are used in this statement.
// *
// * @return All keys i.e. the affected database columns.
// */
// public Set<String> getKeys() {
// Set<String> keys = new HashSet<String>();
// keys.add(mKey);
//
// return keys;
// }
//
// public void setKey(String key) {
// mKey = key;
// }
//
// @Override
// public String toString() {
// return mKey + " " + mOperator + " '" + mValue + "'";
// }
// }
| import java.util.Set;
import com.orm.androrm.statement.AndStatement;
import com.orm.androrm.statement.Statement;
import android.test.AndroidTestCase; | package com.orm.androrm.test.statement;
public class AndStatementTest extends AndroidTestCase {
public void testSimpleAnd() { | // Path: src/src/com/orm/androrm/statement/AndStatement.java
// public class AndStatement extends ComposedStatement{
//
// /**
// * Use this constructor to initialize a new AND
// * statement. The left {@link Statement} and the
// * right {@link Statement} will be separated by
// * the keyword AND.
// *
// * @param left
// * @param right
// */
// public AndStatement(Statement left, Statement right) {
// super(left, right);
//
// mSeparator = " AND ";
// }
// }
//
// Path: src/src/com/orm/androrm/statement/Statement.java
// public class Statement {
//
// /**
// * Key of the statement.
// */
// protected String mKey;
// /**
// * Key of the statement.
// */
// protected String mOperator;
// /**
// * Value of the statement.
// */
// protected String mValue;
//
// /**
// * Empty constructor.
// */
// public Statement() {}
//
// public Statement(String key, int value) {
// mKey = key;
// mOperator = "=";
// mValue = String.valueOf(value);
// }
//
// public Statement(String key, String operator, int value) {
// mKey = key;
// mOperator = operator;
// mValue = String.valueOf(value);
// }
//
// /**
// * This constructor sets the key and value field of this
// * statement.
// *
// * @param key Database column.
// * @param value Expected value of this column.
// */
// public Statement(String key, String value) {
// mKey = key;
// mOperator = "=";
// mValue = value;
// }
//
// public Statement(String key, String operator, String value) {
// mKey = key;
// mOperator = operator;
// mValue = value;
// }
//
// /**
// * Get all keys that are used in this statement.
// *
// * @return All keys i.e. the affected database columns.
// */
// public Set<String> getKeys() {
// Set<String> keys = new HashSet<String>();
// keys.add(mKey);
//
// return keys;
// }
//
// public void setKey(String key) {
// mKey = key;
// }
//
// @Override
// public String toString() {
// return mKey + " " + mOperator + " '" + mValue + "'";
// }
// }
// Path: test/src/com/orm/androrm/test/statement/AndStatementTest.java
import java.util.Set;
import com.orm.androrm.statement.AndStatement;
import com.orm.androrm.statement.Statement;
import android.test.AndroidTestCase;
package com.orm.androrm.test.statement;
public class AndStatementTest extends AndroidTestCase {
public void testSimpleAnd() { | Statement left = new Statement("foo", "bar"); |
androrm/androrm | test/src/com/orm/androrm/test/statement/AndStatementTest.java | // Path: src/src/com/orm/androrm/statement/AndStatement.java
// public class AndStatement extends ComposedStatement{
//
// /**
// * Use this constructor to initialize a new AND
// * statement. The left {@link Statement} and the
// * right {@link Statement} will be separated by
// * the keyword AND.
// *
// * @param left
// * @param right
// */
// public AndStatement(Statement left, Statement right) {
// super(left, right);
//
// mSeparator = " AND ";
// }
// }
//
// Path: src/src/com/orm/androrm/statement/Statement.java
// public class Statement {
//
// /**
// * Key of the statement.
// */
// protected String mKey;
// /**
// * Key of the statement.
// */
// protected String mOperator;
// /**
// * Value of the statement.
// */
// protected String mValue;
//
// /**
// * Empty constructor.
// */
// public Statement() {}
//
// public Statement(String key, int value) {
// mKey = key;
// mOperator = "=";
// mValue = String.valueOf(value);
// }
//
// public Statement(String key, String operator, int value) {
// mKey = key;
// mOperator = operator;
// mValue = String.valueOf(value);
// }
//
// /**
// * This constructor sets the key and value field of this
// * statement.
// *
// * @param key Database column.
// * @param value Expected value of this column.
// */
// public Statement(String key, String value) {
// mKey = key;
// mOperator = "=";
// mValue = value;
// }
//
// public Statement(String key, String operator, String value) {
// mKey = key;
// mOperator = operator;
// mValue = value;
// }
//
// /**
// * Get all keys that are used in this statement.
// *
// * @return All keys i.e. the affected database columns.
// */
// public Set<String> getKeys() {
// Set<String> keys = new HashSet<String>();
// keys.add(mKey);
//
// return keys;
// }
//
// public void setKey(String key) {
// mKey = key;
// }
//
// @Override
// public String toString() {
// return mKey + " " + mOperator + " '" + mValue + "'";
// }
// }
| import java.util.Set;
import com.orm.androrm.statement.AndStatement;
import com.orm.androrm.statement.Statement;
import android.test.AndroidTestCase; | package com.orm.androrm.test.statement;
public class AndStatementTest extends AndroidTestCase {
public void testSimpleAnd() {
Statement left = new Statement("foo", "bar");
Statement right = new Statement("bar", "baz");
| // Path: src/src/com/orm/androrm/statement/AndStatement.java
// public class AndStatement extends ComposedStatement{
//
// /**
// * Use this constructor to initialize a new AND
// * statement. The left {@link Statement} and the
// * right {@link Statement} will be separated by
// * the keyword AND.
// *
// * @param left
// * @param right
// */
// public AndStatement(Statement left, Statement right) {
// super(left, right);
//
// mSeparator = " AND ";
// }
// }
//
// Path: src/src/com/orm/androrm/statement/Statement.java
// public class Statement {
//
// /**
// * Key of the statement.
// */
// protected String mKey;
// /**
// * Key of the statement.
// */
// protected String mOperator;
// /**
// * Value of the statement.
// */
// protected String mValue;
//
// /**
// * Empty constructor.
// */
// public Statement() {}
//
// public Statement(String key, int value) {
// mKey = key;
// mOperator = "=";
// mValue = String.valueOf(value);
// }
//
// public Statement(String key, String operator, int value) {
// mKey = key;
// mOperator = operator;
// mValue = String.valueOf(value);
// }
//
// /**
// * This constructor sets the key and value field of this
// * statement.
// *
// * @param key Database column.
// * @param value Expected value of this column.
// */
// public Statement(String key, String value) {
// mKey = key;
// mOperator = "=";
// mValue = value;
// }
//
// public Statement(String key, String operator, String value) {
// mKey = key;
// mOperator = operator;
// mValue = value;
// }
//
// /**
// * Get all keys that are used in this statement.
// *
// * @return All keys i.e. the affected database columns.
// */
// public Set<String> getKeys() {
// Set<String> keys = new HashSet<String>();
// keys.add(mKey);
//
// return keys;
// }
//
// public void setKey(String key) {
// mKey = key;
// }
//
// @Override
// public String toString() {
// return mKey + " " + mOperator + " '" + mValue + "'";
// }
// }
// Path: test/src/com/orm/androrm/test/statement/AndStatementTest.java
import java.util.Set;
import com.orm.androrm.statement.AndStatement;
import com.orm.androrm.statement.Statement;
import android.test.AndroidTestCase;
package com.orm.androrm.test.statement;
public class AndStatementTest extends AndroidTestCase {
public void testSimpleAnd() {
Statement left = new Statement("foo", "bar");
Statement right = new Statement("bar", "baz");
| AndStatement and = new AndStatement(left, right); |
androrm/androrm | test/src/com/orm/androrm/test/statement/OrStatementTest.java | // Path: src/src/com/orm/androrm/statement/AndStatement.java
// public class AndStatement extends ComposedStatement{
//
// /**
// * Use this constructor to initialize a new AND
// * statement. The left {@link Statement} and the
// * right {@link Statement} will be separated by
// * the keyword AND.
// *
// * @param left
// * @param right
// */
// public AndStatement(Statement left, Statement right) {
// super(left, right);
//
// mSeparator = " AND ";
// }
// }
//
// Path: src/src/com/orm/androrm/statement/Statement.java
// public class Statement {
//
// /**
// * Key of the statement.
// */
// protected String mKey;
// /**
// * Key of the statement.
// */
// protected String mOperator;
// /**
// * Value of the statement.
// */
// protected String mValue;
//
// /**
// * Empty constructor.
// */
// public Statement() {}
//
// public Statement(String key, int value) {
// mKey = key;
// mOperator = "=";
// mValue = String.valueOf(value);
// }
//
// public Statement(String key, String operator, int value) {
// mKey = key;
// mOperator = operator;
// mValue = String.valueOf(value);
// }
//
// /**
// * This constructor sets the key and value field of this
// * statement.
// *
// * @param key Database column.
// * @param value Expected value of this column.
// */
// public Statement(String key, String value) {
// mKey = key;
// mOperator = "=";
// mValue = value;
// }
//
// public Statement(String key, String operator, String value) {
// mKey = key;
// mOperator = operator;
// mValue = value;
// }
//
// /**
// * Get all keys that are used in this statement.
// *
// * @return All keys i.e. the affected database columns.
// */
// public Set<String> getKeys() {
// Set<String> keys = new HashSet<String>();
// keys.add(mKey);
//
// return keys;
// }
//
// public void setKey(String key) {
// mKey = key;
// }
//
// @Override
// public String toString() {
// return mKey + " " + mOperator + " '" + mValue + "'";
// }
// }
| import com.orm.androrm.statement.AndStatement;
import com.orm.androrm.statement.LikeStatement;
import com.orm.androrm.statement.OrStatement;
import com.orm.androrm.statement.Statement;
import android.test.AndroidTestCase; | package com.orm.androrm.test.statement;
public class OrStatementTest extends AndroidTestCase {
public void testSimpleOr() { | // Path: src/src/com/orm/androrm/statement/AndStatement.java
// public class AndStatement extends ComposedStatement{
//
// /**
// * Use this constructor to initialize a new AND
// * statement. The left {@link Statement} and the
// * right {@link Statement} will be separated by
// * the keyword AND.
// *
// * @param left
// * @param right
// */
// public AndStatement(Statement left, Statement right) {
// super(left, right);
//
// mSeparator = " AND ";
// }
// }
//
// Path: src/src/com/orm/androrm/statement/Statement.java
// public class Statement {
//
// /**
// * Key of the statement.
// */
// protected String mKey;
// /**
// * Key of the statement.
// */
// protected String mOperator;
// /**
// * Value of the statement.
// */
// protected String mValue;
//
// /**
// * Empty constructor.
// */
// public Statement() {}
//
// public Statement(String key, int value) {
// mKey = key;
// mOperator = "=";
// mValue = String.valueOf(value);
// }
//
// public Statement(String key, String operator, int value) {
// mKey = key;
// mOperator = operator;
// mValue = String.valueOf(value);
// }
//
// /**
// * This constructor sets the key and value field of this
// * statement.
// *
// * @param key Database column.
// * @param value Expected value of this column.
// */
// public Statement(String key, String value) {
// mKey = key;
// mOperator = "=";
// mValue = value;
// }
//
// public Statement(String key, String operator, String value) {
// mKey = key;
// mOperator = operator;
// mValue = value;
// }
//
// /**
// * Get all keys that are used in this statement.
// *
// * @return All keys i.e. the affected database columns.
// */
// public Set<String> getKeys() {
// Set<String> keys = new HashSet<String>();
// keys.add(mKey);
//
// return keys;
// }
//
// public void setKey(String key) {
// mKey = key;
// }
//
// @Override
// public String toString() {
// return mKey + " " + mOperator + " '" + mValue + "'";
// }
// }
// Path: test/src/com/orm/androrm/test/statement/OrStatementTest.java
import com.orm.androrm.statement.AndStatement;
import com.orm.androrm.statement.LikeStatement;
import com.orm.androrm.statement.OrStatement;
import com.orm.androrm.statement.Statement;
import android.test.AndroidTestCase;
package com.orm.androrm.test.statement;
public class OrStatementTest extends AndroidTestCase {
public void testSimpleOr() { | Statement left = new Statement("foo", "bar"); |
androrm/androrm | test/src/com/orm/androrm/test/statement/OrStatementTest.java | // Path: src/src/com/orm/androrm/statement/AndStatement.java
// public class AndStatement extends ComposedStatement{
//
// /**
// * Use this constructor to initialize a new AND
// * statement. The left {@link Statement} and the
// * right {@link Statement} will be separated by
// * the keyword AND.
// *
// * @param left
// * @param right
// */
// public AndStatement(Statement left, Statement right) {
// super(left, right);
//
// mSeparator = " AND ";
// }
// }
//
// Path: src/src/com/orm/androrm/statement/Statement.java
// public class Statement {
//
// /**
// * Key of the statement.
// */
// protected String mKey;
// /**
// * Key of the statement.
// */
// protected String mOperator;
// /**
// * Value of the statement.
// */
// protected String mValue;
//
// /**
// * Empty constructor.
// */
// public Statement() {}
//
// public Statement(String key, int value) {
// mKey = key;
// mOperator = "=";
// mValue = String.valueOf(value);
// }
//
// public Statement(String key, String operator, int value) {
// mKey = key;
// mOperator = operator;
// mValue = String.valueOf(value);
// }
//
// /**
// * This constructor sets the key and value field of this
// * statement.
// *
// * @param key Database column.
// * @param value Expected value of this column.
// */
// public Statement(String key, String value) {
// mKey = key;
// mOperator = "=";
// mValue = value;
// }
//
// public Statement(String key, String operator, String value) {
// mKey = key;
// mOperator = operator;
// mValue = value;
// }
//
// /**
// * Get all keys that are used in this statement.
// *
// * @return All keys i.e. the affected database columns.
// */
// public Set<String> getKeys() {
// Set<String> keys = new HashSet<String>();
// keys.add(mKey);
//
// return keys;
// }
//
// public void setKey(String key) {
// mKey = key;
// }
//
// @Override
// public String toString() {
// return mKey + " " + mOperator + " '" + mValue + "'";
// }
// }
| import com.orm.androrm.statement.AndStatement;
import com.orm.androrm.statement.LikeStatement;
import com.orm.androrm.statement.OrStatement;
import com.orm.androrm.statement.Statement;
import android.test.AndroidTestCase; | package com.orm.androrm.test.statement;
public class OrStatementTest extends AndroidTestCase {
public void testSimpleOr() {
Statement left = new Statement("foo", "bar");
Statement right = new Statement("bar", "baz");
OrStatement or = new OrStatement(left, right);
assertEquals("(foo = 'bar' OR bar = 'baz')", or.toString());
}
public void testParanthesis() {
OrStatement left = new OrStatement(new Statement("foo", "bar"), new Statement("bar", "baz"));
OrStatement right = new OrStatement(new Statement("baz", "foo"), new LikeStatement("baz", "bar"));
| // Path: src/src/com/orm/androrm/statement/AndStatement.java
// public class AndStatement extends ComposedStatement{
//
// /**
// * Use this constructor to initialize a new AND
// * statement. The left {@link Statement} and the
// * right {@link Statement} will be separated by
// * the keyword AND.
// *
// * @param left
// * @param right
// */
// public AndStatement(Statement left, Statement right) {
// super(left, right);
//
// mSeparator = " AND ";
// }
// }
//
// Path: src/src/com/orm/androrm/statement/Statement.java
// public class Statement {
//
// /**
// * Key of the statement.
// */
// protected String mKey;
// /**
// * Key of the statement.
// */
// protected String mOperator;
// /**
// * Value of the statement.
// */
// protected String mValue;
//
// /**
// * Empty constructor.
// */
// public Statement() {}
//
// public Statement(String key, int value) {
// mKey = key;
// mOperator = "=";
// mValue = String.valueOf(value);
// }
//
// public Statement(String key, String operator, int value) {
// mKey = key;
// mOperator = operator;
// mValue = String.valueOf(value);
// }
//
// /**
// * This constructor sets the key and value field of this
// * statement.
// *
// * @param key Database column.
// * @param value Expected value of this column.
// */
// public Statement(String key, String value) {
// mKey = key;
// mOperator = "=";
// mValue = value;
// }
//
// public Statement(String key, String operator, String value) {
// mKey = key;
// mOperator = operator;
// mValue = value;
// }
//
// /**
// * Get all keys that are used in this statement.
// *
// * @return All keys i.e. the affected database columns.
// */
// public Set<String> getKeys() {
// Set<String> keys = new HashSet<String>();
// keys.add(mKey);
//
// return keys;
// }
//
// public void setKey(String key) {
// mKey = key;
// }
//
// @Override
// public String toString() {
// return mKey + " " + mOperator + " '" + mValue + "'";
// }
// }
// Path: test/src/com/orm/androrm/test/statement/OrStatementTest.java
import com.orm.androrm.statement.AndStatement;
import com.orm.androrm.statement.LikeStatement;
import com.orm.androrm.statement.OrStatement;
import com.orm.androrm.statement.Statement;
import android.test.AndroidTestCase;
package com.orm.androrm.test.statement;
public class OrStatementTest extends AndroidTestCase {
public void testSimpleOr() {
Statement left = new Statement("foo", "bar");
Statement right = new Statement("bar", "baz");
OrStatement or = new OrStatement(left, right);
assertEquals("(foo = 'bar' OR bar = 'baz')", or.toString());
}
public void testParanthesis() {
OrStatement left = new OrStatement(new Statement("foo", "bar"), new Statement("bar", "baz"));
OrStatement right = new OrStatement(new Statement("baz", "foo"), new LikeStatement("baz", "bar"));
| AndStatement and = new AndStatement(left, right); |
androrm/androrm | test/src/com/orm/androrm/test/RuleTest.java | // Path: src/src/com/orm/androrm/Rule.java
// public class Rule {
//
// /**
// * The key leads to the field this filter
// * is applied on. This can be the plain name
// * of a field like "mName" or a series of
// * field names like "mSupplier__mBranches__mName".
// */
// private String mKey;
// /**
// * The statement of a field is only valid for the
// * last field name in {@link Rule#mKey}.
// */
// private Statement mStatement;
//
// public Rule(String key, Statement statement) {
// mKey = key;
// mStatement = statement;
// }
//
// public String getKey() {
// return mKey;
// }
//
// public Statement getStatement() {
// return mStatement;
// }
// }
//
// Path: src/src/com/orm/androrm/statement/Statement.java
// public class Statement {
//
// /**
// * Key of the statement.
// */
// protected String mKey;
// /**
// * Key of the statement.
// */
// protected String mOperator;
// /**
// * Value of the statement.
// */
// protected String mValue;
//
// /**
// * Empty constructor.
// */
// public Statement() {}
//
// public Statement(String key, int value) {
// mKey = key;
// mOperator = "=";
// mValue = String.valueOf(value);
// }
//
// public Statement(String key, String operator, int value) {
// mKey = key;
// mOperator = operator;
// mValue = String.valueOf(value);
// }
//
// /**
// * This constructor sets the key and value field of this
// * statement.
// *
// * @param key Database column.
// * @param value Expected value of this column.
// */
// public Statement(String key, String value) {
// mKey = key;
// mOperator = "=";
// mValue = value;
// }
//
// public Statement(String key, String operator, String value) {
// mKey = key;
// mOperator = operator;
// mValue = value;
// }
//
// /**
// * Get all keys that are used in this statement.
// *
// * @return All keys i.e. the affected database columns.
// */
// public Set<String> getKeys() {
// Set<String> keys = new HashSet<String>();
// keys.add(mKey);
//
// return keys;
// }
//
// public void setKey(String key) {
// mKey = key;
// }
//
// @Override
// public String toString() {
// return mKey + " " + mOperator + " '" + mValue + "'";
// }
// }
| import com.orm.androrm.Rule;
import com.orm.androrm.statement.Statement;
import android.test.AndroidTestCase; | package com.orm.androrm.test;
public class RuleTest extends AndroidTestCase {
public void testFilter() { | // Path: src/src/com/orm/androrm/Rule.java
// public class Rule {
//
// /**
// * The key leads to the field this filter
// * is applied on. This can be the plain name
// * of a field like "mName" or a series of
// * field names like "mSupplier__mBranches__mName".
// */
// private String mKey;
// /**
// * The statement of a field is only valid for the
// * last field name in {@link Rule#mKey}.
// */
// private Statement mStatement;
//
// public Rule(String key, Statement statement) {
// mKey = key;
// mStatement = statement;
// }
//
// public String getKey() {
// return mKey;
// }
//
// public Statement getStatement() {
// return mStatement;
// }
// }
//
// Path: src/src/com/orm/androrm/statement/Statement.java
// public class Statement {
//
// /**
// * Key of the statement.
// */
// protected String mKey;
// /**
// * Key of the statement.
// */
// protected String mOperator;
// /**
// * Value of the statement.
// */
// protected String mValue;
//
// /**
// * Empty constructor.
// */
// public Statement() {}
//
// public Statement(String key, int value) {
// mKey = key;
// mOperator = "=";
// mValue = String.valueOf(value);
// }
//
// public Statement(String key, String operator, int value) {
// mKey = key;
// mOperator = operator;
// mValue = String.valueOf(value);
// }
//
// /**
// * This constructor sets the key and value field of this
// * statement.
// *
// * @param key Database column.
// * @param value Expected value of this column.
// */
// public Statement(String key, String value) {
// mKey = key;
// mOperator = "=";
// mValue = value;
// }
//
// public Statement(String key, String operator, String value) {
// mKey = key;
// mOperator = operator;
// mValue = value;
// }
//
// /**
// * Get all keys that are used in this statement.
// *
// * @return All keys i.e. the affected database columns.
// */
// public Set<String> getKeys() {
// Set<String> keys = new HashSet<String>();
// keys.add(mKey);
//
// return keys;
// }
//
// public void setKey(String key) {
// mKey = key;
// }
//
// @Override
// public String toString() {
// return mKey + " " + mOperator + " '" + mValue + "'";
// }
// }
// Path: test/src/com/orm/androrm/test/RuleTest.java
import com.orm.androrm.Rule;
import com.orm.androrm.statement.Statement;
import android.test.AndroidTestCase;
package com.orm.androrm.test;
public class RuleTest extends AndroidTestCase {
public void testFilter() { | Statement s = new Statement("bar", "baz"); |
androrm/androrm | test/src/com/orm/androrm/test/RuleTest.java | // Path: src/src/com/orm/androrm/Rule.java
// public class Rule {
//
// /**
// * The key leads to the field this filter
// * is applied on. This can be the plain name
// * of a field like "mName" or a series of
// * field names like "mSupplier__mBranches__mName".
// */
// private String mKey;
// /**
// * The statement of a field is only valid for the
// * last field name in {@link Rule#mKey}.
// */
// private Statement mStatement;
//
// public Rule(String key, Statement statement) {
// mKey = key;
// mStatement = statement;
// }
//
// public String getKey() {
// return mKey;
// }
//
// public Statement getStatement() {
// return mStatement;
// }
// }
//
// Path: src/src/com/orm/androrm/statement/Statement.java
// public class Statement {
//
// /**
// * Key of the statement.
// */
// protected String mKey;
// /**
// * Key of the statement.
// */
// protected String mOperator;
// /**
// * Value of the statement.
// */
// protected String mValue;
//
// /**
// * Empty constructor.
// */
// public Statement() {}
//
// public Statement(String key, int value) {
// mKey = key;
// mOperator = "=";
// mValue = String.valueOf(value);
// }
//
// public Statement(String key, String operator, int value) {
// mKey = key;
// mOperator = operator;
// mValue = String.valueOf(value);
// }
//
// /**
// * This constructor sets the key and value field of this
// * statement.
// *
// * @param key Database column.
// * @param value Expected value of this column.
// */
// public Statement(String key, String value) {
// mKey = key;
// mOperator = "=";
// mValue = value;
// }
//
// public Statement(String key, String operator, String value) {
// mKey = key;
// mOperator = operator;
// mValue = value;
// }
//
// /**
// * Get all keys that are used in this statement.
// *
// * @return All keys i.e. the affected database columns.
// */
// public Set<String> getKeys() {
// Set<String> keys = new HashSet<String>();
// keys.add(mKey);
//
// return keys;
// }
//
// public void setKey(String key) {
// mKey = key;
// }
//
// @Override
// public String toString() {
// return mKey + " " + mOperator + " '" + mValue + "'";
// }
// }
| import com.orm.androrm.Rule;
import com.orm.androrm.statement.Statement;
import android.test.AndroidTestCase; | package com.orm.androrm.test;
public class RuleTest extends AndroidTestCase {
public void testFilter() {
Statement s = new Statement("bar", "baz"); | // Path: src/src/com/orm/androrm/Rule.java
// public class Rule {
//
// /**
// * The key leads to the field this filter
// * is applied on. This can be the plain name
// * of a field like "mName" or a series of
// * field names like "mSupplier__mBranches__mName".
// */
// private String mKey;
// /**
// * The statement of a field is only valid for the
// * last field name in {@link Rule#mKey}.
// */
// private Statement mStatement;
//
// public Rule(String key, Statement statement) {
// mKey = key;
// mStatement = statement;
// }
//
// public String getKey() {
// return mKey;
// }
//
// public Statement getStatement() {
// return mStatement;
// }
// }
//
// Path: src/src/com/orm/androrm/statement/Statement.java
// public class Statement {
//
// /**
// * Key of the statement.
// */
// protected String mKey;
// /**
// * Key of the statement.
// */
// protected String mOperator;
// /**
// * Value of the statement.
// */
// protected String mValue;
//
// /**
// * Empty constructor.
// */
// public Statement() {}
//
// public Statement(String key, int value) {
// mKey = key;
// mOperator = "=";
// mValue = String.valueOf(value);
// }
//
// public Statement(String key, String operator, int value) {
// mKey = key;
// mOperator = operator;
// mValue = String.valueOf(value);
// }
//
// /**
// * This constructor sets the key and value field of this
// * statement.
// *
// * @param key Database column.
// * @param value Expected value of this column.
// */
// public Statement(String key, String value) {
// mKey = key;
// mOperator = "=";
// mValue = value;
// }
//
// public Statement(String key, String operator, String value) {
// mKey = key;
// mOperator = operator;
// mValue = value;
// }
//
// /**
// * Get all keys that are used in this statement.
// *
// * @return All keys i.e. the affected database columns.
// */
// public Set<String> getKeys() {
// Set<String> keys = new HashSet<String>();
// keys.add(mKey);
//
// return keys;
// }
//
// public void setKey(String key) {
// mKey = key;
// }
//
// @Override
// public String toString() {
// return mKey + " " + mOperator + " '" + mValue + "'";
// }
// }
// Path: test/src/com/orm/androrm/test/RuleTest.java
import com.orm.androrm.Rule;
import com.orm.androrm.statement.Statement;
import android.test.AndroidTestCase;
package com.orm.androrm.test;
public class RuleTest extends AndroidTestCase {
public void testFilter() {
Statement s = new Statement("bar", "baz"); | Rule f = new Rule("foo", s); |
androrm/androrm | test/src/com/orm/androrm/test/statement/InStatementTest.java | // Path: src/src/com/orm/androrm/statement/InStatement.java
// public class InStatement extends Statement {
//
// private List<Object> mValues;
//
// public InStatement(String key, List<Object> values) {
// mKey = key;
// mValues = values;
// }
//
// private String getList() {
// return StringUtils.join(mValues, "','");
// }
//
// @Override
// public String toString() {
// return mKey + " IN ('" + getList() + "')";
// }
//
// }
| import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import android.test.AndroidTestCase;
import com.orm.androrm.statement.InStatement; | package com.orm.androrm.test.statement;
public class InStatementTest extends AndroidTestCase {
public void testPlainStatement() {
List<Object> values = new ArrayList<Object>();
values.add(1);
| // Path: src/src/com/orm/androrm/statement/InStatement.java
// public class InStatement extends Statement {
//
// private List<Object> mValues;
//
// public InStatement(String key, List<Object> values) {
// mKey = key;
// mValues = values;
// }
//
// private String getList() {
// return StringUtils.join(mValues, "','");
// }
//
// @Override
// public String toString() {
// return mKey + " IN ('" + getList() + "')";
// }
//
// }
// Path: test/src/com/orm/androrm/test/statement/InStatementTest.java
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import android.test.AndroidTestCase;
import com.orm.androrm.statement.InStatement;
package com.orm.androrm.test.statement;
public class InStatementTest extends AndroidTestCase {
public void testPlainStatement() {
List<Object> values = new ArrayList<Object>();
values.add(1);
| InStatement in = new InStatement("foo", values); |
androrm/androrm | test/src/com/orm/androrm/test/field/BooleanFieldTest.java | // Path: src/src/com/orm/androrm/field/BooleanField.java
// public class BooleanField extends DataField<Boolean>{
//
// public BooleanField() {
// setUp();
//
// mValue = false;
// }
//
// @Override
// public void putData(String key, ContentValues values) {
// values.put(key, get());
// }
//
// @Override
// public void set(Cursor c, String fieldName) {
// set(c.getInt(c.getColumnIndexOrThrow(fieldName)) == 1);
// }
//
// private void setUp() {
// mType = "integer";
// mMaxLength = 1;
// }
//
// @Override
// public void reset() {
// mValue = false;
// }
//
// }
| import android.content.ContentValues;
import android.test.AndroidTestCase;
import com.orm.androrm.field.BooleanField; | package com.orm.androrm.test.field;
public class BooleanFieldTest extends AndroidTestCase {
public void testDefaults() { | // Path: src/src/com/orm/androrm/field/BooleanField.java
// public class BooleanField extends DataField<Boolean>{
//
// public BooleanField() {
// setUp();
//
// mValue = false;
// }
//
// @Override
// public void putData(String key, ContentValues values) {
// values.put(key, get());
// }
//
// @Override
// public void set(Cursor c, String fieldName) {
// set(c.getInt(c.getColumnIndexOrThrow(fieldName)) == 1);
// }
//
// private void setUp() {
// mType = "integer";
// mMaxLength = 1;
// }
//
// @Override
// public void reset() {
// mValue = false;
// }
//
// }
// Path: test/src/com/orm/androrm/test/field/BooleanFieldTest.java
import android.content.ContentValues;
import android.test.AndroidTestCase;
import com.orm.androrm.field.BooleanField;
package com.orm.androrm.test.field;
public class BooleanFieldTest extends AndroidTestCase {
public void testDefaults() { | BooleanField b = new BooleanField(); |
androrm/androrm | src/src/com/orm/androrm/DatabaseBuilder.java | // Path: src/src/com/orm/androrm/field/DataField.java
// public abstract class DataField<T> implements DatabaseField<T> {
//
// /**
// * Type descriptor of this field used for the
// * database definition.
// */
// protected String mType;
// /**
// * Value of that field.
// */
// protected T mValue;
// /**
// * Maximum length of that field.
// */
// protected int mMaxLength;
//
// @Override
// public T get() {
// return mValue;
// }
//
// @Override
// public String getDefinition(String fieldName) {
// String definition = "`" + fieldName + "` " + mType;
//
// if(mMaxLength > 0) {
// definition += "(" + mMaxLength + ")";
// }
//
// return definition;
// }
//
// @Override
// public void set(T value) {
// mValue = value;
// }
//
// @Override
// public String toString() {
// return String.valueOf(mValue);
// }
//
// protected boolean exec(Context context, Class<? extends Model> model, String sql) {
// DatabaseAdapter adapter = DatabaseAdapter.getInstance(context);
//
// adapter.open();
//
// try {
// adapter.exec(sql);
// } catch(SQLException e) {
// adapter.close();
//
// return false;
// }
//
// adapter.close();
// return true;
// }
//
// public boolean addToAs(Context context, Class<? extends Model> model, String name) {
// String sql = "ALTER TABLE `" + DatabaseBuilder.getTableName(model) + "` "
// + "ADD COLUMN " + getDefinition(name);
//
// return exec(context, model, sql);
//
// }
// }
//
// Path: src/src/com/orm/androrm/field/OneToManyField.java
// public class OneToManyField<L extends Model,
// R extends Model>
// extends AbstractToManyRelation<L, R> {
//
// public OneToManyField(Class<L> origin, Class<R> target) {
// mOriginClass = origin;
// mTargetClass = target;
// mValues = new ArrayList<R>();
// }
//
// @Override
// public QuerySet<R> get(Context context, L origin) {
// String fieldName = Model.getBackLinkFieldName(mTargetClass, mOriginClass);
//
// Filter filter = new Filter();
// filter.is(fieldName, origin);
//
// QuerySet<R> querySet = new QuerySet<R>(context, mTargetClass);
// querySet.filter(filter);
//
// return querySet;
// }
// }
| import com.orm.androrm.field.OneToManyField;
import android.util.Log;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.List;
import com.orm.androrm.field.DataField;
import com.orm.androrm.field.ForeignKeyField;
import com.orm.androrm.field.ManyToManyField; | definitions.addAll(getRelationDefinitions(c));
}
ModelCache.setTableDefinitions(clazz, definitions);
return definitions;
} catch(IllegalAccessException e) {
Log.e(TAG, "an exception has been thrown while gathering the database structure information.", e);
}
}
return null;
}
private static final<T extends Model> void getFieldDefinitions(
T instance,
Class<T> clazz,
TableDefinition modelTable
) throws IllegalArgumentException, IllegalAccessException {
if(clazz != null && clazz.isInstance(instance)) {
ModelCache.addModel(clazz);
for(Field field: getFields(clazz, instance)) {
String name = field.getName();
Object o = field.get(instance);
| // Path: src/src/com/orm/androrm/field/DataField.java
// public abstract class DataField<T> implements DatabaseField<T> {
//
// /**
// * Type descriptor of this field used for the
// * database definition.
// */
// protected String mType;
// /**
// * Value of that field.
// */
// protected T mValue;
// /**
// * Maximum length of that field.
// */
// protected int mMaxLength;
//
// @Override
// public T get() {
// return mValue;
// }
//
// @Override
// public String getDefinition(String fieldName) {
// String definition = "`" + fieldName + "` " + mType;
//
// if(mMaxLength > 0) {
// definition += "(" + mMaxLength + ")";
// }
//
// return definition;
// }
//
// @Override
// public void set(T value) {
// mValue = value;
// }
//
// @Override
// public String toString() {
// return String.valueOf(mValue);
// }
//
// protected boolean exec(Context context, Class<? extends Model> model, String sql) {
// DatabaseAdapter adapter = DatabaseAdapter.getInstance(context);
//
// adapter.open();
//
// try {
// adapter.exec(sql);
// } catch(SQLException e) {
// adapter.close();
//
// return false;
// }
//
// adapter.close();
// return true;
// }
//
// public boolean addToAs(Context context, Class<? extends Model> model, String name) {
// String sql = "ALTER TABLE `" + DatabaseBuilder.getTableName(model) + "` "
// + "ADD COLUMN " + getDefinition(name);
//
// return exec(context, model, sql);
//
// }
// }
//
// Path: src/src/com/orm/androrm/field/OneToManyField.java
// public class OneToManyField<L extends Model,
// R extends Model>
// extends AbstractToManyRelation<L, R> {
//
// public OneToManyField(Class<L> origin, Class<R> target) {
// mOriginClass = origin;
// mTargetClass = target;
// mValues = new ArrayList<R>();
// }
//
// @Override
// public QuerySet<R> get(Context context, L origin) {
// String fieldName = Model.getBackLinkFieldName(mTargetClass, mOriginClass);
//
// Filter filter = new Filter();
// filter.is(fieldName, origin);
//
// QuerySet<R> querySet = new QuerySet<R>(context, mTargetClass);
// querySet.filter(filter);
//
// return querySet;
// }
// }
// Path: src/src/com/orm/androrm/DatabaseBuilder.java
import com.orm.androrm.field.OneToManyField;
import android.util.Log;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.List;
import com.orm.androrm.field.DataField;
import com.orm.androrm.field.ForeignKeyField;
import com.orm.androrm.field.ManyToManyField;
definitions.addAll(getRelationDefinitions(c));
}
ModelCache.setTableDefinitions(clazz, definitions);
return definitions;
} catch(IllegalAccessException e) {
Log.e(TAG, "an exception has been thrown while gathering the database structure information.", e);
}
}
return null;
}
private static final<T extends Model> void getFieldDefinitions(
T instance,
Class<T> clazz,
TableDefinition modelTable
) throws IllegalArgumentException, IllegalAccessException {
if(clazz != null && clazz.isInstance(instance)) {
ModelCache.addModel(clazz);
for(Field field: getFields(clazz, instance)) {
String name = field.getName();
Object o = field.get(instance);
| if(o instanceof DataField) { |
androrm/androrm | src/src/com/orm/androrm/DatabaseBuilder.java | // Path: src/src/com/orm/androrm/field/DataField.java
// public abstract class DataField<T> implements DatabaseField<T> {
//
// /**
// * Type descriptor of this field used for the
// * database definition.
// */
// protected String mType;
// /**
// * Value of that field.
// */
// protected T mValue;
// /**
// * Maximum length of that field.
// */
// protected int mMaxLength;
//
// @Override
// public T get() {
// return mValue;
// }
//
// @Override
// public String getDefinition(String fieldName) {
// String definition = "`" + fieldName + "` " + mType;
//
// if(mMaxLength > 0) {
// definition += "(" + mMaxLength + ")";
// }
//
// return definition;
// }
//
// @Override
// public void set(T value) {
// mValue = value;
// }
//
// @Override
// public String toString() {
// return String.valueOf(mValue);
// }
//
// protected boolean exec(Context context, Class<? extends Model> model, String sql) {
// DatabaseAdapter adapter = DatabaseAdapter.getInstance(context);
//
// adapter.open();
//
// try {
// adapter.exec(sql);
// } catch(SQLException e) {
// adapter.close();
//
// return false;
// }
//
// adapter.close();
// return true;
// }
//
// public boolean addToAs(Context context, Class<? extends Model> model, String name) {
// String sql = "ALTER TABLE `" + DatabaseBuilder.getTableName(model) + "` "
// + "ADD COLUMN " + getDefinition(name);
//
// return exec(context, model, sql);
//
// }
// }
//
// Path: src/src/com/orm/androrm/field/OneToManyField.java
// public class OneToManyField<L extends Model,
// R extends Model>
// extends AbstractToManyRelation<L, R> {
//
// public OneToManyField(Class<L> origin, Class<R> target) {
// mOriginClass = origin;
// mTargetClass = target;
// mValues = new ArrayList<R>();
// }
//
// @Override
// public QuerySet<R> get(Context context, L origin) {
// String fieldName = Model.getBackLinkFieldName(mTargetClass, mOriginClass);
//
// Filter filter = new Filter();
// filter.is(fieldName, origin);
//
// QuerySet<R> querySet = new QuerySet<R>(context, mTargetClass);
// querySet.filter(filter);
//
// return querySet;
// }
// }
| import com.orm.androrm.field.OneToManyField;
import android.util.Log;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.List;
import com.orm.androrm.field.DataField;
import com.orm.androrm.field.ForeignKeyField;
import com.orm.androrm.field.ManyToManyField; | if(isDatabaseField(f)) {
fields.add(field);
}
}
}
} catch (IllegalAccessException e) {
Log.e(TAG, "exception thrown while trying to gain access to fields of class "
+ clazz.getSimpleName(), e);
}
ModelCache.setModelFields(clazz, fields);
return fields;
}
private static final boolean isDatabaseField(Object field) {
if(field != null) {
if(field instanceof DataField
|| isRelationalField(field)) {
return true;
}
}
return false;
}
protected static final boolean isRelationalField(Object field) {
if(field != null) {
if(field instanceof ForeignKeyField | // Path: src/src/com/orm/androrm/field/DataField.java
// public abstract class DataField<T> implements DatabaseField<T> {
//
// /**
// * Type descriptor of this field used for the
// * database definition.
// */
// protected String mType;
// /**
// * Value of that field.
// */
// protected T mValue;
// /**
// * Maximum length of that field.
// */
// protected int mMaxLength;
//
// @Override
// public T get() {
// return mValue;
// }
//
// @Override
// public String getDefinition(String fieldName) {
// String definition = "`" + fieldName + "` " + mType;
//
// if(mMaxLength > 0) {
// definition += "(" + mMaxLength + ")";
// }
//
// return definition;
// }
//
// @Override
// public void set(T value) {
// mValue = value;
// }
//
// @Override
// public String toString() {
// return String.valueOf(mValue);
// }
//
// protected boolean exec(Context context, Class<? extends Model> model, String sql) {
// DatabaseAdapter adapter = DatabaseAdapter.getInstance(context);
//
// adapter.open();
//
// try {
// adapter.exec(sql);
// } catch(SQLException e) {
// adapter.close();
//
// return false;
// }
//
// adapter.close();
// return true;
// }
//
// public boolean addToAs(Context context, Class<? extends Model> model, String name) {
// String sql = "ALTER TABLE `" + DatabaseBuilder.getTableName(model) + "` "
// + "ADD COLUMN " + getDefinition(name);
//
// return exec(context, model, sql);
//
// }
// }
//
// Path: src/src/com/orm/androrm/field/OneToManyField.java
// public class OneToManyField<L extends Model,
// R extends Model>
// extends AbstractToManyRelation<L, R> {
//
// public OneToManyField(Class<L> origin, Class<R> target) {
// mOriginClass = origin;
// mTargetClass = target;
// mValues = new ArrayList<R>();
// }
//
// @Override
// public QuerySet<R> get(Context context, L origin) {
// String fieldName = Model.getBackLinkFieldName(mTargetClass, mOriginClass);
//
// Filter filter = new Filter();
// filter.is(fieldName, origin);
//
// QuerySet<R> querySet = new QuerySet<R>(context, mTargetClass);
// querySet.filter(filter);
//
// return querySet;
// }
// }
// Path: src/src/com/orm/androrm/DatabaseBuilder.java
import com.orm.androrm.field.OneToManyField;
import android.util.Log;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.List;
import com.orm.androrm.field.DataField;
import com.orm.androrm.field.ForeignKeyField;
import com.orm.androrm.field.ManyToManyField;
if(isDatabaseField(f)) {
fields.add(field);
}
}
}
} catch (IllegalAccessException e) {
Log.e(TAG, "exception thrown while trying to gain access to fields of class "
+ clazz.getSimpleName(), e);
}
ModelCache.setModelFields(clazz, fields);
return fields;
}
private static final boolean isDatabaseField(Object field) {
if(field != null) {
if(field instanceof DataField
|| isRelationalField(field)) {
return true;
}
}
return false;
}
protected static final boolean isRelationalField(Object field) {
if(field != null) {
if(field instanceof ForeignKeyField | || field instanceof OneToManyField |
androrm/androrm | test/src/com/orm/androrm/test/statement/OrderByTest.java | // Path: src/src/com/orm/androrm/OrderBy.java
// public class OrderBy {
//
// private String mOrderBy;
//
// /**
// * Add an ORDER BY statement. For convenience ASC and DESC can
// * be toggled by adding a preceding a <code>+</code> or <code>-</code>
// * to the table column. In order to sort the table column in numerical
// * order add the prefix #.
// * <br /><br />
// * For example <code>-foo</code> will result in <code>foo DESC</code>.
// * <br /><br />
// * If no preceding <code>+</code> or <code>-</code> is given
// * <code>ASC</code> is assumed.
// *
// * @param col Name of the table column.
// */
// public OrderBy(String... columns) {
// boolean first = true;
//
// for(int i = 0, length = columns.length; i < length; i++) {
// String col = columns[i];
//
// if(!first) {
// mOrderBy += ", ";
// } else {
// mOrderBy = " ";
// }
// if(col.startsWith("#")) {
// if(col.startsWith("-")) {
// mOrderBy += "CAST(" +col.substring(2) + " AS INTEGER) DESC";
// } else if(col.startsWith("+")) {
// mOrderBy += "CAST(" +col.substring(2) + " AS INTEGER) ASC";
// } else {
// mOrderBy += "CAST(" +col.substring(1) + " AS INTEGER) ASC";
// }
// }else{
// if(col.startsWith("-")) {
// mOrderBy += "UPPER(" + col.substring(1) + ") DESC";
// } else if(col.startsWith("+")) {
// mOrderBy += "UPPER(" + col.substring(1) + ") ASC";
// } else {
// mOrderBy += "UPPER(" + col + ") ASC";
// }
// }
//
// if(first) {
// first = false;
// }
// }
// }
//
// @Override
// public String toString() {
// return " ORDER BY" + mOrderBy;
// }
// }
| import com.orm.androrm.OrderBy;
import android.test.AndroidTestCase; | package com.orm.androrm.test.statement;
public class OrderByTest extends AndroidTestCase {
public void testDefault() { | // Path: src/src/com/orm/androrm/OrderBy.java
// public class OrderBy {
//
// private String mOrderBy;
//
// /**
// * Add an ORDER BY statement. For convenience ASC and DESC can
// * be toggled by adding a preceding a <code>+</code> or <code>-</code>
// * to the table column. In order to sort the table column in numerical
// * order add the prefix #.
// * <br /><br />
// * For example <code>-foo</code> will result in <code>foo DESC</code>.
// * <br /><br />
// * If no preceding <code>+</code> or <code>-</code> is given
// * <code>ASC</code> is assumed.
// *
// * @param col Name of the table column.
// */
// public OrderBy(String... columns) {
// boolean first = true;
//
// for(int i = 0, length = columns.length; i < length; i++) {
// String col = columns[i];
//
// if(!first) {
// mOrderBy += ", ";
// } else {
// mOrderBy = " ";
// }
// if(col.startsWith("#")) {
// if(col.startsWith("-")) {
// mOrderBy += "CAST(" +col.substring(2) + " AS INTEGER) DESC";
// } else if(col.startsWith("+")) {
// mOrderBy += "CAST(" +col.substring(2) + " AS INTEGER) ASC";
// } else {
// mOrderBy += "CAST(" +col.substring(1) + " AS INTEGER) ASC";
// }
// }else{
// if(col.startsWith("-")) {
// mOrderBy += "UPPER(" + col.substring(1) + ") DESC";
// } else if(col.startsWith("+")) {
// mOrderBy += "UPPER(" + col.substring(1) + ") ASC";
// } else {
// mOrderBy += "UPPER(" + col + ") ASC";
// }
// }
//
// if(first) {
// first = false;
// }
// }
// }
//
// @Override
// public String toString() {
// return " ORDER BY" + mOrderBy;
// }
// }
// Path: test/src/com/orm/androrm/test/statement/OrderByTest.java
import com.orm.androrm.OrderBy;
import android.test.AndroidTestCase;
package com.orm.androrm.test.statement;
public class OrderByTest extends AndroidTestCase {
public void testDefault() { | OrderBy o = new OrderBy("col"); |
androrm/androrm | test/src/com/orm/androrm/test/regression/ForeignKeyRegression.java | // Path: test/src/com/orm/androrm/impl/Car.java
// public class Car extends Model {
//
// public static final QuerySet<Car> objects(Context context) {
// return objects(context, Car.class);
// }
//
// protected OneToManyField<Car, Person> mDrivers;
// protected CharField mName;
//
// public Car() {
// super();
//
// mName = new CharField();
// mDrivers = new OneToManyField<Car, Person>(Car.class, Person.class);
// }
//
// public void setName(String name) {
// mName.set(name);
// }
//
// public void addDriver(Person driver) {
// mDrivers.add(driver);
// }
//
// public QuerySet<Person> getDrivers(Context context) {
// return mDrivers.get(context, this);
// }
//
// }
//
// Path: test/src/com/orm/androrm/impl/Person.java
// public class Person extends Model {
//
// public static final QuerySet<Person> objects(Context context) {
// return objects(context, Person.class);
// }
//
// protected ForeignKeyField<Car> mCar;
// protected CharField mName;
//
// public Person() {
// super();
//
// mName = new CharField();
// mCar = new ForeignKeyField<Car>(Car.class);
// }
//
// public void setName(String name) {
// mName.set(name);
// }
//
// public String getName() {
// return mName.get();
// }
// }
| import java.util.ArrayList;
import java.util.List;
import com.orm.androrm.DatabaseAdapter;
import com.orm.androrm.Model;
import com.orm.androrm.impl.Car;
import com.orm.androrm.impl.Person;
import android.test.AndroidTestCase; | package com.orm.androrm.test.regression;
public class ForeignKeyRegression extends AndroidTestCase {
@Override
public void setUp() {
List<Class<? extends Model>> models = new ArrayList<Class<? extends Model>>(); | // Path: test/src/com/orm/androrm/impl/Car.java
// public class Car extends Model {
//
// public static final QuerySet<Car> objects(Context context) {
// return objects(context, Car.class);
// }
//
// protected OneToManyField<Car, Person> mDrivers;
// protected CharField mName;
//
// public Car() {
// super();
//
// mName = new CharField();
// mDrivers = new OneToManyField<Car, Person>(Car.class, Person.class);
// }
//
// public void setName(String name) {
// mName.set(name);
// }
//
// public void addDriver(Person driver) {
// mDrivers.add(driver);
// }
//
// public QuerySet<Person> getDrivers(Context context) {
// return mDrivers.get(context, this);
// }
//
// }
//
// Path: test/src/com/orm/androrm/impl/Person.java
// public class Person extends Model {
//
// public static final QuerySet<Person> objects(Context context) {
// return objects(context, Person.class);
// }
//
// protected ForeignKeyField<Car> mCar;
// protected CharField mName;
//
// public Person() {
// super();
//
// mName = new CharField();
// mCar = new ForeignKeyField<Car>(Car.class);
// }
//
// public void setName(String name) {
// mName.set(name);
// }
//
// public String getName() {
// return mName.get();
// }
// }
// Path: test/src/com/orm/androrm/test/regression/ForeignKeyRegression.java
import java.util.ArrayList;
import java.util.List;
import com.orm.androrm.DatabaseAdapter;
import com.orm.androrm.Model;
import com.orm.androrm.impl.Car;
import com.orm.androrm.impl.Person;
import android.test.AndroidTestCase;
package com.orm.androrm.test.regression;
public class ForeignKeyRegression extends AndroidTestCase {
@Override
public void setUp() {
List<Class<? extends Model>> models = new ArrayList<Class<? extends Model>>(); | models.add(Car.class); |
androrm/androrm | test/src/com/orm/androrm/test/regression/ForeignKeyRegression.java | // Path: test/src/com/orm/androrm/impl/Car.java
// public class Car extends Model {
//
// public static final QuerySet<Car> objects(Context context) {
// return objects(context, Car.class);
// }
//
// protected OneToManyField<Car, Person> mDrivers;
// protected CharField mName;
//
// public Car() {
// super();
//
// mName = new CharField();
// mDrivers = new OneToManyField<Car, Person>(Car.class, Person.class);
// }
//
// public void setName(String name) {
// mName.set(name);
// }
//
// public void addDriver(Person driver) {
// mDrivers.add(driver);
// }
//
// public QuerySet<Person> getDrivers(Context context) {
// return mDrivers.get(context, this);
// }
//
// }
//
// Path: test/src/com/orm/androrm/impl/Person.java
// public class Person extends Model {
//
// public static final QuerySet<Person> objects(Context context) {
// return objects(context, Person.class);
// }
//
// protected ForeignKeyField<Car> mCar;
// protected CharField mName;
//
// public Person() {
// super();
//
// mName = new CharField();
// mCar = new ForeignKeyField<Car>(Car.class);
// }
//
// public void setName(String name) {
// mName.set(name);
// }
//
// public String getName() {
// return mName.get();
// }
// }
| import java.util.ArrayList;
import java.util.List;
import com.orm.androrm.DatabaseAdapter;
import com.orm.androrm.Model;
import com.orm.androrm.impl.Car;
import com.orm.androrm.impl.Person;
import android.test.AndroidTestCase; | package com.orm.androrm.test.regression;
public class ForeignKeyRegression extends AndroidTestCase {
@Override
public void setUp() {
List<Class<? extends Model>> models = new ArrayList<Class<? extends Model>>();
models.add(Car.class); | // Path: test/src/com/orm/androrm/impl/Car.java
// public class Car extends Model {
//
// public static final QuerySet<Car> objects(Context context) {
// return objects(context, Car.class);
// }
//
// protected OneToManyField<Car, Person> mDrivers;
// protected CharField mName;
//
// public Car() {
// super();
//
// mName = new CharField();
// mDrivers = new OneToManyField<Car, Person>(Car.class, Person.class);
// }
//
// public void setName(String name) {
// mName.set(name);
// }
//
// public void addDriver(Person driver) {
// mDrivers.add(driver);
// }
//
// public QuerySet<Person> getDrivers(Context context) {
// return mDrivers.get(context, this);
// }
//
// }
//
// Path: test/src/com/orm/androrm/impl/Person.java
// public class Person extends Model {
//
// public static final QuerySet<Person> objects(Context context) {
// return objects(context, Person.class);
// }
//
// protected ForeignKeyField<Car> mCar;
// protected CharField mName;
//
// public Person() {
// super();
//
// mName = new CharField();
// mCar = new ForeignKeyField<Car>(Car.class);
// }
//
// public void setName(String name) {
// mName.set(name);
// }
//
// public String getName() {
// return mName.get();
// }
// }
// Path: test/src/com/orm/androrm/test/regression/ForeignKeyRegression.java
import java.util.ArrayList;
import java.util.List;
import com.orm.androrm.DatabaseAdapter;
import com.orm.androrm.Model;
import com.orm.androrm.impl.Car;
import com.orm.androrm.impl.Person;
import android.test.AndroidTestCase;
package com.orm.androrm.test.regression;
public class ForeignKeyRegression extends AndroidTestCase {
@Override
public void setUp() {
List<Class<? extends Model>> models = new ArrayList<Class<? extends Model>>();
models.add(Car.class); | models.add(Person.class); |
androrm/androrm | test/src/com/orm/androrm/test/regression/ModelRegression.java | // Path: test/src/com/orm/androrm/impl/migration/EmptyModel.java
// public class EmptyModel extends Model {
//
// public static QuerySet<EmptyModel> objects(Context context) {
// return objects(context, EmptyModel.class);
// }
//
// protected ManyToManyField<EmptyModel, NewEmptyModel> mM2M;
//
// public EmptyModel() {
// super();
//
// mM2M = new ManyToManyField<EmptyModel, NewEmptyModel>(EmptyModel.class, NewEmptyModel.class);
// }
//
// }
| import java.util.ArrayList;
import java.util.List;
import android.database.SQLException;
import android.test.AndroidTestCase;
import com.orm.androrm.DatabaseAdapter;
import com.orm.androrm.Model;
import com.orm.androrm.impl.migration.EmptyModel; | package com.orm.androrm.test.regression;
public class ModelRegression extends AndroidTestCase {
@Override
public void setUp() {
List<Class<? extends Model>> models = new ArrayList<Class<? extends Model>>(); | // Path: test/src/com/orm/androrm/impl/migration/EmptyModel.java
// public class EmptyModel extends Model {
//
// public static QuerySet<EmptyModel> objects(Context context) {
// return objects(context, EmptyModel.class);
// }
//
// protected ManyToManyField<EmptyModel, NewEmptyModel> mM2M;
//
// public EmptyModel() {
// super();
//
// mM2M = new ManyToManyField<EmptyModel, NewEmptyModel>(EmptyModel.class, NewEmptyModel.class);
// }
//
// }
// Path: test/src/com/orm/androrm/test/regression/ModelRegression.java
import java.util.ArrayList;
import java.util.List;
import android.database.SQLException;
import android.test.AndroidTestCase;
import com.orm.androrm.DatabaseAdapter;
import com.orm.androrm.Model;
import com.orm.androrm.impl.migration.EmptyModel;
package com.orm.androrm.test.regression;
public class ModelRegression extends AndroidTestCase {
@Override
public void setUp() {
List<Class<? extends Model>> models = new ArrayList<Class<? extends Model>>(); | models.add(EmptyModel.class); |
androrm/androrm | test/src/com/orm/androrm/test/field/IntegerFieldTest.java | // Path: src/src/com/orm/androrm/field/IntegerField.java
// public class IntegerField extends DataField<Integer> {
//
// /**
// * Initializes a new {@link IntegerField} with default
// * value 0.
// */
// public IntegerField() {
// mType = "integer";
// mValue = 0;
// }
//
// /**
// * Initializes a new {@link IntegerField} with default
// * value 0 and sets the maximum length to maxLength if
// * it is greater than 0 and less than or equal to 16.
// *
// * @param maxLength Maximum length of this field.
// */
// public IntegerField(int maxLength) {
// mType = "integer";
//
// if(maxLength > 0
// && maxLength <= 16) {
//
// mMaxLength = maxLength;
// }
// }
//
// @Override
// public void putData(String key, ContentValues values) {
// values.put(key, get());
// }
//
// @Override
// public void set(Cursor c, String fieldName) {
// set(c.getInt(c.getColumnIndexOrThrow(fieldName)));
// }
//
// @Override
// public void reset() {
// mValue = 0;
// }
//
// }
| import com.orm.androrm.field.IntegerField;
import android.test.AndroidTestCase; | package com.orm.androrm.test.field;
public class IntegerFieldTest extends AndroidTestCase {
public void testDefauls() { | // Path: src/src/com/orm/androrm/field/IntegerField.java
// public class IntegerField extends DataField<Integer> {
//
// /**
// * Initializes a new {@link IntegerField} with default
// * value 0.
// */
// public IntegerField() {
// mType = "integer";
// mValue = 0;
// }
//
// /**
// * Initializes a new {@link IntegerField} with default
// * value 0 and sets the maximum length to maxLength if
// * it is greater than 0 and less than or equal to 16.
// *
// * @param maxLength Maximum length of this field.
// */
// public IntegerField(int maxLength) {
// mType = "integer";
//
// if(maxLength > 0
// && maxLength <= 16) {
//
// mMaxLength = maxLength;
// }
// }
//
// @Override
// public void putData(String key, ContentValues values) {
// values.put(key, get());
// }
//
// @Override
// public void set(Cursor c, String fieldName) {
// set(c.getInt(c.getColumnIndexOrThrow(fieldName)));
// }
//
// @Override
// public void reset() {
// mValue = 0;
// }
//
// }
// Path: test/src/com/orm/androrm/test/field/IntegerFieldTest.java
import com.orm.androrm.field.IntegerField;
import android.test.AndroidTestCase;
package com.orm.androrm.test.field;
public class IntegerFieldTest extends AndroidTestCase {
public void testDefauls() { | IntegerField i = new IntegerField(); |
tvbarthel/SimpleWeatherForecast | SimpleWeatherForecast/src/androidTest/java/fr/tvbarthel/apps/simpleweatherforcast/tests/ApplicationTest.java | // Path: SimpleWeatherForecast/src/main/java/fr/tvbarthel/apps/simpleweatherforcast/openweathermap/DailyForecastModel.java
// public class DailyForecastModel implements Parcelable {
//
// private long mDateTime;
// private String mDescription;
// private Double mTemperature;
// private Double mMinTemperature;
// private Double mMaxTemperature;
// private int mHumidity;
//
// public DailyForecastModel() {
// }
//
// public DailyForecastModel(Parcel in) {
// readFromParcel(in);
// }
//
// public String getDescription() {
// return mDescription;
// }
//
// public void setDescription(String description) {
// mDescription = description;
// }
//
// public int getHumidity() {
// return mHumidity;
// }
//
// public void setHumidity(int humidity) {
// mHumidity = humidity;
// }
//
// public long getDateTime() {
// return mDateTime;
// }
//
// public void setDateTime(long dateTime) {
// mDateTime = dateTime;
// }
//
// public Double getTemperature() {
// return mTemperature;
// }
//
// public void setTemperature(Double temperature) {
// mTemperature = temperature;
// }
//
// public Double getMinTemperature() {
// return mMinTemperature;
// }
//
// public void setMinTemperature(Double minTemperature) {
// mMinTemperature = minTemperature;
// }
//
// public Double getMaxTemperature() {
// return mMaxTemperature;
// }
//
// public void setMaxTemperature(Double maxTemperature) {
// mMaxTemperature = maxTemperature;
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeLong(mDateTime);
// dest.writeString(mDescription);
// dest.writeInt(mHumidity);
// dest.writeDouble(mTemperature);
// dest.writeDouble(mMinTemperature);
// dest.writeDouble(mMaxTemperature);
// }
//
// private void readFromParcel(Parcel in) {
// mDateTime = in.readLong();
// mDescription = in.readString();
// mHumidity = in.readInt();
// mTemperature = in.readDouble();
// mMinTemperature = in.readDouble();
// mMaxTemperature = in.readDouble();
// }
//
// public static final Parcelable.Creator<DailyForecastModel> CREATOR = new Parcelable.Creator<DailyForecastModel>() {
// @Override
// public DailyForecastModel createFromParcel(Parcel source) {
// return new DailyForecastModel(source);
// }
//
// @Override
// public DailyForecastModel[] newArray(int size) {
// return new DailyForecastModel[size];
// }
// };
//
//
// }
| import android.app.Application;
import android.os.Bundle;
import android.os.Parcel;
import android.test.ApplicationTestCase;
import fr.tvbarthel.apps.simpleweatherforcast.openweathermap.DailyForecastModel; | package fr.tvbarthel.apps.simpleweatherforcast.tests;
public class ApplicationTest extends ApplicationTestCase<Application> {
public ApplicationTest() {
super(Application.class);
}
public void testDailyForecastModel() { | // Path: SimpleWeatherForecast/src/main/java/fr/tvbarthel/apps/simpleweatherforcast/openweathermap/DailyForecastModel.java
// public class DailyForecastModel implements Parcelable {
//
// private long mDateTime;
// private String mDescription;
// private Double mTemperature;
// private Double mMinTemperature;
// private Double mMaxTemperature;
// private int mHumidity;
//
// public DailyForecastModel() {
// }
//
// public DailyForecastModel(Parcel in) {
// readFromParcel(in);
// }
//
// public String getDescription() {
// return mDescription;
// }
//
// public void setDescription(String description) {
// mDescription = description;
// }
//
// public int getHumidity() {
// return mHumidity;
// }
//
// public void setHumidity(int humidity) {
// mHumidity = humidity;
// }
//
// public long getDateTime() {
// return mDateTime;
// }
//
// public void setDateTime(long dateTime) {
// mDateTime = dateTime;
// }
//
// public Double getTemperature() {
// return mTemperature;
// }
//
// public void setTemperature(Double temperature) {
// mTemperature = temperature;
// }
//
// public Double getMinTemperature() {
// return mMinTemperature;
// }
//
// public void setMinTemperature(Double minTemperature) {
// mMinTemperature = minTemperature;
// }
//
// public Double getMaxTemperature() {
// return mMaxTemperature;
// }
//
// public void setMaxTemperature(Double maxTemperature) {
// mMaxTemperature = maxTemperature;
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeLong(mDateTime);
// dest.writeString(mDescription);
// dest.writeInt(mHumidity);
// dest.writeDouble(mTemperature);
// dest.writeDouble(mMinTemperature);
// dest.writeDouble(mMaxTemperature);
// }
//
// private void readFromParcel(Parcel in) {
// mDateTime = in.readLong();
// mDescription = in.readString();
// mHumidity = in.readInt();
// mTemperature = in.readDouble();
// mMinTemperature = in.readDouble();
// mMaxTemperature = in.readDouble();
// }
//
// public static final Parcelable.Creator<DailyForecastModel> CREATOR = new Parcelable.Creator<DailyForecastModel>() {
// @Override
// public DailyForecastModel createFromParcel(Parcel source) {
// return new DailyForecastModel(source);
// }
//
// @Override
// public DailyForecastModel[] newArray(int size) {
// return new DailyForecastModel[size];
// }
// };
//
//
// }
// Path: SimpleWeatherForecast/src/androidTest/java/fr/tvbarthel/apps/simpleweatherforcast/tests/ApplicationTest.java
import android.app.Application;
import android.os.Bundle;
import android.os.Parcel;
import android.test.ApplicationTestCase;
import fr.tvbarthel.apps.simpleweatherforcast.openweathermap.DailyForecastModel;
package fr.tvbarthel.apps.simpleweatherforcast.tests;
public class ApplicationTest extends ApplicationTestCase<Application> {
public ApplicationTest() {
super(Application.class);
}
public void testDailyForecastModel() { | final DailyForecastModel model = new DailyForecastModel(); |
tvbarthel/SimpleWeatherForecast | SimpleWeatherForecast/src/main/java/fr/tvbarthel/apps/simpleweatherforcast/fragments/TemperatureUnitPickerDialogFragment.java | // Path: SimpleWeatherForecast/src/main/java/fr/tvbarthel/apps/simpleweatherforcast/utils/SharedPreferenceUtils.java
// public class SharedPreferenceUtils {
//
// public static final long REFRESH_TIME_AUTO = 1000 * 60 * 60 * 2; // 2 hours in millis.
// public static final long REFRESH_TIME_MANUAL = 1000 * 60 * 10; // 10 minutes.
//
// public static String KEY_LAST_UPDATE = "SharedPreferenceUtils.Key.LastUpdate";
// public static String KEY_LAST_KNOWN_JSON_WEATHER = "SharedPreferenceUtils.Key.LastKnownJsonWeather";
// public static String KEY_TEMPERATURE_UNIT_SYMBOL = "SharedPreferenceUtils.Key.TemperatureUnitSymbol";
//
// private static SharedPreferences getDefaultSharedPreferences(final Context context) {
// return PreferenceManager.getDefaultSharedPreferences(context);
// }
//
// public static String getLastKnownWeather(final Context context) {
// return getDefaultSharedPreferences(context).getString(KEY_LAST_KNOWN_JSON_WEATHER, null);
// }
//
// public static long getLastUpdate(final Context context) {
// return getDefaultSharedPreferences(context).getLong(KEY_LAST_UPDATE, 0);
// }
//
// public static void storeWeather(final Context context, final String jsonWeather) {
// final Editor editor = getDefaultSharedPreferences(context).edit();
// editor.putString(KEY_LAST_KNOWN_JSON_WEATHER, jsonWeather);
// editor.putLong(KEY_LAST_UPDATE, System.currentTimeMillis());
// editor.apply();
// }
//
// public static void storeTemperatureUnitSymbol(final Context context, final String unitSymbol) {
// final Editor editor = getDefaultSharedPreferences(context).edit();
// editor.putString(KEY_TEMPERATURE_UNIT_SYMBOL, unitSymbol);
// editor.apply();
// }
//
// public static String getTemperatureUnitSymbol(final Context context) {
// return getDefaultSharedPreferences(context).getString(KEY_TEMPERATURE_UNIT_SYMBOL,
// context.getString(R.string.temperature_unit_celsius_symbol));
// }
//
// public static void registerOnSharedPreferenceChangeListener(final Context context, SharedPreferences.OnSharedPreferenceChangeListener listener) {
// getDefaultSharedPreferences(context).registerOnSharedPreferenceChangeListener(listener);
// }
//
// public static void unregisterOnSharedPreferenceChangeListener(final Context context, SharedPreferences.OnSharedPreferenceChangeListener listener) {
// getDefaultSharedPreferences(context).unregisterOnSharedPreferenceChangeListener(listener);
// }
//
// public static boolean isWeatherOutdated(Context context, boolean isManualRefresh) {
// final long refreshTimeInMillis = isManualRefresh ? REFRESH_TIME_MANUAL : REFRESH_TIME_AUTO;
// final long lastUpdate = SharedPreferenceUtils.getLastUpdate(context);
// return System.currentTimeMillis() - lastUpdate > refreshTimeInMillis;
// }
//
// }
| import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.widget.ArrayAdapter;
import fr.tvbarthel.apps.simpleweatherforcast.R;
import fr.tvbarthel.apps.simpleweatherforcast.utils.SharedPreferenceUtils; | package fr.tvbarthel.apps.simpleweatherforcast.fragments;
public class TemperatureUnitPickerDialogFragment extends DialogFragment {
private static final String BUNDLE_TEMPERATURE_UNIT_NAMES = "BundleTemperatureUnitNames";
private static final String BUNDLE_TEMPERATURE_UNIT_SYMBOLS = "BundleTemperatureUnitSymbols";
public static TemperatureUnitPickerDialogFragment newInstance(String[] temperatureUnitNames, String[] temperatureUnitSymbols) {
final TemperatureUnitPickerDialogFragment instance = new TemperatureUnitPickerDialogFragment();
final Bundle arguments = new Bundle();
arguments.putStringArray(BUNDLE_TEMPERATURE_UNIT_NAMES, temperatureUnitNames);
arguments.putStringArray(BUNDLE_TEMPERATURE_UNIT_SYMBOLS, temperatureUnitSymbols);
instance.setArguments(arguments);
return instance;
}
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
final Bundle arguments = getArguments();
final String[] temperatureUnitNames = arguments.getStringArray(BUNDLE_TEMPERATURE_UNIT_NAMES);
final String[] temperatureUnitSymbols = arguments.getStringArray(BUNDLE_TEMPERATURE_UNIT_SYMBOLS);
final ArrayAdapter<String> temperatureUnitNameAdapter = new ArrayAdapter<String>(getActivity(),
android.R.layout.simple_expandable_list_item_1, temperatureUnitNames);
final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setTitle(R.string.dialog_temperature_unit_picker_title);
builder.setAdapter(temperatureUnitNameAdapter, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) { | // Path: SimpleWeatherForecast/src/main/java/fr/tvbarthel/apps/simpleweatherforcast/utils/SharedPreferenceUtils.java
// public class SharedPreferenceUtils {
//
// public static final long REFRESH_TIME_AUTO = 1000 * 60 * 60 * 2; // 2 hours in millis.
// public static final long REFRESH_TIME_MANUAL = 1000 * 60 * 10; // 10 minutes.
//
// public static String KEY_LAST_UPDATE = "SharedPreferenceUtils.Key.LastUpdate";
// public static String KEY_LAST_KNOWN_JSON_WEATHER = "SharedPreferenceUtils.Key.LastKnownJsonWeather";
// public static String KEY_TEMPERATURE_UNIT_SYMBOL = "SharedPreferenceUtils.Key.TemperatureUnitSymbol";
//
// private static SharedPreferences getDefaultSharedPreferences(final Context context) {
// return PreferenceManager.getDefaultSharedPreferences(context);
// }
//
// public static String getLastKnownWeather(final Context context) {
// return getDefaultSharedPreferences(context).getString(KEY_LAST_KNOWN_JSON_WEATHER, null);
// }
//
// public static long getLastUpdate(final Context context) {
// return getDefaultSharedPreferences(context).getLong(KEY_LAST_UPDATE, 0);
// }
//
// public static void storeWeather(final Context context, final String jsonWeather) {
// final Editor editor = getDefaultSharedPreferences(context).edit();
// editor.putString(KEY_LAST_KNOWN_JSON_WEATHER, jsonWeather);
// editor.putLong(KEY_LAST_UPDATE, System.currentTimeMillis());
// editor.apply();
// }
//
// public static void storeTemperatureUnitSymbol(final Context context, final String unitSymbol) {
// final Editor editor = getDefaultSharedPreferences(context).edit();
// editor.putString(KEY_TEMPERATURE_UNIT_SYMBOL, unitSymbol);
// editor.apply();
// }
//
// public static String getTemperatureUnitSymbol(final Context context) {
// return getDefaultSharedPreferences(context).getString(KEY_TEMPERATURE_UNIT_SYMBOL,
// context.getString(R.string.temperature_unit_celsius_symbol));
// }
//
// public static void registerOnSharedPreferenceChangeListener(final Context context, SharedPreferences.OnSharedPreferenceChangeListener listener) {
// getDefaultSharedPreferences(context).registerOnSharedPreferenceChangeListener(listener);
// }
//
// public static void unregisterOnSharedPreferenceChangeListener(final Context context, SharedPreferences.OnSharedPreferenceChangeListener listener) {
// getDefaultSharedPreferences(context).unregisterOnSharedPreferenceChangeListener(listener);
// }
//
// public static boolean isWeatherOutdated(Context context, boolean isManualRefresh) {
// final long refreshTimeInMillis = isManualRefresh ? REFRESH_TIME_MANUAL : REFRESH_TIME_AUTO;
// final long lastUpdate = SharedPreferenceUtils.getLastUpdate(context);
// return System.currentTimeMillis() - lastUpdate > refreshTimeInMillis;
// }
//
// }
// Path: SimpleWeatherForecast/src/main/java/fr/tvbarthel/apps/simpleweatherforcast/fragments/TemperatureUnitPickerDialogFragment.java
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.widget.ArrayAdapter;
import fr.tvbarthel.apps.simpleweatherforcast.R;
import fr.tvbarthel.apps.simpleweatherforcast.utils.SharedPreferenceUtils;
package fr.tvbarthel.apps.simpleweatherforcast.fragments;
public class TemperatureUnitPickerDialogFragment extends DialogFragment {
private static final String BUNDLE_TEMPERATURE_UNIT_NAMES = "BundleTemperatureUnitNames";
private static final String BUNDLE_TEMPERATURE_UNIT_SYMBOLS = "BundleTemperatureUnitSymbols";
public static TemperatureUnitPickerDialogFragment newInstance(String[] temperatureUnitNames, String[] temperatureUnitSymbols) {
final TemperatureUnitPickerDialogFragment instance = new TemperatureUnitPickerDialogFragment();
final Bundle arguments = new Bundle();
arguments.putStringArray(BUNDLE_TEMPERATURE_UNIT_NAMES, temperatureUnitNames);
arguments.putStringArray(BUNDLE_TEMPERATURE_UNIT_SYMBOLS, temperatureUnitSymbols);
instance.setArguments(arguments);
return instance;
}
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
final Bundle arguments = getArguments();
final String[] temperatureUnitNames = arguments.getStringArray(BUNDLE_TEMPERATURE_UNIT_NAMES);
final String[] temperatureUnitSymbols = arguments.getStringArray(BUNDLE_TEMPERATURE_UNIT_SYMBOLS);
final ArrayAdapter<String> temperatureUnitNameAdapter = new ArrayAdapter<String>(getActivity(),
android.R.layout.simple_expandable_list_item_1, temperatureUnitNames);
final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setTitle(R.string.dialog_temperature_unit_picker_title);
builder.setAdapter(temperatureUnitNameAdapter, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) { | SharedPreferenceUtils.storeTemperatureUnitSymbol(getActivity(), temperatureUnitSymbols[which]); |
tvbarthel/SimpleWeatherForecast | SimpleWeatherForecast/src/main/java/fr/tvbarthel/apps/simpleweatherforcast/fragments/ForecastFragment.java | // Path: SimpleWeatherForecast/src/main/java/fr/tvbarthel/apps/simpleweatherforcast/openweathermap/DailyForecastModel.java
// public class DailyForecastModel implements Parcelable {
//
// private long mDateTime;
// private String mDescription;
// private Double mTemperature;
// private Double mMinTemperature;
// private Double mMaxTemperature;
// private int mHumidity;
//
// public DailyForecastModel() {
// }
//
// public DailyForecastModel(Parcel in) {
// readFromParcel(in);
// }
//
// public String getDescription() {
// return mDescription;
// }
//
// public void setDescription(String description) {
// mDescription = description;
// }
//
// public int getHumidity() {
// return mHumidity;
// }
//
// public void setHumidity(int humidity) {
// mHumidity = humidity;
// }
//
// public long getDateTime() {
// return mDateTime;
// }
//
// public void setDateTime(long dateTime) {
// mDateTime = dateTime;
// }
//
// public Double getTemperature() {
// return mTemperature;
// }
//
// public void setTemperature(Double temperature) {
// mTemperature = temperature;
// }
//
// public Double getMinTemperature() {
// return mMinTemperature;
// }
//
// public void setMinTemperature(Double minTemperature) {
// mMinTemperature = minTemperature;
// }
//
// public Double getMaxTemperature() {
// return mMaxTemperature;
// }
//
// public void setMaxTemperature(Double maxTemperature) {
// mMaxTemperature = maxTemperature;
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeLong(mDateTime);
// dest.writeString(mDescription);
// dest.writeInt(mHumidity);
// dest.writeDouble(mTemperature);
// dest.writeDouble(mMinTemperature);
// dest.writeDouble(mMaxTemperature);
// }
//
// private void readFromParcel(Parcel in) {
// mDateTime = in.readLong();
// mDescription = in.readString();
// mHumidity = in.readInt();
// mTemperature = in.readDouble();
// mMinTemperature = in.readDouble();
// mMaxTemperature = in.readDouble();
// }
//
// public static final Parcelable.Creator<DailyForecastModel> CREATOR = new Parcelable.Creator<DailyForecastModel>() {
// @Override
// public DailyForecastModel createFromParcel(Parcel source) {
// return new DailyForecastModel(source);
// }
//
// @Override
// public DailyForecastModel[] newArray(int size) {
// return new DailyForecastModel[size];
// }
// };
//
//
// }
//
// Path: SimpleWeatherForecast/src/main/java/fr/tvbarthel/apps/simpleweatherforcast/utils/TemperatureUtils.java
// public final class TemperatureUtils {
//
//
// /**
// * Convert a temperature in Celsius to the requested unit.
// *
// * @param context a {@link android.content.Context}
// * @param temperatureInCelsius the given temperature in Celsius
// * @param temperatureUnit the requested unit
// * @return the temperature converted
// */
// public static long convertTemperature(Context context, double temperatureInCelsius, String temperatureUnit) {
// double temperatureConverted = temperatureInCelsius;
// if (temperatureUnit.equals(context.getString(R.string.temperature_unit_fahrenheit_symbol))) {
// temperatureConverted = temperatureInCelsius * 1.8f + 32f;
// } else if (temperatureUnit.equals(context.getString(R.string.temperature_unit_kelvin_symbol))) {
// temperatureConverted = temperatureInCelsius + 273.15f;
// }
// return Math.round(temperatureConverted);
// }
//
// // Non-instantiable class.
// private TemperatureUtils() {
// }
// }
| import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import fr.tvbarthel.apps.simpleweatherforcast.R;
import fr.tvbarthel.apps.simpleweatherforcast.openweathermap.DailyForecastModel;
import fr.tvbarthel.apps.simpleweatherforcast.utils.TemperatureUtils; | package fr.tvbarthel.apps.simpleweatherforcast.fragments;
/**
* A simple {@link android.support.v4.app.Fragment} that displays the weather forecast of one day.
*/
public class ForecastFragment extends Fragment {
public static String ARGUMENT_MODEL = "ForecastFragment.DailyForecastModel";
public static String ARGUMENT_TEMPERATURE_UNIT = "ForecastFragment.TemperatureUnit";
| // Path: SimpleWeatherForecast/src/main/java/fr/tvbarthel/apps/simpleweatherforcast/openweathermap/DailyForecastModel.java
// public class DailyForecastModel implements Parcelable {
//
// private long mDateTime;
// private String mDescription;
// private Double mTemperature;
// private Double mMinTemperature;
// private Double mMaxTemperature;
// private int mHumidity;
//
// public DailyForecastModel() {
// }
//
// public DailyForecastModel(Parcel in) {
// readFromParcel(in);
// }
//
// public String getDescription() {
// return mDescription;
// }
//
// public void setDescription(String description) {
// mDescription = description;
// }
//
// public int getHumidity() {
// return mHumidity;
// }
//
// public void setHumidity(int humidity) {
// mHumidity = humidity;
// }
//
// public long getDateTime() {
// return mDateTime;
// }
//
// public void setDateTime(long dateTime) {
// mDateTime = dateTime;
// }
//
// public Double getTemperature() {
// return mTemperature;
// }
//
// public void setTemperature(Double temperature) {
// mTemperature = temperature;
// }
//
// public Double getMinTemperature() {
// return mMinTemperature;
// }
//
// public void setMinTemperature(Double minTemperature) {
// mMinTemperature = minTemperature;
// }
//
// public Double getMaxTemperature() {
// return mMaxTemperature;
// }
//
// public void setMaxTemperature(Double maxTemperature) {
// mMaxTemperature = maxTemperature;
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeLong(mDateTime);
// dest.writeString(mDescription);
// dest.writeInt(mHumidity);
// dest.writeDouble(mTemperature);
// dest.writeDouble(mMinTemperature);
// dest.writeDouble(mMaxTemperature);
// }
//
// private void readFromParcel(Parcel in) {
// mDateTime = in.readLong();
// mDescription = in.readString();
// mHumidity = in.readInt();
// mTemperature = in.readDouble();
// mMinTemperature = in.readDouble();
// mMaxTemperature = in.readDouble();
// }
//
// public static final Parcelable.Creator<DailyForecastModel> CREATOR = new Parcelable.Creator<DailyForecastModel>() {
// @Override
// public DailyForecastModel createFromParcel(Parcel source) {
// return new DailyForecastModel(source);
// }
//
// @Override
// public DailyForecastModel[] newArray(int size) {
// return new DailyForecastModel[size];
// }
// };
//
//
// }
//
// Path: SimpleWeatherForecast/src/main/java/fr/tvbarthel/apps/simpleweatherforcast/utils/TemperatureUtils.java
// public final class TemperatureUtils {
//
//
// /**
// * Convert a temperature in Celsius to the requested unit.
// *
// * @param context a {@link android.content.Context}
// * @param temperatureInCelsius the given temperature in Celsius
// * @param temperatureUnit the requested unit
// * @return the temperature converted
// */
// public static long convertTemperature(Context context, double temperatureInCelsius, String temperatureUnit) {
// double temperatureConverted = temperatureInCelsius;
// if (temperatureUnit.equals(context.getString(R.string.temperature_unit_fahrenheit_symbol))) {
// temperatureConverted = temperatureInCelsius * 1.8f + 32f;
// } else if (temperatureUnit.equals(context.getString(R.string.temperature_unit_kelvin_symbol))) {
// temperatureConverted = temperatureInCelsius + 273.15f;
// }
// return Math.round(temperatureConverted);
// }
//
// // Non-instantiable class.
// private TemperatureUtils() {
// }
// }
// Path: SimpleWeatherForecast/src/main/java/fr/tvbarthel/apps/simpleweatherforcast/fragments/ForecastFragment.java
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import fr.tvbarthel.apps.simpleweatherforcast.R;
import fr.tvbarthel.apps.simpleweatherforcast.openweathermap.DailyForecastModel;
import fr.tvbarthel.apps.simpleweatherforcast.utils.TemperatureUtils;
package fr.tvbarthel.apps.simpleweatherforcast.fragments;
/**
* A simple {@link android.support.v4.app.Fragment} that displays the weather forecast of one day.
*/
public class ForecastFragment extends Fragment {
public static String ARGUMENT_MODEL = "ForecastFragment.DailyForecastModel";
public static String ARGUMENT_TEMPERATURE_UNIT = "ForecastFragment.TemperatureUnit";
| public static ForecastFragment newInstance(DailyForecastModel model, String temperatureUnit) { |
tvbarthel/SimpleWeatherForecast | SimpleWeatherForecast/src/main/java/fr/tvbarthel/apps/simpleweatherforcast/fragments/ForecastFragment.java | // Path: SimpleWeatherForecast/src/main/java/fr/tvbarthel/apps/simpleweatherforcast/openweathermap/DailyForecastModel.java
// public class DailyForecastModel implements Parcelable {
//
// private long mDateTime;
// private String mDescription;
// private Double mTemperature;
// private Double mMinTemperature;
// private Double mMaxTemperature;
// private int mHumidity;
//
// public DailyForecastModel() {
// }
//
// public DailyForecastModel(Parcel in) {
// readFromParcel(in);
// }
//
// public String getDescription() {
// return mDescription;
// }
//
// public void setDescription(String description) {
// mDescription = description;
// }
//
// public int getHumidity() {
// return mHumidity;
// }
//
// public void setHumidity(int humidity) {
// mHumidity = humidity;
// }
//
// public long getDateTime() {
// return mDateTime;
// }
//
// public void setDateTime(long dateTime) {
// mDateTime = dateTime;
// }
//
// public Double getTemperature() {
// return mTemperature;
// }
//
// public void setTemperature(Double temperature) {
// mTemperature = temperature;
// }
//
// public Double getMinTemperature() {
// return mMinTemperature;
// }
//
// public void setMinTemperature(Double minTemperature) {
// mMinTemperature = minTemperature;
// }
//
// public Double getMaxTemperature() {
// return mMaxTemperature;
// }
//
// public void setMaxTemperature(Double maxTemperature) {
// mMaxTemperature = maxTemperature;
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeLong(mDateTime);
// dest.writeString(mDescription);
// dest.writeInt(mHumidity);
// dest.writeDouble(mTemperature);
// dest.writeDouble(mMinTemperature);
// dest.writeDouble(mMaxTemperature);
// }
//
// private void readFromParcel(Parcel in) {
// mDateTime = in.readLong();
// mDescription = in.readString();
// mHumidity = in.readInt();
// mTemperature = in.readDouble();
// mMinTemperature = in.readDouble();
// mMaxTemperature = in.readDouble();
// }
//
// public static final Parcelable.Creator<DailyForecastModel> CREATOR = new Parcelable.Creator<DailyForecastModel>() {
// @Override
// public DailyForecastModel createFromParcel(Parcel source) {
// return new DailyForecastModel(source);
// }
//
// @Override
// public DailyForecastModel[] newArray(int size) {
// return new DailyForecastModel[size];
// }
// };
//
//
// }
//
// Path: SimpleWeatherForecast/src/main/java/fr/tvbarthel/apps/simpleweatherforcast/utils/TemperatureUtils.java
// public final class TemperatureUtils {
//
//
// /**
// * Convert a temperature in Celsius to the requested unit.
// *
// * @param context a {@link android.content.Context}
// * @param temperatureInCelsius the given temperature in Celsius
// * @param temperatureUnit the requested unit
// * @return the temperature converted
// */
// public static long convertTemperature(Context context, double temperatureInCelsius, String temperatureUnit) {
// double temperatureConverted = temperatureInCelsius;
// if (temperatureUnit.equals(context.getString(R.string.temperature_unit_fahrenheit_symbol))) {
// temperatureConverted = temperatureInCelsius * 1.8f + 32f;
// } else if (temperatureUnit.equals(context.getString(R.string.temperature_unit_kelvin_symbol))) {
// temperatureConverted = temperatureInCelsius + 273.15f;
// }
// return Math.round(temperatureConverted);
// }
//
// // Non-instantiable class.
// private TemperatureUtils() {
// }
// }
| import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import fr.tvbarthel.apps.simpleweatherforcast.R;
import fr.tvbarthel.apps.simpleweatherforcast.openweathermap.DailyForecastModel;
import fr.tvbarthel.apps.simpleweatherforcast.utils.TemperatureUtils; | package fr.tvbarthel.apps.simpleweatherforcast.fragments;
/**
* A simple {@link android.support.v4.app.Fragment} that displays the weather forecast of one day.
*/
public class ForecastFragment extends Fragment {
public static String ARGUMENT_MODEL = "ForecastFragment.DailyForecastModel";
public static String ARGUMENT_TEMPERATURE_UNIT = "ForecastFragment.TemperatureUnit";
public static ForecastFragment newInstance(DailyForecastModel model, String temperatureUnit) {
final ForecastFragment instance = new ForecastFragment();
final Bundle arguments = new Bundle();
arguments.putParcelable(ARGUMENT_MODEL, model);
arguments.putString(ARGUMENT_TEMPERATURE_UNIT, temperatureUnit);
instance.setArguments(arguments);
return instance;
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final View v = inflater.inflate(R.layout.fragment_forecast, container, false);
final Bundle arguments = getArguments();
final DailyForecastModel dailyForecastModel = arguments.getParcelable(ARGUMENT_MODEL);
final String temperatureUnit = arguments.getString(ARGUMENT_TEMPERATURE_UNIT);
if (dailyForecastModel != null) { | // Path: SimpleWeatherForecast/src/main/java/fr/tvbarthel/apps/simpleweatherforcast/openweathermap/DailyForecastModel.java
// public class DailyForecastModel implements Parcelable {
//
// private long mDateTime;
// private String mDescription;
// private Double mTemperature;
// private Double mMinTemperature;
// private Double mMaxTemperature;
// private int mHumidity;
//
// public DailyForecastModel() {
// }
//
// public DailyForecastModel(Parcel in) {
// readFromParcel(in);
// }
//
// public String getDescription() {
// return mDescription;
// }
//
// public void setDescription(String description) {
// mDescription = description;
// }
//
// public int getHumidity() {
// return mHumidity;
// }
//
// public void setHumidity(int humidity) {
// mHumidity = humidity;
// }
//
// public long getDateTime() {
// return mDateTime;
// }
//
// public void setDateTime(long dateTime) {
// mDateTime = dateTime;
// }
//
// public Double getTemperature() {
// return mTemperature;
// }
//
// public void setTemperature(Double temperature) {
// mTemperature = temperature;
// }
//
// public Double getMinTemperature() {
// return mMinTemperature;
// }
//
// public void setMinTemperature(Double minTemperature) {
// mMinTemperature = minTemperature;
// }
//
// public Double getMaxTemperature() {
// return mMaxTemperature;
// }
//
// public void setMaxTemperature(Double maxTemperature) {
// mMaxTemperature = maxTemperature;
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeLong(mDateTime);
// dest.writeString(mDescription);
// dest.writeInt(mHumidity);
// dest.writeDouble(mTemperature);
// dest.writeDouble(mMinTemperature);
// dest.writeDouble(mMaxTemperature);
// }
//
// private void readFromParcel(Parcel in) {
// mDateTime = in.readLong();
// mDescription = in.readString();
// mHumidity = in.readInt();
// mTemperature = in.readDouble();
// mMinTemperature = in.readDouble();
// mMaxTemperature = in.readDouble();
// }
//
// public static final Parcelable.Creator<DailyForecastModel> CREATOR = new Parcelable.Creator<DailyForecastModel>() {
// @Override
// public DailyForecastModel createFromParcel(Parcel source) {
// return new DailyForecastModel(source);
// }
//
// @Override
// public DailyForecastModel[] newArray(int size) {
// return new DailyForecastModel[size];
// }
// };
//
//
// }
//
// Path: SimpleWeatherForecast/src/main/java/fr/tvbarthel/apps/simpleweatherforcast/utils/TemperatureUtils.java
// public final class TemperatureUtils {
//
//
// /**
// * Convert a temperature in Celsius to the requested unit.
// *
// * @param context a {@link android.content.Context}
// * @param temperatureInCelsius the given temperature in Celsius
// * @param temperatureUnit the requested unit
// * @return the temperature converted
// */
// public static long convertTemperature(Context context, double temperatureInCelsius, String temperatureUnit) {
// double temperatureConverted = temperatureInCelsius;
// if (temperatureUnit.equals(context.getString(R.string.temperature_unit_fahrenheit_symbol))) {
// temperatureConverted = temperatureInCelsius * 1.8f + 32f;
// } else if (temperatureUnit.equals(context.getString(R.string.temperature_unit_kelvin_symbol))) {
// temperatureConverted = temperatureInCelsius + 273.15f;
// }
// return Math.round(temperatureConverted);
// }
//
// // Non-instantiable class.
// private TemperatureUtils() {
// }
// }
// Path: SimpleWeatherForecast/src/main/java/fr/tvbarthel/apps/simpleweatherforcast/fragments/ForecastFragment.java
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import fr.tvbarthel.apps.simpleweatherforcast.R;
import fr.tvbarthel.apps.simpleweatherforcast.openweathermap.DailyForecastModel;
import fr.tvbarthel.apps.simpleweatherforcast.utils.TemperatureUtils;
package fr.tvbarthel.apps.simpleweatherforcast.fragments;
/**
* A simple {@link android.support.v4.app.Fragment} that displays the weather forecast of one day.
*/
public class ForecastFragment extends Fragment {
public static String ARGUMENT_MODEL = "ForecastFragment.DailyForecastModel";
public static String ARGUMENT_TEMPERATURE_UNIT = "ForecastFragment.TemperatureUnit";
public static ForecastFragment newInstance(DailyForecastModel model, String temperatureUnit) {
final ForecastFragment instance = new ForecastFragment();
final Bundle arguments = new Bundle();
arguments.putParcelable(ARGUMENT_MODEL, model);
arguments.putString(ARGUMENT_TEMPERATURE_UNIT, temperatureUnit);
instance.setArguments(arguments);
return instance;
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final View v = inflater.inflate(R.layout.fragment_forecast, container, false);
final Bundle arguments = getArguments();
final DailyForecastModel dailyForecastModel = arguments.getParcelable(ARGUMENT_MODEL);
final String temperatureUnit = arguments.getString(ARGUMENT_TEMPERATURE_UNIT);
if (dailyForecastModel != null) { | final long temperature = TemperatureUtils.convertTemperature(getActivity(), |
tvbarthel/SimpleWeatherForecast | SimpleWeatherForecast/src/main/java/fr/tvbarthel/apps/simpleweatherforcast/services/AppWidgetService.java | // Path: SimpleWeatherForecast/src/main/java/fr/tvbarthel/apps/simpleweatherforcast/ui/WeatherRemoteViewsFactory.java
// @TargetApi(Build.VERSION_CODES.HONEYCOMB)
// public class WeatherRemoteViewsFactory implements RemoteViewsService.RemoteViewsFactory {
//
// private Context mContext;
// private int mAppWidgetId;
// private List<DailyForecastModel> mDailyForecasts;
// private int[] mColors;
// private SimpleDateFormat mSimpleDateFormat;
// private String mTemperatureUnit;
//
// public WeatherRemoteViewsFactory(Context context, Intent intent) {
// mContext = context;
// mAppWidgetId = intent.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID);
// mSimpleDateFormat = new SimpleDateFormat("EEEE dd MMMM", Locale.getDefault());
// }
//
// @Override
// public void onCreate() {
// mColors = new int[]{R.color.holo_blue,
// R.color.holo_purple,
// R.color.holo_yellow,
// R.color.holo_red,
// R.color.holo_green};
// }
//
// @Override
// public void onDataSetChanged() {
// final String lastKnownWeather = SharedPreferenceUtils.getLastKnownWeather(mContext);
// mDailyForecasts = DailyForecastJsonParser.parse(lastKnownWeather);
// mTemperatureUnit = SharedPreferenceUtils.getTemperatureUnitSymbol(mContext);
// }
//
// @Override
// public void onDestroy() {
//
// }
//
// @Override
// public int getCount() {
// return mDailyForecasts.size();
// }
//
// @Override
// public RemoteViews getViewAt(int position) {
// final DailyForecastModel dailyForecast = mDailyForecasts.get(position);
// final RemoteViews remoteViews = new RemoteViews(mContext.getPackageName(), R.layout.row_app_widget);
// final long temperature = TemperatureUtils.convertTemperature(mContext, dailyForecast.getTemperature(), mTemperatureUnit);
// final int backgroundColor = mColors[position % mColors.length];
// final String date = mSimpleDateFormat.format(dailyForecast.getDateTime() * 1000);
//
// remoteViews.setTextViewText(R.id.row_app_widget_date, date);
// remoteViews.setTextViewText(R.id.row_app_widget_temperature, temperature + mTemperatureUnit);
// remoteViews.setTextViewText(R.id.row_app_widget_weather, dailyForecast.getDescription());
// remoteViews.setInt(R.id.row_app_widget_background, "setBackgroundResource", backgroundColor);
// final Intent fillInIntent = new Intent();
// fillInIntent.putExtra(MainActivity.EXTRA_PAGE_POSITION, position);
// remoteViews.setOnClickFillInIntent(R.id.row_app_widget_root, fillInIntent);
//
// return remoteViews;
// }
//
// @Override
// public RemoteViews getLoadingView() {
// return null;
// }
//
// @Override
// public int getViewTypeCount() {
// return 1;
// }
//
// @Override
// public long getItemId(int position) {
// return position;
// }
//
// @Override
// public boolean hasStableIds() {
// return true;
// }
// }
| import android.annotation.TargetApi;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.widget.RemoteViewsService;
import fr.tvbarthel.apps.simpleweatherforcast.ui.WeatherRemoteViewsFactory; | package fr.tvbarthel.apps.simpleweatherforcast.services;
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public class AppWidgetService extends RemoteViewsService {
@Override
public RemoteViewsFactory onGetViewFactory(Intent intent) {
final Context context = getApplicationContext(); | // Path: SimpleWeatherForecast/src/main/java/fr/tvbarthel/apps/simpleweatherforcast/ui/WeatherRemoteViewsFactory.java
// @TargetApi(Build.VERSION_CODES.HONEYCOMB)
// public class WeatherRemoteViewsFactory implements RemoteViewsService.RemoteViewsFactory {
//
// private Context mContext;
// private int mAppWidgetId;
// private List<DailyForecastModel> mDailyForecasts;
// private int[] mColors;
// private SimpleDateFormat mSimpleDateFormat;
// private String mTemperatureUnit;
//
// public WeatherRemoteViewsFactory(Context context, Intent intent) {
// mContext = context;
// mAppWidgetId = intent.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID);
// mSimpleDateFormat = new SimpleDateFormat("EEEE dd MMMM", Locale.getDefault());
// }
//
// @Override
// public void onCreate() {
// mColors = new int[]{R.color.holo_blue,
// R.color.holo_purple,
// R.color.holo_yellow,
// R.color.holo_red,
// R.color.holo_green};
// }
//
// @Override
// public void onDataSetChanged() {
// final String lastKnownWeather = SharedPreferenceUtils.getLastKnownWeather(mContext);
// mDailyForecasts = DailyForecastJsonParser.parse(lastKnownWeather);
// mTemperatureUnit = SharedPreferenceUtils.getTemperatureUnitSymbol(mContext);
// }
//
// @Override
// public void onDestroy() {
//
// }
//
// @Override
// public int getCount() {
// return mDailyForecasts.size();
// }
//
// @Override
// public RemoteViews getViewAt(int position) {
// final DailyForecastModel dailyForecast = mDailyForecasts.get(position);
// final RemoteViews remoteViews = new RemoteViews(mContext.getPackageName(), R.layout.row_app_widget);
// final long temperature = TemperatureUtils.convertTemperature(mContext, dailyForecast.getTemperature(), mTemperatureUnit);
// final int backgroundColor = mColors[position % mColors.length];
// final String date = mSimpleDateFormat.format(dailyForecast.getDateTime() * 1000);
//
// remoteViews.setTextViewText(R.id.row_app_widget_date, date);
// remoteViews.setTextViewText(R.id.row_app_widget_temperature, temperature + mTemperatureUnit);
// remoteViews.setTextViewText(R.id.row_app_widget_weather, dailyForecast.getDescription());
// remoteViews.setInt(R.id.row_app_widget_background, "setBackgroundResource", backgroundColor);
// final Intent fillInIntent = new Intent();
// fillInIntent.putExtra(MainActivity.EXTRA_PAGE_POSITION, position);
// remoteViews.setOnClickFillInIntent(R.id.row_app_widget_root, fillInIntent);
//
// return remoteViews;
// }
//
// @Override
// public RemoteViews getLoadingView() {
// return null;
// }
//
// @Override
// public int getViewTypeCount() {
// return 1;
// }
//
// @Override
// public long getItemId(int position) {
// return position;
// }
//
// @Override
// public boolean hasStableIds() {
// return true;
// }
// }
// Path: SimpleWeatherForecast/src/main/java/fr/tvbarthel/apps/simpleweatherforcast/services/AppWidgetService.java
import android.annotation.TargetApi;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.widget.RemoteViewsService;
import fr.tvbarthel.apps.simpleweatherforcast.ui.WeatherRemoteViewsFactory;
package fr.tvbarthel.apps.simpleweatherforcast.services;
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public class AppWidgetService extends RemoteViewsService {
@Override
public RemoteViewsFactory onGetViewFactory(Intent intent) {
final Context context = getApplicationContext(); | return new WeatherRemoteViewsFactory(getApplicationContext(), intent); |
tvbarthel/SimpleWeatherForecast | SimpleWeatherForecast/src/main/java/fr/tvbarthel/apps/simpleweatherforcast/fragments/MoreAppsDialogFragment.java | // Path: SimpleWeatherForecast/src/main/java/fr/tvbarthel/apps/simpleweatherforcast/model/App.java
// public class App {
//
// private Integer mNameResourceId;
// private Integer mLogoResourceId;
// private Integer mPackageNameResourceId;
//
// public Integer getNameResourceId() {
// return mNameResourceId;
// }
//
// public void setNameResourceId(Integer nameResourceId) {
// mNameResourceId = nameResourceId;
// }
//
// public Integer getLogoResourceId() {
// return mLogoResourceId;
// }
//
// public void setLogoResourceId(Integer logoResourceId) {
// mLogoResourceId = logoResourceId;
// }
//
// public Integer getPackageNameResourceId() {
// return mPackageNameResourceId;
// }
//
// public void setPackageNameResourceId(Integer packageNameResourceId) {
// mPackageNameResourceId = packageNameResourceId;
// }
// }
//
// Path: SimpleWeatherForecast/src/main/java/fr/tvbarthel/apps/simpleweatherforcast/ui/MoreAppsAdapter.java
// public class MoreAppsAdapter extends ArrayAdapter<App> {
//
//
// public MoreAppsAdapter(Context context, List<App> apps) {
// super(context, R.layout.row_more_apps, apps);
// }
//
// @Override
// public View getView(int position, View convertView, ViewGroup parent) {
// RelativeLayout appView = (RelativeLayout) convertView;
// App app = getItem(position);
//
// if (appView == null) {
// LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
// appView = (RelativeLayout) inflater.inflate(R.layout.row_more_apps, parent, false);
// ViewHolder holder = new ViewHolder();
// holder.appName = (TextView) appView.findViewById(R.id.row_more_apps_name);
// holder.appLogo = (ImageView) appView.findViewById(R.id.row_more_apps_logo);
// appView.setTag(holder);
// }
//
// ViewHolder holder = (ViewHolder) appView.getTag();
// holder.appName.setText(app.getNameResourceId());
// holder.appLogo.setImageResource(app.getLogoResourceId());
//
// return appView;
// }
//
// private static class ViewHolder {
// TextView appName;
// ImageView appLogo;
// }
// }
| import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
import java.util.ArrayList;
import fr.tvbarthel.apps.simpleweatherforcast.R;
import fr.tvbarthel.apps.simpleweatherforcast.model.App;
import fr.tvbarthel.apps.simpleweatherforcast.ui.MoreAppsAdapter; | package fr.tvbarthel.apps.simpleweatherforcast.fragments;
public class MoreAppsDialogFragment extends DialogFragment {
private static final String URI_ROOT_MARKET = "market://details?id=";
private static final String URI_ROOT_PLAY_STORE = "http://play.google.com/store/apps/details?id=";
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
final LayoutInflater inflater = getActivity().getLayoutInflater();
final ListView listView = (ListView) inflater.inflate(R.layout.dialog_more_apps, null);
final AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(getActivity());
dialogBuilder.setPositiveButton(android.R.string.ok, null);
dialogBuilder.setTitle(R.string.dialog_more_apps_title);
dialogBuilder.setView(listView);
dialogBuilder.setInverseBackgroundForced(true);
| // Path: SimpleWeatherForecast/src/main/java/fr/tvbarthel/apps/simpleweatherforcast/model/App.java
// public class App {
//
// private Integer mNameResourceId;
// private Integer mLogoResourceId;
// private Integer mPackageNameResourceId;
//
// public Integer getNameResourceId() {
// return mNameResourceId;
// }
//
// public void setNameResourceId(Integer nameResourceId) {
// mNameResourceId = nameResourceId;
// }
//
// public Integer getLogoResourceId() {
// return mLogoResourceId;
// }
//
// public void setLogoResourceId(Integer logoResourceId) {
// mLogoResourceId = logoResourceId;
// }
//
// public Integer getPackageNameResourceId() {
// return mPackageNameResourceId;
// }
//
// public void setPackageNameResourceId(Integer packageNameResourceId) {
// mPackageNameResourceId = packageNameResourceId;
// }
// }
//
// Path: SimpleWeatherForecast/src/main/java/fr/tvbarthel/apps/simpleweatherforcast/ui/MoreAppsAdapter.java
// public class MoreAppsAdapter extends ArrayAdapter<App> {
//
//
// public MoreAppsAdapter(Context context, List<App> apps) {
// super(context, R.layout.row_more_apps, apps);
// }
//
// @Override
// public View getView(int position, View convertView, ViewGroup parent) {
// RelativeLayout appView = (RelativeLayout) convertView;
// App app = getItem(position);
//
// if (appView == null) {
// LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
// appView = (RelativeLayout) inflater.inflate(R.layout.row_more_apps, parent, false);
// ViewHolder holder = new ViewHolder();
// holder.appName = (TextView) appView.findViewById(R.id.row_more_apps_name);
// holder.appLogo = (ImageView) appView.findViewById(R.id.row_more_apps_logo);
// appView.setTag(holder);
// }
//
// ViewHolder holder = (ViewHolder) appView.getTag();
// holder.appName.setText(app.getNameResourceId());
// holder.appLogo.setImageResource(app.getLogoResourceId());
//
// return appView;
// }
//
// private static class ViewHolder {
// TextView appName;
// ImageView appLogo;
// }
// }
// Path: SimpleWeatherForecast/src/main/java/fr/tvbarthel/apps/simpleweatherforcast/fragments/MoreAppsDialogFragment.java
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
import java.util.ArrayList;
import fr.tvbarthel.apps.simpleweatherforcast.R;
import fr.tvbarthel.apps.simpleweatherforcast.model.App;
import fr.tvbarthel.apps.simpleweatherforcast.ui.MoreAppsAdapter;
package fr.tvbarthel.apps.simpleweatherforcast.fragments;
public class MoreAppsDialogFragment extends DialogFragment {
private static final String URI_ROOT_MARKET = "market://details?id=";
private static final String URI_ROOT_PLAY_STORE = "http://play.google.com/store/apps/details?id=";
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
final LayoutInflater inflater = getActivity().getLayoutInflater();
final ListView listView = (ListView) inflater.inflate(R.layout.dialog_more_apps, null);
final AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(getActivity());
dialogBuilder.setPositiveButton(android.R.string.ok, null);
dialogBuilder.setTitle(R.string.dialog_more_apps_title);
dialogBuilder.setView(listView);
dialogBuilder.setInverseBackgroundForced(true);
| App chaseWhisply = new App(); |
tvbarthel/SimpleWeatherForecast | SimpleWeatherForecast/src/main/java/fr/tvbarthel/apps/simpleweatherforcast/fragments/MoreAppsDialogFragment.java | // Path: SimpleWeatherForecast/src/main/java/fr/tvbarthel/apps/simpleweatherforcast/model/App.java
// public class App {
//
// private Integer mNameResourceId;
// private Integer mLogoResourceId;
// private Integer mPackageNameResourceId;
//
// public Integer getNameResourceId() {
// return mNameResourceId;
// }
//
// public void setNameResourceId(Integer nameResourceId) {
// mNameResourceId = nameResourceId;
// }
//
// public Integer getLogoResourceId() {
// return mLogoResourceId;
// }
//
// public void setLogoResourceId(Integer logoResourceId) {
// mLogoResourceId = logoResourceId;
// }
//
// public Integer getPackageNameResourceId() {
// return mPackageNameResourceId;
// }
//
// public void setPackageNameResourceId(Integer packageNameResourceId) {
// mPackageNameResourceId = packageNameResourceId;
// }
// }
//
// Path: SimpleWeatherForecast/src/main/java/fr/tvbarthel/apps/simpleweatherforcast/ui/MoreAppsAdapter.java
// public class MoreAppsAdapter extends ArrayAdapter<App> {
//
//
// public MoreAppsAdapter(Context context, List<App> apps) {
// super(context, R.layout.row_more_apps, apps);
// }
//
// @Override
// public View getView(int position, View convertView, ViewGroup parent) {
// RelativeLayout appView = (RelativeLayout) convertView;
// App app = getItem(position);
//
// if (appView == null) {
// LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
// appView = (RelativeLayout) inflater.inflate(R.layout.row_more_apps, parent, false);
// ViewHolder holder = new ViewHolder();
// holder.appName = (TextView) appView.findViewById(R.id.row_more_apps_name);
// holder.appLogo = (ImageView) appView.findViewById(R.id.row_more_apps_logo);
// appView.setTag(holder);
// }
//
// ViewHolder holder = (ViewHolder) appView.getTag();
// holder.appName.setText(app.getNameResourceId());
// holder.appLogo.setImageResource(app.getLogoResourceId());
//
// return appView;
// }
//
// private static class ViewHolder {
// TextView appName;
// ImageView appLogo;
// }
// }
| import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
import java.util.ArrayList;
import fr.tvbarthel.apps.simpleweatherforcast.R;
import fr.tvbarthel.apps.simpleweatherforcast.model.App;
import fr.tvbarthel.apps.simpleweatherforcast.ui.MoreAppsAdapter; | package fr.tvbarthel.apps.simpleweatherforcast.fragments;
public class MoreAppsDialogFragment extends DialogFragment {
private static final String URI_ROOT_MARKET = "market://details?id=";
private static final String URI_ROOT_PLAY_STORE = "http://play.google.com/store/apps/details?id=";
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
final LayoutInflater inflater = getActivity().getLayoutInflater();
final ListView listView = (ListView) inflater.inflate(R.layout.dialog_more_apps, null);
final AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(getActivity());
dialogBuilder.setPositiveButton(android.R.string.ok, null);
dialogBuilder.setTitle(R.string.dialog_more_apps_title);
dialogBuilder.setView(listView);
dialogBuilder.setInverseBackgroundForced(true);
App chaseWhisply = new App();
chaseWhisply.setLogoResourceId(R.drawable.ic_chase_whisply);
chaseWhisply.setNameResourceId(R.string.dialog_more_apps_chase_whisply_app_name);
chaseWhisply.setPackageNameResourceId(R.string.dialog_more_apps_chase_whisply_package_name);
App googlyZoo = new App();
googlyZoo.setLogoResourceId(R.drawable.ic_googly_zoo);
googlyZoo.setNameResourceId(R.string.dialog_more_apps_googly_zoo_app_name);
googlyZoo.setPackageNameResourceId(R.string.dialog_more_apps_googly_zoo_package_name);
App simpleThermometer = new App();
simpleThermometer.setLogoResourceId(R.drawable.ic_simple_thermometer);
simpleThermometer.setNameResourceId(R.string.dialog_more_apps_simplethermometer_app_name);
simpleThermometer.setPackageNameResourceId(R.string.dialog_more_apps_simplethermometer_package_name);
final ArrayList<App> apps = new ArrayList<App>();
apps.add(chaseWhisply);
apps.add(googlyZoo);
apps.add(simpleThermometer);
| // Path: SimpleWeatherForecast/src/main/java/fr/tvbarthel/apps/simpleweatherforcast/model/App.java
// public class App {
//
// private Integer mNameResourceId;
// private Integer mLogoResourceId;
// private Integer mPackageNameResourceId;
//
// public Integer getNameResourceId() {
// return mNameResourceId;
// }
//
// public void setNameResourceId(Integer nameResourceId) {
// mNameResourceId = nameResourceId;
// }
//
// public Integer getLogoResourceId() {
// return mLogoResourceId;
// }
//
// public void setLogoResourceId(Integer logoResourceId) {
// mLogoResourceId = logoResourceId;
// }
//
// public Integer getPackageNameResourceId() {
// return mPackageNameResourceId;
// }
//
// public void setPackageNameResourceId(Integer packageNameResourceId) {
// mPackageNameResourceId = packageNameResourceId;
// }
// }
//
// Path: SimpleWeatherForecast/src/main/java/fr/tvbarthel/apps/simpleweatherforcast/ui/MoreAppsAdapter.java
// public class MoreAppsAdapter extends ArrayAdapter<App> {
//
//
// public MoreAppsAdapter(Context context, List<App> apps) {
// super(context, R.layout.row_more_apps, apps);
// }
//
// @Override
// public View getView(int position, View convertView, ViewGroup parent) {
// RelativeLayout appView = (RelativeLayout) convertView;
// App app = getItem(position);
//
// if (appView == null) {
// LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
// appView = (RelativeLayout) inflater.inflate(R.layout.row_more_apps, parent, false);
// ViewHolder holder = new ViewHolder();
// holder.appName = (TextView) appView.findViewById(R.id.row_more_apps_name);
// holder.appLogo = (ImageView) appView.findViewById(R.id.row_more_apps_logo);
// appView.setTag(holder);
// }
//
// ViewHolder holder = (ViewHolder) appView.getTag();
// holder.appName.setText(app.getNameResourceId());
// holder.appLogo.setImageResource(app.getLogoResourceId());
//
// return appView;
// }
//
// private static class ViewHolder {
// TextView appName;
// ImageView appLogo;
// }
// }
// Path: SimpleWeatherForecast/src/main/java/fr/tvbarthel/apps/simpleweatherforcast/fragments/MoreAppsDialogFragment.java
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
import java.util.ArrayList;
import fr.tvbarthel.apps.simpleweatherforcast.R;
import fr.tvbarthel.apps.simpleweatherforcast.model.App;
import fr.tvbarthel.apps.simpleweatherforcast.ui.MoreAppsAdapter;
package fr.tvbarthel.apps.simpleweatherforcast.fragments;
public class MoreAppsDialogFragment extends DialogFragment {
private static final String URI_ROOT_MARKET = "market://details?id=";
private static final String URI_ROOT_PLAY_STORE = "http://play.google.com/store/apps/details?id=";
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
final LayoutInflater inflater = getActivity().getLayoutInflater();
final ListView listView = (ListView) inflater.inflate(R.layout.dialog_more_apps, null);
final AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(getActivity());
dialogBuilder.setPositiveButton(android.R.string.ok, null);
dialogBuilder.setTitle(R.string.dialog_more_apps_title);
dialogBuilder.setView(listView);
dialogBuilder.setInverseBackgroundForced(true);
App chaseWhisply = new App();
chaseWhisply.setLogoResourceId(R.drawable.ic_chase_whisply);
chaseWhisply.setNameResourceId(R.string.dialog_more_apps_chase_whisply_app_name);
chaseWhisply.setPackageNameResourceId(R.string.dialog_more_apps_chase_whisply_package_name);
App googlyZoo = new App();
googlyZoo.setLogoResourceId(R.drawable.ic_googly_zoo);
googlyZoo.setNameResourceId(R.string.dialog_more_apps_googly_zoo_app_name);
googlyZoo.setPackageNameResourceId(R.string.dialog_more_apps_googly_zoo_package_name);
App simpleThermometer = new App();
simpleThermometer.setLogoResourceId(R.drawable.ic_simple_thermometer);
simpleThermometer.setNameResourceId(R.string.dialog_more_apps_simplethermometer_app_name);
simpleThermometer.setPackageNameResourceId(R.string.dialog_more_apps_simplethermometer_package_name);
final ArrayList<App> apps = new ArrayList<App>();
apps.add(chaseWhisply);
apps.add(googlyZoo);
apps.add(simpleThermometer);
| listView.setAdapter(new MoreAppsAdapter(getActivity(), apps)); |
buremba/hazelcast-modules | src/main/java/org/rakam/cache/hazelcast/hyperloglog/AsyncHyperLogLog.java | // Path: src/main/java/org/rakam/util/HLLWrapper.java
// public class HLLWrapper {
// final private static int SEED = 123456;
// private HLL hll;
//
// public HLLWrapper() {
// hll = new HLL(13/*log2m*/, 5/*registerWidth*/);
// }
//
// public HLLWrapper(byte[] bytes) {
// hll = HLL.fromBytes(bytes);
// }
//
// public long cardinality() {
// return hll.cardinality();
// }
//
// public void union(HLLWrapper hll) {
// this.hll.union(hll.hll);
// }
//
// public void addAll(Collection<String> coll) {
// for (String a : coll) {
// byte[] s = a.getBytes();
// hll.addRaw(MurmurHash3.murmurhash3x8632(s, 0, s.length, SEED));
// }
// }
//
// public void add(String obj) {
// if (obj == null)
// throw new IllegalArgumentException();
// byte[] s = obj.getBytes();
//
// hll.addRaw(MurmurHash3.murmurhash3x8632(s, 0, s.length, SEED));
// }
//
// public void set(byte[] bytes) {
// hll = HLL.fromBytes(bytes);
// }
//
// public byte[] bytes() {
// return hll.toBytes();
// }
//
// public void reset() {
// hll = new HLL(13/*log2m*/, 5/*registerWidth*/);
// }
// }
| import java.util.Collection;
import com.hazelcast.core.ICompletableFuture;
import org.rakam.util.HLLWrapper; | /**
* Created by buremba <Burak Emre Kabakcı> on 10/07/14.
*/
package org.rakam.cache.hazelcast.hyperloglog;
public interface AsyncHyperLogLog extends HyperLogLog {
ICompletableFuture<Void> asyncAdd(String item);
ICompletableFuture<Long> asyncCardinality();
| // Path: src/main/java/org/rakam/util/HLLWrapper.java
// public class HLLWrapper {
// final private static int SEED = 123456;
// private HLL hll;
//
// public HLLWrapper() {
// hll = new HLL(13/*log2m*/, 5/*registerWidth*/);
// }
//
// public HLLWrapper(byte[] bytes) {
// hll = HLL.fromBytes(bytes);
// }
//
// public long cardinality() {
// return hll.cardinality();
// }
//
// public void union(HLLWrapper hll) {
// this.hll.union(hll.hll);
// }
//
// public void addAll(Collection<String> coll) {
// for (String a : coll) {
// byte[] s = a.getBytes();
// hll.addRaw(MurmurHash3.murmurhash3x8632(s, 0, s.length, SEED));
// }
// }
//
// public void add(String obj) {
// if (obj == null)
// throw new IllegalArgumentException();
// byte[] s = obj.getBytes();
//
// hll.addRaw(MurmurHash3.murmurhash3x8632(s, 0, s.length, SEED));
// }
//
// public void set(byte[] bytes) {
// hll = HLL.fromBytes(bytes);
// }
//
// public byte[] bytes() {
// return hll.toBytes();
// }
//
// public void reset() {
// hll = new HLL(13/*log2m*/, 5/*registerWidth*/);
// }
// }
// Path: src/main/java/org/rakam/cache/hazelcast/hyperloglog/AsyncHyperLogLog.java
import java.util.Collection;
import com.hazelcast.core.ICompletableFuture;
import org.rakam.util.HLLWrapper;
/**
* Created by buremba <Burak Emre Kabakcı> on 10/07/14.
*/
package org.rakam.cache.hazelcast.hyperloglog;
public interface AsyncHyperLogLog extends HyperLogLog {
ICompletableFuture<Void> asyncAdd(String item);
ICompletableFuture<Long> asyncCardinality();
| ICompletableFuture<Void> asyncUnion(HLLWrapper hll); |
buremba/hazelcast-modules | src/main/java/org/rakam/cache/hazelcast/hyperloglog/client/ClientHyperLogLogProxy.java | // Path: src/main/java/org/rakam/cache/hazelcast/hyperloglog/HyperLogLog.java
// public interface HyperLogLog extends DistributedObject {
// /**
// * Returns the name of this HyperLogLog instance.
// *
// * @return name of this instance
// */
//
// String getName();
//
// /**
// * Returns the cardinality of the HyperLogLog container
// */
// public long cardinality();
//
// public void reset();
//
// /**
// * Unions given hll container with the internal one.
// *
// * @param hll the hll container to marge
// */
// public void union(HLLWrapper hll);
//
// public void addAll(Collection<String> coll);
//
// public void add(String obj);
// }
//
// Path: src/main/java/org/rakam/util/HLLWrapper.java
// public class HLLWrapper {
// final private static int SEED = 123456;
// private HLL hll;
//
// public HLLWrapper() {
// hll = new HLL(13/*log2m*/, 5/*registerWidth*/);
// }
//
// public HLLWrapper(byte[] bytes) {
// hll = HLL.fromBytes(bytes);
// }
//
// public long cardinality() {
// return hll.cardinality();
// }
//
// public void union(HLLWrapper hll) {
// this.hll.union(hll.hll);
// }
//
// public void addAll(Collection<String> coll) {
// for (String a : coll) {
// byte[] s = a.getBytes();
// hll.addRaw(MurmurHash3.murmurhash3x8632(s, 0, s.length, SEED));
// }
// }
//
// public void add(String obj) {
// if (obj == null)
// throw new IllegalArgumentException();
// byte[] s = obj.getBytes();
//
// hll.addRaw(MurmurHash3.murmurhash3x8632(s, 0, s.length, SEED));
// }
//
// public void set(byte[] bytes) {
// hll = HLL.fromBytes(bytes);
// }
//
// public byte[] bytes() {
// return hll.toBytes();
// }
//
// public void reset() {
// hll = new HLL(13/*log2m*/, 5/*registerWidth*/);
// }
// }
| import com.hazelcast.client.ClientRequest;
import com.hazelcast.client.spi.ClientProxy;
import com.hazelcast.nio.serialization.Data;
import org.rakam.cache.hazelcast.hyperloglog.HyperLogLog;
import org.rakam.util.HLLWrapper;
import java.util.Collection; |
protected <T> T invoke(ClientRequest req) {
return super.invoke(req, getKey());
}
private Data getKey() {
if (key == null) {
key = toData(name);
}
return key;
}
@Override
public String toString() {
return "HyperLogLog{" + "name='" + name + '\'' + '}';
}
@Override
public long cardinality() {
CardinalityRequest request = new CardinalityRequest(name);
return (Long) invoke(request);
}
@Override
public void reset() {
ResetRequest request = new ResetRequest(name);
invoke(request);
}
@Override | // Path: src/main/java/org/rakam/cache/hazelcast/hyperloglog/HyperLogLog.java
// public interface HyperLogLog extends DistributedObject {
// /**
// * Returns the name of this HyperLogLog instance.
// *
// * @return name of this instance
// */
//
// String getName();
//
// /**
// * Returns the cardinality of the HyperLogLog container
// */
// public long cardinality();
//
// public void reset();
//
// /**
// * Unions given hll container with the internal one.
// *
// * @param hll the hll container to marge
// */
// public void union(HLLWrapper hll);
//
// public void addAll(Collection<String> coll);
//
// public void add(String obj);
// }
//
// Path: src/main/java/org/rakam/util/HLLWrapper.java
// public class HLLWrapper {
// final private static int SEED = 123456;
// private HLL hll;
//
// public HLLWrapper() {
// hll = new HLL(13/*log2m*/, 5/*registerWidth*/);
// }
//
// public HLLWrapper(byte[] bytes) {
// hll = HLL.fromBytes(bytes);
// }
//
// public long cardinality() {
// return hll.cardinality();
// }
//
// public void union(HLLWrapper hll) {
// this.hll.union(hll.hll);
// }
//
// public void addAll(Collection<String> coll) {
// for (String a : coll) {
// byte[] s = a.getBytes();
// hll.addRaw(MurmurHash3.murmurhash3x8632(s, 0, s.length, SEED));
// }
// }
//
// public void add(String obj) {
// if (obj == null)
// throw new IllegalArgumentException();
// byte[] s = obj.getBytes();
//
// hll.addRaw(MurmurHash3.murmurhash3x8632(s, 0, s.length, SEED));
// }
//
// public void set(byte[] bytes) {
// hll = HLL.fromBytes(bytes);
// }
//
// public byte[] bytes() {
// return hll.toBytes();
// }
//
// public void reset() {
// hll = new HLL(13/*log2m*/, 5/*registerWidth*/);
// }
// }
// Path: src/main/java/org/rakam/cache/hazelcast/hyperloglog/client/ClientHyperLogLogProxy.java
import com.hazelcast.client.ClientRequest;
import com.hazelcast.client.spi.ClientProxy;
import com.hazelcast.nio.serialization.Data;
import org.rakam.cache.hazelcast.hyperloglog.HyperLogLog;
import org.rakam.util.HLLWrapper;
import java.util.Collection;
protected <T> T invoke(ClientRequest req) {
return super.invoke(req, getKey());
}
private Data getKey() {
if (key == null) {
key = toData(name);
}
return key;
}
@Override
public String toString() {
return "HyperLogLog{" + "name='" + name + '\'' + '}';
}
@Override
public long cardinality() {
CardinalityRequest request = new CardinalityRequest(name);
return (Long) invoke(request);
}
@Override
public void reset() {
ResetRequest request = new ResetRequest(name);
invoke(request);
}
@Override | public void union(HLLWrapper hll) { |
buremba/hazelcast-modules | src/main/java/org/rakam/cache/hazelcast/hyperloglog/client/WriteRequest.java | // Path: src/main/java/org/rakam/cache/hazelcast/hyperloglog/HyperLogLogService.java
// public class HyperLogLogService implements ManagedService, RemoteService, MigrationAwareService {
//
// public static final String SERVICE_NAME = "rakam:hyperLogLogService";
//
// private NodeEngine nodeEngine;
// private final ConcurrentMap<String, HLLWrapper> containers = new ConcurrentHashMap<String, HLLWrapper>();
// private final ConstructorFunction<String, HLLWrapper> CountersConstructorFunction =
// new ConstructorFunction<String, HLLWrapper>() {
// public HLLWrapper createNew(String key) {
// return new HLLWrapper();
// }
// };
//
// public HyperLogLogService() {
// }
//
// public HLLWrapper getHLL(String name) {
// return getOrPutIfAbsent(containers, name, CountersConstructorFunction);
// }
//
// @Override
// public void init(NodeEngine nodeEngine, Properties properties) {
// this.nodeEngine = nodeEngine;
// }
//
// @Override
// public void reset() {
// containers.clear();
// }
//
// @Override
// public void shutdown(boolean terminate) {
// reset();
// }
//
// @Override
// public HyperLogLogProxy createDistributedObject(String name) {
// return new HyperLogLogProxy(name, nodeEngine, this);
// }
//
// @Override
// public void destroyDistributedObject(String name) {
// containers.remove(name);
// }
//
// @Override
// public void beforeMigration(PartitionMigrationEvent partitionMigrationEvent) {
// }
//
// @Override
// public Operation prepareReplicationOperation(PartitionReplicationEvent event) {
//
// Map<String, byte[]> data = new HashMap<String, byte[]>();
// int partitionId = event.getPartitionId();
// for (String name : containers.keySet()) {
// if (partitionId == getPartitionId(name)) {
// HLLWrapper number = containers.get(name);
// data.put(name, number.bytes());
// }
// }
// return data.isEmpty() ? null : new HyperLogLogReplicationOperation(data);
// }
//
// private int getPartitionId(String name) {
// InternalPartitionService partitionService = nodeEngine.getPartitionService();
// String partitionKey = getPartitionKey(name);
// return partitionService.getPartitionId(partitionKey);
// }
//
// @Override
// public void commitMigration(PartitionMigrationEvent partitionMigrationEvent) {
// if (partitionMigrationEvent.getMigrationEndpoint() == MigrationEndpoint.SOURCE) {
// removePartition(partitionMigrationEvent.getPartitionId());
// }
// }
//
// @Override
// public void rollbackMigration(PartitionMigrationEvent partitionMigrationEvent) {
// if (partitionMigrationEvent.getMigrationEndpoint() == MigrationEndpoint.DESTINATION) {
// removePartition(partitionMigrationEvent.getPartitionId());
// }
// }
//
// @Override
// public void clearPartitionReplica(int partitionId) {
// removePartition(partitionId);
// }
//
// public void removePartition(int partitionId) {
// final Iterator<String> iterator = containers.keySet().iterator();
// while (iterator.hasNext()) {
// String name = iterator.next();
// if (getPartitionId(name) == partitionId) {
// iterator.remove();
// }
// }
// }
// }
| import com.hazelcast.client.ClientEngine;
import com.hazelcast.client.PartitionClientRequest;
import com.hazelcast.client.SecureRequest;
import com.hazelcast.nio.serialization.Data;
import com.hazelcast.nio.serialization.Portable;
import com.hazelcast.security.permission.ActionConstants;
import com.hazelcast.security.permission.AtomicLongPermission;
import org.rakam.cache.hazelcast.hyperloglog.HyperLogLogService;
import java.security.Permission; | /**
* Created by buremba <Burak Emre Kabakcı> on 10/07/14.
*/
package org.rakam.cache.hazelcast.hyperloglog.client;
public abstract class WriteRequest extends PartitionClientRequest implements Portable, SecureRequest {
protected String name;
protected WriteRequest() {
}
protected WriteRequest(String name) {
this.name = name;
}
@Override
protected int getPartition() {
ClientEngine clientEngine = getClientEngine();
//Data key = serializationService.toData(name);
Data key = clientEngine.getSerializationService().toData(name);
return clientEngine.getPartitionService().getPartitionId(key);
}
@Override
public String getServiceName() { | // Path: src/main/java/org/rakam/cache/hazelcast/hyperloglog/HyperLogLogService.java
// public class HyperLogLogService implements ManagedService, RemoteService, MigrationAwareService {
//
// public static final String SERVICE_NAME = "rakam:hyperLogLogService";
//
// private NodeEngine nodeEngine;
// private final ConcurrentMap<String, HLLWrapper> containers = new ConcurrentHashMap<String, HLLWrapper>();
// private final ConstructorFunction<String, HLLWrapper> CountersConstructorFunction =
// new ConstructorFunction<String, HLLWrapper>() {
// public HLLWrapper createNew(String key) {
// return new HLLWrapper();
// }
// };
//
// public HyperLogLogService() {
// }
//
// public HLLWrapper getHLL(String name) {
// return getOrPutIfAbsent(containers, name, CountersConstructorFunction);
// }
//
// @Override
// public void init(NodeEngine nodeEngine, Properties properties) {
// this.nodeEngine = nodeEngine;
// }
//
// @Override
// public void reset() {
// containers.clear();
// }
//
// @Override
// public void shutdown(boolean terminate) {
// reset();
// }
//
// @Override
// public HyperLogLogProxy createDistributedObject(String name) {
// return new HyperLogLogProxy(name, nodeEngine, this);
// }
//
// @Override
// public void destroyDistributedObject(String name) {
// containers.remove(name);
// }
//
// @Override
// public void beforeMigration(PartitionMigrationEvent partitionMigrationEvent) {
// }
//
// @Override
// public Operation prepareReplicationOperation(PartitionReplicationEvent event) {
//
// Map<String, byte[]> data = new HashMap<String, byte[]>();
// int partitionId = event.getPartitionId();
// for (String name : containers.keySet()) {
// if (partitionId == getPartitionId(name)) {
// HLLWrapper number = containers.get(name);
// data.put(name, number.bytes());
// }
// }
// return data.isEmpty() ? null : new HyperLogLogReplicationOperation(data);
// }
//
// private int getPartitionId(String name) {
// InternalPartitionService partitionService = nodeEngine.getPartitionService();
// String partitionKey = getPartitionKey(name);
// return partitionService.getPartitionId(partitionKey);
// }
//
// @Override
// public void commitMigration(PartitionMigrationEvent partitionMigrationEvent) {
// if (partitionMigrationEvent.getMigrationEndpoint() == MigrationEndpoint.SOURCE) {
// removePartition(partitionMigrationEvent.getPartitionId());
// }
// }
//
// @Override
// public void rollbackMigration(PartitionMigrationEvent partitionMigrationEvent) {
// if (partitionMigrationEvent.getMigrationEndpoint() == MigrationEndpoint.DESTINATION) {
// removePartition(partitionMigrationEvent.getPartitionId());
// }
// }
//
// @Override
// public void clearPartitionReplica(int partitionId) {
// removePartition(partitionId);
// }
//
// public void removePartition(int partitionId) {
// final Iterator<String> iterator = containers.keySet().iterator();
// while (iterator.hasNext()) {
// String name = iterator.next();
// if (getPartitionId(name) == partitionId) {
// iterator.remove();
// }
// }
// }
// }
// Path: src/main/java/org/rakam/cache/hazelcast/hyperloglog/client/WriteRequest.java
import com.hazelcast.client.ClientEngine;
import com.hazelcast.client.PartitionClientRequest;
import com.hazelcast.client.SecureRequest;
import com.hazelcast.nio.serialization.Data;
import com.hazelcast.nio.serialization.Portable;
import com.hazelcast.security.permission.ActionConstants;
import com.hazelcast.security.permission.AtomicLongPermission;
import org.rakam.cache.hazelcast.hyperloglog.HyperLogLogService;
import java.security.Permission;
/**
* Created by buremba <Burak Emre Kabakcı> on 10/07/14.
*/
package org.rakam.cache.hazelcast.hyperloglog.client;
public abstract class WriteRequest extends PartitionClientRequest implements Portable, SecureRequest {
protected String name;
protected WriteRequest() {
}
protected WriteRequest(String name) {
this.name = name;
}
@Override
protected int getPartition() {
ClientEngine clientEngine = getClientEngine();
//Data key = serializationService.toData(name);
Data key = clientEngine.getSerializationService().toData(name);
return clientEngine.getPartitionService().getPartitionId(key);
}
@Override
public String getServiceName() { | return HyperLogLogService.SERVICE_NAME; |
buremba/hazelcast-modules | src/main/java/org/rakam/cache/hazelcast/hyperloglog/client/UnionRequest.java | // Path: src/main/java/org/rakam/cache/hazelcast/hyperloglog/operations/UnionOperation.java
// public class UnionOperation extends HyperLogLogBackupAwareOperation {
//
// private HLLWrapper hll;
//
// public UnionOperation() {
// }
//
// public UnionOperation(String name, HLLWrapper hll) {
// super(name);
// this.hll = hll;
// }
//
// @Override
// public void run() throws Exception {
// HLLWrapper number = getHLL();
// number.union(hll);
// }
//
// @Override
// public int getId() {
// return HyperLogLogSerializerFactory.UNION;
// }
//
// @Override
// protected void writeInternal(ObjectDataOutput out) throws IOException {
// super.writeInternal(out);
// byte[] bytes = hll.bytes();
// out.writeInt(bytes.length);
// out.write(bytes);
// }
//
// @Override
// protected void readInternal(ObjectDataInput in) throws IOException {
// super.readInternal(in);
// int size = in.readInt();
// byte[] rawHll = new byte[size];
// in.readFully(rawHll);
// hll = new HLLWrapper(rawHll);
// }
//
// @Override
// public Operation getBackupOperation() {
// return new UnionBackupOperation(name, hll);
// }
// }
//
// Path: src/main/java/org/rakam/util/HLLWrapper.java
// public class HLLWrapper {
// final private static int SEED = 123456;
// private HLL hll;
//
// public HLLWrapper() {
// hll = new HLL(13/*log2m*/, 5/*registerWidth*/);
// }
//
// public HLLWrapper(byte[] bytes) {
// hll = HLL.fromBytes(bytes);
// }
//
// public long cardinality() {
// return hll.cardinality();
// }
//
// public void union(HLLWrapper hll) {
// this.hll.union(hll.hll);
// }
//
// public void addAll(Collection<String> coll) {
// for (String a : coll) {
// byte[] s = a.getBytes();
// hll.addRaw(MurmurHash3.murmurhash3x8632(s, 0, s.length, SEED));
// }
// }
//
// public void add(String obj) {
// if (obj == null)
// throw new IllegalArgumentException();
// byte[] s = obj.getBytes();
//
// hll.addRaw(MurmurHash3.murmurhash3x8632(s, 0, s.length, SEED));
// }
//
// public void set(byte[] bytes) {
// hll = HLL.fromBytes(bytes);
// }
//
// public byte[] bytes() {
// return hll.toBytes();
// }
//
// public void reset() {
// hll = new HLL(13/*log2m*/, 5/*registerWidth*/);
// }
// }
| import com.hazelcast.nio.ObjectDataInput;
import com.hazelcast.nio.ObjectDataOutput;
import com.hazelcast.nio.serialization.PortableReader;
import com.hazelcast.nio.serialization.PortableWriter;
import com.hazelcast.spi.Operation;
import org.rakam.cache.hazelcast.hyperloglog.operations.UnionOperation;
import org.rakam.util.HLLWrapper;
import java.io.IOException; | /**
* Created by buremba <Burak Emre Kabakcı> on 10/07/14.
*/
package org.rakam.cache.hazelcast.hyperloglog.client;
/**
* Created by buremba on 10/07/14.
*/
public class UnionRequest extends WriteRequest {
HLLWrapper hll;
public UnionRequest(String name, HLLWrapper hll) {
super(name);
this.hll = hll;
}
public UnionRequest() {
}
@Override
protected Operation prepareOperation() { | // Path: src/main/java/org/rakam/cache/hazelcast/hyperloglog/operations/UnionOperation.java
// public class UnionOperation extends HyperLogLogBackupAwareOperation {
//
// private HLLWrapper hll;
//
// public UnionOperation() {
// }
//
// public UnionOperation(String name, HLLWrapper hll) {
// super(name);
// this.hll = hll;
// }
//
// @Override
// public void run() throws Exception {
// HLLWrapper number = getHLL();
// number.union(hll);
// }
//
// @Override
// public int getId() {
// return HyperLogLogSerializerFactory.UNION;
// }
//
// @Override
// protected void writeInternal(ObjectDataOutput out) throws IOException {
// super.writeInternal(out);
// byte[] bytes = hll.bytes();
// out.writeInt(bytes.length);
// out.write(bytes);
// }
//
// @Override
// protected void readInternal(ObjectDataInput in) throws IOException {
// super.readInternal(in);
// int size = in.readInt();
// byte[] rawHll = new byte[size];
// in.readFully(rawHll);
// hll = new HLLWrapper(rawHll);
// }
//
// @Override
// public Operation getBackupOperation() {
// return new UnionBackupOperation(name, hll);
// }
// }
//
// Path: src/main/java/org/rakam/util/HLLWrapper.java
// public class HLLWrapper {
// final private static int SEED = 123456;
// private HLL hll;
//
// public HLLWrapper() {
// hll = new HLL(13/*log2m*/, 5/*registerWidth*/);
// }
//
// public HLLWrapper(byte[] bytes) {
// hll = HLL.fromBytes(bytes);
// }
//
// public long cardinality() {
// return hll.cardinality();
// }
//
// public void union(HLLWrapper hll) {
// this.hll.union(hll.hll);
// }
//
// public void addAll(Collection<String> coll) {
// for (String a : coll) {
// byte[] s = a.getBytes();
// hll.addRaw(MurmurHash3.murmurhash3x8632(s, 0, s.length, SEED));
// }
// }
//
// public void add(String obj) {
// if (obj == null)
// throw new IllegalArgumentException();
// byte[] s = obj.getBytes();
//
// hll.addRaw(MurmurHash3.murmurhash3x8632(s, 0, s.length, SEED));
// }
//
// public void set(byte[] bytes) {
// hll = HLL.fromBytes(bytes);
// }
//
// public byte[] bytes() {
// return hll.toBytes();
// }
//
// public void reset() {
// hll = new HLL(13/*log2m*/, 5/*registerWidth*/);
// }
// }
// Path: src/main/java/org/rakam/cache/hazelcast/hyperloglog/client/UnionRequest.java
import com.hazelcast.nio.ObjectDataInput;
import com.hazelcast.nio.ObjectDataOutput;
import com.hazelcast.nio.serialization.PortableReader;
import com.hazelcast.nio.serialization.PortableWriter;
import com.hazelcast.spi.Operation;
import org.rakam.cache.hazelcast.hyperloglog.operations.UnionOperation;
import org.rakam.util.HLLWrapper;
import java.io.IOException;
/**
* Created by buremba <Burak Emre Kabakcı> on 10/07/14.
*/
package org.rakam.cache.hazelcast.hyperloglog.client;
/**
* Created by buremba on 10/07/14.
*/
public class UnionRequest extends WriteRequest {
HLLWrapper hll;
public UnionRequest(String name, HLLWrapper hll) {
super(name);
this.hll = hll;
}
public UnionRequest() {
}
@Override
protected Operation prepareOperation() { | return new UnionOperation(name, hll); |
buremba/hazelcast-modules | src/main/java/org/rakam/cache/hazelcast/hyperloglog/client/AddRequest.java | // Path: src/main/java/org/rakam/cache/hazelcast/hyperloglog/operations/AddOperation.java
// public class AddOperation extends HyperLogLogBackupAwareOperation {
//
// private String item;
//
// public AddOperation() {
// }
//
// public AddOperation(String name, String item) {
// super(name);
// this.item = item;
// }
//
// @Override
// public void run() throws IllegalArgumentException {
// HLLWrapper hll = getHLL();
// hll.add(item);
// }
//
// @Override
// public int getId() {
// return HyperLogLogSerializerFactory.ADD;
// }
//
// @Override
// protected void writeInternal(ObjectDataOutput out) throws IOException {
// super.writeInternal(out);
// out.writeUTF(item);
// }
//
// @Override
// protected void readInternal(ObjectDataInput in) throws IOException {
// super.readInternal(in);
// item = in.readUTF();
// }
//
// @Override
// public Operation getBackupOperation() {
// return new AddBackupOperation(name, item);
// }
// }
| import com.hazelcast.nio.serialization.PortableReader;
import com.hazelcast.nio.serialization.PortableWriter;
import com.hazelcast.spi.Operation;
import org.rakam.cache.hazelcast.hyperloglog.operations.AddOperation;
import java.io.IOException; | /**
* Created by buremba <Burak Emre Kabakcı> on 10/07/14.
*/
package org.rakam.cache.hazelcast.hyperloglog.client;
public class AddRequest extends WriteRequest {
private String value;
public AddRequest() {
}
protected AddRequest(String name, String value) {
this.name = name;
this.value = value;
}
@Override
protected Operation prepareOperation() { | // Path: src/main/java/org/rakam/cache/hazelcast/hyperloglog/operations/AddOperation.java
// public class AddOperation extends HyperLogLogBackupAwareOperation {
//
// private String item;
//
// public AddOperation() {
// }
//
// public AddOperation(String name, String item) {
// super(name);
// this.item = item;
// }
//
// @Override
// public void run() throws IllegalArgumentException {
// HLLWrapper hll = getHLL();
// hll.add(item);
// }
//
// @Override
// public int getId() {
// return HyperLogLogSerializerFactory.ADD;
// }
//
// @Override
// protected void writeInternal(ObjectDataOutput out) throws IOException {
// super.writeInternal(out);
// out.writeUTF(item);
// }
//
// @Override
// protected void readInternal(ObjectDataInput in) throws IOException {
// super.readInternal(in);
// item = in.readUTF();
// }
//
// @Override
// public Operation getBackupOperation() {
// return new AddBackupOperation(name, item);
// }
// }
// Path: src/main/java/org/rakam/cache/hazelcast/hyperloglog/client/AddRequest.java
import com.hazelcast.nio.serialization.PortableReader;
import com.hazelcast.nio.serialization.PortableWriter;
import com.hazelcast.spi.Operation;
import org.rakam.cache.hazelcast.hyperloglog.operations.AddOperation;
import java.io.IOException;
/**
* Created by buremba <Burak Emre Kabakcı> on 10/07/14.
*/
package org.rakam.cache.hazelcast.hyperloglog.client;
public class AddRequest extends WriteRequest {
private String value;
public AddRequest() {
}
protected AddRequest(String name, String value) {
this.name = name;
this.value = value;
}
@Override
protected Operation prepareOperation() { | return new AddOperation(name, value); |
buremba/hazelcast-modules | src/test/java/org/rakam/cache/hazelcast/hyperloglog/HLLTest.java | // Path: src/main/java/org/rakam/util/HLLWrapper.java
// public class HLLWrapper {
// final private static int SEED = 123456;
// private HLL hll;
//
// public HLLWrapper() {
// hll = new HLL(13/*log2m*/, 5/*registerWidth*/);
// }
//
// public HLLWrapper(byte[] bytes) {
// hll = HLL.fromBytes(bytes);
// }
//
// public long cardinality() {
// return hll.cardinality();
// }
//
// public void union(HLLWrapper hll) {
// this.hll.union(hll.hll);
// }
//
// public void addAll(Collection<String> coll) {
// for (String a : coll) {
// byte[] s = a.getBytes();
// hll.addRaw(MurmurHash3.murmurhash3x8632(s, 0, s.length, SEED));
// }
// }
//
// public void add(String obj) {
// if (obj == null)
// throw new IllegalArgumentException();
// byte[] s = obj.getBytes();
//
// hll.addRaw(MurmurHash3.murmurhash3x8632(s, 0, s.length, SEED));
// }
//
// public void set(byte[] bytes) {
// hll = HLL.fromBytes(bytes);
// }
//
// public byte[] bytes() {
// return hll.toBytes();
// }
//
// public void reset() {
// hll = new HLL(13/*log2m*/, 5/*registerWidth*/);
// }
// }
| import com.hazelcast.client.HazelcastClient;
import com.hazelcast.core.Hazelcast;
import com.hazelcast.core.HazelcastInstance;
import org.junit.*;
import org.rakam.util.HLLWrapper;
import java.io.IOException;
import java.util.ArrayList;
import static junit.framework.Assert.assertEquals; |
assertEquals(1, hll0.cardinality());
assertEquals(1, hll1.cardinality());
assertEquals(1, hllClient.cardinality());
}
@Test
public void addAll_testAcrossServers() throws Exception {
hll0 = server0.getDistributedObject(HyperLogLogService.SERVICE_NAME, name);
hll1 = server0.getDistributedObject(HyperLogLogService.SERVICE_NAME, name);
ArrayList<String> list = new ArrayList<String>() {{
add("TEST0");
add("TEST1");
add("TEST2");
}};
hll0.addAll(list);
hll1.addAll(list);
assertEquals(3, hll0.cardinality());
assertEquals(3, hll1.cardinality());
assertEquals(3, hllClient.cardinality());
}
@Test
public void union_testAcrossServers() throws Exception {
hll0 = server0.getDistributedObject(HyperLogLogService.SERVICE_NAME, name);
hll1 = server0.getDistributedObject(HyperLogLogService.SERVICE_NAME, name);
hll0.add("TEST1"); | // Path: src/main/java/org/rakam/util/HLLWrapper.java
// public class HLLWrapper {
// final private static int SEED = 123456;
// private HLL hll;
//
// public HLLWrapper() {
// hll = new HLL(13/*log2m*/, 5/*registerWidth*/);
// }
//
// public HLLWrapper(byte[] bytes) {
// hll = HLL.fromBytes(bytes);
// }
//
// public long cardinality() {
// return hll.cardinality();
// }
//
// public void union(HLLWrapper hll) {
// this.hll.union(hll.hll);
// }
//
// public void addAll(Collection<String> coll) {
// for (String a : coll) {
// byte[] s = a.getBytes();
// hll.addRaw(MurmurHash3.murmurhash3x8632(s, 0, s.length, SEED));
// }
// }
//
// public void add(String obj) {
// if (obj == null)
// throw new IllegalArgumentException();
// byte[] s = obj.getBytes();
//
// hll.addRaw(MurmurHash3.murmurhash3x8632(s, 0, s.length, SEED));
// }
//
// public void set(byte[] bytes) {
// hll = HLL.fromBytes(bytes);
// }
//
// public byte[] bytes() {
// return hll.toBytes();
// }
//
// public void reset() {
// hll = new HLL(13/*log2m*/, 5/*registerWidth*/);
// }
// }
// Path: src/test/java/org/rakam/cache/hazelcast/hyperloglog/HLLTest.java
import com.hazelcast.client.HazelcastClient;
import com.hazelcast.core.Hazelcast;
import com.hazelcast.core.HazelcastInstance;
import org.junit.*;
import org.rakam.util.HLLWrapper;
import java.io.IOException;
import java.util.ArrayList;
import static junit.framework.Assert.assertEquals;
assertEquals(1, hll0.cardinality());
assertEquals(1, hll1.cardinality());
assertEquals(1, hllClient.cardinality());
}
@Test
public void addAll_testAcrossServers() throws Exception {
hll0 = server0.getDistributedObject(HyperLogLogService.SERVICE_NAME, name);
hll1 = server0.getDistributedObject(HyperLogLogService.SERVICE_NAME, name);
ArrayList<String> list = new ArrayList<String>() {{
add("TEST0");
add("TEST1");
add("TEST2");
}};
hll0.addAll(list);
hll1.addAll(list);
assertEquals(3, hll0.cardinality());
assertEquals(3, hll1.cardinality());
assertEquals(3, hllClient.cardinality());
}
@Test
public void union_testAcrossServers() throws Exception {
hll0 = server0.getDistributedObject(HyperLogLogService.SERVICE_NAME, name);
hll1 = server0.getDistributedObject(HyperLogLogService.SERVICE_NAME, name);
hll0.add("TEST1"); | HLLWrapper hll = new HLLWrapper(); |
buremba/hazelcast-modules | src/main/java/org/rakam/cache/hazelcast/treemap/client/ClientTreeMapProxyFactory.java | // Path: src/main/java/org/rakam/cache/hazelcast/treemap/TreeMapService.java
// public class TreeMapService implements ManagedService, RemoteService, MigrationAwareService {
//
// public static final String SERVICE_NAME = "rakam:treeMapService";
//
// private NodeEngine nodeEngine;
// private final ConcurrentMap<String, OrderedCounterMap> containers = new ConcurrentHashMap<String, OrderedCounterMap>();
// private final ConstructorFunction<String, OrderedCounterMap> CountersConstructorFunction =
// new ConstructorFunction<String, OrderedCounterMap>() {
// public OrderedCounterMap createNew(String key) {
// return new OrderedCounterMap();
// }
// };
//
// public TreeMapService() {
// }
//
// public OrderedCounterMap getHLL(String name) {
// return getOrPutIfAbsent(containers, name, CountersConstructorFunction);
// }
//
// public void setHLL(String name, OrderedCounterMap map) {
// containers.put(name, map);
// }
//
// @Override
// public void init(NodeEngine nodeEngine, Properties properties) {
// this.nodeEngine = nodeEngine;
// }
//
// @Override
// public void reset() {
// containers.clear();
// }
//
// @Override
// public void shutdown(boolean terminate) {
// reset();
// }
//
// @Override
// public TreeMapProxy createDistributedObject(String name) {
// return new TreeMapProxy(name, nodeEngine, this);
// }
//
// @Override
// public void destroyDistributedObject(String name) {
// containers.remove(name);
// }
//
// @Override
// public void beforeMigration(PartitionMigrationEvent partitionMigrationEvent) {
// }
//
// @Override
// public Operation prepareReplicationOperation(PartitionReplicationEvent event) {
// Map<String, OrderedCounterMap> data = new HashMap();
// int partitionId = event.getPartitionId();
// for (String name : containers.keySet()) {
// if (partitionId == getPartitionId(name)) {
// OrderedCounterMap number = containers.get(name);
// data.put(name, number);
// }
// }
// return data.isEmpty() ? null : new TreeMapReplicationOperation(data);
// }
//
// private int getPartitionId(String name) {
// InternalPartitionService partitionService = nodeEngine.getPartitionService();
// String partitionKey = getPartitionKey(name);
// return partitionService.getPartitionId(partitionKey);
// }
//
// @Override
// public void commitMigration(PartitionMigrationEvent partitionMigrationEvent) {
// if (partitionMigrationEvent.getMigrationEndpoint() == MigrationEndpoint.SOURCE) {
// removePartition(partitionMigrationEvent.getPartitionId());
// }
// }
//
// @Override
// public void rollbackMigration(PartitionMigrationEvent partitionMigrationEvent) {
// if (partitionMigrationEvent.getMigrationEndpoint() == MigrationEndpoint.DESTINATION) {
// removePartition(partitionMigrationEvent.getPartitionId());
// }
// }
//
// @Override
// public void clearPartitionReplica(int partitionId) {
// removePartition(partitionId);
// }
//
// public void removePartition(int partitionId) {
// final Iterator<String> iterator = containers.keySet().iterator();
// while (iterator.hasNext()) {
// String name = iterator.next();
// if (getPartitionId(name) == partitionId) {
// iterator.remove();
// }
// }
// }
// }
| import com.hazelcast.client.spi.ClientProxyFactory;
import org.rakam.cache.hazelcast.treemap.TreeMapService;
import com.hazelcast.client.spi.ClientProxy; | /**
* Created by buremba <Burak Emre Kabakcı> on 10/07/14.
*/
package org.rakam.cache.hazelcast.treemap.client;
public class ClientTreeMapProxyFactory implements ClientProxyFactory {
@Override
public ClientProxy create(String s) { | // Path: src/main/java/org/rakam/cache/hazelcast/treemap/TreeMapService.java
// public class TreeMapService implements ManagedService, RemoteService, MigrationAwareService {
//
// public static final String SERVICE_NAME = "rakam:treeMapService";
//
// private NodeEngine nodeEngine;
// private final ConcurrentMap<String, OrderedCounterMap> containers = new ConcurrentHashMap<String, OrderedCounterMap>();
// private final ConstructorFunction<String, OrderedCounterMap> CountersConstructorFunction =
// new ConstructorFunction<String, OrderedCounterMap>() {
// public OrderedCounterMap createNew(String key) {
// return new OrderedCounterMap();
// }
// };
//
// public TreeMapService() {
// }
//
// public OrderedCounterMap getHLL(String name) {
// return getOrPutIfAbsent(containers, name, CountersConstructorFunction);
// }
//
// public void setHLL(String name, OrderedCounterMap map) {
// containers.put(name, map);
// }
//
// @Override
// public void init(NodeEngine nodeEngine, Properties properties) {
// this.nodeEngine = nodeEngine;
// }
//
// @Override
// public void reset() {
// containers.clear();
// }
//
// @Override
// public void shutdown(boolean terminate) {
// reset();
// }
//
// @Override
// public TreeMapProxy createDistributedObject(String name) {
// return new TreeMapProxy(name, nodeEngine, this);
// }
//
// @Override
// public void destroyDistributedObject(String name) {
// containers.remove(name);
// }
//
// @Override
// public void beforeMigration(PartitionMigrationEvent partitionMigrationEvent) {
// }
//
// @Override
// public Operation prepareReplicationOperation(PartitionReplicationEvent event) {
// Map<String, OrderedCounterMap> data = new HashMap();
// int partitionId = event.getPartitionId();
// for (String name : containers.keySet()) {
// if (partitionId == getPartitionId(name)) {
// OrderedCounterMap number = containers.get(name);
// data.put(name, number);
// }
// }
// return data.isEmpty() ? null : new TreeMapReplicationOperation(data);
// }
//
// private int getPartitionId(String name) {
// InternalPartitionService partitionService = nodeEngine.getPartitionService();
// String partitionKey = getPartitionKey(name);
// return partitionService.getPartitionId(partitionKey);
// }
//
// @Override
// public void commitMigration(PartitionMigrationEvent partitionMigrationEvent) {
// if (partitionMigrationEvent.getMigrationEndpoint() == MigrationEndpoint.SOURCE) {
// removePartition(partitionMigrationEvent.getPartitionId());
// }
// }
//
// @Override
// public void rollbackMigration(PartitionMigrationEvent partitionMigrationEvent) {
// if (partitionMigrationEvent.getMigrationEndpoint() == MigrationEndpoint.DESTINATION) {
// removePartition(partitionMigrationEvent.getPartitionId());
// }
// }
//
// @Override
// public void clearPartitionReplica(int partitionId) {
// removePartition(partitionId);
// }
//
// public void removePartition(int partitionId) {
// final Iterator<String> iterator = containers.keySet().iterator();
// while (iterator.hasNext()) {
// String name = iterator.next();
// if (getPartitionId(name) == partitionId) {
// iterator.remove();
// }
// }
// }
// }
// Path: src/main/java/org/rakam/cache/hazelcast/treemap/client/ClientTreeMapProxyFactory.java
import com.hazelcast.client.spi.ClientProxyFactory;
import org.rakam.cache.hazelcast.treemap.TreeMapService;
import com.hazelcast.client.spi.ClientProxy;
/**
* Created by buremba <Burak Emre Kabakcı> on 10/07/14.
*/
package org.rakam.cache.hazelcast.treemap.client;
public class ClientTreeMapProxyFactory implements ClientProxyFactory {
@Override
public ClientProxy create(String s) { | return new ClientTreeMapProxy("ClientTreeMapProxy", TreeMapService.SERVICE_NAME, s); |
buremba/hazelcast-modules | src/main/java/org/rakam/cache/hazelcast/hyperloglog/client/CardinalityRequest.java | // Path: src/main/java/org/rakam/cache/hazelcast/hyperloglog/operations/CardinalityOperation.java
// public class CardinalityOperation extends HyperLogLogBaseOperation {
//
// private long returnValue;
//
// public CardinalityOperation() {
// }
//
// public CardinalityOperation(String name) {
// super(name);
// }
//
// @Override
// public void run() throws Exception {
// HLLWrapper number = getHLL();
// this.returnValue = number.cardinality();
// }
//
// @Override
// public Object getResponse() {
// return returnValue;
// }
//
// @Override
// public int getId() {
// return HyperLogLogSerializerFactory.CARDINALITY;
// }
//
// @Override
// protected void writeInternal(ObjectDataOutput out) throws IOException {
// super.writeInternal(out);
// }
//
// @Override
// protected void readInternal(ObjectDataInput in) throws IOException {
// super.readInternal(in);
// }
// }
| import com.hazelcast.spi.Operation;
import org.rakam.cache.hazelcast.hyperloglog.operations.CardinalityOperation; | /**
* Created by buremba <Burak Emre Kabakcı> on 10/07/14.
*/
package org.rakam.cache.hazelcast.hyperloglog.client;
public class CardinalityRequest extends ReadRequest {
public CardinalityRequest(String name) {
super(name);
}
public CardinalityRequest() {
}
@Override
protected Operation prepareOperation() { | // Path: src/main/java/org/rakam/cache/hazelcast/hyperloglog/operations/CardinalityOperation.java
// public class CardinalityOperation extends HyperLogLogBaseOperation {
//
// private long returnValue;
//
// public CardinalityOperation() {
// }
//
// public CardinalityOperation(String name) {
// super(name);
// }
//
// @Override
// public void run() throws Exception {
// HLLWrapper number = getHLL();
// this.returnValue = number.cardinality();
// }
//
// @Override
// public Object getResponse() {
// return returnValue;
// }
//
// @Override
// public int getId() {
// return HyperLogLogSerializerFactory.CARDINALITY;
// }
//
// @Override
// protected void writeInternal(ObjectDataOutput out) throws IOException {
// super.writeInternal(out);
// }
//
// @Override
// protected void readInternal(ObjectDataInput in) throws IOException {
// super.readInternal(in);
// }
// }
// Path: src/main/java/org/rakam/cache/hazelcast/hyperloglog/client/CardinalityRequest.java
import com.hazelcast.spi.Operation;
import org.rakam.cache.hazelcast.hyperloglog.operations.CardinalityOperation;
/**
* Created by buremba <Burak Emre Kabakcı> on 10/07/14.
*/
package org.rakam.cache.hazelcast.hyperloglog.client;
public class CardinalityRequest extends ReadRequest {
public CardinalityRequest(String name) {
super(name);
}
public CardinalityRequest() {
}
@Override
protected Operation prepareOperation() { | return new CardinalityOperation(name); |
buremba/hazelcast-modules | src/main/java/org/rakam/cache/hazelcast/hyperloglog/operations/AddBackupOperation.java | // Path: src/main/java/org/rakam/cache/hazelcast/hyperloglog/HyperLogLogBaseOperation.java
// public abstract class HyperLogLogBaseOperation extends Operation implements PartitionAwareOperation, IdentifiedDataSerializable {
//
// protected String name;
//
// public HyperLogLogBaseOperation() {
// }
//
// public HyperLogLogBaseOperation(String name) {
// this.name = name;
// }
//
// public HLLWrapper getHLL() {
// HyperLogLogService service = getService();
// return service.getHLL(name);
// }
//
// @Override
// public int getFactoryId() {
// return HyperLogLogSerializerFactory.F_ID;
// }
//
// @Override
// protected void writeInternal(ObjectDataOutput out) throws IOException {
// out.writeUTF(name);
// }
//
// @Override
// protected void readInternal(ObjectDataInput in) throws IOException {
// name = in.readUTF();
// }
//
// @Override
// public void afterRun() throws Exception {
// }
//
// @Override
// public void beforeRun() throws Exception {
// }
//
// @Override
// public Object getResponse() {
// return null;
// }
//
// @Override
// public boolean returnsResponse() {
// return true;
// }
// }
//
// Path: src/main/java/org/rakam/util/HLLWrapper.java
// public class HLLWrapper {
// final private static int SEED = 123456;
// private HLL hll;
//
// public HLLWrapper() {
// hll = new HLL(13/*log2m*/, 5/*registerWidth*/);
// }
//
// public HLLWrapper(byte[] bytes) {
// hll = HLL.fromBytes(bytes);
// }
//
// public long cardinality() {
// return hll.cardinality();
// }
//
// public void union(HLLWrapper hll) {
// this.hll.union(hll.hll);
// }
//
// public void addAll(Collection<String> coll) {
// for (String a : coll) {
// byte[] s = a.getBytes();
// hll.addRaw(MurmurHash3.murmurhash3x8632(s, 0, s.length, SEED));
// }
// }
//
// public void add(String obj) {
// if (obj == null)
// throw new IllegalArgumentException();
// byte[] s = obj.getBytes();
//
// hll.addRaw(MurmurHash3.murmurhash3x8632(s, 0, s.length, SEED));
// }
//
// public void set(byte[] bytes) {
// hll = HLL.fromBytes(bytes);
// }
//
// public byte[] bytes() {
// return hll.toBytes();
// }
//
// public void reset() {
// hll = new HLL(13/*log2m*/, 5/*registerWidth*/);
// }
// }
| import com.hazelcast.nio.ObjectDataInput;
import com.hazelcast.nio.ObjectDataOutput;
import com.hazelcast.spi.BackupOperation;
import org.rakam.cache.hazelcast.hyperloglog.HyperLogLogBaseOperation;
import org.rakam.util.HLLWrapper;
import java.io.IOException; | /**
* Created by buremba on 10/07/14.
*/
package org.rakam.cache.hazelcast.hyperloglog.operations;
public class AddBackupOperation extends HyperLogLogBaseOperation implements BackupOperation {
private String item;
public AddBackupOperation() {
}
public AddBackupOperation(String name, String item) {
super(name);
this.item = item;
}
@Override
public void run() throws IllegalArgumentException { | // Path: src/main/java/org/rakam/cache/hazelcast/hyperloglog/HyperLogLogBaseOperation.java
// public abstract class HyperLogLogBaseOperation extends Operation implements PartitionAwareOperation, IdentifiedDataSerializable {
//
// protected String name;
//
// public HyperLogLogBaseOperation() {
// }
//
// public HyperLogLogBaseOperation(String name) {
// this.name = name;
// }
//
// public HLLWrapper getHLL() {
// HyperLogLogService service = getService();
// return service.getHLL(name);
// }
//
// @Override
// public int getFactoryId() {
// return HyperLogLogSerializerFactory.F_ID;
// }
//
// @Override
// protected void writeInternal(ObjectDataOutput out) throws IOException {
// out.writeUTF(name);
// }
//
// @Override
// protected void readInternal(ObjectDataInput in) throws IOException {
// name = in.readUTF();
// }
//
// @Override
// public void afterRun() throws Exception {
// }
//
// @Override
// public void beforeRun() throws Exception {
// }
//
// @Override
// public Object getResponse() {
// return null;
// }
//
// @Override
// public boolean returnsResponse() {
// return true;
// }
// }
//
// Path: src/main/java/org/rakam/util/HLLWrapper.java
// public class HLLWrapper {
// final private static int SEED = 123456;
// private HLL hll;
//
// public HLLWrapper() {
// hll = new HLL(13/*log2m*/, 5/*registerWidth*/);
// }
//
// public HLLWrapper(byte[] bytes) {
// hll = HLL.fromBytes(bytes);
// }
//
// public long cardinality() {
// return hll.cardinality();
// }
//
// public void union(HLLWrapper hll) {
// this.hll.union(hll.hll);
// }
//
// public void addAll(Collection<String> coll) {
// for (String a : coll) {
// byte[] s = a.getBytes();
// hll.addRaw(MurmurHash3.murmurhash3x8632(s, 0, s.length, SEED));
// }
// }
//
// public void add(String obj) {
// if (obj == null)
// throw new IllegalArgumentException();
// byte[] s = obj.getBytes();
//
// hll.addRaw(MurmurHash3.murmurhash3x8632(s, 0, s.length, SEED));
// }
//
// public void set(byte[] bytes) {
// hll = HLL.fromBytes(bytes);
// }
//
// public byte[] bytes() {
// return hll.toBytes();
// }
//
// public void reset() {
// hll = new HLL(13/*log2m*/, 5/*registerWidth*/);
// }
// }
// Path: src/main/java/org/rakam/cache/hazelcast/hyperloglog/operations/AddBackupOperation.java
import com.hazelcast.nio.ObjectDataInput;
import com.hazelcast.nio.ObjectDataOutput;
import com.hazelcast.spi.BackupOperation;
import org.rakam.cache.hazelcast.hyperloglog.HyperLogLogBaseOperation;
import org.rakam.util.HLLWrapper;
import java.io.IOException;
/**
* Created by buremba on 10/07/14.
*/
package org.rakam.cache.hazelcast.hyperloglog.operations;
public class AddBackupOperation extends HyperLogLogBaseOperation implements BackupOperation {
private String item;
public AddBackupOperation() {
}
public AddBackupOperation(String name, String item) {
super(name);
this.item = item;
}
@Override
public void run() throws IllegalArgumentException { | HLLWrapper number = getHLL(); |
buremba/hazelcast-modules | src/main/java/org/rakam/cache/hazelcast/hyperloglog/operations/AddOperation.java | // Path: src/main/java/org/rakam/cache/hazelcast/hyperloglog/HyperLogLogBackupAwareOperation.java
// public abstract class HyperLogLogBackupAwareOperation extends HyperLogLogBaseOperation implements BackupAwareOperation, BackupOperation {
//
// protected boolean shouldBackup = true;
//
// public HyperLogLogBackupAwareOperation() {
// }
//
// public HyperLogLogBackupAwareOperation(String name) {
// super(name);
// }
//
// @Override
// public boolean shouldBackup() {
// return shouldBackup;
// }
//
// @Override
// public int getSyncBackupCount() {
// return 1;
// }
//
// @Override
// public int getAsyncBackupCount() {
// return 0;
// }
// }
//
// Path: src/main/java/org/rakam/util/HLLWrapper.java
// public class HLLWrapper {
// final private static int SEED = 123456;
// private HLL hll;
//
// public HLLWrapper() {
// hll = new HLL(13/*log2m*/, 5/*registerWidth*/);
// }
//
// public HLLWrapper(byte[] bytes) {
// hll = HLL.fromBytes(bytes);
// }
//
// public long cardinality() {
// return hll.cardinality();
// }
//
// public void union(HLLWrapper hll) {
// this.hll.union(hll.hll);
// }
//
// public void addAll(Collection<String> coll) {
// for (String a : coll) {
// byte[] s = a.getBytes();
// hll.addRaw(MurmurHash3.murmurhash3x8632(s, 0, s.length, SEED));
// }
// }
//
// public void add(String obj) {
// if (obj == null)
// throw new IllegalArgumentException();
// byte[] s = obj.getBytes();
//
// hll.addRaw(MurmurHash3.murmurhash3x8632(s, 0, s.length, SEED));
// }
//
// public void set(byte[] bytes) {
// hll = HLL.fromBytes(bytes);
// }
//
// public byte[] bytes() {
// return hll.toBytes();
// }
//
// public void reset() {
// hll = new HLL(13/*log2m*/, 5/*registerWidth*/);
// }
// }
| import com.hazelcast.nio.ObjectDataInput;
import com.hazelcast.nio.ObjectDataOutput;
import com.hazelcast.spi.Operation;
import org.rakam.cache.hazelcast.hyperloglog.HyperLogLogBackupAwareOperation;
import org.rakam.util.HLLWrapper;
import java.io.IOException; | /**
* Created by buremba on 08/07/14.
*/
package org.rakam.cache.hazelcast.hyperloglog.operations;
public class AddOperation extends HyperLogLogBackupAwareOperation {
private String item;
public AddOperation() {
}
public AddOperation(String name, String item) {
super(name);
this.item = item;
}
@Override
public void run() throws IllegalArgumentException { | // Path: src/main/java/org/rakam/cache/hazelcast/hyperloglog/HyperLogLogBackupAwareOperation.java
// public abstract class HyperLogLogBackupAwareOperation extends HyperLogLogBaseOperation implements BackupAwareOperation, BackupOperation {
//
// protected boolean shouldBackup = true;
//
// public HyperLogLogBackupAwareOperation() {
// }
//
// public HyperLogLogBackupAwareOperation(String name) {
// super(name);
// }
//
// @Override
// public boolean shouldBackup() {
// return shouldBackup;
// }
//
// @Override
// public int getSyncBackupCount() {
// return 1;
// }
//
// @Override
// public int getAsyncBackupCount() {
// return 0;
// }
// }
//
// Path: src/main/java/org/rakam/util/HLLWrapper.java
// public class HLLWrapper {
// final private static int SEED = 123456;
// private HLL hll;
//
// public HLLWrapper() {
// hll = new HLL(13/*log2m*/, 5/*registerWidth*/);
// }
//
// public HLLWrapper(byte[] bytes) {
// hll = HLL.fromBytes(bytes);
// }
//
// public long cardinality() {
// return hll.cardinality();
// }
//
// public void union(HLLWrapper hll) {
// this.hll.union(hll.hll);
// }
//
// public void addAll(Collection<String> coll) {
// for (String a : coll) {
// byte[] s = a.getBytes();
// hll.addRaw(MurmurHash3.murmurhash3x8632(s, 0, s.length, SEED));
// }
// }
//
// public void add(String obj) {
// if (obj == null)
// throw new IllegalArgumentException();
// byte[] s = obj.getBytes();
//
// hll.addRaw(MurmurHash3.murmurhash3x8632(s, 0, s.length, SEED));
// }
//
// public void set(byte[] bytes) {
// hll = HLL.fromBytes(bytes);
// }
//
// public byte[] bytes() {
// return hll.toBytes();
// }
//
// public void reset() {
// hll = new HLL(13/*log2m*/, 5/*registerWidth*/);
// }
// }
// Path: src/main/java/org/rakam/cache/hazelcast/hyperloglog/operations/AddOperation.java
import com.hazelcast.nio.ObjectDataInput;
import com.hazelcast.nio.ObjectDataOutput;
import com.hazelcast.spi.Operation;
import org.rakam.cache.hazelcast.hyperloglog.HyperLogLogBackupAwareOperation;
import org.rakam.util.HLLWrapper;
import java.io.IOException;
/**
* Created by buremba on 08/07/14.
*/
package org.rakam.cache.hazelcast.hyperloglog.operations;
public class AddOperation extends HyperLogLogBackupAwareOperation {
private String item;
public AddOperation() {
}
public AddOperation(String name, String item) {
super(name);
this.item = item;
}
@Override
public void run() throws IllegalArgumentException { | HLLWrapper hll = getHLL(); |
buremba/hazelcast-modules | src/main/java/org/rakam/cache/hazelcast/treemap/client/WriteRequest.java | // Path: src/main/java/org/rakam/cache/hazelcast/treemap/TreeMapService.java
// public class TreeMapService implements ManagedService, RemoteService, MigrationAwareService {
//
// public static final String SERVICE_NAME = "rakam:treeMapService";
//
// private NodeEngine nodeEngine;
// private final ConcurrentMap<String, OrderedCounterMap> containers = new ConcurrentHashMap<String, OrderedCounterMap>();
// private final ConstructorFunction<String, OrderedCounterMap> CountersConstructorFunction =
// new ConstructorFunction<String, OrderedCounterMap>() {
// public OrderedCounterMap createNew(String key) {
// return new OrderedCounterMap();
// }
// };
//
// public TreeMapService() {
// }
//
// public OrderedCounterMap getHLL(String name) {
// return getOrPutIfAbsent(containers, name, CountersConstructorFunction);
// }
//
// public void setHLL(String name, OrderedCounterMap map) {
// containers.put(name, map);
// }
//
// @Override
// public void init(NodeEngine nodeEngine, Properties properties) {
// this.nodeEngine = nodeEngine;
// }
//
// @Override
// public void reset() {
// containers.clear();
// }
//
// @Override
// public void shutdown(boolean terminate) {
// reset();
// }
//
// @Override
// public TreeMapProxy createDistributedObject(String name) {
// return new TreeMapProxy(name, nodeEngine, this);
// }
//
// @Override
// public void destroyDistributedObject(String name) {
// containers.remove(name);
// }
//
// @Override
// public void beforeMigration(PartitionMigrationEvent partitionMigrationEvent) {
// }
//
// @Override
// public Operation prepareReplicationOperation(PartitionReplicationEvent event) {
// Map<String, OrderedCounterMap> data = new HashMap();
// int partitionId = event.getPartitionId();
// for (String name : containers.keySet()) {
// if (partitionId == getPartitionId(name)) {
// OrderedCounterMap number = containers.get(name);
// data.put(name, number);
// }
// }
// return data.isEmpty() ? null : new TreeMapReplicationOperation(data);
// }
//
// private int getPartitionId(String name) {
// InternalPartitionService partitionService = nodeEngine.getPartitionService();
// String partitionKey = getPartitionKey(name);
// return partitionService.getPartitionId(partitionKey);
// }
//
// @Override
// public void commitMigration(PartitionMigrationEvent partitionMigrationEvent) {
// if (partitionMigrationEvent.getMigrationEndpoint() == MigrationEndpoint.SOURCE) {
// removePartition(partitionMigrationEvent.getPartitionId());
// }
// }
//
// @Override
// public void rollbackMigration(PartitionMigrationEvent partitionMigrationEvent) {
// if (partitionMigrationEvent.getMigrationEndpoint() == MigrationEndpoint.DESTINATION) {
// removePartition(partitionMigrationEvent.getPartitionId());
// }
// }
//
// @Override
// public void clearPartitionReplica(int partitionId) {
// removePartition(partitionId);
// }
//
// public void removePartition(int partitionId) {
// final Iterator<String> iterator = containers.keySet().iterator();
// while (iterator.hasNext()) {
// String name = iterator.next();
// if (getPartitionId(name) == partitionId) {
// iterator.remove();
// }
// }
// }
// }
//
// Path: src/main/java/org/rakam/cache/hazelcast/treemap/operations/TreeMapSerializerFactory.java
// public final class TreeMapSerializerFactory implements DataSerializableFactory {
//
// public static final int F_ID = 103;
//
// public static final int ADD = 0;
// public static final int GET = 1;
// public static final int REPLICATION = 7;
// public static final int ADD_BACKUP = 2;
//
// @Override
// public IdentifiedDataSerializable create(int typeId) {
// switch (typeId) {
// case ADD:
// return new IncrementByOperation();
// case ADD_BACKUP:
// return new IncrementByBackupOperation();
// case GET:
// return new GetOperation();
// case REPLICATION:
// return new TreeMapReplicationOperation();
// default:
// return null;
// }
// }
// }
| import com.hazelcast.client.ClientEngine;
import com.hazelcast.client.PartitionClientRequest;
import com.hazelcast.client.SecureRequest;
import com.hazelcast.nio.serialization.Data;
import com.hazelcast.nio.serialization.Portable;
import com.hazelcast.security.permission.ActionConstants;
import com.hazelcast.security.permission.AtomicLongPermission;
import org.rakam.cache.hazelcast.treemap.TreeMapService;
import org.rakam.cache.hazelcast.treemap.operations.TreeMapSerializerFactory;
import java.security.Permission; | package org.rakam.cache.hazelcast.treemap.client;
/**
* Created by buremba <Burak Emre Kabakcı> on 19/07/14 20:03.
*/
/**
* Created by buremba <Burak Emre Kabakcı> on 10/07/14.
*/
public abstract class WriteRequest extends PartitionClientRequest implements Portable, SecureRequest {
protected String name;
protected WriteRequest() {
}
protected WriteRequest(String name) {
this.name = name;
}
@Override
protected int getPartition() {
ClientEngine clientEngine = getClientEngine();
//Data key = serializationService.toData(name);
Data key = clientEngine.getSerializationService().toData(name);
return clientEngine.getPartitionService().getPartitionId(key);
}
@Override
public String getServiceName() { | // Path: src/main/java/org/rakam/cache/hazelcast/treemap/TreeMapService.java
// public class TreeMapService implements ManagedService, RemoteService, MigrationAwareService {
//
// public static final String SERVICE_NAME = "rakam:treeMapService";
//
// private NodeEngine nodeEngine;
// private final ConcurrentMap<String, OrderedCounterMap> containers = new ConcurrentHashMap<String, OrderedCounterMap>();
// private final ConstructorFunction<String, OrderedCounterMap> CountersConstructorFunction =
// new ConstructorFunction<String, OrderedCounterMap>() {
// public OrderedCounterMap createNew(String key) {
// return new OrderedCounterMap();
// }
// };
//
// public TreeMapService() {
// }
//
// public OrderedCounterMap getHLL(String name) {
// return getOrPutIfAbsent(containers, name, CountersConstructorFunction);
// }
//
// public void setHLL(String name, OrderedCounterMap map) {
// containers.put(name, map);
// }
//
// @Override
// public void init(NodeEngine nodeEngine, Properties properties) {
// this.nodeEngine = nodeEngine;
// }
//
// @Override
// public void reset() {
// containers.clear();
// }
//
// @Override
// public void shutdown(boolean terminate) {
// reset();
// }
//
// @Override
// public TreeMapProxy createDistributedObject(String name) {
// return new TreeMapProxy(name, nodeEngine, this);
// }
//
// @Override
// public void destroyDistributedObject(String name) {
// containers.remove(name);
// }
//
// @Override
// public void beforeMigration(PartitionMigrationEvent partitionMigrationEvent) {
// }
//
// @Override
// public Operation prepareReplicationOperation(PartitionReplicationEvent event) {
// Map<String, OrderedCounterMap> data = new HashMap();
// int partitionId = event.getPartitionId();
// for (String name : containers.keySet()) {
// if (partitionId == getPartitionId(name)) {
// OrderedCounterMap number = containers.get(name);
// data.put(name, number);
// }
// }
// return data.isEmpty() ? null : new TreeMapReplicationOperation(data);
// }
//
// private int getPartitionId(String name) {
// InternalPartitionService partitionService = nodeEngine.getPartitionService();
// String partitionKey = getPartitionKey(name);
// return partitionService.getPartitionId(partitionKey);
// }
//
// @Override
// public void commitMigration(PartitionMigrationEvent partitionMigrationEvent) {
// if (partitionMigrationEvent.getMigrationEndpoint() == MigrationEndpoint.SOURCE) {
// removePartition(partitionMigrationEvent.getPartitionId());
// }
// }
//
// @Override
// public void rollbackMigration(PartitionMigrationEvent partitionMigrationEvent) {
// if (partitionMigrationEvent.getMigrationEndpoint() == MigrationEndpoint.DESTINATION) {
// removePartition(partitionMigrationEvent.getPartitionId());
// }
// }
//
// @Override
// public void clearPartitionReplica(int partitionId) {
// removePartition(partitionId);
// }
//
// public void removePartition(int partitionId) {
// final Iterator<String> iterator = containers.keySet().iterator();
// while (iterator.hasNext()) {
// String name = iterator.next();
// if (getPartitionId(name) == partitionId) {
// iterator.remove();
// }
// }
// }
// }
//
// Path: src/main/java/org/rakam/cache/hazelcast/treemap/operations/TreeMapSerializerFactory.java
// public final class TreeMapSerializerFactory implements DataSerializableFactory {
//
// public static final int F_ID = 103;
//
// public static final int ADD = 0;
// public static final int GET = 1;
// public static final int REPLICATION = 7;
// public static final int ADD_BACKUP = 2;
//
// @Override
// public IdentifiedDataSerializable create(int typeId) {
// switch (typeId) {
// case ADD:
// return new IncrementByOperation();
// case ADD_BACKUP:
// return new IncrementByBackupOperation();
// case GET:
// return new GetOperation();
// case REPLICATION:
// return new TreeMapReplicationOperation();
// default:
// return null;
// }
// }
// }
// Path: src/main/java/org/rakam/cache/hazelcast/treemap/client/WriteRequest.java
import com.hazelcast.client.ClientEngine;
import com.hazelcast.client.PartitionClientRequest;
import com.hazelcast.client.SecureRequest;
import com.hazelcast.nio.serialization.Data;
import com.hazelcast.nio.serialization.Portable;
import com.hazelcast.security.permission.ActionConstants;
import com.hazelcast.security.permission.AtomicLongPermission;
import org.rakam.cache.hazelcast.treemap.TreeMapService;
import org.rakam.cache.hazelcast.treemap.operations.TreeMapSerializerFactory;
import java.security.Permission;
package org.rakam.cache.hazelcast.treemap.client;
/**
* Created by buremba <Burak Emre Kabakcı> on 19/07/14 20:03.
*/
/**
* Created by buremba <Burak Emre Kabakcı> on 10/07/14.
*/
public abstract class WriteRequest extends PartitionClientRequest implements Portable, SecureRequest {
protected String name;
protected WriteRequest() {
}
protected WriteRequest(String name) {
this.name = name;
}
@Override
protected int getPartition() {
ClientEngine clientEngine = getClientEngine();
//Data key = serializationService.toData(name);
Data key = clientEngine.getSerializationService().toData(name);
return clientEngine.getPartitionService().getPartitionId(key);
}
@Override
public String getServiceName() { | return TreeMapService.SERVICE_NAME; |
buremba/hazelcast-modules | src/main/java/org/rakam/cache/hazelcast/treemap/client/WriteRequest.java | // Path: src/main/java/org/rakam/cache/hazelcast/treemap/TreeMapService.java
// public class TreeMapService implements ManagedService, RemoteService, MigrationAwareService {
//
// public static final String SERVICE_NAME = "rakam:treeMapService";
//
// private NodeEngine nodeEngine;
// private final ConcurrentMap<String, OrderedCounterMap> containers = new ConcurrentHashMap<String, OrderedCounterMap>();
// private final ConstructorFunction<String, OrderedCounterMap> CountersConstructorFunction =
// new ConstructorFunction<String, OrderedCounterMap>() {
// public OrderedCounterMap createNew(String key) {
// return new OrderedCounterMap();
// }
// };
//
// public TreeMapService() {
// }
//
// public OrderedCounterMap getHLL(String name) {
// return getOrPutIfAbsent(containers, name, CountersConstructorFunction);
// }
//
// public void setHLL(String name, OrderedCounterMap map) {
// containers.put(name, map);
// }
//
// @Override
// public void init(NodeEngine nodeEngine, Properties properties) {
// this.nodeEngine = nodeEngine;
// }
//
// @Override
// public void reset() {
// containers.clear();
// }
//
// @Override
// public void shutdown(boolean terminate) {
// reset();
// }
//
// @Override
// public TreeMapProxy createDistributedObject(String name) {
// return new TreeMapProxy(name, nodeEngine, this);
// }
//
// @Override
// public void destroyDistributedObject(String name) {
// containers.remove(name);
// }
//
// @Override
// public void beforeMigration(PartitionMigrationEvent partitionMigrationEvent) {
// }
//
// @Override
// public Operation prepareReplicationOperation(PartitionReplicationEvent event) {
// Map<String, OrderedCounterMap> data = new HashMap();
// int partitionId = event.getPartitionId();
// for (String name : containers.keySet()) {
// if (partitionId == getPartitionId(name)) {
// OrderedCounterMap number = containers.get(name);
// data.put(name, number);
// }
// }
// return data.isEmpty() ? null : new TreeMapReplicationOperation(data);
// }
//
// private int getPartitionId(String name) {
// InternalPartitionService partitionService = nodeEngine.getPartitionService();
// String partitionKey = getPartitionKey(name);
// return partitionService.getPartitionId(partitionKey);
// }
//
// @Override
// public void commitMigration(PartitionMigrationEvent partitionMigrationEvent) {
// if (partitionMigrationEvent.getMigrationEndpoint() == MigrationEndpoint.SOURCE) {
// removePartition(partitionMigrationEvent.getPartitionId());
// }
// }
//
// @Override
// public void rollbackMigration(PartitionMigrationEvent partitionMigrationEvent) {
// if (partitionMigrationEvent.getMigrationEndpoint() == MigrationEndpoint.DESTINATION) {
// removePartition(partitionMigrationEvent.getPartitionId());
// }
// }
//
// @Override
// public void clearPartitionReplica(int partitionId) {
// removePartition(partitionId);
// }
//
// public void removePartition(int partitionId) {
// final Iterator<String> iterator = containers.keySet().iterator();
// while (iterator.hasNext()) {
// String name = iterator.next();
// if (getPartitionId(name) == partitionId) {
// iterator.remove();
// }
// }
// }
// }
//
// Path: src/main/java/org/rakam/cache/hazelcast/treemap/operations/TreeMapSerializerFactory.java
// public final class TreeMapSerializerFactory implements DataSerializableFactory {
//
// public static final int F_ID = 103;
//
// public static final int ADD = 0;
// public static final int GET = 1;
// public static final int REPLICATION = 7;
// public static final int ADD_BACKUP = 2;
//
// @Override
// public IdentifiedDataSerializable create(int typeId) {
// switch (typeId) {
// case ADD:
// return new IncrementByOperation();
// case ADD_BACKUP:
// return new IncrementByBackupOperation();
// case GET:
// return new GetOperation();
// case REPLICATION:
// return new TreeMapReplicationOperation();
// default:
// return null;
// }
// }
// }
| import com.hazelcast.client.ClientEngine;
import com.hazelcast.client.PartitionClientRequest;
import com.hazelcast.client.SecureRequest;
import com.hazelcast.nio.serialization.Data;
import com.hazelcast.nio.serialization.Portable;
import com.hazelcast.security.permission.ActionConstants;
import com.hazelcast.security.permission.AtomicLongPermission;
import org.rakam.cache.hazelcast.treemap.TreeMapService;
import org.rakam.cache.hazelcast.treemap.operations.TreeMapSerializerFactory;
import java.security.Permission; | package org.rakam.cache.hazelcast.treemap.client;
/**
* Created by buremba <Burak Emre Kabakcı> on 19/07/14 20:03.
*/
/**
* Created by buremba <Burak Emre Kabakcı> on 10/07/14.
*/
public abstract class WriteRequest extends PartitionClientRequest implements Portable, SecureRequest {
protected String name;
protected WriteRequest() {
}
protected WriteRequest(String name) {
this.name = name;
}
@Override
protected int getPartition() {
ClientEngine clientEngine = getClientEngine();
//Data key = serializationService.toData(name);
Data key = clientEngine.getSerializationService().toData(name);
return clientEngine.getPartitionService().getPartitionId(key);
}
@Override
public String getServiceName() {
return TreeMapService.SERVICE_NAME;
}
@Override
public int getFactoryId() { | // Path: src/main/java/org/rakam/cache/hazelcast/treemap/TreeMapService.java
// public class TreeMapService implements ManagedService, RemoteService, MigrationAwareService {
//
// public static final String SERVICE_NAME = "rakam:treeMapService";
//
// private NodeEngine nodeEngine;
// private final ConcurrentMap<String, OrderedCounterMap> containers = new ConcurrentHashMap<String, OrderedCounterMap>();
// private final ConstructorFunction<String, OrderedCounterMap> CountersConstructorFunction =
// new ConstructorFunction<String, OrderedCounterMap>() {
// public OrderedCounterMap createNew(String key) {
// return new OrderedCounterMap();
// }
// };
//
// public TreeMapService() {
// }
//
// public OrderedCounterMap getHLL(String name) {
// return getOrPutIfAbsent(containers, name, CountersConstructorFunction);
// }
//
// public void setHLL(String name, OrderedCounterMap map) {
// containers.put(name, map);
// }
//
// @Override
// public void init(NodeEngine nodeEngine, Properties properties) {
// this.nodeEngine = nodeEngine;
// }
//
// @Override
// public void reset() {
// containers.clear();
// }
//
// @Override
// public void shutdown(boolean terminate) {
// reset();
// }
//
// @Override
// public TreeMapProxy createDistributedObject(String name) {
// return new TreeMapProxy(name, nodeEngine, this);
// }
//
// @Override
// public void destroyDistributedObject(String name) {
// containers.remove(name);
// }
//
// @Override
// public void beforeMigration(PartitionMigrationEvent partitionMigrationEvent) {
// }
//
// @Override
// public Operation prepareReplicationOperation(PartitionReplicationEvent event) {
// Map<String, OrderedCounterMap> data = new HashMap();
// int partitionId = event.getPartitionId();
// for (String name : containers.keySet()) {
// if (partitionId == getPartitionId(name)) {
// OrderedCounterMap number = containers.get(name);
// data.put(name, number);
// }
// }
// return data.isEmpty() ? null : new TreeMapReplicationOperation(data);
// }
//
// private int getPartitionId(String name) {
// InternalPartitionService partitionService = nodeEngine.getPartitionService();
// String partitionKey = getPartitionKey(name);
// return partitionService.getPartitionId(partitionKey);
// }
//
// @Override
// public void commitMigration(PartitionMigrationEvent partitionMigrationEvent) {
// if (partitionMigrationEvent.getMigrationEndpoint() == MigrationEndpoint.SOURCE) {
// removePartition(partitionMigrationEvent.getPartitionId());
// }
// }
//
// @Override
// public void rollbackMigration(PartitionMigrationEvent partitionMigrationEvent) {
// if (partitionMigrationEvent.getMigrationEndpoint() == MigrationEndpoint.DESTINATION) {
// removePartition(partitionMigrationEvent.getPartitionId());
// }
// }
//
// @Override
// public void clearPartitionReplica(int partitionId) {
// removePartition(partitionId);
// }
//
// public void removePartition(int partitionId) {
// final Iterator<String> iterator = containers.keySet().iterator();
// while (iterator.hasNext()) {
// String name = iterator.next();
// if (getPartitionId(name) == partitionId) {
// iterator.remove();
// }
// }
// }
// }
//
// Path: src/main/java/org/rakam/cache/hazelcast/treemap/operations/TreeMapSerializerFactory.java
// public final class TreeMapSerializerFactory implements DataSerializableFactory {
//
// public static final int F_ID = 103;
//
// public static final int ADD = 0;
// public static final int GET = 1;
// public static final int REPLICATION = 7;
// public static final int ADD_BACKUP = 2;
//
// @Override
// public IdentifiedDataSerializable create(int typeId) {
// switch (typeId) {
// case ADD:
// return new IncrementByOperation();
// case ADD_BACKUP:
// return new IncrementByBackupOperation();
// case GET:
// return new GetOperation();
// case REPLICATION:
// return new TreeMapReplicationOperation();
// default:
// return null;
// }
// }
// }
// Path: src/main/java/org/rakam/cache/hazelcast/treemap/client/WriteRequest.java
import com.hazelcast.client.ClientEngine;
import com.hazelcast.client.PartitionClientRequest;
import com.hazelcast.client.SecureRequest;
import com.hazelcast.nio.serialization.Data;
import com.hazelcast.nio.serialization.Portable;
import com.hazelcast.security.permission.ActionConstants;
import com.hazelcast.security.permission.AtomicLongPermission;
import org.rakam.cache.hazelcast.treemap.TreeMapService;
import org.rakam.cache.hazelcast.treemap.operations.TreeMapSerializerFactory;
import java.security.Permission;
package org.rakam.cache.hazelcast.treemap.client;
/**
* Created by buremba <Burak Emre Kabakcı> on 19/07/14 20:03.
*/
/**
* Created by buremba <Burak Emre Kabakcı> on 10/07/14.
*/
public abstract class WriteRequest extends PartitionClientRequest implements Portable, SecureRequest {
protected String name;
protected WriteRequest() {
}
protected WriteRequest(String name) {
this.name = name;
}
@Override
protected int getPartition() {
ClientEngine clientEngine = getClientEngine();
//Data key = serializationService.toData(name);
Data key = clientEngine.getSerializationService().toData(name);
return clientEngine.getPartitionService().getPartitionId(key);
}
@Override
public String getServiceName() {
return TreeMapService.SERVICE_NAME;
}
@Override
public int getFactoryId() { | return TreeMapSerializerFactory.F_ID; |
buremba/hazelcast-modules | src/main/java/org/rakam/cache/hazelcast/hyperloglog/operations/AddAllBackupOperation.java | // Path: src/main/java/org/rakam/cache/hazelcast/hyperloglog/HyperLogLogBaseOperation.java
// public abstract class HyperLogLogBaseOperation extends Operation implements PartitionAwareOperation, IdentifiedDataSerializable {
//
// protected String name;
//
// public HyperLogLogBaseOperation() {
// }
//
// public HyperLogLogBaseOperation(String name) {
// this.name = name;
// }
//
// public HLLWrapper getHLL() {
// HyperLogLogService service = getService();
// return service.getHLL(name);
// }
//
// @Override
// public int getFactoryId() {
// return HyperLogLogSerializerFactory.F_ID;
// }
//
// @Override
// protected void writeInternal(ObjectDataOutput out) throws IOException {
// out.writeUTF(name);
// }
//
// @Override
// protected void readInternal(ObjectDataInput in) throws IOException {
// name = in.readUTF();
// }
//
// @Override
// public void afterRun() throws Exception {
// }
//
// @Override
// public void beforeRun() throws Exception {
// }
//
// @Override
// public Object getResponse() {
// return null;
// }
//
// @Override
// public boolean returnsResponse() {
// return true;
// }
// }
//
// Path: src/main/java/org/rakam/util/HLLWrapper.java
// public class HLLWrapper {
// final private static int SEED = 123456;
// private HLL hll;
//
// public HLLWrapper() {
// hll = new HLL(13/*log2m*/, 5/*registerWidth*/);
// }
//
// public HLLWrapper(byte[] bytes) {
// hll = HLL.fromBytes(bytes);
// }
//
// public long cardinality() {
// return hll.cardinality();
// }
//
// public void union(HLLWrapper hll) {
// this.hll.union(hll.hll);
// }
//
// public void addAll(Collection<String> coll) {
// for (String a : coll) {
// byte[] s = a.getBytes();
// hll.addRaw(MurmurHash3.murmurhash3x8632(s, 0, s.length, SEED));
// }
// }
//
// public void add(String obj) {
// if (obj == null)
// throw new IllegalArgumentException();
// byte[] s = obj.getBytes();
//
// hll.addRaw(MurmurHash3.murmurhash3x8632(s, 0, s.length, SEED));
// }
//
// public void set(byte[] bytes) {
// hll = HLL.fromBytes(bytes);
// }
//
// public byte[] bytes() {
// return hll.toBytes();
// }
//
// public void reset() {
// hll = new HLL(13/*log2m*/, 5/*registerWidth*/);
// }
// }
| import com.hazelcast.nio.ObjectDataInput;
import com.hazelcast.nio.ObjectDataOutput;
import com.hazelcast.spi.BackupOperation;
import org.rakam.cache.hazelcast.hyperloglog.HyperLogLogBaseOperation;
import org.rakam.util.HLLWrapper;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection; | /**
* Created by buremba on 10/07/14.
*/
package org.rakam.cache.hazelcast.hyperloglog.operations;
public class AddAllBackupOperation extends HyperLogLogBaseOperation implements BackupOperation {
private Collection<String> items;
public AddAllBackupOperation() {
}
public AddAllBackupOperation(String name, Collection<String> item) {
super(name);
this.items = item;
}
@Override
public void run() throws Exception { | // Path: src/main/java/org/rakam/cache/hazelcast/hyperloglog/HyperLogLogBaseOperation.java
// public abstract class HyperLogLogBaseOperation extends Operation implements PartitionAwareOperation, IdentifiedDataSerializable {
//
// protected String name;
//
// public HyperLogLogBaseOperation() {
// }
//
// public HyperLogLogBaseOperation(String name) {
// this.name = name;
// }
//
// public HLLWrapper getHLL() {
// HyperLogLogService service = getService();
// return service.getHLL(name);
// }
//
// @Override
// public int getFactoryId() {
// return HyperLogLogSerializerFactory.F_ID;
// }
//
// @Override
// protected void writeInternal(ObjectDataOutput out) throws IOException {
// out.writeUTF(name);
// }
//
// @Override
// protected void readInternal(ObjectDataInput in) throws IOException {
// name = in.readUTF();
// }
//
// @Override
// public void afterRun() throws Exception {
// }
//
// @Override
// public void beforeRun() throws Exception {
// }
//
// @Override
// public Object getResponse() {
// return null;
// }
//
// @Override
// public boolean returnsResponse() {
// return true;
// }
// }
//
// Path: src/main/java/org/rakam/util/HLLWrapper.java
// public class HLLWrapper {
// final private static int SEED = 123456;
// private HLL hll;
//
// public HLLWrapper() {
// hll = new HLL(13/*log2m*/, 5/*registerWidth*/);
// }
//
// public HLLWrapper(byte[] bytes) {
// hll = HLL.fromBytes(bytes);
// }
//
// public long cardinality() {
// return hll.cardinality();
// }
//
// public void union(HLLWrapper hll) {
// this.hll.union(hll.hll);
// }
//
// public void addAll(Collection<String> coll) {
// for (String a : coll) {
// byte[] s = a.getBytes();
// hll.addRaw(MurmurHash3.murmurhash3x8632(s, 0, s.length, SEED));
// }
// }
//
// public void add(String obj) {
// if (obj == null)
// throw new IllegalArgumentException();
// byte[] s = obj.getBytes();
//
// hll.addRaw(MurmurHash3.murmurhash3x8632(s, 0, s.length, SEED));
// }
//
// public void set(byte[] bytes) {
// hll = HLL.fromBytes(bytes);
// }
//
// public byte[] bytes() {
// return hll.toBytes();
// }
//
// public void reset() {
// hll = new HLL(13/*log2m*/, 5/*registerWidth*/);
// }
// }
// Path: src/main/java/org/rakam/cache/hazelcast/hyperloglog/operations/AddAllBackupOperation.java
import com.hazelcast.nio.ObjectDataInput;
import com.hazelcast.nio.ObjectDataOutput;
import com.hazelcast.spi.BackupOperation;
import org.rakam.cache.hazelcast.hyperloglog.HyperLogLogBaseOperation;
import org.rakam.util.HLLWrapper;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
/**
* Created by buremba on 10/07/14.
*/
package org.rakam.cache.hazelcast.hyperloglog.operations;
public class AddAllBackupOperation extends HyperLogLogBaseOperation implements BackupOperation {
private Collection<String> items;
public AddAllBackupOperation() {
}
public AddAllBackupOperation(String name, Collection<String> item) {
super(name);
this.items = item;
}
@Override
public void run() throws Exception { | HLLWrapper hll = getHLL(); |
buremba/hazelcast-modules | src/main/java/org/rakam/cache/hazelcast/treemap/client/IncrementByRequest.java | // Path: src/main/java/org/rakam/cache/hazelcast/treemap/operations/IncrementByOperation.java
// public class IncrementByOperation extends TreeMapBackupAwareOperation {
// private String key;
// private long by;
//
// public IncrementByOperation(String name, String key, long by) {
// super(name);
// this.by = by;
// this.key = key;
// }
//
// public IncrementByOperation() {
//
// }
//
// @Override
// protected void writeInternal(ObjectDataOutput out) throws IOException {
// super.writeInternal(out);
// out.writeLong(by);
// out.writeUTF(key);
// }
//
// @Override
// protected void readInternal(ObjectDataInput in) throws IOException {
// super.readInternal(in);
// by = in.readLong();
// key = in.readUTF();
// }
//
// @Override
// public void run() throws Exception {
//
// OrderedCounterMap map = ((TreeMapService) getService()).getHLL(name);
// map.increment(key, by);
// }
//
// @Override
// public Operation getBackupOperation() {
// return new IncrementByBackupOperation();
// }
//
// @Override
// public int getId() {
// return TreeMapSerializerFactory.ADD;
// }
// }
| import com.hazelcast.nio.serialization.PortableReader;
import com.hazelcast.nio.serialization.PortableWriter;
import com.hazelcast.spi.Operation;
import org.rakam.cache.hazelcast.treemap.operations.IncrementByOperation;
import java.io.IOException; | package org.rakam.cache.hazelcast.treemap.client;
/**
* Created by buremba <Burak Emre Kabakcı> on 11/07/14 16:18.
*/
public class IncrementByRequest extends WriteRequest {
private String key;
private long inc;
public IncrementByRequest(String name, String key, long inc) {
super(name);
this.key = key;
this.inc = inc;
}
public IncrementByRequest() {
}
@Override
public void write(PortableWriter writer) throws IOException {
writer.writeUTF("n", name);
writer.writeUTF("d", key);
writer.writeLong("l", inc);
}
@Override
public void read(PortableReader reader) throws IOException {
name = reader.readUTF("n");
key = reader.readUTF("d");
inc = reader.readLong("l");
}
@Override
protected Operation prepareOperation() { | // Path: src/main/java/org/rakam/cache/hazelcast/treemap/operations/IncrementByOperation.java
// public class IncrementByOperation extends TreeMapBackupAwareOperation {
// private String key;
// private long by;
//
// public IncrementByOperation(String name, String key, long by) {
// super(name);
// this.by = by;
// this.key = key;
// }
//
// public IncrementByOperation() {
//
// }
//
// @Override
// protected void writeInternal(ObjectDataOutput out) throws IOException {
// super.writeInternal(out);
// out.writeLong(by);
// out.writeUTF(key);
// }
//
// @Override
// protected void readInternal(ObjectDataInput in) throws IOException {
// super.readInternal(in);
// by = in.readLong();
// key = in.readUTF();
// }
//
// @Override
// public void run() throws Exception {
//
// OrderedCounterMap map = ((TreeMapService) getService()).getHLL(name);
// map.increment(key, by);
// }
//
// @Override
// public Operation getBackupOperation() {
// return new IncrementByBackupOperation();
// }
//
// @Override
// public int getId() {
// return TreeMapSerializerFactory.ADD;
// }
// }
// Path: src/main/java/org/rakam/cache/hazelcast/treemap/client/IncrementByRequest.java
import com.hazelcast.nio.serialization.PortableReader;
import com.hazelcast.nio.serialization.PortableWriter;
import com.hazelcast.spi.Operation;
import org.rakam.cache.hazelcast.treemap.operations.IncrementByOperation;
import java.io.IOException;
package org.rakam.cache.hazelcast.treemap.client;
/**
* Created by buremba <Burak Emre Kabakcı> on 11/07/14 16:18.
*/
public class IncrementByRequest extends WriteRequest {
private String key;
private long inc;
public IncrementByRequest(String name, String key, long inc) {
super(name);
this.key = key;
this.inc = inc;
}
public IncrementByRequest() {
}
@Override
public void write(PortableWriter writer) throws IOException {
writer.writeUTF("n", name);
writer.writeUTF("d", key);
writer.writeLong("l", inc);
}
@Override
public void read(PortableReader reader) throws IOException {
name = reader.readUTF("n");
key = reader.readUTF("d");
inc = reader.readLong("l");
}
@Override
protected Operation prepareOperation() { | return new IncrementByOperation(name, key, inc); |
buremba/hazelcast-modules | src/main/java/org/rakam/cache/hazelcast/hyperloglog/operations/ResetOperation.java | // Path: src/main/java/org/rakam/cache/hazelcast/hyperloglog/HyperLogLogBackupAwareOperation.java
// public abstract class HyperLogLogBackupAwareOperation extends HyperLogLogBaseOperation implements BackupAwareOperation, BackupOperation {
//
// protected boolean shouldBackup = true;
//
// public HyperLogLogBackupAwareOperation() {
// }
//
// public HyperLogLogBackupAwareOperation(String name) {
// super(name);
// }
//
// @Override
// public boolean shouldBackup() {
// return shouldBackup;
// }
//
// @Override
// public int getSyncBackupCount() {
// return 1;
// }
//
// @Override
// public int getAsyncBackupCount() {
// return 0;
// }
// }
//
// Path: src/main/java/org/rakam/util/HLLWrapper.java
// public class HLLWrapper {
// final private static int SEED = 123456;
// private HLL hll;
//
// public HLLWrapper() {
// hll = new HLL(13/*log2m*/, 5/*registerWidth*/);
// }
//
// public HLLWrapper(byte[] bytes) {
// hll = HLL.fromBytes(bytes);
// }
//
// public long cardinality() {
// return hll.cardinality();
// }
//
// public void union(HLLWrapper hll) {
// this.hll.union(hll.hll);
// }
//
// public void addAll(Collection<String> coll) {
// for (String a : coll) {
// byte[] s = a.getBytes();
// hll.addRaw(MurmurHash3.murmurhash3x8632(s, 0, s.length, SEED));
// }
// }
//
// public void add(String obj) {
// if (obj == null)
// throw new IllegalArgumentException();
// byte[] s = obj.getBytes();
//
// hll.addRaw(MurmurHash3.murmurhash3x8632(s, 0, s.length, SEED));
// }
//
// public void set(byte[] bytes) {
// hll = HLL.fromBytes(bytes);
// }
//
// public byte[] bytes() {
// return hll.toBytes();
// }
//
// public void reset() {
// hll = new HLL(13/*log2m*/, 5/*registerWidth*/);
// }
// }
| import com.hazelcast.spi.Operation;
import org.rakam.cache.hazelcast.hyperloglog.HyperLogLogBackupAwareOperation;
import org.rakam.util.HLLWrapper; | package org.rakam.cache.hazelcast.hyperloglog.operations;
/**
* Created by buremba <Burak Emre Kabakcı> on 11/07/14 16:13.
*/
public class ResetOperation extends HyperLogLogBackupAwareOperation {
public ResetOperation() {
}
public ResetOperation(String name) {
super(name);
}
@Override
public void run() throws IllegalArgumentException { | // Path: src/main/java/org/rakam/cache/hazelcast/hyperloglog/HyperLogLogBackupAwareOperation.java
// public abstract class HyperLogLogBackupAwareOperation extends HyperLogLogBaseOperation implements BackupAwareOperation, BackupOperation {
//
// protected boolean shouldBackup = true;
//
// public HyperLogLogBackupAwareOperation() {
// }
//
// public HyperLogLogBackupAwareOperation(String name) {
// super(name);
// }
//
// @Override
// public boolean shouldBackup() {
// return shouldBackup;
// }
//
// @Override
// public int getSyncBackupCount() {
// return 1;
// }
//
// @Override
// public int getAsyncBackupCount() {
// return 0;
// }
// }
//
// Path: src/main/java/org/rakam/util/HLLWrapper.java
// public class HLLWrapper {
// final private static int SEED = 123456;
// private HLL hll;
//
// public HLLWrapper() {
// hll = new HLL(13/*log2m*/, 5/*registerWidth*/);
// }
//
// public HLLWrapper(byte[] bytes) {
// hll = HLL.fromBytes(bytes);
// }
//
// public long cardinality() {
// return hll.cardinality();
// }
//
// public void union(HLLWrapper hll) {
// this.hll.union(hll.hll);
// }
//
// public void addAll(Collection<String> coll) {
// for (String a : coll) {
// byte[] s = a.getBytes();
// hll.addRaw(MurmurHash3.murmurhash3x8632(s, 0, s.length, SEED));
// }
// }
//
// public void add(String obj) {
// if (obj == null)
// throw new IllegalArgumentException();
// byte[] s = obj.getBytes();
//
// hll.addRaw(MurmurHash3.murmurhash3x8632(s, 0, s.length, SEED));
// }
//
// public void set(byte[] bytes) {
// hll = HLL.fromBytes(bytes);
// }
//
// public byte[] bytes() {
// return hll.toBytes();
// }
//
// public void reset() {
// hll = new HLL(13/*log2m*/, 5/*registerWidth*/);
// }
// }
// Path: src/main/java/org/rakam/cache/hazelcast/hyperloglog/operations/ResetOperation.java
import com.hazelcast.spi.Operation;
import org.rakam.cache.hazelcast.hyperloglog.HyperLogLogBackupAwareOperation;
import org.rakam.util.HLLWrapper;
package org.rakam.cache.hazelcast.hyperloglog.operations;
/**
* Created by buremba <Burak Emre Kabakcı> on 11/07/14 16:13.
*/
public class ResetOperation extends HyperLogLogBackupAwareOperation {
public ResetOperation() {
}
public ResetOperation(String name) {
super(name);
}
@Override
public void run() throws IllegalArgumentException { | HLLWrapper hll = getHLL(); |
buremba/hazelcast-modules | src/main/java/org/rakam/cache/hazelcast/hyperloglog/operations/CardinalityOperation.java | // Path: src/main/java/org/rakam/cache/hazelcast/hyperloglog/HyperLogLogBaseOperation.java
// public abstract class HyperLogLogBaseOperation extends Operation implements PartitionAwareOperation, IdentifiedDataSerializable {
//
// protected String name;
//
// public HyperLogLogBaseOperation() {
// }
//
// public HyperLogLogBaseOperation(String name) {
// this.name = name;
// }
//
// public HLLWrapper getHLL() {
// HyperLogLogService service = getService();
// return service.getHLL(name);
// }
//
// @Override
// public int getFactoryId() {
// return HyperLogLogSerializerFactory.F_ID;
// }
//
// @Override
// protected void writeInternal(ObjectDataOutput out) throws IOException {
// out.writeUTF(name);
// }
//
// @Override
// protected void readInternal(ObjectDataInput in) throws IOException {
// name = in.readUTF();
// }
//
// @Override
// public void afterRun() throws Exception {
// }
//
// @Override
// public void beforeRun() throws Exception {
// }
//
// @Override
// public Object getResponse() {
// return null;
// }
//
// @Override
// public boolean returnsResponse() {
// return true;
// }
// }
//
// Path: src/main/java/org/rakam/util/HLLWrapper.java
// public class HLLWrapper {
// final private static int SEED = 123456;
// private HLL hll;
//
// public HLLWrapper() {
// hll = new HLL(13/*log2m*/, 5/*registerWidth*/);
// }
//
// public HLLWrapper(byte[] bytes) {
// hll = HLL.fromBytes(bytes);
// }
//
// public long cardinality() {
// return hll.cardinality();
// }
//
// public void union(HLLWrapper hll) {
// this.hll.union(hll.hll);
// }
//
// public void addAll(Collection<String> coll) {
// for (String a : coll) {
// byte[] s = a.getBytes();
// hll.addRaw(MurmurHash3.murmurhash3x8632(s, 0, s.length, SEED));
// }
// }
//
// public void add(String obj) {
// if (obj == null)
// throw new IllegalArgumentException();
// byte[] s = obj.getBytes();
//
// hll.addRaw(MurmurHash3.murmurhash3x8632(s, 0, s.length, SEED));
// }
//
// public void set(byte[] bytes) {
// hll = HLL.fromBytes(bytes);
// }
//
// public byte[] bytes() {
// return hll.toBytes();
// }
//
// public void reset() {
// hll = new HLL(13/*log2m*/, 5/*registerWidth*/);
// }
// }
| import com.hazelcast.nio.ObjectDataInput;
import com.hazelcast.nio.ObjectDataOutput;
import org.rakam.cache.hazelcast.hyperloglog.HyperLogLogBaseOperation;
import org.rakam.util.HLLWrapper;
import java.io.IOException; | /**
* Created by buremba on 10/07/14.
*/
package org.rakam.cache.hazelcast.hyperloglog.operations;
public class CardinalityOperation extends HyperLogLogBaseOperation {
private long returnValue;
public CardinalityOperation() {
}
public CardinalityOperation(String name) {
super(name);
}
@Override
public void run() throws Exception { | // Path: src/main/java/org/rakam/cache/hazelcast/hyperloglog/HyperLogLogBaseOperation.java
// public abstract class HyperLogLogBaseOperation extends Operation implements PartitionAwareOperation, IdentifiedDataSerializable {
//
// protected String name;
//
// public HyperLogLogBaseOperation() {
// }
//
// public HyperLogLogBaseOperation(String name) {
// this.name = name;
// }
//
// public HLLWrapper getHLL() {
// HyperLogLogService service = getService();
// return service.getHLL(name);
// }
//
// @Override
// public int getFactoryId() {
// return HyperLogLogSerializerFactory.F_ID;
// }
//
// @Override
// protected void writeInternal(ObjectDataOutput out) throws IOException {
// out.writeUTF(name);
// }
//
// @Override
// protected void readInternal(ObjectDataInput in) throws IOException {
// name = in.readUTF();
// }
//
// @Override
// public void afterRun() throws Exception {
// }
//
// @Override
// public void beforeRun() throws Exception {
// }
//
// @Override
// public Object getResponse() {
// return null;
// }
//
// @Override
// public boolean returnsResponse() {
// return true;
// }
// }
//
// Path: src/main/java/org/rakam/util/HLLWrapper.java
// public class HLLWrapper {
// final private static int SEED = 123456;
// private HLL hll;
//
// public HLLWrapper() {
// hll = new HLL(13/*log2m*/, 5/*registerWidth*/);
// }
//
// public HLLWrapper(byte[] bytes) {
// hll = HLL.fromBytes(bytes);
// }
//
// public long cardinality() {
// return hll.cardinality();
// }
//
// public void union(HLLWrapper hll) {
// this.hll.union(hll.hll);
// }
//
// public void addAll(Collection<String> coll) {
// for (String a : coll) {
// byte[] s = a.getBytes();
// hll.addRaw(MurmurHash3.murmurhash3x8632(s, 0, s.length, SEED));
// }
// }
//
// public void add(String obj) {
// if (obj == null)
// throw new IllegalArgumentException();
// byte[] s = obj.getBytes();
//
// hll.addRaw(MurmurHash3.murmurhash3x8632(s, 0, s.length, SEED));
// }
//
// public void set(byte[] bytes) {
// hll = HLL.fromBytes(bytes);
// }
//
// public byte[] bytes() {
// return hll.toBytes();
// }
//
// public void reset() {
// hll = new HLL(13/*log2m*/, 5/*registerWidth*/);
// }
// }
// Path: src/main/java/org/rakam/cache/hazelcast/hyperloglog/operations/CardinalityOperation.java
import com.hazelcast.nio.ObjectDataInput;
import com.hazelcast.nio.ObjectDataOutput;
import org.rakam.cache.hazelcast.hyperloglog.HyperLogLogBaseOperation;
import org.rakam.util.HLLWrapper;
import java.io.IOException;
/**
* Created by buremba on 10/07/14.
*/
package org.rakam.cache.hazelcast.hyperloglog.operations;
public class CardinalityOperation extends HyperLogLogBaseOperation {
private long returnValue;
public CardinalityOperation() {
}
public CardinalityOperation(String name) {
super(name);
}
@Override
public void run() throws Exception { | HLLWrapper number = getHLL(); |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.