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
|
|---|---|---|---|---|---|---|
Turbo87/flight-club
|
core/src/main/java/org/flightclub/Object3d.java
|
// Path: core/src/main/java/org/flightclub/compat/Color.java
// public class Color {
// private final java.awt.Color c;
//
//
// /**
// * The color white. In the default sRGB space.
// */
// public final static Color WHITE = new Color(255, 255, 255);
//
// /**
// * The color light gray. In the default sRGB space.
// */
// public final static Color LIGHT_GRAY = new Color(192, 192, 192);
//
// /**
// * The color gray. In the default sRGB space.
// */
// public final static Color GRAY = new Color(128, 128, 128);
//
// /**
// * The color dark gray. In the default sRGB space.
// */
// public final static Color DARK_GRAY = new Color(64, 64, 64);
//
// /**
// * The color black. In the default sRGB space.
// */
// public final static Color BLACK = new Color(0, 0, 0);
//
// /**
// * The color red. In the default sRGB space.
// */
// public final static Color RED = new Color(255, 0, 0);
//
// /**
// * The color pink. In the default sRGB space.
// */
// public final static Color PINK = new Color(255, 175, 175);
//
// /**
// * The color orange. In the default sRGB space.
// */
// public final static Color ORANGE = new Color(255, 200, 0);
//
// /**
// * The color yellow. In the default sRGB space.
// */
// public final static Color YELLOW = new Color(255, 255, 0);
//
// /**
// * The color green. In the default sRGB space.
// */
// public final static Color GREEN = new Color(0, 255, 0);
//
// /**
// * The color magenta. In the default sRGB space.
// */
// public final static Color MAGENTA = new Color(255, 0, 255);
//
// /**
// * The color cyan. In the default sRGB space.
// */
// public final static Color CYAN = new Color(0, 255, 255);
//
// /**
// * The color blue. In the default sRGB space.
// */
// public final static Color BLUE = new Color(0, 0, 255);
//
// public Color(int r, int g, int b) {
// this.c = new java.awt.Color(r, g, b);
// }
//
// public java.awt.Color getColor() {
// return c;
// }
//
// public int getRed() {
// return c.getRed();
// }
//
// public int getGreen() {
// return c.getGreen();
// }
//
// public int getBlue() {
// return c.getBlue();
// }
// }
//
// Path: core/src/main/java/org/flightclub/compat/Graphics.java
// public interface Graphics {
// void setColor(Color color);
// void setFont(Font font);
//
// void drawLine(int x1, int y1, int x2, int y2);
// void drawString(String str, int x, int y);
//
// void fillCircle(int x, int y, int diameter);
// void fillPolygon(int[] xPoints, int[] yPoints, int nPoints);
// }
|
import org.flightclub.compat.Color;
import org.flightclub.compat.Graphics;
import java.util.Vector;
|
/**
This code is covered by the GNU General Public License
detailed at http://www.gnu.org/copyleft/gpl.html
Flight Club docs located at http://www.danb.dircon.co.uk/hg/hg.htm
Dan Burton , Nov 2001
*/
package org.flightclub;
public class Object3d {
protected XCGame app = null;
final Vector<Vector3d> points = new Vector<>();
final Vector<Vector3d> points_ = new Vector<>();
final Vector<PolyLine> wires = new Vector<>();
// list of flags - is point within field of view
final Vector<Boolean> inFOVs = new Vector<>();
boolean inFOV = false;
// default layer 1
int layer;
Object3d(XCGame theApp) {
this(theApp, true);
}
Object3d(XCGame theApp, boolean register) {
this(theApp, register, 1);
}
Object3d(XCGame theApp, boolean register, int inLayer) {
app = theApp;
layer = inLayer;
if (register)
registerObject3d();
}
public void destroyMe() {
app.obj3dManager.removeObj(this, layer);
}
void registerObject3d() {
app.obj3dManager.addObj(this, layer);
}
|
// Path: core/src/main/java/org/flightclub/compat/Color.java
// public class Color {
// private final java.awt.Color c;
//
//
// /**
// * The color white. In the default sRGB space.
// */
// public final static Color WHITE = new Color(255, 255, 255);
//
// /**
// * The color light gray. In the default sRGB space.
// */
// public final static Color LIGHT_GRAY = new Color(192, 192, 192);
//
// /**
// * The color gray. In the default sRGB space.
// */
// public final static Color GRAY = new Color(128, 128, 128);
//
// /**
// * The color dark gray. In the default sRGB space.
// */
// public final static Color DARK_GRAY = new Color(64, 64, 64);
//
// /**
// * The color black. In the default sRGB space.
// */
// public final static Color BLACK = new Color(0, 0, 0);
//
// /**
// * The color red. In the default sRGB space.
// */
// public final static Color RED = new Color(255, 0, 0);
//
// /**
// * The color pink. In the default sRGB space.
// */
// public final static Color PINK = new Color(255, 175, 175);
//
// /**
// * The color orange. In the default sRGB space.
// */
// public final static Color ORANGE = new Color(255, 200, 0);
//
// /**
// * The color yellow. In the default sRGB space.
// */
// public final static Color YELLOW = new Color(255, 255, 0);
//
// /**
// * The color green. In the default sRGB space.
// */
// public final static Color GREEN = new Color(0, 255, 0);
//
// /**
// * The color magenta. In the default sRGB space.
// */
// public final static Color MAGENTA = new Color(255, 0, 255);
//
// /**
// * The color cyan. In the default sRGB space.
// */
// public final static Color CYAN = new Color(0, 255, 255);
//
// /**
// * The color blue. In the default sRGB space.
// */
// public final static Color BLUE = new Color(0, 0, 255);
//
// public Color(int r, int g, int b) {
// this.c = new java.awt.Color(r, g, b);
// }
//
// public java.awt.Color getColor() {
// return c;
// }
//
// public int getRed() {
// return c.getRed();
// }
//
// public int getGreen() {
// return c.getGreen();
// }
//
// public int getBlue() {
// return c.getBlue();
// }
// }
//
// Path: core/src/main/java/org/flightclub/compat/Graphics.java
// public interface Graphics {
// void setColor(Color color);
// void setFont(Font font);
//
// void drawLine(int x1, int y1, int x2, int y2);
// void drawString(String str, int x, int y);
//
// void fillCircle(int x, int y, int diameter);
// void fillPolygon(int[] xPoints, int[] yPoints, int nPoints);
// }
// Path: core/src/main/java/org/flightclub/Object3d.java
import org.flightclub.compat.Color;
import org.flightclub.compat.Graphics;
import java.util.Vector;
/**
This code is covered by the GNU General Public License
detailed at http://www.gnu.org/copyleft/gpl.html
Flight Club docs located at http://www.danb.dircon.co.uk/hg/hg.htm
Dan Burton , Nov 2001
*/
package org.flightclub;
public class Object3d {
protected XCGame app = null;
final Vector<Vector3d> points = new Vector<>();
final Vector<Vector3d> points_ = new Vector<>();
final Vector<PolyLine> wires = new Vector<>();
// list of flags - is point within field of view
final Vector<Boolean> inFOVs = new Vector<>();
boolean inFOV = false;
// default layer 1
int layer;
Object3d(XCGame theApp) {
this(theApp, true);
}
Object3d(XCGame theApp, boolean register) {
this(theApp, register, 1);
}
Object3d(XCGame theApp, boolean register, int inLayer) {
app = theApp;
layer = inLayer;
if (register)
registerObject3d();
}
public void destroyMe() {
app.obj3dManager.removeObj(this, layer);
}
void registerObject3d() {
app.obj3dManager.addObj(this, layer);
}
|
public void draw(Graphics g) {
|
Turbo87/flight-club
|
core/src/main/java/org/flightclub/Object3d.java
|
// Path: core/src/main/java/org/flightclub/compat/Color.java
// public class Color {
// private final java.awt.Color c;
//
//
// /**
// * The color white. In the default sRGB space.
// */
// public final static Color WHITE = new Color(255, 255, 255);
//
// /**
// * The color light gray. In the default sRGB space.
// */
// public final static Color LIGHT_GRAY = new Color(192, 192, 192);
//
// /**
// * The color gray. In the default sRGB space.
// */
// public final static Color GRAY = new Color(128, 128, 128);
//
// /**
// * The color dark gray. In the default sRGB space.
// */
// public final static Color DARK_GRAY = new Color(64, 64, 64);
//
// /**
// * The color black. In the default sRGB space.
// */
// public final static Color BLACK = new Color(0, 0, 0);
//
// /**
// * The color red. In the default sRGB space.
// */
// public final static Color RED = new Color(255, 0, 0);
//
// /**
// * The color pink. In the default sRGB space.
// */
// public final static Color PINK = new Color(255, 175, 175);
//
// /**
// * The color orange. In the default sRGB space.
// */
// public final static Color ORANGE = new Color(255, 200, 0);
//
// /**
// * The color yellow. In the default sRGB space.
// */
// public final static Color YELLOW = new Color(255, 255, 0);
//
// /**
// * The color green. In the default sRGB space.
// */
// public final static Color GREEN = new Color(0, 255, 0);
//
// /**
// * The color magenta. In the default sRGB space.
// */
// public final static Color MAGENTA = new Color(255, 0, 255);
//
// /**
// * The color cyan. In the default sRGB space.
// */
// public final static Color CYAN = new Color(0, 255, 255);
//
// /**
// * The color blue. In the default sRGB space.
// */
// public final static Color BLUE = new Color(0, 0, 255);
//
// public Color(int r, int g, int b) {
// this.c = new java.awt.Color(r, g, b);
// }
//
// public java.awt.Color getColor() {
// return c;
// }
//
// public int getRed() {
// return c.getRed();
// }
//
// public int getGreen() {
// return c.getGreen();
// }
//
// public int getBlue() {
// return c.getBlue();
// }
// }
//
// Path: core/src/main/java/org/flightclub/compat/Graphics.java
// public interface Graphics {
// void setColor(Color color);
// void setFont(Font font);
//
// void drawLine(int x1, int y1, int x2, int y2);
// void drawString(String str, int x, int y);
//
// void fillCircle(int x, int y, int diameter);
// void fillPolygon(int[] xPoints, int[] yPoints, int nPoints);
// }
|
import org.flightclub.compat.Color;
import org.flightclub.compat.Graphics;
import java.util.Vector;
|
}
/** use camera to get from 3d to 2d */
void film(CameraMan camera) {
Vector3d v;
Vector3d v_;
inFOV = false; //set true if any points are in FOV
for (int i = 0; i < points.size(); i++) {
v = points.elementAt(i);
v_ = points_.elementAt(i);
//translate, rotate and project (only if visible)
v_.set(v).subtract(camera.getFocus());
Tools3d.applyTo(camera.getMatrix(), v_, v_);
boolean rc = Tools3d.projectYZ(v_, v_, camera.getDistance());
inFOV = inFOV || rc;
inFOVs.setElementAt(rc, i);
camera.scaleToScreen(v_);
}
}
public void scaleBy(float s) {
for (Vector3d v : points)
v.scaleBy(s);
}
|
// Path: core/src/main/java/org/flightclub/compat/Color.java
// public class Color {
// private final java.awt.Color c;
//
//
// /**
// * The color white. In the default sRGB space.
// */
// public final static Color WHITE = new Color(255, 255, 255);
//
// /**
// * The color light gray. In the default sRGB space.
// */
// public final static Color LIGHT_GRAY = new Color(192, 192, 192);
//
// /**
// * The color gray. In the default sRGB space.
// */
// public final static Color GRAY = new Color(128, 128, 128);
//
// /**
// * The color dark gray. In the default sRGB space.
// */
// public final static Color DARK_GRAY = new Color(64, 64, 64);
//
// /**
// * The color black. In the default sRGB space.
// */
// public final static Color BLACK = new Color(0, 0, 0);
//
// /**
// * The color red. In the default sRGB space.
// */
// public final static Color RED = new Color(255, 0, 0);
//
// /**
// * The color pink. In the default sRGB space.
// */
// public final static Color PINK = new Color(255, 175, 175);
//
// /**
// * The color orange. In the default sRGB space.
// */
// public final static Color ORANGE = new Color(255, 200, 0);
//
// /**
// * The color yellow. In the default sRGB space.
// */
// public final static Color YELLOW = new Color(255, 255, 0);
//
// /**
// * The color green. In the default sRGB space.
// */
// public final static Color GREEN = new Color(0, 255, 0);
//
// /**
// * The color magenta. In the default sRGB space.
// */
// public final static Color MAGENTA = new Color(255, 0, 255);
//
// /**
// * The color cyan. In the default sRGB space.
// */
// public final static Color CYAN = new Color(0, 255, 255);
//
// /**
// * The color blue. In the default sRGB space.
// */
// public final static Color BLUE = new Color(0, 0, 255);
//
// public Color(int r, int g, int b) {
// this.c = new java.awt.Color(r, g, b);
// }
//
// public java.awt.Color getColor() {
// return c;
// }
//
// public int getRed() {
// return c.getRed();
// }
//
// public int getGreen() {
// return c.getGreen();
// }
//
// public int getBlue() {
// return c.getBlue();
// }
// }
//
// Path: core/src/main/java/org/flightclub/compat/Graphics.java
// public interface Graphics {
// void setColor(Color color);
// void setFont(Font font);
//
// void drawLine(int x1, int y1, int x2, int y2);
// void drawString(String str, int x, int y);
//
// void fillCircle(int x, int y, int diameter);
// void fillPolygon(int[] xPoints, int[] yPoints, int nPoints);
// }
// Path: core/src/main/java/org/flightclub/Object3d.java
import org.flightclub.compat.Color;
import org.flightclub.compat.Graphics;
import java.util.Vector;
}
/** use camera to get from 3d to 2d */
void film(CameraMan camera) {
Vector3d v;
Vector3d v_;
inFOV = false; //set true if any points are in FOV
for (int i = 0; i < points.size(); i++) {
v = points.elementAt(i);
v_ = points_.elementAt(i);
//translate, rotate and project (only if visible)
v_.set(v).subtract(camera.getFocus());
Tools3d.applyTo(camera.getMatrix(), v_, v_);
boolean rc = Tools3d.projectYZ(v_, v_, camera.getDistance());
inFOV = inFOV || rc;
inFOVs.setElementAt(rc, i);
camera.scaleToScreen(v_);
}
}
public void scaleBy(float s) {
for (Vector3d v : points)
v.scaleBy(s);
}
|
public void setColor(Color c) {
|
Turbo87/flight-club
|
core/src/main/java/org/flightclub/Surface.java
|
// Path: core/src/main/java/org/flightclub/compat/Color.java
// public class Color {
// private final java.awt.Color c;
//
//
// /**
// * The color white. In the default sRGB space.
// */
// public final static Color WHITE = new Color(255, 255, 255);
//
// /**
// * The color light gray. In the default sRGB space.
// */
// public final static Color LIGHT_GRAY = new Color(192, 192, 192);
//
// /**
// * The color gray. In the default sRGB space.
// */
// public final static Color GRAY = new Color(128, 128, 128);
//
// /**
// * The color dark gray. In the default sRGB space.
// */
// public final static Color DARK_GRAY = new Color(64, 64, 64);
//
// /**
// * The color black. In the default sRGB space.
// */
// public final static Color BLACK = new Color(0, 0, 0);
//
// /**
// * The color red. In the default sRGB space.
// */
// public final static Color RED = new Color(255, 0, 0);
//
// /**
// * The color pink. In the default sRGB space.
// */
// public final static Color PINK = new Color(255, 175, 175);
//
// /**
// * The color orange. In the default sRGB space.
// */
// public final static Color ORANGE = new Color(255, 200, 0);
//
// /**
// * The color yellow. In the default sRGB space.
// */
// public final static Color YELLOW = new Color(255, 255, 0);
//
// /**
// * The color green. In the default sRGB space.
// */
// public final static Color GREEN = new Color(0, 255, 0);
//
// /**
// * The color magenta. In the default sRGB space.
// */
// public final static Color MAGENTA = new Color(255, 0, 255);
//
// /**
// * The color cyan. In the default sRGB space.
// */
// public final static Color CYAN = new Color(0, 255, 255);
//
// /**
// * The color blue. In the default sRGB space.
// */
// public final static Color BLUE = new Color(0, 0, 255);
//
// public Color(int r, int g, int b) {
// this.c = new java.awt.Color(r, g, b);
// }
//
// public java.awt.Color getColor() {
// return c;
// }
//
// public int getRed() {
// return c.getRed();
// }
//
// public int getGreen() {
// return c.getGreen();
// }
//
// public int getBlue() {
// return c.getBlue();
// }
// }
//
// Path: core/src/main/java/org/flightclub/compat/Graphics.java
// public interface Graphics {
// void setColor(Color color);
// void setFont(Font font);
//
// void drawLine(int x1, int y1, int x2, int y2);
// void drawString(String str, int x, int y);
//
// void fillCircle(int x, int y, int diameter);
// void fillPolygon(int[] xPoints, int[] yPoints, int nPoints);
// }
|
import org.flightclub.compat.Color;
import org.flightclub.compat.Graphics;
|
/**
This code is covered by the GNU General Public License
detailed at http://www.gnu.org/copyleft/gpl.html
Flight Club docs located at http://www.danb.dircon.co.uk/hg/hg.htm
Dan Burton , Nov 2001
*/
package org.flightclub;
public class Surface extends PolyLine {
final int[] xs;
final int[] ys;
|
// Path: core/src/main/java/org/flightclub/compat/Color.java
// public class Color {
// private final java.awt.Color c;
//
//
// /**
// * The color white. In the default sRGB space.
// */
// public final static Color WHITE = new Color(255, 255, 255);
//
// /**
// * The color light gray. In the default sRGB space.
// */
// public final static Color LIGHT_GRAY = new Color(192, 192, 192);
//
// /**
// * The color gray. In the default sRGB space.
// */
// public final static Color GRAY = new Color(128, 128, 128);
//
// /**
// * The color dark gray. In the default sRGB space.
// */
// public final static Color DARK_GRAY = new Color(64, 64, 64);
//
// /**
// * The color black. In the default sRGB space.
// */
// public final static Color BLACK = new Color(0, 0, 0);
//
// /**
// * The color red. In the default sRGB space.
// */
// public final static Color RED = new Color(255, 0, 0);
//
// /**
// * The color pink. In the default sRGB space.
// */
// public final static Color PINK = new Color(255, 175, 175);
//
// /**
// * The color orange. In the default sRGB space.
// */
// public final static Color ORANGE = new Color(255, 200, 0);
//
// /**
// * The color yellow. In the default sRGB space.
// */
// public final static Color YELLOW = new Color(255, 255, 0);
//
// /**
// * The color green. In the default sRGB space.
// */
// public final static Color GREEN = new Color(0, 255, 0);
//
// /**
// * The color magenta. In the default sRGB space.
// */
// public final static Color MAGENTA = new Color(255, 0, 255);
//
// /**
// * The color cyan. In the default sRGB space.
// */
// public final static Color CYAN = new Color(0, 255, 255);
//
// /**
// * The color blue. In the default sRGB space.
// */
// public final static Color BLUE = new Color(0, 0, 255);
//
// public Color(int r, int g, int b) {
// this.c = new java.awt.Color(r, g, b);
// }
//
// public java.awt.Color getColor() {
// return c;
// }
//
// public int getRed() {
// return c.getRed();
// }
//
// public int getGreen() {
// return c.getGreen();
// }
//
// public int getBlue() {
// return c.getBlue();
// }
// }
//
// Path: core/src/main/java/org/flightclub/compat/Graphics.java
// public interface Graphics {
// void setColor(Color color);
// void setFont(Font font);
//
// void drawLine(int x1, int y1, int x2, int y2);
// void drawString(String str, int x, int y);
//
// void fillCircle(int x, int y, int diameter);
// void fillPolygon(int[] xPoints, int[] yPoints, int nPoints);
// }
// Path: core/src/main/java/org/flightclub/Surface.java
import org.flightclub.compat.Color;
import org.flightclub.compat.Graphics;
/**
This code is covered by the GNU General Public License
detailed at http://www.gnu.org/copyleft/gpl.html
Flight Club docs located at http://www.danb.dircon.co.uk/hg/hg.htm
Dan Burton , Nov 2001
*/
package org.flightclub;
public class Surface extends PolyLine {
final int[] xs;
final int[] ys;
|
public Surface(Object3d object, int numPoints, Color color) {
|
Turbo87/flight-club
|
core/src/main/java/org/flightclub/Surface.java
|
// Path: core/src/main/java/org/flightclub/compat/Color.java
// public class Color {
// private final java.awt.Color c;
//
//
// /**
// * The color white. In the default sRGB space.
// */
// public final static Color WHITE = new Color(255, 255, 255);
//
// /**
// * The color light gray. In the default sRGB space.
// */
// public final static Color LIGHT_GRAY = new Color(192, 192, 192);
//
// /**
// * The color gray. In the default sRGB space.
// */
// public final static Color GRAY = new Color(128, 128, 128);
//
// /**
// * The color dark gray. In the default sRGB space.
// */
// public final static Color DARK_GRAY = new Color(64, 64, 64);
//
// /**
// * The color black. In the default sRGB space.
// */
// public final static Color BLACK = new Color(0, 0, 0);
//
// /**
// * The color red. In the default sRGB space.
// */
// public final static Color RED = new Color(255, 0, 0);
//
// /**
// * The color pink. In the default sRGB space.
// */
// public final static Color PINK = new Color(255, 175, 175);
//
// /**
// * The color orange. In the default sRGB space.
// */
// public final static Color ORANGE = new Color(255, 200, 0);
//
// /**
// * The color yellow. In the default sRGB space.
// */
// public final static Color YELLOW = new Color(255, 255, 0);
//
// /**
// * The color green. In the default sRGB space.
// */
// public final static Color GREEN = new Color(0, 255, 0);
//
// /**
// * The color magenta. In the default sRGB space.
// */
// public final static Color MAGENTA = new Color(255, 0, 255);
//
// /**
// * The color cyan. In the default sRGB space.
// */
// public final static Color CYAN = new Color(0, 255, 255);
//
// /**
// * The color blue. In the default sRGB space.
// */
// public final static Color BLUE = new Color(0, 0, 255);
//
// public Color(int r, int g, int b) {
// this.c = new java.awt.Color(r, g, b);
// }
//
// public java.awt.Color getColor() {
// return c;
// }
//
// public int getRed() {
// return c.getRed();
// }
//
// public int getGreen() {
// return c.getGreen();
// }
//
// public int getBlue() {
// return c.getBlue();
// }
// }
//
// Path: core/src/main/java/org/flightclub/compat/Graphics.java
// public interface Graphics {
// void setColor(Color color);
// void setFont(Font font);
//
// void drawLine(int x1, int y1, int x2, int y2);
// void drawString(String str, int x, int y);
//
// void fillCircle(int x, int y, int diameter);
// void fillPolygon(int[] xPoints, int[] yPoints, int nPoints);
// }
|
import org.flightclub.compat.Color;
import org.flightclub.compat.Graphics;
|
/**
This code is covered by the GNU General Public License
detailed at http://www.gnu.org/copyleft/gpl.html
Flight Club docs located at http://www.danb.dircon.co.uk/hg/hg.htm
Dan Burton , Nov 2001
*/
package org.flightclub;
public class Surface extends PolyLine {
final int[] xs;
final int[] ys;
public Surface(Object3d object, int numPoints, Color color) {
super(object, numPoints, color);
isSolid = true;
xs = new int[numPoints];
ys = new int[numPoints];
}
@Override
|
// Path: core/src/main/java/org/flightclub/compat/Color.java
// public class Color {
// private final java.awt.Color c;
//
//
// /**
// * The color white. In the default sRGB space.
// */
// public final static Color WHITE = new Color(255, 255, 255);
//
// /**
// * The color light gray. In the default sRGB space.
// */
// public final static Color LIGHT_GRAY = new Color(192, 192, 192);
//
// /**
// * The color gray. In the default sRGB space.
// */
// public final static Color GRAY = new Color(128, 128, 128);
//
// /**
// * The color dark gray. In the default sRGB space.
// */
// public final static Color DARK_GRAY = new Color(64, 64, 64);
//
// /**
// * The color black. In the default sRGB space.
// */
// public final static Color BLACK = new Color(0, 0, 0);
//
// /**
// * The color red. In the default sRGB space.
// */
// public final static Color RED = new Color(255, 0, 0);
//
// /**
// * The color pink. In the default sRGB space.
// */
// public final static Color PINK = new Color(255, 175, 175);
//
// /**
// * The color orange. In the default sRGB space.
// */
// public final static Color ORANGE = new Color(255, 200, 0);
//
// /**
// * The color yellow. In the default sRGB space.
// */
// public final static Color YELLOW = new Color(255, 255, 0);
//
// /**
// * The color green. In the default sRGB space.
// */
// public final static Color GREEN = new Color(0, 255, 0);
//
// /**
// * The color magenta. In the default sRGB space.
// */
// public final static Color MAGENTA = new Color(255, 0, 255);
//
// /**
// * The color cyan. In the default sRGB space.
// */
// public final static Color CYAN = new Color(0, 255, 255);
//
// /**
// * The color blue. In the default sRGB space.
// */
// public final static Color BLUE = new Color(0, 0, 255);
//
// public Color(int r, int g, int b) {
// this.c = new java.awt.Color(r, g, b);
// }
//
// public java.awt.Color getColor() {
// return c;
// }
//
// public int getRed() {
// return c.getRed();
// }
//
// public int getGreen() {
// return c.getGreen();
// }
//
// public int getBlue() {
// return c.getBlue();
// }
// }
//
// Path: core/src/main/java/org/flightclub/compat/Graphics.java
// public interface Graphics {
// void setColor(Color color);
// void setFont(Font font);
//
// void drawLine(int x1, int y1, int x2, int y2);
// void drawString(String str, int x, int y);
//
// void fillCircle(int x, int y, int diameter);
// void fillPolygon(int[] xPoints, int[] yPoints, int nPoints);
// }
// Path: core/src/main/java/org/flightclub/Surface.java
import org.flightclub.compat.Color;
import org.flightclub.compat.Graphics;
/**
This code is covered by the GNU General Public License
detailed at http://www.gnu.org/copyleft/gpl.html
Flight Club docs located at http://www.danb.dircon.co.uk/hg/hg.htm
Dan Burton , Nov 2001
*/
package org.flightclub;
public class Surface extends PolyLine {
final int[] xs;
final int[] ys;
public Surface(Object3d object, int numPoints, Color color) {
super(object, numPoints, color);
isSolid = true;
xs = new int[numPoints];
ys = new int[numPoints];
}
@Override
|
public void draw(Graphics g) {
|
Turbo87/flight-club
|
core/src/main/java/org/flightclub/Glider.java
|
// Path: core/src/main/java/org/flightclub/compat/Color.java
// public class Color {
// private final java.awt.Color c;
//
//
// /**
// * The color white. In the default sRGB space.
// */
// public final static Color WHITE = new Color(255, 255, 255);
//
// /**
// * The color light gray. In the default sRGB space.
// */
// public final static Color LIGHT_GRAY = new Color(192, 192, 192);
//
// /**
// * The color gray. In the default sRGB space.
// */
// public final static Color GRAY = new Color(128, 128, 128);
//
// /**
// * The color dark gray. In the default sRGB space.
// */
// public final static Color DARK_GRAY = new Color(64, 64, 64);
//
// /**
// * The color black. In the default sRGB space.
// */
// public final static Color BLACK = new Color(0, 0, 0);
//
// /**
// * The color red. In the default sRGB space.
// */
// public final static Color RED = new Color(255, 0, 0);
//
// /**
// * The color pink. In the default sRGB space.
// */
// public final static Color PINK = new Color(255, 175, 175);
//
// /**
// * The color orange. In the default sRGB space.
// */
// public final static Color ORANGE = new Color(255, 200, 0);
//
// /**
// * The color yellow. In the default sRGB space.
// */
// public final static Color YELLOW = new Color(255, 255, 0);
//
// /**
// * The color green. In the default sRGB space.
// */
// public final static Color GREEN = new Color(0, 255, 0);
//
// /**
// * The color magenta. In the default sRGB space.
// */
// public final static Color MAGENTA = new Color(255, 0, 255);
//
// /**
// * The color cyan. In the default sRGB space.
// */
// public final static Color CYAN = new Color(0, 255, 255);
//
// /**
// * The color blue. In the default sRGB space.
// */
// public final static Color BLUE = new Color(0, 0, 255);
//
// public Color(int r, int g, int b) {
// this.c = new java.awt.Color(r, g, b);
// }
//
// public java.awt.Color getColor() {
// return c;
// }
//
// public int getRed() {
// return c.getRed();
// }
//
// public int getGreen() {
// return c.getGreen();
// }
//
// public int getBlue() {
// return c.getBlue();
// }
// }
|
import org.flightclub.compat.Color;
|
/**
This code is covered by the GNU General Public License
detailed at http://www.gnu.org/copyleft/gpl.html
Flight Club docs located at http://www.danb.dircon.co.uk/hg/hg.htm
Dan Burton , Nov 2001
*/
package org.flightclub;
/**
* a glider that sniffs out lift
*/
public class Glider extends FlyingBody {
boolean landed = true;
int tryLater = 0;
// hack - only glider user should know about this
boolean demoMode = true;
boolean reachedGoal;
// where on the polar are we
int polarIndex = 0;
// 4 vars for hack to delay cuts
boolean cutPending = false;
int cutWhen;
CameraSubject cutSubject = null;
int cutCount = 0;
// hack var for camera position - left or right depending
int lastEyeX = 1;
boolean triggerLoading = false;
// units of dist (km) per time (minute)
final static float SPEED = (float) 1;
// i.e. glide angle of 8
final static float SINK_RATE = (float) (-1.0 / 8);
final static float TURN_RADIUS = (float) 0.3;
// polar curve
final static float[][] POLAR = {{1, 1}, {(float) 1.5, (float) 2.1}};
public static final int TAIL_LENGTH = 40;
|
// Path: core/src/main/java/org/flightclub/compat/Color.java
// public class Color {
// private final java.awt.Color c;
//
//
// /**
// * The color white. In the default sRGB space.
// */
// public final static Color WHITE = new Color(255, 255, 255);
//
// /**
// * The color light gray. In the default sRGB space.
// */
// public final static Color LIGHT_GRAY = new Color(192, 192, 192);
//
// /**
// * The color gray. In the default sRGB space.
// */
// public final static Color GRAY = new Color(128, 128, 128);
//
// /**
// * The color dark gray. In the default sRGB space.
// */
// public final static Color DARK_GRAY = new Color(64, 64, 64);
//
// /**
// * The color black. In the default sRGB space.
// */
// public final static Color BLACK = new Color(0, 0, 0);
//
// /**
// * The color red. In the default sRGB space.
// */
// public final static Color RED = new Color(255, 0, 0);
//
// /**
// * The color pink. In the default sRGB space.
// */
// public final static Color PINK = new Color(255, 175, 175);
//
// /**
// * The color orange. In the default sRGB space.
// */
// public final static Color ORANGE = new Color(255, 200, 0);
//
// /**
// * The color yellow. In the default sRGB space.
// */
// public final static Color YELLOW = new Color(255, 255, 0);
//
// /**
// * The color green. In the default sRGB space.
// */
// public final static Color GREEN = new Color(0, 255, 0);
//
// /**
// * The color magenta. In the default sRGB space.
// */
// public final static Color MAGENTA = new Color(255, 0, 255);
//
// /**
// * The color cyan. In the default sRGB space.
// */
// public final static Color CYAN = new Color(0, 255, 255);
//
// /**
// * The color blue. In the default sRGB space.
// */
// public final static Color BLUE = new Color(0, 0, 255);
//
// public Color(int r, int g, int b) {
// this.c = new java.awt.Color(r, g, b);
// }
//
// public java.awt.Color getColor() {
// return c;
// }
//
// public int getRed() {
// return c.getRed();
// }
//
// public int getGreen() {
// return c.getGreen();
// }
//
// public int getBlue() {
// return c.getBlue();
// }
// }
// Path: core/src/main/java/org/flightclub/Glider.java
import org.flightclub.compat.Color;
/**
This code is covered by the GNU General Public License
detailed at http://www.gnu.org/copyleft/gpl.html
Flight Club docs located at http://www.danb.dircon.co.uk/hg/hg.htm
Dan Burton , Nov 2001
*/
package org.flightclub;
/**
* a glider that sniffs out lift
*/
public class Glider extends FlyingBody {
boolean landed = true;
int tryLater = 0;
// hack - only glider user should know about this
boolean demoMode = true;
boolean reachedGoal;
// where on the polar are we
int polarIndex = 0;
// 4 vars for hack to delay cuts
boolean cutPending = false;
int cutWhen;
CameraSubject cutSubject = null;
int cutCount = 0;
// hack var for camera position - left or right depending
int lastEyeX = 1;
boolean triggerLoading = false;
// units of dist (km) per time (minute)
final static float SPEED = (float) 1;
// i.e. glide angle of 8
final static float SINK_RATE = (float) (-1.0 / 8);
final static float TURN_RADIUS = (float) 0.3;
// polar curve
final static float[][] POLAR = {{1, 1}, {(float) 1.5, (float) 2.1}};
public static final int TAIL_LENGTH = 40;
|
public static final Color TAIL_COLOR = Color.LIGHT_GRAY;
|
Turbo87/flight-club
|
core/src/main/java/org/flightclub/FlyingDot.java
|
// Path: core/src/main/java/org/flightclub/compat/Color.java
// public class Color {
// private final java.awt.Color c;
//
//
// /**
// * The color white. In the default sRGB space.
// */
// public final static Color WHITE = new Color(255, 255, 255);
//
// /**
// * The color light gray. In the default sRGB space.
// */
// public final static Color LIGHT_GRAY = new Color(192, 192, 192);
//
// /**
// * The color gray. In the default sRGB space.
// */
// public final static Color GRAY = new Color(128, 128, 128);
//
// /**
// * The color dark gray. In the default sRGB space.
// */
// public final static Color DARK_GRAY = new Color(64, 64, 64);
//
// /**
// * The color black. In the default sRGB space.
// */
// public final static Color BLACK = new Color(0, 0, 0);
//
// /**
// * The color red. In the default sRGB space.
// */
// public final static Color RED = new Color(255, 0, 0);
//
// /**
// * The color pink. In the default sRGB space.
// */
// public final static Color PINK = new Color(255, 175, 175);
//
// /**
// * The color orange. In the default sRGB space.
// */
// public final static Color ORANGE = new Color(255, 200, 0);
//
// /**
// * The color yellow. In the default sRGB space.
// */
// public final static Color YELLOW = new Color(255, 255, 0);
//
// /**
// * The color green. In the default sRGB space.
// */
// public final static Color GREEN = new Color(0, 255, 0);
//
// /**
// * The color magenta. In the default sRGB space.
// */
// public final static Color MAGENTA = new Color(255, 0, 255);
//
// /**
// * The color cyan. In the default sRGB space.
// */
// public final static Color CYAN = new Color(0, 255, 255);
//
// /**
// * The color blue. In the default sRGB space.
// */
// public final static Color BLUE = new Color(0, 0, 255);
//
// public Color(int r, int g, int b) {
// this.c = new java.awt.Color(r, g, b);
// }
//
// public java.awt.Color getColor() {
// return c;
// }
//
// public int getRed() {
// return c.getRed();
// }
//
// public int getGreen() {
// return c.getGreen();
// }
//
// public int getBlue() {
// return c.getBlue();
// }
// }
|
import org.flightclub.compat.Color;
|
/**
This code is covered by the GNU General Public License
detailed at http://www.gnu.org/copyleft/gpl.html
Flight Club docs located at http://www.danb.dircon.co.uk/hg/hg.htm
Dan Burton , Nov 2001
*/
package org.flightclub;
/*
a dot with a position and velocity. also...
- a local coord system (v points along +y, z has roll effect)
- turn radius to use when circling. halve this for ridge sooaring.
- factory method for a tail
- ds (horizontal distance moved per tick)
*/
public class FlyingDot implements Clock.Observer, CameraSubject {
final XCGame app;
Vector3d v;
Vector3d p = new Vector3d();
float speed;
float ds;//distance per frame - hack
final float my_turn_radius;
boolean isUser = false; //TODO - tidy this hack ! classname operator ?
final Vector3d axisX = new Vector3d();
final Vector3d axisY = new Vector3d();
final Vector3d axisZ = new Vector3d();
Tail tail = null;
MovementManager moveManager = null;
public static final int TAIL_LENGTH = 25;
|
// Path: core/src/main/java/org/flightclub/compat/Color.java
// public class Color {
// private final java.awt.Color c;
//
//
// /**
// * The color white. In the default sRGB space.
// */
// public final static Color WHITE = new Color(255, 255, 255);
//
// /**
// * The color light gray. In the default sRGB space.
// */
// public final static Color LIGHT_GRAY = new Color(192, 192, 192);
//
// /**
// * The color gray. In the default sRGB space.
// */
// public final static Color GRAY = new Color(128, 128, 128);
//
// /**
// * The color dark gray. In the default sRGB space.
// */
// public final static Color DARK_GRAY = new Color(64, 64, 64);
//
// /**
// * The color black. In the default sRGB space.
// */
// public final static Color BLACK = new Color(0, 0, 0);
//
// /**
// * The color red. In the default sRGB space.
// */
// public final static Color RED = new Color(255, 0, 0);
//
// /**
// * The color pink. In the default sRGB space.
// */
// public final static Color PINK = new Color(255, 175, 175);
//
// /**
// * The color orange. In the default sRGB space.
// */
// public final static Color ORANGE = new Color(255, 200, 0);
//
// /**
// * The color yellow. In the default sRGB space.
// */
// public final static Color YELLOW = new Color(255, 255, 0);
//
// /**
// * The color green. In the default sRGB space.
// */
// public final static Color GREEN = new Color(0, 255, 0);
//
// /**
// * The color magenta. In the default sRGB space.
// */
// public final static Color MAGENTA = new Color(255, 0, 255);
//
// /**
// * The color cyan. In the default sRGB space.
// */
// public final static Color CYAN = new Color(0, 255, 255);
//
// /**
// * The color blue. In the default sRGB space.
// */
// public final static Color BLUE = new Color(0, 0, 255);
//
// public Color(int r, int g, int b) {
// this.c = new java.awt.Color(r, g, b);
// }
//
// public java.awt.Color getColor() {
// return c;
// }
//
// public int getRed() {
// return c.getRed();
// }
//
// public int getGreen() {
// return c.getGreen();
// }
//
// public int getBlue() {
// return c.getBlue();
// }
// }
// Path: core/src/main/java/org/flightclub/FlyingDot.java
import org.flightclub.compat.Color;
/**
This code is covered by the GNU General Public License
detailed at http://www.gnu.org/copyleft/gpl.html
Flight Club docs located at http://www.danb.dircon.co.uk/hg/hg.htm
Dan Burton , Nov 2001
*/
package org.flightclub;
/*
a dot with a position and velocity. also...
- a local coord system (v points along +y, z has roll effect)
- turn radius to use when circling. halve this for ridge sooaring.
- factory method for a tail
- ds (horizontal distance moved per tick)
*/
public class FlyingDot implements Clock.Observer, CameraSubject {
final XCGame app;
Vector3d v;
Vector3d p = new Vector3d();
float speed;
float ds;//distance per frame - hack
final float my_turn_radius;
boolean isUser = false; //TODO - tidy this hack ! classname operator ?
final Vector3d axisX = new Vector3d();
final Vector3d axisY = new Vector3d();
final Vector3d axisZ = new Vector3d();
Tail tail = null;
MovementManager moveManager = null;
public static final int TAIL_LENGTH = 25;
|
public static final Color TAIL_COLOR = Color.LIGHT_GRAY;
|
Turbo87/flight-club
|
core/src/main/java/org/flightclub/ModelCanvas.java
|
// Path: core/src/main/java/org/flightclub/compat/AwtGraphics.java
// public class AwtGraphics implements Graphics {
//
// private final java.awt.Graphics g;
//
// public AwtGraphics(java.awt.Graphics g) {
// this.g = g;
// }
//
// @Override
// public void setColor(Color color) {
// g.setColor(color.getColor());
// }
//
// @Override
// public void drawLine(int x1, int y1, int x2, int y2) {
// g.drawLine(x1, y1, x2, y2);
// }
//
// @Override
// public void setFont(Font font) {
// g.setFont(font.getFont());
// }
//
// @Override
// public void drawString(String str, int x, int y) {
// g.drawString(str, x, y);
// }
//
// @Override
// public void fillPolygon(int[] xPoints, int[] yPoints, int nPoints) {
// g.fillPolygon(xPoints, yPoints, nPoints);
// }
//
// @Override
// public void fillCircle(int x, int y, int diameter) {
// g.fillOval(x, y, diameter, diameter);
// }
// }
|
import org.flightclub.compat.AwtGraphics;
import java.awt.Canvas;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionAdapter;
|
if (mouseTracker.getDeltaY() > 20)
dz = delta / 4;
if (mouseTracker.getDeltaY() < -20)
dz = -delta / 4;
app.cameraMan.rotateEyeAboutFocus(-dtheta);
app.cameraMan.translateZ(-dz);
}
repaint();
}
@Override
public void paint(Graphics g) {
if (imgBuffer == null) return;
updateImgBuffer(graphicsBuffer);
g.drawImage(imgBuffer, 0, 0, this);
}
@Override
public void update(Graphics g) {
paint(g);
}
public void updateImgBuffer(Graphics g) {
g.setColor(backColor);
g.fillRect(0, 0, getWidth(), getHeight());
|
// Path: core/src/main/java/org/flightclub/compat/AwtGraphics.java
// public class AwtGraphics implements Graphics {
//
// private final java.awt.Graphics g;
//
// public AwtGraphics(java.awt.Graphics g) {
// this.g = g;
// }
//
// @Override
// public void setColor(Color color) {
// g.setColor(color.getColor());
// }
//
// @Override
// public void drawLine(int x1, int y1, int x2, int y2) {
// g.drawLine(x1, y1, x2, y2);
// }
//
// @Override
// public void setFont(Font font) {
// g.setFont(font.getFont());
// }
//
// @Override
// public void drawString(String str, int x, int y) {
// g.drawString(str, x, y);
// }
//
// @Override
// public void fillPolygon(int[] xPoints, int[] yPoints, int nPoints) {
// g.fillPolygon(xPoints, yPoints, nPoints);
// }
//
// @Override
// public void fillCircle(int x, int y, int diameter) {
// g.fillOval(x, y, diameter, diameter);
// }
// }
// Path: core/src/main/java/org/flightclub/ModelCanvas.java
import org.flightclub.compat.AwtGraphics;
import java.awt.Canvas;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionAdapter;
if (mouseTracker.getDeltaY() > 20)
dz = delta / 4;
if (mouseTracker.getDeltaY() < -20)
dz = -delta / 4;
app.cameraMan.rotateEyeAboutFocus(-dtheta);
app.cameraMan.translateZ(-dz);
}
repaint();
}
@Override
public void paint(Graphics g) {
if (imgBuffer == null) return;
updateImgBuffer(graphicsBuffer);
g.drawImage(imgBuffer, 0, 0, this);
}
@Override
public void update(Graphics g) {
paint(g);
}
public void updateImgBuffer(Graphics g) {
g.setColor(backColor);
g.fillRect(0, 0, getWidth(), getHeight());
|
app.draw(new AwtGraphics(g), getWidth(), getHeight());
|
Turbo87/flight-club
|
core/src/main/java/org/flightclub/JetTrail.java
|
// Path: core/src/main/java/org/flightclub/compat/Color.java
// public class Color {
// private final java.awt.Color c;
//
//
// /**
// * The color white. In the default sRGB space.
// */
// public final static Color WHITE = new Color(255, 255, 255);
//
// /**
// * The color light gray. In the default sRGB space.
// */
// public final static Color LIGHT_GRAY = new Color(192, 192, 192);
//
// /**
// * The color gray. In the default sRGB space.
// */
// public final static Color GRAY = new Color(128, 128, 128);
//
// /**
// * The color dark gray. In the default sRGB space.
// */
// public final static Color DARK_GRAY = new Color(64, 64, 64);
//
// /**
// * The color black. In the default sRGB space.
// */
// public final static Color BLACK = new Color(0, 0, 0);
//
// /**
// * The color red. In the default sRGB space.
// */
// public final static Color RED = new Color(255, 0, 0);
//
// /**
// * The color pink. In the default sRGB space.
// */
// public final static Color PINK = new Color(255, 175, 175);
//
// /**
// * The color orange. In the default sRGB space.
// */
// public final static Color ORANGE = new Color(255, 200, 0);
//
// /**
// * The color yellow. In the default sRGB space.
// */
// public final static Color YELLOW = new Color(255, 255, 0);
//
// /**
// * The color green. In the default sRGB space.
// */
// public final static Color GREEN = new Color(0, 255, 0);
//
// /**
// * The color magenta. In the default sRGB space.
// */
// public final static Color MAGENTA = new Color(255, 0, 255);
//
// /**
// * The color cyan. In the default sRGB space.
// */
// public final static Color CYAN = new Color(0, 255, 255);
//
// /**
// * The color blue. In the default sRGB space.
// */
// public final static Color BLUE = new Color(0, 0, 255);
//
// public Color(int r, int g, int b) {
// this.c = new java.awt.Color(r, g, b);
// }
//
// public java.awt.Color getColor() {
// return c;
// }
//
// public int getRed() {
// return c.getRed();
// }
//
// public int getGreen() {
// return c.getGreen();
// }
//
// public int getBlue() {
// return c.getBlue();
// }
// }
|
import org.flightclub.compat.Color;
|
/**
This code is covered by the GNU General Public License
detailed at http://www.gnu.org/copyleft/gpl.html
Flight Club docs located at http://www.danb.dircon.co.uk/hg/hg.htm
Dan Burton , Nov 2001
*/
package org.flightclub;
/**
* a jet in the upper atmosphere - leaves a long trail
*/
public class JetTrail extends FlyingDot {
static final float SPEED = 5;
static final float ALTITUDE = 6;
static final float TURN_RADIUS = 16;
FlyingDot buzzThis;
static final float RANGE = 40;
public static final int TAIL_LENGTH = 240;
|
// Path: core/src/main/java/org/flightclub/compat/Color.java
// public class Color {
// private final java.awt.Color c;
//
//
// /**
// * The color white. In the default sRGB space.
// */
// public final static Color WHITE = new Color(255, 255, 255);
//
// /**
// * The color light gray. In the default sRGB space.
// */
// public final static Color LIGHT_GRAY = new Color(192, 192, 192);
//
// /**
// * The color gray. In the default sRGB space.
// */
// public final static Color GRAY = new Color(128, 128, 128);
//
// /**
// * The color dark gray. In the default sRGB space.
// */
// public final static Color DARK_GRAY = new Color(64, 64, 64);
//
// /**
// * The color black. In the default sRGB space.
// */
// public final static Color BLACK = new Color(0, 0, 0);
//
// /**
// * The color red. In the default sRGB space.
// */
// public final static Color RED = new Color(255, 0, 0);
//
// /**
// * The color pink. In the default sRGB space.
// */
// public final static Color PINK = new Color(255, 175, 175);
//
// /**
// * The color orange. In the default sRGB space.
// */
// public final static Color ORANGE = new Color(255, 200, 0);
//
// /**
// * The color yellow. In the default sRGB space.
// */
// public final static Color YELLOW = new Color(255, 255, 0);
//
// /**
// * The color green. In the default sRGB space.
// */
// public final static Color GREEN = new Color(0, 255, 0);
//
// /**
// * The color magenta. In the default sRGB space.
// */
// public final static Color MAGENTA = new Color(255, 0, 255);
//
// /**
// * The color cyan. In the default sRGB space.
// */
// public final static Color CYAN = new Color(0, 255, 255);
//
// /**
// * The color blue. In the default sRGB space.
// */
// public final static Color BLUE = new Color(0, 0, 255);
//
// public Color(int r, int g, int b) {
// this.c = new java.awt.Color(r, g, b);
// }
//
// public java.awt.Color getColor() {
// return c;
// }
//
// public int getRed() {
// return c.getRed();
// }
//
// public int getGreen() {
// return c.getGreen();
// }
//
// public int getBlue() {
// return c.getBlue();
// }
// }
// Path: core/src/main/java/org/flightclub/JetTrail.java
import org.flightclub.compat.Color;
/**
This code is covered by the GNU General Public License
detailed at http://www.gnu.org/copyleft/gpl.html
Flight Club docs located at http://www.danb.dircon.co.uk/hg/hg.htm
Dan Burton , Nov 2001
*/
package org.flightclub;
/**
* a jet in the upper atmosphere - leaves a long trail
*/
public class JetTrail extends FlyingDot {
static final float SPEED = 5;
static final float ALTITUDE = 6;
static final float TURN_RADIUS = 16;
FlyingDot buzzThis;
static final float RANGE = 40;
public static final int TAIL_LENGTH = 240;
|
public static final Color TAIL_COLOR = new Color(200, 200, 200);
|
Turbo87/flight-club
|
core/src/main/java/org/flightclub/GliderUser.java
|
// Path: core/src/main/java/org/flightclub/compat/Color.java
// public class Color {
// private final java.awt.Color c;
//
//
// /**
// * The color white. In the default sRGB space.
// */
// public final static Color WHITE = new Color(255, 255, 255);
//
// /**
// * The color light gray. In the default sRGB space.
// */
// public final static Color LIGHT_GRAY = new Color(192, 192, 192);
//
// /**
// * The color gray. In the default sRGB space.
// */
// public final static Color GRAY = new Color(128, 128, 128);
//
// /**
// * The color dark gray. In the default sRGB space.
// */
// public final static Color DARK_GRAY = new Color(64, 64, 64);
//
// /**
// * The color black. In the default sRGB space.
// */
// public final static Color BLACK = new Color(0, 0, 0);
//
// /**
// * The color red. In the default sRGB space.
// */
// public final static Color RED = new Color(255, 0, 0);
//
// /**
// * The color pink. In the default sRGB space.
// */
// public final static Color PINK = new Color(255, 175, 175);
//
// /**
// * The color orange. In the default sRGB space.
// */
// public final static Color ORANGE = new Color(255, 200, 0);
//
// /**
// * The color yellow. In the default sRGB space.
// */
// public final static Color YELLOW = new Color(255, 255, 0);
//
// /**
// * The color green. In the default sRGB space.
// */
// public final static Color GREEN = new Color(0, 255, 0);
//
// /**
// * The color magenta. In the default sRGB space.
// */
// public final static Color MAGENTA = new Color(255, 0, 255);
//
// /**
// * The color cyan. In the default sRGB space.
// */
// public final static Color CYAN = new Color(0, 255, 255);
//
// /**
// * The color blue. In the default sRGB space.
// */
// public final static Color BLUE = new Color(0, 0, 255);
//
// public Color(int r, int g, int b) {
// this.c = new java.awt.Color(r, g, b);
// }
//
// public java.awt.Color getColor() {
// return c;
// }
//
// public int getRed() {
// return c.getRed();
// }
//
// public int getGreen() {
// return c.getGreen();
// }
//
// public int getBlue() {
// return c.getBlue();
// }
// }
|
import org.flightclub.compat.Color;
import java.awt.event.KeyEvent;
|
/**
This code is covered by the GNU General Public License
detailed at http://www.gnu.org/copyleft/gpl.html
Flight Club docs located at http://www.danb.dircon.co.uk/hg/hg.htm
Dan Burton , Nov 2001
*/
package org.flightclub;
/**
* a glider that the user may control
*/
public class GliderUser extends Glider implements EventManager.Interface {
public static final int TAIL_LENGTH = 60;
|
// Path: core/src/main/java/org/flightclub/compat/Color.java
// public class Color {
// private final java.awt.Color c;
//
//
// /**
// * The color white. In the default sRGB space.
// */
// public final static Color WHITE = new Color(255, 255, 255);
//
// /**
// * The color light gray. In the default sRGB space.
// */
// public final static Color LIGHT_GRAY = new Color(192, 192, 192);
//
// /**
// * The color gray. In the default sRGB space.
// */
// public final static Color GRAY = new Color(128, 128, 128);
//
// /**
// * The color dark gray. In the default sRGB space.
// */
// public final static Color DARK_GRAY = new Color(64, 64, 64);
//
// /**
// * The color black. In the default sRGB space.
// */
// public final static Color BLACK = new Color(0, 0, 0);
//
// /**
// * The color red. In the default sRGB space.
// */
// public final static Color RED = new Color(255, 0, 0);
//
// /**
// * The color pink. In the default sRGB space.
// */
// public final static Color PINK = new Color(255, 175, 175);
//
// /**
// * The color orange. In the default sRGB space.
// */
// public final static Color ORANGE = new Color(255, 200, 0);
//
// /**
// * The color yellow. In the default sRGB space.
// */
// public final static Color YELLOW = new Color(255, 255, 0);
//
// /**
// * The color green. In the default sRGB space.
// */
// public final static Color GREEN = new Color(0, 255, 0);
//
// /**
// * The color magenta. In the default sRGB space.
// */
// public final static Color MAGENTA = new Color(255, 0, 255);
//
// /**
// * The color cyan. In the default sRGB space.
// */
// public final static Color CYAN = new Color(0, 255, 255);
//
// /**
// * The color blue. In the default sRGB space.
// */
// public final static Color BLUE = new Color(0, 0, 255);
//
// public Color(int r, int g, int b) {
// this.c = new java.awt.Color(r, g, b);
// }
//
// public java.awt.Color getColor() {
// return c;
// }
//
// public int getRed() {
// return c.getRed();
// }
//
// public int getGreen() {
// return c.getGreen();
// }
//
// public int getBlue() {
// return c.getBlue();
// }
// }
// Path: core/src/main/java/org/flightclub/GliderUser.java
import org.flightclub.compat.Color;
import java.awt.event.KeyEvent;
/**
This code is covered by the GNU General Public License
detailed at http://www.gnu.org/copyleft/gpl.html
Flight Club docs located at http://www.danb.dircon.co.uk/hg/hg.htm
Dan Burton , Nov 2001
*/
package org.flightclub;
/**
* a glider that the user may control
*/
public class GliderUser extends Glider implements EventManager.Interface {
public static final int TAIL_LENGTH = 60;
|
public static final Color TAIL_COLOR = new Color(120, 120, 120);
|
Turbo87/flight-club
|
core/src/main/java/org/flightclub/Compass.java
|
// Path: core/src/main/java/org/flightclub/compat/Color.java
// public class Color {
// private final java.awt.Color c;
//
//
// /**
// * The color white. In the default sRGB space.
// */
// public final static Color WHITE = new Color(255, 255, 255);
//
// /**
// * The color light gray. In the default sRGB space.
// */
// public final static Color LIGHT_GRAY = new Color(192, 192, 192);
//
// /**
// * The color gray. In the default sRGB space.
// */
// public final static Color GRAY = new Color(128, 128, 128);
//
// /**
// * The color dark gray. In the default sRGB space.
// */
// public final static Color DARK_GRAY = new Color(64, 64, 64);
//
// /**
// * The color black. In the default sRGB space.
// */
// public final static Color BLACK = new Color(0, 0, 0);
//
// /**
// * The color red. In the default sRGB space.
// */
// public final static Color RED = new Color(255, 0, 0);
//
// /**
// * The color pink. In the default sRGB space.
// */
// public final static Color PINK = new Color(255, 175, 175);
//
// /**
// * The color orange. In the default sRGB space.
// */
// public final static Color ORANGE = new Color(255, 200, 0);
//
// /**
// * The color yellow. In the default sRGB space.
// */
// public final static Color YELLOW = new Color(255, 255, 0);
//
// /**
// * The color green. In the default sRGB space.
// */
// public final static Color GREEN = new Color(0, 255, 0);
//
// /**
// * The color magenta. In the default sRGB space.
// */
// public final static Color MAGENTA = new Color(255, 0, 255);
//
// /**
// * The color cyan. In the default sRGB space.
// */
// public final static Color CYAN = new Color(0, 255, 255);
//
// /**
// * The color blue. In the default sRGB space.
// */
// public final static Color BLUE = new Color(0, 0, 255);
//
// public Color(int r, int g, int b) {
// this.c = new java.awt.Color(r, g, b);
// }
//
// public java.awt.Color getColor() {
// return c;
// }
//
// public int getRed() {
// return c.getRed();
// }
//
// public int getGreen() {
// return c.getGreen();
// }
//
// public int getBlue() {
// return c.getBlue();
// }
// }
//
// Path: core/src/main/java/org/flightclub/compat/Font.java
// public class Font {
// private java.awt.Font f;
//
// /**
// * The plain style constant.
// */
// public static final int PLAIN = 0;
//
// /**
// * The bold style constant. This can be combined with the other style
// * constants (except PLAIN) for mixed styles.
// */
// public static final int BOLD = 1;
//
// /**
// * The italicized style constant. This can be combined with the other
// * style constants (except PLAIN) for mixed styles.
// */
// public static final int ITALIC = 2;
//
// public Font(String name, int style, int size) {
// this(new java.awt.Font(name, style, size));
// }
//
// public Font(java.awt.Font f) {
// this.f = f;
// }
//
// public java.awt.Font getFont() {
// return f;
// }
// }
//
// Path: core/src/main/java/org/flightclub/compat/Graphics.java
// public interface Graphics {
// void setColor(Color color);
// void setFont(Font font);
//
// void drawLine(int x1, int y1, int x2, int y2);
// void drawString(String str, int x, int y);
//
// void fillCircle(int x, int y, int diameter);
// void fillPolygon(int[] xPoints, int[] yPoints, int nPoints);
// }
|
import org.flightclub.compat.Color;
import org.flightclub.compat.Font;
import org.flightclub.compat.Graphics;
|
*/
float s = (float) (r - 2) / 5;
for (int i = 0; i < H_NUM; i++) {
hxs[i] = (int) (hxs[i] * s);
hys[i] = (int) (hys[i] * -s);
}
for (int i = 0; i < T_NUM; i++) {
txs[i] = (int) (txs[i] * s);
tys[i] = (int) (tys[i] * -s);
}
updateArrow();
}
void setArrow(float x, float y) {
// +y is north
// +x is east
vx = x;
vy = y;
// normalize
float d = (float) Math.hypot(x, y);
vx = vx / d;
vy = vy / d;
// calc arrow points
updateArrow();
}
|
// Path: core/src/main/java/org/flightclub/compat/Color.java
// public class Color {
// private final java.awt.Color c;
//
//
// /**
// * The color white. In the default sRGB space.
// */
// public final static Color WHITE = new Color(255, 255, 255);
//
// /**
// * The color light gray. In the default sRGB space.
// */
// public final static Color LIGHT_GRAY = new Color(192, 192, 192);
//
// /**
// * The color gray. In the default sRGB space.
// */
// public final static Color GRAY = new Color(128, 128, 128);
//
// /**
// * The color dark gray. In the default sRGB space.
// */
// public final static Color DARK_GRAY = new Color(64, 64, 64);
//
// /**
// * The color black. In the default sRGB space.
// */
// public final static Color BLACK = new Color(0, 0, 0);
//
// /**
// * The color red. In the default sRGB space.
// */
// public final static Color RED = new Color(255, 0, 0);
//
// /**
// * The color pink. In the default sRGB space.
// */
// public final static Color PINK = new Color(255, 175, 175);
//
// /**
// * The color orange. In the default sRGB space.
// */
// public final static Color ORANGE = new Color(255, 200, 0);
//
// /**
// * The color yellow. In the default sRGB space.
// */
// public final static Color YELLOW = new Color(255, 255, 0);
//
// /**
// * The color green. In the default sRGB space.
// */
// public final static Color GREEN = new Color(0, 255, 0);
//
// /**
// * The color magenta. In the default sRGB space.
// */
// public final static Color MAGENTA = new Color(255, 0, 255);
//
// /**
// * The color cyan. In the default sRGB space.
// */
// public final static Color CYAN = new Color(0, 255, 255);
//
// /**
// * The color blue. In the default sRGB space.
// */
// public final static Color BLUE = new Color(0, 0, 255);
//
// public Color(int r, int g, int b) {
// this.c = new java.awt.Color(r, g, b);
// }
//
// public java.awt.Color getColor() {
// return c;
// }
//
// public int getRed() {
// return c.getRed();
// }
//
// public int getGreen() {
// return c.getGreen();
// }
//
// public int getBlue() {
// return c.getBlue();
// }
// }
//
// Path: core/src/main/java/org/flightclub/compat/Font.java
// public class Font {
// private java.awt.Font f;
//
// /**
// * The plain style constant.
// */
// public static final int PLAIN = 0;
//
// /**
// * The bold style constant. This can be combined with the other style
// * constants (except PLAIN) for mixed styles.
// */
// public static final int BOLD = 1;
//
// /**
// * The italicized style constant. This can be combined with the other
// * style constants (except PLAIN) for mixed styles.
// */
// public static final int ITALIC = 2;
//
// public Font(String name, int style, int size) {
// this(new java.awt.Font(name, style, size));
// }
//
// public Font(java.awt.Font f) {
// this.f = f;
// }
//
// public java.awt.Font getFont() {
// return f;
// }
// }
//
// Path: core/src/main/java/org/flightclub/compat/Graphics.java
// public interface Graphics {
// void setColor(Color color);
// void setFont(Font font);
//
// void drawLine(int x1, int y1, int x2, int y2);
// void drawString(String str, int x, int y);
//
// void fillCircle(int x, int y, int diameter);
// void fillPolygon(int[] xPoints, int[] yPoints, int nPoints);
// }
// Path: core/src/main/java/org/flightclub/Compass.java
import org.flightclub.compat.Color;
import org.flightclub.compat.Font;
import org.flightclub.compat.Graphics;
*/
float s = (float) (r - 2) / 5;
for (int i = 0; i < H_NUM; i++) {
hxs[i] = (int) (hxs[i] * s);
hys[i] = (int) (hys[i] * -s);
}
for (int i = 0; i < T_NUM; i++) {
txs[i] = (int) (txs[i] * s);
tys[i] = (int) (tys[i] * -s);
}
updateArrow();
}
void setArrow(float x, float y) {
// +y is north
// +x is east
vx = x;
vy = y;
// normalize
float d = (float) Math.hypot(x, y);
vx = vx / d;
vy = vy / d;
// calc arrow points
updateArrow();
}
|
public void draw(Graphics g) {
|
Turbo87/flight-club
|
core/src/main/java/org/flightclub/Compass.java
|
// Path: core/src/main/java/org/flightclub/compat/Color.java
// public class Color {
// private final java.awt.Color c;
//
//
// /**
// * The color white. In the default sRGB space.
// */
// public final static Color WHITE = new Color(255, 255, 255);
//
// /**
// * The color light gray. In the default sRGB space.
// */
// public final static Color LIGHT_GRAY = new Color(192, 192, 192);
//
// /**
// * The color gray. In the default sRGB space.
// */
// public final static Color GRAY = new Color(128, 128, 128);
//
// /**
// * The color dark gray. In the default sRGB space.
// */
// public final static Color DARK_GRAY = new Color(64, 64, 64);
//
// /**
// * The color black. In the default sRGB space.
// */
// public final static Color BLACK = new Color(0, 0, 0);
//
// /**
// * The color red. In the default sRGB space.
// */
// public final static Color RED = new Color(255, 0, 0);
//
// /**
// * The color pink. In the default sRGB space.
// */
// public final static Color PINK = new Color(255, 175, 175);
//
// /**
// * The color orange. In the default sRGB space.
// */
// public final static Color ORANGE = new Color(255, 200, 0);
//
// /**
// * The color yellow. In the default sRGB space.
// */
// public final static Color YELLOW = new Color(255, 255, 0);
//
// /**
// * The color green. In the default sRGB space.
// */
// public final static Color GREEN = new Color(0, 255, 0);
//
// /**
// * The color magenta. In the default sRGB space.
// */
// public final static Color MAGENTA = new Color(255, 0, 255);
//
// /**
// * The color cyan. In the default sRGB space.
// */
// public final static Color CYAN = new Color(0, 255, 255);
//
// /**
// * The color blue. In the default sRGB space.
// */
// public final static Color BLUE = new Color(0, 0, 255);
//
// public Color(int r, int g, int b) {
// this.c = new java.awt.Color(r, g, b);
// }
//
// public java.awt.Color getColor() {
// return c;
// }
//
// public int getRed() {
// return c.getRed();
// }
//
// public int getGreen() {
// return c.getGreen();
// }
//
// public int getBlue() {
// return c.getBlue();
// }
// }
//
// Path: core/src/main/java/org/flightclub/compat/Font.java
// public class Font {
// private java.awt.Font f;
//
// /**
// * The plain style constant.
// */
// public static final int PLAIN = 0;
//
// /**
// * The bold style constant. This can be combined with the other style
// * constants (except PLAIN) for mixed styles.
// */
// public static final int BOLD = 1;
//
// /**
// * The italicized style constant. This can be combined with the other
// * style constants (except PLAIN) for mixed styles.
// */
// public static final int ITALIC = 2;
//
// public Font(String name, int style, int size) {
// this(new java.awt.Font(name, style, size));
// }
//
// public Font(java.awt.Font f) {
// this.f = f;
// }
//
// public java.awt.Font getFont() {
// return f;
// }
// }
//
// Path: core/src/main/java/org/flightclub/compat/Graphics.java
// public interface Graphics {
// void setColor(Color color);
// void setFont(Font font);
//
// void drawLine(int x1, int y1, int x2, int y2);
// void drawString(String str, int x, int y);
//
// void fillCircle(int x, int y, int diameter);
// void fillPolygon(int[] xPoints, int[] yPoints, int nPoints);
// }
|
import org.flightclub.compat.Color;
import org.flightclub.compat.Font;
import org.flightclub.compat.Graphics;
|
for (int i = 0; i < H_NUM; i++) {
hxs[i] = (int) (hxs[i] * s);
hys[i] = (int) (hys[i] * -s);
}
for (int i = 0; i < T_NUM; i++) {
txs[i] = (int) (txs[i] * s);
tys[i] = (int) (tys[i] * -s);
}
updateArrow();
}
void setArrow(float x, float y) {
// +y is north
// +x is east
vx = x;
vy = y;
// normalize
float d = (float) Math.hypot(x, y);
vx = vx / d;
vy = vy / d;
// calc arrow points
updateArrow();
}
public void draw(Graphics g) {
|
// Path: core/src/main/java/org/flightclub/compat/Color.java
// public class Color {
// private final java.awt.Color c;
//
//
// /**
// * The color white. In the default sRGB space.
// */
// public final static Color WHITE = new Color(255, 255, 255);
//
// /**
// * The color light gray. In the default sRGB space.
// */
// public final static Color LIGHT_GRAY = new Color(192, 192, 192);
//
// /**
// * The color gray. In the default sRGB space.
// */
// public final static Color GRAY = new Color(128, 128, 128);
//
// /**
// * The color dark gray. In the default sRGB space.
// */
// public final static Color DARK_GRAY = new Color(64, 64, 64);
//
// /**
// * The color black. In the default sRGB space.
// */
// public final static Color BLACK = new Color(0, 0, 0);
//
// /**
// * The color red. In the default sRGB space.
// */
// public final static Color RED = new Color(255, 0, 0);
//
// /**
// * The color pink. In the default sRGB space.
// */
// public final static Color PINK = new Color(255, 175, 175);
//
// /**
// * The color orange. In the default sRGB space.
// */
// public final static Color ORANGE = new Color(255, 200, 0);
//
// /**
// * The color yellow. In the default sRGB space.
// */
// public final static Color YELLOW = new Color(255, 255, 0);
//
// /**
// * The color green. In the default sRGB space.
// */
// public final static Color GREEN = new Color(0, 255, 0);
//
// /**
// * The color magenta. In the default sRGB space.
// */
// public final static Color MAGENTA = new Color(255, 0, 255);
//
// /**
// * The color cyan. In the default sRGB space.
// */
// public final static Color CYAN = new Color(0, 255, 255);
//
// /**
// * The color blue. In the default sRGB space.
// */
// public final static Color BLUE = new Color(0, 0, 255);
//
// public Color(int r, int g, int b) {
// this.c = new java.awt.Color(r, g, b);
// }
//
// public java.awt.Color getColor() {
// return c;
// }
//
// public int getRed() {
// return c.getRed();
// }
//
// public int getGreen() {
// return c.getGreen();
// }
//
// public int getBlue() {
// return c.getBlue();
// }
// }
//
// Path: core/src/main/java/org/flightclub/compat/Font.java
// public class Font {
// private java.awt.Font f;
//
// /**
// * The plain style constant.
// */
// public static final int PLAIN = 0;
//
// /**
// * The bold style constant. This can be combined with the other style
// * constants (except PLAIN) for mixed styles.
// */
// public static final int BOLD = 1;
//
// /**
// * The italicized style constant. This can be combined with the other
// * style constants (except PLAIN) for mixed styles.
// */
// public static final int ITALIC = 2;
//
// public Font(String name, int style, int size) {
// this(new java.awt.Font(name, style, size));
// }
//
// public Font(java.awt.Font f) {
// this.f = f;
// }
//
// public java.awt.Font getFont() {
// return f;
// }
// }
//
// Path: core/src/main/java/org/flightclub/compat/Graphics.java
// public interface Graphics {
// void setColor(Color color);
// void setFont(Font font);
//
// void drawLine(int x1, int y1, int x2, int y2);
// void drawString(String str, int x, int y);
//
// void fillCircle(int x, int y, int diameter);
// void fillPolygon(int[] xPoints, int[] yPoints, int nPoints);
// }
// Path: core/src/main/java/org/flightclub/Compass.java
import org.flightclub.compat.Color;
import org.flightclub.compat.Font;
import org.flightclub.compat.Graphics;
for (int i = 0; i < H_NUM; i++) {
hxs[i] = (int) (hxs[i] * s);
hys[i] = (int) (hys[i] * -s);
}
for (int i = 0; i < T_NUM; i++) {
txs[i] = (int) (txs[i] * s);
tys[i] = (int) (tys[i] * -s);
}
updateArrow();
}
void setArrow(float x, float y) {
// +y is north
// +x is east
vx = x;
vy = y;
// normalize
float d = (float) Math.hypot(x, y);
vx = vx / d;
vy = vy / d;
// calc arrow points
updateArrow();
}
public void draw(Graphics g) {
|
g.setColor(Color.LIGHT_GRAY);
|
Turbo87/flight-club
|
core/src/main/java/org/flightclub/Compass.java
|
// Path: core/src/main/java/org/flightclub/compat/Color.java
// public class Color {
// private final java.awt.Color c;
//
//
// /**
// * The color white. In the default sRGB space.
// */
// public final static Color WHITE = new Color(255, 255, 255);
//
// /**
// * The color light gray. In the default sRGB space.
// */
// public final static Color LIGHT_GRAY = new Color(192, 192, 192);
//
// /**
// * The color gray. In the default sRGB space.
// */
// public final static Color GRAY = new Color(128, 128, 128);
//
// /**
// * The color dark gray. In the default sRGB space.
// */
// public final static Color DARK_GRAY = new Color(64, 64, 64);
//
// /**
// * The color black. In the default sRGB space.
// */
// public final static Color BLACK = new Color(0, 0, 0);
//
// /**
// * The color red. In the default sRGB space.
// */
// public final static Color RED = new Color(255, 0, 0);
//
// /**
// * The color pink. In the default sRGB space.
// */
// public final static Color PINK = new Color(255, 175, 175);
//
// /**
// * The color orange. In the default sRGB space.
// */
// public final static Color ORANGE = new Color(255, 200, 0);
//
// /**
// * The color yellow. In the default sRGB space.
// */
// public final static Color YELLOW = new Color(255, 255, 0);
//
// /**
// * The color green. In the default sRGB space.
// */
// public final static Color GREEN = new Color(0, 255, 0);
//
// /**
// * The color magenta. In the default sRGB space.
// */
// public final static Color MAGENTA = new Color(255, 0, 255);
//
// /**
// * The color cyan. In the default sRGB space.
// */
// public final static Color CYAN = new Color(0, 255, 255);
//
// /**
// * The color blue. In the default sRGB space.
// */
// public final static Color BLUE = new Color(0, 0, 255);
//
// public Color(int r, int g, int b) {
// this.c = new java.awt.Color(r, g, b);
// }
//
// public java.awt.Color getColor() {
// return c;
// }
//
// public int getRed() {
// return c.getRed();
// }
//
// public int getGreen() {
// return c.getGreen();
// }
//
// public int getBlue() {
// return c.getBlue();
// }
// }
//
// Path: core/src/main/java/org/flightclub/compat/Font.java
// public class Font {
// private java.awt.Font f;
//
// /**
// * The plain style constant.
// */
// public static final int PLAIN = 0;
//
// /**
// * The bold style constant. This can be combined with the other style
// * constants (except PLAIN) for mixed styles.
// */
// public static final int BOLD = 1;
//
// /**
// * The italicized style constant. This can be combined with the other
// * style constants (except PLAIN) for mixed styles.
// */
// public static final int ITALIC = 2;
//
// public Font(String name, int style, int size) {
// this(new java.awt.Font(name, style, size));
// }
//
// public Font(java.awt.Font f) {
// this.f = f;
// }
//
// public java.awt.Font getFont() {
// return f;
// }
// }
//
// Path: core/src/main/java/org/flightclub/compat/Graphics.java
// public interface Graphics {
// void setColor(Color color);
// void setFont(Font font);
//
// void drawLine(int x1, int y1, int x2, int y2);
// void drawString(String str, int x, int y);
//
// void fillCircle(int x, int y, int diameter);
// void fillPolygon(int[] xPoints, int[] yPoints, int nPoints);
// }
|
import org.flightclub.compat.Color;
import org.flightclub.compat.Font;
import org.flightclub.compat.Graphics;
|
hys[i] = (int) (hys[i] * -s);
}
for (int i = 0; i < T_NUM; i++) {
txs[i] = (int) (txs[i] * s);
tys[i] = (int) (tys[i] * -s);
}
updateArrow();
}
void setArrow(float x, float y) {
// +y is north
// +x is east
vx = x;
vy = y;
// normalize
float d = (float) Math.hypot(x, y);
vx = vx / d;
vy = vy / d;
// calc arrow points
updateArrow();
}
public void draw(Graphics g) {
g.setColor(Color.LIGHT_GRAY);
g.drawLine(txs_[0], tys_[0], txs_[1], tys_[1]);
|
// Path: core/src/main/java/org/flightclub/compat/Color.java
// public class Color {
// private final java.awt.Color c;
//
//
// /**
// * The color white. In the default sRGB space.
// */
// public final static Color WHITE = new Color(255, 255, 255);
//
// /**
// * The color light gray. In the default sRGB space.
// */
// public final static Color LIGHT_GRAY = new Color(192, 192, 192);
//
// /**
// * The color gray. In the default sRGB space.
// */
// public final static Color GRAY = new Color(128, 128, 128);
//
// /**
// * The color dark gray. In the default sRGB space.
// */
// public final static Color DARK_GRAY = new Color(64, 64, 64);
//
// /**
// * The color black. In the default sRGB space.
// */
// public final static Color BLACK = new Color(0, 0, 0);
//
// /**
// * The color red. In the default sRGB space.
// */
// public final static Color RED = new Color(255, 0, 0);
//
// /**
// * The color pink. In the default sRGB space.
// */
// public final static Color PINK = new Color(255, 175, 175);
//
// /**
// * The color orange. In the default sRGB space.
// */
// public final static Color ORANGE = new Color(255, 200, 0);
//
// /**
// * The color yellow. In the default sRGB space.
// */
// public final static Color YELLOW = new Color(255, 255, 0);
//
// /**
// * The color green. In the default sRGB space.
// */
// public final static Color GREEN = new Color(0, 255, 0);
//
// /**
// * The color magenta. In the default sRGB space.
// */
// public final static Color MAGENTA = new Color(255, 0, 255);
//
// /**
// * The color cyan. In the default sRGB space.
// */
// public final static Color CYAN = new Color(0, 255, 255);
//
// /**
// * The color blue. In the default sRGB space.
// */
// public final static Color BLUE = new Color(0, 0, 255);
//
// public Color(int r, int g, int b) {
// this.c = new java.awt.Color(r, g, b);
// }
//
// public java.awt.Color getColor() {
// return c;
// }
//
// public int getRed() {
// return c.getRed();
// }
//
// public int getGreen() {
// return c.getGreen();
// }
//
// public int getBlue() {
// return c.getBlue();
// }
// }
//
// Path: core/src/main/java/org/flightclub/compat/Font.java
// public class Font {
// private java.awt.Font f;
//
// /**
// * The plain style constant.
// */
// public static final int PLAIN = 0;
//
// /**
// * The bold style constant. This can be combined with the other style
// * constants (except PLAIN) for mixed styles.
// */
// public static final int BOLD = 1;
//
// /**
// * The italicized style constant. This can be combined with the other
// * style constants (except PLAIN) for mixed styles.
// */
// public static final int ITALIC = 2;
//
// public Font(String name, int style, int size) {
// this(new java.awt.Font(name, style, size));
// }
//
// public Font(java.awt.Font f) {
// this.f = f;
// }
//
// public java.awt.Font getFont() {
// return f;
// }
// }
//
// Path: core/src/main/java/org/flightclub/compat/Graphics.java
// public interface Graphics {
// void setColor(Color color);
// void setFont(Font font);
//
// void drawLine(int x1, int y1, int x2, int y2);
// void drawString(String str, int x, int y);
//
// void fillCircle(int x, int y, int diameter);
// void fillPolygon(int[] xPoints, int[] yPoints, int nPoints);
// }
// Path: core/src/main/java/org/flightclub/Compass.java
import org.flightclub.compat.Color;
import org.flightclub.compat.Font;
import org.flightclub.compat.Graphics;
hys[i] = (int) (hys[i] * -s);
}
for (int i = 0; i < T_NUM; i++) {
txs[i] = (int) (txs[i] * s);
tys[i] = (int) (tys[i] * -s);
}
updateArrow();
}
void setArrow(float x, float y) {
// +y is north
// +x is east
vx = x;
vy = y;
// normalize
float d = (float) Math.hypot(x, y);
vx = vx / d;
vy = vy / d;
// calc arrow points
updateArrow();
}
public void draw(Graphics g) {
g.setColor(Color.LIGHT_GRAY);
g.drawLine(txs_[0], tys_[0], txs_[1], tys_[1]);
|
Font font = new Font("SansSerif", Font.PLAIN, 10);
|
Turbo87/flight-club
|
core/src/main/java/org/flightclub/Hill.java
|
// Path: core/src/main/java/org/flightclub/compat/Color.java
// public class Color {
// private final java.awt.Color c;
//
//
// /**
// * The color white. In the default sRGB space.
// */
// public final static Color WHITE = new Color(255, 255, 255);
//
// /**
// * The color light gray. In the default sRGB space.
// */
// public final static Color LIGHT_GRAY = new Color(192, 192, 192);
//
// /**
// * The color gray. In the default sRGB space.
// */
// public final static Color GRAY = new Color(128, 128, 128);
//
// /**
// * The color dark gray. In the default sRGB space.
// */
// public final static Color DARK_GRAY = new Color(64, 64, 64);
//
// /**
// * The color black. In the default sRGB space.
// */
// public final static Color BLACK = new Color(0, 0, 0);
//
// /**
// * The color red. In the default sRGB space.
// */
// public final static Color RED = new Color(255, 0, 0);
//
// /**
// * The color pink. In the default sRGB space.
// */
// public final static Color PINK = new Color(255, 175, 175);
//
// /**
// * The color orange. In the default sRGB space.
// */
// public final static Color ORANGE = new Color(255, 200, 0);
//
// /**
// * The color yellow. In the default sRGB space.
// */
// public final static Color YELLOW = new Color(255, 255, 0);
//
// /**
// * The color green. In the default sRGB space.
// */
// public final static Color GREEN = new Color(0, 255, 0);
//
// /**
// * The color magenta. In the default sRGB space.
// */
// public final static Color MAGENTA = new Color(255, 0, 255);
//
// /**
// * The color cyan. In the default sRGB space.
// */
// public final static Color CYAN = new Color(0, 255, 255);
//
// /**
// * The color blue. In the default sRGB space.
// */
// public final static Color BLUE = new Color(0, 0, 255);
//
// public Color(int r, int g, int b) {
// this.c = new java.awt.Color(r, g, b);
// }
//
// public java.awt.Color getColor() {
// return c;
// }
//
// public int getRed() {
// return c.getRed();
// }
//
// public int getGreen() {
// return c.getGreen();
// }
//
// public int getBlue() {
// return c.getBlue();
// }
// }
|
import org.flightclub.compat.Color;
|
/**
This code is covered by the GNU General Public License
detailed at http://www.gnu.org/copyleft/gpl.html
Flight Club docs located at http://www.danb.dircon.co.uk/hg/hg.htm
Dan Burton , Nov 2001
*/
package org.flightclub;
/**
* a spine running parallel to x axis or y axis (orientation 0 or 1)
* has a circuit for ridge soaring
*
* build surface from maths functions...
* - taylor approx's of sin wave (cubic polynomial)
*/
public class Hill implements CameraSubject {
//spine start point
final float x0;
final float y0;
public enum Orientation {
X,
Y,
}
Orientation orientation = Orientation.X;
final int spineLength;
final float phase;
final float h0;
final int face;
final XCGame app;
final Object3d object3d;
|
// Path: core/src/main/java/org/flightclub/compat/Color.java
// public class Color {
// private final java.awt.Color c;
//
//
// /**
// * The color white. In the default sRGB space.
// */
// public final static Color WHITE = new Color(255, 255, 255);
//
// /**
// * The color light gray. In the default sRGB space.
// */
// public final static Color LIGHT_GRAY = new Color(192, 192, 192);
//
// /**
// * The color gray. In the default sRGB space.
// */
// public final static Color GRAY = new Color(128, 128, 128);
//
// /**
// * The color dark gray. In the default sRGB space.
// */
// public final static Color DARK_GRAY = new Color(64, 64, 64);
//
// /**
// * The color black. In the default sRGB space.
// */
// public final static Color BLACK = new Color(0, 0, 0);
//
// /**
// * The color red. In the default sRGB space.
// */
// public final static Color RED = new Color(255, 0, 0);
//
// /**
// * The color pink. In the default sRGB space.
// */
// public final static Color PINK = new Color(255, 175, 175);
//
// /**
// * The color orange. In the default sRGB space.
// */
// public final static Color ORANGE = new Color(255, 200, 0);
//
// /**
// * The color yellow. In the default sRGB space.
// */
// public final static Color YELLOW = new Color(255, 255, 0);
//
// /**
// * The color green. In the default sRGB space.
// */
// public final static Color GREEN = new Color(0, 255, 0);
//
// /**
// * The color magenta. In the default sRGB space.
// */
// public final static Color MAGENTA = new Color(255, 0, 255);
//
// /**
// * The color cyan. In the default sRGB space.
// */
// public final static Color CYAN = new Color(0, 255, 255);
//
// /**
// * The color blue. In the default sRGB space.
// */
// public final static Color BLUE = new Color(0, 0, 255);
//
// public Color(int r, int g, int b) {
// this.c = new java.awt.Color(r, g, b);
// }
//
// public java.awt.Color getColor() {
// return c;
// }
//
// public int getRed() {
// return c.getRed();
// }
//
// public int getGreen() {
// return c.getGreen();
// }
//
// public int getBlue() {
// return c.getBlue();
// }
// }
// Path: core/src/main/java/org/flightclub/Hill.java
import org.flightclub.compat.Color;
/**
This code is covered by the GNU General Public License
detailed at http://www.gnu.org/copyleft/gpl.html
Flight Club docs located at http://www.danb.dircon.co.uk/hg/hg.htm
Dan Burton , Nov 2001
*/
package org.flightclub;
/**
* a spine running parallel to x axis or y axis (orientation 0 or 1)
* has a circuit for ridge soaring
*
* build surface from maths functions...
* - taylor approx's of sin wave (cubic polynomial)
*/
public class Hill implements CameraSubject {
//spine start point
final float x0;
final float y0;
public enum Orientation {
X,
Y,
}
Orientation orientation = Orientation.X;
final int spineLength;
final float phase;
final float h0;
final int face;
final XCGame app;
final Object3d object3d;
|
final Color color;
|
Turbo87/flight-club
|
core/src/main/java/org/flightclub/Landscape.java
|
// Path: core/src/main/java/org/flightclub/compat/Color.java
// public class Color {
// private final java.awt.Color c;
//
//
// /**
// * The color white. In the default sRGB space.
// */
// public final static Color WHITE = new Color(255, 255, 255);
//
// /**
// * The color light gray. In the default sRGB space.
// */
// public final static Color LIGHT_GRAY = new Color(192, 192, 192);
//
// /**
// * The color gray. In the default sRGB space.
// */
// public final static Color GRAY = new Color(128, 128, 128);
//
// /**
// * The color dark gray. In the default sRGB space.
// */
// public final static Color DARK_GRAY = new Color(64, 64, 64);
//
// /**
// * The color black. In the default sRGB space.
// */
// public final static Color BLACK = new Color(0, 0, 0);
//
// /**
// * The color red. In the default sRGB space.
// */
// public final static Color RED = new Color(255, 0, 0);
//
// /**
// * The color pink. In the default sRGB space.
// */
// public final static Color PINK = new Color(255, 175, 175);
//
// /**
// * The color orange. In the default sRGB space.
// */
// public final static Color ORANGE = new Color(255, 200, 0);
//
// /**
// * The color yellow. In the default sRGB space.
// */
// public final static Color YELLOW = new Color(255, 255, 0);
//
// /**
// * The color green. In the default sRGB space.
// */
// public final static Color GREEN = new Color(0, 255, 0);
//
// /**
// * The color magenta. In the default sRGB space.
// */
// public final static Color MAGENTA = new Color(255, 0, 255);
//
// /**
// * The color cyan. In the default sRGB space.
// */
// public final static Color CYAN = new Color(0, 255, 255);
//
// /**
// * The color blue. In the default sRGB space.
// */
// public final static Color BLUE = new Color(0, 0, 255);
//
// public Color(int r, int g, int b) {
// this.c = new java.awt.Color(r, g, b);
// }
//
// public java.awt.Color getColor() {
// return c;
// }
//
// public int getRed() {
// return c.getRed();
// }
//
// public int getGreen() {
// return c.getGreen();
// }
//
// public int getBlue() {
// return c.getBlue();
// }
// }
|
import org.flightclub.compat.Color;
import java.util.Vector;
|
loadFlatLand(t);
}
tiles[t].loaded = true;
}
void addFrame(int tile, int x) {
//Vector wire;
//int y0 = tile * TILE_WIDTH;
//int x0 = - TILE_WIDTH/2 + x * TILE_WIDTH;
//two cross hairs
//crossHair(x0, y0);
//crossHair(x0 + TILE_WIDTH, y0);
}
/*
* add a cross hair (show your working + LED !)
* - use for tile corners and triggers
*/
static void crossHair(float x, float y) {
float HAIR = 1;
Object3d o = new Object3d(app, true, 0); //layer zero !!
Vector<Vector3d> wire;
wire = new Vector<>();
wire.addElement(new Vector3d(x, y - HAIR, 0));
wire.addElement(new Vector3d(x, y + HAIR, 0));
|
// Path: core/src/main/java/org/flightclub/compat/Color.java
// public class Color {
// private final java.awt.Color c;
//
//
// /**
// * The color white. In the default sRGB space.
// */
// public final static Color WHITE = new Color(255, 255, 255);
//
// /**
// * The color light gray. In the default sRGB space.
// */
// public final static Color LIGHT_GRAY = new Color(192, 192, 192);
//
// /**
// * The color gray. In the default sRGB space.
// */
// public final static Color GRAY = new Color(128, 128, 128);
//
// /**
// * The color dark gray. In the default sRGB space.
// */
// public final static Color DARK_GRAY = new Color(64, 64, 64);
//
// /**
// * The color black. In the default sRGB space.
// */
// public final static Color BLACK = new Color(0, 0, 0);
//
// /**
// * The color red. In the default sRGB space.
// */
// public final static Color RED = new Color(255, 0, 0);
//
// /**
// * The color pink. In the default sRGB space.
// */
// public final static Color PINK = new Color(255, 175, 175);
//
// /**
// * The color orange. In the default sRGB space.
// */
// public final static Color ORANGE = new Color(255, 200, 0);
//
// /**
// * The color yellow. In the default sRGB space.
// */
// public final static Color YELLOW = new Color(255, 255, 0);
//
// /**
// * The color green. In the default sRGB space.
// */
// public final static Color GREEN = new Color(0, 255, 0);
//
// /**
// * The color magenta. In the default sRGB space.
// */
// public final static Color MAGENTA = new Color(255, 0, 255);
//
// /**
// * The color cyan. In the default sRGB space.
// */
// public final static Color CYAN = new Color(0, 255, 255);
//
// /**
// * The color blue. In the default sRGB space.
// */
// public final static Color BLUE = new Color(0, 0, 255);
//
// public Color(int r, int g, int b) {
// this.c = new java.awt.Color(r, g, b);
// }
//
// public java.awt.Color getColor() {
// return c;
// }
//
// public int getRed() {
// return c.getRed();
// }
//
// public int getGreen() {
// return c.getGreen();
// }
//
// public int getBlue() {
// return c.getBlue();
// }
// }
// Path: core/src/main/java/org/flightclub/Landscape.java
import org.flightclub.compat.Color;
import java.util.Vector;
loadFlatLand(t);
}
tiles[t].loaded = true;
}
void addFrame(int tile, int x) {
//Vector wire;
//int y0 = tile * TILE_WIDTH;
//int x0 = - TILE_WIDTH/2 + x * TILE_WIDTH;
//two cross hairs
//crossHair(x0, y0);
//crossHair(x0 + TILE_WIDTH, y0);
}
/*
* add a cross hair (show your working + LED !)
* - use for tile corners and triggers
*/
static void crossHair(float x, float y) {
float HAIR = 1;
Object3d o = new Object3d(app, true, 0); //layer zero !!
Vector<Vector3d> wire;
wire = new Vector<>();
wire.addElement(new Vector3d(x, y - HAIR, 0));
wire.addElement(new Vector3d(x, y + HAIR, 0));
|
o.addWire(wire, new Color(230, 230, 230), false, false);
|
tourettes/libbluray
|
src/libbluray/bdj/java/org/videolan/media/content/playlist/VideoControl.java
|
// Path: src/libbluray/bdj/java/org/havi/ui/HScreenRectangle.java
// public class HScreenRectangle {
// public HScreenRectangle(float x, float y, float width, float height) {
// setLocation(x, y);
// setSize(width, height);
// }
//
// public void setLocation(float x, float y) {
// this.x = x;
// this.y = y;
// }
//
// public void setSize(float width, float height) {
// this.width = Math.max(0.0f, width);
// this.height = Math.max(0.0f, height);
// }
//
// public boolean equals(Object obj)
// {
// if (!(obj instanceof HScreenRectangle))
// return false;
//
// HScreenRectangle other = (HScreenRectangle)obj;
// Float x1 = new Float(this.x);
// Float y1 = new Float(this.y);
// Float w1 = new Float(this.width);
// Float h1 = new Float(this.height);
// Float x2 = new Float(other.x);
// Float y2 = new Float(other.y);
// Float w2 = new Float(other.width);
// Float h2 = new Float(other.height);
// return x1.equals(x2) && y1.equals(y2) && w1.equals(w2) && h1.equals(h2);
// }
//
// public String toString() {
// return getClass().getName() + "[" + x + "," + y + " " + width + "x" + height + "]";
// }
//
// public float x;
// public float y;
// public float width;
// public float height;
// }
|
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Rectangle;
import org.dvb.media.VideoPresentationControl;
import org.havi.ui.HScreen;
import org.havi.ui.HScreenRectangle;
import org.havi.ui.HVideoConfiguration;
import org.videolan.StreamInfo;
|
/*
* This file is part of libbluray
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <http://www.gnu.org/licenses/>.
*/
package org.videolan.media.content.playlist;
public abstract class VideoControl extends StreamControl implements VideoPresentationControl {
protected VideoControl(int plane) {
this.plane = plane;
}
|
// Path: src/libbluray/bdj/java/org/havi/ui/HScreenRectangle.java
// public class HScreenRectangle {
// public HScreenRectangle(float x, float y, float width, float height) {
// setLocation(x, y);
// setSize(width, height);
// }
//
// public void setLocation(float x, float y) {
// this.x = x;
// this.y = y;
// }
//
// public void setSize(float width, float height) {
// this.width = Math.max(0.0f, width);
// this.height = Math.max(0.0f, height);
// }
//
// public boolean equals(Object obj)
// {
// if (!(obj instanceof HScreenRectangle))
// return false;
//
// HScreenRectangle other = (HScreenRectangle)obj;
// Float x1 = new Float(this.x);
// Float y1 = new Float(this.y);
// Float w1 = new Float(this.width);
// Float h1 = new Float(this.height);
// Float x2 = new Float(other.x);
// Float y2 = new Float(other.y);
// Float w2 = new Float(other.width);
// Float h2 = new Float(other.height);
// return x1.equals(x2) && y1.equals(y2) && w1.equals(w2) && h1.equals(h2);
// }
//
// public String toString() {
// return getClass().getName() + "[" + x + "," + y + " " + width + "x" + height + "]";
// }
//
// public float x;
// public float y;
// public float width;
// public float height;
// }
// Path: src/libbluray/bdj/java/org/videolan/media/content/playlist/VideoControl.java
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Rectangle;
import org.dvb.media.VideoPresentationControl;
import org.havi.ui.HScreen;
import org.havi.ui.HScreenRectangle;
import org.havi.ui.HVideoConfiguration;
import org.videolan.StreamInfo;
/*
* This file is part of libbluray
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <http://www.gnu.org/licenses/>.
*/
package org.videolan.media.content.playlist;
public abstract class VideoControl extends StreamControl implements VideoPresentationControl {
protected VideoControl(int plane) {
this.plane = plane;
}
|
protected HScreenRectangle getNormalizedRectangle(Dimension dimension, Rectangle rectangle) {
|
tourettes/libbluray
|
src/libbluray/bdj/java/org/bluray/net/BDLocator.java
|
// Path: src/libbluray/bdj/java/org/davic/net/Locator.java
// public class Locator implements javax.tv.locator.Locator {
// public Locator(String url) {
// this.url = url;
// }
//
// public String toString() {
// return url;
// }
//
// public boolean hasMultipleTransformations() {
// return false;
// }
//
// public String toExternalForm() {
// return url;
// }
//
// public boolean equals(Object obj) {
// if (obj == null || !(obj instanceof Locator) || url == null)
// return false;
//
// Locator locator = (Locator)obj;
// return toExternalForm().equals(locator.toExternalForm());
// }
//
// protected String url;
// }
//
// Path: src/libbluray/bdj/java/org/videolan/BDJUtil.java
// public class BDJUtil {
// /**
// * Make a five digit zero padded string based on an integer
// * Ex. integer 1 -> string "00001"
// *
// * @param id
// * @return
// */
// public static String makeFiveDigitStr(int id)
// {
// if (id < 0 || id > 99999) {
// System.err.println("Invalid ID: " + id);
// throw new IllegalArgumentException("Invalid ID " + id);
// }
// String s = "" + id;
// while (s.length() < 5) {
// s = "0" + s;
// }
// return s;
// /*
// DecimalFormat fmt = new DecimalFormat();
// fmt.setMaximumIntegerDigits(5);
// fmt.setMinimumIntegerDigits(5);
// fmt.setGroupingUsed(false);
//
// return fmt.format(id);
// */
// }
//
// /**
// * Make a path based on the disc root to an absolute path based on the filesystem of the computer
// * Ex. /BDMV/JAR/00000.jar -> /bluray/disc/mount/point/BDMV/JAR/00000.jar
// * @param path
// * @return
// */
// public static String discRootToFilesystem(String path)
// {
// String vfsRoot = System.getProperty("bluray.vfs.root");
// if (vfsRoot == null) {
// System.err.println("discRootToFilesystem(): disc root not set !");
// return path;
// }
// return vfsRoot + path;
// }
// }
|
import org.videolan.BDJUtil;
import org.videolan.Logger;
import org.davic.net.Locator;
import org.davic.net.InvalidLocatorException;
|
secondaryVideoNum = num;
url = getUrl();
}
}
public void setPGTextStreamNumber(int num) {
if ((num >= 0) && (num != textStreamNum)) {
textStreamNum = num;
url = getUrl();
}
}
protected String getUrl() {
String str = "bd://";
if (disc != null && disc != "") {
str += disc;
if (titleNum >= 0) {
str += ".";
}
}
if (titleNum >= 0) {
str += Integer.toString(titleNum, 16);
if (jar >= 0 || playList >= 0 || sound >= 0) {
str += ".";
}
}
if (jar >= 0) {
|
// Path: src/libbluray/bdj/java/org/davic/net/Locator.java
// public class Locator implements javax.tv.locator.Locator {
// public Locator(String url) {
// this.url = url;
// }
//
// public String toString() {
// return url;
// }
//
// public boolean hasMultipleTransformations() {
// return false;
// }
//
// public String toExternalForm() {
// return url;
// }
//
// public boolean equals(Object obj) {
// if (obj == null || !(obj instanceof Locator) || url == null)
// return false;
//
// Locator locator = (Locator)obj;
// return toExternalForm().equals(locator.toExternalForm());
// }
//
// protected String url;
// }
//
// Path: src/libbluray/bdj/java/org/videolan/BDJUtil.java
// public class BDJUtil {
// /**
// * Make a five digit zero padded string based on an integer
// * Ex. integer 1 -> string "00001"
// *
// * @param id
// * @return
// */
// public static String makeFiveDigitStr(int id)
// {
// if (id < 0 || id > 99999) {
// System.err.println("Invalid ID: " + id);
// throw new IllegalArgumentException("Invalid ID " + id);
// }
// String s = "" + id;
// while (s.length() < 5) {
// s = "0" + s;
// }
// return s;
// /*
// DecimalFormat fmt = new DecimalFormat();
// fmt.setMaximumIntegerDigits(5);
// fmt.setMinimumIntegerDigits(5);
// fmt.setGroupingUsed(false);
//
// return fmt.format(id);
// */
// }
//
// /**
// * Make a path based on the disc root to an absolute path based on the filesystem of the computer
// * Ex. /BDMV/JAR/00000.jar -> /bluray/disc/mount/point/BDMV/JAR/00000.jar
// * @param path
// * @return
// */
// public static String discRootToFilesystem(String path)
// {
// String vfsRoot = System.getProperty("bluray.vfs.root");
// if (vfsRoot == null) {
// System.err.println("discRootToFilesystem(): disc root not set !");
// return path;
// }
// return vfsRoot + path;
// }
// }
// Path: src/libbluray/bdj/java/org/bluray/net/BDLocator.java
import org.videolan.BDJUtil;
import org.videolan.Logger;
import org.davic.net.Locator;
import org.davic.net.InvalidLocatorException;
secondaryVideoNum = num;
url = getUrl();
}
}
public void setPGTextStreamNumber(int num) {
if ((num >= 0) && (num != textStreamNum)) {
textStreamNum = num;
url = getUrl();
}
}
protected String getUrl() {
String str = "bd://";
if (disc != null && disc != "") {
str += disc;
if (titleNum >= 0) {
str += ".";
}
}
if (titleNum >= 0) {
str += Integer.toString(titleNum, 16);
if (jar >= 0 || playList >= 0 || sound >= 0) {
str += ".";
}
}
if (jar >= 0) {
|
str += "JAR:" + BDJUtil.makeFiveDigitStr(jar);
|
bencvt/LibShapeDraw
|
projects/main/src/main/java/libshapedraw/animation/trident/interpolator/KeyInterpolators.java
|
// Path: projects/main/src/main/java/libshapedraw/animation/trident/ease/Linear.java
// public class Linear implements TimelineEase {
// @Override
// public float map(float durationFraction) {
// return durationFraction;
// }
//
// }
//
// Path: projects/main/src/main/java/libshapedraw/animation/trident/ease/TimelineEase.java
// public interface TimelineEase {
// public float map(float durationFraction);
// }
|
import java.util.ArrayList;
import libshapedraw.animation.trident.ease.Linear;
import libshapedraw.animation.trident.ease.TimelineEase;
|
// original package: org.pushingpixels.trident.interpolator
// imported from http://kenai.com/projects/trident/ (version 1.3)
/**
* Copyright (c) 2006, Sun Microsystems, Inc
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of the TimingFramework project nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package libshapedraw.animation.trident.interpolator;
/**
*
* @author Chet
*/
class KeyInterpolators {
private ArrayList<TimelineEase> interpolators = new ArrayList<TimelineEase>();
/**
* Creates a new instance of KeyInterpolators
*/
KeyInterpolators(int numIntervals, TimelineEase... interpolators) {
if (interpolators == null || interpolators[0] == null) {
for (int i = 0; i < numIntervals; ++i) {
|
// Path: projects/main/src/main/java/libshapedraw/animation/trident/ease/Linear.java
// public class Linear implements TimelineEase {
// @Override
// public float map(float durationFraction) {
// return durationFraction;
// }
//
// }
//
// Path: projects/main/src/main/java/libshapedraw/animation/trident/ease/TimelineEase.java
// public interface TimelineEase {
// public float map(float durationFraction);
// }
// Path: projects/main/src/main/java/libshapedraw/animation/trident/interpolator/KeyInterpolators.java
import java.util.ArrayList;
import libshapedraw.animation.trident.ease.Linear;
import libshapedraw.animation.trident.ease.TimelineEase;
// original package: org.pushingpixels.trident.interpolator
// imported from http://kenai.com/projects/trident/ (version 1.3)
/**
* Copyright (c) 2006, Sun Microsystems, Inc
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of the TimingFramework project nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package libshapedraw.animation.trident.interpolator;
/**
*
* @author Chet
*/
class KeyInterpolators {
private ArrayList<TimelineEase> interpolators = new ArrayList<TimelineEase>();
/**
* Creates a new instance of KeyInterpolators
*/
KeyInterpolators(int numIntervals, TimelineEase... interpolators) {
if (interpolators == null || interpolators[0] == null) {
for (int i = 0; i < numIntervals; ++i) {
|
this.interpolators.add(new Linear());
|
bencvt/LibShapeDraw
|
projects/main/src/main/java/libshapedraw/animation/trident/TridentConfig.java
|
// Path: projects/main/src/main/java/libshapedraw/animation/trident/TimelineEngine.java
// class TridentAnimationThread extends Thread {
// public TridentAnimationThread() {
// super();
// this.setName("Trident pulse source thread");
// this.setDaemon(true);
// }
//
// /*
// * (non-Javadoc)
// *
// * @see java.lang.Thread#run()
// */
// @Override
// public final void run() {
// TridentConfig.PulseSource pulseSource = TridentConfig.getInstance()
// .getPulseSource();
// lastIterationTimeStamp = System.currentTimeMillis();
// while (true) {
// pulseSource.waitUntilNextPulse();
// updateTimelines();
// // engine.currLoopId++;
// }
// }
//
// @Override
// public void interrupt() {
// System.err.println("Interrupted");
// super.interrupt();
// }
// }
//
// Path: projects/main/src/main/java/libshapedraw/animation/trident/interpolator/CorePropertyInterpolators.java
// public class CorePropertyInterpolators implements PropertyInterpolatorSource {
// private Set<PropertyInterpolator> interpolators;
//
// public CorePropertyInterpolators() {
// this.interpolators = new HashSet<PropertyInterpolator>();
// this.interpolators.add(new IntegerPropertyInterpolator());
// this.interpolators.add(new FloatPropertyInterpolator());
// this.interpolators.add(new DoublePropertyInterpolator());
// this.interpolators.add(new LongPropertyInterpolator());
// }
//
// @Override
// public Set<PropertyInterpolator> getPropertyInterpolators() {
// return Collections.unmodifiableSet(this.interpolators);
// }
//
// private static class FloatPropertyInterpolator implements
// PropertyInterpolator<Float> {
// @Override
// public Class getBasePropertyClass() {
// return Float.class;
// }
//
// @Override
// public Float interpolate(Float from, Float to, float timelinePosition) {
// return from + (to - from) * timelinePosition;
// }
// }
//
// private static class DoublePropertyInterpolator implements
// PropertyInterpolator<Double> {
// @Override
// public Class getBasePropertyClass() {
// return Double.class;
// }
//
// @Override
// public Double interpolate(Double from, Double to, float timelinePosition) {
// return from + (to - from) * timelinePosition;
// }
// }
//
// private static class IntegerPropertyInterpolator implements
// PropertyInterpolator<Integer> {
// @Override
// public Class getBasePropertyClass() {
// return Integer.class;
// }
//
// @Override
// public Integer interpolate(Integer from, Integer to,
// float timelinePosition) {
// return (int) (from + (to - from) * timelinePosition);
// }
// }
//
// private static class LongPropertyInterpolator implements
// PropertyInterpolator<Long> {
// @Override
// public Class getBasePropertyClass() {
// return Long.class;
// }
//
// @Override
// public Long interpolate(Long from, Long to, float timelinePosition) {
// return (long) (from + (to - from) * timelinePosition);
// }
// }
// }
//
// Path: projects/main/src/main/java/libshapedraw/animation/trident/interpolator/PropertyInterpolator.java
// public interface PropertyInterpolator<T> {
// public Class getBasePropertyClass();
//
// public T interpolate(T from, T to, float timelinePosition);
// }
//
// Path: projects/main/src/main/java/libshapedraw/animation/trident/interpolator/PropertyInterpolatorSource.java
// public interface PropertyInterpolatorSource {
// public Set<PropertyInterpolator> getPropertyInterpolators();
// }
|
import java.io.*;
import java.net.URL;
import java.util.*;
import libshapedraw.animation.trident.TimelineEngine.TridentAnimationThread;
import libshapedraw.animation.trident.interpolator.CorePropertyInterpolators;
import libshapedraw.animation.trident.interpolator.PropertyInterpolator;
import libshapedraw.animation.trident.interpolator.PropertyInterpolatorSource;
|
// original package: org.pushingpixels.trident
// imported from http://kenai.com/projects/trident/ (version 1.3)
/*
* Copyright (c) 2005-2010 Trident Kirill Grouchnikov. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* o Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* o Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* o Neither the name of Trident Kirill Grouchnikov nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package libshapedraw.animation.trident;
public class TridentConfig {
private static TridentConfig config;
private Set<UIToolkitHandler> uiToolkitHandlers;
|
// Path: projects/main/src/main/java/libshapedraw/animation/trident/TimelineEngine.java
// class TridentAnimationThread extends Thread {
// public TridentAnimationThread() {
// super();
// this.setName("Trident pulse source thread");
// this.setDaemon(true);
// }
//
// /*
// * (non-Javadoc)
// *
// * @see java.lang.Thread#run()
// */
// @Override
// public final void run() {
// TridentConfig.PulseSource pulseSource = TridentConfig.getInstance()
// .getPulseSource();
// lastIterationTimeStamp = System.currentTimeMillis();
// while (true) {
// pulseSource.waitUntilNextPulse();
// updateTimelines();
// // engine.currLoopId++;
// }
// }
//
// @Override
// public void interrupt() {
// System.err.println("Interrupted");
// super.interrupt();
// }
// }
//
// Path: projects/main/src/main/java/libshapedraw/animation/trident/interpolator/CorePropertyInterpolators.java
// public class CorePropertyInterpolators implements PropertyInterpolatorSource {
// private Set<PropertyInterpolator> interpolators;
//
// public CorePropertyInterpolators() {
// this.interpolators = new HashSet<PropertyInterpolator>();
// this.interpolators.add(new IntegerPropertyInterpolator());
// this.interpolators.add(new FloatPropertyInterpolator());
// this.interpolators.add(new DoublePropertyInterpolator());
// this.interpolators.add(new LongPropertyInterpolator());
// }
//
// @Override
// public Set<PropertyInterpolator> getPropertyInterpolators() {
// return Collections.unmodifiableSet(this.interpolators);
// }
//
// private static class FloatPropertyInterpolator implements
// PropertyInterpolator<Float> {
// @Override
// public Class getBasePropertyClass() {
// return Float.class;
// }
//
// @Override
// public Float interpolate(Float from, Float to, float timelinePosition) {
// return from + (to - from) * timelinePosition;
// }
// }
//
// private static class DoublePropertyInterpolator implements
// PropertyInterpolator<Double> {
// @Override
// public Class getBasePropertyClass() {
// return Double.class;
// }
//
// @Override
// public Double interpolate(Double from, Double to, float timelinePosition) {
// return from + (to - from) * timelinePosition;
// }
// }
//
// private static class IntegerPropertyInterpolator implements
// PropertyInterpolator<Integer> {
// @Override
// public Class getBasePropertyClass() {
// return Integer.class;
// }
//
// @Override
// public Integer interpolate(Integer from, Integer to,
// float timelinePosition) {
// return (int) (from + (to - from) * timelinePosition);
// }
// }
//
// private static class LongPropertyInterpolator implements
// PropertyInterpolator<Long> {
// @Override
// public Class getBasePropertyClass() {
// return Long.class;
// }
//
// @Override
// public Long interpolate(Long from, Long to, float timelinePosition) {
// return (long) (from + (to - from) * timelinePosition);
// }
// }
// }
//
// Path: projects/main/src/main/java/libshapedraw/animation/trident/interpolator/PropertyInterpolator.java
// public interface PropertyInterpolator<T> {
// public Class getBasePropertyClass();
//
// public T interpolate(T from, T to, float timelinePosition);
// }
//
// Path: projects/main/src/main/java/libshapedraw/animation/trident/interpolator/PropertyInterpolatorSource.java
// public interface PropertyInterpolatorSource {
// public Set<PropertyInterpolator> getPropertyInterpolators();
// }
// Path: projects/main/src/main/java/libshapedraw/animation/trident/TridentConfig.java
import java.io.*;
import java.net.URL;
import java.util.*;
import libshapedraw.animation.trident.TimelineEngine.TridentAnimationThread;
import libshapedraw.animation.trident.interpolator.CorePropertyInterpolators;
import libshapedraw.animation.trident.interpolator.PropertyInterpolator;
import libshapedraw.animation.trident.interpolator.PropertyInterpolatorSource;
// original package: org.pushingpixels.trident
// imported from http://kenai.com/projects/trident/ (version 1.3)
/*
* Copyright (c) 2005-2010 Trident Kirill Grouchnikov. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* o Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* o Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* o Neither the name of Trident Kirill Grouchnikov nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package libshapedraw.animation.trident;
public class TridentConfig {
private static TridentConfig config;
private Set<UIToolkitHandler> uiToolkitHandlers;
|
private Set<PropertyInterpolator> propertyInterpolators;
|
bencvt/LibShapeDraw
|
projects/main/src/main/java/libshapedraw/animation/trident/TridentConfig.java
|
// Path: projects/main/src/main/java/libshapedraw/animation/trident/TimelineEngine.java
// class TridentAnimationThread extends Thread {
// public TridentAnimationThread() {
// super();
// this.setName("Trident pulse source thread");
// this.setDaemon(true);
// }
//
// /*
// * (non-Javadoc)
// *
// * @see java.lang.Thread#run()
// */
// @Override
// public final void run() {
// TridentConfig.PulseSource pulseSource = TridentConfig.getInstance()
// .getPulseSource();
// lastIterationTimeStamp = System.currentTimeMillis();
// while (true) {
// pulseSource.waitUntilNextPulse();
// updateTimelines();
// // engine.currLoopId++;
// }
// }
//
// @Override
// public void interrupt() {
// System.err.println("Interrupted");
// super.interrupt();
// }
// }
//
// Path: projects/main/src/main/java/libshapedraw/animation/trident/interpolator/CorePropertyInterpolators.java
// public class CorePropertyInterpolators implements PropertyInterpolatorSource {
// private Set<PropertyInterpolator> interpolators;
//
// public CorePropertyInterpolators() {
// this.interpolators = new HashSet<PropertyInterpolator>();
// this.interpolators.add(new IntegerPropertyInterpolator());
// this.interpolators.add(new FloatPropertyInterpolator());
// this.interpolators.add(new DoublePropertyInterpolator());
// this.interpolators.add(new LongPropertyInterpolator());
// }
//
// @Override
// public Set<PropertyInterpolator> getPropertyInterpolators() {
// return Collections.unmodifiableSet(this.interpolators);
// }
//
// private static class FloatPropertyInterpolator implements
// PropertyInterpolator<Float> {
// @Override
// public Class getBasePropertyClass() {
// return Float.class;
// }
//
// @Override
// public Float interpolate(Float from, Float to, float timelinePosition) {
// return from + (to - from) * timelinePosition;
// }
// }
//
// private static class DoublePropertyInterpolator implements
// PropertyInterpolator<Double> {
// @Override
// public Class getBasePropertyClass() {
// return Double.class;
// }
//
// @Override
// public Double interpolate(Double from, Double to, float timelinePosition) {
// return from + (to - from) * timelinePosition;
// }
// }
//
// private static class IntegerPropertyInterpolator implements
// PropertyInterpolator<Integer> {
// @Override
// public Class getBasePropertyClass() {
// return Integer.class;
// }
//
// @Override
// public Integer interpolate(Integer from, Integer to,
// float timelinePosition) {
// return (int) (from + (to - from) * timelinePosition);
// }
// }
//
// private static class LongPropertyInterpolator implements
// PropertyInterpolator<Long> {
// @Override
// public Class getBasePropertyClass() {
// return Long.class;
// }
//
// @Override
// public Long interpolate(Long from, Long to, float timelinePosition) {
// return (long) (from + (to - from) * timelinePosition);
// }
// }
// }
//
// Path: projects/main/src/main/java/libshapedraw/animation/trident/interpolator/PropertyInterpolator.java
// public interface PropertyInterpolator<T> {
// public Class getBasePropertyClass();
//
// public T interpolate(T from, T to, float timelinePosition);
// }
//
// Path: projects/main/src/main/java/libshapedraw/animation/trident/interpolator/PropertyInterpolatorSource.java
// public interface PropertyInterpolatorSource {
// public Set<PropertyInterpolator> getPropertyInterpolators();
// }
|
import java.io.*;
import java.net.URL;
import java.util.*;
import libshapedraw.animation.trident.TimelineEngine.TridentAnimationThread;
import libshapedraw.animation.trident.interpolator.CorePropertyInterpolators;
import libshapedraw.animation.trident.interpolator.PropertyInterpolator;
import libshapedraw.animation.trident.interpolator.PropertyInterpolatorSource;
|
public FixedRatePulseSource(int msDelay) {
this.msDelay = msDelay;
}
@Override
public void waitUntilNextPulse() {
try {
Thread.sleep(this.msDelay);
} catch (InterruptedException ie) {
ie.printStackTrace();
}
}
}
private class DefaultPulseSource extends FixedRatePulseSource {
DefaultPulseSource() {
super(40);
}
}
private TridentConfig() {
this.pulseSource = new DefaultPulseSource();
this.uiToolkitHandlers = new HashSet<UIToolkitHandler>();
this.propertyInterpolators = new HashSet<PropertyInterpolator>();
// Simplify Trident config to not load its UIToolkitHandlers and
// PropertyInterpolator from properties files. These can still be added
// programmatically if needed.
|
// Path: projects/main/src/main/java/libshapedraw/animation/trident/TimelineEngine.java
// class TridentAnimationThread extends Thread {
// public TridentAnimationThread() {
// super();
// this.setName("Trident pulse source thread");
// this.setDaemon(true);
// }
//
// /*
// * (non-Javadoc)
// *
// * @see java.lang.Thread#run()
// */
// @Override
// public final void run() {
// TridentConfig.PulseSource pulseSource = TridentConfig.getInstance()
// .getPulseSource();
// lastIterationTimeStamp = System.currentTimeMillis();
// while (true) {
// pulseSource.waitUntilNextPulse();
// updateTimelines();
// // engine.currLoopId++;
// }
// }
//
// @Override
// public void interrupt() {
// System.err.println("Interrupted");
// super.interrupt();
// }
// }
//
// Path: projects/main/src/main/java/libshapedraw/animation/trident/interpolator/CorePropertyInterpolators.java
// public class CorePropertyInterpolators implements PropertyInterpolatorSource {
// private Set<PropertyInterpolator> interpolators;
//
// public CorePropertyInterpolators() {
// this.interpolators = new HashSet<PropertyInterpolator>();
// this.interpolators.add(new IntegerPropertyInterpolator());
// this.interpolators.add(new FloatPropertyInterpolator());
// this.interpolators.add(new DoublePropertyInterpolator());
// this.interpolators.add(new LongPropertyInterpolator());
// }
//
// @Override
// public Set<PropertyInterpolator> getPropertyInterpolators() {
// return Collections.unmodifiableSet(this.interpolators);
// }
//
// private static class FloatPropertyInterpolator implements
// PropertyInterpolator<Float> {
// @Override
// public Class getBasePropertyClass() {
// return Float.class;
// }
//
// @Override
// public Float interpolate(Float from, Float to, float timelinePosition) {
// return from + (to - from) * timelinePosition;
// }
// }
//
// private static class DoublePropertyInterpolator implements
// PropertyInterpolator<Double> {
// @Override
// public Class getBasePropertyClass() {
// return Double.class;
// }
//
// @Override
// public Double interpolate(Double from, Double to, float timelinePosition) {
// return from + (to - from) * timelinePosition;
// }
// }
//
// private static class IntegerPropertyInterpolator implements
// PropertyInterpolator<Integer> {
// @Override
// public Class getBasePropertyClass() {
// return Integer.class;
// }
//
// @Override
// public Integer interpolate(Integer from, Integer to,
// float timelinePosition) {
// return (int) (from + (to - from) * timelinePosition);
// }
// }
//
// private static class LongPropertyInterpolator implements
// PropertyInterpolator<Long> {
// @Override
// public Class getBasePropertyClass() {
// return Long.class;
// }
//
// @Override
// public Long interpolate(Long from, Long to, float timelinePosition) {
// return (long) (from + (to - from) * timelinePosition);
// }
// }
// }
//
// Path: projects/main/src/main/java/libshapedraw/animation/trident/interpolator/PropertyInterpolator.java
// public interface PropertyInterpolator<T> {
// public Class getBasePropertyClass();
//
// public T interpolate(T from, T to, float timelinePosition);
// }
//
// Path: projects/main/src/main/java/libshapedraw/animation/trident/interpolator/PropertyInterpolatorSource.java
// public interface PropertyInterpolatorSource {
// public Set<PropertyInterpolator> getPropertyInterpolators();
// }
// Path: projects/main/src/main/java/libshapedraw/animation/trident/TridentConfig.java
import java.io.*;
import java.net.URL;
import java.util.*;
import libshapedraw.animation.trident.TimelineEngine.TridentAnimationThread;
import libshapedraw.animation.trident.interpolator.CorePropertyInterpolators;
import libshapedraw.animation.trident.interpolator.PropertyInterpolator;
import libshapedraw.animation.trident.interpolator.PropertyInterpolatorSource;
public FixedRatePulseSource(int msDelay) {
this.msDelay = msDelay;
}
@Override
public void waitUntilNextPulse() {
try {
Thread.sleep(this.msDelay);
} catch (InterruptedException ie) {
ie.printStackTrace();
}
}
}
private class DefaultPulseSource extends FixedRatePulseSource {
DefaultPulseSource() {
super(40);
}
}
private TridentConfig() {
this.pulseSource = new DefaultPulseSource();
this.uiToolkitHandlers = new HashSet<UIToolkitHandler>();
this.propertyInterpolators = new HashSet<PropertyInterpolator>();
// Simplify Trident config to not load its UIToolkitHandlers and
// PropertyInterpolator from properties files. These can still be added
// programmatically if needed.
|
PropertyInterpolatorSource piSource = new CorePropertyInterpolators();
|
bencvt/LibShapeDraw
|
projects/main/src/main/java/libshapedraw/animation/trident/TridentConfig.java
|
// Path: projects/main/src/main/java/libshapedraw/animation/trident/TimelineEngine.java
// class TridentAnimationThread extends Thread {
// public TridentAnimationThread() {
// super();
// this.setName("Trident pulse source thread");
// this.setDaemon(true);
// }
//
// /*
// * (non-Javadoc)
// *
// * @see java.lang.Thread#run()
// */
// @Override
// public final void run() {
// TridentConfig.PulseSource pulseSource = TridentConfig.getInstance()
// .getPulseSource();
// lastIterationTimeStamp = System.currentTimeMillis();
// while (true) {
// pulseSource.waitUntilNextPulse();
// updateTimelines();
// // engine.currLoopId++;
// }
// }
//
// @Override
// public void interrupt() {
// System.err.println("Interrupted");
// super.interrupt();
// }
// }
//
// Path: projects/main/src/main/java/libshapedraw/animation/trident/interpolator/CorePropertyInterpolators.java
// public class CorePropertyInterpolators implements PropertyInterpolatorSource {
// private Set<PropertyInterpolator> interpolators;
//
// public CorePropertyInterpolators() {
// this.interpolators = new HashSet<PropertyInterpolator>();
// this.interpolators.add(new IntegerPropertyInterpolator());
// this.interpolators.add(new FloatPropertyInterpolator());
// this.interpolators.add(new DoublePropertyInterpolator());
// this.interpolators.add(new LongPropertyInterpolator());
// }
//
// @Override
// public Set<PropertyInterpolator> getPropertyInterpolators() {
// return Collections.unmodifiableSet(this.interpolators);
// }
//
// private static class FloatPropertyInterpolator implements
// PropertyInterpolator<Float> {
// @Override
// public Class getBasePropertyClass() {
// return Float.class;
// }
//
// @Override
// public Float interpolate(Float from, Float to, float timelinePosition) {
// return from + (to - from) * timelinePosition;
// }
// }
//
// private static class DoublePropertyInterpolator implements
// PropertyInterpolator<Double> {
// @Override
// public Class getBasePropertyClass() {
// return Double.class;
// }
//
// @Override
// public Double interpolate(Double from, Double to, float timelinePosition) {
// return from + (to - from) * timelinePosition;
// }
// }
//
// private static class IntegerPropertyInterpolator implements
// PropertyInterpolator<Integer> {
// @Override
// public Class getBasePropertyClass() {
// return Integer.class;
// }
//
// @Override
// public Integer interpolate(Integer from, Integer to,
// float timelinePosition) {
// return (int) (from + (to - from) * timelinePosition);
// }
// }
//
// private static class LongPropertyInterpolator implements
// PropertyInterpolator<Long> {
// @Override
// public Class getBasePropertyClass() {
// return Long.class;
// }
//
// @Override
// public Long interpolate(Long from, Long to, float timelinePosition) {
// return (long) (from + (to - from) * timelinePosition);
// }
// }
// }
//
// Path: projects/main/src/main/java/libshapedraw/animation/trident/interpolator/PropertyInterpolator.java
// public interface PropertyInterpolator<T> {
// public Class getBasePropertyClass();
//
// public T interpolate(T from, T to, float timelinePosition);
// }
//
// Path: projects/main/src/main/java/libshapedraw/animation/trident/interpolator/PropertyInterpolatorSource.java
// public interface PropertyInterpolatorSource {
// public Set<PropertyInterpolator> getPropertyInterpolators();
// }
|
import java.io.*;
import java.net.URL;
import java.util.*;
import libshapedraw.animation.trident.TimelineEngine.TridentAnimationThread;
import libshapedraw.animation.trident.interpolator.CorePropertyInterpolators;
import libshapedraw.animation.trident.interpolator.PropertyInterpolator;
import libshapedraw.animation.trident.interpolator.PropertyInterpolatorSource;
|
public FixedRatePulseSource(int msDelay) {
this.msDelay = msDelay;
}
@Override
public void waitUntilNextPulse() {
try {
Thread.sleep(this.msDelay);
} catch (InterruptedException ie) {
ie.printStackTrace();
}
}
}
private class DefaultPulseSource extends FixedRatePulseSource {
DefaultPulseSource() {
super(40);
}
}
private TridentConfig() {
this.pulseSource = new DefaultPulseSource();
this.uiToolkitHandlers = new HashSet<UIToolkitHandler>();
this.propertyInterpolators = new HashSet<PropertyInterpolator>();
// Simplify Trident config to not load its UIToolkitHandlers and
// PropertyInterpolator from properties files. These can still be added
// programmatically if needed.
|
// Path: projects/main/src/main/java/libshapedraw/animation/trident/TimelineEngine.java
// class TridentAnimationThread extends Thread {
// public TridentAnimationThread() {
// super();
// this.setName("Trident pulse source thread");
// this.setDaemon(true);
// }
//
// /*
// * (non-Javadoc)
// *
// * @see java.lang.Thread#run()
// */
// @Override
// public final void run() {
// TridentConfig.PulseSource pulseSource = TridentConfig.getInstance()
// .getPulseSource();
// lastIterationTimeStamp = System.currentTimeMillis();
// while (true) {
// pulseSource.waitUntilNextPulse();
// updateTimelines();
// // engine.currLoopId++;
// }
// }
//
// @Override
// public void interrupt() {
// System.err.println("Interrupted");
// super.interrupt();
// }
// }
//
// Path: projects/main/src/main/java/libshapedraw/animation/trident/interpolator/CorePropertyInterpolators.java
// public class CorePropertyInterpolators implements PropertyInterpolatorSource {
// private Set<PropertyInterpolator> interpolators;
//
// public CorePropertyInterpolators() {
// this.interpolators = new HashSet<PropertyInterpolator>();
// this.interpolators.add(new IntegerPropertyInterpolator());
// this.interpolators.add(new FloatPropertyInterpolator());
// this.interpolators.add(new DoublePropertyInterpolator());
// this.interpolators.add(new LongPropertyInterpolator());
// }
//
// @Override
// public Set<PropertyInterpolator> getPropertyInterpolators() {
// return Collections.unmodifiableSet(this.interpolators);
// }
//
// private static class FloatPropertyInterpolator implements
// PropertyInterpolator<Float> {
// @Override
// public Class getBasePropertyClass() {
// return Float.class;
// }
//
// @Override
// public Float interpolate(Float from, Float to, float timelinePosition) {
// return from + (to - from) * timelinePosition;
// }
// }
//
// private static class DoublePropertyInterpolator implements
// PropertyInterpolator<Double> {
// @Override
// public Class getBasePropertyClass() {
// return Double.class;
// }
//
// @Override
// public Double interpolate(Double from, Double to, float timelinePosition) {
// return from + (to - from) * timelinePosition;
// }
// }
//
// private static class IntegerPropertyInterpolator implements
// PropertyInterpolator<Integer> {
// @Override
// public Class getBasePropertyClass() {
// return Integer.class;
// }
//
// @Override
// public Integer interpolate(Integer from, Integer to,
// float timelinePosition) {
// return (int) (from + (to - from) * timelinePosition);
// }
// }
//
// private static class LongPropertyInterpolator implements
// PropertyInterpolator<Long> {
// @Override
// public Class getBasePropertyClass() {
// return Long.class;
// }
//
// @Override
// public Long interpolate(Long from, Long to, float timelinePosition) {
// return (long) (from + (to - from) * timelinePosition);
// }
// }
// }
//
// Path: projects/main/src/main/java/libshapedraw/animation/trident/interpolator/PropertyInterpolator.java
// public interface PropertyInterpolator<T> {
// public Class getBasePropertyClass();
//
// public T interpolate(T from, T to, float timelinePosition);
// }
//
// Path: projects/main/src/main/java/libshapedraw/animation/trident/interpolator/PropertyInterpolatorSource.java
// public interface PropertyInterpolatorSource {
// public Set<PropertyInterpolator> getPropertyInterpolators();
// }
// Path: projects/main/src/main/java/libshapedraw/animation/trident/TridentConfig.java
import java.io.*;
import java.net.URL;
import java.util.*;
import libshapedraw.animation.trident.TimelineEngine.TridentAnimationThread;
import libshapedraw.animation.trident.interpolator.CorePropertyInterpolators;
import libshapedraw.animation.trident.interpolator.PropertyInterpolator;
import libshapedraw.animation.trident.interpolator.PropertyInterpolatorSource;
public FixedRatePulseSource(int msDelay) {
this.msDelay = msDelay;
}
@Override
public void waitUntilNextPulse() {
try {
Thread.sleep(this.msDelay);
} catch (InterruptedException ie) {
ie.printStackTrace();
}
}
}
private class DefaultPulseSource extends FixedRatePulseSource {
DefaultPulseSource() {
super(40);
}
}
private TridentConfig() {
this.pulseSource = new DefaultPulseSource();
this.uiToolkitHandlers = new HashSet<UIToolkitHandler>();
this.propertyInterpolators = new HashSet<PropertyInterpolator>();
// Simplify Trident config to not load its UIToolkitHandlers and
// PropertyInterpolator from properties files. These can still be added
// programmatically if needed.
|
PropertyInterpolatorSource piSource = new CorePropertyInterpolators();
|
bencvt/LibShapeDraw
|
projects/main/src/main/java/libshapedraw/animation/trident/TridentConfig.java
|
// Path: projects/main/src/main/java/libshapedraw/animation/trident/TimelineEngine.java
// class TridentAnimationThread extends Thread {
// public TridentAnimationThread() {
// super();
// this.setName("Trident pulse source thread");
// this.setDaemon(true);
// }
//
// /*
// * (non-Javadoc)
// *
// * @see java.lang.Thread#run()
// */
// @Override
// public final void run() {
// TridentConfig.PulseSource pulseSource = TridentConfig.getInstance()
// .getPulseSource();
// lastIterationTimeStamp = System.currentTimeMillis();
// while (true) {
// pulseSource.waitUntilNextPulse();
// updateTimelines();
// // engine.currLoopId++;
// }
// }
//
// @Override
// public void interrupt() {
// System.err.println("Interrupted");
// super.interrupt();
// }
// }
//
// Path: projects/main/src/main/java/libshapedraw/animation/trident/interpolator/CorePropertyInterpolators.java
// public class CorePropertyInterpolators implements PropertyInterpolatorSource {
// private Set<PropertyInterpolator> interpolators;
//
// public CorePropertyInterpolators() {
// this.interpolators = new HashSet<PropertyInterpolator>();
// this.interpolators.add(new IntegerPropertyInterpolator());
// this.interpolators.add(new FloatPropertyInterpolator());
// this.interpolators.add(new DoublePropertyInterpolator());
// this.interpolators.add(new LongPropertyInterpolator());
// }
//
// @Override
// public Set<PropertyInterpolator> getPropertyInterpolators() {
// return Collections.unmodifiableSet(this.interpolators);
// }
//
// private static class FloatPropertyInterpolator implements
// PropertyInterpolator<Float> {
// @Override
// public Class getBasePropertyClass() {
// return Float.class;
// }
//
// @Override
// public Float interpolate(Float from, Float to, float timelinePosition) {
// return from + (to - from) * timelinePosition;
// }
// }
//
// private static class DoublePropertyInterpolator implements
// PropertyInterpolator<Double> {
// @Override
// public Class getBasePropertyClass() {
// return Double.class;
// }
//
// @Override
// public Double interpolate(Double from, Double to, float timelinePosition) {
// return from + (to - from) * timelinePosition;
// }
// }
//
// private static class IntegerPropertyInterpolator implements
// PropertyInterpolator<Integer> {
// @Override
// public Class getBasePropertyClass() {
// return Integer.class;
// }
//
// @Override
// public Integer interpolate(Integer from, Integer to,
// float timelinePosition) {
// return (int) (from + (to - from) * timelinePosition);
// }
// }
//
// private static class LongPropertyInterpolator implements
// PropertyInterpolator<Long> {
// @Override
// public Class getBasePropertyClass() {
// return Long.class;
// }
//
// @Override
// public Long interpolate(Long from, Long to, float timelinePosition) {
// return (long) (from + (to - from) * timelinePosition);
// }
// }
// }
//
// Path: projects/main/src/main/java/libshapedraw/animation/trident/interpolator/PropertyInterpolator.java
// public interface PropertyInterpolator<T> {
// public Class getBasePropertyClass();
//
// public T interpolate(T from, T to, float timelinePosition);
// }
//
// Path: projects/main/src/main/java/libshapedraw/animation/trident/interpolator/PropertyInterpolatorSource.java
// public interface PropertyInterpolatorSource {
// public Set<PropertyInterpolator> getPropertyInterpolators();
// }
|
import java.io.*;
import java.net.URL;
import java.util.*;
import libshapedraw.animation.trident.TimelineEngine.TridentAnimationThread;
import libshapedraw.animation.trident.interpolator.CorePropertyInterpolators;
import libshapedraw.animation.trident.interpolator.PropertyInterpolator;
import libshapedraw.animation.trident.interpolator.PropertyInterpolatorSource;
|
return null;
}
public synchronized void addPropertyInterpolator(
PropertyInterpolator pInterpolator) {
this.propertyInterpolators.add(pInterpolator);
}
public synchronized void addPropertyInterpolatorSource(
PropertyInterpolatorSource pInterpolatorSource) {
this.propertyInterpolators.addAll(pInterpolatorSource
.getPropertyInterpolators());
}
public synchronized void removePropertyInterpolator(
PropertyInterpolator pInterpolator) {
this.propertyInterpolators.remove(pInterpolator);
}
public synchronized void addUIToolkitHandler(
UIToolkitHandler uiToolkitHandler) {
this.uiToolkitHandlers.add(uiToolkitHandler);
}
public synchronized void removeUIToolkitHandler(
UIToolkitHandler uiToolkitHandler) {
this.uiToolkitHandlers.remove(uiToolkitHandler);
}
public synchronized void setPulseSource(PulseSource pulseSource) {
|
// Path: projects/main/src/main/java/libshapedraw/animation/trident/TimelineEngine.java
// class TridentAnimationThread extends Thread {
// public TridentAnimationThread() {
// super();
// this.setName("Trident pulse source thread");
// this.setDaemon(true);
// }
//
// /*
// * (non-Javadoc)
// *
// * @see java.lang.Thread#run()
// */
// @Override
// public final void run() {
// TridentConfig.PulseSource pulseSource = TridentConfig.getInstance()
// .getPulseSource();
// lastIterationTimeStamp = System.currentTimeMillis();
// while (true) {
// pulseSource.waitUntilNextPulse();
// updateTimelines();
// // engine.currLoopId++;
// }
// }
//
// @Override
// public void interrupt() {
// System.err.println("Interrupted");
// super.interrupt();
// }
// }
//
// Path: projects/main/src/main/java/libshapedraw/animation/trident/interpolator/CorePropertyInterpolators.java
// public class CorePropertyInterpolators implements PropertyInterpolatorSource {
// private Set<PropertyInterpolator> interpolators;
//
// public CorePropertyInterpolators() {
// this.interpolators = new HashSet<PropertyInterpolator>();
// this.interpolators.add(new IntegerPropertyInterpolator());
// this.interpolators.add(new FloatPropertyInterpolator());
// this.interpolators.add(new DoublePropertyInterpolator());
// this.interpolators.add(new LongPropertyInterpolator());
// }
//
// @Override
// public Set<PropertyInterpolator> getPropertyInterpolators() {
// return Collections.unmodifiableSet(this.interpolators);
// }
//
// private static class FloatPropertyInterpolator implements
// PropertyInterpolator<Float> {
// @Override
// public Class getBasePropertyClass() {
// return Float.class;
// }
//
// @Override
// public Float interpolate(Float from, Float to, float timelinePosition) {
// return from + (to - from) * timelinePosition;
// }
// }
//
// private static class DoublePropertyInterpolator implements
// PropertyInterpolator<Double> {
// @Override
// public Class getBasePropertyClass() {
// return Double.class;
// }
//
// @Override
// public Double interpolate(Double from, Double to, float timelinePosition) {
// return from + (to - from) * timelinePosition;
// }
// }
//
// private static class IntegerPropertyInterpolator implements
// PropertyInterpolator<Integer> {
// @Override
// public Class getBasePropertyClass() {
// return Integer.class;
// }
//
// @Override
// public Integer interpolate(Integer from, Integer to,
// float timelinePosition) {
// return (int) (from + (to - from) * timelinePosition);
// }
// }
//
// private static class LongPropertyInterpolator implements
// PropertyInterpolator<Long> {
// @Override
// public Class getBasePropertyClass() {
// return Long.class;
// }
//
// @Override
// public Long interpolate(Long from, Long to, float timelinePosition) {
// return (long) (from + (to - from) * timelinePosition);
// }
// }
// }
//
// Path: projects/main/src/main/java/libshapedraw/animation/trident/interpolator/PropertyInterpolator.java
// public interface PropertyInterpolator<T> {
// public Class getBasePropertyClass();
//
// public T interpolate(T from, T to, float timelinePosition);
// }
//
// Path: projects/main/src/main/java/libshapedraw/animation/trident/interpolator/PropertyInterpolatorSource.java
// public interface PropertyInterpolatorSource {
// public Set<PropertyInterpolator> getPropertyInterpolators();
// }
// Path: projects/main/src/main/java/libshapedraw/animation/trident/TridentConfig.java
import java.io.*;
import java.net.URL;
import java.util.*;
import libshapedraw.animation.trident.TimelineEngine.TridentAnimationThread;
import libshapedraw.animation.trident.interpolator.CorePropertyInterpolators;
import libshapedraw.animation.trident.interpolator.PropertyInterpolator;
import libshapedraw.animation.trident.interpolator.PropertyInterpolatorSource;
return null;
}
public synchronized void addPropertyInterpolator(
PropertyInterpolator pInterpolator) {
this.propertyInterpolators.add(pInterpolator);
}
public synchronized void addPropertyInterpolatorSource(
PropertyInterpolatorSource pInterpolatorSource) {
this.propertyInterpolators.addAll(pInterpolatorSource
.getPropertyInterpolators());
}
public synchronized void removePropertyInterpolator(
PropertyInterpolator pInterpolator) {
this.propertyInterpolators.remove(pInterpolator);
}
public synchronized void addUIToolkitHandler(
UIToolkitHandler uiToolkitHandler) {
this.uiToolkitHandlers.add(uiToolkitHandler);
}
public synchronized void removeUIToolkitHandler(
UIToolkitHandler uiToolkitHandler) {
this.uiToolkitHandlers.remove(uiToolkitHandler);
}
public synchronized void setPulseSource(PulseSource pulseSource) {
|
TridentAnimationThread current = TimelineEngine.getInstance().animatorThread;
|
bencvt/LibShapeDraw
|
projects/main/src/main/java/libshapedraw/ApiInfo.java
|
// Path: projects/main/src/main/java/libshapedraw/internal/LSDInternalException.java
// public class LSDInternalException extends RuntimeException {
// private static final long serialVersionUID = 1L;
//
// public LSDInternalException(String message) {
// super(message);
// }
//
// public LSDInternalException(String message, Throwable t) {
// super(message, t);
// }
// }
//
// Path: projects/main/src/main/java/libshapedraw/internal/LSDModDirectory.java
// public class LSDModDirectory {
// public static final File DIRECTORY = new File(getMinecraftDir(), "mods" + File.separator + ApiInfo.getName());
//
// /**
// * Use reflection to invoke the static method. This supports both normal
// * play (reobfuscated minecraft.jar) and development (deobfuscated classes
// * in MCP).
// */
// private static File getMinecraftDir() {
// try {
// Method m;
// try {
// m = Minecraft.class.getMethod("b");
// } catch (NoSuchMethodException e) {
// m = Minecraft.class.getMethod("getMinecraftDir");
// }
// return (File) m.invoke(null);
// } catch (Exception e) {
// throw new LSDInternalReflectionException("unable to invoke Minecraft.getMinecraftDir", e);
// }
// }
// }
|
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Properties;
import libshapedraw.internal.LSDInternalException;
import libshapedraw.internal.LSDModDirectory;
|
return getInstance().name;
}
public static String getVersion() {
return getInstance().version;
}
public static boolean isVersionAtLeast(String minVersion) {
if (minVersion == null) {
throw new IllegalArgumentException("minVersion cannot be null");
}
return minVersion.compareTo(getInstance().version) <= 0;
}
@Deprecated public static String getUrl() {
return getInstance().urlMain.toString();
}
public static URL getUrlMain() {
return getInstance().urlMain;
}
public static URL getUrlShort() {
return getInstance().urlShort;
}
public static URL getUrlSource() {
return getInstance().urlSource;
}
public static URL getUrlUpdate() {
return getInstance().urlUpdate;
}
public static String getAuthors() {
return getInstance().authors;
}
public static File getModDirectory() {
|
// Path: projects/main/src/main/java/libshapedraw/internal/LSDInternalException.java
// public class LSDInternalException extends RuntimeException {
// private static final long serialVersionUID = 1L;
//
// public LSDInternalException(String message) {
// super(message);
// }
//
// public LSDInternalException(String message, Throwable t) {
// super(message, t);
// }
// }
//
// Path: projects/main/src/main/java/libshapedraw/internal/LSDModDirectory.java
// public class LSDModDirectory {
// public static final File DIRECTORY = new File(getMinecraftDir(), "mods" + File.separator + ApiInfo.getName());
//
// /**
// * Use reflection to invoke the static method. This supports both normal
// * play (reobfuscated minecraft.jar) and development (deobfuscated classes
// * in MCP).
// */
// private static File getMinecraftDir() {
// try {
// Method m;
// try {
// m = Minecraft.class.getMethod("b");
// } catch (NoSuchMethodException e) {
// m = Minecraft.class.getMethod("getMinecraftDir");
// }
// return (File) m.invoke(null);
// } catch (Exception e) {
// throw new LSDInternalReflectionException("unable to invoke Minecraft.getMinecraftDir", e);
// }
// }
// }
// Path: projects/main/src/main/java/libshapedraw/ApiInfo.java
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Properties;
import libshapedraw.internal.LSDInternalException;
import libshapedraw.internal.LSDModDirectory;
return getInstance().name;
}
public static String getVersion() {
return getInstance().version;
}
public static boolean isVersionAtLeast(String minVersion) {
if (minVersion == null) {
throw new IllegalArgumentException("minVersion cannot be null");
}
return minVersion.compareTo(getInstance().version) <= 0;
}
@Deprecated public static String getUrl() {
return getInstance().urlMain.toString();
}
public static URL getUrlMain() {
return getInstance().urlMain;
}
public static URL getUrlShort() {
return getInstance().urlShort;
}
public static URL getUrlSource() {
return getInstance().urlSource;
}
public static URL getUrlUpdate() {
return getInstance().urlUpdate;
}
public static String getAuthors() {
return getInstance().authors;
}
public static File getModDirectory() {
|
return LSDModDirectory.DIRECTORY;
|
bencvt/LibShapeDraw
|
projects/main/src/main/java/libshapedraw/ApiInfo.java
|
// Path: projects/main/src/main/java/libshapedraw/internal/LSDInternalException.java
// public class LSDInternalException extends RuntimeException {
// private static final long serialVersionUID = 1L;
//
// public LSDInternalException(String message) {
// super(message);
// }
//
// public LSDInternalException(String message, Throwable t) {
// super(message, t);
// }
// }
//
// Path: projects/main/src/main/java/libshapedraw/internal/LSDModDirectory.java
// public class LSDModDirectory {
// public static final File DIRECTORY = new File(getMinecraftDir(), "mods" + File.separator + ApiInfo.getName());
//
// /**
// * Use reflection to invoke the static method. This supports both normal
// * play (reobfuscated minecraft.jar) and development (deobfuscated classes
// * in MCP).
// */
// private static File getMinecraftDir() {
// try {
// Method m;
// try {
// m = Minecraft.class.getMethod("b");
// } catch (NoSuchMethodException e) {
// m = Minecraft.class.getMethod("getMinecraftDir");
// }
// return (File) m.invoke(null);
// } catch (Exception e) {
// throw new LSDInternalReflectionException("unable to invoke Minecraft.getMinecraftDir", e);
// }
// }
// }
|
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Properties;
import libshapedraw.internal.LSDInternalException;
import libshapedraw.internal.LSDModDirectory;
|
public static URL getUrlSource() {
return getInstance().urlSource;
}
public static URL getUrlUpdate() {
return getInstance().urlUpdate;
}
public static String getAuthors() {
return getInstance().authors;
}
public static File getModDirectory() {
return LSDModDirectory.DIRECTORY;
}
private final String name;
private final String version;
private final URL urlMain;
private final URL urlShort;
private final URL urlSource;
private final URL urlUpdate;
private final String authors;
private static ApiInfo instance;
private ApiInfo() {
Properties props = new Properties();
InputStream in = getClass().getResourceAsStream("api.properties");
try {
props.load(in);
in.close();
} catch (IOException e) {
|
// Path: projects/main/src/main/java/libshapedraw/internal/LSDInternalException.java
// public class LSDInternalException extends RuntimeException {
// private static final long serialVersionUID = 1L;
//
// public LSDInternalException(String message) {
// super(message);
// }
//
// public LSDInternalException(String message, Throwable t) {
// super(message, t);
// }
// }
//
// Path: projects/main/src/main/java/libshapedraw/internal/LSDModDirectory.java
// public class LSDModDirectory {
// public static final File DIRECTORY = new File(getMinecraftDir(), "mods" + File.separator + ApiInfo.getName());
//
// /**
// * Use reflection to invoke the static method. This supports both normal
// * play (reobfuscated minecraft.jar) and development (deobfuscated classes
// * in MCP).
// */
// private static File getMinecraftDir() {
// try {
// Method m;
// try {
// m = Minecraft.class.getMethod("b");
// } catch (NoSuchMethodException e) {
// m = Minecraft.class.getMethod("getMinecraftDir");
// }
// return (File) m.invoke(null);
// } catch (Exception e) {
// throw new LSDInternalReflectionException("unable to invoke Minecraft.getMinecraftDir", e);
// }
// }
// }
// Path: projects/main/src/main/java/libshapedraw/ApiInfo.java
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Properties;
import libshapedraw.internal.LSDInternalException;
import libshapedraw.internal.LSDModDirectory;
public static URL getUrlSource() {
return getInstance().urlSource;
}
public static URL getUrlUpdate() {
return getInstance().urlUpdate;
}
public static String getAuthors() {
return getInstance().authors;
}
public static File getModDirectory() {
return LSDModDirectory.DIRECTORY;
}
private final String name;
private final String version;
private final URL urlMain;
private final URL urlShort;
private final URL urlSource;
private final URL urlUpdate;
private final String authors;
private static ApiInfo instance;
private ApiInfo() {
Properties props = new Properties();
InputStream in = getClass().getResourceAsStream("api.properties");
try {
props.load(in);
in.close();
} catch (IOException e) {
|
throw new LSDInternalException("unable to load resource", e);
|
bencvt/LibShapeDraw
|
projects/main/src/main/java/libshapedraw/primitive/LineStyle.java
|
// Path: projects/main/src/main/java/libshapedraw/shape/XrayShape.java
// public interface XrayShape {
// public ReadonlyColor getMainColorReadonly();
//
// public ReadonlyColor getSecondaryColorReadonly();
//
// /** @return true if getSecondaryColorReadonly() is non-null. */
// public boolean isVisibleThroughTerrain();
//
// /**
// * A recommended alpha scaling factor to apply when making a secondary
// * color based on the main color. In other words, how much to reduce the
// * transparency of the secondary color.
// * <p>
// * This isn't obligatory. The secondary color does not necessarily have to
// * be based on the main color.
// */
// public static double SECONDARY_ALPHA = 0.25;
// }
|
import libshapedraw.shape.XrayShape;
import org.lwjgl.opengl.GL11;
|
}
/**
* Set the line style's main width.
* @return the same line style object, modified in-place.
*/
public LineStyle setMainWidth(float mainWidth) {
if (mainWidth < 0) {
throw new IllegalArgumentException("line width must be positive");
}
this.mainWidth = mainWidth;
return this;
}
/**
* Set the line style's secondary color, which can be null.
* @return the same line style object, modified in-place.
*/
public LineStyle setSecondaryColor(Color secondaryColor) {
// null allowed
this.secondaryColor = secondaryColor;
return this;
}
/**
* Set the line style's secondary color to a semi-transparent version of
* the main line color.
* @return the same line style object, modified in-place.
*/
public LineStyle setSecondaryColorFromMain() {
|
// Path: projects/main/src/main/java/libshapedraw/shape/XrayShape.java
// public interface XrayShape {
// public ReadonlyColor getMainColorReadonly();
//
// public ReadonlyColor getSecondaryColorReadonly();
//
// /** @return true if getSecondaryColorReadonly() is non-null. */
// public boolean isVisibleThroughTerrain();
//
// /**
// * A recommended alpha scaling factor to apply when making a secondary
// * color based on the main color. In other words, how much to reduce the
// * transparency of the secondary color.
// * <p>
// * This isn't obligatory. The secondary color does not necessarily have to
// * be based on the main color.
// */
// public static double SECONDARY_ALPHA = 0.25;
// }
// Path: projects/main/src/main/java/libshapedraw/primitive/LineStyle.java
import libshapedraw.shape.XrayShape;
import org.lwjgl.opengl.GL11;
}
/**
* Set the line style's main width.
* @return the same line style object, modified in-place.
*/
public LineStyle setMainWidth(float mainWidth) {
if (mainWidth < 0) {
throw new IllegalArgumentException("line width must be positive");
}
this.mainWidth = mainWidth;
return this;
}
/**
* Set the line style's secondary color, which can be null.
* @return the same line style object, modified in-place.
*/
public LineStyle setSecondaryColor(Color secondaryColor) {
// null allowed
this.secondaryColor = secondaryColor;
return this;
}
/**
* Set the line style's secondary color to a semi-transparent version of
* the main line color.
* @return the same line style object, modified in-place.
*/
public LineStyle setSecondaryColorFromMain() {
|
secondaryColor = mainColor.copy().scaleAlpha(XrayShape.SECONDARY_ALPHA);
|
bencvt/LibShapeDraw
|
projects/main/src/main/java/libshapedraw/animation/trident/interpolator/KeyFrames.java
|
// Path: projects/main/src/main/java/libshapedraw/animation/trident/ease/TimelineEase.java
// public interface TimelineEase {
// public float map(float durationFraction);
// }
|
import libshapedraw.animation.trident.ease.TimelineEase;
|
// original package: org.pushingpixels.trident.interpolator
// imported from http://kenai.com/projects/trident/ (version 1.3)
/**
* Copyright (c) 2006, Sun Microsystems, Inc
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of the TimingFramework project nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package libshapedraw.animation.trident.interpolator;
/**
*
* KeyFrames holds information about the times at which values are sampled
* (KeyTimes) and the values at those times (KeyValues). It also holds
* information about how to interpolate between these values for times that lie
* between the sampling points.
*
* @author Chet
*/
public class KeyFrames<T> {
private KeyValues<T> keyValues;
private KeyTimes keyTimes;
private KeyInterpolators interpolators;
/**
* Simplest variation; determine keyTimes based on even division of 0-1
* range based on number of keyValues. This constructor assumes LINEAR
* interpolation.
*
* @param keyValues
* values that will be assumed at each time in keyTimes
*/
public KeyFrames(KeyValues<T> keyValues) {
|
// Path: projects/main/src/main/java/libshapedraw/animation/trident/ease/TimelineEase.java
// public interface TimelineEase {
// public float map(float durationFraction);
// }
// Path: projects/main/src/main/java/libshapedraw/animation/trident/interpolator/KeyFrames.java
import libshapedraw.animation.trident.ease.TimelineEase;
// original package: org.pushingpixels.trident.interpolator
// imported from http://kenai.com/projects/trident/ (version 1.3)
/**
* Copyright (c) 2006, Sun Microsystems, Inc
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of the TimingFramework project nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package libshapedraw.animation.trident.interpolator;
/**
*
* KeyFrames holds information about the times at which values are sampled
* (KeyTimes) and the values at those times (KeyValues). It also holds
* information about how to interpolate between these values for times that lie
* between the sampling points.
*
* @author Chet
*/
public class KeyFrames<T> {
private KeyValues<T> keyValues;
private KeyTimes keyTimes;
private KeyInterpolators interpolators;
/**
* Simplest variation; determine keyTimes based on even division of 0-1
* range based on number of keyValues. This constructor assumes LINEAR
* interpolation.
*
* @param keyValues
* values that will be assumed at each time in keyTimes
*/
public KeyFrames(KeyValues<T> keyValues) {
|
init(keyValues, null, (TimelineEase) null);
|
bencvt/LibShapeDraw
|
projects/main/src/main/java/libshapedraw/internal/LSDUpdateCheck.java
|
// Path: projects/main/src/main/java/libshapedraw/ApiInfo.java
// public class ApiInfo {
// public static String getName() {
// return getInstance().name;
// }
// public static String getVersion() {
// return getInstance().version;
// }
// public static boolean isVersionAtLeast(String minVersion) {
// if (minVersion == null) {
// throw new IllegalArgumentException("minVersion cannot be null");
// }
// return minVersion.compareTo(getInstance().version) <= 0;
// }
// @Deprecated public static String getUrl() {
// return getInstance().urlMain.toString();
// }
// public static URL getUrlMain() {
// return getInstance().urlMain;
// }
// public static URL getUrlShort() {
// return getInstance().urlShort;
// }
// public static URL getUrlSource() {
// return getInstance().urlSource;
// }
// public static URL getUrlUpdate() {
// return getInstance().urlUpdate;
// }
// public static String getAuthors() {
// return getInstance().authors;
// }
// public static File getModDirectory() {
// return LSDModDirectory.DIRECTORY;
// }
//
// private final String name;
// private final String version;
// private final URL urlMain;
// private final URL urlShort;
// private final URL urlSource;
// private final URL urlUpdate;
// private final String authors;
//
// private static ApiInfo instance;
//
// private ApiInfo() {
// Properties props = new Properties();
// InputStream in = getClass().getResourceAsStream("api.properties");
// try {
// props.load(in);
// in.close();
// } catch (IOException e) {
// throw new LSDInternalException("unable to load resource", e);
// }
// name = notNull(props.getProperty("name"));
// version = notNull(props.getProperty("version"));
// urlMain = validUrl(props.getProperty("url-main"));
// urlShort = validUrl(props.getProperty("url-short"));
// urlSource = validUrl(props.getProperty("url-source"));
// urlUpdate = validUrl(props.getProperty("url-update"));
// authors = notNull(props.getProperty("authors"));
// }
//
// private static ApiInfo getInstance() {
// if (instance == null) {
// instance = new ApiInfo();
// }
// return instance;
// }
//
// private String notNull(String value) {
// if (value == null) {
// throw new IllegalArgumentException("value cannot be null");
// }
// return value;
// }
//
// private URL validUrl(String value) {
// try {
// return new URL(notNull(value));
// } catch (MalformedURLException e) {
// throw new IllegalArgumentException("invalid url: " + value, e);
// }
// }
// }
//
// Path: projects/main/src/main/java/libshapedraw/MinecraftAccess.java
// public interface MinecraftAccess {
// /** Tessellator.instance.startDrawing */
// public MinecraftAccess startDrawing(int mode);
//
// /** Tessellator.instance.addVertex */
// public MinecraftAccess addVertex(double x, double y, double z);
//
// /** Tessellator.instance.addVertex */
// public MinecraftAccess addVertex(ReadonlyVector3 coords);
//
// /** Tessellator.instance.draw */
// public MinecraftAccess finishDrawing();
//
// /** RenderHelper.enableStandardItemLighting */
// public MinecraftAccess enableStandardItemLighting();
//
// /** Minecraft.ingameGUI.getChatGUI().printChatMessage */
// public MinecraftAccess sendChatMessage(String message);
//
// /** Minecraft.ingameGUI.getChatGUI() */
// public boolean chatWindowExists();
//
// /** Minecraft.timer.renderPartialTicks */
// public float getPartialTick();
//
// /** Minecraft.mcProfiler.startSection */
// public MinecraftAccess profilerStartSection(String sectionName);
//
// /** Minecraft.mcProfiler.endSection */
// public MinecraftAccess profilerEndSection();
//
// /** Minecraft.mcProfiler.endStartSection */
// public MinecraftAccess profilerEndStartSection(String sectionName);
// }
|
import libshapedraw.ApiInfo;
import libshapedraw.MinecraftAccess;
|
package libshapedraw.internal;
/**
* Internal class. Check the remote website for updates.
* <p>
* The server-side part of this is dead simple: a static text file hosted on a
* web server.
*/
public class LSDUpdateCheck {
public class UrlRetriever implements Runnable {
@Override
public void run() {
|
// Path: projects/main/src/main/java/libshapedraw/ApiInfo.java
// public class ApiInfo {
// public static String getName() {
// return getInstance().name;
// }
// public static String getVersion() {
// return getInstance().version;
// }
// public static boolean isVersionAtLeast(String minVersion) {
// if (minVersion == null) {
// throw new IllegalArgumentException("minVersion cannot be null");
// }
// return minVersion.compareTo(getInstance().version) <= 0;
// }
// @Deprecated public static String getUrl() {
// return getInstance().urlMain.toString();
// }
// public static URL getUrlMain() {
// return getInstance().urlMain;
// }
// public static URL getUrlShort() {
// return getInstance().urlShort;
// }
// public static URL getUrlSource() {
// return getInstance().urlSource;
// }
// public static URL getUrlUpdate() {
// return getInstance().urlUpdate;
// }
// public static String getAuthors() {
// return getInstance().authors;
// }
// public static File getModDirectory() {
// return LSDModDirectory.DIRECTORY;
// }
//
// private final String name;
// private final String version;
// private final URL urlMain;
// private final URL urlShort;
// private final URL urlSource;
// private final URL urlUpdate;
// private final String authors;
//
// private static ApiInfo instance;
//
// private ApiInfo() {
// Properties props = new Properties();
// InputStream in = getClass().getResourceAsStream("api.properties");
// try {
// props.load(in);
// in.close();
// } catch (IOException e) {
// throw new LSDInternalException("unable to load resource", e);
// }
// name = notNull(props.getProperty("name"));
// version = notNull(props.getProperty("version"));
// urlMain = validUrl(props.getProperty("url-main"));
// urlShort = validUrl(props.getProperty("url-short"));
// urlSource = validUrl(props.getProperty("url-source"));
// urlUpdate = validUrl(props.getProperty("url-update"));
// authors = notNull(props.getProperty("authors"));
// }
//
// private static ApiInfo getInstance() {
// if (instance == null) {
// instance = new ApiInfo();
// }
// return instance;
// }
//
// private String notNull(String value) {
// if (value == null) {
// throw new IllegalArgumentException("value cannot be null");
// }
// return value;
// }
//
// private URL validUrl(String value) {
// try {
// return new URL(notNull(value));
// } catch (MalformedURLException e) {
// throw new IllegalArgumentException("invalid url: " + value, e);
// }
// }
// }
//
// Path: projects/main/src/main/java/libshapedraw/MinecraftAccess.java
// public interface MinecraftAccess {
// /** Tessellator.instance.startDrawing */
// public MinecraftAccess startDrawing(int mode);
//
// /** Tessellator.instance.addVertex */
// public MinecraftAccess addVertex(double x, double y, double z);
//
// /** Tessellator.instance.addVertex */
// public MinecraftAccess addVertex(ReadonlyVector3 coords);
//
// /** Tessellator.instance.draw */
// public MinecraftAccess finishDrawing();
//
// /** RenderHelper.enableStandardItemLighting */
// public MinecraftAccess enableStandardItemLighting();
//
// /** Minecraft.ingameGUI.getChatGUI().printChatMessage */
// public MinecraftAccess sendChatMessage(String message);
//
// /** Minecraft.ingameGUI.getChatGUI() */
// public boolean chatWindowExists();
//
// /** Minecraft.timer.renderPartialTicks */
// public float getPartialTick();
//
// /** Minecraft.mcProfiler.startSection */
// public MinecraftAccess profilerStartSection(String sectionName);
//
// /** Minecraft.mcProfiler.endSection */
// public MinecraftAccess profilerEndSection();
//
// /** Minecraft.mcProfiler.endStartSection */
// public MinecraftAccess profilerEndStartSection(String sectionName);
// }
// Path: projects/main/src/main/java/libshapedraw/internal/LSDUpdateCheck.java
import libshapedraw.ApiInfo;
import libshapedraw.MinecraftAccess;
package libshapedraw.internal;
/**
* Internal class. Check the remote website for updates.
* <p>
* The server-side part of this is dead simple: a static text file hosted on a
* web server.
*/
public class LSDUpdateCheck {
public class UrlRetriever implements Runnable {
@Override
public void run() {
|
LSDController.getLog().info("update check request: " + ApiInfo.getUrlUpdate());
|
bencvt/LibShapeDraw
|
projects/main/src/main/java/libshapedraw/internal/LSDUpdateCheck.java
|
// Path: projects/main/src/main/java/libshapedraw/ApiInfo.java
// public class ApiInfo {
// public static String getName() {
// return getInstance().name;
// }
// public static String getVersion() {
// return getInstance().version;
// }
// public static boolean isVersionAtLeast(String minVersion) {
// if (minVersion == null) {
// throw new IllegalArgumentException("minVersion cannot be null");
// }
// return minVersion.compareTo(getInstance().version) <= 0;
// }
// @Deprecated public static String getUrl() {
// return getInstance().urlMain.toString();
// }
// public static URL getUrlMain() {
// return getInstance().urlMain;
// }
// public static URL getUrlShort() {
// return getInstance().urlShort;
// }
// public static URL getUrlSource() {
// return getInstance().urlSource;
// }
// public static URL getUrlUpdate() {
// return getInstance().urlUpdate;
// }
// public static String getAuthors() {
// return getInstance().authors;
// }
// public static File getModDirectory() {
// return LSDModDirectory.DIRECTORY;
// }
//
// private final String name;
// private final String version;
// private final URL urlMain;
// private final URL urlShort;
// private final URL urlSource;
// private final URL urlUpdate;
// private final String authors;
//
// private static ApiInfo instance;
//
// private ApiInfo() {
// Properties props = new Properties();
// InputStream in = getClass().getResourceAsStream("api.properties");
// try {
// props.load(in);
// in.close();
// } catch (IOException e) {
// throw new LSDInternalException("unable to load resource", e);
// }
// name = notNull(props.getProperty("name"));
// version = notNull(props.getProperty("version"));
// urlMain = validUrl(props.getProperty("url-main"));
// urlShort = validUrl(props.getProperty("url-short"));
// urlSource = validUrl(props.getProperty("url-source"));
// urlUpdate = validUrl(props.getProperty("url-update"));
// authors = notNull(props.getProperty("authors"));
// }
//
// private static ApiInfo getInstance() {
// if (instance == null) {
// instance = new ApiInfo();
// }
// return instance;
// }
//
// private String notNull(String value) {
// if (value == null) {
// throw new IllegalArgumentException("value cannot be null");
// }
// return value;
// }
//
// private URL validUrl(String value) {
// try {
// return new URL(notNull(value));
// } catch (MalformedURLException e) {
// throw new IllegalArgumentException("invalid url: " + value, e);
// }
// }
// }
//
// Path: projects/main/src/main/java/libshapedraw/MinecraftAccess.java
// public interface MinecraftAccess {
// /** Tessellator.instance.startDrawing */
// public MinecraftAccess startDrawing(int mode);
//
// /** Tessellator.instance.addVertex */
// public MinecraftAccess addVertex(double x, double y, double z);
//
// /** Tessellator.instance.addVertex */
// public MinecraftAccess addVertex(ReadonlyVector3 coords);
//
// /** Tessellator.instance.draw */
// public MinecraftAccess finishDrawing();
//
// /** RenderHelper.enableStandardItemLighting */
// public MinecraftAccess enableStandardItemLighting();
//
// /** Minecraft.ingameGUI.getChatGUI().printChatMessage */
// public MinecraftAccess sendChatMessage(String message);
//
// /** Minecraft.ingameGUI.getChatGUI() */
// public boolean chatWindowExists();
//
// /** Minecraft.timer.renderPartialTicks */
// public float getPartialTick();
//
// /** Minecraft.mcProfiler.startSection */
// public MinecraftAccess profilerStartSection(String sectionName);
//
// /** Minecraft.mcProfiler.endSection */
// public MinecraftAccess profilerEndSection();
//
// /** Minecraft.mcProfiler.endStartSection */
// public MinecraftAccess profilerEndStartSection(String sectionName);
// }
|
import libshapedraw.ApiInfo;
import libshapedraw.MinecraftAccess;
|
}
b.append(lines[i]);
}
}
if (b.length() > 0) {
result = b.toString();
} else {
// The response was just the version.
result = buildOutput(lines[0]);
}
}
private String buildOutput(String newVersion) {
return new StringBuilder().append("\u00a7c")
.append(ApiInfo.getName()).append(" is out of date. ")
.append(newVersion.isEmpty() ? "A new version" : "Version ")
.append(newVersion)
.append(" is available at\n \u00a7c")
.append(ApiInfo.getUrlShort()).toString();
}
}
private String result;
public LSDUpdateCheck() {
if (LSDGlobalSettings.isUpdateCheckEnabled()) {
new Thread(new UrlRetriever()).start();
}
}
|
// Path: projects/main/src/main/java/libshapedraw/ApiInfo.java
// public class ApiInfo {
// public static String getName() {
// return getInstance().name;
// }
// public static String getVersion() {
// return getInstance().version;
// }
// public static boolean isVersionAtLeast(String minVersion) {
// if (minVersion == null) {
// throw new IllegalArgumentException("minVersion cannot be null");
// }
// return minVersion.compareTo(getInstance().version) <= 0;
// }
// @Deprecated public static String getUrl() {
// return getInstance().urlMain.toString();
// }
// public static URL getUrlMain() {
// return getInstance().urlMain;
// }
// public static URL getUrlShort() {
// return getInstance().urlShort;
// }
// public static URL getUrlSource() {
// return getInstance().urlSource;
// }
// public static URL getUrlUpdate() {
// return getInstance().urlUpdate;
// }
// public static String getAuthors() {
// return getInstance().authors;
// }
// public static File getModDirectory() {
// return LSDModDirectory.DIRECTORY;
// }
//
// private final String name;
// private final String version;
// private final URL urlMain;
// private final URL urlShort;
// private final URL urlSource;
// private final URL urlUpdate;
// private final String authors;
//
// private static ApiInfo instance;
//
// private ApiInfo() {
// Properties props = new Properties();
// InputStream in = getClass().getResourceAsStream("api.properties");
// try {
// props.load(in);
// in.close();
// } catch (IOException e) {
// throw new LSDInternalException("unable to load resource", e);
// }
// name = notNull(props.getProperty("name"));
// version = notNull(props.getProperty("version"));
// urlMain = validUrl(props.getProperty("url-main"));
// urlShort = validUrl(props.getProperty("url-short"));
// urlSource = validUrl(props.getProperty("url-source"));
// urlUpdate = validUrl(props.getProperty("url-update"));
// authors = notNull(props.getProperty("authors"));
// }
//
// private static ApiInfo getInstance() {
// if (instance == null) {
// instance = new ApiInfo();
// }
// return instance;
// }
//
// private String notNull(String value) {
// if (value == null) {
// throw new IllegalArgumentException("value cannot be null");
// }
// return value;
// }
//
// private URL validUrl(String value) {
// try {
// return new URL(notNull(value));
// } catch (MalformedURLException e) {
// throw new IllegalArgumentException("invalid url: " + value, e);
// }
// }
// }
//
// Path: projects/main/src/main/java/libshapedraw/MinecraftAccess.java
// public interface MinecraftAccess {
// /** Tessellator.instance.startDrawing */
// public MinecraftAccess startDrawing(int mode);
//
// /** Tessellator.instance.addVertex */
// public MinecraftAccess addVertex(double x, double y, double z);
//
// /** Tessellator.instance.addVertex */
// public MinecraftAccess addVertex(ReadonlyVector3 coords);
//
// /** Tessellator.instance.draw */
// public MinecraftAccess finishDrawing();
//
// /** RenderHelper.enableStandardItemLighting */
// public MinecraftAccess enableStandardItemLighting();
//
// /** Minecraft.ingameGUI.getChatGUI().printChatMessage */
// public MinecraftAccess sendChatMessage(String message);
//
// /** Minecraft.ingameGUI.getChatGUI() */
// public boolean chatWindowExists();
//
// /** Minecraft.timer.renderPartialTicks */
// public float getPartialTick();
//
// /** Minecraft.mcProfiler.startSection */
// public MinecraftAccess profilerStartSection(String sectionName);
//
// /** Minecraft.mcProfiler.endSection */
// public MinecraftAccess profilerEndSection();
//
// /** Minecraft.mcProfiler.endStartSection */
// public MinecraftAccess profilerEndStartSection(String sectionName);
// }
// Path: projects/main/src/main/java/libshapedraw/internal/LSDUpdateCheck.java
import libshapedraw.ApiInfo;
import libshapedraw.MinecraftAccess;
}
b.append(lines[i]);
}
}
if (b.length() > 0) {
result = b.toString();
} else {
// The response was just the version.
result = buildOutput(lines[0]);
}
}
private String buildOutput(String newVersion) {
return new StringBuilder().append("\u00a7c")
.append(ApiInfo.getName()).append(" is out of date. ")
.append(newVersion.isEmpty() ? "A new version" : "Version ")
.append(newVersion)
.append(" is available at\n \u00a7c")
.append(ApiInfo.getUrlShort()).toString();
}
}
private String result;
public LSDUpdateCheck() {
if (LSDGlobalSettings.isUpdateCheckEnabled()) {
new Thread(new UrlRetriever()).start();
}
}
|
public void announceResultIfReady(MinecraftAccess minecraftAccess) {
|
bencvt/LibShapeDraw
|
projects/main/src/main/java/libshapedraw/animation/trident/callback/TimelineCallbackAdapter.java
|
// Path: projects/main/src/main/java/libshapedraw/animation/trident/Timeline.java
// public enum TimelineState {
// IDLE(false), READY(false), PLAYING_FORWARD(true), PLAYING_REVERSE(true), SUSPENDED(
// false), CANCELLED(false), DONE(false);
//
// private boolean isActive;
//
// private TimelineState(boolean isActive) {
// this.isActive = isActive;
// }
// }
|
import libshapedraw.animation.trident.Timeline.TimelineState;
|
// original package: org.pushingpixels.trident.callback
// imported from http://kenai.com/projects/trident/ (version 1.3)
/*
* Copyright (c) 2005-2010 Trident Kirill Grouchnikov. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* o Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* o Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* o Neither the name of Trident Kirill Grouchnikov nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package libshapedraw.animation.trident.callback;
/**
* Default implementation of {@link TimelineCallback} that does nothing.
*
* @author Kirill Grouchnikov
*/
public class TimelineCallbackAdapter implements TimelineCallback {
@Override
|
// Path: projects/main/src/main/java/libshapedraw/animation/trident/Timeline.java
// public enum TimelineState {
// IDLE(false), READY(false), PLAYING_FORWARD(true), PLAYING_REVERSE(true), SUSPENDED(
// false), CANCELLED(false), DONE(false);
//
// private boolean isActive;
//
// private TimelineState(boolean isActive) {
// this.isActive = isActive;
// }
// }
// Path: projects/main/src/main/java/libshapedraw/animation/trident/callback/TimelineCallbackAdapter.java
import libshapedraw.animation.trident.Timeline.TimelineState;
// original package: org.pushingpixels.trident.callback
// imported from http://kenai.com/projects/trident/ (version 1.3)
/*
* Copyright (c) 2005-2010 Trident Kirill Grouchnikov. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* o Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* o Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* o Neither the name of Trident Kirill Grouchnikov nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package libshapedraw.animation.trident.callback;
/**
* Default implementation of {@link TimelineCallback} that does nothing.
*
* @author Kirill Grouchnikov
*/
public class TimelineCallbackAdapter implements TimelineCallback {
@Override
|
public void onTimelineStateChanged(TimelineState oldState,
|
bencvt/LibShapeDraw
|
projects/main/src/main/java/libshapedraw/animation/trident/TimelineScenario.java
|
// Path: projects/main/src/main/java/libshapedraw/animation/trident/callback/TimelineScenarioCallback.java
// public interface TimelineScenarioCallback {
// /**
// * Indicates that the all timelines and swing workers in the timeline
// * scenario have finished.
// */
// public void onTimelineScenarioDone();
// }
|
import java.util.*;
import libshapedraw.animation.trident.callback.TimelineScenarioCallback;
|
// original package: org.pushingpixels.trident
// imported from http://kenai.com/projects/trident/ (version 1.3)
/*
* Copyright (c) 2005-2010 Trident Kirill Grouchnikov. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* o Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* o Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* o Neither the name of Trident Kirill Grouchnikov nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package libshapedraw.animation.trident;
public class TimelineScenario {
private Set<TimelineScenarioActor> waitingActors;
private Set<TimelineScenarioActor> runningActors;
private Set<TimelineScenarioActor> doneActors;
private Map<TimelineScenarioActor, Set<TimelineScenarioActor>> dependencies;
Chain callback;
TimelineScenarioState state;
TimelineScenarioState statePriorToSuspension;
boolean isLooping;
public enum TimelineScenarioState {
DONE, PLAYING, IDLE, SUSPENDED
}
|
// Path: projects/main/src/main/java/libshapedraw/animation/trident/callback/TimelineScenarioCallback.java
// public interface TimelineScenarioCallback {
// /**
// * Indicates that the all timelines and swing workers in the timeline
// * scenario have finished.
// */
// public void onTimelineScenarioDone();
// }
// Path: projects/main/src/main/java/libshapedraw/animation/trident/TimelineScenario.java
import java.util.*;
import libshapedraw.animation.trident.callback.TimelineScenarioCallback;
// original package: org.pushingpixels.trident
// imported from http://kenai.com/projects/trident/ (version 1.3)
/*
* Copyright (c) 2005-2010 Trident Kirill Grouchnikov. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* o Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* o Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* o Neither the name of Trident Kirill Grouchnikov nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package libshapedraw.animation.trident;
public class TimelineScenario {
private Set<TimelineScenarioActor> waitingActors;
private Set<TimelineScenarioActor> runningActors;
private Set<TimelineScenarioActor> doneActors;
private Map<TimelineScenarioActor, Set<TimelineScenarioActor>> dependencies;
Chain callback;
TimelineScenarioState state;
TimelineScenarioState statePriorToSuspension;
boolean isLooping;
public enum TimelineScenarioState {
DONE, PLAYING, IDLE, SUSPENDED
}
|
class Chain implements TimelineScenarioCallback {
|
bencvt/LibShapeDraw
|
projects/main/src/main/java/libshapedraw/animation/trident/TimelineEngine.java
|
// Path: projects/main/src/main/java/libshapedraw/animation/trident/Timeline.java
// public enum TimelineState {
// IDLE(false), READY(false), PLAYING_FORWARD(true), PLAYING_REVERSE(true), SUSPENDED(
// false), CANCELLED(false), DONE(false);
//
// private boolean isActive;
//
// private TimelineState(boolean isActive) {
// this.isActive = isActive;
// }
// }
//
// Path: projects/main/src/main/java/libshapedraw/animation/trident/TimelineScenario.java
// public enum TimelineScenarioState {
// DONE, PLAYING, IDLE, SUSPENDED
// }
|
import java.util.*;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
import libshapedraw.animation.trident.Timeline.TimelineState;
import libshapedraw.animation.trident.TimelineScenario.TimelineScenarioState;
import libshapedraw.animation.trident.callback.RunOnUIThread;
|
long passedSinceLastIteration = (System.currentTimeMillis() - this.lastIterationTimeStamp);
if (passedSinceLastIteration < 0) {
// ???
passedSinceLastIteration = 0;
}
if (DEBUG_MODE) {
System.out.println("Elapsed since last iteration: "
+ passedSinceLastIteration + "ms");
}
// System.err.println("Periodic update on "
// + this.runningTimelines.size() + " timelines; "
// + passedSinceLastIteration + " ms passed since last");
// for (Timeline t : runningTimelines) {
// if (t.mainObject != null
// && t.mainObject.getClass().getName().indexOf(
// "ProgressBar") >= 0) {
// continue;
// }
// System.err.println("\tTimeline @"
// + t.hashCode()
// + " ["
// + t.getName()
// + "] on "
// + (t.mainObject == null ? "null" : t.mainObject
// .getClass().getName()));
// }
for (Iterator<Timeline> itTimeline = this.runningTimelines
.iterator(); itTimeline.hasNext();) {
Timeline timeline = itTimeline.next();
|
// Path: projects/main/src/main/java/libshapedraw/animation/trident/Timeline.java
// public enum TimelineState {
// IDLE(false), READY(false), PLAYING_FORWARD(true), PLAYING_REVERSE(true), SUSPENDED(
// false), CANCELLED(false), DONE(false);
//
// private boolean isActive;
//
// private TimelineState(boolean isActive) {
// this.isActive = isActive;
// }
// }
//
// Path: projects/main/src/main/java/libshapedraw/animation/trident/TimelineScenario.java
// public enum TimelineScenarioState {
// DONE, PLAYING, IDLE, SUSPENDED
// }
// Path: projects/main/src/main/java/libshapedraw/animation/trident/TimelineEngine.java
import java.util.*;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
import libshapedraw.animation.trident.Timeline.TimelineState;
import libshapedraw.animation.trident.TimelineScenario.TimelineScenarioState;
import libshapedraw.animation.trident.callback.RunOnUIThread;
long passedSinceLastIteration = (System.currentTimeMillis() - this.lastIterationTimeStamp);
if (passedSinceLastIteration < 0) {
// ???
passedSinceLastIteration = 0;
}
if (DEBUG_MODE) {
System.out.println("Elapsed since last iteration: "
+ passedSinceLastIteration + "ms");
}
// System.err.println("Periodic update on "
// + this.runningTimelines.size() + " timelines; "
// + passedSinceLastIteration + " ms passed since last");
// for (Timeline t : runningTimelines) {
// if (t.mainObject != null
// && t.mainObject.getClass().getName().indexOf(
// "ProgressBar") >= 0) {
// continue;
// }
// System.err.println("\tTimeline @"
// + t.hashCode()
// + " ["
// + t.getName()
// + "] on "
// + (t.mainObject == null ? "null" : t.mainObject
// .getClass().getName()));
// }
for (Iterator<Timeline> itTimeline = this.runningTimelines
.iterator(); itTimeline.hasNext();) {
Timeline timeline = itTimeline.next();
|
if (timeline.getState() == TimelineState.SUSPENDED)
|
bencvt/LibShapeDraw
|
projects/main/src/main/java/libshapedraw/animation/trident/TimelineEngine.java
|
// Path: projects/main/src/main/java/libshapedraw/animation/trident/Timeline.java
// public enum TimelineState {
// IDLE(false), READY(false), PLAYING_FORWARD(true), PLAYING_REVERSE(true), SUSPENDED(
// false), CANCELLED(false), DONE(false);
//
// private boolean isActive;
//
// private TimelineState(boolean isActive) {
// this.isActive = isActive;
// }
// }
//
// Path: projects/main/src/main/java/libshapedraw/animation/trident/TimelineScenario.java
// public enum TimelineScenarioState {
// DONE, PLAYING, IDLE, SUSPENDED
// }
|
import java.util.*;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
import libshapedraw.animation.trident.Timeline.TimelineState;
import libshapedraw.animation.trident.TimelineScenario.TimelineScenarioState;
import libshapedraw.animation.trident.callback.RunOnUIThread;
|
// + timeline.timelineKind.toString()
+ " in state " + timeline.getState().name()
+ " at position " + timeline.durationFraction);
}
TimelineState oldState = timeline.getState();
timeline.replaceState(TimelineState.DONE);
this.callbackCallTimelineStateChanged(timeline, oldState);
timeline.popState();
if (timeline.getState() != TimelineState.IDLE) {
throw new IllegalStateException(
"Timeline should be IDLE at this point");
}
this.callbackCallTimelineStateChanged(timeline,
TimelineState.DONE);
} else {
if (DEBUG_MODE) {
System.out.println("Calling " + timeline.id + " on "
// + timeline.timelineKind.toString() + " at "
+ timeline.durationFraction);
}
this.callbackCallTimelinePulse(timeline);
}
}
if (this.runningScenarios.size() > 0) {
// System.err.println(Thread.currentThread().getName()
// + " : updating");
for (Iterator<TimelineScenario> it = this.runningScenarios
.iterator(); it.hasNext();) {
TimelineScenario scenario = it.next();
|
// Path: projects/main/src/main/java/libshapedraw/animation/trident/Timeline.java
// public enum TimelineState {
// IDLE(false), READY(false), PLAYING_FORWARD(true), PLAYING_REVERSE(true), SUSPENDED(
// false), CANCELLED(false), DONE(false);
//
// private boolean isActive;
//
// private TimelineState(boolean isActive) {
// this.isActive = isActive;
// }
// }
//
// Path: projects/main/src/main/java/libshapedraw/animation/trident/TimelineScenario.java
// public enum TimelineScenarioState {
// DONE, PLAYING, IDLE, SUSPENDED
// }
// Path: projects/main/src/main/java/libshapedraw/animation/trident/TimelineEngine.java
import java.util.*;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
import libshapedraw.animation.trident.Timeline.TimelineState;
import libshapedraw.animation.trident.TimelineScenario.TimelineScenarioState;
import libshapedraw.animation.trident.callback.RunOnUIThread;
// + timeline.timelineKind.toString()
+ " in state " + timeline.getState().name()
+ " at position " + timeline.durationFraction);
}
TimelineState oldState = timeline.getState();
timeline.replaceState(TimelineState.DONE);
this.callbackCallTimelineStateChanged(timeline, oldState);
timeline.popState();
if (timeline.getState() != TimelineState.IDLE) {
throw new IllegalStateException(
"Timeline should be IDLE at this point");
}
this.callbackCallTimelineStateChanged(timeline,
TimelineState.DONE);
} else {
if (DEBUG_MODE) {
System.out.println("Calling " + timeline.id + " on "
// + timeline.timelineKind.toString() + " at "
+ timeline.durationFraction);
}
this.callbackCallTimelinePulse(timeline);
}
}
if (this.runningScenarios.size() > 0) {
// System.err.println(Thread.currentThread().getName()
// + " : updating");
for (Iterator<TimelineScenario> it = this.runningScenarios
.iterator(); it.hasNext();) {
TimelineScenario scenario = it.next();
|
if (scenario.state == TimelineScenarioState.DONE) {
|
bencvt/LibShapeDraw
|
projects/main/src/test/java/libshapedraw/TestApiInfo.java
|
// Path: projects/main/src/main/java/libshapedraw/internal/LSDModDirectory.java
// public class LSDModDirectory {
// public static final File DIRECTORY = new File(getMinecraftDir(), "mods" + File.separator + ApiInfo.getName());
//
// /**
// * Use reflection to invoke the static method. This supports both normal
// * play (reobfuscated minecraft.jar) and development (deobfuscated classes
// * in MCP).
// */
// private static File getMinecraftDir() {
// try {
// Method m;
// try {
// m = Minecraft.class.getMethod("b");
// } catch (NoSuchMethodException e) {
// m = Minecraft.class.getMethod("getMinecraftDir");
// }
// return (File) m.invoke(null);
// } catch (Exception e) {
// throw new LSDInternalReflectionException("unable to invoke Minecraft.getMinecraftDir", e);
// }
// }
// }
|
import org.junit.Test;
import static org.junit.Assert.*;
import java.net.URL;
import libshapedraw.internal.LSDModDirectory;
|
package libshapedraw;
public class TestApiInfo extends SetupTestEnvironment.TestCase {
@SuppressWarnings("deprecation")
@Test
public void testStaticMethods() {
assertEquals("LibShapeDraw", ApiInfo.getName());
assertFalse(ApiInfo.getVersion().isEmpty());
assertValidHttpUrl(ApiInfo.getUrlMain());
assertValidHttpUrl(ApiInfo.getUrlShort());
assertValidHttpUrl(ApiInfo.getUrlSource());
assertValidHttpUrl(ApiInfo.getUrlUpdate());
assertEquals(ApiInfo.getUrlMain().toString(), ApiInfo.getUrl());
assertFalse(ApiInfo.getAuthors().isEmpty());
|
// Path: projects/main/src/main/java/libshapedraw/internal/LSDModDirectory.java
// public class LSDModDirectory {
// public static final File DIRECTORY = new File(getMinecraftDir(), "mods" + File.separator + ApiInfo.getName());
//
// /**
// * Use reflection to invoke the static method. This supports both normal
// * play (reobfuscated minecraft.jar) and development (deobfuscated classes
// * in MCP).
// */
// private static File getMinecraftDir() {
// try {
// Method m;
// try {
// m = Minecraft.class.getMethod("b");
// } catch (NoSuchMethodException e) {
// m = Minecraft.class.getMethod("getMinecraftDir");
// }
// return (File) m.invoke(null);
// } catch (Exception e) {
// throw new LSDInternalReflectionException("unable to invoke Minecraft.getMinecraftDir", e);
// }
// }
// }
// Path: projects/main/src/test/java/libshapedraw/TestApiInfo.java
import org.junit.Test;
import static org.junit.Assert.*;
import java.net.URL;
import libshapedraw.internal.LSDModDirectory;
package libshapedraw;
public class TestApiInfo extends SetupTestEnvironment.TestCase {
@SuppressWarnings("deprecation")
@Test
public void testStaticMethods() {
assertEquals("LibShapeDraw", ApiInfo.getName());
assertFalse(ApiInfo.getVersion().isEmpty());
assertValidHttpUrl(ApiInfo.getUrlMain());
assertValidHttpUrl(ApiInfo.getUrlShort());
assertValidHttpUrl(ApiInfo.getUrlSource());
assertValidHttpUrl(ApiInfo.getUrlUpdate());
assertEquals(ApiInfo.getUrlMain().toString(), ApiInfo.getUrl());
assertFalse(ApiInfo.getAuthors().isEmpty());
|
assertEquals(ApiInfo.getModDirectory(), LSDModDirectory.DIRECTORY);
|
DarkPhoenixs/connection-pool-client
|
src/test/java/org/darkphoenixs/pool/http/HttpTest.java
|
// Path: src/main/java/org/darkphoenixs/pool/PoolConfig.java
// public class PoolConfig extends GenericObjectPoolConfig implements Serializable {
//
// /**
// * DEFAULT_TEST_WHILE_IDLE
// */
// public static final boolean DEFAULT_TEST_WHILE_IDLE = true;
// /**
// * DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS
// */
// public static final long DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS = 60000;
// /**
// * DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS
// */
// public static final long DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS = 30000;
// /**
// * DEFAULT_NUM_TESTS_PER_EVICTION_RUN
// */
// public static final int DEFAULT_NUM_TESTS_PER_EVICTION_RUN = -1;
// /**
// * serialVersionUID
// */
// private static final long serialVersionUID = -2414567557372345057L;
//
// /**
// * <p>Title: PoolConfig</p>
// * <p>Description: 默认构造方法</p>
// */
// public PoolConfig() {
//
// // defaults to make your life with connection pool easier :)
// setTestWhileIdle(DEFAULT_TEST_WHILE_IDLE);
// setMinEvictableIdleTimeMillis(DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS);
// setTimeBetweenEvictionRunsMillis(DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS);
// setNumTestsPerEvictionRun(DEFAULT_NUM_TESTS_PER_EVICTION_RUN);
// }
// }
|
import org.darkphoenixs.pool.PoolConfig;
import org.junit.Test;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
|
package org.darkphoenixs.pool.http;
public class HttpTest {
@Test
public void test() throws Exception {
|
// Path: src/main/java/org/darkphoenixs/pool/PoolConfig.java
// public class PoolConfig extends GenericObjectPoolConfig implements Serializable {
//
// /**
// * DEFAULT_TEST_WHILE_IDLE
// */
// public static final boolean DEFAULT_TEST_WHILE_IDLE = true;
// /**
// * DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS
// */
// public static final long DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS = 60000;
// /**
// * DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS
// */
// public static final long DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS = 30000;
// /**
// * DEFAULT_NUM_TESTS_PER_EVICTION_RUN
// */
// public static final int DEFAULT_NUM_TESTS_PER_EVICTION_RUN = -1;
// /**
// * serialVersionUID
// */
// private static final long serialVersionUID = -2414567557372345057L;
//
// /**
// * <p>Title: PoolConfig</p>
// * <p>Description: 默认构造方法</p>
// */
// public PoolConfig() {
//
// // defaults to make your life with connection pool easier :)
// setTestWhileIdle(DEFAULT_TEST_WHILE_IDLE);
// setMinEvictableIdleTimeMillis(DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS);
// setTimeBetweenEvictionRunsMillis(DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS);
// setNumTestsPerEvictionRun(DEFAULT_NUM_TESTS_PER_EVICTION_RUN);
// }
// }
// Path: src/test/java/org/darkphoenixs/pool/http/HttpTest.java
import org.darkphoenixs.pool.PoolConfig;
import org.junit.Test;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
package org.darkphoenixs.pool.http;
public class HttpTest {
@Test
public void test() throws Exception {
|
PoolConfig config = new PoolConfig();
|
DarkPhoenixs/connection-pool-client
|
src/main/java/org/darkphoenixs/pool/http/HttpConnectionFactory.java
|
// Path: src/main/java/org/darkphoenixs/pool/ConnectionException.java
// public class ConnectionException extends RuntimeException {
//
// private static final long serialVersionUID = -6503525110247209484L;
//
// public ConnectionException() {
// super();
// }
//
// public ConnectionException(String message) {
// super(message);
// }
//
// public ConnectionException(Throwable e) {
// super(e);
// }
//
// public ConnectionException(String message, Throwable cause) {
// super(message, cause);
// }
// }
//
// Path: src/main/java/org/darkphoenixs/pool/ConnectionFactory.java
// public interface ConnectionFactory<T> extends PooledObjectFactory<T>, Serializable {
//
// /**
// * <p>Title: createConnection</p>
// * <p>Description: 创建连接</p>
// *
// * @return 连接
// * @throws Exception
// */
// public abstract T createConnection() throws Exception;
// }
|
import org.apache.commons.pool2.PooledObject;
import org.apache.commons.pool2.impl.DefaultPooledObject;
import org.darkphoenixs.pool.ConnectionException;
import org.darkphoenixs.pool.ConnectionFactory;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.InetSocketAddress;
import java.net.Proxy;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
|
/*
* Copyright 2015-2016 Dark Phoenixs (Open-Source Organization).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.darkphoenixs.pool.http;
/**
* <p>HttpConnectionFactory</p>
* <p>Http连接工厂</p>
*
* @author Victor
* @see ConnectionFactory
* @since 1.2.7
*/
public class HttpConnectionFactory implements ConnectionFactory<HttpURLConnection> {
private static final long serialVersionUID = 7077039510216492412L;
private final Proxy proxy;
private final String address;
private final String method;
private final int connectTimeout;
private final int readTimeout;
private final Map<String, String> header;
/**
* Instantiates a new Http connection factory.
*
* @param proxy the proxy
* @param address the address
* @param method the method
* @param connectTimeout the connect timeout
* @param readTimeout the read timeout
* @param header the header
*/
public HttpConnectionFactory(final Proxy proxy, final String address,
final String method, final int connectTimeout,
final int readTimeout, final Map<String, String> header) {
this.proxy = proxy;
this.address = address;
this.method = method;
this.connectTimeout = connectTimeout;
this.readTimeout = readTimeout;
this.header = header;
}
/**
* Instantiates a new Http connection factory.
*
* @param properties the properties
*/
public HttpConnectionFactory(final Properties properties) {
String proxyHost = properties.getProperty(HttpConfig.PROXY_HOST_PROPERTY);
String proxyPort = properties.getProperty(HttpConfig.PROXY_PORT_PROPERTY);
if (proxyHost != null && proxyPort != null)
proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(proxyHost, Integer.valueOf(proxyPort)));
else
proxy = null;
address = properties.getProperty(HttpConfig.HTTP_URL_PROPERTY);
if (address == null)
|
// Path: src/main/java/org/darkphoenixs/pool/ConnectionException.java
// public class ConnectionException extends RuntimeException {
//
// private static final long serialVersionUID = -6503525110247209484L;
//
// public ConnectionException() {
// super();
// }
//
// public ConnectionException(String message) {
// super(message);
// }
//
// public ConnectionException(Throwable e) {
// super(e);
// }
//
// public ConnectionException(String message, Throwable cause) {
// super(message, cause);
// }
// }
//
// Path: src/main/java/org/darkphoenixs/pool/ConnectionFactory.java
// public interface ConnectionFactory<T> extends PooledObjectFactory<T>, Serializable {
//
// /**
// * <p>Title: createConnection</p>
// * <p>Description: 创建连接</p>
// *
// * @return 连接
// * @throws Exception
// */
// public abstract T createConnection() throws Exception;
// }
// Path: src/main/java/org/darkphoenixs/pool/http/HttpConnectionFactory.java
import org.apache.commons.pool2.PooledObject;
import org.apache.commons.pool2.impl.DefaultPooledObject;
import org.darkphoenixs.pool.ConnectionException;
import org.darkphoenixs.pool.ConnectionFactory;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.InetSocketAddress;
import java.net.Proxy;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
/*
* Copyright 2015-2016 Dark Phoenixs (Open-Source Organization).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.darkphoenixs.pool.http;
/**
* <p>HttpConnectionFactory</p>
* <p>Http连接工厂</p>
*
* @author Victor
* @see ConnectionFactory
* @since 1.2.7
*/
public class HttpConnectionFactory implements ConnectionFactory<HttpURLConnection> {
private static final long serialVersionUID = 7077039510216492412L;
private final Proxy proxy;
private final String address;
private final String method;
private final int connectTimeout;
private final int readTimeout;
private final Map<String, String> header;
/**
* Instantiates a new Http connection factory.
*
* @param proxy the proxy
* @param address the address
* @param method the method
* @param connectTimeout the connect timeout
* @param readTimeout the read timeout
* @param header the header
*/
public HttpConnectionFactory(final Proxy proxy, final String address,
final String method, final int connectTimeout,
final int readTimeout, final Map<String, String> header) {
this.proxy = proxy;
this.address = address;
this.method = method;
this.connectTimeout = connectTimeout;
this.readTimeout = readTimeout;
this.header = header;
}
/**
* Instantiates a new Http connection factory.
*
* @param properties the properties
*/
public HttpConnectionFactory(final Properties properties) {
String proxyHost = properties.getProperty(HttpConfig.PROXY_HOST_PROPERTY);
String proxyPort = properties.getProperty(HttpConfig.PROXY_PORT_PROPERTY);
if (proxyHost != null && proxyPort != null)
proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(proxyHost, Integer.valueOf(proxyPort)));
else
proxy = null;
address = properties.getProperty(HttpConfig.HTTP_URL_PROPERTY);
if (address == null)
|
throw new ConnectionException("[" + HttpConfig.HTTP_URL_PROPERTY + "] is required !");
|
DarkPhoenixs/connection-pool-client
|
src/main/java/org/darkphoenixs/pool/socket/SocketConnectionFactory.java
|
// Path: src/main/java/org/darkphoenixs/pool/ConnectionException.java
// public class ConnectionException extends RuntimeException {
//
// private static final long serialVersionUID = -6503525110247209484L;
//
// public ConnectionException() {
// super();
// }
//
// public ConnectionException(String message) {
// super(message);
// }
//
// public ConnectionException(Throwable e) {
// super(e);
// }
//
// public ConnectionException(String message, Throwable cause) {
// super(message, cause);
// }
// }
//
// Path: src/main/java/org/darkphoenixs/pool/ConnectionFactory.java
// public interface ConnectionFactory<T> extends PooledObjectFactory<T>, Serializable {
//
// /**
// * <p>Title: createConnection</p>
// * <p>Description: 创建连接</p>
// *
// * @return 连接
// * @throws Exception
// */
// public abstract T createConnection() throws Exception;
// }
|
import org.apache.commons.pool2.PooledObject;
import org.apache.commons.pool2.impl.DefaultPooledObject;
import org.darkphoenixs.pool.ConnectionException;
import org.darkphoenixs.pool.ConnectionFactory;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.util.Properties;
|
/*
* Copyright 2015-2016 Dark Phoenixs (Open-Source Organization).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.darkphoenixs.pool.socket;
/**
* <p>SocketConnectionFactory</p>
* <p>Socket连接工厂</p>
*
* @author Victor.Zxy
* @see ConnectionFactory
* @since 1.2.1
*/
class SocketConnectionFactory implements ConnectionFactory<Socket> {
/**
* serialVersionUID
*/
private static final long serialVersionUID = -727722488965747494L;
/**
* address
*/
private final InetSocketAddress socketAddress;
/**
* receiveBufferSize
*/
private final int receiveBufferSize;
/**
* sendBufferSize
*/
private final int sendBufferSize;
/**
* connectionTimeout
*/
private final int connectionTimeout;
/**
* soTimeout
*/
private final int soTimeout;
/**
* keepAlive
*/
private final boolean keepAlive;
/**
* tcpNoDelay
*/
private final boolean tcpNoDelay;
/**
* performance
*/
private final String[] performance;
/**
* linger
*/
private int linger;
/**
* @param properties 连接属性
*/
public SocketConnectionFactory(final Properties properties) {
String address = properties.getProperty(SocketConfig.ADDRESS_PROPERTY);
if (address == null)
|
// Path: src/main/java/org/darkphoenixs/pool/ConnectionException.java
// public class ConnectionException extends RuntimeException {
//
// private static final long serialVersionUID = -6503525110247209484L;
//
// public ConnectionException() {
// super();
// }
//
// public ConnectionException(String message) {
// super(message);
// }
//
// public ConnectionException(Throwable e) {
// super(e);
// }
//
// public ConnectionException(String message, Throwable cause) {
// super(message, cause);
// }
// }
//
// Path: src/main/java/org/darkphoenixs/pool/ConnectionFactory.java
// public interface ConnectionFactory<T> extends PooledObjectFactory<T>, Serializable {
//
// /**
// * <p>Title: createConnection</p>
// * <p>Description: 创建连接</p>
// *
// * @return 连接
// * @throws Exception
// */
// public abstract T createConnection() throws Exception;
// }
// Path: src/main/java/org/darkphoenixs/pool/socket/SocketConnectionFactory.java
import org.apache.commons.pool2.PooledObject;
import org.apache.commons.pool2.impl.DefaultPooledObject;
import org.darkphoenixs.pool.ConnectionException;
import org.darkphoenixs.pool.ConnectionFactory;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.util.Properties;
/*
* Copyright 2015-2016 Dark Phoenixs (Open-Source Organization).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.darkphoenixs.pool.socket;
/**
* <p>SocketConnectionFactory</p>
* <p>Socket连接工厂</p>
*
* @author Victor.Zxy
* @see ConnectionFactory
* @since 1.2.1
*/
class SocketConnectionFactory implements ConnectionFactory<Socket> {
/**
* serialVersionUID
*/
private static final long serialVersionUID = -727722488965747494L;
/**
* address
*/
private final InetSocketAddress socketAddress;
/**
* receiveBufferSize
*/
private final int receiveBufferSize;
/**
* sendBufferSize
*/
private final int sendBufferSize;
/**
* connectionTimeout
*/
private final int connectionTimeout;
/**
* soTimeout
*/
private final int soTimeout;
/**
* keepAlive
*/
private final boolean keepAlive;
/**
* tcpNoDelay
*/
private final boolean tcpNoDelay;
/**
* performance
*/
private final String[] performance;
/**
* linger
*/
private int linger;
/**
* @param properties 连接属性
*/
public SocketConnectionFactory(final Properties properties) {
String address = properties.getProperty(SocketConfig.ADDRESS_PROPERTY);
if (address == null)
|
throw new ConnectionException("[" + SocketConfig.ADDRESS_PROPERTY + "] is required !");
|
DarkPhoenixs/connection-pool-client
|
src/main/java/org/darkphoenixs/pool/kafka/KafkaConnectionFactory.java
|
// Path: src/main/java/org/darkphoenixs/pool/ConnectionException.java
// public class ConnectionException extends RuntimeException {
//
// private static final long serialVersionUID = -6503525110247209484L;
//
// public ConnectionException() {
// super();
// }
//
// public ConnectionException(String message) {
// super(message);
// }
//
// public ConnectionException(Throwable e) {
// super(e);
// }
//
// public ConnectionException(String message, Throwable cause) {
// super(message, cause);
// }
// }
//
// Path: src/main/java/org/darkphoenixs/pool/ConnectionFactory.java
// public interface ConnectionFactory<T> extends PooledObjectFactory<T>, Serializable {
//
// /**
// * <p>Title: createConnection</p>
// * <p>Description: 创建连接</p>
// *
// * @return 连接
// * @throws Exception
// */
// public abstract T createConnection() throws Exception;
// }
|
import kafka.javaapi.producer.Producer;
import kafka.producer.ProducerConfig;
import org.apache.commons.pool2.PooledObject;
import org.apache.commons.pool2.impl.DefaultPooledObject;
import org.darkphoenixs.pool.ConnectionException;
import org.darkphoenixs.pool.ConnectionFactory;
import java.util.Properties;
|
/*
* Copyright 2015-2016 Dark Phoenixs (Open-Source Organization).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.darkphoenixs.pool.kafka;
/**
* <p>Title: KafkaConnectionFactory</p>
* <p>Description: Kafka连接工厂</p>
*
* @author Victor
* @version 1.0
* @see ConnectionFactory
* @since 2015年9月19日
*/
class KafkaConnectionFactory implements ConnectionFactory<Producer<byte[], byte[]>> {
/**
* serialVersionUID
*/
private static final long serialVersionUID = 8271607366818512399L;
/**
* config
*/
private final ProducerConfig config;
/**
* <p>Title: KafkaConnectionFactory</p>
* <p>Description: 构造方法</p>
*
* @param config 生产者配置
*/
public KafkaConnectionFactory(final ProducerConfig config) {
this.config = config;
}
/**
* <p>Title: KafkaConnectionFactory</p>
* <p>Description: 构造方法</p>
*
* @param brokers broker列表
* @param type 生产者类型
* @param acks 确认类型
* @param codec 压缩类型
* @param batch 批量大小
*/
public KafkaConnectionFactory(final String brokers, final String type, final String acks, final String codec, final String batch) {
Properties props = new Properties();
props.setProperty(KafkaConfig.BROKERS_LIST_PROPERTY, brokers);
props.setProperty(KafkaConfig.PRODUCER_TYPE_PROPERTY, type);
props.setProperty(KafkaConfig.REQUEST_ACKS_PROPERTY, acks);
props.setProperty(KafkaConfig.COMPRESSION_CODEC_PROPERTY, codec);
props.setProperty(KafkaConfig.BATCH_NUMBER_PROPERTY, batch);
this.config = new ProducerConfig(props);
}
/**
* @param properties 参数配置
* @since 1.2.1
*/
public KafkaConnectionFactory(final Properties properties) {
String brokers = properties.getProperty(KafkaConfig.BROKERS_LIST_PROPERTY);
if (brokers == null)
|
// Path: src/main/java/org/darkphoenixs/pool/ConnectionException.java
// public class ConnectionException extends RuntimeException {
//
// private static final long serialVersionUID = -6503525110247209484L;
//
// public ConnectionException() {
// super();
// }
//
// public ConnectionException(String message) {
// super(message);
// }
//
// public ConnectionException(Throwable e) {
// super(e);
// }
//
// public ConnectionException(String message, Throwable cause) {
// super(message, cause);
// }
// }
//
// Path: src/main/java/org/darkphoenixs/pool/ConnectionFactory.java
// public interface ConnectionFactory<T> extends PooledObjectFactory<T>, Serializable {
//
// /**
// * <p>Title: createConnection</p>
// * <p>Description: 创建连接</p>
// *
// * @return 连接
// * @throws Exception
// */
// public abstract T createConnection() throws Exception;
// }
// Path: src/main/java/org/darkphoenixs/pool/kafka/KafkaConnectionFactory.java
import kafka.javaapi.producer.Producer;
import kafka.producer.ProducerConfig;
import org.apache.commons.pool2.PooledObject;
import org.apache.commons.pool2.impl.DefaultPooledObject;
import org.darkphoenixs.pool.ConnectionException;
import org.darkphoenixs.pool.ConnectionFactory;
import java.util.Properties;
/*
* Copyright 2015-2016 Dark Phoenixs (Open-Source Organization).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.darkphoenixs.pool.kafka;
/**
* <p>Title: KafkaConnectionFactory</p>
* <p>Description: Kafka连接工厂</p>
*
* @author Victor
* @version 1.0
* @see ConnectionFactory
* @since 2015年9月19日
*/
class KafkaConnectionFactory implements ConnectionFactory<Producer<byte[], byte[]>> {
/**
* serialVersionUID
*/
private static final long serialVersionUID = 8271607366818512399L;
/**
* config
*/
private final ProducerConfig config;
/**
* <p>Title: KafkaConnectionFactory</p>
* <p>Description: 构造方法</p>
*
* @param config 生产者配置
*/
public KafkaConnectionFactory(final ProducerConfig config) {
this.config = config;
}
/**
* <p>Title: KafkaConnectionFactory</p>
* <p>Description: 构造方法</p>
*
* @param brokers broker列表
* @param type 生产者类型
* @param acks 确认类型
* @param codec 压缩类型
* @param batch 批量大小
*/
public KafkaConnectionFactory(final String brokers, final String type, final String acks, final String codec, final String batch) {
Properties props = new Properties();
props.setProperty(KafkaConfig.BROKERS_LIST_PROPERTY, brokers);
props.setProperty(KafkaConfig.PRODUCER_TYPE_PROPERTY, type);
props.setProperty(KafkaConfig.REQUEST_ACKS_PROPERTY, acks);
props.setProperty(KafkaConfig.COMPRESSION_CODEC_PROPERTY, codec);
props.setProperty(KafkaConfig.BATCH_NUMBER_PROPERTY, batch);
this.config = new ProducerConfig(props);
}
/**
* @param properties 参数配置
* @since 1.2.1
*/
public KafkaConnectionFactory(final Properties properties) {
String brokers = properties.getProperty(KafkaConfig.BROKERS_LIST_PROPERTY);
if (brokers == null)
|
throw new ConnectionException("[" + KafkaConfig.BROKERS_LIST_PROPERTY + "] is required !");
|
DarkPhoenixs/connection-pool-client
|
src/test/java/org/darkphoenixs/pool/jdbc/JdbcConnectionPoolTest.java
|
// Path: src/main/java/org/darkphoenixs/pool/PoolConfig.java
// public class PoolConfig extends GenericObjectPoolConfig implements Serializable {
//
// /**
// * DEFAULT_TEST_WHILE_IDLE
// */
// public static final boolean DEFAULT_TEST_WHILE_IDLE = true;
// /**
// * DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS
// */
// public static final long DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS = 60000;
// /**
// * DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS
// */
// public static final long DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS = 30000;
// /**
// * DEFAULT_NUM_TESTS_PER_EVICTION_RUN
// */
// public static final int DEFAULT_NUM_TESTS_PER_EVICTION_RUN = -1;
// /**
// * serialVersionUID
// */
// private static final long serialVersionUID = -2414567557372345057L;
//
// /**
// * <p>Title: PoolConfig</p>
// * <p>Description: 默认构造方法</p>
// */
// public PoolConfig() {
//
// // defaults to make your life with connection pool easier :)
// setTestWhileIdle(DEFAULT_TEST_WHILE_IDLE);
// setMinEvictableIdleTimeMillis(DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS);
// setTimeBetweenEvictionRunsMillis(DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS);
// setNumTestsPerEvictionRun(DEFAULT_NUM_TESTS_PER_EVICTION_RUN);
// }
// }
|
import org.apache.commons.pool2.BasePooledObjectFactory;
import org.apache.commons.pool2.PooledObject;
import org.darkphoenixs.pool.PoolConfig;
import org.junit.Test;
import java.sql.Connection;
import java.util.Properties;
|
/*
* Copyright 2015-2016 Dark Phoenixs (Open-Source Organization).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.darkphoenixs.pool.jdbc;
public class JdbcConnectionPoolTest {
@Test
public void test() throws Exception {
try {
JdbcConnectionPool pool = new JdbcConnectionPool(
JdbcConfig.DEFAULT_DRIVER_CLASS,
JdbcConfig.DEFAULT_JDBC_URL,
JdbcConfig.DEFAULT_JDBC_USERNAME,
JdbcConfig.DEFAULT_JDBC_PASSWORD);
pool.close();
} catch (Exception e) {
}
try {
|
// Path: src/main/java/org/darkphoenixs/pool/PoolConfig.java
// public class PoolConfig extends GenericObjectPoolConfig implements Serializable {
//
// /**
// * DEFAULT_TEST_WHILE_IDLE
// */
// public static final boolean DEFAULT_TEST_WHILE_IDLE = true;
// /**
// * DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS
// */
// public static final long DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS = 60000;
// /**
// * DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS
// */
// public static final long DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS = 30000;
// /**
// * DEFAULT_NUM_TESTS_PER_EVICTION_RUN
// */
// public static final int DEFAULT_NUM_TESTS_PER_EVICTION_RUN = -1;
// /**
// * serialVersionUID
// */
// private static final long serialVersionUID = -2414567557372345057L;
//
// /**
// * <p>Title: PoolConfig</p>
// * <p>Description: 默认构造方法</p>
// */
// public PoolConfig() {
//
// // defaults to make your life with connection pool easier :)
// setTestWhileIdle(DEFAULT_TEST_WHILE_IDLE);
// setMinEvictableIdleTimeMillis(DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS);
// setTimeBetweenEvictionRunsMillis(DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS);
// setNumTestsPerEvictionRun(DEFAULT_NUM_TESTS_PER_EVICTION_RUN);
// }
// }
// Path: src/test/java/org/darkphoenixs/pool/jdbc/JdbcConnectionPoolTest.java
import org.apache.commons.pool2.BasePooledObjectFactory;
import org.apache.commons.pool2.PooledObject;
import org.darkphoenixs.pool.PoolConfig;
import org.junit.Test;
import java.sql.Connection;
import java.util.Properties;
/*
* Copyright 2015-2016 Dark Phoenixs (Open-Source Organization).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.darkphoenixs.pool.jdbc;
public class JdbcConnectionPoolTest {
@Test
public void test() throws Exception {
try {
JdbcConnectionPool pool = new JdbcConnectionPool(
JdbcConfig.DEFAULT_DRIVER_CLASS,
JdbcConfig.DEFAULT_JDBC_URL,
JdbcConfig.DEFAULT_JDBC_USERNAME,
JdbcConfig.DEFAULT_JDBC_PASSWORD);
pool.close();
} catch (Exception e) {
}
try {
|
JdbcConnectionPool pool = new JdbcConnectionPool(new PoolConfig(),
|
DarkPhoenixs/connection-pool-client
|
src/main/java/org/darkphoenixs/pool/redis/RedisSentinelConnPool.java
|
// Path: src/main/java/org/darkphoenixs/pool/ConnectionPool.java
// public interface ConnectionPool<T> extends Serializable {
//
// /**
// * <p>Title: getConnection</p>
// * <p>Description: 获取连接</p>
// *
// * @return 连接
// */
// public abstract T getConnection();
//
// /**
// * <p>Title: returnConnection</p>
// * <p>Description: 返回连接</p>
// *
// * @param conn 连接
// */
// public void returnConnection(T conn);
//
// /**
// * <p>Title: invalidateConnection</p>
// * <p>Description: 废弃连接</p>
// *
// * @param conn 连接
// */
// public void invalidateConnection(T conn);
// }
//
// Path: src/main/java/org/darkphoenixs/pool/PoolConfig.java
// public class PoolConfig extends GenericObjectPoolConfig implements Serializable {
//
// /**
// * DEFAULT_TEST_WHILE_IDLE
// */
// public static final boolean DEFAULT_TEST_WHILE_IDLE = true;
// /**
// * DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS
// */
// public static final long DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS = 60000;
// /**
// * DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS
// */
// public static final long DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS = 30000;
// /**
// * DEFAULT_NUM_TESTS_PER_EVICTION_RUN
// */
// public static final int DEFAULT_NUM_TESTS_PER_EVICTION_RUN = -1;
// /**
// * serialVersionUID
// */
// private static final long serialVersionUID = -2414567557372345057L;
//
// /**
// * <p>Title: PoolConfig</p>
// * <p>Description: 默认构造方法</p>
// */
// public PoolConfig() {
//
// // defaults to make your life with connection pool easier :)
// setTestWhileIdle(DEFAULT_TEST_WHILE_IDLE);
// setMinEvictableIdleTimeMillis(DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS);
// setTimeBetweenEvictionRunsMillis(DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS);
// setNumTestsPerEvictionRun(DEFAULT_NUM_TESTS_PER_EVICTION_RUN);
// }
// }
|
import org.darkphoenixs.pool.ConnectionPool;
import org.darkphoenixs.pool.PoolConfig;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisSentinelPool;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Properties;
import java.util.Set;
|
package org.darkphoenixs.pool.redis;
/**
* <p>Title: RedisSentinelConnPool</p>
* <p>Description: Redis哨兵连接池</p>
*
* @author Victor.Zxy
* @version 1.2.3
* @see ConnectionPool
* @since 2016 /8/25
*/
public class RedisSentinelConnPool implements ConnectionPool<Jedis> {
private final JedisSentinelPool pool;
/**
* Instantiates a new Redis sentinel conn pool(For test).
*
* @param pool the pool
*/
protected RedisSentinelConnPool(final JedisSentinelPool pool) {
this.pool = pool;
}
/**
* Instantiates a new Redis sentinel conn pool.
*
* @param masterName the master name
* @param sentinels the sentinels
*/
public RedisSentinelConnPool(final String masterName, final Set<String> sentinels) {
|
// Path: src/main/java/org/darkphoenixs/pool/ConnectionPool.java
// public interface ConnectionPool<T> extends Serializable {
//
// /**
// * <p>Title: getConnection</p>
// * <p>Description: 获取连接</p>
// *
// * @return 连接
// */
// public abstract T getConnection();
//
// /**
// * <p>Title: returnConnection</p>
// * <p>Description: 返回连接</p>
// *
// * @param conn 连接
// */
// public void returnConnection(T conn);
//
// /**
// * <p>Title: invalidateConnection</p>
// * <p>Description: 废弃连接</p>
// *
// * @param conn 连接
// */
// public void invalidateConnection(T conn);
// }
//
// Path: src/main/java/org/darkphoenixs/pool/PoolConfig.java
// public class PoolConfig extends GenericObjectPoolConfig implements Serializable {
//
// /**
// * DEFAULT_TEST_WHILE_IDLE
// */
// public static final boolean DEFAULT_TEST_WHILE_IDLE = true;
// /**
// * DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS
// */
// public static final long DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS = 60000;
// /**
// * DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS
// */
// public static final long DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS = 30000;
// /**
// * DEFAULT_NUM_TESTS_PER_EVICTION_RUN
// */
// public static final int DEFAULT_NUM_TESTS_PER_EVICTION_RUN = -1;
// /**
// * serialVersionUID
// */
// private static final long serialVersionUID = -2414567557372345057L;
//
// /**
// * <p>Title: PoolConfig</p>
// * <p>Description: 默认构造方法</p>
// */
// public PoolConfig() {
//
// // defaults to make your life with connection pool easier :)
// setTestWhileIdle(DEFAULT_TEST_WHILE_IDLE);
// setMinEvictableIdleTimeMillis(DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS);
// setTimeBetweenEvictionRunsMillis(DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS);
// setNumTestsPerEvictionRun(DEFAULT_NUM_TESTS_PER_EVICTION_RUN);
// }
// }
// Path: src/main/java/org/darkphoenixs/pool/redis/RedisSentinelConnPool.java
import org.darkphoenixs.pool.ConnectionPool;
import org.darkphoenixs.pool.PoolConfig;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisSentinelPool;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Properties;
import java.util.Set;
package org.darkphoenixs.pool.redis;
/**
* <p>Title: RedisSentinelConnPool</p>
* <p>Description: Redis哨兵连接池</p>
*
* @author Victor.Zxy
* @version 1.2.3
* @see ConnectionPool
* @since 2016 /8/25
*/
public class RedisSentinelConnPool implements ConnectionPool<Jedis> {
private final JedisSentinelPool pool;
/**
* Instantiates a new Redis sentinel conn pool(For test).
*
* @param pool the pool
*/
protected RedisSentinelConnPool(final JedisSentinelPool pool) {
this.pool = pool;
}
/**
* Instantiates a new Redis sentinel conn pool.
*
* @param masterName the master name
* @param sentinels the sentinels
*/
public RedisSentinelConnPool(final String masterName, final Set<String> sentinels) {
|
this(new PoolConfig(), masterName, sentinels);
|
DarkPhoenixs/connection-pool-client
|
src/main/java/org/darkphoenixs/pool/hbase/HbaseSharedConnPool.java
|
// Path: src/main/java/org/darkphoenixs/pool/ConnectionException.java
// public class ConnectionException extends RuntimeException {
//
// private static final long serialVersionUID = -6503525110247209484L;
//
// public ConnectionException() {
// super();
// }
//
// public ConnectionException(String message) {
// super(message);
// }
//
// public ConnectionException(Throwable e) {
// super(e);
// }
//
// public ConnectionException(String message, Throwable cause) {
// super(message, cause);
// }
// }
//
// Path: src/main/java/org/darkphoenixs/pool/ConnectionPool.java
// public interface ConnectionPool<T> extends Serializable {
//
// /**
// * <p>Title: getConnection</p>
// * <p>Description: 获取连接</p>
// *
// * @return 连接
// */
// public abstract T getConnection();
//
// /**
// * <p>Title: returnConnection</p>
// * <p>Description: 返回连接</p>
// *
// * @param conn 连接
// */
// public void returnConnection(T conn);
//
// /**
// * <p>Title: invalidateConnection</p>
// * <p>Description: 废弃连接</p>
// *
// * @param conn 连接
// */
// public void invalidateConnection(T conn);
// }
|
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.client.Connection;
import org.apache.hadoop.hbase.client.ConnectionFactory;
import org.darkphoenixs.pool.ConnectionException;
import org.darkphoenixs.pool.ConnectionPool;
import java.io.IOException;
import java.util.Map;
import java.util.Properties;
import java.util.concurrent.atomic.AtomicReference;
|
package org.darkphoenixs.pool.hbase;
/**
* <p>Title: HbaseSharedConnPool</p>
* <p>Description: Hbase共享连接池(单例)</p>
*
* @author Victor.Zxy
* @version 1.2.3
* @see ConnectionPool
* @since 2016 /8/25
*/
public class HbaseSharedConnPool implements ConnectionPool<Connection> {
private static final AtomicReference<HbaseSharedConnPool> pool = new AtomicReference<HbaseSharedConnPool>();
private final Connection connection;
private HbaseSharedConnPool(Configuration configuration) throws IOException {
this.connection = ConnectionFactory.createConnection(configuration);
}
/**
* Gets instance.
*
* @param host the host
* @param port the port
* @param master the master
* @param rootdir the rootdir
* @return the instance
*/
public synchronized static HbaseSharedConnPool getInstance(final String host, final String port, final String master, final String rootdir) {
Properties properties = new Properties();
if (host == null)
|
// Path: src/main/java/org/darkphoenixs/pool/ConnectionException.java
// public class ConnectionException extends RuntimeException {
//
// private static final long serialVersionUID = -6503525110247209484L;
//
// public ConnectionException() {
// super();
// }
//
// public ConnectionException(String message) {
// super(message);
// }
//
// public ConnectionException(Throwable e) {
// super(e);
// }
//
// public ConnectionException(String message, Throwable cause) {
// super(message, cause);
// }
// }
//
// Path: src/main/java/org/darkphoenixs/pool/ConnectionPool.java
// public interface ConnectionPool<T> extends Serializable {
//
// /**
// * <p>Title: getConnection</p>
// * <p>Description: 获取连接</p>
// *
// * @return 连接
// */
// public abstract T getConnection();
//
// /**
// * <p>Title: returnConnection</p>
// * <p>Description: 返回连接</p>
// *
// * @param conn 连接
// */
// public void returnConnection(T conn);
//
// /**
// * <p>Title: invalidateConnection</p>
// * <p>Description: 废弃连接</p>
// *
// * @param conn 连接
// */
// public void invalidateConnection(T conn);
// }
// Path: src/main/java/org/darkphoenixs/pool/hbase/HbaseSharedConnPool.java
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.client.Connection;
import org.apache.hadoop.hbase.client.ConnectionFactory;
import org.darkphoenixs.pool.ConnectionException;
import org.darkphoenixs.pool.ConnectionPool;
import java.io.IOException;
import java.util.Map;
import java.util.Properties;
import java.util.concurrent.atomic.AtomicReference;
package org.darkphoenixs.pool.hbase;
/**
* <p>Title: HbaseSharedConnPool</p>
* <p>Description: Hbase共享连接池(单例)</p>
*
* @author Victor.Zxy
* @version 1.2.3
* @see ConnectionPool
* @since 2016 /8/25
*/
public class HbaseSharedConnPool implements ConnectionPool<Connection> {
private static final AtomicReference<HbaseSharedConnPool> pool = new AtomicReference<HbaseSharedConnPool>();
private final Connection connection;
private HbaseSharedConnPool(Configuration configuration) throws IOException {
this.connection = ConnectionFactory.createConnection(configuration);
}
/**
* Gets instance.
*
* @param host the host
* @param port the port
* @param master the master
* @param rootdir the rootdir
* @return the instance
*/
public synchronized static HbaseSharedConnPool getInstance(final String host, final String port, final String master, final String rootdir) {
Properties properties = new Properties();
if (host == null)
|
throw new ConnectionException("[" + HbaseConfig.ZOOKEEPER_QUORUM_PROPERTY + "] is required !");
|
DarkPhoenixs/connection-pool-client
|
src/main/java/org/darkphoenixs/pool/hbase/HbaseConnectionFactory.java
|
// Path: src/main/java/org/darkphoenixs/pool/ConnectionException.java
// public class ConnectionException extends RuntimeException {
//
// private static final long serialVersionUID = -6503525110247209484L;
//
// public ConnectionException() {
// super();
// }
//
// public ConnectionException(String message) {
// super(message);
// }
//
// public ConnectionException(Throwable e) {
// super(e);
// }
//
// public ConnectionException(String message, Throwable cause) {
// super(message, cause);
// }
// }
//
// Path: src/main/java/org/darkphoenixs/pool/ConnectionFactory.java
// public interface ConnectionFactory<T> extends PooledObjectFactory<T>, Serializable {
//
// /**
// * <p>Title: createConnection</p>
// * <p>Description: 创建连接</p>
// *
// * @return 连接
// * @throws Exception
// */
// public abstract T createConnection() throws Exception;
// }
|
import org.apache.commons.pool2.PooledObject;
import org.apache.commons.pool2.impl.DefaultPooledObject;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.client.Connection;
import org.darkphoenixs.pool.ConnectionException;
import org.darkphoenixs.pool.ConnectionFactory;
import java.util.Map.Entry;
import java.util.Properties;
|
/*
* Copyright 2015-2016 Dark Phoenixs (Open-Source Organization).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.darkphoenixs.pool.hbase;
/**
* <p>Title: HbaseConnectionFactory</p>
* <p>Description: Hbase连接工厂</p>
*
* @author Victor
* @version 1.0
* @see ConnectionFactory
* @since 2015年9月19日
*/
class HbaseConnectionFactory implements ConnectionFactory<Connection> {
/**
* serialVersionUID
*/
private static final long serialVersionUID = 4024923894283696465L;
/**
* hadoopConfiguration
*/
private final Configuration hadoopConfiguration;
/**
* <p>Title: HbaseConnectionFactory</p>
* <p>Description: 构造方法</p>
*
* @param hadoopConfiguration hbase配置
*/
public HbaseConnectionFactory(final Configuration hadoopConfiguration) {
this.hadoopConfiguration = hadoopConfiguration;
}
/**
* <p>Title: HbaseConnectionFactory</p>
* <p>Description: 构造方法</p>
*
* @param host zookeeper地址
* @param port zookeeper端口
* @param master hbase主机
* @param rootdir hdfs数据目录
*/
public HbaseConnectionFactory(final String host, final String port, final String master, final String rootdir) {
this.hadoopConfiguration = new Configuration();
if (host == null)
|
// Path: src/main/java/org/darkphoenixs/pool/ConnectionException.java
// public class ConnectionException extends RuntimeException {
//
// private static final long serialVersionUID = -6503525110247209484L;
//
// public ConnectionException() {
// super();
// }
//
// public ConnectionException(String message) {
// super(message);
// }
//
// public ConnectionException(Throwable e) {
// super(e);
// }
//
// public ConnectionException(String message, Throwable cause) {
// super(message, cause);
// }
// }
//
// Path: src/main/java/org/darkphoenixs/pool/ConnectionFactory.java
// public interface ConnectionFactory<T> extends PooledObjectFactory<T>, Serializable {
//
// /**
// * <p>Title: createConnection</p>
// * <p>Description: 创建连接</p>
// *
// * @return 连接
// * @throws Exception
// */
// public abstract T createConnection() throws Exception;
// }
// Path: src/main/java/org/darkphoenixs/pool/hbase/HbaseConnectionFactory.java
import org.apache.commons.pool2.PooledObject;
import org.apache.commons.pool2.impl.DefaultPooledObject;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.client.Connection;
import org.darkphoenixs.pool.ConnectionException;
import org.darkphoenixs.pool.ConnectionFactory;
import java.util.Map.Entry;
import java.util.Properties;
/*
* Copyright 2015-2016 Dark Phoenixs (Open-Source Organization).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.darkphoenixs.pool.hbase;
/**
* <p>Title: HbaseConnectionFactory</p>
* <p>Description: Hbase连接工厂</p>
*
* @author Victor
* @version 1.0
* @see ConnectionFactory
* @since 2015年9月19日
*/
class HbaseConnectionFactory implements ConnectionFactory<Connection> {
/**
* serialVersionUID
*/
private static final long serialVersionUID = 4024923894283696465L;
/**
* hadoopConfiguration
*/
private final Configuration hadoopConfiguration;
/**
* <p>Title: HbaseConnectionFactory</p>
* <p>Description: 构造方法</p>
*
* @param hadoopConfiguration hbase配置
*/
public HbaseConnectionFactory(final Configuration hadoopConfiguration) {
this.hadoopConfiguration = hadoopConfiguration;
}
/**
* <p>Title: HbaseConnectionFactory</p>
* <p>Description: 构造方法</p>
*
* @param host zookeeper地址
* @param port zookeeper端口
* @param master hbase主机
* @param rootdir hdfs数据目录
*/
public HbaseConnectionFactory(final String host, final String port, final String master, final String rootdir) {
this.hadoopConfiguration = new Configuration();
if (host == null)
|
throw new ConnectionException("[" + HbaseConfig.ZOOKEEPER_QUORUM_PROPERTY + "] is required !");
|
DarkPhoenixs/connection-pool-client
|
src/main/java/org/darkphoenixs/pool/jdbc/JdbcConnectionFactory.java
|
// Path: src/main/java/org/darkphoenixs/pool/ConnectionException.java
// public class ConnectionException extends RuntimeException {
//
// private static final long serialVersionUID = -6503525110247209484L;
//
// public ConnectionException() {
// super();
// }
//
// public ConnectionException(String message) {
// super(message);
// }
//
// public ConnectionException(Throwable e) {
// super(e);
// }
//
// public ConnectionException(String message, Throwable cause) {
// super(message, cause);
// }
// }
//
// Path: src/main/java/org/darkphoenixs/pool/ConnectionFactory.java
// public interface ConnectionFactory<T> extends PooledObjectFactory<T>, Serializable {
//
// /**
// * <p>Title: createConnection</p>
// * <p>Description: 创建连接</p>
// *
// * @return 连接
// * @throws Exception
// */
// public abstract T createConnection() throws Exception;
// }
|
import org.apache.commons.pool2.PooledObject;
import org.apache.commons.pool2.impl.DefaultPooledObject;
import org.darkphoenixs.pool.ConnectionException;
import org.darkphoenixs.pool.ConnectionFactory;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.Properties;
|
/*
* Copyright 2015-2016 Dark Phoenixs (Open-Source Organization).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.darkphoenixs.pool.jdbc;
/**
* <p>Title: JdbcConnectionFactory</p>
* <p>Description: JDBC连接工厂</p>
*
* @author Victor.Zxy
* @version 1.0
* @see ConnectionFactory
* @since 2015年11月17日
*/
class JdbcConnectionFactory implements ConnectionFactory<Connection> {
/**
* serialVersionUID
*/
private static final long serialVersionUID = 4941500146671191616L;
/**
* driverClass
*/
private final String driverClass;
/**
* jdbcUrl
*/
private final String jdbcUrl;
/**
* username
*/
private final String username;
/**
* password
*/
private final String password;
/**
* <p>Title: JdbcConnectionFactory</p>
* <p>Description: 构造方法</p>
*
* @param properties JDBC参数
*/
public JdbcConnectionFactory(final Properties properties) {
this.driverClass = properties.getProperty(JdbcConfig.DRIVER_CLASS_PROPERTY);
if (driverClass == null)
|
// Path: src/main/java/org/darkphoenixs/pool/ConnectionException.java
// public class ConnectionException extends RuntimeException {
//
// private static final long serialVersionUID = -6503525110247209484L;
//
// public ConnectionException() {
// super();
// }
//
// public ConnectionException(String message) {
// super(message);
// }
//
// public ConnectionException(Throwable e) {
// super(e);
// }
//
// public ConnectionException(String message, Throwable cause) {
// super(message, cause);
// }
// }
//
// Path: src/main/java/org/darkphoenixs/pool/ConnectionFactory.java
// public interface ConnectionFactory<T> extends PooledObjectFactory<T>, Serializable {
//
// /**
// * <p>Title: createConnection</p>
// * <p>Description: 创建连接</p>
// *
// * @return 连接
// * @throws Exception
// */
// public abstract T createConnection() throws Exception;
// }
// Path: src/main/java/org/darkphoenixs/pool/jdbc/JdbcConnectionFactory.java
import org.apache.commons.pool2.PooledObject;
import org.apache.commons.pool2.impl.DefaultPooledObject;
import org.darkphoenixs.pool.ConnectionException;
import org.darkphoenixs.pool.ConnectionFactory;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.Properties;
/*
* Copyright 2015-2016 Dark Phoenixs (Open-Source Organization).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.darkphoenixs.pool.jdbc;
/**
* <p>Title: JdbcConnectionFactory</p>
* <p>Description: JDBC连接工厂</p>
*
* @author Victor.Zxy
* @version 1.0
* @see ConnectionFactory
* @since 2015年11月17日
*/
class JdbcConnectionFactory implements ConnectionFactory<Connection> {
/**
* serialVersionUID
*/
private static final long serialVersionUID = 4941500146671191616L;
/**
* driverClass
*/
private final String driverClass;
/**
* jdbcUrl
*/
private final String jdbcUrl;
/**
* username
*/
private final String username;
/**
* password
*/
private final String password;
/**
* <p>Title: JdbcConnectionFactory</p>
* <p>Description: 构造方法</p>
*
* @param properties JDBC参数
*/
public JdbcConnectionFactory(final Properties properties) {
this.driverClass = properties.getProperty(JdbcConfig.DRIVER_CLASS_PROPERTY);
if (driverClass == null)
|
throw new ConnectionException("[" + JdbcConfig.DRIVER_CLASS_PROPERTY + "] is required !");
|
DarkPhoenixs/connection-pool-client
|
src/test/java/org/darkphoenixs/pool/redis/RedisClusterConnPoolTest.java
|
// Path: src/main/java/org/darkphoenixs/pool/PoolConfig.java
// public class PoolConfig extends GenericObjectPoolConfig implements Serializable {
//
// /**
// * DEFAULT_TEST_WHILE_IDLE
// */
// public static final boolean DEFAULT_TEST_WHILE_IDLE = true;
// /**
// * DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS
// */
// public static final long DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS = 60000;
// /**
// * DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS
// */
// public static final long DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS = 30000;
// /**
// * DEFAULT_NUM_TESTS_PER_EVICTION_RUN
// */
// public static final int DEFAULT_NUM_TESTS_PER_EVICTION_RUN = -1;
// /**
// * serialVersionUID
// */
// private static final long serialVersionUID = -2414567557372345057L;
//
// /**
// * <p>Title: PoolConfig</p>
// * <p>Description: 默认构造方法</p>
// */
// public PoolConfig() {
//
// // defaults to make your life with connection pool easier :)
// setTestWhileIdle(DEFAULT_TEST_WHILE_IDLE);
// setMinEvictableIdleTimeMillis(DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS);
// setTimeBetweenEvictionRunsMillis(DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS);
// setNumTestsPerEvictionRun(DEFAULT_NUM_TESTS_PER_EVICTION_RUN);
// }
// }
|
import org.darkphoenixs.pool.PoolConfig;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import redis.clients.jedis.HostAndPort;
import redis.clients.jedis.JedisCluster;
import java.io.IOException;
import java.net.ServerSocket;
import java.util.HashSet;
import java.util.Properties;
import java.util.Set;
|
e.printStackTrace();
}
}
});
th.setDaemon(true);
th.start();
}
@Test
public void test() throws Exception {
Set<HostAndPort> jedisClusterNodes = new HashSet<HostAndPort>();
jedisClusterNodes.add(new HostAndPort(RedisConfig.DEFAULT_HOST, RedisConfig.DEFAULT_PORT));
RedisClusterConnPool pool = new RedisClusterConnPool(jedisClusterNodes);
JedisCluster cluster = pool.getConnection();
Assert.assertNotNull(cluster);
pool.returnConnection(cluster);
pool.invalidateConnection(cluster);
Properties properties = new Properties();
properties.setProperty(RedisConfig.CLUSTER_PROPERTY, RedisConfig.DEFAULT_HOST + ":" + RedisConfig.DEFAULT_PORT);
pool = new RedisClusterConnPool(properties);
cluster = pool.getConnection();
Assert.assertNotNull(cluster);
pool.close();
|
// Path: src/main/java/org/darkphoenixs/pool/PoolConfig.java
// public class PoolConfig extends GenericObjectPoolConfig implements Serializable {
//
// /**
// * DEFAULT_TEST_WHILE_IDLE
// */
// public static final boolean DEFAULT_TEST_WHILE_IDLE = true;
// /**
// * DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS
// */
// public static final long DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS = 60000;
// /**
// * DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS
// */
// public static final long DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS = 30000;
// /**
// * DEFAULT_NUM_TESTS_PER_EVICTION_RUN
// */
// public static final int DEFAULT_NUM_TESTS_PER_EVICTION_RUN = -1;
// /**
// * serialVersionUID
// */
// private static final long serialVersionUID = -2414567557372345057L;
//
// /**
// * <p>Title: PoolConfig</p>
// * <p>Description: 默认构造方法</p>
// */
// public PoolConfig() {
//
// // defaults to make your life with connection pool easier :)
// setTestWhileIdle(DEFAULT_TEST_WHILE_IDLE);
// setMinEvictableIdleTimeMillis(DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS);
// setTimeBetweenEvictionRunsMillis(DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS);
// setNumTestsPerEvictionRun(DEFAULT_NUM_TESTS_PER_EVICTION_RUN);
// }
// }
// Path: src/test/java/org/darkphoenixs/pool/redis/RedisClusterConnPoolTest.java
import org.darkphoenixs.pool.PoolConfig;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import redis.clients.jedis.HostAndPort;
import redis.clients.jedis.JedisCluster;
import java.io.IOException;
import java.net.ServerSocket;
import java.util.HashSet;
import java.util.Properties;
import java.util.Set;
e.printStackTrace();
}
}
});
th.setDaemon(true);
th.start();
}
@Test
public void test() throws Exception {
Set<HostAndPort> jedisClusterNodes = new HashSet<HostAndPort>();
jedisClusterNodes.add(new HostAndPort(RedisConfig.DEFAULT_HOST, RedisConfig.DEFAULT_PORT));
RedisClusterConnPool pool = new RedisClusterConnPool(jedisClusterNodes);
JedisCluster cluster = pool.getConnection();
Assert.assertNotNull(cluster);
pool.returnConnection(cluster);
pool.invalidateConnection(cluster);
Properties properties = new Properties();
properties.setProperty(RedisConfig.CLUSTER_PROPERTY, RedisConfig.DEFAULT_HOST + ":" + RedisConfig.DEFAULT_PORT);
pool = new RedisClusterConnPool(properties);
cluster = pool.getConnection();
Assert.assertNotNull(cluster);
pool.close();
|
pool = new RedisClusterConnPool(new PoolConfig(), jedisClusterNodes);
|
DarkPhoenixs/connection-pool-client
|
src/test/java/org/darkphoenixs/pool/redis/RedisConnectionPoolOldTest.java
|
// Path: src/main/java/org/darkphoenixs/pool/PoolConfig.java
// public class PoolConfig extends GenericObjectPoolConfig implements Serializable {
//
// /**
// * DEFAULT_TEST_WHILE_IDLE
// */
// public static final boolean DEFAULT_TEST_WHILE_IDLE = true;
// /**
// * DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS
// */
// public static final long DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS = 60000;
// /**
// * DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS
// */
// public static final long DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS = 30000;
// /**
// * DEFAULT_NUM_TESTS_PER_EVICTION_RUN
// */
// public static final int DEFAULT_NUM_TESTS_PER_EVICTION_RUN = -1;
// /**
// * serialVersionUID
// */
// private static final long serialVersionUID = -2414567557372345057L;
//
// /**
// * <p>Title: PoolConfig</p>
// * <p>Description: 默认构造方法</p>
// */
// public PoolConfig() {
//
// // defaults to make your life with connection pool easier :)
// setTestWhileIdle(DEFAULT_TEST_WHILE_IDLE);
// setMinEvictableIdleTimeMillis(DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS);
// setTimeBetweenEvictionRunsMillis(DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS);
// setNumTestsPerEvictionRun(DEFAULT_NUM_TESTS_PER_EVICTION_RUN);
// }
// }
|
import org.darkphoenixs.pool.PoolConfig;
import org.junit.Before;
import org.junit.Test;
import redis.clients.jedis.Jedis;
import java.io.IOException;
import java.net.ServerSocket;
import java.util.Properties;
|
}
}
});
th.setDaemon(true);
th.start();
}
@Test
public void test() throws Exception {
try {
RedisConnectionPoolOld pool = new RedisConnectionPoolOld(
RedisConfig.DEFAULT_HOST, RedisConfig.DEFAULT_PORT);
pool.close();
} catch (Exception e) {
}
try {
Properties prop = new Properties();
prop.setProperty(RedisConfig.ADDRESS_PROPERTY,
RedisConfig.DEFAULT_HOST + ":" + RedisConfig.DEFAULT_PORT);
prop.setProperty(RedisConfig.CONN_TIMEOUT_PROPERTY,
RedisConfig.DEFAULT_TIMEOUT + "");
prop.setProperty(RedisConfig.SO_TIMEOUT_PROPERTY,
RedisConfig.DEFAULT_TIMEOUT + "");
prop.setProperty(RedisConfig.DATABASE_PROPERTY,
RedisConfig.DEFAULT_DATABASE + "");
RedisConnectionPoolOld pool = new RedisConnectionPoolOld(
|
// Path: src/main/java/org/darkphoenixs/pool/PoolConfig.java
// public class PoolConfig extends GenericObjectPoolConfig implements Serializable {
//
// /**
// * DEFAULT_TEST_WHILE_IDLE
// */
// public static final boolean DEFAULT_TEST_WHILE_IDLE = true;
// /**
// * DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS
// */
// public static final long DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS = 60000;
// /**
// * DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS
// */
// public static final long DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS = 30000;
// /**
// * DEFAULT_NUM_TESTS_PER_EVICTION_RUN
// */
// public static final int DEFAULT_NUM_TESTS_PER_EVICTION_RUN = -1;
// /**
// * serialVersionUID
// */
// private static final long serialVersionUID = -2414567557372345057L;
//
// /**
// * <p>Title: PoolConfig</p>
// * <p>Description: 默认构造方法</p>
// */
// public PoolConfig() {
//
// // defaults to make your life with connection pool easier :)
// setTestWhileIdle(DEFAULT_TEST_WHILE_IDLE);
// setMinEvictableIdleTimeMillis(DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS);
// setTimeBetweenEvictionRunsMillis(DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS);
// setNumTestsPerEvictionRun(DEFAULT_NUM_TESTS_PER_EVICTION_RUN);
// }
// }
// Path: src/test/java/org/darkphoenixs/pool/redis/RedisConnectionPoolOldTest.java
import org.darkphoenixs.pool.PoolConfig;
import org.junit.Before;
import org.junit.Test;
import redis.clients.jedis.Jedis;
import java.io.IOException;
import java.net.ServerSocket;
import java.util.Properties;
}
}
});
th.setDaemon(true);
th.start();
}
@Test
public void test() throws Exception {
try {
RedisConnectionPoolOld pool = new RedisConnectionPoolOld(
RedisConfig.DEFAULT_HOST, RedisConfig.DEFAULT_PORT);
pool.close();
} catch (Exception e) {
}
try {
Properties prop = new Properties();
prop.setProperty(RedisConfig.ADDRESS_PROPERTY,
RedisConfig.DEFAULT_HOST + ":" + RedisConfig.DEFAULT_PORT);
prop.setProperty(RedisConfig.CONN_TIMEOUT_PROPERTY,
RedisConfig.DEFAULT_TIMEOUT + "");
prop.setProperty(RedisConfig.SO_TIMEOUT_PROPERTY,
RedisConfig.DEFAULT_TIMEOUT + "");
prop.setProperty(RedisConfig.DATABASE_PROPERTY,
RedisConfig.DEFAULT_DATABASE + "");
RedisConnectionPoolOld pool = new RedisConnectionPoolOld(
|
new PoolConfig(), prop);
|
DarkPhoenixs/connection-pool-client
|
src/test/java/org/darkphoenixs/pool/redis/RedisShardedConnPoolTest.java
|
// Path: src/main/java/org/darkphoenixs/pool/PoolConfig.java
// public class PoolConfig extends GenericObjectPoolConfig implements Serializable {
//
// /**
// * DEFAULT_TEST_WHILE_IDLE
// */
// public static final boolean DEFAULT_TEST_WHILE_IDLE = true;
// /**
// * DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS
// */
// public static final long DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS = 60000;
// /**
// * DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS
// */
// public static final long DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS = 30000;
// /**
// * DEFAULT_NUM_TESTS_PER_EVICTION_RUN
// */
// public static final int DEFAULT_NUM_TESTS_PER_EVICTION_RUN = -1;
// /**
// * serialVersionUID
// */
// private static final long serialVersionUID = -2414567557372345057L;
//
// /**
// * <p>Title: PoolConfig</p>
// * <p>Description: 默认构造方法</p>
// */
// public PoolConfig() {
//
// // defaults to make your life with connection pool easier :)
// setTestWhileIdle(DEFAULT_TEST_WHILE_IDLE);
// setMinEvictableIdleTimeMillis(DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS);
// setTimeBetweenEvictionRunsMillis(DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS);
// setNumTestsPerEvictionRun(DEFAULT_NUM_TESTS_PER_EVICTION_RUN);
// }
// }
|
import org.darkphoenixs.pool.PoolConfig;
import org.junit.Before;
import org.junit.Test;
import redis.clients.jedis.JedisShardInfo;
import redis.clients.jedis.ShardedJedis;
import java.io.IOException;
import java.net.ServerSocket;
import java.util.Arrays;
import java.util.regex.Pattern;
|
package org.darkphoenixs.pool.redis;
public class RedisShardedConnPoolTest {
@Before
public void before() throws Exception {
Thread th = new Thread(new Runnable() {
private ServerSocket serverSocket;
@Override
public void run() {
try {
serverSocket = new ServerSocket(RedisConfig.DEFAULT_PORT);
serverSocket.accept();
} catch (IOException e) {
e.printStackTrace();
}
}
});
th.setDaemon(true);
th.start();
}
@Test
public void test() throws Exception {
JedisShardInfo info1 = new JedisShardInfo(RedisConfig.DEFAULT_HOST,
RedisConfig.DEFAULT_PORT);
|
// Path: src/main/java/org/darkphoenixs/pool/PoolConfig.java
// public class PoolConfig extends GenericObjectPoolConfig implements Serializable {
//
// /**
// * DEFAULT_TEST_WHILE_IDLE
// */
// public static final boolean DEFAULT_TEST_WHILE_IDLE = true;
// /**
// * DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS
// */
// public static final long DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS = 60000;
// /**
// * DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS
// */
// public static final long DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS = 30000;
// /**
// * DEFAULT_NUM_TESTS_PER_EVICTION_RUN
// */
// public static final int DEFAULT_NUM_TESTS_PER_EVICTION_RUN = -1;
// /**
// * serialVersionUID
// */
// private static final long serialVersionUID = -2414567557372345057L;
//
// /**
// * <p>Title: PoolConfig</p>
// * <p>Description: 默认构造方法</p>
// */
// public PoolConfig() {
//
// // defaults to make your life with connection pool easier :)
// setTestWhileIdle(DEFAULT_TEST_WHILE_IDLE);
// setMinEvictableIdleTimeMillis(DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS);
// setTimeBetweenEvictionRunsMillis(DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS);
// setNumTestsPerEvictionRun(DEFAULT_NUM_TESTS_PER_EVICTION_RUN);
// }
// }
// Path: src/test/java/org/darkphoenixs/pool/redis/RedisShardedConnPoolTest.java
import org.darkphoenixs.pool.PoolConfig;
import org.junit.Before;
import org.junit.Test;
import redis.clients.jedis.JedisShardInfo;
import redis.clients.jedis.ShardedJedis;
import java.io.IOException;
import java.net.ServerSocket;
import java.util.Arrays;
import java.util.regex.Pattern;
package org.darkphoenixs.pool.redis;
public class RedisShardedConnPoolTest {
@Before
public void before() throws Exception {
Thread th = new Thread(new Runnable() {
private ServerSocket serverSocket;
@Override
public void run() {
try {
serverSocket = new ServerSocket(RedisConfig.DEFAULT_PORT);
serverSocket.accept();
} catch (IOException e) {
e.printStackTrace();
}
}
});
th.setDaemon(true);
th.start();
}
@Test
public void test() throws Exception {
JedisShardInfo info1 = new JedisShardInfo(RedisConfig.DEFAULT_HOST,
RedisConfig.DEFAULT_PORT);
|
RedisShardedConnPool pool1 = new RedisShardedConnPool(new PoolConfig(),
|
DarkPhoenixs/connection-pool-client
|
src/main/java/org/darkphoenixs/pool/redis/RedisShardedConnPool.java
|
// Path: src/main/java/org/darkphoenixs/pool/ConnectionPool.java
// public interface ConnectionPool<T> extends Serializable {
//
// /**
// * <p>Title: getConnection</p>
// * <p>Description: 获取连接</p>
// *
// * @return 连接
// */
// public abstract T getConnection();
//
// /**
// * <p>Title: returnConnection</p>
// * <p>Description: 返回连接</p>
// *
// * @param conn 连接
// */
// public void returnConnection(T conn);
//
// /**
// * <p>Title: invalidateConnection</p>
// * <p>Description: 废弃连接</p>
// *
// * @param conn 连接
// */
// public void invalidateConnection(T conn);
// }
//
// Path: src/main/java/org/darkphoenixs/pool/PoolConfig.java
// public class PoolConfig extends GenericObjectPoolConfig implements Serializable {
//
// /**
// * DEFAULT_TEST_WHILE_IDLE
// */
// public static final boolean DEFAULT_TEST_WHILE_IDLE = true;
// /**
// * DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS
// */
// public static final long DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS = 60000;
// /**
// * DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS
// */
// public static final long DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS = 30000;
// /**
// * DEFAULT_NUM_TESTS_PER_EVICTION_RUN
// */
// public static final int DEFAULT_NUM_TESTS_PER_EVICTION_RUN = -1;
// /**
// * serialVersionUID
// */
// private static final long serialVersionUID = -2414567557372345057L;
//
// /**
// * <p>Title: PoolConfig</p>
// * <p>Description: 默认构造方法</p>
// */
// public PoolConfig() {
//
// // defaults to make your life with connection pool easier :)
// setTestWhileIdle(DEFAULT_TEST_WHILE_IDLE);
// setMinEvictableIdleTimeMillis(DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS);
// setTimeBetweenEvictionRunsMillis(DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS);
// setNumTestsPerEvictionRun(DEFAULT_NUM_TESTS_PER_EVICTION_RUN);
// }
// }
|
import org.darkphoenixs.pool.ConnectionPool;
import org.darkphoenixs.pool.PoolConfig;
import redis.clients.jedis.JedisShardInfo;
import redis.clients.jedis.ShardedJedis;
import redis.clients.jedis.ShardedJedisPool;
import redis.clients.util.Hashing;
import java.util.List;
import java.util.regex.Pattern;
|
package org.darkphoenixs.pool.redis;
/**
* <p>Title: RedisShardedConnPool</p>
* <p>Description: Redis分片连接池</p>
*
* @author Victor.Zxy
* @version 1.2.3
* @see ConnectionPool
* @since 2016 /8/25
*/
public class RedisShardedConnPool implements ConnectionPool<ShardedJedis> {
private final ShardedJedisPool pool;
/**
* Instantiates a new Redis sharded conn pool.
*
* @param poolConfig the pool config
* @param shards the shards
*/
|
// Path: src/main/java/org/darkphoenixs/pool/ConnectionPool.java
// public interface ConnectionPool<T> extends Serializable {
//
// /**
// * <p>Title: getConnection</p>
// * <p>Description: 获取连接</p>
// *
// * @return 连接
// */
// public abstract T getConnection();
//
// /**
// * <p>Title: returnConnection</p>
// * <p>Description: 返回连接</p>
// *
// * @param conn 连接
// */
// public void returnConnection(T conn);
//
// /**
// * <p>Title: invalidateConnection</p>
// * <p>Description: 废弃连接</p>
// *
// * @param conn 连接
// */
// public void invalidateConnection(T conn);
// }
//
// Path: src/main/java/org/darkphoenixs/pool/PoolConfig.java
// public class PoolConfig extends GenericObjectPoolConfig implements Serializable {
//
// /**
// * DEFAULT_TEST_WHILE_IDLE
// */
// public static final boolean DEFAULT_TEST_WHILE_IDLE = true;
// /**
// * DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS
// */
// public static final long DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS = 60000;
// /**
// * DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS
// */
// public static final long DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS = 30000;
// /**
// * DEFAULT_NUM_TESTS_PER_EVICTION_RUN
// */
// public static final int DEFAULT_NUM_TESTS_PER_EVICTION_RUN = -1;
// /**
// * serialVersionUID
// */
// private static final long serialVersionUID = -2414567557372345057L;
//
// /**
// * <p>Title: PoolConfig</p>
// * <p>Description: 默认构造方法</p>
// */
// public PoolConfig() {
//
// // defaults to make your life with connection pool easier :)
// setTestWhileIdle(DEFAULT_TEST_WHILE_IDLE);
// setMinEvictableIdleTimeMillis(DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS);
// setTimeBetweenEvictionRunsMillis(DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS);
// setNumTestsPerEvictionRun(DEFAULT_NUM_TESTS_PER_EVICTION_RUN);
// }
// }
// Path: src/main/java/org/darkphoenixs/pool/redis/RedisShardedConnPool.java
import org.darkphoenixs.pool.ConnectionPool;
import org.darkphoenixs.pool.PoolConfig;
import redis.clients.jedis.JedisShardInfo;
import redis.clients.jedis.ShardedJedis;
import redis.clients.jedis.ShardedJedisPool;
import redis.clients.util.Hashing;
import java.util.List;
import java.util.regex.Pattern;
package org.darkphoenixs.pool.redis;
/**
* <p>Title: RedisShardedConnPool</p>
* <p>Description: Redis分片连接池</p>
*
* @author Victor.Zxy
* @version 1.2.3
* @see ConnectionPool
* @since 2016 /8/25
*/
public class RedisShardedConnPool implements ConnectionPool<ShardedJedis> {
private final ShardedJedisPool pool;
/**
* Instantiates a new Redis sharded conn pool.
*
* @param poolConfig the pool config
* @param shards the shards
*/
|
public RedisShardedConnPool(final PoolConfig poolConfig,
|
DarkPhoenixs/connection-pool-client
|
src/main/java/org/darkphoenixs/pool/redis/RedisClusterConnPool.java
|
// Path: src/main/java/org/darkphoenixs/pool/ConnectionPool.java
// public interface ConnectionPool<T> extends Serializable {
//
// /**
// * <p>Title: getConnection</p>
// * <p>Description: 获取连接</p>
// *
// * @return 连接
// */
// public abstract T getConnection();
//
// /**
// * <p>Title: returnConnection</p>
// * <p>Description: 返回连接</p>
// *
// * @param conn 连接
// */
// public void returnConnection(T conn);
//
// /**
// * <p>Title: invalidateConnection</p>
// * <p>Description: 废弃连接</p>
// *
// * @param conn 连接
// */
// public void invalidateConnection(T conn);
// }
//
// Path: src/main/java/org/darkphoenixs/pool/PoolConfig.java
// public class PoolConfig extends GenericObjectPoolConfig implements Serializable {
//
// /**
// * DEFAULT_TEST_WHILE_IDLE
// */
// public static final boolean DEFAULT_TEST_WHILE_IDLE = true;
// /**
// * DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS
// */
// public static final long DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS = 60000;
// /**
// * DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS
// */
// public static final long DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS = 30000;
// /**
// * DEFAULT_NUM_TESTS_PER_EVICTION_RUN
// */
// public static final int DEFAULT_NUM_TESTS_PER_EVICTION_RUN = -1;
// /**
// * serialVersionUID
// */
// private static final long serialVersionUID = -2414567557372345057L;
//
// /**
// * <p>Title: PoolConfig</p>
// * <p>Description: 默认构造方法</p>
// */
// public PoolConfig() {
//
// // defaults to make your life with connection pool easier :)
// setTestWhileIdle(DEFAULT_TEST_WHILE_IDLE);
// setMinEvictableIdleTimeMillis(DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS);
// setTimeBetweenEvictionRunsMillis(DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS);
// setNumTestsPerEvictionRun(DEFAULT_NUM_TESTS_PER_EVICTION_RUN);
// }
// }
|
import org.darkphoenixs.pool.ConnectionPool;
import org.darkphoenixs.pool.PoolConfig;
import redis.clients.jedis.HostAndPort;
import redis.clients.jedis.JedisCluster;
import java.io.IOException;
import java.util.HashSet;
import java.util.Properties;
import java.util.Set;
|
package org.darkphoenixs.pool.redis;
/**
* <p>Title: RedisClusterConnPool</p>
* <p>Description: Redis集群连接池</p>
*
* @author Victor
* @version 1.2.4
* @see ConnectionPool
* @since 2016 /11/21
*/
public class RedisClusterConnPool implements ConnectionPool<JedisCluster> {
private final JedisCluster jedisCluster;
/**
* Instantiates a new Redis cluster conn pool.
*
* @param clusterNodes the jedis cluster nodes
*/
public RedisClusterConnPool(final Set<HostAndPort> clusterNodes) {
this(clusterNodes, RedisConfig.DEFAULT_TIMEOUT);
}
/**
* Instantiates a new Redis cluster conn pool.
*
* @param clusterNodes the cluster nodes
* @param timeout the timeout
*/
public RedisClusterConnPool(final Set<HostAndPort> clusterNodes,
final int timeout) {
this(clusterNodes, timeout, timeout);
}
/**
* Instantiates a new Redis cluster conn pool.
*
* @param clusterNodes the jedis cluster nodes
* @param connectionTimeout the connection timeout
* @param soTimeout the so timeout
*/
public RedisClusterConnPool(final Set<HostAndPort> clusterNodes,
final int connectionTimeout,
final int soTimeout) {
this(clusterNodes, connectionTimeout, soTimeout, RedisConfig.DEFAULT_MAXATTE);
}
/**
* Instantiates a new Redis cluster conn pool.
*
* @param clusterNodes the jedis cluster nodes
* @param connectionTimeout the connection timeout
* @param soTimeout the so timeout
* @param maxAttempts the max attempts
*/
public RedisClusterConnPool(final Set<HostAndPort> clusterNodes,
final int connectionTimeout,
final int soTimeout,
final int maxAttempts) {
|
// Path: src/main/java/org/darkphoenixs/pool/ConnectionPool.java
// public interface ConnectionPool<T> extends Serializable {
//
// /**
// * <p>Title: getConnection</p>
// * <p>Description: 获取连接</p>
// *
// * @return 连接
// */
// public abstract T getConnection();
//
// /**
// * <p>Title: returnConnection</p>
// * <p>Description: 返回连接</p>
// *
// * @param conn 连接
// */
// public void returnConnection(T conn);
//
// /**
// * <p>Title: invalidateConnection</p>
// * <p>Description: 废弃连接</p>
// *
// * @param conn 连接
// */
// public void invalidateConnection(T conn);
// }
//
// Path: src/main/java/org/darkphoenixs/pool/PoolConfig.java
// public class PoolConfig extends GenericObjectPoolConfig implements Serializable {
//
// /**
// * DEFAULT_TEST_WHILE_IDLE
// */
// public static final boolean DEFAULT_TEST_WHILE_IDLE = true;
// /**
// * DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS
// */
// public static final long DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS = 60000;
// /**
// * DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS
// */
// public static final long DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS = 30000;
// /**
// * DEFAULT_NUM_TESTS_PER_EVICTION_RUN
// */
// public static final int DEFAULT_NUM_TESTS_PER_EVICTION_RUN = -1;
// /**
// * serialVersionUID
// */
// private static final long serialVersionUID = -2414567557372345057L;
//
// /**
// * <p>Title: PoolConfig</p>
// * <p>Description: 默认构造方法</p>
// */
// public PoolConfig() {
//
// // defaults to make your life with connection pool easier :)
// setTestWhileIdle(DEFAULT_TEST_WHILE_IDLE);
// setMinEvictableIdleTimeMillis(DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS);
// setTimeBetweenEvictionRunsMillis(DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS);
// setNumTestsPerEvictionRun(DEFAULT_NUM_TESTS_PER_EVICTION_RUN);
// }
// }
// Path: src/main/java/org/darkphoenixs/pool/redis/RedisClusterConnPool.java
import org.darkphoenixs.pool.ConnectionPool;
import org.darkphoenixs.pool.PoolConfig;
import redis.clients.jedis.HostAndPort;
import redis.clients.jedis.JedisCluster;
import java.io.IOException;
import java.util.HashSet;
import java.util.Properties;
import java.util.Set;
package org.darkphoenixs.pool.redis;
/**
* <p>Title: RedisClusterConnPool</p>
* <p>Description: Redis集群连接池</p>
*
* @author Victor
* @version 1.2.4
* @see ConnectionPool
* @since 2016 /11/21
*/
public class RedisClusterConnPool implements ConnectionPool<JedisCluster> {
private final JedisCluster jedisCluster;
/**
* Instantiates a new Redis cluster conn pool.
*
* @param clusterNodes the jedis cluster nodes
*/
public RedisClusterConnPool(final Set<HostAndPort> clusterNodes) {
this(clusterNodes, RedisConfig.DEFAULT_TIMEOUT);
}
/**
* Instantiates a new Redis cluster conn pool.
*
* @param clusterNodes the cluster nodes
* @param timeout the timeout
*/
public RedisClusterConnPool(final Set<HostAndPort> clusterNodes,
final int timeout) {
this(clusterNodes, timeout, timeout);
}
/**
* Instantiates a new Redis cluster conn pool.
*
* @param clusterNodes the jedis cluster nodes
* @param connectionTimeout the connection timeout
* @param soTimeout the so timeout
*/
public RedisClusterConnPool(final Set<HostAndPort> clusterNodes,
final int connectionTimeout,
final int soTimeout) {
this(clusterNodes, connectionTimeout, soTimeout, RedisConfig.DEFAULT_MAXATTE);
}
/**
* Instantiates a new Redis cluster conn pool.
*
* @param clusterNodes the jedis cluster nodes
* @param connectionTimeout the connection timeout
* @param soTimeout the so timeout
* @param maxAttempts the max attempts
*/
public RedisClusterConnPool(final Set<HostAndPort> clusterNodes,
final int connectionTimeout,
final int soTimeout,
final int maxAttempts) {
|
this(clusterNodes, connectionTimeout, soTimeout, maxAttempts, new PoolConfig());
|
DarkPhoenixs/connection-pool-client
|
src/test/java/org/darkphoenixs/pool/http/HttpConnectionPoolTest.java
|
// Path: src/main/java/org/darkphoenixs/pool/PoolConfig.java
// public class PoolConfig extends GenericObjectPoolConfig implements Serializable {
//
// /**
// * DEFAULT_TEST_WHILE_IDLE
// */
// public static final boolean DEFAULT_TEST_WHILE_IDLE = true;
// /**
// * DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS
// */
// public static final long DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS = 60000;
// /**
// * DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS
// */
// public static final long DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS = 30000;
// /**
// * DEFAULT_NUM_TESTS_PER_EVICTION_RUN
// */
// public static final int DEFAULT_NUM_TESTS_PER_EVICTION_RUN = -1;
// /**
// * serialVersionUID
// */
// private static final long serialVersionUID = -2414567557372345057L;
//
// /**
// * <p>Title: PoolConfig</p>
// * <p>Description: 默认构造方法</p>
// */
// public PoolConfig() {
//
// // defaults to make your life with connection pool easier :)
// setTestWhileIdle(DEFAULT_TEST_WHILE_IDLE);
// setMinEvictableIdleTimeMillis(DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS);
// setTimeBetweenEvictionRunsMillis(DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS);
// setNumTestsPerEvictionRun(DEFAULT_NUM_TESTS_PER_EVICTION_RUN);
// }
// }
|
import org.darkphoenixs.pool.PoolConfig;
import org.junit.Test;
import java.net.Proxy;
import java.util.Properties;
|
package org.darkphoenixs.pool.http;
public class HttpConnectionPoolTest {
@Test
public void test() throws Exception {
|
// Path: src/main/java/org/darkphoenixs/pool/PoolConfig.java
// public class PoolConfig extends GenericObjectPoolConfig implements Serializable {
//
// /**
// * DEFAULT_TEST_WHILE_IDLE
// */
// public static final boolean DEFAULT_TEST_WHILE_IDLE = true;
// /**
// * DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS
// */
// public static final long DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS = 60000;
// /**
// * DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS
// */
// public static final long DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS = 30000;
// /**
// * DEFAULT_NUM_TESTS_PER_EVICTION_RUN
// */
// public static final int DEFAULT_NUM_TESTS_PER_EVICTION_RUN = -1;
// /**
// * serialVersionUID
// */
// private static final long serialVersionUID = -2414567557372345057L;
//
// /**
// * <p>Title: PoolConfig</p>
// * <p>Description: 默认构造方法</p>
// */
// public PoolConfig() {
//
// // defaults to make your life with connection pool easier :)
// setTestWhileIdle(DEFAULT_TEST_WHILE_IDLE);
// setMinEvictableIdleTimeMillis(DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS);
// setTimeBetweenEvictionRunsMillis(DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS);
// setNumTestsPerEvictionRun(DEFAULT_NUM_TESTS_PER_EVICTION_RUN);
// }
// }
// Path: src/test/java/org/darkphoenixs/pool/http/HttpConnectionPoolTest.java
import org.darkphoenixs.pool.PoolConfig;
import org.junit.Test;
import java.net.Proxy;
import java.util.Properties;
package org.darkphoenixs.pool.http;
public class HttpConnectionPoolTest {
@Test
public void test() throws Exception {
|
PoolConfig config = new PoolConfig();
|
DarkPhoenixs/connection-pool-client
|
src/test/java/org/darkphoenixs/pool/hbase/HbaseConnectionPoolTest.java
|
// Path: src/main/java/org/darkphoenixs/pool/PoolConfig.java
// public class PoolConfig extends GenericObjectPoolConfig implements Serializable {
//
// /**
// * DEFAULT_TEST_WHILE_IDLE
// */
// public static final boolean DEFAULT_TEST_WHILE_IDLE = true;
// /**
// * DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS
// */
// public static final long DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS = 60000;
// /**
// * DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS
// */
// public static final long DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS = 30000;
// /**
// * DEFAULT_NUM_TESTS_PER_EVICTION_RUN
// */
// public static final int DEFAULT_NUM_TESTS_PER_EVICTION_RUN = -1;
// /**
// * serialVersionUID
// */
// private static final long serialVersionUID = -2414567557372345057L;
//
// /**
// * <p>Title: PoolConfig</p>
// * <p>Description: 默认构造方法</p>
// */
// public PoolConfig() {
//
// // defaults to make your life with connection pool easier :)
// setTestWhileIdle(DEFAULT_TEST_WHILE_IDLE);
// setMinEvictableIdleTimeMillis(DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS);
// setTimeBetweenEvictionRunsMillis(DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS);
// setNumTestsPerEvictionRun(DEFAULT_NUM_TESTS_PER_EVICTION_RUN);
// }
// }
|
import org.apache.hadoop.conf.Configuration;
import org.darkphoenixs.pool.PoolConfig;
import org.junit.Test;
import java.util.Properties;
|
/*
* Copyright 2015-2016 Dark Phoenixs (Open-Source Organization).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.darkphoenixs.pool.hbase;
public class HbaseConnectionPoolTest {
@Test
public void test() throws Exception {
try {
HbaseConnectionPool pool = new HbaseConnectionPool(
|
// Path: src/main/java/org/darkphoenixs/pool/PoolConfig.java
// public class PoolConfig extends GenericObjectPoolConfig implements Serializable {
//
// /**
// * DEFAULT_TEST_WHILE_IDLE
// */
// public static final boolean DEFAULT_TEST_WHILE_IDLE = true;
// /**
// * DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS
// */
// public static final long DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS = 60000;
// /**
// * DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS
// */
// public static final long DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS = 30000;
// /**
// * DEFAULT_NUM_TESTS_PER_EVICTION_RUN
// */
// public static final int DEFAULT_NUM_TESTS_PER_EVICTION_RUN = -1;
// /**
// * serialVersionUID
// */
// private static final long serialVersionUID = -2414567557372345057L;
//
// /**
// * <p>Title: PoolConfig</p>
// * <p>Description: 默认构造方法</p>
// */
// public PoolConfig() {
//
// // defaults to make your life with connection pool easier :)
// setTestWhileIdle(DEFAULT_TEST_WHILE_IDLE);
// setMinEvictableIdleTimeMillis(DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS);
// setTimeBetweenEvictionRunsMillis(DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS);
// setNumTestsPerEvictionRun(DEFAULT_NUM_TESTS_PER_EVICTION_RUN);
// }
// }
// Path: src/test/java/org/darkphoenixs/pool/hbase/HbaseConnectionPoolTest.java
import org.apache.hadoop.conf.Configuration;
import org.darkphoenixs.pool.PoolConfig;
import org.junit.Test;
import java.util.Properties;
/*
* Copyright 2015-2016 Dark Phoenixs (Open-Source Organization).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.darkphoenixs.pool.hbase;
public class HbaseConnectionPoolTest {
@Test
public void test() throws Exception {
try {
HbaseConnectionPool pool = new HbaseConnectionPool(
|
new PoolConfig(), HbaseConfig.DEFAULT_HOST,
|
DarkPhoenixs/connection-pool-client
|
src/test/java/org/darkphoenixs/pool/redis/RedisShardedConnPoolOldTest.java
|
// Path: src/main/java/org/darkphoenixs/pool/PoolConfig.java
// public class PoolConfig extends GenericObjectPoolConfig implements Serializable {
//
// /**
// * DEFAULT_TEST_WHILE_IDLE
// */
// public static final boolean DEFAULT_TEST_WHILE_IDLE = true;
// /**
// * DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS
// */
// public static final long DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS = 60000;
// /**
// * DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS
// */
// public static final long DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS = 30000;
// /**
// * DEFAULT_NUM_TESTS_PER_EVICTION_RUN
// */
// public static final int DEFAULT_NUM_TESTS_PER_EVICTION_RUN = -1;
// /**
// * serialVersionUID
// */
// private static final long serialVersionUID = -2414567557372345057L;
//
// /**
// * <p>Title: PoolConfig</p>
// * <p>Description: 默认构造方法</p>
// */
// public PoolConfig() {
//
// // defaults to make your life with connection pool easier :)
// setTestWhileIdle(DEFAULT_TEST_WHILE_IDLE);
// setMinEvictableIdleTimeMillis(DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS);
// setTimeBetweenEvictionRunsMillis(DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS);
// setNumTestsPerEvictionRun(DEFAULT_NUM_TESTS_PER_EVICTION_RUN);
// }
// }
|
import org.apache.commons.pool2.impl.DefaultPooledObject;
import org.darkphoenixs.pool.PoolConfig;
import org.junit.Before;
import org.junit.Test;
import redis.clients.jedis.JedisShardInfo;
import redis.clients.jedis.ShardedJedis;
import redis.clients.util.Hashing;
import java.io.IOException;
import java.net.ServerSocket;
import java.util.Arrays;
import java.util.regex.Pattern;
|
package org.darkphoenixs.pool.redis;
public class RedisShardedConnPoolOldTest {
@Before
public void before() throws Exception {
Thread th = new Thread(new Runnable() {
private ServerSocket serverSocket;
@Override
public void run() {
try {
serverSocket = new ServerSocket(RedisConfig.DEFAULT_PORT);
serverSocket.accept();
} catch (IOException e) {
e.printStackTrace();
}
}
});
th.setDaemon(true);
th.start();
}
@Test
public void test_0() throws Exception {
JedisShardInfo info = new JedisShardInfo(RedisConfig.DEFAULT_HOST,
RedisConfig.DEFAULT_PORT);
|
// Path: src/main/java/org/darkphoenixs/pool/PoolConfig.java
// public class PoolConfig extends GenericObjectPoolConfig implements Serializable {
//
// /**
// * DEFAULT_TEST_WHILE_IDLE
// */
// public static final boolean DEFAULT_TEST_WHILE_IDLE = true;
// /**
// * DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS
// */
// public static final long DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS = 60000;
// /**
// * DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS
// */
// public static final long DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS = 30000;
// /**
// * DEFAULT_NUM_TESTS_PER_EVICTION_RUN
// */
// public static final int DEFAULT_NUM_TESTS_PER_EVICTION_RUN = -1;
// /**
// * serialVersionUID
// */
// private static final long serialVersionUID = -2414567557372345057L;
//
// /**
// * <p>Title: PoolConfig</p>
// * <p>Description: 默认构造方法</p>
// */
// public PoolConfig() {
//
// // defaults to make your life with connection pool easier :)
// setTestWhileIdle(DEFAULT_TEST_WHILE_IDLE);
// setMinEvictableIdleTimeMillis(DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS);
// setTimeBetweenEvictionRunsMillis(DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS);
// setNumTestsPerEvictionRun(DEFAULT_NUM_TESTS_PER_EVICTION_RUN);
// }
// }
// Path: src/test/java/org/darkphoenixs/pool/redis/RedisShardedConnPoolOldTest.java
import org.apache.commons.pool2.impl.DefaultPooledObject;
import org.darkphoenixs.pool.PoolConfig;
import org.junit.Before;
import org.junit.Test;
import redis.clients.jedis.JedisShardInfo;
import redis.clients.jedis.ShardedJedis;
import redis.clients.util.Hashing;
import java.io.IOException;
import java.net.ServerSocket;
import java.util.Arrays;
import java.util.regex.Pattern;
package org.darkphoenixs.pool.redis;
public class RedisShardedConnPoolOldTest {
@Before
public void before() throws Exception {
Thread th = new Thread(new Runnable() {
private ServerSocket serverSocket;
@Override
public void run() {
try {
serverSocket = new ServerSocket(RedisConfig.DEFAULT_PORT);
serverSocket.accept();
} catch (IOException e) {
e.printStackTrace();
}
}
});
th.setDaemon(true);
th.start();
}
@Test
public void test_0() throws Exception {
JedisShardInfo info = new JedisShardInfo(RedisConfig.DEFAULT_HOST,
RedisConfig.DEFAULT_PORT);
|
RedisShardedConnPoolOld pool = new RedisShardedConnPoolOld(new PoolConfig(),
|
DarkPhoenixs/connection-pool-client
|
src/main/java/org/darkphoenixs/pool/redis/RedisConnectionFactoryOld.java
|
// Path: src/main/java/org/darkphoenixs/pool/ConnectionException.java
// public class ConnectionException extends RuntimeException {
//
// private static final long serialVersionUID = -6503525110247209484L;
//
// public ConnectionException() {
// super();
// }
//
// public ConnectionException(String message) {
// super(message);
// }
//
// public ConnectionException(Throwable e) {
// super(e);
// }
//
// public ConnectionException(String message, Throwable cause) {
// super(message, cause);
// }
// }
//
// Path: src/main/java/org/darkphoenixs/pool/ConnectionFactory.java
// public interface ConnectionFactory<T> extends PooledObjectFactory<T>, Serializable {
//
// /**
// * <p>Title: createConnection</p>
// * <p>Description: 创建连接</p>
// *
// * @return 连接
// * @throws Exception
// */
// public abstract T createConnection() throws Exception;
// }
|
import org.apache.commons.pool2.PooledObject;
import org.apache.commons.pool2.impl.DefaultPooledObject;
import org.darkphoenixs.pool.ConnectionException;
import org.darkphoenixs.pool.ConnectionFactory;
import redis.clients.jedis.BinaryJedis;
import redis.clients.jedis.HostAndPort;
import redis.clients.jedis.Jedis;
import java.util.Properties;
import java.util.concurrent.atomic.AtomicReference;
|
/*
* Copyright 2015-2016 Dark Phoenixs (Open-Source Organization).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.darkphoenixs.pool.redis;
/**
* <p>Title: RedisConnectionFactoryOld</p>
* <p>Description: Redis连接工厂</p>
*
* @author Victor
* @version 1.0
* @see ConnectionFactory
* @since 2015年9月19日
*/
@Deprecated
class RedisConnectionFactoryOld implements ConnectionFactory<Jedis> {
/**
* serialVersionUID
*/
private static final long serialVersionUID = 5692815845396189037L;
/**
* hostAndPort
*/
private final AtomicReference<HostAndPort> hostAndPort = new AtomicReference<HostAndPort>();
/**
* connectionTimeout
*/
private final int connectionTimeout;
/**
* soTimeout
*/
private final int soTimeout;
/**
* password
*/
private final String password;
/**
* database
*/
private final int database;
/**
* clientName
*/
private final String clientName;
/**
* <p>Title: RedisConnectionFactoryOld</p>
* <p>Description: 构造方法</p>
*
* @param host 地址
* @param port 端口
* @param connectionTimeout 连接超时
* @param soTimeout 超时时间
* @param password 密码
* @param database 数据库
* @param clientName 客户端名称
*/
public RedisConnectionFactoryOld(final String host, final int port, final int connectionTimeout,
final int soTimeout, final String password, final int database, final String clientName) {
this.hostAndPort.set(new HostAndPort(host, port));
this.connectionTimeout = connectionTimeout;
this.soTimeout = soTimeout;
this.password = password;
this.database = database;
this.clientName = clientName;
}
/**
* @param properties 参数配置
* @since 1.2.1
*/
public RedisConnectionFactoryOld(final Properties properties) {
String address = properties.getProperty(RedisConfig.ADDRESS_PROPERTY);
if (address == null)
|
// Path: src/main/java/org/darkphoenixs/pool/ConnectionException.java
// public class ConnectionException extends RuntimeException {
//
// private static final long serialVersionUID = -6503525110247209484L;
//
// public ConnectionException() {
// super();
// }
//
// public ConnectionException(String message) {
// super(message);
// }
//
// public ConnectionException(Throwable e) {
// super(e);
// }
//
// public ConnectionException(String message, Throwable cause) {
// super(message, cause);
// }
// }
//
// Path: src/main/java/org/darkphoenixs/pool/ConnectionFactory.java
// public interface ConnectionFactory<T> extends PooledObjectFactory<T>, Serializable {
//
// /**
// * <p>Title: createConnection</p>
// * <p>Description: 创建连接</p>
// *
// * @return 连接
// * @throws Exception
// */
// public abstract T createConnection() throws Exception;
// }
// Path: src/main/java/org/darkphoenixs/pool/redis/RedisConnectionFactoryOld.java
import org.apache.commons.pool2.PooledObject;
import org.apache.commons.pool2.impl.DefaultPooledObject;
import org.darkphoenixs.pool.ConnectionException;
import org.darkphoenixs.pool.ConnectionFactory;
import redis.clients.jedis.BinaryJedis;
import redis.clients.jedis.HostAndPort;
import redis.clients.jedis.Jedis;
import java.util.Properties;
import java.util.concurrent.atomic.AtomicReference;
/*
* Copyright 2015-2016 Dark Phoenixs (Open-Source Organization).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.darkphoenixs.pool.redis;
/**
* <p>Title: RedisConnectionFactoryOld</p>
* <p>Description: Redis连接工厂</p>
*
* @author Victor
* @version 1.0
* @see ConnectionFactory
* @since 2015年9月19日
*/
@Deprecated
class RedisConnectionFactoryOld implements ConnectionFactory<Jedis> {
/**
* serialVersionUID
*/
private static final long serialVersionUID = 5692815845396189037L;
/**
* hostAndPort
*/
private final AtomicReference<HostAndPort> hostAndPort = new AtomicReference<HostAndPort>();
/**
* connectionTimeout
*/
private final int connectionTimeout;
/**
* soTimeout
*/
private final int soTimeout;
/**
* password
*/
private final String password;
/**
* database
*/
private final int database;
/**
* clientName
*/
private final String clientName;
/**
* <p>Title: RedisConnectionFactoryOld</p>
* <p>Description: 构造方法</p>
*
* @param host 地址
* @param port 端口
* @param connectionTimeout 连接超时
* @param soTimeout 超时时间
* @param password 密码
* @param database 数据库
* @param clientName 客户端名称
*/
public RedisConnectionFactoryOld(final String host, final int port, final int connectionTimeout,
final int soTimeout, final String password, final int database, final String clientName) {
this.hostAndPort.set(new HostAndPort(host, port));
this.connectionTimeout = connectionTimeout;
this.soTimeout = soTimeout;
this.password = password;
this.database = database;
this.clientName = clientName;
}
/**
* @param properties 参数配置
* @since 1.2.1
*/
public RedisConnectionFactoryOld(final Properties properties) {
String address = properties.getProperty(RedisConfig.ADDRESS_PROPERTY);
if (address == null)
|
throw new ConnectionException("[" + RedisConfig.ADDRESS_PROPERTY + "] is required !");
|
DarkPhoenixs/connection-pool-client
|
src/main/java/org/darkphoenixs/pool/redis/RedisConnectionPool.java
|
// Path: src/main/java/org/darkphoenixs/pool/ConnectionPool.java
// public interface ConnectionPool<T> extends Serializable {
//
// /**
// * <p>Title: getConnection</p>
// * <p>Description: 获取连接</p>
// *
// * @return 连接
// */
// public abstract T getConnection();
//
// /**
// * <p>Title: returnConnection</p>
// * <p>Description: 返回连接</p>
// *
// * @param conn 连接
// */
// public void returnConnection(T conn);
//
// /**
// * <p>Title: invalidateConnection</p>
// * <p>Description: 废弃连接</p>
// *
// * @param conn 连接
// */
// public void invalidateConnection(T conn);
// }
//
// Path: src/main/java/org/darkphoenixs/pool/PoolConfig.java
// public class PoolConfig extends GenericObjectPoolConfig implements Serializable {
//
// /**
// * DEFAULT_TEST_WHILE_IDLE
// */
// public static final boolean DEFAULT_TEST_WHILE_IDLE = true;
// /**
// * DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS
// */
// public static final long DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS = 60000;
// /**
// * DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS
// */
// public static final long DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS = 30000;
// /**
// * DEFAULT_NUM_TESTS_PER_EVICTION_RUN
// */
// public static final int DEFAULT_NUM_TESTS_PER_EVICTION_RUN = -1;
// /**
// * serialVersionUID
// */
// private static final long serialVersionUID = -2414567557372345057L;
//
// /**
// * <p>Title: PoolConfig</p>
// * <p>Description: 默认构造方法</p>
// */
// public PoolConfig() {
//
// // defaults to make your life with connection pool easier :)
// setTestWhileIdle(DEFAULT_TEST_WHILE_IDLE);
// setMinEvictableIdleTimeMillis(DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS);
// setTimeBetweenEvictionRunsMillis(DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS);
// setNumTestsPerEvictionRun(DEFAULT_NUM_TESTS_PER_EVICTION_RUN);
// }
// }
|
import org.darkphoenixs.pool.ConnectionPool;
import org.darkphoenixs.pool.PoolConfig;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import java.util.Properties;
|
package org.darkphoenixs.pool.redis;
/**
* <p>Title: RedisConnectionPool</p>
* <p>Description: Redis连接池</p>
*
* @author Victor.Zxy
* @version 1.2.3
* @see ConnectionPool
* @since 2016 /8/25
*/
public class RedisConnectionPool implements ConnectionPool<Jedis> {
private final JedisPool pool;
/**
* Instantiates a new Redis connection pool.
*
* @param host the host
* @param port the port
*/
public RedisConnectionPool(final String host, final int port) {
|
// Path: src/main/java/org/darkphoenixs/pool/ConnectionPool.java
// public interface ConnectionPool<T> extends Serializable {
//
// /**
// * <p>Title: getConnection</p>
// * <p>Description: 获取连接</p>
// *
// * @return 连接
// */
// public abstract T getConnection();
//
// /**
// * <p>Title: returnConnection</p>
// * <p>Description: 返回连接</p>
// *
// * @param conn 连接
// */
// public void returnConnection(T conn);
//
// /**
// * <p>Title: invalidateConnection</p>
// * <p>Description: 废弃连接</p>
// *
// * @param conn 连接
// */
// public void invalidateConnection(T conn);
// }
//
// Path: src/main/java/org/darkphoenixs/pool/PoolConfig.java
// public class PoolConfig extends GenericObjectPoolConfig implements Serializable {
//
// /**
// * DEFAULT_TEST_WHILE_IDLE
// */
// public static final boolean DEFAULT_TEST_WHILE_IDLE = true;
// /**
// * DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS
// */
// public static final long DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS = 60000;
// /**
// * DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS
// */
// public static final long DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS = 30000;
// /**
// * DEFAULT_NUM_TESTS_PER_EVICTION_RUN
// */
// public static final int DEFAULT_NUM_TESTS_PER_EVICTION_RUN = -1;
// /**
// * serialVersionUID
// */
// private static final long serialVersionUID = -2414567557372345057L;
//
// /**
// * <p>Title: PoolConfig</p>
// * <p>Description: 默认构造方法</p>
// */
// public PoolConfig() {
//
// // defaults to make your life with connection pool easier :)
// setTestWhileIdle(DEFAULT_TEST_WHILE_IDLE);
// setMinEvictableIdleTimeMillis(DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS);
// setTimeBetweenEvictionRunsMillis(DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS);
// setNumTestsPerEvictionRun(DEFAULT_NUM_TESTS_PER_EVICTION_RUN);
// }
// }
// Path: src/main/java/org/darkphoenixs/pool/redis/RedisConnectionPool.java
import org.darkphoenixs.pool.ConnectionPool;
import org.darkphoenixs.pool.PoolConfig;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import java.util.Properties;
package org.darkphoenixs.pool.redis;
/**
* <p>Title: RedisConnectionPool</p>
* <p>Description: Redis连接池</p>
*
* @author Victor.Zxy
* @version 1.2.3
* @see ConnectionPool
* @since 2016 /8/25
*/
public class RedisConnectionPool implements ConnectionPool<Jedis> {
private final JedisPool pool;
/**
* Instantiates a new Redis connection pool.
*
* @param host the host
* @param port the port
*/
public RedisConnectionPool(final String host, final int port) {
|
this(new PoolConfig(), host, port);
|
DarkPhoenixs/connection-pool-client
|
src/test/java/org/darkphoenixs/pool/kafka/KafkaConnectionPoolTest.java
|
// Path: src/main/java/org/darkphoenixs/pool/PoolConfig.java
// public class PoolConfig extends GenericObjectPoolConfig implements Serializable {
//
// /**
// * DEFAULT_TEST_WHILE_IDLE
// */
// public static final boolean DEFAULT_TEST_WHILE_IDLE = true;
// /**
// * DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS
// */
// public static final long DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS = 60000;
// /**
// * DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS
// */
// public static final long DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS = 30000;
// /**
// * DEFAULT_NUM_TESTS_PER_EVICTION_RUN
// */
// public static final int DEFAULT_NUM_TESTS_PER_EVICTION_RUN = -1;
// /**
// * serialVersionUID
// */
// private static final long serialVersionUID = -2414567557372345057L;
//
// /**
// * <p>Title: PoolConfig</p>
// * <p>Description: 默认构造方法</p>
// */
// public PoolConfig() {
//
// // defaults to make your life with connection pool easier :)
// setTestWhileIdle(DEFAULT_TEST_WHILE_IDLE);
// setMinEvictableIdleTimeMillis(DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS);
// setTimeBetweenEvictionRunsMillis(DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS);
// setNumTestsPerEvictionRun(DEFAULT_NUM_TESTS_PER_EVICTION_RUN);
// }
// }
|
import kafka.producer.ProducerConfig;
import org.darkphoenixs.pool.PoolConfig;
import org.junit.Test;
import java.util.Properties;
|
prop.setProperty(KafkaConfig.PRODUCER_TYPE_PROPERTY,
KafkaConfig.DEFAULT_TYPE);
prop.setProperty(KafkaConfig.REQUEST_ACKS_PROPERTY,
KafkaConfig.DEFAULT_ACKS);
prop.setProperty(KafkaConfig.COMPRESSION_CODEC_PROPERTY,
KafkaConfig.DEFAULT_CODEC);
prop.setProperty(KafkaConfig.BATCH_NUMBER_PROPERTY,
KafkaConfig.DEFAULT_BATCH);
ProducerConfig config = new ProducerConfig(prop);
try {
KafkaConnectionPool pool = new KafkaConnectionPool(KafkaConfig.DEFAULT_BROKERS);
pool.close();
} catch (Exception e) {
}
try {
KafkaConnectionPool pool = new KafkaConnectionPool(prop);
pool.close();
} catch (Exception e) {
}
try {
KafkaConnectionPool pool = new KafkaConnectionPool(config);
pool.close();
} catch (Exception e) {
}
try {
|
// Path: src/main/java/org/darkphoenixs/pool/PoolConfig.java
// public class PoolConfig extends GenericObjectPoolConfig implements Serializable {
//
// /**
// * DEFAULT_TEST_WHILE_IDLE
// */
// public static final boolean DEFAULT_TEST_WHILE_IDLE = true;
// /**
// * DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS
// */
// public static final long DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS = 60000;
// /**
// * DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS
// */
// public static final long DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS = 30000;
// /**
// * DEFAULT_NUM_TESTS_PER_EVICTION_RUN
// */
// public static final int DEFAULT_NUM_TESTS_PER_EVICTION_RUN = -1;
// /**
// * serialVersionUID
// */
// private static final long serialVersionUID = -2414567557372345057L;
//
// /**
// * <p>Title: PoolConfig</p>
// * <p>Description: 默认构造方法</p>
// */
// public PoolConfig() {
//
// // defaults to make your life with connection pool easier :)
// setTestWhileIdle(DEFAULT_TEST_WHILE_IDLE);
// setMinEvictableIdleTimeMillis(DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS);
// setTimeBetweenEvictionRunsMillis(DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS);
// setNumTestsPerEvictionRun(DEFAULT_NUM_TESTS_PER_EVICTION_RUN);
// }
// }
// Path: src/test/java/org/darkphoenixs/pool/kafka/KafkaConnectionPoolTest.java
import kafka.producer.ProducerConfig;
import org.darkphoenixs.pool.PoolConfig;
import org.junit.Test;
import java.util.Properties;
prop.setProperty(KafkaConfig.PRODUCER_TYPE_PROPERTY,
KafkaConfig.DEFAULT_TYPE);
prop.setProperty(KafkaConfig.REQUEST_ACKS_PROPERTY,
KafkaConfig.DEFAULT_ACKS);
prop.setProperty(KafkaConfig.COMPRESSION_CODEC_PROPERTY,
KafkaConfig.DEFAULT_CODEC);
prop.setProperty(KafkaConfig.BATCH_NUMBER_PROPERTY,
KafkaConfig.DEFAULT_BATCH);
ProducerConfig config = new ProducerConfig(prop);
try {
KafkaConnectionPool pool = new KafkaConnectionPool(KafkaConfig.DEFAULT_BROKERS);
pool.close();
} catch (Exception e) {
}
try {
KafkaConnectionPool pool = new KafkaConnectionPool(prop);
pool.close();
} catch (Exception e) {
}
try {
KafkaConnectionPool pool = new KafkaConnectionPool(config);
pool.close();
} catch (Exception e) {
}
try {
|
KafkaConnectionPool pool = new KafkaConnectionPool(new PoolConfig(), prop);
|
DarkPhoenixs/connection-pool-client
|
src/test/java/org/darkphoenixs/pool/redis/RedisSentinelConnPoolTest.java
|
// Path: src/main/java/org/darkphoenixs/pool/PoolConfig.java
// public class PoolConfig extends GenericObjectPoolConfig implements Serializable {
//
// /**
// * DEFAULT_TEST_WHILE_IDLE
// */
// public static final boolean DEFAULT_TEST_WHILE_IDLE = true;
// /**
// * DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS
// */
// public static final long DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS = 60000;
// /**
// * DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS
// */
// public static final long DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS = 30000;
// /**
// * DEFAULT_NUM_TESTS_PER_EVICTION_RUN
// */
// public static final int DEFAULT_NUM_TESTS_PER_EVICTION_RUN = -1;
// /**
// * serialVersionUID
// */
// private static final long serialVersionUID = -2414567557372345057L;
//
// /**
// * <p>Title: PoolConfig</p>
// * <p>Description: 默认构造方法</p>
// */
// public PoolConfig() {
//
// // defaults to make your life with connection pool easier :)
// setTestWhileIdle(DEFAULT_TEST_WHILE_IDLE);
// setMinEvictableIdleTimeMillis(DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS);
// setTimeBetweenEvictionRunsMillis(DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS);
// setNumTestsPerEvictionRun(DEFAULT_NUM_TESTS_PER_EVICTION_RUN);
// }
// }
|
import org.darkphoenixs.pool.PoolConfig;
import org.junit.Before;
import org.junit.Test;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisSentinelPool;
import java.io.IOException;
import java.net.ServerSocket;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Properties;
|
});
th.setDaemon(true);
th.start();
}
@Test
public void test() throws Exception {
try {
RedisSentinelConnPool pool = new RedisSentinelConnPool("localhost",
new HashSet<String>(
Arrays.asList(new String[]{"localhost:6379"})));
pool.close();
} catch (Exception e) {
}
try {
RedisSentinelConnPool pool = new RedisSentinelConnPool("localhost",
new HashSet<String>(Arrays
.asList(new String[]{"localhost:6379"})));
pool.close();
} catch (Exception e) {
}
Properties properties = new Properties();
try {
RedisSentinelConnPool pool = new RedisSentinelConnPool(
|
// Path: src/main/java/org/darkphoenixs/pool/PoolConfig.java
// public class PoolConfig extends GenericObjectPoolConfig implements Serializable {
//
// /**
// * DEFAULT_TEST_WHILE_IDLE
// */
// public static final boolean DEFAULT_TEST_WHILE_IDLE = true;
// /**
// * DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS
// */
// public static final long DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS = 60000;
// /**
// * DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS
// */
// public static final long DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS = 30000;
// /**
// * DEFAULT_NUM_TESTS_PER_EVICTION_RUN
// */
// public static final int DEFAULT_NUM_TESTS_PER_EVICTION_RUN = -1;
// /**
// * serialVersionUID
// */
// private static final long serialVersionUID = -2414567557372345057L;
//
// /**
// * <p>Title: PoolConfig</p>
// * <p>Description: 默认构造方法</p>
// */
// public PoolConfig() {
//
// // defaults to make your life with connection pool easier :)
// setTestWhileIdle(DEFAULT_TEST_WHILE_IDLE);
// setMinEvictableIdleTimeMillis(DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS);
// setTimeBetweenEvictionRunsMillis(DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS);
// setNumTestsPerEvictionRun(DEFAULT_NUM_TESTS_PER_EVICTION_RUN);
// }
// }
// Path: src/test/java/org/darkphoenixs/pool/redis/RedisSentinelConnPoolTest.java
import org.darkphoenixs.pool.PoolConfig;
import org.junit.Before;
import org.junit.Test;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisSentinelPool;
import java.io.IOException;
import java.net.ServerSocket;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Properties;
});
th.setDaemon(true);
th.start();
}
@Test
public void test() throws Exception {
try {
RedisSentinelConnPool pool = new RedisSentinelConnPool("localhost",
new HashSet<String>(
Arrays.asList(new String[]{"localhost:6379"})));
pool.close();
} catch (Exception e) {
}
try {
RedisSentinelConnPool pool = new RedisSentinelConnPool("localhost",
new HashSet<String>(Arrays
.asList(new String[]{"localhost:6379"})));
pool.close();
} catch (Exception e) {
}
Properties properties = new Properties();
try {
RedisSentinelConnPool pool = new RedisSentinelConnPool(
|
new PoolConfig(), properties);
|
DarkPhoenixs/connection-pool-client
|
src/test/java/org/darkphoenixs/pool/redis/RedisConnectionPoolTest.java
|
// Path: src/main/java/org/darkphoenixs/pool/PoolConfig.java
// public class PoolConfig extends GenericObjectPoolConfig implements Serializable {
//
// /**
// * DEFAULT_TEST_WHILE_IDLE
// */
// public static final boolean DEFAULT_TEST_WHILE_IDLE = true;
// /**
// * DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS
// */
// public static final long DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS = 60000;
// /**
// * DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS
// */
// public static final long DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS = 30000;
// /**
// * DEFAULT_NUM_TESTS_PER_EVICTION_RUN
// */
// public static final int DEFAULT_NUM_TESTS_PER_EVICTION_RUN = -1;
// /**
// * serialVersionUID
// */
// private static final long serialVersionUID = -2414567557372345057L;
//
// /**
// * <p>Title: PoolConfig</p>
// * <p>Description: 默认构造方法</p>
// */
// public PoolConfig() {
//
// // defaults to make your life with connection pool easier :)
// setTestWhileIdle(DEFAULT_TEST_WHILE_IDLE);
// setMinEvictableIdleTimeMillis(DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS);
// setTimeBetweenEvictionRunsMillis(DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS);
// setNumTestsPerEvictionRun(DEFAULT_NUM_TESTS_PER_EVICTION_RUN);
// }
// }
|
import org.darkphoenixs.pool.PoolConfig;
import org.junit.Before;
import org.junit.Test;
import redis.clients.jedis.Jedis;
import java.io.IOException;
import java.net.ServerSocket;
import java.util.Properties;
|
}
}
});
th.setDaemon(true);
th.start();
}
@Test
public void test() throws Exception {
Properties prop = new Properties();
prop.setProperty(RedisConfig.ADDRESS_PROPERTY,
RedisConfig.DEFAULT_HOST + ":" + RedisConfig.DEFAULT_PORT);
prop.setProperty(RedisConfig.CONN_TIMEOUT_PROPERTY,
RedisConfig.DEFAULT_TIMEOUT + "");
prop.setProperty(RedisConfig.SO_TIMEOUT_PROPERTY,
RedisConfig.DEFAULT_TIMEOUT + "");
prop.setProperty(RedisConfig.DATABASE_PROPERTY,
RedisConfig.DEFAULT_DATABASE + "");
try {
RedisConnectionPool pool = new RedisConnectionPool(
RedisConfig.DEFAULT_HOST, RedisConfig.DEFAULT_PORT);
pool.close();
} catch (Exception e) {
}
try {
RedisConnectionPool pool = new RedisConnectionPool(
|
// Path: src/main/java/org/darkphoenixs/pool/PoolConfig.java
// public class PoolConfig extends GenericObjectPoolConfig implements Serializable {
//
// /**
// * DEFAULT_TEST_WHILE_IDLE
// */
// public static final boolean DEFAULT_TEST_WHILE_IDLE = true;
// /**
// * DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS
// */
// public static final long DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS = 60000;
// /**
// * DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS
// */
// public static final long DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS = 30000;
// /**
// * DEFAULT_NUM_TESTS_PER_EVICTION_RUN
// */
// public static final int DEFAULT_NUM_TESTS_PER_EVICTION_RUN = -1;
// /**
// * serialVersionUID
// */
// private static final long serialVersionUID = -2414567557372345057L;
//
// /**
// * <p>Title: PoolConfig</p>
// * <p>Description: 默认构造方法</p>
// */
// public PoolConfig() {
//
// // defaults to make your life with connection pool easier :)
// setTestWhileIdle(DEFAULT_TEST_WHILE_IDLE);
// setMinEvictableIdleTimeMillis(DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS);
// setTimeBetweenEvictionRunsMillis(DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS);
// setNumTestsPerEvictionRun(DEFAULT_NUM_TESTS_PER_EVICTION_RUN);
// }
// }
// Path: src/test/java/org/darkphoenixs/pool/redis/RedisConnectionPoolTest.java
import org.darkphoenixs.pool.PoolConfig;
import org.junit.Before;
import org.junit.Test;
import redis.clients.jedis.Jedis;
import java.io.IOException;
import java.net.ServerSocket;
import java.util.Properties;
}
}
});
th.setDaemon(true);
th.start();
}
@Test
public void test() throws Exception {
Properties prop = new Properties();
prop.setProperty(RedisConfig.ADDRESS_PROPERTY,
RedisConfig.DEFAULT_HOST + ":" + RedisConfig.DEFAULT_PORT);
prop.setProperty(RedisConfig.CONN_TIMEOUT_PROPERTY,
RedisConfig.DEFAULT_TIMEOUT + "");
prop.setProperty(RedisConfig.SO_TIMEOUT_PROPERTY,
RedisConfig.DEFAULT_TIMEOUT + "");
prop.setProperty(RedisConfig.DATABASE_PROPERTY,
RedisConfig.DEFAULT_DATABASE + "");
try {
RedisConnectionPool pool = new RedisConnectionPool(
RedisConfig.DEFAULT_HOST, RedisConfig.DEFAULT_PORT);
pool.close();
} catch (Exception e) {
}
try {
RedisConnectionPool pool = new RedisConnectionPool(
|
new PoolConfig(), prop);
|
BSUIR-Helper/helper-android
|
app/src/ru/bsuirhelper/android/ui/schedule/DialogDatePicker.java
|
// Path: app/src/ru/bsuirhelper/android/core/StudentCalendar.java
// public class StudentCalendar {
// private final DateTime mCurrentDateTime;
// private static int mDaysOfYear = 0;
// private static int mSemester;
//
// public StudentCalendar() {
// mCurrentDateTime = new DateTime();
// mDaysOfYear = getDaysOfYear();
//
// if (mCurrentDateTime.getMonthOfYear() >= 9) {
// mSemester = 1;
// } else {
// mSemester = 2;
// }
// }
//
// public int getDayOfYear() {
// int dayOfYear;
// if (mCurrentDateTime.getMonthOfYear() >= 9) {
// DateTime september = new DateTime(mCurrentDateTime.getYear(), 9, 1, 0, 0, 0);
// dayOfYear = new Interval(september, mCurrentDateTime).toPeriod(PeriodType.days()).getDays();
// } else {
// DateTime september = new DateTime(mCurrentDateTime.getYear() - 1, 9, 1, 0, 0, 0);
// dayOfYear = new Interval(september, mCurrentDateTime).toPeriod(PeriodType.days()).getDays();
// }
//
// return dayOfYear + 1;
// }
//
// public int getDayOfYear(DateTime dateTime) {
// int dayOfYear;
// if (dateTime.getMonthOfYear() >= 9) {
// DateTime september = new DateTime(dateTime.getYear(), 9, 1, 0, 0, 0);
// dayOfYear = new Interval(september, dateTime).toPeriod(PeriodType.days()).getDays();
// } else {
// DateTime september = new DateTime(dateTime.getYear() - 1, 9, 1, 0, 0, 0);
// dayOfYear = new Interval(september, dateTime).toPeriod(PeriodType.days()).getDays();
// }
// return dayOfYear;
// }
//
// public int getDaysOfYear() {
// if (mDaysOfYear == 0) {
// DateTime september;
// DateTime august;
//
// if (mCurrentDateTime.getMonthOfYear() <= 8) {
// september = new DateTime(mCurrentDateTime.getYear() - 1, 9, 1, 0, 0, 0);
// august = new DateTime(mCurrentDateTime.getYear(), 8, 31, 0, 0, 0);
// } else {
// september = new DateTime(mCurrentDateTime.getYear(), 8, 31, 0, 0, 0);
// august = new DateTime(mCurrentDateTime.getYear() + 1, 8, 31, 0, 0, 0);
// }
//
// mDaysOfYear = new Interval(september, august).toPeriod(PeriodType.days()).getDays();
// }
// return mDaysOfYear;
// }
//
// public static int getWorkWeek(DateTime dateTime) {
// DateTime september;
//
// if (dateTime.getMonthOfYear() <= 8) {
// september = new DateTime(dateTime.getYear() - 1, 9, 1, 0, 0, 0);
// } else {
// september = new DateTime(dateTime.getYear(), 9, 1, 0, 0, 0);
// }
//
// Interval interval = new Interval(september, dateTime);
// int workWeek = (interval.toPeriod(PeriodType.weeks()).getWeeks() + 2) % 4;
// workWeek = workWeek == 0 ? 4 : workWeek;
// return workWeek;
// }
//
// public static DateTime convertToDefaultDateTime(int studentDay) {
// DateTime september;
// int currentMonth = DateTime.now().getMonthOfYear();
// if (currentMonth <= 8) {
// september = new DateTime(DateTime.now().getYear() - 1, 9, 1, 0, 0, 0);
// } else {
// september = new DateTime(DateTime.now().getYear(), 9, 1, 0, 0, 0);
// }
// return september.plusDays(studentDay - 1);
// }
//
// public int getSemester() {
// return mSemester;
// }
//
// public static long getStartStudentYear() {
// DateTime september;
//
// if (DateTime.now().getMonthOfYear() <= 8) {
// september = new DateTime(DateTime.now().getYear() - 1, 9, 1, 0, 0, 0);
// } else {
// september = new DateTime(DateTime.now().getYear(), 8, 31, 1, 0, 0);
// }
//
// return september.getMillis();
// }
//
// public static long getEndStudentYear() {
// DateTime august;
// if (DateTime.now().getMonthOfYear() <= 8) {
// august = new DateTime(DateTime.now().getYear(), 8, 31, 1, 0, 0);
// } else {
// august = new DateTime(DateTime.now().getYear() + 1, 8, 31, 1, 0, 0);
// }
// return august.getMillis();
// }
//
// }
|
import android.app.DatePickerDialog;
import android.app.Dialog;
import android.content.Context;
import android.os.Build;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.widget.DatePicker;
import org.joda.time.DateTime;
import ru.bsuirhelper.android.core.StudentCalendar;
import java.util.Calendar;
import static android.app.DatePickerDialog.OnDateSetListener;
|
package ru.bsuirhelper.android.ui.schedule;
/**
* Created by Влад on 07.11.13.
*/
public abstract class DialogDatePicker extends DialogFragment implements OnDateSetListener {
private static final String SCHOOL_WEEK = "Учебная неделя ";
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
// Use the current date as the default date in the picker
final Calendar c = Calendar.getInstance();
int year = c.get(Calendar.YEAR);
int month = c.get(Calendar.MONTH);
int day = c.get(Calendar.DAY_OF_MONTH);
CustomDatePicker datePickerDialog = new CustomDatePicker(getActivity(), this, year, month, day);
if (Build.VERSION.SDK_INT > 10) {
|
// Path: app/src/ru/bsuirhelper/android/core/StudentCalendar.java
// public class StudentCalendar {
// private final DateTime mCurrentDateTime;
// private static int mDaysOfYear = 0;
// private static int mSemester;
//
// public StudentCalendar() {
// mCurrentDateTime = new DateTime();
// mDaysOfYear = getDaysOfYear();
//
// if (mCurrentDateTime.getMonthOfYear() >= 9) {
// mSemester = 1;
// } else {
// mSemester = 2;
// }
// }
//
// public int getDayOfYear() {
// int dayOfYear;
// if (mCurrentDateTime.getMonthOfYear() >= 9) {
// DateTime september = new DateTime(mCurrentDateTime.getYear(), 9, 1, 0, 0, 0);
// dayOfYear = new Interval(september, mCurrentDateTime).toPeriod(PeriodType.days()).getDays();
// } else {
// DateTime september = new DateTime(mCurrentDateTime.getYear() - 1, 9, 1, 0, 0, 0);
// dayOfYear = new Interval(september, mCurrentDateTime).toPeriod(PeriodType.days()).getDays();
// }
//
// return dayOfYear + 1;
// }
//
// public int getDayOfYear(DateTime dateTime) {
// int dayOfYear;
// if (dateTime.getMonthOfYear() >= 9) {
// DateTime september = new DateTime(dateTime.getYear(), 9, 1, 0, 0, 0);
// dayOfYear = new Interval(september, dateTime).toPeriod(PeriodType.days()).getDays();
// } else {
// DateTime september = new DateTime(dateTime.getYear() - 1, 9, 1, 0, 0, 0);
// dayOfYear = new Interval(september, dateTime).toPeriod(PeriodType.days()).getDays();
// }
// return dayOfYear;
// }
//
// public int getDaysOfYear() {
// if (mDaysOfYear == 0) {
// DateTime september;
// DateTime august;
//
// if (mCurrentDateTime.getMonthOfYear() <= 8) {
// september = new DateTime(mCurrentDateTime.getYear() - 1, 9, 1, 0, 0, 0);
// august = new DateTime(mCurrentDateTime.getYear(), 8, 31, 0, 0, 0);
// } else {
// september = new DateTime(mCurrentDateTime.getYear(), 8, 31, 0, 0, 0);
// august = new DateTime(mCurrentDateTime.getYear() + 1, 8, 31, 0, 0, 0);
// }
//
// mDaysOfYear = new Interval(september, august).toPeriod(PeriodType.days()).getDays();
// }
// return mDaysOfYear;
// }
//
// public static int getWorkWeek(DateTime dateTime) {
// DateTime september;
//
// if (dateTime.getMonthOfYear() <= 8) {
// september = new DateTime(dateTime.getYear() - 1, 9, 1, 0, 0, 0);
// } else {
// september = new DateTime(dateTime.getYear(), 9, 1, 0, 0, 0);
// }
//
// Interval interval = new Interval(september, dateTime);
// int workWeek = (interval.toPeriod(PeriodType.weeks()).getWeeks() + 2) % 4;
// workWeek = workWeek == 0 ? 4 : workWeek;
// return workWeek;
// }
//
// public static DateTime convertToDefaultDateTime(int studentDay) {
// DateTime september;
// int currentMonth = DateTime.now().getMonthOfYear();
// if (currentMonth <= 8) {
// september = new DateTime(DateTime.now().getYear() - 1, 9, 1, 0, 0, 0);
// } else {
// september = new DateTime(DateTime.now().getYear(), 9, 1, 0, 0, 0);
// }
// return september.plusDays(studentDay - 1);
// }
//
// public int getSemester() {
// return mSemester;
// }
//
// public static long getStartStudentYear() {
// DateTime september;
//
// if (DateTime.now().getMonthOfYear() <= 8) {
// september = new DateTime(DateTime.now().getYear() - 1, 9, 1, 0, 0, 0);
// } else {
// september = new DateTime(DateTime.now().getYear(), 8, 31, 1, 0, 0);
// }
//
// return september.getMillis();
// }
//
// public static long getEndStudentYear() {
// DateTime august;
// if (DateTime.now().getMonthOfYear() <= 8) {
// august = new DateTime(DateTime.now().getYear(), 8, 31, 1, 0, 0);
// } else {
// august = new DateTime(DateTime.now().getYear() + 1, 8, 31, 1, 0, 0);
// }
// return august.getMillis();
// }
//
// }
// Path: app/src/ru/bsuirhelper/android/ui/schedule/DialogDatePicker.java
import android.app.DatePickerDialog;
import android.app.Dialog;
import android.content.Context;
import android.os.Build;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.widget.DatePicker;
import org.joda.time.DateTime;
import ru.bsuirhelper.android.core.StudentCalendar;
import java.util.Calendar;
import static android.app.DatePickerDialog.OnDateSetListener;
package ru.bsuirhelper.android.ui.schedule;
/**
* Created by Влад on 07.11.13.
*/
public abstract class DialogDatePicker extends DialogFragment implements OnDateSetListener {
private static final String SCHOOL_WEEK = "Учебная неделя ";
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
// Use the current date as the default date in the picker
final Calendar c = Calendar.getInstance();
int year = c.get(Calendar.YEAR);
int month = c.get(Calendar.MONTH);
int day = c.get(Calendar.DAY_OF_MONTH);
CustomDatePicker datePickerDialog = new CustomDatePicker(getActivity(), this, year, month, day);
if (Build.VERSION.SDK_INT > 10) {
|
datePickerDialog.getDatePicker().setMinDate(StudentCalendar.getStartStudentYear());
|
BSUIR-Helper/helper-android
|
app/src/ru/bsuirhelper/android/ui/DownloadScheduleTask.java
|
// Path: app/src/ru/bsuirhelper/android/core/schedule/Lesson.java
// public class Lesson {
// public final HashMap<String, String> fields = new HashMap<String, String>();
// public int id;
//
// public Lesson() {
// fields.put("faculty", "");
// fields.put("year", "");
// fields.put("course", "");
// fields.put("term", "");
// fields.put("stream", "");
// fields.put("s_group", "");
// fields.put("subgroup", "");
// fields.put("weekDay", "");
// fields.put("timePeriod", "");
// fields.put("weekList", "");
// fields.put("subject", "");
// fields.put("subjectType", "");
// fields.put("auditorium", "");
// fields.put("teacher", "");
// fields.put("date", "");
// fields.put("timePeriodStart", "");
// fields.put("timePeriodEnd", "");
// }
// }
//
// Path: app/src/ru/bsuirhelper/android/core/schedule/ScheduleManager.java
// public class ScheduleManager {
// private final ScheduleDatabase mScheduleDatabase;
// private StudentCalendar mStudentCalendar = new StudentCalendar();
// private static ScheduleManager instance;
//
// public static ScheduleManager getInstance(Context context) {
// if (instance == null) {
// instance = new ScheduleManager(context);
// }
// return instance;
// }
//
// public ScheduleManager(Context context) {
// mScheduleDatabase = new ScheduleDatabase(context);
// mStudentCalendar = new StudentCalendar();
// }
//
// public ArrayList<StudentGroup> getGroups() {
// return mScheduleDatabase.getGroups();
// }
//
// public void addSchedule(String groupId, ArrayList<Lesson> lessons) {
// mScheduleDatabase.addSchedule(lessons, groupId);
// }
//
// public Lesson[] getLessonsOfDay(String groupId, DateTime dayOfYear, int subgroup) {
// return mScheduleDatabase.getLessonsOfDay(groupId, dayOfYear, subgroup);
// }
//
// public void deleteSchedule(String groupId) {
// mScheduleDatabase.deleteSchedule(groupId);
// }
//
// public boolean isLessonsEndToday(String groupId, int subgroup) {
// DateTime currentTime = new DateTime();
// Lesson[] lessons = mScheduleDatabase.getLessonsOfDay(groupId, DateTime.now(), subgroup);
// if (lessons.length > 0) {
// Lesson lesson = lessons[lessons.length - 1];
//
// DateTimeFormatter formatter = DateTimeFormat.forPattern("HH:mm");
// DateTime dt = formatter.parseDateTime(getFinishTimeOfLesson(lesson));
// if (currentTime.getHourOfDay() + 1 > dt.getHourOfDay()) {
// return true;
// }
// } else {
// return true;
// }
// return false;
// }
//
// private String getFinishTimeOfLesson(Lesson lesson) {
// String time = lesson.fields.get("timePeriod");
// char c = '-';
// int pos = -1;
// while (time.charAt(++pos) != c) ;
// String result = time.substring(pos + 1, time.length());
// return result;
// }
// }
//
// Path: app/src/ru/bsuirhelper/android/core/schedule/ScheduleParser.java
// public class ScheduleParser {
//
// public static ArrayList<Lesson> parseXmlSchedule(File xmlFile) {
// DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
// DocumentBuilder dBuilder;
// Document doc = null;
// try {
// dBuilder = dbFactory.newDocumentBuilder();
// doc = dBuilder.parse(xmlFile);
// } catch (Exception e) {
// e.printStackTrace();
// }
// doc.getDocumentElement().normalize();
//
// NodeList list = doc.getElementsByTagName("ROW");
// ArrayList<Lesson> lessons = new ArrayList<Lesson>();
// for (int i = 0; i < list.getLength(); i++) {
// Lesson lesson = new Lesson();
// Element element = (Element) list.item(i);
// NamedNodeMap attrs = element.getAttributes();
// for (int j = 0; j < attrs.getLength(); j++) {
// Node attribute = attrs.item(j);
// //In xml file attribute name group, but group it is keyword of sqlite
// if (attribute.getNodeName().equals("group")) {
// lesson.fields.put("s_group", attribute.getNodeValue());
// continue;
// }
// lesson.fields.put(attribute.getNodeName(), attribute.getNodeValue());
// }
// lessons.add(lesson);
// }
// return lessons;
// }
// }
|
import android.app.ProgressDialog;
import android.content.Context;
import android.os.AsyncTask;
import android.support.v4.app.Fragment;
import android.widget.Toast;
import ru.bsuirhelper.android.core.schedule.Lesson;
import ru.bsuirhelper.android.core.schedule.ScheduleManager;
import ru.bsuirhelper.android.core.schedule.ScheduleParser;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.ArrayList;
|
package ru.bsuirhelper.android.ui;
/**
* Created by Влад on 18.02.14.
*/
public class DownloadScheduleTask extends AsyncTask<String, Integer, String> {
private static final String message = "Обновление расписания";
private static final String LIST_URL = "http://www.bsuir.by/psched/rest/";
private static final String TEMP_FILE_NAME = "schedule.xml";
private static final String ERROR_HAPPENED = "Произошла ошибка";
private static final String FRAGMENT_MESSAGE = "Fragment must implement CallBack Interface";
private static final String SUCCESS = "Success";
private static final String ERROR = "Error";
private ProgressDialog mPogressDialog;
private Fragment fragment;
private Context context;
|
// Path: app/src/ru/bsuirhelper/android/core/schedule/Lesson.java
// public class Lesson {
// public final HashMap<String, String> fields = new HashMap<String, String>();
// public int id;
//
// public Lesson() {
// fields.put("faculty", "");
// fields.put("year", "");
// fields.put("course", "");
// fields.put("term", "");
// fields.put("stream", "");
// fields.put("s_group", "");
// fields.put("subgroup", "");
// fields.put("weekDay", "");
// fields.put("timePeriod", "");
// fields.put("weekList", "");
// fields.put("subject", "");
// fields.put("subjectType", "");
// fields.put("auditorium", "");
// fields.put("teacher", "");
// fields.put("date", "");
// fields.put("timePeriodStart", "");
// fields.put("timePeriodEnd", "");
// }
// }
//
// Path: app/src/ru/bsuirhelper/android/core/schedule/ScheduleManager.java
// public class ScheduleManager {
// private final ScheduleDatabase mScheduleDatabase;
// private StudentCalendar mStudentCalendar = new StudentCalendar();
// private static ScheduleManager instance;
//
// public static ScheduleManager getInstance(Context context) {
// if (instance == null) {
// instance = new ScheduleManager(context);
// }
// return instance;
// }
//
// public ScheduleManager(Context context) {
// mScheduleDatabase = new ScheduleDatabase(context);
// mStudentCalendar = new StudentCalendar();
// }
//
// public ArrayList<StudentGroup> getGroups() {
// return mScheduleDatabase.getGroups();
// }
//
// public void addSchedule(String groupId, ArrayList<Lesson> lessons) {
// mScheduleDatabase.addSchedule(lessons, groupId);
// }
//
// public Lesson[] getLessonsOfDay(String groupId, DateTime dayOfYear, int subgroup) {
// return mScheduleDatabase.getLessonsOfDay(groupId, dayOfYear, subgroup);
// }
//
// public void deleteSchedule(String groupId) {
// mScheduleDatabase.deleteSchedule(groupId);
// }
//
// public boolean isLessonsEndToday(String groupId, int subgroup) {
// DateTime currentTime = new DateTime();
// Lesson[] lessons = mScheduleDatabase.getLessonsOfDay(groupId, DateTime.now(), subgroup);
// if (lessons.length > 0) {
// Lesson lesson = lessons[lessons.length - 1];
//
// DateTimeFormatter formatter = DateTimeFormat.forPattern("HH:mm");
// DateTime dt = formatter.parseDateTime(getFinishTimeOfLesson(lesson));
// if (currentTime.getHourOfDay() + 1 > dt.getHourOfDay()) {
// return true;
// }
// } else {
// return true;
// }
// return false;
// }
//
// private String getFinishTimeOfLesson(Lesson lesson) {
// String time = lesson.fields.get("timePeriod");
// char c = '-';
// int pos = -1;
// while (time.charAt(++pos) != c) ;
// String result = time.substring(pos + 1, time.length());
// return result;
// }
// }
//
// Path: app/src/ru/bsuirhelper/android/core/schedule/ScheduleParser.java
// public class ScheduleParser {
//
// public static ArrayList<Lesson> parseXmlSchedule(File xmlFile) {
// DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
// DocumentBuilder dBuilder;
// Document doc = null;
// try {
// dBuilder = dbFactory.newDocumentBuilder();
// doc = dBuilder.parse(xmlFile);
// } catch (Exception e) {
// e.printStackTrace();
// }
// doc.getDocumentElement().normalize();
//
// NodeList list = doc.getElementsByTagName("ROW");
// ArrayList<Lesson> lessons = new ArrayList<Lesson>();
// for (int i = 0; i < list.getLength(); i++) {
// Lesson lesson = new Lesson();
// Element element = (Element) list.item(i);
// NamedNodeMap attrs = element.getAttributes();
// for (int j = 0; j < attrs.getLength(); j++) {
// Node attribute = attrs.item(j);
// //In xml file attribute name group, but group it is keyword of sqlite
// if (attribute.getNodeName().equals("group")) {
// lesson.fields.put("s_group", attribute.getNodeValue());
// continue;
// }
// lesson.fields.put(attribute.getNodeName(), attribute.getNodeValue());
// }
// lessons.add(lesson);
// }
// return lessons;
// }
// }
// Path: app/src/ru/bsuirhelper/android/ui/DownloadScheduleTask.java
import android.app.ProgressDialog;
import android.content.Context;
import android.os.AsyncTask;
import android.support.v4.app.Fragment;
import android.widget.Toast;
import ru.bsuirhelper.android.core.schedule.Lesson;
import ru.bsuirhelper.android.core.schedule.ScheduleManager;
import ru.bsuirhelper.android.core.schedule.ScheduleParser;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.ArrayList;
package ru.bsuirhelper.android.ui;
/**
* Created by Влад on 18.02.14.
*/
public class DownloadScheduleTask extends AsyncTask<String, Integer, String> {
private static final String message = "Обновление расписания";
private static final String LIST_URL = "http://www.bsuir.by/psched/rest/";
private static final String TEMP_FILE_NAME = "schedule.xml";
private static final String ERROR_HAPPENED = "Произошла ошибка";
private static final String FRAGMENT_MESSAGE = "Fragment must implement CallBack Interface";
private static final String SUCCESS = "Success";
private static final String ERROR = "Error";
private ProgressDialog mPogressDialog;
private Fragment fragment;
private Context context;
|
private ScheduleManager scheduleManager;
|
BSUIR-Helper/helper-android
|
app/src/ru/bsuirhelper/android/ui/DownloadScheduleTask.java
|
// Path: app/src/ru/bsuirhelper/android/core/schedule/Lesson.java
// public class Lesson {
// public final HashMap<String, String> fields = new HashMap<String, String>();
// public int id;
//
// public Lesson() {
// fields.put("faculty", "");
// fields.put("year", "");
// fields.put("course", "");
// fields.put("term", "");
// fields.put("stream", "");
// fields.put("s_group", "");
// fields.put("subgroup", "");
// fields.put("weekDay", "");
// fields.put("timePeriod", "");
// fields.put("weekList", "");
// fields.put("subject", "");
// fields.put("subjectType", "");
// fields.put("auditorium", "");
// fields.put("teacher", "");
// fields.put("date", "");
// fields.put("timePeriodStart", "");
// fields.put("timePeriodEnd", "");
// }
// }
//
// Path: app/src/ru/bsuirhelper/android/core/schedule/ScheduleManager.java
// public class ScheduleManager {
// private final ScheduleDatabase mScheduleDatabase;
// private StudentCalendar mStudentCalendar = new StudentCalendar();
// private static ScheduleManager instance;
//
// public static ScheduleManager getInstance(Context context) {
// if (instance == null) {
// instance = new ScheduleManager(context);
// }
// return instance;
// }
//
// public ScheduleManager(Context context) {
// mScheduleDatabase = new ScheduleDatabase(context);
// mStudentCalendar = new StudentCalendar();
// }
//
// public ArrayList<StudentGroup> getGroups() {
// return mScheduleDatabase.getGroups();
// }
//
// public void addSchedule(String groupId, ArrayList<Lesson> lessons) {
// mScheduleDatabase.addSchedule(lessons, groupId);
// }
//
// public Lesson[] getLessonsOfDay(String groupId, DateTime dayOfYear, int subgroup) {
// return mScheduleDatabase.getLessonsOfDay(groupId, dayOfYear, subgroup);
// }
//
// public void deleteSchedule(String groupId) {
// mScheduleDatabase.deleteSchedule(groupId);
// }
//
// public boolean isLessonsEndToday(String groupId, int subgroup) {
// DateTime currentTime = new DateTime();
// Lesson[] lessons = mScheduleDatabase.getLessonsOfDay(groupId, DateTime.now(), subgroup);
// if (lessons.length > 0) {
// Lesson lesson = lessons[lessons.length - 1];
//
// DateTimeFormatter formatter = DateTimeFormat.forPattern("HH:mm");
// DateTime dt = formatter.parseDateTime(getFinishTimeOfLesson(lesson));
// if (currentTime.getHourOfDay() + 1 > dt.getHourOfDay()) {
// return true;
// }
// } else {
// return true;
// }
// return false;
// }
//
// private String getFinishTimeOfLesson(Lesson lesson) {
// String time = lesson.fields.get("timePeriod");
// char c = '-';
// int pos = -1;
// while (time.charAt(++pos) != c) ;
// String result = time.substring(pos + 1, time.length());
// return result;
// }
// }
//
// Path: app/src/ru/bsuirhelper/android/core/schedule/ScheduleParser.java
// public class ScheduleParser {
//
// public static ArrayList<Lesson> parseXmlSchedule(File xmlFile) {
// DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
// DocumentBuilder dBuilder;
// Document doc = null;
// try {
// dBuilder = dbFactory.newDocumentBuilder();
// doc = dBuilder.parse(xmlFile);
// } catch (Exception e) {
// e.printStackTrace();
// }
// doc.getDocumentElement().normalize();
//
// NodeList list = doc.getElementsByTagName("ROW");
// ArrayList<Lesson> lessons = new ArrayList<Lesson>();
// for (int i = 0; i < list.getLength(); i++) {
// Lesson lesson = new Lesson();
// Element element = (Element) list.item(i);
// NamedNodeMap attrs = element.getAttributes();
// for (int j = 0; j < attrs.getLength(); j++) {
// Node attribute = attrs.item(j);
// //In xml file attribute name group, but group it is keyword of sqlite
// if (attribute.getNodeName().equals("group")) {
// lesson.fields.put("s_group", attribute.getNodeValue());
// continue;
// }
// lesson.fields.put(attribute.getNodeName(), attribute.getNodeValue());
// }
// lessons.add(lesson);
// }
// return lessons;
// }
// }
|
import android.app.ProgressDialog;
import android.content.Context;
import android.os.AsyncTask;
import android.support.v4.app.Fragment;
import android.widget.Toast;
import ru.bsuirhelper.android.core.schedule.Lesson;
import ru.bsuirhelper.android.core.schedule.ScheduleManager;
import ru.bsuirhelper.android.core.schedule.ScheduleParser;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.ArrayList;
|
while ((count = input.read(data)) != -1) {
output.write(data, 0, count);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (output != null)
output.close();
if (input != null)
input.close();
} catch (IOException e) {
e.printStackTrace();
}
if (connection != null)
connection.disconnect();
}
return new File(context.getApplicationContext().getFilesDir() + "/" + TEMP_FILE_NAME);
}
@Override
protected String doInBackground(String... urls) {
String groupId = urls[0];
File xmlFile = downloadScheduleFromInternet(groupId);
if (xmlFile == null) {
return ERROR;
}
|
// Path: app/src/ru/bsuirhelper/android/core/schedule/Lesson.java
// public class Lesson {
// public final HashMap<String, String> fields = new HashMap<String, String>();
// public int id;
//
// public Lesson() {
// fields.put("faculty", "");
// fields.put("year", "");
// fields.put("course", "");
// fields.put("term", "");
// fields.put("stream", "");
// fields.put("s_group", "");
// fields.put("subgroup", "");
// fields.put("weekDay", "");
// fields.put("timePeriod", "");
// fields.put("weekList", "");
// fields.put("subject", "");
// fields.put("subjectType", "");
// fields.put("auditorium", "");
// fields.put("teacher", "");
// fields.put("date", "");
// fields.put("timePeriodStart", "");
// fields.put("timePeriodEnd", "");
// }
// }
//
// Path: app/src/ru/bsuirhelper/android/core/schedule/ScheduleManager.java
// public class ScheduleManager {
// private final ScheduleDatabase mScheduleDatabase;
// private StudentCalendar mStudentCalendar = new StudentCalendar();
// private static ScheduleManager instance;
//
// public static ScheduleManager getInstance(Context context) {
// if (instance == null) {
// instance = new ScheduleManager(context);
// }
// return instance;
// }
//
// public ScheduleManager(Context context) {
// mScheduleDatabase = new ScheduleDatabase(context);
// mStudentCalendar = new StudentCalendar();
// }
//
// public ArrayList<StudentGroup> getGroups() {
// return mScheduleDatabase.getGroups();
// }
//
// public void addSchedule(String groupId, ArrayList<Lesson> lessons) {
// mScheduleDatabase.addSchedule(lessons, groupId);
// }
//
// public Lesson[] getLessonsOfDay(String groupId, DateTime dayOfYear, int subgroup) {
// return mScheduleDatabase.getLessonsOfDay(groupId, dayOfYear, subgroup);
// }
//
// public void deleteSchedule(String groupId) {
// mScheduleDatabase.deleteSchedule(groupId);
// }
//
// public boolean isLessonsEndToday(String groupId, int subgroup) {
// DateTime currentTime = new DateTime();
// Lesson[] lessons = mScheduleDatabase.getLessonsOfDay(groupId, DateTime.now(), subgroup);
// if (lessons.length > 0) {
// Lesson lesson = lessons[lessons.length - 1];
//
// DateTimeFormatter formatter = DateTimeFormat.forPattern("HH:mm");
// DateTime dt = formatter.parseDateTime(getFinishTimeOfLesson(lesson));
// if (currentTime.getHourOfDay() + 1 > dt.getHourOfDay()) {
// return true;
// }
// } else {
// return true;
// }
// return false;
// }
//
// private String getFinishTimeOfLesson(Lesson lesson) {
// String time = lesson.fields.get("timePeriod");
// char c = '-';
// int pos = -1;
// while (time.charAt(++pos) != c) ;
// String result = time.substring(pos + 1, time.length());
// return result;
// }
// }
//
// Path: app/src/ru/bsuirhelper/android/core/schedule/ScheduleParser.java
// public class ScheduleParser {
//
// public static ArrayList<Lesson> parseXmlSchedule(File xmlFile) {
// DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
// DocumentBuilder dBuilder;
// Document doc = null;
// try {
// dBuilder = dbFactory.newDocumentBuilder();
// doc = dBuilder.parse(xmlFile);
// } catch (Exception e) {
// e.printStackTrace();
// }
// doc.getDocumentElement().normalize();
//
// NodeList list = doc.getElementsByTagName("ROW");
// ArrayList<Lesson> lessons = new ArrayList<Lesson>();
// for (int i = 0; i < list.getLength(); i++) {
// Lesson lesson = new Lesson();
// Element element = (Element) list.item(i);
// NamedNodeMap attrs = element.getAttributes();
// for (int j = 0; j < attrs.getLength(); j++) {
// Node attribute = attrs.item(j);
// //In xml file attribute name group, but group it is keyword of sqlite
// if (attribute.getNodeName().equals("group")) {
// lesson.fields.put("s_group", attribute.getNodeValue());
// continue;
// }
// lesson.fields.put(attribute.getNodeName(), attribute.getNodeValue());
// }
// lessons.add(lesson);
// }
// return lessons;
// }
// }
// Path: app/src/ru/bsuirhelper/android/ui/DownloadScheduleTask.java
import android.app.ProgressDialog;
import android.content.Context;
import android.os.AsyncTask;
import android.support.v4.app.Fragment;
import android.widget.Toast;
import ru.bsuirhelper.android.core.schedule.Lesson;
import ru.bsuirhelper.android.core.schedule.ScheduleManager;
import ru.bsuirhelper.android.core.schedule.ScheduleParser;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.ArrayList;
while ((count = input.read(data)) != -1) {
output.write(data, 0, count);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (output != null)
output.close();
if (input != null)
input.close();
} catch (IOException e) {
e.printStackTrace();
}
if (connection != null)
connection.disconnect();
}
return new File(context.getApplicationContext().getFilesDir() + "/" + TEMP_FILE_NAME);
}
@Override
protected String doInBackground(String... urls) {
String groupId = urls[0];
File xmlFile = downloadScheduleFromInternet(groupId);
if (xmlFile == null) {
return ERROR;
}
|
ArrayList<Lesson> lessons = ScheduleParser.parseXmlSchedule(xmlFile);
|
BSUIR-Helper/helper-android
|
app/src/ru/bsuirhelper/android/ui/DownloadScheduleTask.java
|
// Path: app/src/ru/bsuirhelper/android/core/schedule/Lesson.java
// public class Lesson {
// public final HashMap<String, String> fields = new HashMap<String, String>();
// public int id;
//
// public Lesson() {
// fields.put("faculty", "");
// fields.put("year", "");
// fields.put("course", "");
// fields.put("term", "");
// fields.put("stream", "");
// fields.put("s_group", "");
// fields.put("subgroup", "");
// fields.put("weekDay", "");
// fields.put("timePeriod", "");
// fields.put("weekList", "");
// fields.put("subject", "");
// fields.put("subjectType", "");
// fields.put("auditorium", "");
// fields.put("teacher", "");
// fields.put("date", "");
// fields.put("timePeriodStart", "");
// fields.put("timePeriodEnd", "");
// }
// }
//
// Path: app/src/ru/bsuirhelper/android/core/schedule/ScheduleManager.java
// public class ScheduleManager {
// private final ScheduleDatabase mScheduleDatabase;
// private StudentCalendar mStudentCalendar = new StudentCalendar();
// private static ScheduleManager instance;
//
// public static ScheduleManager getInstance(Context context) {
// if (instance == null) {
// instance = new ScheduleManager(context);
// }
// return instance;
// }
//
// public ScheduleManager(Context context) {
// mScheduleDatabase = new ScheduleDatabase(context);
// mStudentCalendar = new StudentCalendar();
// }
//
// public ArrayList<StudentGroup> getGroups() {
// return mScheduleDatabase.getGroups();
// }
//
// public void addSchedule(String groupId, ArrayList<Lesson> lessons) {
// mScheduleDatabase.addSchedule(lessons, groupId);
// }
//
// public Lesson[] getLessonsOfDay(String groupId, DateTime dayOfYear, int subgroup) {
// return mScheduleDatabase.getLessonsOfDay(groupId, dayOfYear, subgroup);
// }
//
// public void deleteSchedule(String groupId) {
// mScheduleDatabase.deleteSchedule(groupId);
// }
//
// public boolean isLessonsEndToday(String groupId, int subgroup) {
// DateTime currentTime = new DateTime();
// Lesson[] lessons = mScheduleDatabase.getLessonsOfDay(groupId, DateTime.now(), subgroup);
// if (lessons.length > 0) {
// Lesson lesson = lessons[lessons.length - 1];
//
// DateTimeFormatter formatter = DateTimeFormat.forPattern("HH:mm");
// DateTime dt = formatter.parseDateTime(getFinishTimeOfLesson(lesson));
// if (currentTime.getHourOfDay() + 1 > dt.getHourOfDay()) {
// return true;
// }
// } else {
// return true;
// }
// return false;
// }
//
// private String getFinishTimeOfLesson(Lesson lesson) {
// String time = lesson.fields.get("timePeriod");
// char c = '-';
// int pos = -1;
// while (time.charAt(++pos) != c) ;
// String result = time.substring(pos + 1, time.length());
// return result;
// }
// }
//
// Path: app/src/ru/bsuirhelper/android/core/schedule/ScheduleParser.java
// public class ScheduleParser {
//
// public static ArrayList<Lesson> parseXmlSchedule(File xmlFile) {
// DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
// DocumentBuilder dBuilder;
// Document doc = null;
// try {
// dBuilder = dbFactory.newDocumentBuilder();
// doc = dBuilder.parse(xmlFile);
// } catch (Exception e) {
// e.printStackTrace();
// }
// doc.getDocumentElement().normalize();
//
// NodeList list = doc.getElementsByTagName("ROW");
// ArrayList<Lesson> lessons = new ArrayList<Lesson>();
// for (int i = 0; i < list.getLength(); i++) {
// Lesson lesson = new Lesson();
// Element element = (Element) list.item(i);
// NamedNodeMap attrs = element.getAttributes();
// for (int j = 0; j < attrs.getLength(); j++) {
// Node attribute = attrs.item(j);
// //In xml file attribute name group, but group it is keyword of sqlite
// if (attribute.getNodeName().equals("group")) {
// lesson.fields.put("s_group", attribute.getNodeValue());
// continue;
// }
// lesson.fields.put(attribute.getNodeName(), attribute.getNodeValue());
// }
// lessons.add(lesson);
// }
// return lessons;
// }
// }
|
import android.app.ProgressDialog;
import android.content.Context;
import android.os.AsyncTask;
import android.support.v4.app.Fragment;
import android.widget.Toast;
import ru.bsuirhelper.android.core.schedule.Lesson;
import ru.bsuirhelper.android.core.schedule.ScheduleManager;
import ru.bsuirhelper.android.core.schedule.ScheduleParser;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.ArrayList;
|
while ((count = input.read(data)) != -1) {
output.write(data, 0, count);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (output != null)
output.close();
if (input != null)
input.close();
} catch (IOException e) {
e.printStackTrace();
}
if (connection != null)
connection.disconnect();
}
return new File(context.getApplicationContext().getFilesDir() + "/" + TEMP_FILE_NAME);
}
@Override
protected String doInBackground(String... urls) {
String groupId = urls[0];
File xmlFile = downloadScheduleFromInternet(groupId);
if (xmlFile == null) {
return ERROR;
}
|
// Path: app/src/ru/bsuirhelper/android/core/schedule/Lesson.java
// public class Lesson {
// public final HashMap<String, String> fields = new HashMap<String, String>();
// public int id;
//
// public Lesson() {
// fields.put("faculty", "");
// fields.put("year", "");
// fields.put("course", "");
// fields.put("term", "");
// fields.put("stream", "");
// fields.put("s_group", "");
// fields.put("subgroup", "");
// fields.put("weekDay", "");
// fields.put("timePeriod", "");
// fields.put("weekList", "");
// fields.put("subject", "");
// fields.put("subjectType", "");
// fields.put("auditorium", "");
// fields.put("teacher", "");
// fields.put("date", "");
// fields.put("timePeriodStart", "");
// fields.put("timePeriodEnd", "");
// }
// }
//
// Path: app/src/ru/bsuirhelper/android/core/schedule/ScheduleManager.java
// public class ScheduleManager {
// private final ScheduleDatabase mScheduleDatabase;
// private StudentCalendar mStudentCalendar = new StudentCalendar();
// private static ScheduleManager instance;
//
// public static ScheduleManager getInstance(Context context) {
// if (instance == null) {
// instance = new ScheduleManager(context);
// }
// return instance;
// }
//
// public ScheduleManager(Context context) {
// mScheduleDatabase = new ScheduleDatabase(context);
// mStudentCalendar = new StudentCalendar();
// }
//
// public ArrayList<StudentGroup> getGroups() {
// return mScheduleDatabase.getGroups();
// }
//
// public void addSchedule(String groupId, ArrayList<Lesson> lessons) {
// mScheduleDatabase.addSchedule(lessons, groupId);
// }
//
// public Lesson[] getLessonsOfDay(String groupId, DateTime dayOfYear, int subgroup) {
// return mScheduleDatabase.getLessonsOfDay(groupId, dayOfYear, subgroup);
// }
//
// public void deleteSchedule(String groupId) {
// mScheduleDatabase.deleteSchedule(groupId);
// }
//
// public boolean isLessonsEndToday(String groupId, int subgroup) {
// DateTime currentTime = new DateTime();
// Lesson[] lessons = mScheduleDatabase.getLessonsOfDay(groupId, DateTime.now(), subgroup);
// if (lessons.length > 0) {
// Lesson lesson = lessons[lessons.length - 1];
//
// DateTimeFormatter formatter = DateTimeFormat.forPattern("HH:mm");
// DateTime dt = formatter.parseDateTime(getFinishTimeOfLesson(lesson));
// if (currentTime.getHourOfDay() + 1 > dt.getHourOfDay()) {
// return true;
// }
// } else {
// return true;
// }
// return false;
// }
//
// private String getFinishTimeOfLesson(Lesson lesson) {
// String time = lesson.fields.get("timePeriod");
// char c = '-';
// int pos = -1;
// while (time.charAt(++pos) != c) ;
// String result = time.substring(pos + 1, time.length());
// return result;
// }
// }
//
// Path: app/src/ru/bsuirhelper/android/core/schedule/ScheduleParser.java
// public class ScheduleParser {
//
// public static ArrayList<Lesson> parseXmlSchedule(File xmlFile) {
// DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
// DocumentBuilder dBuilder;
// Document doc = null;
// try {
// dBuilder = dbFactory.newDocumentBuilder();
// doc = dBuilder.parse(xmlFile);
// } catch (Exception e) {
// e.printStackTrace();
// }
// doc.getDocumentElement().normalize();
//
// NodeList list = doc.getElementsByTagName("ROW");
// ArrayList<Lesson> lessons = new ArrayList<Lesson>();
// for (int i = 0; i < list.getLength(); i++) {
// Lesson lesson = new Lesson();
// Element element = (Element) list.item(i);
// NamedNodeMap attrs = element.getAttributes();
// for (int j = 0; j < attrs.getLength(); j++) {
// Node attribute = attrs.item(j);
// //In xml file attribute name group, but group it is keyword of sqlite
// if (attribute.getNodeName().equals("group")) {
// lesson.fields.put("s_group", attribute.getNodeValue());
// continue;
// }
// lesson.fields.put(attribute.getNodeName(), attribute.getNodeValue());
// }
// lessons.add(lesson);
// }
// return lessons;
// }
// }
// Path: app/src/ru/bsuirhelper/android/ui/DownloadScheduleTask.java
import android.app.ProgressDialog;
import android.content.Context;
import android.os.AsyncTask;
import android.support.v4.app.Fragment;
import android.widget.Toast;
import ru.bsuirhelper.android.core.schedule.Lesson;
import ru.bsuirhelper.android.core.schedule.ScheduleManager;
import ru.bsuirhelper.android.core.schedule.ScheduleParser;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.ArrayList;
while ((count = input.read(data)) != -1) {
output.write(data, 0, count);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (output != null)
output.close();
if (input != null)
input.close();
} catch (IOException e) {
e.printStackTrace();
}
if (connection != null)
connection.disconnect();
}
return new File(context.getApplicationContext().getFilesDir() + "/" + TEMP_FILE_NAME);
}
@Override
protected String doInBackground(String... urls) {
String groupId = urls[0];
File xmlFile = downloadScheduleFromInternet(groupId);
if (xmlFile == null) {
return ERROR;
}
|
ArrayList<Lesson> lessons = ScheduleParser.parseXmlSchedule(xmlFile);
|
BSUIR-Helper/helper-android
|
app/src/ru/bsuirhelper/android/core/schedule/ScheduleDatabase.java
|
// Path: app/src/ru/bsuirhelper/android/core/StudentCalendar.java
// public class StudentCalendar {
// private final DateTime mCurrentDateTime;
// private static int mDaysOfYear = 0;
// private static int mSemester;
//
// public StudentCalendar() {
// mCurrentDateTime = new DateTime();
// mDaysOfYear = getDaysOfYear();
//
// if (mCurrentDateTime.getMonthOfYear() >= 9) {
// mSemester = 1;
// } else {
// mSemester = 2;
// }
// }
//
// public int getDayOfYear() {
// int dayOfYear;
// if (mCurrentDateTime.getMonthOfYear() >= 9) {
// DateTime september = new DateTime(mCurrentDateTime.getYear(), 9, 1, 0, 0, 0);
// dayOfYear = new Interval(september, mCurrentDateTime).toPeriod(PeriodType.days()).getDays();
// } else {
// DateTime september = new DateTime(mCurrentDateTime.getYear() - 1, 9, 1, 0, 0, 0);
// dayOfYear = new Interval(september, mCurrentDateTime).toPeriod(PeriodType.days()).getDays();
// }
//
// return dayOfYear + 1;
// }
//
// public int getDayOfYear(DateTime dateTime) {
// int dayOfYear;
// if (dateTime.getMonthOfYear() >= 9) {
// DateTime september = new DateTime(dateTime.getYear(), 9, 1, 0, 0, 0);
// dayOfYear = new Interval(september, dateTime).toPeriod(PeriodType.days()).getDays();
// } else {
// DateTime september = new DateTime(dateTime.getYear() - 1, 9, 1, 0, 0, 0);
// dayOfYear = new Interval(september, dateTime).toPeriod(PeriodType.days()).getDays();
// }
// return dayOfYear;
// }
//
// public int getDaysOfYear() {
// if (mDaysOfYear == 0) {
// DateTime september;
// DateTime august;
//
// if (mCurrentDateTime.getMonthOfYear() <= 8) {
// september = new DateTime(mCurrentDateTime.getYear() - 1, 9, 1, 0, 0, 0);
// august = new DateTime(mCurrentDateTime.getYear(), 8, 31, 0, 0, 0);
// } else {
// september = new DateTime(mCurrentDateTime.getYear(), 8, 31, 0, 0, 0);
// august = new DateTime(mCurrentDateTime.getYear() + 1, 8, 31, 0, 0, 0);
// }
//
// mDaysOfYear = new Interval(september, august).toPeriod(PeriodType.days()).getDays();
// }
// return mDaysOfYear;
// }
//
// public static int getWorkWeek(DateTime dateTime) {
// DateTime september;
//
// if (dateTime.getMonthOfYear() <= 8) {
// september = new DateTime(dateTime.getYear() - 1, 9, 1, 0, 0, 0);
// } else {
// september = new DateTime(dateTime.getYear(), 9, 1, 0, 0, 0);
// }
//
// Interval interval = new Interval(september, dateTime);
// int workWeek = (interval.toPeriod(PeriodType.weeks()).getWeeks() + 2) % 4;
// workWeek = workWeek == 0 ? 4 : workWeek;
// return workWeek;
// }
//
// public static DateTime convertToDefaultDateTime(int studentDay) {
// DateTime september;
// int currentMonth = DateTime.now().getMonthOfYear();
// if (currentMonth <= 8) {
// september = new DateTime(DateTime.now().getYear() - 1, 9, 1, 0, 0, 0);
// } else {
// september = new DateTime(DateTime.now().getYear(), 9, 1, 0, 0, 0);
// }
// return september.plusDays(studentDay - 1);
// }
//
// public int getSemester() {
// return mSemester;
// }
//
// public static long getStartStudentYear() {
// DateTime september;
//
// if (DateTime.now().getMonthOfYear() <= 8) {
// september = new DateTime(DateTime.now().getYear() - 1, 9, 1, 0, 0, 0);
// } else {
// september = new DateTime(DateTime.now().getYear(), 8, 31, 1, 0, 0);
// }
//
// return september.getMillis();
// }
//
// public static long getEndStudentYear() {
// DateTime august;
// if (DateTime.now().getMonthOfYear() <= 8) {
// august = new DateTime(DateTime.now().getYear(), 8, 31, 1, 0, 0);
// } else {
// august = new DateTime(DateTime.now().getYear() + 1, 8, 31, 1, 0, 0);
// }
// return august.getMillis();
// }
//
// }
|
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import org.joda.time.DateTime;
import org.joda.time.DateTimeConstants;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;
import ru.bsuirhelper.android.core.StudentCalendar;
import java.util.ArrayList;
import java.util.Map;
|
}
@Override
public void onUpgrade(SQLiteDatabase sqLiteDatabase, int i, int i2) {
/*
sqLiteDatabase.execSQL("DROP TABLE IF EXISTS " + TABLE_COMMENTS);
onCreate(sqLiteDatabase);
*/
}
public ArrayList<Lesson> fetchAllLessons(String groupId) {
this.open();
String scheduleGroup = "schedule_" + groupId;
Cursor c = db.rawQuery("SELECT*FROM " + scheduleGroup, null);
ArrayList<Lesson> lessons = new ArrayList<Lesson>(c.getCount());
while (c.moveToNext()) {
Lesson lesson = new Lesson();
setDataFromCursor(lesson, c);
lessons.add(lesson);
}
this.close();
return lessons;
}
public Lesson[] getLessonsOfDay(String groupID, DateTime dayOfYear, int subgroup) {
String sWeekDay = "";
int weekDay = dayOfYear.getDayOfWeek();
|
// Path: app/src/ru/bsuirhelper/android/core/StudentCalendar.java
// public class StudentCalendar {
// private final DateTime mCurrentDateTime;
// private static int mDaysOfYear = 0;
// private static int mSemester;
//
// public StudentCalendar() {
// mCurrentDateTime = new DateTime();
// mDaysOfYear = getDaysOfYear();
//
// if (mCurrentDateTime.getMonthOfYear() >= 9) {
// mSemester = 1;
// } else {
// mSemester = 2;
// }
// }
//
// public int getDayOfYear() {
// int dayOfYear;
// if (mCurrentDateTime.getMonthOfYear() >= 9) {
// DateTime september = new DateTime(mCurrentDateTime.getYear(), 9, 1, 0, 0, 0);
// dayOfYear = new Interval(september, mCurrentDateTime).toPeriod(PeriodType.days()).getDays();
// } else {
// DateTime september = new DateTime(mCurrentDateTime.getYear() - 1, 9, 1, 0, 0, 0);
// dayOfYear = new Interval(september, mCurrentDateTime).toPeriod(PeriodType.days()).getDays();
// }
//
// return dayOfYear + 1;
// }
//
// public int getDayOfYear(DateTime dateTime) {
// int dayOfYear;
// if (dateTime.getMonthOfYear() >= 9) {
// DateTime september = new DateTime(dateTime.getYear(), 9, 1, 0, 0, 0);
// dayOfYear = new Interval(september, dateTime).toPeriod(PeriodType.days()).getDays();
// } else {
// DateTime september = new DateTime(dateTime.getYear() - 1, 9, 1, 0, 0, 0);
// dayOfYear = new Interval(september, dateTime).toPeriod(PeriodType.days()).getDays();
// }
// return dayOfYear;
// }
//
// public int getDaysOfYear() {
// if (mDaysOfYear == 0) {
// DateTime september;
// DateTime august;
//
// if (mCurrentDateTime.getMonthOfYear() <= 8) {
// september = new DateTime(mCurrentDateTime.getYear() - 1, 9, 1, 0, 0, 0);
// august = new DateTime(mCurrentDateTime.getYear(), 8, 31, 0, 0, 0);
// } else {
// september = new DateTime(mCurrentDateTime.getYear(), 8, 31, 0, 0, 0);
// august = new DateTime(mCurrentDateTime.getYear() + 1, 8, 31, 0, 0, 0);
// }
//
// mDaysOfYear = new Interval(september, august).toPeriod(PeriodType.days()).getDays();
// }
// return mDaysOfYear;
// }
//
// public static int getWorkWeek(DateTime dateTime) {
// DateTime september;
//
// if (dateTime.getMonthOfYear() <= 8) {
// september = new DateTime(dateTime.getYear() - 1, 9, 1, 0, 0, 0);
// } else {
// september = new DateTime(dateTime.getYear(), 9, 1, 0, 0, 0);
// }
//
// Interval interval = new Interval(september, dateTime);
// int workWeek = (interval.toPeriod(PeriodType.weeks()).getWeeks() + 2) % 4;
// workWeek = workWeek == 0 ? 4 : workWeek;
// return workWeek;
// }
//
// public static DateTime convertToDefaultDateTime(int studentDay) {
// DateTime september;
// int currentMonth = DateTime.now().getMonthOfYear();
// if (currentMonth <= 8) {
// september = new DateTime(DateTime.now().getYear() - 1, 9, 1, 0, 0, 0);
// } else {
// september = new DateTime(DateTime.now().getYear(), 9, 1, 0, 0, 0);
// }
// return september.plusDays(studentDay - 1);
// }
//
// public int getSemester() {
// return mSemester;
// }
//
// public static long getStartStudentYear() {
// DateTime september;
//
// if (DateTime.now().getMonthOfYear() <= 8) {
// september = new DateTime(DateTime.now().getYear() - 1, 9, 1, 0, 0, 0);
// } else {
// september = new DateTime(DateTime.now().getYear(), 8, 31, 1, 0, 0);
// }
//
// return september.getMillis();
// }
//
// public static long getEndStudentYear() {
// DateTime august;
// if (DateTime.now().getMonthOfYear() <= 8) {
// august = new DateTime(DateTime.now().getYear(), 8, 31, 1, 0, 0);
// } else {
// august = new DateTime(DateTime.now().getYear() + 1, 8, 31, 1, 0, 0);
// }
// return august.getMillis();
// }
//
// }
// Path: app/src/ru/bsuirhelper/android/core/schedule/ScheduleDatabase.java
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import org.joda.time.DateTime;
import org.joda.time.DateTimeConstants;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;
import ru.bsuirhelper.android.core.StudentCalendar;
import java.util.ArrayList;
import java.util.Map;
}
@Override
public void onUpgrade(SQLiteDatabase sqLiteDatabase, int i, int i2) {
/*
sqLiteDatabase.execSQL("DROP TABLE IF EXISTS " + TABLE_COMMENTS);
onCreate(sqLiteDatabase);
*/
}
public ArrayList<Lesson> fetchAllLessons(String groupId) {
this.open();
String scheduleGroup = "schedule_" + groupId;
Cursor c = db.rawQuery("SELECT*FROM " + scheduleGroup, null);
ArrayList<Lesson> lessons = new ArrayList<Lesson>(c.getCount());
while (c.moveToNext()) {
Lesson lesson = new Lesson();
setDataFromCursor(lesson, c);
lessons.add(lesson);
}
this.close();
return lessons;
}
public Lesson[] getLessonsOfDay(String groupID, DateTime dayOfYear, int subgroup) {
String sWeekDay = "";
int weekDay = dayOfYear.getDayOfWeek();
|
int workWeek = StudentCalendar.getWorkWeek(dayOfYear);
|
BSUIR-Helper/helper-android
|
app/src/ru/bsuirhelper/android/appwidget/ScheduleFactoryViews.java
|
// Path: app/src/ru/bsuirhelper/android/ApplicationSettings.java
// public class ApplicationSettings {
// private static ApplicationSettings instance;
// private static SharedPreferences settings;
// private static final String PREFS_NAME = "settings.txt";
//
// private ApplicationSettings(Context context) {
// settings = context.getSharedPreferences(PREFS_NAME, 1);
// }
//
// public static synchronized ApplicationSettings getInstance(Context context) {
// if (instance == null) {
// instance = new ApplicationSettings(context);
// }
// return instance;
// }
//
// public int getInt(String varName, int defaultValue) {
// return settings.getInt(varName, defaultValue);
// }
//
// public String getString(String varName, String defaultValue) {
// return settings.getString(varName, defaultValue);
// }
//
// public boolean getBoolean(String varName, boolean defaultValue) {
// return settings.getBoolean(varName, defaultValue);
// }
//
// public boolean putInt(String varName, int value) {
// return settings.edit().putInt(varName, value).commit();
// }
//
// public boolean putString(String varName, String value) {
// return settings.edit().putString(varName, value).commit();
// }
//
// public boolean putBoolean(String varName, boolean value) {
// return settings.edit().putBoolean(varName, value).commit();
// }
// }
//
// Path: app/src/ru/bsuirhelper/android/core/schedule/Lesson.java
// public class Lesson {
// public final HashMap<String, String> fields = new HashMap<String, String>();
// public int id;
//
// public Lesson() {
// fields.put("faculty", "");
// fields.put("year", "");
// fields.put("course", "");
// fields.put("term", "");
// fields.put("stream", "");
// fields.put("s_group", "");
// fields.put("subgroup", "");
// fields.put("weekDay", "");
// fields.put("timePeriod", "");
// fields.put("weekList", "");
// fields.put("subject", "");
// fields.put("subjectType", "");
// fields.put("auditorium", "");
// fields.put("teacher", "");
// fields.put("date", "");
// fields.put("timePeriodStart", "");
// fields.put("timePeriodEnd", "");
// }
// }
//
// Path: app/src/ru/bsuirhelper/android/core/schedule/ScheduleManager.java
// public class ScheduleManager {
// private final ScheduleDatabase mScheduleDatabase;
// private StudentCalendar mStudentCalendar = new StudentCalendar();
// private static ScheduleManager instance;
//
// public static ScheduleManager getInstance(Context context) {
// if (instance == null) {
// instance = new ScheduleManager(context);
// }
// return instance;
// }
//
// public ScheduleManager(Context context) {
// mScheduleDatabase = new ScheduleDatabase(context);
// mStudentCalendar = new StudentCalendar();
// }
//
// public ArrayList<StudentGroup> getGroups() {
// return mScheduleDatabase.getGroups();
// }
//
// public void addSchedule(String groupId, ArrayList<Lesson> lessons) {
// mScheduleDatabase.addSchedule(lessons, groupId);
// }
//
// public Lesson[] getLessonsOfDay(String groupId, DateTime dayOfYear, int subgroup) {
// return mScheduleDatabase.getLessonsOfDay(groupId, dayOfYear, subgroup);
// }
//
// public void deleteSchedule(String groupId) {
// mScheduleDatabase.deleteSchedule(groupId);
// }
//
// public boolean isLessonsEndToday(String groupId, int subgroup) {
// DateTime currentTime = new DateTime();
// Lesson[] lessons = mScheduleDatabase.getLessonsOfDay(groupId, DateTime.now(), subgroup);
// if (lessons.length > 0) {
// Lesson lesson = lessons[lessons.length - 1];
//
// DateTimeFormatter formatter = DateTimeFormat.forPattern("HH:mm");
// DateTime dt = formatter.parseDateTime(getFinishTimeOfLesson(lesson));
// if (currentTime.getHourOfDay() + 1 > dt.getHourOfDay()) {
// return true;
// }
// } else {
// return true;
// }
// return false;
// }
//
// private String getFinishTimeOfLesson(Lesson lesson) {
// String time = lesson.fields.get("timePeriod");
// char c = '-';
// int pos = -1;
// while (time.charAt(++pos) != c) ;
// String result = time.substring(pos + 1, time.length());
// return result;
// }
// }
|
import android.annotation.TargetApi;
import android.appwidget.AppWidgetManager;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.os.Build;
import android.widget.RemoteViews;
import android.widget.RemoteViewsService;
import org.joda.time.DateTime;
import ru.bsuirhelper.android.ApplicationSettings;
import ru.bsuirhelper.android.R;
import ru.bsuirhelper.android.core.schedule.Lesson;
import ru.bsuirhelper.android.core.schedule.ScheduleManager;
|
package ru.bsuirhelper.android.appwidget;
/**
* Created by Влад on 15.10.13.
*/
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
class ScheduleFactoryViews implements RemoteViewsService.RemoteViewsFactory {
|
// Path: app/src/ru/bsuirhelper/android/ApplicationSettings.java
// public class ApplicationSettings {
// private static ApplicationSettings instance;
// private static SharedPreferences settings;
// private static final String PREFS_NAME = "settings.txt";
//
// private ApplicationSettings(Context context) {
// settings = context.getSharedPreferences(PREFS_NAME, 1);
// }
//
// public static synchronized ApplicationSettings getInstance(Context context) {
// if (instance == null) {
// instance = new ApplicationSettings(context);
// }
// return instance;
// }
//
// public int getInt(String varName, int defaultValue) {
// return settings.getInt(varName, defaultValue);
// }
//
// public String getString(String varName, String defaultValue) {
// return settings.getString(varName, defaultValue);
// }
//
// public boolean getBoolean(String varName, boolean defaultValue) {
// return settings.getBoolean(varName, defaultValue);
// }
//
// public boolean putInt(String varName, int value) {
// return settings.edit().putInt(varName, value).commit();
// }
//
// public boolean putString(String varName, String value) {
// return settings.edit().putString(varName, value).commit();
// }
//
// public boolean putBoolean(String varName, boolean value) {
// return settings.edit().putBoolean(varName, value).commit();
// }
// }
//
// Path: app/src/ru/bsuirhelper/android/core/schedule/Lesson.java
// public class Lesson {
// public final HashMap<String, String> fields = new HashMap<String, String>();
// public int id;
//
// public Lesson() {
// fields.put("faculty", "");
// fields.put("year", "");
// fields.put("course", "");
// fields.put("term", "");
// fields.put("stream", "");
// fields.put("s_group", "");
// fields.put("subgroup", "");
// fields.put("weekDay", "");
// fields.put("timePeriod", "");
// fields.put("weekList", "");
// fields.put("subject", "");
// fields.put("subjectType", "");
// fields.put("auditorium", "");
// fields.put("teacher", "");
// fields.put("date", "");
// fields.put("timePeriodStart", "");
// fields.put("timePeriodEnd", "");
// }
// }
//
// Path: app/src/ru/bsuirhelper/android/core/schedule/ScheduleManager.java
// public class ScheduleManager {
// private final ScheduleDatabase mScheduleDatabase;
// private StudentCalendar mStudentCalendar = new StudentCalendar();
// private static ScheduleManager instance;
//
// public static ScheduleManager getInstance(Context context) {
// if (instance == null) {
// instance = new ScheduleManager(context);
// }
// return instance;
// }
//
// public ScheduleManager(Context context) {
// mScheduleDatabase = new ScheduleDatabase(context);
// mStudentCalendar = new StudentCalendar();
// }
//
// public ArrayList<StudentGroup> getGroups() {
// return mScheduleDatabase.getGroups();
// }
//
// public void addSchedule(String groupId, ArrayList<Lesson> lessons) {
// mScheduleDatabase.addSchedule(lessons, groupId);
// }
//
// public Lesson[] getLessonsOfDay(String groupId, DateTime dayOfYear, int subgroup) {
// return mScheduleDatabase.getLessonsOfDay(groupId, dayOfYear, subgroup);
// }
//
// public void deleteSchedule(String groupId) {
// mScheduleDatabase.deleteSchedule(groupId);
// }
//
// public boolean isLessonsEndToday(String groupId, int subgroup) {
// DateTime currentTime = new DateTime();
// Lesson[] lessons = mScheduleDatabase.getLessonsOfDay(groupId, DateTime.now(), subgroup);
// if (lessons.length > 0) {
// Lesson lesson = lessons[lessons.length - 1];
//
// DateTimeFormatter formatter = DateTimeFormat.forPattern("HH:mm");
// DateTime dt = formatter.parseDateTime(getFinishTimeOfLesson(lesson));
// if (currentTime.getHourOfDay() + 1 > dt.getHourOfDay()) {
// return true;
// }
// } else {
// return true;
// }
// return false;
// }
//
// private String getFinishTimeOfLesson(Lesson lesson) {
// String time = lesson.fields.get("timePeriod");
// char c = '-';
// int pos = -1;
// while (time.charAt(++pos) != c) ;
// String result = time.substring(pos + 1, time.length());
// return result;
// }
// }
// Path: app/src/ru/bsuirhelper/android/appwidget/ScheduleFactoryViews.java
import android.annotation.TargetApi;
import android.appwidget.AppWidgetManager;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.os.Build;
import android.widget.RemoteViews;
import android.widget.RemoteViewsService;
import org.joda.time.DateTime;
import ru.bsuirhelper.android.ApplicationSettings;
import ru.bsuirhelper.android.R;
import ru.bsuirhelper.android.core.schedule.Lesson;
import ru.bsuirhelper.android.core.schedule.ScheduleManager;
package ru.bsuirhelper.android.appwidget;
/**
* Created by Влад on 15.10.13.
*/
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
class ScheduleFactoryViews implements RemoteViewsService.RemoteViewsFactory {
|
private final ScheduleManager mScheduleManager;
|
BSUIR-Helper/helper-android
|
app/src/ru/bsuirhelper/android/appwidget/ScheduleFactoryViews.java
|
// Path: app/src/ru/bsuirhelper/android/ApplicationSettings.java
// public class ApplicationSettings {
// private static ApplicationSettings instance;
// private static SharedPreferences settings;
// private static final String PREFS_NAME = "settings.txt";
//
// private ApplicationSettings(Context context) {
// settings = context.getSharedPreferences(PREFS_NAME, 1);
// }
//
// public static synchronized ApplicationSettings getInstance(Context context) {
// if (instance == null) {
// instance = new ApplicationSettings(context);
// }
// return instance;
// }
//
// public int getInt(String varName, int defaultValue) {
// return settings.getInt(varName, defaultValue);
// }
//
// public String getString(String varName, String defaultValue) {
// return settings.getString(varName, defaultValue);
// }
//
// public boolean getBoolean(String varName, boolean defaultValue) {
// return settings.getBoolean(varName, defaultValue);
// }
//
// public boolean putInt(String varName, int value) {
// return settings.edit().putInt(varName, value).commit();
// }
//
// public boolean putString(String varName, String value) {
// return settings.edit().putString(varName, value).commit();
// }
//
// public boolean putBoolean(String varName, boolean value) {
// return settings.edit().putBoolean(varName, value).commit();
// }
// }
//
// Path: app/src/ru/bsuirhelper/android/core/schedule/Lesson.java
// public class Lesson {
// public final HashMap<String, String> fields = new HashMap<String, String>();
// public int id;
//
// public Lesson() {
// fields.put("faculty", "");
// fields.put("year", "");
// fields.put("course", "");
// fields.put("term", "");
// fields.put("stream", "");
// fields.put("s_group", "");
// fields.put("subgroup", "");
// fields.put("weekDay", "");
// fields.put("timePeriod", "");
// fields.put("weekList", "");
// fields.put("subject", "");
// fields.put("subjectType", "");
// fields.put("auditorium", "");
// fields.put("teacher", "");
// fields.put("date", "");
// fields.put("timePeriodStart", "");
// fields.put("timePeriodEnd", "");
// }
// }
//
// Path: app/src/ru/bsuirhelper/android/core/schedule/ScheduleManager.java
// public class ScheduleManager {
// private final ScheduleDatabase mScheduleDatabase;
// private StudentCalendar mStudentCalendar = new StudentCalendar();
// private static ScheduleManager instance;
//
// public static ScheduleManager getInstance(Context context) {
// if (instance == null) {
// instance = new ScheduleManager(context);
// }
// return instance;
// }
//
// public ScheduleManager(Context context) {
// mScheduleDatabase = new ScheduleDatabase(context);
// mStudentCalendar = new StudentCalendar();
// }
//
// public ArrayList<StudentGroup> getGroups() {
// return mScheduleDatabase.getGroups();
// }
//
// public void addSchedule(String groupId, ArrayList<Lesson> lessons) {
// mScheduleDatabase.addSchedule(lessons, groupId);
// }
//
// public Lesson[] getLessonsOfDay(String groupId, DateTime dayOfYear, int subgroup) {
// return mScheduleDatabase.getLessonsOfDay(groupId, dayOfYear, subgroup);
// }
//
// public void deleteSchedule(String groupId) {
// mScheduleDatabase.deleteSchedule(groupId);
// }
//
// public boolean isLessonsEndToday(String groupId, int subgroup) {
// DateTime currentTime = new DateTime();
// Lesson[] lessons = mScheduleDatabase.getLessonsOfDay(groupId, DateTime.now(), subgroup);
// if (lessons.length > 0) {
// Lesson lesson = lessons[lessons.length - 1];
//
// DateTimeFormatter formatter = DateTimeFormat.forPattern("HH:mm");
// DateTime dt = formatter.parseDateTime(getFinishTimeOfLesson(lesson));
// if (currentTime.getHourOfDay() + 1 > dt.getHourOfDay()) {
// return true;
// }
// } else {
// return true;
// }
// return false;
// }
//
// private String getFinishTimeOfLesson(Lesson lesson) {
// String time = lesson.fields.get("timePeriod");
// char c = '-';
// int pos = -1;
// while (time.charAt(++pos) != c) ;
// String result = time.substring(pos + 1, time.length());
// return result;
// }
// }
|
import android.annotation.TargetApi;
import android.appwidget.AppWidgetManager;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.os.Build;
import android.widget.RemoteViews;
import android.widget.RemoteViewsService;
import org.joda.time.DateTime;
import ru.bsuirhelper.android.ApplicationSettings;
import ru.bsuirhelper.android.R;
import ru.bsuirhelper.android.core.schedule.Lesson;
import ru.bsuirhelper.android.core.schedule.ScheduleManager;
|
package ru.bsuirhelper.android.appwidget;
/**
* Created by Влад on 15.10.13.
*/
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
class ScheduleFactoryViews implements RemoteViewsService.RemoteViewsFactory {
private final ScheduleManager mScheduleManager;
|
// Path: app/src/ru/bsuirhelper/android/ApplicationSettings.java
// public class ApplicationSettings {
// private static ApplicationSettings instance;
// private static SharedPreferences settings;
// private static final String PREFS_NAME = "settings.txt";
//
// private ApplicationSettings(Context context) {
// settings = context.getSharedPreferences(PREFS_NAME, 1);
// }
//
// public static synchronized ApplicationSettings getInstance(Context context) {
// if (instance == null) {
// instance = new ApplicationSettings(context);
// }
// return instance;
// }
//
// public int getInt(String varName, int defaultValue) {
// return settings.getInt(varName, defaultValue);
// }
//
// public String getString(String varName, String defaultValue) {
// return settings.getString(varName, defaultValue);
// }
//
// public boolean getBoolean(String varName, boolean defaultValue) {
// return settings.getBoolean(varName, defaultValue);
// }
//
// public boolean putInt(String varName, int value) {
// return settings.edit().putInt(varName, value).commit();
// }
//
// public boolean putString(String varName, String value) {
// return settings.edit().putString(varName, value).commit();
// }
//
// public boolean putBoolean(String varName, boolean value) {
// return settings.edit().putBoolean(varName, value).commit();
// }
// }
//
// Path: app/src/ru/bsuirhelper/android/core/schedule/Lesson.java
// public class Lesson {
// public final HashMap<String, String> fields = new HashMap<String, String>();
// public int id;
//
// public Lesson() {
// fields.put("faculty", "");
// fields.put("year", "");
// fields.put("course", "");
// fields.put("term", "");
// fields.put("stream", "");
// fields.put("s_group", "");
// fields.put("subgroup", "");
// fields.put("weekDay", "");
// fields.put("timePeriod", "");
// fields.put("weekList", "");
// fields.put("subject", "");
// fields.put("subjectType", "");
// fields.put("auditorium", "");
// fields.put("teacher", "");
// fields.put("date", "");
// fields.put("timePeriodStart", "");
// fields.put("timePeriodEnd", "");
// }
// }
//
// Path: app/src/ru/bsuirhelper/android/core/schedule/ScheduleManager.java
// public class ScheduleManager {
// private final ScheduleDatabase mScheduleDatabase;
// private StudentCalendar mStudentCalendar = new StudentCalendar();
// private static ScheduleManager instance;
//
// public static ScheduleManager getInstance(Context context) {
// if (instance == null) {
// instance = new ScheduleManager(context);
// }
// return instance;
// }
//
// public ScheduleManager(Context context) {
// mScheduleDatabase = new ScheduleDatabase(context);
// mStudentCalendar = new StudentCalendar();
// }
//
// public ArrayList<StudentGroup> getGroups() {
// return mScheduleDatabase.getGroups();
// }
//
// public void addSchedule(String groupId, ArrayList<Lesson> lessons) {
// mScheduleDatabase.addSchedule(lessons, groupId);
// }
//
// public Lesson[] getLessonsOfDay(String groupId, DateTime dayOfYear, int subgroup) {
// return mScheduleDatabase.getLessonsOfDay(groupId, dayOfYear, subgroup);
// }
//
// public void deleteSchedule(String groupId) {
// mScheduleDatabase.deleteSchedule(groupId);
// }
//
// public boolean isLessonsEndToday(String groupId, int subgroup) {
// DateTime currentTime = new DateTime();
// Lesson[] lessons = mScheduleDatabase.getLessonsOfDay(groupId, DateTime.now(), subgroup);
// if (lessons.length > 0) {
// Lesson lesson = lessons[lessons.length - 1];
//
// DateTimeFormatter formatter = DateTimeFormat.forPattern("HH:mm");
// DateTime dt = formatter.parseDateTime(getFinishTimeOfLesson(lesson));
// if (currentTime.getHourOfDay() + 1 > dt.getHourOfDay()) {
// return true;
// }
// } else {
// return true;
// }
// return false;
// }
//
// private String getFinishTimeOfLesson(Lesson lesson) {
// String time = lesson.fields.get("timePeriod");
// char c = '-';
// int pos = -1;
// while (time.charAt(++pos) != c) ;
// String result = time.substring(pos + 1, time.length());
// return result;
// }
// }
// Path: app/src/ru/bsuirhelper/android/appwidget/ScheduleFactoryViews.java
import android.annotation.TargetApi;
import android.appwidget.AppWidgetManager;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.os.Build;
import android.widget.RemoteViews;
import android.widget.RemoteViewsService;
import org.joda.time.DateTime;
import ru.bsuirhelper.android.ApplicationSettings;
import ru.bsuirhelper.android.R;
import ru.bsuirhelper.android.core.schedule.Lesson;
import ru.bsuirhelper.android.core.schedule.ScheduleManager;
package ru.bsuirhelper.android.appwidget;
/**
* Created by Влад on 15.10.13.
*/
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
class ScheduleFactoryViews implements RemoteViewsService.RemoteViewsFactory {
private final ScheduleManager mScheduleManager;
|
private Lesson[] mLessons;
|
BSUIR-Helper/helper-android
|
app/src/ru/bsuirhelper/android/appwidget/ScheduleFactoryViews.java
|
// Path: app/src/ru/bsuirhelper/android/ApplicationSettings.java
// public class ApplicationSettings {
// private static ApplicationSettings instance;
// private static SharedPreferences settings;
// private static final String PREFS_NAME = "settings.txt";
//
// private ApplicationSettings(Context context) {
// settings = context.getSharedPreferences(PREFS_NAME, 1);
// }
//
// public static synchronized ApplicationSettings getInstance(Context context) {
// if (instance == null) {
// instance = new ApplicationSettings(context);
// }
// return instance;
// }
//
// public int getInt(String varName, int defaultValue) {
// return settings.getInt(varName, defaultValue);
// }
//
// public String getString(String varName, String defaultValue) {
// return settings.getString(varName, defaultValue);
// }
//
// public boolean getBoolean(String varName, boolean defaultValue) {
// return settings.getBoolean(varName, defaultValue);
// }
//
// public boolean putInt(String varName, int value) {
// return settings.edit().putInt(varName, value).commit();
// }
//
// public boolean putString(String varName, String value) {
// return settings.edit().putString(varName, value).commit();
// }
//
// public boolean putBoolean(String varName, boolean value) {
// return settings.edit().putBoolean(varName, value).commit();
// }
// }
//
// Path: app/src/ru/bsuirhelper/android/core/schedule/Lesson.java
// public class Lesson {
// public final HashMap<String, String> fields = new HashMap<String, String>();
// public int id;
//
// public Lesson() {
// fields.put("faculty", "");
// fields.put("year", "");
// fields.put("course", "");
// fields.put("term", "");
// fields.put("stream", "");
// fields.put("s_group", "");
// fields.put("subgroup", "");
// fields.put("weekDay", "");
// fields.put("timePeriod", "");
// fields.put("weekList", "");
// fields.put("subject", "");
// fields.put("subjectType", "");
// fields.put("auditorium", "");
// fields.put("teacher", "");
// fields.put("date", "");
// fields.put("timePeriodStart", "");
// fields.put("timePeriodEnd", "");
// }
// }
//
// Path: app/src/ru/bsuirhelper/android/core/schedule/ScheduleManager.java
// public class ScheduleManager {
// private final ScheduleDatabase mScheduleDatabase;
// private StudentCalendar mStudentCalendar = new StudentCalendar();
// private static ScheduleManager instance;
//
// public static ScheduleManager getInstance(Context context) {
// if (instance == null) {
// instance = new ScheduleManager(context);
// }
// return instance;
// }
//
// public ScheduleManager(Context context) {
// mScheduleDatabase = new ScheduleDatabase(context);
// mStudentCalendar = new StudentCalendar();
// }
//
// public ArrayList<StudentGroup> getGroups() {
// return mScheduleDatabase.getGroups();
// }
//
// public void addSchedule(String groupId, ArrayList<Lesson> lessons) {
// mScheduleDatabase.addSchedule(lessons, groupId);
// }
//
// public Lesson[] getLessonsOfDay(String groupId, DateTime dayOfYear, int subgroup) {
// return mScheduleDatabase.getLessonsOfDay(groupId, dayOfYear, subgroup);
// }
//
// public void deleteSchedule(String groupId) {
// mScheduleDatabase.deleteSchedule(groupId);
// }
//
// public boolean isLessonsEndToday(String groupId, int subgroup) {
// DateTime currentTime = new DateTime();
// Lesson[] lessons = mScheduleDatabase.getLessonsOfDay(groupId, DateTime.now(), subgroup);
// if (lessons.length > 0) {
// Lesson lesson = lessons[lessons.length - 1];
//
// DateTimeFormatter formatter = DateTimeFormat.forPattern("HH:mm");
// DateTime dt = formatter.parseDateTime(getFinishTimeOfLesson(lesson));
// if (currentTime.getHourOfDay() + 1 > dt.getHourOfDay()) {
// return true;
// }
// } else {
// return true;
// }
// return false;
// }
//
// private String getFinishTimeOfLesson(Lesson lesson) {
// String time = lesson.fields.get("timePeriod");
// char c = '-';
// int pos = -1;
// while (time.charAt(++pos) != c) ;
// String result = time.substring(pos + 1, time.length());
// return result;
// }
// }
|
import android.annotation.TargetApi;
import android.appwidget.AppWidgetManager;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.os.Build;
import android.widget.RemoteViews;
import android.widget.RemoteViewsService;
import org.joda.time.DateTime;
import ru.bsuirhelper.android.ApplicationSettings;
import ru.bsuirhelper.android.R;
import ru.bsuirhelper.android.core.schedule.Lesson;
import ru.bsuirhelper.android.core.schedule.ScheduleManager;
|
package ru.bsuirhelper.android.appwidget;
/**
* Created by Влад on 15.10.13.
*/
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
class ScheduleFactoryViews implements RemoteViewsService.RemoteViewsFactory {
private final ScheduleManager mScheduleManager;
private Lesson[] mLessons;
private final Context mContext;
private final Intent mIntent;
private final int mWidgetId;
private int mLessonCount;
|
// Path: app/src/ru/bsuirhelper/android/ApplicationSettings.java
// public class ApplicationSettings {
// private static ApplicationSettings instance;
// private static SharedPreferences settings;
// private static final String PREFS_NAME = "settings.txt";
//
// private ApplicationSettings(Context context) {
// settings = context.getSharedPreferences(PREFS_NAME, 1);
// }
//
// public static synchronized ApplicationSettings getInstance(Context context) {
// if (instance == null) {
// instance = new ApplicationSettings(context);
// }
// return instance;
// }
//
// public int getInt(String varName, int defaultValue) {
// return settings.getInt(varName, defaultValue);
// }
//
// public String getString(String varName, String defaultValue) {
// return settings.getString(varName, defaultValue);
// }
//
// public boolean getBoolean(String varName, boolean defaultValue) {
// return settings.getBoolean(varName, defaultValue);
// }
//
// public boolean putInt(String varName, int value) {
// return settings.edit().putInt(varName, value).commit();
// }
//
// public boolean putString(String varName, String value) {
// return settings.edit().putString(varName, value).commit();
// }
//
// public boolean putBoolean(String varName, boolean value) {
// return settings.edit().putBoolean(varName, value).commit();
// }
// }
//
// Path: app/src/ru/bsuirhelper/android/core/schedule/Lesson.java
// public class Lesson {
// public final HashMap<String, String> fields = new HashMap<String, String>();
// public int id;
//
// public Lesson() {
// fields.put("faculty", "");
// fields.put("year", "");
// fields.put("course", "");
// fields.put("term", "");
// fields.put("stream", "");
// fields.put("s_group", "");
// fields.put("subgroup", "");
// fields.put("weekDay", "");
// fields.put("timePeriod", "");
// fields.put("weekList", "");
// fields.put("subject", "");
// fields.put("subjectType", "");
// fields.put("auditorium", "");
// fields.put("teacher", "");
// fields.put("date", "");
// fields.put("timePeriodStart", "");
// fields.put("timePeriodEnd", "");
// }
// }
//
// Path: app/src/ru/bsuirhelper/android/core/schedule/ScheduleManager.java
// public class ScheduleManager {
// private final ScheduleDatabase mScheduleDatabase;
// private StudentCalendar mStudentCalendar = new StudentCalendar();
// private static ScheduleManager instance;
//
// public static ScheduleManager getInstance(Context context) {
// if (instance == null) {
// instance = new ScheduleManager(context);
// }
// return instance;
// }
//
// public ScheduleManager(Context context) {
// mScheduleDatabase = new ScheduleDatabase(context);
// mStudentCalendar = new StudentCalendar();
// }
//
// public ArrayList<StudentGroup> getGroups() {
// return mScheduleDatabase.getGroups();
// }
//
// public void addSchedule(String groupId, ArrayList<Lesson> lessons) {
// mScheduleDatabase.addSchedule(lessons, groupId);
// }
//
// public Lesson[] getLessonsOfDay(String groupId, DateTime dayOfYear, int subgroup) {
// return mScheduleDatabase.getLessonsOfDay(groupId, dayOfYear, subgroup);
// }
//
// public void deleteSchedule(String groupId) {
// mScheduleDatabase.deleteSchedule(groupId);
// }
//
// public boolean isLessonsEndToday(String groupId, int subgroup) {
// DateTime currentTime = new DateTime();
// Lesson[] lessons = mScheduleDatabase.getLessonsOfDay(groupId, DateTime.now(), subgroup);
// if (lessons.length > 0) {
// Lesson lesson = lessons[lessons.length - 1];
//
// DateTimeFormatter formatter = DateTimeFormat.forPattern("HH:mm");
// DateTime dt = formatter.parseDateTime(getFinishTimeOfLesson(lesson));
// if (currentTime.getHourOfDay() + 1 > dt.getHourOfDay()) {
// return true;
// }
// } else {
// return true;
// }
// return false;
// }
//
// private String getFinishTimeOfLesson(Lesson lesson) {
// String time = lesson.fields.get("timePeriod");
// char c = '-';
// int pos = -1;
// while (time.charAt(++pos) != c) ;
// String result = time.substring(pos + 1, time.length());
// return result;
// }
// }
// Path: app/src/ru/bsuirhelper/android/appwidget/ScheduleFactoryViews.java
import android.annotation.TargetApi;
import android.appwidget.AppWidgetManager;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.os.Build;
import android.widget.RemoteViews;
import android.widget.RemoteViewsService;
import org.joda.time.DateTime;
import ru.bsuirhelper.android.ApplicationSettings;
import ru.bsuirhelper.android.R;
import ru.bsuirhelper.android.core.schedule.Lesson;
import ru.bsuirhelper.android.core.schedule.ScheduleManager;
package ru.bsuirhelper.android.appwidget;
/**
* Created by Влад on 15.10.13.
*/
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
class ScheduleFactoryViews implements RemoteViewsService.RemoteViewsFactory {
private final ScheduleManager mScheduleManager;
private Lesson[] mLessons;
private final Context mContext;
private final Intent mIntent;
private final int mWidgetId;
private int mLessonCount;
|
private final ApplicationSettings mSettings;
|
BSUIR-Helper/helper-android
|
app/src/ru/bsuirhelper/android/core/schedule/ScheduleManager.java
|
// Path: app/src/ru/bsuirhelper/android/core/StudentCalendar.java
// public class StudentCalendar {
// private final DateTime mCurrentDateTime;
// private static int mDaysOfYear = 0;
// private static int mSemester;
//
// public StudentCalendar() {
// mCurrentDateTime = new DateTime();
// mDaysOfYear = getDaysOfYear();
//
// if (mCurrentDateTime.getMonthOfYear() >= 9) {
// mSemester = 1;
// } else {
// mSemester = 2;
// }
// }
//
// public int getDayOfYear() {
// int dayOfYear;
// if (mCurrentDateTime.getMonthOfYear() >= 9) {
// DateTime september = new DateTime(mCurrentDateTime.getYear(), 9, 1, 0, 0, 0);
// dayOfYear = new Interval(september, mCurrentDateTime).toPeriod(PeriodType.days()).getDays();
// } else {
// DateTime september = new DateTime(mCurrentDateTime.getYear() - 1, 9, 1, 0, 0, 0);
// dayOfYear = new Interval(september, mCurrentDateTime).toPeriod(PeriodType.days()).getDays();
// }
//
// return dayOfYear + 1;
// }
//
// public int getDayOfYear(DateTime dateTime) {
// int dayOfYear;
// if (dateTime.getMonthOfYear() >= 9) {
// DateTime september = new DateTime(dateTime.getYear(), 9, 1, 0, 0, 0);
// dayOfYear = new Interval(september, dateTime).toPeriod(PeriodType.days()).getDays();
// } else {
// DateTime september = new DateTime(dateTime.getYear() - 1, 9, 1, 0, 0, 0);
// dayOfYear = new Interval(september, dateTime).toPeriod(PeriodType.days()).getDays();
// }
// return dayOfYear;
// }
//
// public int getDaysOfYear() {
// if (mDaysOfYear == 0) {
// DateTime september;
// DateTime august;
//
// if (mCurrentDateTime.getMonthOfYear() <= 8) {
// september = new DateTime(mCurrentDateTime.getYear() - 1, 9, 1, 0, 0, 0);
// august = new DateTime(mCurrentDateTime.getYear(), 8, 31, 0, 0, 0);
// } else {
// september = new DateTime(mCurrentDateTime.getYear(), 8, 31, 0, 0, 0);
// august = new DateTime(mCurrentDateTime.getYear() + 1, 8, 31, 0, 0, 0);
// }
//
// mDaysOfYear = new Interval(september, august).toPeriod(PeriodType.days()).getDays();
// }
// return mDaysOfYear;
// }
//
// public static int getWorkWeek(DateTime dateTime) {
// DateTime september;
//
// if (dateTime.getMonthOfYear() <= 8) {
// september = new DateTime(dateTime.getYear() - 1, 9, 1, 0, 0, 0);
// } else {
// september = new DateTime(dateTime.getYear(), 9, 1, 0, 0, 0);
// }
//
// Interval interval = new Interval(september, dateTime);
// int workWeek = (interval.toPeriod(PeriodType.weeks()).getWeeks() + 2) % 4;
// workWeek = workWeek == 0 ? 4 : workWeek;
// return workWeek;
// }
//
// public static DateTime convertToDefaultDateTime(int studentDay) {
// DateTime september;
// int currentMonth = DateTime.now().getMonthOfYear();
// if (currentMonth <= 8) {
// september = new DateTime(DateTime.now().getYear() - 1, 9, 1, 0, 0, 0);
// } else {
// september = new DateTime(DateTime.now().getYear(), 9, 1, 0, 0, 0);
// }
// return september.plusDays(studentDay - 1);
// }
//
// public int getSemester() {
// return mSemester;
// }
//
// public static long getStartStudentYear() {
// DateTime september;
//
// if (DateTime.now().getMonthOfYear() <= 8) {
// september = new DateTime(DateTime.now().getYear() - 1, 9, 1, 0, 0, 0);
// } else {
// september = new DateTime(DateTime.now().getYear(), 8, 31, 1, 0, 0);
// }
//
// return september.getMillis();
// }
//
// public static long getEndStudentYear() {
// DateTime august;
// if (DateTime.now().getMonthOfYear() <= 8) {
// august = new DateTime(DateTime.now().getYear(), 8, 31, 1, 0, 0);
// } else {
// august = new DateTime(DateTime.now().getYear() + 1, 8, 31, 1, 0, 0);
// }
// return august.getMillis();
// }
//
// }
|
import android.content.Context;
import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;
import ru.bsuirhelper.android.core.StudentCalendar;
import java.util.ArrayList;
|
package ru.bsuirhelper.android.core.schedule;
/**
* Created by Влад on 12.09.13.
*/
public class ScheduleManager {
private final ScheduleDatabase mScheduleDatabase;
|
// Path: app/src/ru/bsuirhelper/android/core/StudentCalendar.java
// public class StudentCalendar {
// private final DateTime mCurrentDateTime;
// private static int mDaysOfYear = 0;
// private static int mSemester;
//
// public StudentCalendar() {
// mCurrentDateTime = new DateTime();
// mDaysOfYear = getDaysOfYear();
//
// if (mCurrentDateTime.getMonthOfYear() >= 9) {
// mSemester = 1;
// } else {
// mSemester = 2;
// }
// }
//
// public int getDayOfYear() {
// int dayOfYear;
// if (mCurrentDateTime.getMonthOfYear() >= 9) {
// DateTime september = new DateTime(mCurrentDateTime.getYear(), 9, 1, 0, 0, 0);
// dayOfYear = new Interval(september, mCurrentDateTime).toPeriod(PeriodType.days()).getDays();
// } else {
// DateTime september = new DateTime(mCurrentDateTime.getYear() - 1, 9, 1, 0, 0, 0);
// dayOfYear = new Interval(september, mCurrentDateTime).toPeriod(PeriodType.days()).getDays();
// }
//
// return dayOfYear + 1;
// }
//
// public int getDayOfYear(DateTime dateTime) {
// int dayOfYear;
// if (dateTime.getMonthOfYear() >= 9) {
// DateTime september = new DateTime(dateTime.getYear(), 9, 1, 0, 0, 0);
// dayOfYear = new Interval(september, dateTime).toPeriod(PeriodType.days()).getDays();
// } else {
// DateTime september = new DateTime(dateTime.getYear() - 1, 9, 1, 0, 0, 0);
// dayOfYear = new Interval(september, dateTime).toPeriod(PeriodType.days()).getDays();
// }
// return dayOfYear;
// }
//
// public int getDaysOfYear() {
// if (mDaysOfYear == 0) {
// DateTime september;
// DateTime august;
//
// if (mCurrentDateTime.getMonthOfYear() <= 8) {
// september = new DateTime(mCurrentDateTime.getYear() - 1, 9, 1, 0, 0, 0);
// august = new DateTime(mCurrentDateTime.getYear(), 8, 31, 0, 0, 0);
// } else {
// september = new DateTime(mCurrentDateTime.getYear(), 8, 31, 0, 0, 0);
// august = new DateTime(mCurrentDateTime.getYear() + 1, 8, 31, 0, 0, 0);
// }
//
// mDaysOfYear = new Interval(september, august).toPeriod(PeriodType.days()).getDays();
// }
// return mDaysOfYear;
// }
//
// public static int getWorkWeek(DateTime dateTime) {
// DateTime september;
//
// if (dateTime.getMonthOfYear() <= 8) {
// september = new DateTime(dateTime.getYear() - 1, 9, 1, 0, 0, 0);
// } else {
// september = new DateTime(dateTime.getYear(), 9, 1, 0, 0, 0);
// }
//
// Interval interval = new Interval(september, dateTime);
// int workWeek = (interval.toPeriod(PeriodType.weeks()).getWeeks() + 2) % 4;
// workWeek = workWeek == 0 ? 4 : workWeek;
// return workWeek;
// }
//
// public static DateTime convertToDefaultDateTime(int studentDay) {
// DateTime september;
// int currentMonth = DateTime.now().getMonthOfYear();
// if (currentMonth <= 8) {
// september = new DateTime(DateTime.now().getYear() - 1, 9, 1, 0, 0, 0);
// } else {
// september = new DateTime(DateTime.now().getYear(), 9, 1, 0, 0, 0);
// }
// return september.plusDays(studentDay - 1);
// }
//
// public int getSemester() {
// return mSemester;
// }
//
// public static long getStartStudentYear() {
// DateTime september;
//
// if (DateTime.now().getMonthOfYear() <= 8) {
// september = new DateTime(DateTime.now().getYear() - 1, 9, 1, 0, 0, 0);
// } else {
// september = new DateTime(DateTime.now().getYear(), 8, 31, 1, 0, 0);
// }
//
// return september.getMillis();
// }
//
// public static long getEndStudentYear() {
// DateTime august;
// if (DateTime.now().getMonthOfYear() <= 8) {
// august = new DateTime(DateTime.now().getYear(), 8, 31, 1, 0, 0);
// } else {
// august = new DateTime(DateTime.now().getYear() + 1, 8, 31, 1, 0, 0);
// }
// return august.getMillis();
// }
//
// }
// Path: app/src/ru/bsuirhelper/android/core/schedule/ScheduleManager.java
import android.content.Context;
import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;
import ru.bsuirhelper.android.core.StudentCalendar;
import java.util.ArrayList;
package ru.bsuirhelper.android.core.schedule;
/**
* Created by Влад on 12.09.13.
*/
public class ScheduleManager {
private final ScheduleDatabase mScheduleDatabase;
|
private StudentCalendar mStudentCalendar = new StudentCalendar();
|
kalessil/yii2inspections
|
src/main/java/com/kalessil/phpStorm/yii2inspections/inspectors/MissingPropertyAnnotationsInspector.java
|
// Path: src/main/java/com/kalessil/phpStorm/yii2inspections/inspectors/utils/InheritanceChainExtractUtil.java
// final public class InheritanceChainExtractUtil {
// @NotNull
// public static Set<PhpClass> collect(@NotNull PhpClass clazz) {
// final Set<PhpClass> processedItems = new HashSet<>();
//
// if (clazz.isInterface()) {
// processInterface(clazz, processedItems);
// } else {
// processClass(clazz, processedItems);
// }
//
// return processedItems;
// }
//
// private static void processClass(@NotNull PhpClass clazz, @NotNull Set<PhpClass> processed) {
// if (clazz.isInterface()) {
// throw new InvalidParameterException("Interface shall not be provided");
// }
// processed.add(clazz);
//
// /* re-delegate interface handling */
// for (PhpClass anInterface : clazz.getImplementedInterfaces()) {
// processInterface(anInterface, processed);
// }
//
// /* handle parent class */
// if (null != clazz.getSuperClass()) {
// processClass(clazz.getSuperClass(), processed);
// }
// }
//
// private static void processInterface(@NotNull PhpClass clazz, @NotNull Set<PhpClass> processed) {
// if (!clazz.isInterface()) {
// throw new InvalidParameterException("Class shall not be provided");
// }
//
// if (processed.add(clazz)) {
// for (PhpClass parentInterface : clazz.getImplementedInterfaces()) {
// processInterface(parentInterface, processed);
// }
// }
// }
// }
//
// Path: src/main/java/com/kalessil/phpStorm/yii2inspections/inspectors/utils/NamedElementUtil.java
// final public class NamedElementUtil {
//
// /** returns name identifier, which is valid for reporting */
// @Nullable
// static public PsiElement getNameIdentifier(@Nullable PsiNameIdentifierOwner element) {
// if (null != element) {
// PsiElement id = element.getNameIdentifier();
// boolean isIdReportable = null != id && id.getTextLength() > 0;
//
// return isIdReportable ? id : null;
// }
//
// return null;
// }
//
// }
|
import com.intellij.codeInspection.LocalQuickFix;
import com.intellij.codeInspection.ProblemDescriptor;
import com.intellij.codeInspection.ProblemHighlightType;
import com.intellij.codeInspection.ProblemsHolder;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiElementVisitor;
import com.jetbrains.php.lang.documentation.phpdoc.psi.PhpDocComment;
import com.jetbrains.php.lang.inspections.PhpInspection;
import com.jetbrains.php.lang.psi.PhpPsiElementFactory;
import com.jetbrains.php.lang.psi.elements.*;
import com.jetbrains.php.lang.psi.visitors.PhpElementVisitor;
import com.kalessil.phpStorm.yii2inspections.inspectors.utils.InheritanceChainExtractUtil;
import com.kalessil.phpStorm.yii2inspections.inspectors.utils.NamedElementUtil;
import net.miginfocom.swing.MigLayout;
import org.apache.commons.lang.StringUtils;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import java.util.*;
|
package com.kalessil.phpStorm.yii2inspections.inspectors;
/*
* This file is part of the Yii2 Inspections package.
*
* Author: Vladimir Reznichenko <kalessil@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
final public class MissingPropertyAnnotationsInspector extends PhpInspection {
// configuration flags automatically saved by IDE
@SuppressWarnings("WeakerAccess")
public boolean REQUIRE_BOTH_GETTER_SETTER = false;
private static final String messagePattern = "'%p%': properties needs to be annotated";
private static final Set<String> baseObjectClasses = new HashSet<>();
static {
baseObjectClasses.add("\\yii\\base\\Object");
baseObjectClasses.add("\\yii\\base\\BaseObject");
}
@NotNull
public String getShortName() {
return "MissingPropertyAnnotationsInspection";
}
@Override
@NotNull
public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, boolean isOnTheFly) {
return new PhpElementVisitor() {
@Override
public void visitPhpClass(PhpClass clazz) {
/* check only regular named classes */
|
// Path: src/main/java/com/kalessil/phpStorm/yii2inspections/inspectors/utils/InheritanceChainExtractUtil.java
// final public class InheritanceChainExtractUtil {
// @NotNull
// public static Set<PhpClass> collect(@NotNull PhpClass clazz) {
// final Set<PhpClass> processedItems = new HashSet<>();
//
// if (clazz.isInterface()) {
// processInterface(clazz, processedItems);
// } else {
// processClass(clazz, processedItems);
// }
//
// return processedItems;
// }
//
// private static void processClass(@NotNull PhpClass clazz, @NotNull Set<PhpClass> processed) {
// if (clazz.isInterface()) {
// throw new InvalidParameterException("Interface shall not be provided");
// }
// processed.add(clazz);
//
// /* re-delegate interface handling */
// for (PhpClass anInterface : clazz.getImplementedInterfaces()) {
// processInterface(anInterface, processed);
// }
//
// /* handle parent class */
// if (null != clazz.getSuperClass()) {
// processClass(clazz.getSuperClass(), processed);
// }
// }
//
// private static void processInterface(@NotNull PhpClass clazz, @NotNull Set<PhpClass> processed) {
// if (!clazz.isInterface()) {
// throw new InvalidParameterException("Class shall not be provided");
// }
//
// if (processed.add(clazz)) {
// for (PhpClass parentInterface : clazz.getImplementedInterfaces()) {
// processInterface(parentInterface, processed);
// }
// }
// }
// }
//
// Path: src/main/java/com/kalessil/phpStorm/yii2inspections/inspectors/utils/NamedElementUtil.java
// final public class NamedElementUtil {
//
// /** returns name identifier, which is valid for reporting */
// @Nullable
// static public PsiElement getNameIdentifier(@Nullable PsiNameIdentifierOwner element) {
// if (null != element) {
// PsiElement id = element.getNameIdentifier();
// boolean isIdReportable = null != id && id.getTextLength() > 0;
//
// return isIdReportable ? id : null;
// }
//
// return null;
// }
//
// }
// Path: src/main/java/com/kalessil/phpStorm/yii2inspections/inspectors/MissingPropertyAnnotationsInspector.java
import com.intellij.codeInspection.LocalQuickFix;
import com.intellij.codeInspection.ProblemDescriptor;
import com.intellij.codeInspection.ProblemHighlightType;
import com.intellij.codeInspection.ProblemsHolder;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiElementVisitor;
import com.jetbrains.php.lang.documentation.phpdoc.psi.PhpDocComment;
import com.jetbrains.php.lang.inspections.PhpInspection;
import com.jetbrains.php.lang.psi.PhpPsiElementFactory;
import com.jetbrains.php.lang.psi.elements.*;
import com.jetbrains.php.lang.psi.visitors.PhpElementVisitor;
import com.kalessil.phpStorm.yii2inspections.inspectors.utils.InheritanceChainExtractUtil;
import com.kalessil.phpStorm.yii2inspections.inspectors.utils.NamedElementUtil;
import net.miginfocom.swing.MigLayout;
import org.apache.commons.lang.StringUtils;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import java.util.*;
package com.kalessil.phpStorm.yii2inspections.inspectors;
/*
* This file is part of the Yii2 Inspections package.
*
* Author: Vladimir Reznichenko <kalessil@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
final public class MissingPropertyAnnotationsInspector extends PhpInspection {
// configuration flags automatically saved by IDE
@SuppressWarnings("WeakerAccess")
public boolean REQUIRE_BOTH_GETTER_SETTER = false;
private static final String messagePattern = "'%p%': properties needs to be annotated";
private static final Set<String> baseObjectClasses = new HashSet<>();
static {
baseObjectClasses.add("\\yii\\base\\Object");
baseObjectClasses.add("\\yii\\base\\BaseObject");
}
@NotNull
public String getShortName() {
return "MissingPropertyAnnotationsInspection";
}
@Override
@NotNull
public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, boolean isOnTheFly) {
return new PhpElementVisitor() {
@Override
public void visitPhpClass(PhpClass clazz) {
/* check only regular named classes */
|
final PsiElement nameNode = NamedElementUtil.getNameIdentifier(clazz);
|
kalessil/yii2inspections
|
src/main/java/com/kalessil/phpStorm/yii2inspections/inspectors/MissingPropertyAnnotationsInspector.java
|
// Path: src/main/java/com/kalessil/phpStorm/yii2inspections/inspectors/utils/InheritanceChainExtractUtil.java
// final public class InheritanceChainExtractUtil {
// @NotNull
// public static Set<PhpClass> collect(@NotNull PhpClass clazz) {
// final Set<PhpClass> processedItems = new HashSet<>();
//
// if (clazz.isInterface()) {
// processInterface(clazz, processedItems);
// } else {
// processClass(clazz, processedItems);
// }
//
// return processedItems;
// }
//
// private static void processClass(@NotNull PhpClass clazz, @NotNull Set<PhpClass> processed) {
// if (clazz.isInterface()) {
// throw new InvalidParameterException("Interface shall not be provided");
// }
// processed.add(clazz);
//
// /* re-delegate interface handling */
// for (PhpClass anInterface : clazz.getImplementedInterfaces()) {
// processInterface(anInterface, processed);
// }
//
// /* handle parent class */
// if (null != clazz.getSuperClass()) {
// processClass(clazz.getSuperClass(), processed);
// }
// }
//
// private static void processInterface(@NotNull PhpClass clazz, @NotNull Set<PhpClass> processed) {
// if (!clazz.isInterface()) {
// throw new InvalidParameterException("Class shall not be provided");
// }
//
// if (processed.add(clazz)) {
// for (PhpClass parentInterface : clazz.getImplementedInterfaces()) {
// processInterface(parentInterface, processed);
// }
// }
// }
// }
//
// Path: src/main/java/com/kalessil/phpStorm/yii2inspections/inspectors/utils/NamedElementUtil.java
// final public class NamedElementUtil {
//
// /** returns name identifier, which is valid for reporting */
// @Nullable
// static public PsiElement getNameIdentifier(@Nullable PsiNameIdentifierOwner element) {
// if (null != element) {
// PsiElement id = element.getNameIdentifier();
// boolean isIdReportable = null != id && id.getTextLength() > 0;
//
// return isIdReportable ? id : null;
// }
//
// return null;
// }
//
// }
|
import com.intellij.codeInspection.LocalQuickFix;
import com.intellij.codeInspection.ProblemDescriptor;
import com.intellij.codeInspection.ProblemHighlightType;
import com.intellij.codeInspection.ProblemsHolder;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiElementVisitor;
import com.jetbrains.php.lang.documentation.phpdoc.psi.PhpDocComment;
import com.jetbrains.php.lang.inspections.PhpInspection;
import com.jetbrains.php.lang.psi.PhpPsiElementFactory;
import com.jetbrains.php.lang.psi.elements.*;
import com.jetbrains.php.lang.psi.visitors.PhpElementVisitor;
import com.kalessil.phpStorm.yii2inspections.inspectors.utils.InheritanceChainExtractUtil;
import com.kalessil.phpStorm.yii2inspections.inspectors.utils.NamedElementUtil;
import net.miginfocom.swing.MigLayout;
import org.apache.commons.lang.StringUtils;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import java.util.*;
|
package com.kalessil.phpStorm.yii2inspections.inspectors;
/*
* This file is part of the Yii2 Inspections package.
*
* Author: Vladimir Reznichenko <kalessil@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
final public class MissingPropertyAnnotationsInspector extends PhpInspection {
// configuration flags automatically saved by IDE
@SuppressWarnings("WeakerAccess")
public boolean REQUIRE_BOTH_GETTER_SETTER = false;
private static final String messagePattern = "'%p%': properties needs to be annotated";
private static final Set<String> baseObjectClasses = new HashSet<>();
static {
baseObjectClasses.add("\\yii\\base\\Object");
baseObjectClasses.add("\\yii\\base\\BaseObject");
}
@NotNull
public String getShortName() {
return "MissingPropertyAnnotationsInspection";
}
@Override
@NotNull
public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, boolean isOnTheFly) {
return new PhpElementVisitor() {
@Override
public void visitPhpClass(PhpClass clazz) {
/* check only regular named classes */
final PsiElement nameNode = NamedElementUtil.getNameIdentifier(clazz);
if (null == nameNode) {
return;
}
/* check if the class inherited from yii\base\Object */
boolean supportsPropertyFeature = false;
|
// Path: src/main/java/com/kalessil/phpStorm/yii2inspections/inspectors/utils/InheritanceChainExtractUtil.java
// final public class InheritanceChainExtractUtil {
// @NotNull
// public static Set<PhpClass> collect(@NotNull PhpClass clazz) {
// final Set<PhpClass> processedItems = new HashSet<>();
//
// if (clazz.isInterface()) {
// processInterface(clazz, processedItems);
// } else {
// processClass(clazz, processedItems);
// }
//
// return processedItems;
// }
//
// private static void processClass(@NotNull PhpClass clazz, @NotNull Set<PhpClass> processed) {
// if (clazz.isInterface()) {
// throw new InvalidParameterException("Interface shall not be provided");
// }
// processed.add(clazz);
//
// /* re-delegate interface handling */
// for (PhpClass anInterface : clazz.getImplementedInterfaces()) {
// processInterface(anInterface, processed);
// }
//
// /* handle parent class */
// if (null != clazz.getSuperClass()) {
// processClass(clazz.getSuperClass(), processed);
// }
// }
//
// private static void processInterface(@NotNull PhpClass clazz, @NotNull Set<PhpClass> processed) {
// if (!clazz.isInterface()) {
// throw new InvalidParameterException("Class shall not be provided");
// }
//
// if (processed.add(clazz)) {
// for (PhpClass parentInterface : clazz.getImplementedInterfaces()) {
// processInterface(parentInterface, processed);
// }
// }
// }
// }
//
// Path: src/main/java/com/kalessil/phpStorm/yii2inspections/inspectors/utils/NamedElementUtil.java
// final public class NamedElementUtil {
//
// /** returns name identifier, which is valid for reporting */
// @Nullable
// static public PsiElement getNameIdentifier(@Nullable PsiNameIdentifierOwner element) {
// if (null != element) {
// PsiElement id = element.getNameIdentifier();
// boolean isIdReportable = null != id && id.getTextLength() > 0;
//
// return isIdReportable ? id : null;
// }
//
// return null;
// }
//
// }
// Path: src/main/java/com/kalessil/phpStorm/yii2inspections/inspectors/MissingPropertyAnnotationsInspector.java
import com.intellij.codeInspection.LocalQuickFix;
import com.intellij.codeInspection.ProblemDescriptor;
import com.intellij.codeInspection.ProblemHighlightType;
import com.intellij.codeInspection.ProblemsHolder;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiElementVisitor;
import com.jetbrains.php.lang.documentation.phpdoc.psi.PhpDocComment;
import com.jetbrains.php.lang.inspections.PhpInspection;
import com.jetbrains.php.lang.psi.PhpPsiElementFactory;
import com.jetbrains.php.lang.psi.elements.*;
import com.jetbrains.php.lang.psi.visitors.PhpElementVisitor;
import com.kalessil.phpStorm.yii2inspections.inspectors.utils.InheritanceChainExtractUtil;
import com.kalessil.phpStorm.yii2inspections.inspectors.utils.NamedElementUtil;
import net.miginfocom.swing.MigLayout;
import org.apache.commons.lang.StringUtils;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import java.util.*;
package com.kalessil.phpStorm.yii2inspections.inspectors;
/*
* This file is part of the Yii2 Inspections package.
*
* Author: Vladimir Reznichenko <kalessil@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
final public class MissingPropertyAnnotationsInspector extends PhpInspection {
// configuration flags automatically saved by IDE
@SuppressWarnings("WeakerAccess")
public boolean REQUIRE_BOTH_GETTER_SETTER = false;
private static final String messagePattern = "'%p%': properties needs to be annotated";
private static final Set<String> baseObjectClasses = new HashSet<>();
static {
baseObjectClasses.add("\\yii\\base\\Object");
baseObjectClasses.add("\\yii\\base\\BaseObject");
}
@NotNull
public String getShortName() {
return "MissingPropertyAnnotationsInspection";
}
@Override
@NotNull
public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, boolean isOnTheFly) {
return new PhpElementVisitor() {
@Override
public void visitPhpClass(PhpClass clazz) {
/* check only regular named classes */
final PsiElement nameNode = NamedElementUtil.getNameIdentifier(clazz);
if (null == nameNode) {
return;
}
/* check if the class inherited from yii\base\Object */
boolean supportsPropertyFeature = false;
|
final Set<PhpClass> parents = InheritanceChainExtractUtil.collect(clazz);
|
kalessil/yii2inspections
|
src/main/java/com/kalessil/phpStorm/yii2inspections/codeInsight/TranslationAutocompleteContributor.java
|
// Path: src/main/java/com/kalessil/phpStorm/yii2inspections/inspectors/utils/StringLiteralExtractUtil.java
// final public class StringLiteralExtractUtil {
// @Nullable
// private static PsiElement getExpressionTroughParenthesis(@Nullable PsiElement expression) {
// if (!(expression instanceof ParenthesizedExpression)) {
// return expression;
// }
//
// PsiElement innerExpression = ((ParenthesizedExpression) expression).getArgument();
// while (innerExpression instanceof ParenthesizedExpression) {
// innerExpression = ((ParenthesizedExpression) innerExpression).getArgument();
// }
//
// return innerExpression;
// }
//
// @Nullable
// private static Function getScope(@NotNull PsiElement expression) {
// PsiElement parent = expression.getParent();
// while (null != parent && !(parent instanceof PhpFile)) {
// if (parent instanceof Function) {
// return (Function) parent;
// }
//
// parent = parent.getParent();
// }
//
// return null;
// }
//
// @Nullable
// public static StringLiteralExpression resolveAsStringLiteral(@Nullable PsiElement expression, boolean resolve) {
// if (null == expression) {
// return null;
// }
// expression = getExpressionTroughParenthesis(expression);
//
// if (expression instanceof StringLiteralExpression) {
// return (StringLiteralExpression) expression;
// }
//
// if (expression instanceof FieldReference || expression instanceof ClassConstantReference) {
// final Field fieldOrConstant = resolve ? (Field) ((MemberReference) expression).resolve() : null;
// if (null != fieldOrConstant && fieldOrConstant.getDefaultValue() instanceof StringLiteralExpression) {
// return (StringLiteralExpression) fieldOrConstant.getDefaultValue();
// }
// }
//
// if (expression instanceof Variable) {
// final String variable = ((Variable) expression).getName();
// if (!StringUtil.isEmpty(variable)) {
// final Function scope = getScope(expression);
// if (null != scope) {
// final Set<AssignmentExpression> matched = new HashSet<>();
//
// Collection<AssignmentExpression> assignments
// = PsiTreeUtil.findChildrenOfType(scope, AssignmentExpression.class);
// /* collect self-assignments as well */
// for (AssignmentExpression assignment : assignments) {
// if (assignment.getVariable() instanceof Variable && assignment.getValue() instanceof StringLiteralExpression) {
// final String name = assignment.getVariable().getName();
// if (!StringUtil.isEmpty(name) && name.equals(variable)) {
// matched.add(assignment);
// }
// }
// }
// assignments.clear();
//
// if (matched.size() == 1) {
// StringLiteralExpression result = (StringLiteralExpression) matched.iterator().next().getValue();
//
// matched.clear();
// return result;
// }
// matched.clear();
// }
// }
// }
//
// return null;
// }
// }
|
import com.intellij.codeInsight.completion.*;
import com.intellij.codeInsight.lookup.LookupElementBuilder;
import com.intellij.openapi.project.Project;
import com.intellij.patterns.ElementPattern;
import com.intellij.patterns.PlatformPatterns;
import com.intellij.psi.PsiElement;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.util.ProcessingContext;
import com.intellij.util.indexing.FileBasedIndex;
import com.jetbrains.php.lang.PhpLanguage;
import com.jetbrains.php.lang.parser.PhpElementTypes;
import com.jetbrains.php.lang.psi.elements.MethodReference;
import com.jetbrains.php.lang.psi.elements.ParameterList;
import com.jetbrains.php.lang.psi.elements.StringLiteralExpression;
import com.kalessil.phpStorm.yii2inspections.inspectors.utils.StringLiteralExtractUtil;
import org.jetbrains.annotations.NotNull;
import java.util.*;
|
package com.kalessil.phpStorm.yii2inspections.codeInsight;
public class TranslationAutocompleteContributor extends CompletionContributor {
public TranslationAutocompleteContributor() {
final CompletionProvider<CompletionParameters> provider = new CompletionProvider<CompletionParameters>() {
@Override
protected void addCompletions(
@NotNull CompletionParameters completionParameters,
ProcessingContext processingContext,
@NotNull CompletionResultSet completionResultSet
) {
/* validate the autocompletion target */
final PsiElement target = completionParameters.getOriginalPosition();
if (target == null || !(target.getParent() instanceof StringLiteralExpression)) {
return;
}
/* suggest only to target code structure */
final StringLiteralExpression parameter = (StringLiteralExpression) target.getParent();
final PsiElement context = parameter.getParent().getParent();
if (!(context instanceof MethodReference)) {
return;
}
final MethodReference reference = (MethodReference) context;
final String name = reference.getName();
final PsiElement[] arguments = reference.getParameters();
if (name == null || arguments.length == 0 || (!name.equals("t") && !name.equals("registerTranslations"))) {
return;
}
/* generate proposals */
final boolean autocompleteCategory = arguments[0] == parameter;
final boolean autocompleteMessage = arguments.length > 1 && arguments[1] == parameter;
if (autocompleteCategory || autocompleteMessage) {
StringLiteralExpression categoryLiteral = null;
if (autocompleteMessage) {
|
// Path: src/main/java/com/kalessil/phpStorm/yii2inspections/inspectors/utils/StringLiteralExtractUtil.java
// final public class StringLiteralExtractUtil {
// @Nullable
// private static PsiElement getExpressionTroughParenthesis(@Nullable PsiElement expression) {
// if (!(expression instanceof ParenthesizedExpression)) {
// return expression;
// }
//
// PsiElement innerExpression = ((ParenthesizedExpression) expression).getArgument();
// while (innerExpression instanceof ParenthesizedExpression) {
// innerExpression = ((ParenthesizedExpression) innerExpression).getArgument();
// }
//
// return innerExpression;
// }
//
// @Nullable
// private static Function getScope(@NotNull PsiElement expression) {
// PsiElement parent = expression.getParent();
// while (null != parent && !(parent instanceof PhpFile)) {
// if (parent instanceof Function) {
// return (Function) parent;
// }
//
// parent = parent.getParent();
// }
//
// return null;
// }
//
// @Nullable
// public static StringLiteralExpression resolveAsStringLiteral(@Nullable PsiElement expression, boolean resolve) {
// if (null == expression) {
// return null;
// }
// expression = getExpressionTroughParenthesis(expression);
//
// if (expression instanceof StringLiteralExpression) {
// return (StringLiteralExpression) expression;
// }
//
// if (expression instanceof FieldReference || expression instanceof ClassConstantReference) {
// final Field fieldOrConstant = resolve ? (Field) ((MemberReference) expression).resolve() : null;
// if (null != fieldOrConstant && fieldOrConstant.getDefaultValue() instanceof StringLiteralExpression) {
// return (StringLiteralExpression) fieldOrConstant.getDefaultValue();
// }
// }
//
// if (expression instanceof Variable) {
// final String variable = ((Variable) expression).getName();
// if (!StringUtil.isEmpty(variable)) {
// final Function scope = getScope(expression);
// if (null != scope) {
// final Set<AssignmentExpression> matched = new HashSet<>();
//
// Collection<AssignmentExpression> assignments
// = PsiTreeUtil.findChildrenOfType(scope, AssignmentExpression.class);
// /* collect self-assignments as well */
// for (AssignmentExpression assignment : assignments) {
// if (assignment.getVariable() instanceof Variable && assignment.getValue() instanceof StringLiteralExpression) {
// final String name = assignment.getVariable().getName();
// if (!StringUtil.isEmpty(name) && name.equals(variable)) {
// matched.add(assignment);
// }
// }
// }
// assignments.clear();
//
// if (matched.size() == 1) {
// StringLiteralExpression result = (StringLiteralExpression) matched.iterator().next().getValue();
//
// matched.clear();
// return result;
// }
// matched.clear();
// }
// }
// }
//
// return null;
// }
// }
// Path: src/main/java/com/kalessil/phpStorm/yii2inspections/codeInsight/TranslationAutocompleteContributor.java
import com.intellij.codeInsight.completion.*;
import com.intellij.codeInsight.lookup.LookupElementBuilder;
import com.intellij.openapi.project.Project;
import com.intellij.patterns.ElementPattern;
import com.intellij.patterns.PlatformPatterns;
import com.intellij.psi.PsiElement;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.util.ProcessingContext;
import com.intellij.util.indexing.FileBasedIndex;
import com.jetbrains.php.lang.PhpLanguage;
import com.jetbrains.php.lang.parser.PhpElementTypes;
import com.jetbrains.php.lang.psi.elements.MethodReference;
import com.jetbrains.php.lang.psi.elements.ParameterList;
import com.jetbrains.php.lang.psi.elements.StringLiteralExpression;
import com.kalessil.phpStorm.yii2inspections.inspectors.utils.StringLiteralExtractUtil;
import org.jetbrains.annotations.NotNull;
import java.util.*;
package com.kalessil.phpStorm.yii2inspections.codeInsight;
public class TranslationAutocompleteContributor extends CompletionContributor {
public TranslationAutocompleteContributor() {
final CompletionProvider<CompletionParameters> provider = new CompletionProvider<CompletionParameters>() {
@Override
protected void addCompletions(
@NotNull CompletionParameters completionParameters,
ProcessingContext processingContext,
@NotNull CompletionResultSet completionResultSet
) {
/* validate the autocompletion target */
final PsiElement target = completionParameters.getOriginalPosition();
if (target == null || !(target.getParent() instanceof StringLiteralExpression)) {
return;
}
/* suggest only to target code structure */
final StringLiteralExpression parameter = (StringLiteralExpression) target.getParent();
final PsiElement context = parameter.getParent().getParent();
if (!(context instanceof MethodReference)) {
return;
}
final MethodReference reference = (MethodReference) context;
final String name = reference.getName();
final PsiElement[] arguments = reference.getParameters();
if (name == null || arguments.length == 0 || (!name.equals("t") && !name.equals("registerTranslations"))) {
return;
}
/* generate proposals */
final boolean autocompleteCategory = arguments[0] == parameter;
final boolean autocompleteMessage = arguments.length > 1 && arguments[1] == parameter;
if (autocompleteCategory || autocompleteMessage) {
StringLiteralExpression categoryLiteral = null;
if (autocompleteMessage) {
|
categoryLiteral = StringLiteralExtractUtil.resolveAsStringLiteral(arguments[0], true);
|
kalessil/yii2inspections
|
src/test/java/com/kalessil/phpStorm/yii2inspections/inspectors/TranslationCallsProcessUtilTest.java
|
// Path: src/main/java/com/kalessil/phpStorm/yii2inspections/utils/TranslationCallsProcessUtil.java
// final public class TranslationCallsProcessUtil {
//
// /* Returns null if category is not clean or empty string literal or no reasonable messages were found*/
// @Nullable
// static public ProcessingResult process(@NotNull MethodReference reference, boolean resolve) {
// final String name = reference.getName();
// final PsiElement[] params = reference.getParameters();
// if (null == name || params.length < 2 || (!name.equals("t") && !(name.equals("registerTranslations")))) {
// return null;
// }
//
// /* category needs to be resolved and without any injections */
// final StringLiteralExpression categoryLiteral = StringLiteralExtractUtil.resolveAsStringLiteral(params[0], resolve);
// if (null == categoryLiteral || null != categoryLiteral.getFirstPsiChild() || categoryLiteral.getTextLength() <= 2) {
// return null;
// }
//
// final Map<StringLiteralExpression, PsiElement> messages = new HashMap<>();
// if (name.equals("t")) {
// /* 2nd argument expected to be a string literal (possible with injections) */
// final StringLiteralExpression messageLiteral = StringLiteralExtractUtil.resolveAsStringLiteral(params[1], resolve);
// if (null != messageLiteral && messageLiteral.getTextLength() > 2) {
// messages.put(messageLiteral, params[1]);
// }
// }
//
// if (name.equals("registerTranslations") && params[1] instanceof ArrayCreationExpression) {
// /* 2nd argument expected to be an inline array with string literal (possible with injections) */
// for (PsiElement child : params[1].getChildren()) {
// final PsiElement literalCandidate = child.getFirstChild();
// final StringLiteralExpression messageLiteral = StringLiteralExtractUtil.resolveAsStringLiteral(literalCandidate, resolve);
// if (null != messageLiteral && messageLiteral.getTextLength() > 2) {
// messages.put(messageLiteral, literalCandidate);
// }
// }
// }
//
// return 0 == messages.size() ? null : new ProcessingResult(categoryLiteral, messages);
// }
//
// static public class ProcessingResult {
// @Nullable
// private StringLiteralExpression category;
// @Nullable
// private Map<StringLiteralExpression, PsiElement> messages;
//
// ProcessingResult(@NotNull StringLiteralExpression category, @NotNull Map<StringLiteralExpression, PsiElement> messages) {
// this.category = category;
// this.messages = messages;
// }
//
// @NotNull
// public StringLiteralExpression getCategory() {
// if (null == this.category) {
// throw new RuntimeException("The object has been disposed already");
// }
//
// return this.category;
// }
//
// @NotNull
// public Map<StringLiteralExpression, PsiElement> getMessages() {
// if (null == this.messages) {
// throw new RuntimeException("The object has been disposed already");
// }
//
// return this.messages;
// }
//
// public void dispose() {
// if (null != this.messages) {
// this.messages.clear();
// }
//
// this.category = null;
// this.messages = null;
// }
// }
// }
|
import com.intellij.openapi.project.Project;
import com.intellij.testFramework.fixtures.CodeInsightFixtureTestCase;
import com.jetbrains.php.lang.psi.PhpPsiElementFactory;
import com.jetbrains.php.lang.psi.elements.MethodReference;
import com.kalessil.phpStorm.yii2inspections.utils.TranslationCallsProcessUtil;
import java.util.HashMap;
import java.util.Map;
|
package com.kalessil.phpStorm.yii2inspections.inspectors;
public class TranslationCallsProcessUtilTest extends CodeInsightFixtureTestCase {
public void testSingleMessageExtraction() {
Project project = myFixture.getProject();
Map<String, Integer> patterns = new HashMap<>();
patterns.put("Yii::t('yii', \"$x\")", 1);
patterns.put("Yii::t('yii', 'message')", 1);
patterns.put("Yii::t('yii', \"message\")", 1);
patterns.put("$view->registerTranslations('craft', ['message', 'message']);", 2);
for (String pattern : patterns.keySet()) {
MethodReference call = PhpPsiElementFactory.createFromText(project, MethodReference.class, pattern);
assertNotNull(pattern + ": incorrect pattern", call);
|
// Path: src/main/java/com/kalessil/phpStorm/yii2inspections/utils/TranslationCallsProcessUtil.java
// final public class TranslationCallsProcessUtil {
//
// /* Returns null if category is not clean or empty string literal or no reasonable messages were found*/
// @Nullable
// static public ProcessingResult process(@NotNull MethodReference reference, boolean resolve) {
// final String name = reference.getName();
// final PsiElement[] params = reference.getParameters();
// if (null == name || params.length < 2 || (!name.equals("t") && !(name.equals("registerTranslations")))) {
// return null;
// }
//
// /* category needs to be resolved and without any injections */
// final StringLiteralExpression categoryLiteral = StringLiteralExtractUtil.resolveAsStringLiteral(params[0], resolve);
// if (null == categoryLiteral || null != categoryLiteral.getFirstPsiChild() || categoryLiteral.getTextLength() <= 2) {
// return null;
// }
//
// final Map<StringLiteralExpression, PsiElement> messages = new HashMap<>();
// if (name.equals("t")) {
// /* 2nd argument expected to be a string literal (possible with injections) */
// final StringLiteralExpression messageLiteral = StringLiteralExtractUtil.resolveAsStringLiteral(params[1], resolve);
// if (null != messageLiteral && messageLiteral.getTextLength() > 2) {
// messages.put(messageLiteral, params[1]);
// }
// }
//
// if (name.equals("registerTranslations") && params[1] instanceof ArrayCreationExpression) {
// /* 2nd argument expected to be an inline array with string literal (possible with injections) */
// for (PsiElement child : params[1].getChildren()) {
// final PsiElement literalCandidate = child.getFirstChild();
// final StringLiteralExpression messageLiteral = StringLiteralExtractUtil.resolveAsStringLiteral(literalCandidate, resolve);
// if (null != messageLiteral && messageLiteral.getTextLength() > 2) {
// messages.put(messageLiteral, literalCandidate);
// }
// }
// }
//
// return 0 == messages.size() ? null : new ProcessingResult(categoryLiteral, messages);
// }
//
// static public class ProcessingResult {
// @Nullable
// private StringLiteralExpression category;
// @Nullable
// private Map<StringLiteralExpression, PsiElement> messages;
//
// ProcessingResult(@NotNull StringLiteralExpression category, @NotNull Map<StringLiteralExpression, PsiElement> messages) {
// this.category = category;
// this.messages = messages;
// }
//
// @NotNull
// public StringLiteralExpression getCategory() {
// if (null == this.category) {
// throw new RuntimeException("The object has been disposed already");
// }
//
// return this.category;
// }
//
// @NotNull
// public Map<StringLiteralExpression, PsiElement> getMessages() {
// if (null == this.messages) {
// throw new RuntimeException("The object has been disposed already");
// }
//
// return this.messages;
// }
//
// public void dispose() {
// if (null != this.messages) {
// this.messages.clear();
// }
//
// this.category = null;
// this.messages = null;
// }
// }
// }
// Path: src/test/java/com/kalessil/phpStorm/yii2inspections/inspectors/TranslationCallsProcessUtilTest.java
import com.intellij.openapi.project.Project;
import com.intellij.testFramework.fixtures.CodeInsightFixtureTestCase;
import com.jetbrains.php.lang.psi.PhpPsiElementFactory;
import com.jetbrains.php.lang.psi.elements.MethodReference;
import com.kalessil.phpStorm.yii2inspections.utils.TranslationCallsProcessUtil;
import java.util.HashMap;
import java.util.Map;
package com.kalessil.phpStorm.yii2inspections.inspectors;
public class TranslationCallsProcessUtilTest extends CodeInsightFixtureTestCase {
public void testSingleMessageExtraction() {
Project project = myFixture.getProject();
Map<String, Integer> patterns = new HashMap<>();
patterns.put("Yii::t('yii', \"$x\")", 1);
patterns.put("Yii::t('yii', 'message')", 1);
patterns.put("Yii::t('yii', \"message\")", 1);
patterns.put("$view->registerTranslations('craft', ['message', 'message']);", 2);
for (String pattern : patterns.keySet()) {
MethodReference call = PhpPsiElementFactory.createFromText(project, MethodReference.class, pattern);
assertNotNull(pattern + ": incorrect pattern", call);
|
TranslationCallsProcessUtil.ProcessingResult messages = TranslationCallsProcessUtil.process(call, false);
|
TonnyL/Espresso
|
app/src/main/java/io/github/marktony/espresso/zxing/camera/CameraManager.java
|
// Path: app/src/main/java/io/github/marktony/espresso/zxing/camera/open/OpenCameraInterface.java
// public class OpenCameraInterface {
//
// private static final String TAG = OpenCameraInterface.class.getName();
//
// /**
// * Opens the requested camera with {@link Camera#open(int)}, if one exists.
// *
// * @param cameraId
// * camera ID of the camera to use. A negative value means
// * "no preference"
// * @return handle to {@link Camera} that was opened
// */
// public static Camera open(int cameraId) {
//
// int numCameras = Camera.getNumberOfCameras();
// if (numCameras == 0) {
// Log.w(TAG, "No cameras!");
// return null;
// }
//
// boolean explicitRequest = cameraId >= 0;
//
// if (!explicitRequest) {
// // Select a camera if no explicit camera requested
// int index = 0;
// while (index < numCameras) {
// Camera.CameraInfo cameraInfo = new Camera.CameraInfo();
// Camera.getCameraInfo(index, cameraInfo);
// if (cameraInfo.facing == Camera.CameraInfo.CAMERA_FACING_BACK) {
// break;
// }
// index++;
// }
//
// cameraId = index;
// }
//
// Camera camera;
// if (cameraId < numCameras) {
// Log.i(TAG, "Opening camera #" + cameraId);
// camera = Camera.open(cameraId);
// } else {
// if (explicitRequest) {
// Log.w(TAG, "Requested camera does not exist: " + cameraId);
// camera = null;
// } else {
// Log.i(TAG, "No camera facing back; returning camera #0");
// camera = Camera.open(0);
// }
// }
//
// return camera;
// }
//
// /**
// * Opens a rear-facing camera with {@link Camera#open(int)}, if one exists,
// * or opens camera 0.
// *
// * @return handle to {@link Camera} that was opened
// */
// public static Camera open() {
// return open(-1);
// }
//
// }
|
import java.io.IOException;
import android.content.Context;
import android.graphics.Point;
import android.hardware.Camera;
import android.hardware.Camera.Size;
import android.os.Handler;
import android.util.Log;
import android.view.SurfaceHolder;
import io.github.marktony.espresso.zxing.camera.open.OpenCameraInterface;
|
/*
* Copyright(c) 2017 lizhaotailang
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.marktony.espresso.zxing.camera;
/**
* This object wraps the Camera service object and expects to be the only one
* talking to it. The implementation encapsulates the steps needed to take
* preview-sized images, which are used for both preview and decoding.
*
* @author dswitkin@google.com (Daniel Switkin)
*/
public class CameraManager {
private static final String TAG = CameraManager.class.getSimpleName();
private final Context context;
private final CameraConfigurationManager configManager;
private Camera camera;
private AutoFocusManager autoFocusManager;
private boolean initialized;
private boolean previewing;
private int requestedCameraId = -1;
/**
* Preview frames are delivered here, which we pass on to the registered
* handler. Make sure to clear the handler so it will only receive one
* message.
*/
private final PreviewCallback previewCallback;
public CameraManager(Context context) {
this.context = context;
this.configManager = new CameraConfigurationManager(context);
previewCallback = new PreviewCallback(configManager);
}
/**
* Opens the camera driver and initializes the hardware parameters.
*
* @param holder
* The surface object which the camera will draw preview frames
* into.
* @throws IOException
* Indicates the camera driver failed to open.
*/
public synchronized void openDriver(SurfaceHolder holder) throws IOException {
Camera theCamera = camera;
if (theCamera == null) {
if (requestedCameraId >= 0) {
|
// Path: app/src/main/java/io/github/marktony/espresso/zxing/camera/open/OpenCameraInterface.java
// public class OpenCameraInterface {
//
// private static final String TAG = OpenCameraInterface.class.getName();
//
// /**
// * Opens the requested camera with {@link Camera#open(int)}, if one exists.
// *
// * @param cameraId
// * camera ID of the camera to use. A negative value means
// * "no preference"
// * @return handle to {@link Camera} that was opened
// */
// public static Camera open(int cameraId) {
//
// int numCameras = Camera.getNumberOfCameras();
// if (numCameras == 0) {
// Log.w(TAG, "No cameras!");
// return null;
// }
//
// boolean explicitRequest = cameraId >= 0;
//
// if (!explicitRequest) {
// // Select a camera if no explicit camera requested
// int index = 0;
// while (index < numCameras) {
// Camera.CameraInfo cameraInfo = new Camera.CameraInfo();
// Camera.getCameraInfo(index, cameraInfo);
// if (cameraInfo.facing == Camera.CameraInfo.CAMERA_FACING_BACK) {
// break;
// }
// index++;
// }
//
// cameraId = index;
// }
//
// Camera camera;
// if (cameraId < numCameras) {
// Log.i(TAG, "Opening camera #" + cameraId);
// camera = Camera.open(cameraId);
// } else {
// if (explicitRequest) {
// Log.w(TAG, "Requested camera does not exist: " + cameraId);
// camera = null;
// } else {
// Log.i(TAG, "No camera facing back; returning camera #0");
// camera = Camera.open(0);
// }
// }
//
// return camera;
// }
//
// /**
// * Opens a rear-facing camera with {@link Camera#open(int)}, if one exists,
// * or opens camera 0.
// *
// * @return handle to {@link Camera} that was opened
// */
// public static Camera open() {
// return open(-1);
// }
//
// }
// Path: app/src/main/java/io/github/marktony/espresso/zxing/camera/CameraManager.java
import java.io.IOException;
import android.content.Context;
import android.graphics.Point;
import android.hardware.Camera;
import android.hardware.Camera.Size;
import android.os.Handler;
import android.util.Log;
import android.view.SurfaceHolder;
import io.github.marktony.espresso.zxing.camera.open.OpenCameraInterface;
/*
* Copyright(c) 2017 lizhaotailang
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.marktony.espresso.zxing.camera;
/**
* This object wraps the Camera service object and expects to be the only one
* talking to it. The implementation encapsulates the steps needed to take
* preview-sized images, which are used for both preview and decoding.
*
* @author dswitkin@google.com (Daniel Switkin)
*/
public class CameraManager {
private static final String TAG = CameraManager.class.getSimpleName();
private final Context context;
private final CameraConfigurationManager configManager;
private Camera camera;
private AutoFocusManager autoFocusManager;
private boolean initialized;
private boolean previewing;
private int requestedCameraId = -1;
/**
* Preview frames are delivered here, which we pass on to the registered
* handler. Make sure to clear the handler so it will only receive one
* message.
*/
private final PreviewCallback previewCallback;
public CameraManager(Context context) {
this.context = context;
this.configManager = new CameraConfigurationManager(context);
previewCallback = new PreviewCallback(configManager);
}
/**
* Opens the camera driver and initializes the hardware parameters.
*
* @param holder
* The surface object which the camera will draw preview frames
* into.
* @throws IOException
* Indicates the camera driver failed to open.
*/
public synchronized void openDriver(SurfaceHolder holder) throws IOException {
Camera theCamera = camera;
if (theCamera == null) {
if (requestedCameraId >= 0) {
|
theCamera = OpenCameraInterface.open(requestedCameraId);
|
TonnyL/Espresso
|
app/src/main/java/io/github/marktony/espresso/mvp/companydetails/CompanyDetailFragment.java
|
// Path: app/src/main/java/io/github/marktony/espresso/customtabs/CustomTabsHelper.java
// public class CustomTabsHelper {
//
// public static void openUrl(Context context, String url) {
// SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
//
// if (sharedPreferences.getBoolean(SettingsUtil.KEY_CUSTOM_TABS, true)) {
// CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
// builder.setToolbarColor(ContextCompat.getColor(context, R.color.colorPrimaryDark));
// builder.build().launchUrl(context, Uri.parse(url));
// } else {
// try {
// context.startActivity(new Intent(Intent.ACTION_VIEW).setData(Uri.parse(url)));
// } catch (ActivityNotFoundException e) {
// Toast.makeText(context, R.string.error_no_browser, Toast.LENGTH_SHORT).show();
// }
// }
// }
//
// }
|
import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.graphics.Typeface;
import android.net.Uri;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v4.app.Fragment;
import android.support.v7.widget.AppCompatTextView;
import android.support.v7.widget.Toolbar;
import android.text.Spannable;
import android.text.SpannableStringBuilder;
import android.text.Spanned;
import android.text.style.StyleSpan;
import android.text.style.URLSpan;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import io.github.marktony.espresso.R;
import io.github.marktony.espresso.customtabs.CustomTabsHelper;
|
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_company_details, container, false);
initViews(view);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
share();
}
});
textViewTel.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (tel != null && !tel.isEmpty()) {
Intent intent = new Intent(Intent.ACTION_DIAL);
intent.setData(Uri.parse("tel:" + tel));
getActivity().startActivity(intent);
}
}
});
textViewWebsite.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (website != null) {
|
// Path: app/src/main/java/io/github/marktony/espresso/customtabs/CustomTabsHelper.java
// public class CustomTabsHelper {
//
// public static void openUrl(Context context, String url) {
// SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
//
// if (sharedPreferences.getBoolean(SettingsUtil.KEY_CUSTOM_TABS, true)) {
// CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
// builder.setToolbarColor(ContextCompat.getColor(context, R.color.colorPrimaryDark));
// builder.build().launchUrl(context, Uri.parse(url));
// } else {
// try {
// context.startActivity(new Intent(Intent.ACTION_VIEW).setData(Uri.parse(url)));
// } catch (ActivityNotFoundException e) {
// Toast.makeText(context, R.string.error_no_browser, Toast.LENGTH_SHORT).show();
// }
// }
// }
//
// }
// Path: app/src/main/java/io/github/marktony/espresso/mvp/companydetails/CompanyDetailFragment.java
import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.graphics.Typeface;
import android.net.Uri;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v4.app.Fragment;
import android.support.v7.widget.AppCompatTextView;
import android.support.v7.widget.Toolbar;
import android.text.Spannable;
import android.text.SpannableStringBuilder;
import android.text.Spanned;
import android.text.style.StyleSpan;
import android.text.style.URLSpan;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import io.github.marktony.espresso.R;
import io.github.marktony.espresso.customtabs.CustomTabsHelper;
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_company_details, container, false);
initViews(view);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
share();
}
});
textViewTel.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (tel != null && !tel.isEmpty()) {
Intent intent = new Intent(Intent.ACTION_DIAL);
intent.setData(Uri.parse("tel:" + tel));
getActivity().startActivity(intent);
}
}
});
textViewWebsite.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (website != null) {
|
CustomTabsHelper.openUrl(getContext(), website);
|
TonnyL/Espresso
|
app/src/androidTest/java/io/github/marktony/espresso/about/AboutScreenTest.java
|
// Path: app/src/main/java/io/github/marktony/espresso/ui/PrefsActivity.java
// public class PrefsActivity extends AppCompatActivity {
//
// public static final String EXTRA_FLAG= "EXTRA_FLAG";
//
// public static final int FLAG_SETTINGS = 0, FLAG_ABOUT = 1, FLAG_LICENSES = 2;
//
// @Override
// protected void onCreate(@Nullable Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_prefs);
//
// // Set the navigation bar color
// if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean("navigation_bar_tint", true)) {
// getWindow().setNavigationBarColor(ContextCompat.getColor(this, R.color.colorPrimaryDark));
// }
//
// initViews();
//
// Intent intent = getIntent();
// Fragment fragment;
//
// if (intent.getIntExtra(EXTRA_FLAG, 0) == FLAG_SETTINGS) {
// setTitle(R.string.nav_settings);
// fragment = new SettingsFragment();
// } else if (intent.getIntExtra(EXTRA_FLAG, 0) == FLAG_ABOUT){
// setTitle(R.string.nav_about);
// fragment = new AboutFragment();
// } else if (intent.getIntExtra(EXTRA_FLAG, 0) == FLAG_LICENSES) {
// setTitle(R.string.licenses);
// fragment = new LicensesFragment();
// } else {
// throw new RuntimeException("Please set flag when launching PrefsActivity.");
// }
//
// getSupportFragmentManager()
// .beginTransaction()
// .replace(R.id.view_pager,fragment)
// .commit();
//
// }
//
// @Override
// public boolean onOptionsItemSelected(MenuItem item) {
// if (item.getItemId() == android.R.id.home) {
// onBackPressed();
// }
// return true;
// }
//
// private void initViews() {
// setSupportActionBar((Toolbar) findViewById(R.id.toolbar));
// getSupportActionBar().setDisplayHomeAsUpEnabled(true);
// }
//
// }
|
import android.content.Context;
import android.content.Intent;
import android.support.test.InstrumentationRegistry;
import android.support.test.filters.SmallTest;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import io.github.marktony.espresso.R;
import io.github.marktony.espresso.ui.PrefsActivity;
import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.assertion.ViewAssertions.matches;
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static android.support.test.espresso.matcher.ViewMatchers.withParent;
import static android.support.test.espresso.matcher.ViewMatchers.withText;
import static org.hamcrest.core.AllOf.allOf;
|
package io.github.marktony.espresso.about;
/**
* Created by lizhaotailang on 2017/5/13.
* Tests for the {@link io.github.marktony.espresso.ui.AboutFragment}.
*/
@RunWith(AndroidJUnit4.class)
@SmallTest
public class AboutScreenTest {
/**
* {@link ActivityTestRule} is a JUnit {@link Rule @Rule} to launch your activity under test.
*
* <p>
* Rules are interceptors which are executed for each test method and are important building
* blocks of Junit tests.
*/
@Rule
|
// Path: app/src/main/java/io/github/marktony/espresso/ui/PrefsActivity.java
// public class PrefsActivity extends AppCompatActivity {
//
// public static final String EXTRA_FLAG= "EXTRA_FLAG";
//
// public static final int FLAG_SETTINGS = 0, FLAG_ABOUT = 1, FLAG_LICENSES = 2;
//
// @Override
// protected void onCreate(@Nullable Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_prefs);
//
// // Set the navigation bar color
// if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean("navigation_bar_tint", true)) {
// getWindow().setNavigationBarColor(ContextCompat.getColor(this, R.color.colorPrimaryDark));
// }
//
// initViews();
//
// Intent intent = getIntent();
// Fragment fragment;
//
// if (intent.getIntExtra(EXTRA_FLAG, 0) == FLAG_SETTINGS) {
// setTitle(R.string.nav_settings);
// fragment = new SettingsFragment();
// } else if (intent.getIntExtra(EXTRA_FLAG, 0) == FLAG_ABOUT){
// setTitle(R.string.nav_about);
// fragment = new AboutFragment();
// } else if (intent.getIntExtra(EXTRA_FLAG, 0) == FLAG_LICENSES) {
// setTitle(R.string.licenses);
// fragment = new LicensesFragment();
// } else {
// throw new RuntimeException("Please set flag when launching PrefsActivity.");
// }
//
// getSupportFragmentManager()
// .beginTransaction()
// .replace(R.id.view_pager,fragment)
// .commit();
//
// }
//
// @Override
// public boolean onOptionsItemSelected(MenuItem item) {
// if (item.getItemId() == android.R.id.home) {
// onBackPressed();
// }
// return true;
// }
//
// private void initViews() {
// setSupportActionBar((Toolbar) findViewById(R.id.toolbar));
// getSupportActionBar().setDisplayHomeAsUpEnabled(true);
// }
//
// }
// Path: app/src/androidTest/java/io/github/marktony/espresso/about/AboutScreenTest.java
import android.content.Context;
import android.content.Intent;
import android.support.test.InstrumentationRegistry;
import android.support.test.filters.SmallTest;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import io.github.marktony.espresso.R;
import io.github.marktony.espresso.ui.PrefsActivity;
import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.assertion.ViewAssertions.matches;
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static android.support.test.espresso.matcher.ViewMatchers.withParent;
import static android.support.test.espresso.matcher.ViewMatchers.withText;
import static org.hamcrest.core.AllOf.allOf;
package io.github.marktony.espresso.about;
/**
* Created by lizhaotailang on 2017/5/13.
* Tests for the {@link io.github.marktony.espresso.ui.AboutFragment}.
*/
@RunWith(AndroidJUnit4.class)
@SmallTest
public class AboutScreenTest {
/**
* {@link ActivityTestRule} is a JUnit {@link Rule @Rule} to launch your activity under test.
*
* <p>
* Rules are interceptors which are executed for each test method and are important building
* blocks of Junit tests.
*/
@Rule
|
public ActivityTestRule<PrefsActivity> mPrefsActivityTestRule
|
TonnyL/Espresso
|
app/src/main/java/io/github/marktony/espresso/mvp/addpackage/AddPackageContract.java
|
// Path: app/src/main/java/io/github/marktony/espresso/mvp/BasePresenter.java
// public interface BasePresenter {
//
// void subscribe();
//
// void unsubscribe();
//
// }
//
// Path: app/src/main/java/io/github/marktony/espresso/mvp/BaseView.java
// public interface BaseView<T> {
//
// void initViews(View view);
//
// void setPresenter(T presenter);
//
// }
|
import io.github.marktony.espresso.mvp.BasePresenter;
import io.github.marktony.espresso.mvp.BaseView;
|
/*
* Copyright(c) 2017 lizhaotailang
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.marktony.espresso.mvp.addpackage;
/**
* Created by lizhaotailang on 2017/2/10.
*/
public interface AddPackageContract {
interface View extends BaseView<Presenter> {
void showNumberExistError();
void showNumberError();
void setProgressIndicator(boolean loading);
void showPackagesList();
void showNetworkError();
}
|
// Path: app/src/main/java/io/github/marktony/espresso/mvp/BasePresenter.java
// public interface BasePresenter {
//
// void subscribe();
//
// void unsubscribe();
//
// }
//
// Path: app/src/main/java/io/github/marktony/espresso/mvp/BaseView.java
// public interface BaseView<T> {
//
// void initViews(View view);
//
// void setPresenter(T presenter);
//
// }
// Path: app/src/main/java/io/github/marktony/espresso/mvp/addpackage/AddPackageContract.java
import io.github.marktony.espresso.mvp.BasePresenter;
import io.github.marktony.espresso.mvp.BaseView;
/*
* Copyright(c) 2017 lizhaotailang
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.marktony.espresso.mvp.addpackage;
/**
* Created by lizhaotailang on 2017/2/10.
*/
public interface AddPackageContract {
interface View extends BaseView<Presenter> {
void showNumberExistError();
void showNumberError();
void setProgressIndicator(boolean loading);
void showPackagesList();
void showNetworkError();
}
|
interface Presenter extends BasePresenter {
|
TonnyL/Espresso
|
app/src/main/java/io/github/marktony/espresso/app/App.java
|
// Path: app/src/main/java/io/github/marktony/espresso/util/SettingsUtil.java
// public class SettingsUtil {
//
// public static final String KEY_ALERT = "alert";
// public static final String KEY_DO_NOT_DISTURB_MODE = "do_not_disturb_mode";
// public static final String KEY_DO_NOT_DISTURB_MODE_START_HOUR = "do_not_disturb_mode_start_hour";
// public static final String KEY_DO_NOT_DISTURB_MODE_START_MINUTE = "do_not_disturb_mode_start_minute";
// public static final String KEY_DO_NOT_DISTURB_MODE_END_HOUR = "do_not_disturb_mode_end_hour";
// public static final String KEY_DO_NOT_DISTURB_MODE_END_MINUTE = "do_not_disturb_mode_end_minute";
// public static final String KEY_NOTIFICATION_INTERVAL = "notification_interval";
//
// public static final String KEY_FIRST_LAUNCH = "first_launch";
//
// public static final String KEY_CUSTOM_TABS = "chrome_custom_tabs";
//
// public static final String KEY_NIGHT_MODE = "night_mode";
//
// }
|
import android.app.Application;
import android.preference.PreferenceManager;
import android.support.v7.app.AppCompatDelegate;
import io.github.marktony.espresso.util.SettingsUtil;
import io.realm.Realm;
|
/*
* Copyright(c) 2017 lizhaotailang
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.marktony.espresso.app;
/**
* Created by lizhaotailang on 2017/2/10.
*/
public class App extends Application {
@Override
public void onCreate() {
super.onCreate();
Realm.init(this);
|
// Path: app/src/main/java/io/github/marktony/espresso/util/SettingsUtil.java
// public class SettingsUtil {
//
// public static final String KEY_ALERT = "alert";
// public static final String KEY_DO_NOT_DISTURB_MODE = "do_not_disturb_mode";
// public static final String KEY_DO_NOT_DISTURB_MODE_START_HOUR = "do_not_disturb_mode_start_hour";
// public static final String KEY_DO_NOT_DISTURB_MODE_START_MINUTE = "do_not_disturb_mode_start_minute";
// public static final String KEY_DO_NOT_DISTURB_MODE_END_HOUR = "do_not_disturb_mode_end_hour";
// public static final String KEY_DO_NOT_DISTURB_MODE_END_MINUTE = "do_not_disturb_mode_end_minute";
// public static final String KEY_NOTIFICATION_INTERVAL = "notification_interval";
//
// public static final String KEY_FIRST_LAUNCH = "first_launch";
//
// public static final String KEY_CUSTOM_TABS = "chrome_custom_tabs";
//
// public static final String KEY_NIGHT_MODE = "night_mode";
//
// }
// Path: app/src/main/java/io/github/marktony/espresso/app/App.java
import android.app.Application;
import android.preference.PreferenceManager;
import android.support.v7.app.AppCompatDelegate;
import io.github.marktony.espresso.util.SettingsUtil;
import io.realm.Realm;
/*
* Copyright(c) 2017 lizhaotailang
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.marktony.espresso.app;
/**
* Created by lizhaotailang on 2017/2/10.
*/
public class App extends Application {
@Override
public void onCreate() {
super.onCreate();
Realm.init(this);
|
if (PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getBoolean(SettingsUtil.KEY_NIGHT_MODE, false)) {
|
TonnyL/Espresso
|
app/src/androidTest/java/io/github/marktony/espresso/settings/SettingsScreenTest.java
|
// Path: app/src/main/java/io/github/marktony/espresso/ui/PrefsActivity.java
// public class PrefsActivity extends AppCompatActivity {
//
// public static final String EXTRA_FLAG= "EXTRA_FLAG";
//
// public static final int FLAG_SETTINGS = 0, FLAG_ABOUT = 1, FLAG_LICENSES = 2;
//
// @Override
// protected void onCreate(@Nullable Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_prefs);
//
// // Set the navigation bar color
// if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean("navigation_bar_tint", true)) {
// getWindow().setNavigationBarColor(ContextCompat.getColor(this, R.color.colorPrimaryDark));
// }
//
// initViews();
//
// Intent intent = getIntent();
// Fragment fragment;
//
// if (intent.getIntExtra(EXTRA_FLAG, 0) == FLAG_SETTINGS) {
// setTitle(R.string.nav_settings);
// fragment = new SettingsFragment();
// } else if (intent.getIntExtra(EXTRA_FLAG, 0) == FLAG_ABOUT){
// setTitle(R.string.nav_about);
// fragment = new AboutFragment();
// } else if (intent.getIntExtra(EXTRA_FLAG, 0) == FLAG_LICENSES) {
// setTitle(R.string.licenses);
// fragment = new LicensesFragment();
// } else {
// throw new RuntimeException("Please set flag when launching PrefsActivity.");
// }
//
// getSupportFragmentManager()
// .beginTransaction()
// .replace(R.id.view_pager,fragment)
// .commit();
//
// }
//
// @Override
// public boolean onOptionsItemSelected(MenuItem item) {
// if (item.getItemId() == android.R.id.home) {
// onBackPressed();
// }
// return true;
// }
//
// private void initViews() {
// setSupportActionBar((Toolbar) findViewById(R.id.toolbar));
// getSupportActionBar().setDisplayHomeAsUpEnabled(true);
// }
//
// }
|
import android.content.Context;
import android.content.Intent;
import android.support.test.InstrumentationRegistry;
import android.support.test.filters.SmallTest;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import io.github.marktony.espresso.R;
import io.github.marktony.espresso.ui.PrefsActivity;
import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.assertion.ViewAssertions.matches;
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static android.support.test.espresso.matcher.ViewMatchers.withParent;
import static android.support.test.espresso.matcher.ViewMatchers.withText;
import static org.hamcrest.core.AllOf.allOf;
|
package io.github.marktony.espresso.settings;
/**
* Created by lizhaotailang on 2017/5/14.
* The tests for {@link io.github.marktony.espresso.ui.SettingsFragment}.
*/
@RunWith(AndroidJUnit4.class)
@SmallTest
public class SettingsScreenTest {
/**
* {@link ActivityTestRule} is a JUnit {@link Rule @Rule} to launch your activity under test.
*
* <p>
* Rules are interceptors which are executed for each test method and are important building
* blocks of Junit tests.
*/
@Rule
|
// Path: app/src/main/java/io/github/marktony/espresso/ui/PrefsActivity.java
// public class PrefsActivity extends AppCompatActivity {
//
// public static final String EXTRA_FLAG= "EXTRA_FLAG";
//
// public static final int FLAG_SETTINGS = 0, FLAG_ABOUT = 1, FLAG_LICENSES = 2;
//
// @Override
// protected void onCreate(@Nullable Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_prefs);
//
// // Set the navigation bar color
// if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean("navigation_bar_tint", true)) {
// getWindow().setNavigationBarColor(ContextCompat.getColor(this, R.color.colorPrimaryDark));
// }
//
// initViews();
//
// Intent intent = getIntent();
// Fragment fragment;
//
// if (intent.getIntExtra(EXTRA_FLAG, 0) == FLAG_SETTINGS) {
// setTitle(R.string.nav_settings);
// fragment = new SettingsFragment();
// } else if (intent.getIntExtra(EXTRA_FLAG, 0) == FLAG_ABOUT){
// setTitle(R.string.nav_about);
// fragment = new AboutFragment();
// } else if (intent.getIntExtra(EXTRA_FLAG, 0) == FLAG_LICENSES) {
// setTitle(R.string.licenses);
// fragment = new LicensesFragment();
// } else {
// throw new RuntimeException("Please set flag when launching PrefsActivity.");
// }
//
// getSupportFragmentManager()
// .beginTransaction()
// .replace(R.id.view_pager,fragment)
// .commit();
//
// }
//
// @Override
// public boolean onOptionsItemSelected(MenuItem item) {
// if (item.getItemId() == android.R.id.home) {
// onBackPressed();
// }
// return true;
// }
//
// private void initViews() {
// setSupportActionBar((Toolbar) findViewById(R.id.toolbar));
// getSupportActionBar().setDisplayHomeAsUpEnabled(true);
// }
//
// }
// Path: app/src/androidTest/java/io/github/marktony/espresso/settings/SettingsScreenTest.java
import android.content.Context;
import android.content.Intent;
import android.support.test.InstrumentationRegistry;
import android.support.test.filters.SmallTest;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import io.github.marktony.espresso.R;
import io.github.marktony.espresso.ui.PrefsActivity;
import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.assertion.ViewAssertions.matches;
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static android.support.test.espresso.matcher.ViewMatchers.withParent;
import static android.support.test.espresso.matcher.ViewMatchers.withText;
import static org.hamcrest.core.AllOf.allOf;
package io.github.marktony.espresso.settings;
/**
* Created by lizhaotailang on 2017/5/14.
* The tests for {@link io.github.marktony.espresso.ui.SettingsFragment}.
*/
@RunWith(AndroidJUnit4.class)
@SmallTest
public class SettingsScreenTest {
/**
* {@link ActivityTestRule} is a JUnit {@link Rule @Rule} to launch your activity under test.
*
* <p>
* Rules are interceptors which are executed for each test method and are important building
* blocks of Junit tests.
*/
@Rule
|
public ActivityTestRule<PrefsActivity> mPrefsActivityTestRule
|
TonnyL/Espresso
|
app/src/main/java/io/github/marktony/espresso/data/source/PackagesRepository.java
|
// Path: app/src/main/java/io/github/marktony/espresso/data/Package.java
// public class Package extends RealmObject {
//
// public static final int STATUS_FAILED = 2, STATUS_NORMAL = 0,
// STATUS_ON_THE_WAY = 5, STATUS_DELIVERED = 3,
// STATUS_RETURNED = 4, STATUS_RETURNING = 6,
// STATUS_OTHER = 1;
//
// @Expose
// @SerializedName("message")
// private String message;
// @Expose
// @SerializedName("nu")
// @PrimaryKey
// private String number;
// @Expose
// @SerializedName("ischeck")
// private String isCheck;
// @Expose
// @SerializedName("condition")
// private String condition;
// @Expose
// @SerializedName("com")
// private String company;
// @Expose
// @SerializedName("status")
// private String status;
// @Expose
// @SerializedName("state")
// private String state;
// @Expose
// @SerializedName("data")
// private RealmList<PackageStatus> data;
//
// @Expose
// private boolean pushable = false;
// @Expose
// private boolean readable = false;
// @Expose
// private String name;
// @Expose
// private String companyChineseName;
// @Expose
// private int colorAvatar;
// @Expose
// private long timestamp;
//
// public String getMessage() {
// return message;
// }
//
// public void setMessage(String message) {
// this.message = message;
// }
//
// public String getNumber() {
// return number;
// }
//
// public void setNumber(String number) {
// this.number = number;
// }
//
// public String getIsCheck() {
// return isCheck;
// }
//
// public void setIsCheck(String isCheck) {
// this.isCheck = isCheck;
// }
//
// public String getCondition() {
// return condition;
// }
//
// public void setCondition(String condition) {
// this.condition = condition;
// }
//
// public String getStatus() {
// return status;
// }
//
// public void setStatus(String status) {
// this.status = status;
// }
//
// public String getState() {
// return state;
// }
//
// public void setState(String state) {
// this.state = state;
// }
//
// public RealmList<PackageStatus> getData() {
// return data;
// }
//
// public void setData(RealmList<PackageStatus> data) {
// this.data = data;
// }
//
// public boolean isReadable() {
// return readable;
// }
//
// public void setReadable(boolean readable) {
// this.readable = readable;
// }
//
// public String getCompany() {
// return company;
// }
//
// public void setCompany(String company) {
// this.company = company;
// }
//
// public boolean isPushable() {
// return pushable;
// }
//
// public void setPushable(boolean pushable) {
// this.pushable = pushable;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getCompanyChineseName() {
// return companyChineseName;
// }
//
// public void setCompanyChineseName(String companyChineseName) {
// this.companyChineseName = companyChineseName;
// }
//
// public void setColorAvatar(int colorAvatar) {
// this.colorAvatar = colorAvatar;
// }
//
// public int getColorAvatar() {
// return colorAvatar;
// }
//
// public void setTimestamp(long timestamp) {
// this.timestamp = timestamp;
// }
//
// public long getTimestamp() {
// return timestamp;
// }
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
|
import io.reactivex.ObservableSource;
import io.reactivex.functions.Consumer;
import io.reactivex.functions.Function;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.Callable;
import io.github.marktony.espresso.data.Package;
import io.reactivex.Observable;
|
/*
* Copyright(c) 2017 lizhaotailang
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.marktony.espresso.data.source;
/**
* Created by lizhaotailang on 2017/2/12.
* Concrete implementation to load packages from the data sources into a cache.
* <p/>
* For simplicity, this implements a dumb synchronisation between locally persisted data and data
* obtained from the server, by using the remote data source only if the local database
* is not the latest.
*/
public class PackagesRepository implements PackagesDataSource {
@Nullable
private static PackagesRepository INSTANCE = null;
@NonNull
private final PackagesDataSource packagesRemoteDataSource;
@NonNull
private final PackagesDataSource packagesLocalDataSource;
|
// Path: app/src/main/java/io/github/marktony/espresso/data/Package.java
// public class Package extends RealmObject {
//
// public static final int STATUS_FAILED = 2, STATUS_NORMAL = 0,
// STATUS_ON_THE_WAY = 5, STATUS_DELIVERED = 3,
// STATUS_RETURNED = 4, STATUS_RETURNING = 6,
// STATUS_OTHER = 1;
//
// @Expose
// @SerializedName("message")
// private String message;
// @Expose
// @SerializedName("nu")
// @PrimaryKey
// private String number;
// @Expose
// @SerializedName("ischeck")
// private String isCheck;
// @Expose
// @SerializedName("condition")
// private String condition;
// @Expose
// @SerializedName("com")
// private String company;
// @Expose
// @SerializedName("status")
// private String status;
// @Expose
// @SerializedName("state")
// private String state;
// @Expose
// @SerializedName("data")
// private RealmList<PackageStatus> data;
//
// @Expose
// private boolean pushable = false;
// @Expose
// private boolean readable = false;
// @Expose
// private String name;
// @Expose
// private String companyChineseName;
// @Expose
// private int colorAvatar;
// @Expose
// private long timestamp;
//
// public String getMessage() {
// return message;
// }
//
// public void setMessage(String message) {
// this.message = message;
// }
//
// public String getNumber() {
// return number;
// }
//
// public void setNumber(String number) {
// this.number = number;
// }
//
// public String getIsCheck() {
// return isCheck;
// }
//
// public void setIsCheck(String isCheck) {
// this.isCheck = isCheck;
// }
//
// public String getCondition() {
// return condition;
// }
//
// public void setCondition(String condition) {
// this.condition = condition;
// }
//
// public String getStatus() {
// return status;
// }
//
// public void setStatus(String status) {
// this.status = status;
// }
//
// public String getState() {
// return state;
// }
//
// public void setState(String state) {
// this.state = state;
// }
//
// public RealmList<PackageStatus> getData() {
// return data;
// }
//
// public void setData(RealmList<PackageStatus> data) {
// this.data = data;
// }
//
// public boolean isReadable() {
// return readable;
// }
//
// public void setReadable(boolean readable) {
// this.readable = readable;
// }
//
// public String getCompany() {
// return company;
// }
//
// public void setCompany(String company) {
// this.company = company;
// }
//
// public boolean isPushable() {
// return pushable;
// }
//
// public void setPushable(boolean pushable) {
// this.pushable = pushable;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getCompanyChineseName() {
// return companyChineseName;
// }
//
// public void setCompanyChineseName(String companyChineseName) {
// this.companyChineseName = companyChineseName;
// }
//
// public void setColorAvatar(int colorAvatar) {
// this.colorAvatar = colorAvatar;
// }
//
// public int getColorAvatar() {
// return colorAvatar;
// }
//
// public void setTimestamp(long timestamp) {
// this.timestamp = timestamp;
// }
//
// public long getTimestamp() {
// return timestamp;
// }
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
// Path: app/src/main/java/io/github/marktony/espresso/data/source/PackagesRepository.java
import io.reactivex.ObservableSource;
import io.reactivex.functions.Consumer;
import io.reactivex.functions.Function;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.Callable;
import io.github.marktony.espresso.data.Package;
import io.reactivex.Observable;
/*
* Copyright(c) 2017 lizhaotailang
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.marktony.espresso.data.source;
/**
* Created by lizhaotailang on 2017/2/12.
* Concrete implementation to load packages from the data sources into a cache.
* <p/>
* For simplicity, this implements a dumb synchronisation between locally persisted data and data
* obtained from the server, by using the remote data source only if the local database
* is not the latest.
*/
public class PackagesRepository implements PackagesDataSource {
@Nullable
private static PackagesRepository INSTANCE = null;
@NonNull
private final PackagesDataSource packagesRemoteDataSource;
@NonNull
private final PackagesDataSource packagesLocalDataSource;
|
private Map<String, Package> cachedPackages;
|
TonnyL/Espresso
|
app/src/main/java/io/github/marktony/espresso/mvp/packages/PackagesContract.java
|
// Path: app/src/main/java/io/github/marktony/espresso/mvp/BasePresenter.java
// public interface BasePresenter {
//
// void subscribe();
//
// void unsubscribe();
//
// }
//
// Path: app/src/main/java/io/github/marktony/espresso/mvp/BaseView.java
// public interface BaseView<T> {
//
// void initViews(View view);
//
// void setPresenter(T presenter);
//
// }
//
// Path: app/src/main/java/io/github/marktony/espresso/data/Package.java
// public class Package extends RealmObject {
//
// public static final int STATUS_FAILED = 2, STATUS_NORMAL = 0,
// STATUS_ON_THE_WAY = 5, STATUS_DELIVERED = 3,
// STATUS_RETURNED = 4, STATUS_RETURNING = 6,
// STATUS_OTHER = 1;
//
// @Expose
// @SerializedName("message")
// private String message;
// @Expose
// @SerializedName("nu")
// @PrimaryKey
// private String number;
// @Expose
// @SerializedName("ischeck")
// private String isCheck;
// @Expose
// @SerializedName("condition")
// private String condition;
// @Expose
// @SerializedName("com")
// private String company;
// @Expose
// @SerializedName("status")
// private String status;
// @Expose
// @SerializedName("state")
// private String state;
// @Expose
// @SerializedName("data")
// private RealmList<PackageStatus> data;
//
// @Expose
// private boolean pushable = false;
// @Expose
// private boolean readable = false;
// @Expose
// private String name;
// @Expose
// private String companyChineseName;
// @Expose
// private int colorAvatar;
// @Expose
// private long timestamp;
//
// public String getMessage() {
// return message;
// }
//
// public void setMessage(String message) {
// this.message = message;
// }
//
// public String getNumber() {
// return number;
// }
//
// public void setNumber(String number) {
// this.number = number;
// }
//
// public String getIsCheck() {
// return isCheck;
// }
//
// public void setIsCheck(String isCheck) {
// this.isCheck = isCheck;
// }
//
// public String getCondition() {
// return condition;
// }
//
// public void setCondition(String condition) {
// this.condition = condition;
// }
//
// public String getStatus() {
// return status;
// }
//
// public void setStatus(String status) {
// this.status = status;
// }
//
// public String getState() {
// return state;
// }
//
// public void setState(String state) {
// this.state = state;
// }
//
// public RealmList<PackageStatus> getData() {
// return data;
// }
//
// public void setData(RealmList<PackageStatus> data) {
// this.data = data;
// }
//
// public boolean isReadable() {
// return readable;
// }
//
// public void setReadable(boolean readable) {
// this.readable = readable;
// }
//
// public String getCompany() {
// return company;
// }
//
// public void setCompany(String company) {
// this.company = company;
// }
//
// public boolean isPushable() {
// return pushable;
// }
//
// public void setPushable(boolean pushable) {
// this.pushable = pushable;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getCompanyChineseName() {
// return companyChineseName;
// }
//
// public void setCompanyChineseName(String companyChineseName) {
// this.companyChineseName = companyChineseName;
// }
//
// public void setColorAvatar(int colorAvatar) {
// this.colorAvatar = colorAvatar;
// }
//
// public int getColorAvatar() {
// return colorAvatar;
// }
//
// public void setTimestamp(long timestamp) {
// this.timestamp = timestamp;
// }
//
// public long getTimestamp() {
// return timestamp;
// }
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
|
import android.support.annotation.NonNull;
import java.util.List;
import io.github.marktony.espresso.mvp.BasePresenter;
import io.github.marktony.espresso.mvp.BaseView;
import io.github.marktony.espresso.data.Package;
|
/*
* Copyright(c) 2017 lizhaotailang
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.marktony.espresso.mvp.packages;
/**
* Created by lizhaotailang on 2017/2/10.
*/
public interface PackagesContract {
interface View extends BaseView<Presenter> {
void setLoadingIndicator(boolean active);
void showEmptyView(boolean toShow);
|
// Path: app/src/main/java/io/github/marktony/espresso/mvp/BasePresenter.java
// public interface BasePresenter {
//
// void subscribe();
//
// void unsubscribe();
//
// }
//
// Path: app/src/main/java/io/github/marktony/espresso/mvp/BaseView.java
// public interface BaseView<T> {
//
// void initViews(View view);
//
// void setPresenter(T presenter);
//
// }
//
// Path: app/src/main/java/io/github/marktony/espresso/data/Package.java
// public class Package extends RealmObject {
//
// public static final int STATUS_FAILED = 2, STATUS_NORMAL = 0,
// STATUS_ON_THE_WAY = 5, STATUS_DELIVERED = 3,
// STATUS_RETURNED = 4, STATUS_RETURNING = 6,
// STATUS_OTHER = 1;
//
// @Expose
// @SerializedName("message")
// private String message;
// @Expose
// @SerializedName("nu")
// @PrimaryKey
// private String number;
// @Expose
// @SerializedName("ischeck")
// private String isCheck;
// @Expose
// @SerializedName("condition")
// private String condition;
// @Expose
// @SerializedName("com")
// private String company;
// @Expose
// @SerializedName("status")
// private String status;
// @Expose
// @SerializedName("state")
// private String state;
// @Expose
// @SerializedName("data")
// private RealmList<PackageStatus> data;
//
// @Expose
// private boolean pushable = false;
// @Expose
// private boolean readable = false;
// @Expose
// private String name;
// @Expose
// private String companyChineseName;
// @Expose
// private int colorAvatar;
// @Expose
// private long timestamp;
//
// public String getMessage() {
// return message;
// }
//
// public void setMessage(String message) {
// this.message = message;
// }
//
// public String getNumber() {
// return number;
// }
//
// public void setNumber(String number) {
// this.number = number;
// }
//
// public String getIsCheck() {
// return isCheck;
// }
//
// public void setIsCheck(String isCheck) {
// this.isCheck = isCheck;
// }
//
// public String getCondition() {
// return condition;
// }
//
// public void setCondition(String condition) {
// this.condition = condition;
// }
//
// public String getStatus() {
// return status;
// }
//
// public void setStatus(String status) {
// this.status = status;
// }
//
// public String getState() {
// return state;
// }
//
// public void setState(String state) {
// this.state = state;
// }
//
// public RealmList<PackageStatus> getData() {
// return data;
// }
//
// public void setData(RealmList<PackageStatus> data) {
// this.data = data;
// }
//
// public boolean isReadable() {
// return readable;
// }
//
// public void setReadable(boolean readable) {
// this.readable = readable;
// }
//
// public String getCompany() {
// return company;
// }
//
// public void setCompany(String company) {
// this.company = company;
// }
//
// public boolean isPushable() {
// return pushable;
// }
//
// public void setPushable(boolean pushable) {
// this.pushable = pushable;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getCompanyChineseName() {
// return companyChineseName;
// }
//
// public void setCompanyChineseName(String companyChineseName) {
// this.companyChineseName = companyChineseName;
// }
//
// public void setColorAvatar(int colorAvatar) {
// this.colorAvatar = colorAvatar;
// }
//
// public int getColorAvatar() {
// return colorAvatar;
// }
//
// public void setTimestamp(long timestamp) {
// this.timestamp = timestamp;
// }
//
// public long getTimestamp() {
// return timestamp;
// }
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
// Path: app/src/main/java/io/github/marktony/espresso/mvp/packages/PackagesContract.java
import android.support.annotation.NonNull;
import java.util.List;
import io.github.marktony.espresso.mvp.BasePresenter;
import io.github.marktony.espresso.mvp.BaseView;
import io.github.marktony.espresso.data.Package;
/*
* Copyright(c) 2017 lizhaotailang
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.marktony.espresso.mvp.packages;
/**
* Created by lizhaotailang on 2017/2/10.
*/
public interface PackagesContract {
interface View extends BaseView<Presenter> {
void setLoadingIndicator(boolean active);
void showEmptyView(boolean toShow);
|
void showPackages(@NonNull List<Package> list);
|
TonnyL/Espresso
|
app/src/main/java/io/github/marktony/espresso/mvp/packages/PackagesContract.java
|
// Path: app/src/main/java/io/github/marktony/espresso/mvp/BasePresenter.java
// public interface BasePresenter {
//
// void subscribe();
//
// void unsubscribe();
//
// }
//
// Path: app/src/main/java/io/github/marktony/espresso/mvp/BaseView.java
// public interface BaseView<T> {
//
// void initViews(View view);
//
// void setPresenter(T presenter);
//
// }
//
// Path: app/src/main/java/io/github/marktony/espresso/data/Package.java
// public class Package extends RealmObject {
//
// public static final int STATUS_FAILED = 2, STATUS_NORMAL = 0,
// STATUS_ON_THE_WAY = 5, STATUS_DELIVERED = 3,
// STATUS_RETURNED = 4, STATUS_RETURNING = 6,
// STATUS_OTHER = 1;
//
// @Expose
// @SerializedName("message")
// private String message;
// @Expose
// @SerializedName("nu")
// @PrimaryKey
// private String number;
// @Expose
// @SerializedName("ischeck")
// private String isCheck;
// @Expose
// @SerializedName("condition")
// private String condition;
// @Expose
// @SerializedName("com")
// private String company;
// @Expose
// @SerializedName("status")
// private String status;
// @Expose
// @SerializedName("state")
// private String state;
// @Expose
// @SerializedName("data")
// private RealmList<PackageStatus> data;
//
// @Expose
// private boolean pushable = false;
// @Expose
// private boolean readable = false;
// @Expose
// private String name;
// @Expose
// private String companyChineseName;
// @Expose
// private int colorAvatar;
// @Expose
// private long timestamp;
//
// public String getMessage() {
// return message;
// }
//
// public void setMessage(String message) {
// this.message = message;
// }
//
// public String getNumber() {
// return number;
// }
//
// public void setNumber(String number) {
// this.number = number;
// }
//
// public String getIsCheck() {
// return isCheck;
// }
//
// public void setIsCheck(String isCheck) {
// this.isCheck = isCheck;
// }
//
// public String getCondition() {
// return condition;
// }
//
// public void setCondition(String condition) {
// this.condition = condition;
// }
//
// public String getStatus() {
// return status;
// }
//
// public void setStatus(String status) {
// this.status = status;
// }
//
// public String getState() {
// return state;
// }
//
// public void setState(String state) {
// this.state = state;
// }
//
// public RealmList<PackageStatus> getData() {
// return data;
// }
//
// public void setData(RealmList<PackageStatus> data) {
// this.data = data;
// }
//
// public boolean isReadable() {
// return readable;
// }
//
// public void setReadable(boolean readable) {
// this.readable = readable;
// }
//
// public String getCompany() {
// return company;
// }
//
// public void setCompany(String company) {
// this.company = company;
// }
//
// public boolean isPushable() {
// return pushable;
// }
//
// public void setPushable(boolean pushable) {
// this.pushable = pushable;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getCompanyChineseName() {
// return companyChineseName;
// }
//
// public void setCompanyChineseName(String companyChineseName) {
// this.companyChineseName = companyChineseName;
// }
//
// public void setColorAvatar(int colorAvatar) {
// this.colorAvatar = colorAvatar;
// }
//
// public int getColorAvatar() {
// return colorAvatar;
// }
//
// public void setTimestamp(long timestamp) {
// this.timestamp = timestamp;
// }
//
// public long getTimestamp() {
// return timestamp;
// }
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
|
import android.support.annotation.NonNull;
import java.util.List;
import io.github.marktony.espresso.mvp.BasePresenter;
import io.github.marktony.espresso.mvp.BaseView;
import io.github.marktony.espresso.data.Package;
|
/*
* Copyright(c) 2017 lizhaotailang
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.marktony.espresso.mvp.packages;
/**
* Created by lizhaotailang on 2017/2/10.
*/
public interface PackagesContract {
interface View extends BaseView<Presenter> {
void setLoadingIndicator(boolean active);
void showEmptyView(boolean toShow);
void showPackages(@NonNull List<Package> list);
void shareTo(@NonNull Package pack);
void showPackageRemovedMsg(String packageName);
void copyPackageNumber();
void showNetworkError();
}
|
// Path: app/src/main/java/io/github/marktony/espresso/mvp/BasePresenter.java
// public interface BasePresenter {
//
// void subscribe();
//
// void unsubscribe();
//
// }
//
// Path: app/src/main/java/io/github/marktony/espresso/mvp/BaseView.java
// public interface BaseView<T> {
//
// void initViews(View view);
//
// void setPresenter(T presenter);
//
// }
//
// Path: app/src/main/java/io/github/marktony/espresso/data/Package.java
// public class Package extends RealmObject {
//
// public static final int STATUS_FAILED = 2, STATUS_NORMAL = 0,
// STATUS_ON_THE_WAY = 5, STATUS_DELIVERED = 3,
// STATUS_RETURNED = 4, STATUS_RETURNING = 6,
// STATUS_OTHER = 1;
//
// @Expose
// @SerializedName("message")
// private String message;
// @Expose
// @SerializedName("nu")
// @PrimaryKey
// private String number;
// @Expose
// @SerializedName("ischeck")
// private String isCheck;
// @Expose
// @SerializedName("condition")
// private String condition;
// @Expose
// @SerializedName("com")
// private String company;
// @Expose
// @SerializedName("status")
// private String status;
// @Expose
// @SerializedName("state")
// private String state;
// @Expose
// @SerializedName("data")
// private RealmList<PackageStatus> data;
//
// @Expose
// private boolean pushable = false;
// @Expose
// private boolean readable = false;
// @Expose
// private String name;
// @Expose
// private String companyChineseName;
// @Expose
// private int colorAvatar;
// @Expose
// private long timestamp;
//
// public String getMessage() {
// return message;
// }
//
// public void setMessage(String message) {
// this.message = message;
// }
//
// public String getNumber() {
// return number;
// }
//
// public void setNumber(String number) {
// this.number = number;
// }
//
// public String getIsCheck() {
// return isCheck;
// }
//
// public void setIsCheck(String isCheck) {
// this.isCheck = isCheck;
// }
//
// public String getCondition() {
// return condition;
// }
//
// public void setCondition(String condition) {
// this.condition = condition;
// }
//
// public String getStatus() {
// return status;
// }
//
// public void setStatus(String status) {
// this.status = status;
// }
//
// public String getState() {
// return state;
// }
//
// public void setState(String state) {
// this.state = state;
// }
//
// public RealmList<PackageStatus> getData() {
// return data;
// }
//
// public void setData(RealmList<PackageStatus> data) {
// this.data = data;
// }
//
// public boolean isReadable() {
// return readable;
// }
//
// public void setReadable(boolean readable) {
// this.readable = readable;
// }
//
// public String getCompany() {
// return company;
// }
//
// public void setCompany(String company) {
// this.company = company;
// }
//
// public boolean isPushable() {
// return pushable;
// }
//
// public void setPushable(boolean pushable) {
// this.pushable = pushable;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getCompanyChineseName() {
// return companyChineseName;
// }
//
// public void setCompanyChineseName(String companyChineseName) {
// this.companyChineseName = companyChineseName;
// }
//
// public void setColorAvatar(int colorAvatar) {
// this.colorAvatar = colorAvatar;
// }
//
// public int getColorAvatar() {
// return colorAvatar;
// }
//
// public void setTimestamp(long timestamp) {
// this.timestamp = timestamp;
// }
//
// public long getTimestamp() {
// return timestamp;
// }
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
// Path: app/src/main/java/io/github/marktony/espresso/mvp/packages/PackagesContract.java
import android.support.annotation.NonNull;
import java.util.List;
import io.github.marktony.espresso.mvp.BasePresenter;
import io.github.marktony.espresso.mvp.BaseView;
import io.github.marktony.espresso.data.Package;
/*
* Copyright(c) 2017 lizhaotailang
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.marktony.espresso.mvp.packages;
/**
* Created by lizhaotailang on 2017/2/10.
*/
public interface PackagesContract {
interface View extends BaseView<Presenter> {
void setLoadingIndicator(boolean active);
void showEmptyView(boolean toShow);
void showPackages(@NonNull List<Package> list);
void shareTo(@NonNull Package pack);
void showPackageRemovedMsg(String packageName);
void copyPackageNumber();
void showNetworkError();
}
|
interface Presenter extends BasePresenter {
|
TonnyL/Espresso
|
app/src/main/java/io/github/marktony/espresso/appwidget/AppWidgetProvider.java
|
// Path: app/src/main/java/io/github/marktony/espresso/mvp/packagedetails/PackageDetailsActivity.java
// public class PackageDetailsActivity extends AppCompatActivity{
//
// private PackageDetailsFragment fragment;
//
// public static final String PACKAGE_ID = "PACKAGE_ID";
//
// @Override
// protected void onCreate(@Nullable Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.container);
//
// // Set the navigation bar color
// if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean("navigation_bar_tint", true)) {
// getWindow().setNavigationBarColor(ContextCompat.getColor(this, R.color.colorPrimaryDark));
// }
//
// // Restore the status.
// if (savedInstanceState != null) {
// fragment = (PackageDetailsFragment) getSupportFragmentManager().getFragment(savedInstanceState, "PackageDetailsFragment");
// } else {
// fragment = PackageDetailsFragment.newInstance();
// }
//
// getSupportFragmentManager().beginTransaction()
// .replace(R.id.view_pager, fragment)
// .commit();
//
// // Create the presenter.
// new PackageDetailsPresenter(
// getIntent().getStringExtra(PACKAGE_ID),
// PackagesRepository.getInstance(
// PackagesRemoteDataSource.getInstance(),
// PackagesLocalDataSource.getInstance()),
// fragment);
//
// }
//
// // Save the fragment state to bundle.
// @Override
// protected void onSaveInstanceState(Bundle outState) {
// super.onSaveInstanceState(outState);
// getSupportFragmentManager().putFragment(outState, "PackageDetailsFragment", fragment);
// }
//
// }
|
import android.app.PendingIntent;
import android.appwidget.AppWidgetManager;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.widget.RemoteViews;
import io.github.marktony.espresso.R;
import io.github.marktony.espresso.mvp.packagedetails.PackageDetailsActivity;
|
/*
* Copyright(c) 2017 lizhaotailang
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.marktony.espresso.appwidget;
/**
* Created by lizhaotailang on 2017/3/8.
*/
public class AppWidgetProvider extends android.appwidget.AppWidgetProvider {
private static final String REFRESH_ACTION = "io.github.marktony.espresso.appwidget.action.REFRESH";
public static Intent getRefreshBroadcastIntent(Context context) {
return new Intent(REFRESH_ACTION)
.setComponent(new ComponentName(context, AppWidgetProvider.class));
}
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
for (int appWidgetId : appWidgetIds) {
RemoteViews remoteViews = updateWidgetListView(context, appWidgetId);
appWidgetManager.updateAppWidget(appWidgetId, remoteViews);
}
super.onUpdate(context, appWidgetManager, appWidgetIds);
}
private RemoteViews updateWidgetListView(Context context, int id) {
RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.launcher_list_widget);
Intent intent = new Intent(context, AppWidgetService.class);
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, id);
intent.setData(Uri.parse(intent.toUri(Intent.URI_INTENT_SCHEME)));
remoteViews.setRemoteAdapter(R.id.listViewWidget, intent);
remoteViews.setEmptyView(R.id.listViewWidget, R.id.emptyView);
|
// Path: app/src/main/java/io/github/marktony/espresso/mvp/packagedetails/PackageDetailsActivity.java
// public class PackageDetailsActivity extends AppCompatActivity{
//
// private PackageDetailsFragment fragment;
//
// public static final String PACKAGE_ID = "PACKAGE_ID";
//
// @Override
// protected void onCreate(@Nullable Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.container);
//
// // Set the navigation bar color
// if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean("navigation_bar_tint", true)) {
// getWindow().setNavigationBarColor(ContextCompat.getColor(this, R.color.colorPrimaryDark));
// }
//
// // Restore the status.
// if (savedInstanceState != null) {
// fragment = (PackageDetailsFragment) getSupportFragmentManager().getFragment(savedInstanceState, "PackageDetailsFragment");
// } else {
// fragment = PackageDetailsFragment.newInstance();
// }
//
// getSupportFragmentManager().beginTransaction()
// .replace(R.id.view_pager, fragment)
// .commit();
//
// // Create the presenter.
// new PackageDetailsPresenter(
// getIntent().getStringExtra(PACKAGE_ID),
// PackagesRepository.getInstance(
// PackagesRemoteDataSource.getInstance(),
// PackagesLocalDataSource.getInstance()),
// fragment);
//
// }
//
// // Save the fragment state to bundle.
// @Override
// protected void onSaveInstanceState(Bundle outState) {
// super.onSaveInstanceState(outState);
// getSupportFragmentManager().putFragment(outState, "PackageDetailsFragment", fragment);
// }
//
// }
// Path: app/src/main/java/io/github/marktony/espresso/appwidget/AppWidgetProvider.java
import android.app.PendingIntent;
import android.appwidget.AppWidgetManager;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.widget.RemoteViews;
import io.github.marktony.espresso.R;
import io.github.marktony.espresso.mvp.packagedetails.PackageDetailsActivity;
/*
* Copyright(c) 2017 lizhaotailang
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.marktony.espresso.appwidget;
/**
* Created by lizhaotailang on 2017/3/8.
*/
public class AppWidgetProvider extends android.appwidget.AppWidgetProvider {
private static final String REFRESH_ACTION = "io.github.marktony.espresso.appwidget.action.REFRESH";
public static Intent getRefreshBroadcastIntent(Context context) {
return new Intent(REFRESH_ACTION)
.setComponent(new ComponentName(context, AppWidgetProvider.class));
}
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
for (int appWidgetId : appWidgetIds) {
RemoteViews remoteViews = updateWidgetListView(context, appWidgetId);
appWidgetManager.updateAppWidget(appWidgetId, remoteViews);
}
super.onUpdate(context, appWidgetManager, appWidgetIds);
}
private RemoteViews updateWidgetListView(Context context, int id) {
RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.launcher_list_widget);
Intent intent = new Intent(context, AppWidgetService.class);
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, id);
intent.setData(Uri.parse(intent.toUri(Intent.URI_INTENT_SCHEME)));
remoteViews.setRemoteAdapter(R.id.listViewWidget, intent);
remoteViews.setEmptyView(R.id.listViewWidget, R.id.emptyView);
|
Intent tempIntent = new Intent(context, PackageDetailsActivity.class);
|
TonnyL/Espresso
|
app/src/main/java/io/github/marktony/espresso/mvp/companydetails/CompanyDetailPresenter.java
|
// Path: app/src/main/java/io/github/marktony/espresso/data/Company.java
// public class Company extends RealmObject {
//
// @Expose
// @SerializedName("name")
// private String name;
//
// @PrimaryKey
// @Expose
// @SerializedName("id")
// private String id;
//
// @Expose
// @SerializedName("tel")
// private String tel;
//
// @Expose
// @SerializedName("website")
// private String website;
//
// @Expose
// @SerializedName("alphabet")
// private String alphabet;
//
// @Expose
// @SerializedName("avatar")
// private String avatar;
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getTel() {
// return tel;
// }
//
// public void setTel(String tel) {
// this.tel = tel;
// }
//
// public String getWebsite() {
// return website;
// }
//
// public void setWebsite(String website) {
// this.website = website;
// }
//
// public String getAlphabet() {
// return alphabet;
// }
//
// public void setAlphabet(String alphabet) {
// this.alphabet = alphabet;
// }
//
// public String getAvatarColor() {
// return avatar;
// }
//
// public void setAvatarColor(String avatar) {
// this.avatar = avatar;
// }
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: app/src/main/java/io/github/marktony/espresso/data/source/CompaniesRepository.java
// public class CompaniesRepository implements CompaniesDataSource {
//
// @Nullable
// private static CompaniesRepository INSTANCE = null;
//
// @NonNull
// private final CompaniesDataSource localDataSource;
//
// // Prevent direct instantiation
// private CompaniesRepository(@NonNull CompaniesDataSource localDataSource) {
// this.localDataSource = localDataSource;
// }
//
// public static CompaniesRepository getInstance(@NonNull CompaniesDataSource localDataSource) {
// if (INSTANCE == null) {
// INSTANCE = new CompaniesRepository(localDataSource);
// }
// return INSTANCE;
// }
//
// @Override
// public Observable<List<Company>> getCompanies() {
// return localDataSource.getCompanies();
// }
//
// @Override
// public Observable<Company> getCompany(@NonNull String companyId) {
// return localDataSource.getCompany(companyId);
// }
//
// @Override
// public void initData() {
// localDataSource.initData();
// }
//
// @Override
// public Observable<List<Company>> searchCompanies(@NonNull String keyWords) {
// return localDataSource.searchCompanies(keyWords);
// }
//
// }
|
import android.support.annotation.NonNull;
import io.github.marktony.espresso.data.Company;
import io.github.marktony.espresso.data.source.CompaniesRepository;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.CompositeDisposable;
import io.reactivex.disposables.Disposable;
import io.reactivex.observers.DisposableObserver;
import io.reactivex.schedulers.Schedulers;
|
/*
* Copyright(c) 2017 lizhaotailang
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.marktony.espresso.mvp.companydetails;
/**
* Created by lizhaotailang on 2017/2/10.
*/
public class CompanyDetailPresenter implements CompanyDetailContract.Presenter {
@NonNull
private CompanyDetailContract.View view;
@NonNull
|
// Path: app/src/main/java/io/github/marktony/espresso/data/Company.java
// public class Company extends RealmObject {
//
// @Expose
// @SerializedName("name")
// private String name;
//
// @PrimaryKey
// @Expose
// @SerializedName("id")
// private String id;
//
// @Expose
// @SerializedName("tel")
// private String tel;
//
// @Expose
// @SerializedName("website")
// private String website;
//
// @Expose
// @SerializedName("alphabet")
// private String alphabet;
//
// @Expose
// @SerializedName("avatar")
// private String avatar;
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getTel() {
// return tel;
// }
//
// public void setTel(String tel) {
// this.tel = tel;
// }
//
// public String getWebsite() {
// return website;
// }
//
// public void setWebsite(String website) {
// this.website = website;
// }
//
// public String getAlphabet() {
// return alphabet;
// }
//
// public void setAlphabet(String alphabet) {
// this.alphabet = alphabet;
// }
//
// public String getAvatarColor() {
// return avatar;
// }
//
// public void setAvatarColor(String avatar) {
// this.avatar = avatar;
// }
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: app/src/main/java/io/github/marktony/espresso/data/source/CompaniesRepository.java
// public class CompaniesRepository implements CompaniesDataSource {
//
// @Nullable
// private static CompaniesRepository INSTANCE = null;
//
// @NonNull
// private final CompaniesDataSource localDataSource;
//
// // Prevent direct instantiation
// private CompaniesRepository(@NonNull CompaniesDataSource localDataSource) {
// this.localDataSource = localDataSource;
// }
//
// public static CompaniesRepository getInstance(@NonNull CompaniesDataSource localDataSource) {
// if (INSTANCE == null) {
// INSTANCE = new CompaniesRepository(localDataSource);
// }
// return INSTANCE;
// }
//
// @Override
// public Observable<List<Company>> getCompanies() {
// return localDataSource.getCompanies();
// }
//
// @Override
// public Observable<Company> getCompany(@NonNull String companyId) {
// return localDataSource.getCompany(companyId);
// }
//
// @Override
// public void initData() {
// localDataSource.initData();
// }
//
// @Override
// public Observable<List<Company>> searchCompanies(@NonNull String keyWords) {
// return localDataSource.searchCompanies(keyWords);
// }
//
// }
// Path: app/src/main/java/io/github/marktony/espresso/mvp/companydetails/CompanyDetailPresenter.java
import android.support.annotation.NonNull;
import io.github.marktony.espresso.data.Company;
import io.github.marktony.espresso.data.source.CompaniesRepository;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.CompositeDisposable;
import io.reactivex.disposables.Disposable;
import io.reactivex.observers.DisposableObserver;
import io.reactivex.schedulers.Schedulers;
/*
* Copyright(c) 2017 lizhaotailang
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.marktony.espresso.mvp.companydetails;
/**
* Created by lizhaotailang on 2017/2/10.
*/
public class CompanyDetailPresenter implements CompanyDetailContract.Presenter {
@NonNull
private CompanyDetailContract.View view;
@NonNull
|
private CompaniesRepository companiesRepository;
|
TonnyL/Espresso
|
app/src/main/java/io/github/marktony/espresso/mvp/companydetails/CompanyDetailPresenter.java
|
// Path: app/src/main/java/io/github/marktony/espresso/data/Company.java
// public class Company extends RealmObject {
//
// @Expose
// @SerializedName("name")
// private String name;
//
// @PrimaryKey
// @Expose
// @SerializedName("id")
// private String id;
//
// @Expose
// @SerializedName("tel")
// private String tel;
//
// @Expose
// @SerializedName("website")
// private String website;
//
// @Expose
// @SerializedName("alphabet")
// private String alphabet;
//
// @Expose
// @SerializedName("avatar")
// private String avatar;
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getTel() {
// return tel;
// }
//
// public void setTel(String tel) {
// this.tel = tel;
// }
//
// public String getWebsite() {
// return website;
// }
//
// public void setWebsite(String website) {
// this.website = website;
// }
//
// public String getAlphabet() {
// return alphabet;
// }
//
// public void setAlphabet(String alphabet) {
// this.alphabet = alphabet;
// }
//
// public String getAvatarColor() {
// return avatar;
// }
//
// public void setAvatarColor(String avatar) {
// this.avatar = avatar;
// }
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: app/src/main/java/io/github/marktony/espresso/data/source/CompaniesRepository.java
// public class CompaniesRepository implements CompaniesDataSource {
//
// @Nullable
// private static CompaniesRepository INSTANCE = null;
//
// @NonNull
// private final CompaniesDataSource localDataSource;
//
// // Prevent direct instantiation
// private CompaniesRepository(@NonNull CompaniesDataSource localDataSource) {
// this.localDataSource = localDataSource;
// }
//
// public static CompaniesRepository getInstance(@NonNull CompaniesDataSource localDataSource) {
// if (INSTANCE == null) {
// INSTANCE = new CompaniesRepository(localDataSource);
// }
// return INSTANCE;
// }
//
// @Override
// public Observable<List<Company>> getCompanies() {
// return localDataSource.getCompanies();
// }
//
// @Override
// public Observable<Company> getCompany(@NonNull String companyId) {
// return localDataSource.getCompany(companyId);
// }
//
// @Override
// public void initData() {
// localDataSource.initData();
// }
//
// @Override
// public Observable<List<Company>> searchCompanies(@NonNull String keyWords) {
// return localDataSource.searchCompanies(keyWords);
// }
//
// }
|
import android.support.annotation.NonNull;
import io.github.marktony.espresso.data.Company;
import io.github.marktony.espresso.data.source.CompaniesRepository;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.CompositeDisposable;
import io.reactivex.disposables.Disposable;
import io.reactivex.observers.DisposableObserver;
import io.reactivex.schedulers.Schedulers;
|
private String companyId;
@NonNull
private CompositeDisposable compositeDisposable;
public CompanyDetailPresenter(@NonNull CompanyDetailContract.View view,
@NonNull CompaniesRepository companiesRepository,
@NonNull String companyId) {
this.view = view;
this.companiesRepository = companiesRepository;
this.companyId = companyId;
this.view.setPresenter(this);
compositeDisposable = new CompositeDisposable();
}
@Override
public void subscribe() {
fetchCompanyData();
}
@Override
public void unsubscribe() {
compositeDisposable.clear();
}
private void fetchCompanyData() {
Disposable disposable = companiesRepository
.getCompany(companyId)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
|
// Path: app/src/main/java/io/github/marktony/espresso/data/Company.java
// public class Company extends RealmObject {
//
// @Expose
// @SerializedName("name")
// private String name;
//
// @PrimaryKey
// @Expose
// @SerializedName("id")
// private String id;
//
// @Expose
// @SerializedName("tel")
// private String tel;
//
// @Expose
// @SerializedName("website")
// private String website;
//
// @Expose
// @SerializedName("alphabet")
// private String alphabet;
//
// @Expose
// @SerializedName("avatar")
// private String avatar;
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getTel() {
// return tel;
// }
//
// public void setTel(String tel) {
// this.tel = tel;
// }
//
// public String getWebsite() {
// return website;
// }
//
// public void setWebsite(String website) {
// this.website = website;
// }
//
// public String getAlphabet() {
// return alphabet;
// }
//
// public void setAlphabet(String alphabet) {
// this.alphabet = alphabet;
// }
//
// public String getAvatarColor() {
// return avatar;
// }
//
// public void setAvatarColor(String avatar) {
// this.avatar = avatar;
// }
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: app/src/main/java/io/github/marktony/espresso/data/source/CompaniesRepository.java
// public class CompaniesRepository implements CompaniesDataSource {
//
// @Nullable
// private static CompaniesRepository INSTANCE = null;
//
// @NonNull
// private final CompaniesDataSource localDataSource;
//
// // Prevent direct instantiation
// private CompaniesRepository(@NonNull CompaniesDataSource localDataSource) {
// this.localDataSource = localDataSource;
// }
//
// public static CompaniesRepository getInstance(@NonNull CompaniesDataSource localDataSource) {
// if (INSTANCE == null) {
// INSTANCE = new CompaniesRepository(localDataSource);
// }
// return INSTANCE;
// }
//
// @Override
// public Observable<List<Company>> getCompanies() {
// return localDataSource.getCompanies();
// }
//
// @Override
// public Observable<Company> getCompany(@NonNull String companyId) {
// return localDataSource.getCompany(companyId);
// }
//
// @Override
// public void initData() {
// localDataSource.initData();
// }
//
// @Override
// public Observable<List<Company>> searchCompanies(@NonNull String keyWords) {
// return localDataSource.searchCompanies(keyWords);
// }
//
// }
// Path: app/src/main/java/io/github/marktony/espresso/mvp/companydetails/CompanyDetailPresenter.java
import android.support.annotation.NonNull;
import io.github.marktony.espresso.data.Company;
import io.github.marktony.espresso.data.source.CompaniesRepository;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.CompositeDisposable;
import io.reactivex.disposables.Disposable;
import io.reactivex.observers.DisposableObserver;
import io.reactivex.schedulers.Schedulers;
private String companyId;
@NonNull
private CompositeDisposable compositeDisposable;
public CompanyDetailPresenter(@NonNull CompanyDetailContract.View view,
@NonNull CompaniesRepository companiesRepository,
@NonNull String companyId) {
this.view = view;
this.companiesRepository = companiesRepository;
this.companyId = companyId;
this.view.setPresenter(this);
compositeDisposable = new CompositeDisposable();
}
@Override
public void subscribe() {
fetchCompanyData();
}
@Override
public void unsubscribe() {
compositeDisposable.clear();
}
private void fetchCompanyData() {
Disposable disposable = companiesRepository
.getCompany(companyId)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
|
.subscribeWith(new DisposableObserver<Company>() {
|
TonnyL/Espresso
|
app/src/main/java/io/github/marktony/espresso/ui/AboutFragment.java
|
// Path: app/src/main/java/io/github/marktony/espresso/customtabs/CustomTabsHelper.java
// public class CustomTabsHelper {
//
// public static void openUrl(Context context, String url) {
// SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
//
// if (sharedPreferences.getBoolean(SettingsUtil.KEY_CUSTOM_TABS, true)) {
// CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
// builder.setToolbarColor(ContextCompat.getColor(context, R.color.colorPrimaryDark));
// builder.build().launchUrl(context, Uri.parse(url));
// } else {
// try {
// context.startActivity(new Intent(Intent.ACTION_VIEW).setData(Uri.parse(url)));
// } catch (ActivityNotFoundException e) {
// Toast.makeText(context, R.string.error_no_browser, Toast.LENGTH_SHORT).show();
// }
// }
// }
//
// }
|
import io.github.marktony.espresso.customtabs.CustomTabsHelper;
import static android.content.Context.CLIPBOARD_SERVICE;
import android.content.ActivityNotFoundException;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.v7.app.AlertDialog;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceFragmentCompat;
import android.widget.Toast;
import io.github.marktony.espresso.BuildConfig;
import io.github.marktony.espresso.R;
|
@Override
public boolean onPreferenceClick(Preference preference) {
try {
Uri uri = Uri.parse("market://details?id=" + getActivity().getPackageName());
Intent intent = new Intent(Intent.ACTION_VIEW,uri);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
} catch (android.content.ActivityNotFoundException ex){
showError();
}
return true;
}
});
// Licenses
prefLicenses.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
Intent intent = new Intent(getContext(), PrefsActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.putExtra(PrefsActivity.EXTRA_FLAG, PrefsActivity.FLAG_LICENSES);
startActivity(intent);
return true;
}
});
// Thanks 1
prefThx1.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
|
// Path: app/src/main/java/io/github/marktony/espresso/customtabs/CustomTabsHelper.java
// public class CustomTabsHelper {
//
// public static void openUrl(Context context, String url) {
// SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
//
// if (sharedPreferences.getBoolean(SettingsUtil.KEY_CUSTOM_TABS, true)) {
// CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
// builder.setToolbarColor(ContextCompat.getColor(context, R.color.colorPrimaryDark));
// builder.build().launchUrl(context, Uri.parse(url));
// } else {
// try {
// context.startActivity(new Intent(Intent.ACTION_VIEW).setData(Uri.parse(url)));
// } catch (ActivityNotFoundException e) {
// Toast.makeText(context, R.string.error_no_browser, Toast.LENGTH_SHORT).show();
// }
// }
// }
//
// }
// Path: app/src/main/java/io/github/marktony/espresso/ui/AboutFragment.java
import io.github.marktony.espresso.customtabs.CustomTabsHelper;
import static android.content.Context.CLIPBOARD_SERVICE;
import android.content.ActivityNotFoundException;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.v7.app.AlertDialog;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceFragmentCompat;
import android.widget.Toast;
import io.github.marktony.espresso.BuildConfig;
import io.github.marktony.espresso.R;
@Override
public boolean onPreferenceClick(Preference preference) {
try {
Uri uri = Uri.parse("market://details?id=" + getActivity().getPackageName());
Intent intent = new Intent(Intent.ACTION_VIEW,uri);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
} catch (android.content.ActivityNotFoundException ex){
showError();
}
return true;
}
});
// Licenses
prefLicenses.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
Intent intent = new Intent(getContext(), PrefsActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.putExtra(PrefsActivity.EXTRA_FLAG, PrefsActivity.FLAG_LICENSES);
startActivity(intent);
return true;
}
});
// Thanks 1
prefThx1.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
|
CustomTabsHelper.openUrl(getContext(), getString(R.string.thanks_1_url));
|
TonnyL/Espresso
|
app/src/androidTest/java/io/github/marktony/espresso/addpackage/AddPackageScreenTest.java
|
// Path: app/src/main/java/io/github/marktony/espresso/mvp/addpackage/AddPackageActivity.java
// public class AddPackageActivity extends AppCompatActivity {
//
// private AddPackageFragment fragment;
//
// @Override
// protected void onCreate(@Nullable Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.container);
//
// // Set the navigation bar color
// if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean("navigation_bar_tint", true)) {
// getWindow().setNavigationBarColor(ContextCompat.getColor(this, R.color.colorPrimaryDark));
// }
//
// if (savedInstanceState != null) {
// fragment = (AddPackageFragment) getSupportFragmentManager().getFragment(savedInstanceState, "AddPackageFragment");
// } else {
// fragment = AddPackageFragment.newInstance();
// }
//
// if (!fragment.isAdded()) {
// getSupportFragmentManager().beginTransaction()
// .replace(R.id.view_pager, fragment, "AddPackageFragment")
// .commit();
// }
//
// // Create the presenter.
// new AddPackagePresenter(PackagesRepository.getInstance(
// PackagesRemoteDataSource.getInstance(),
// PackagesLocalDataSource.getInstance()),
// CompaniesRepository.getInstance(CompaniesLocalDataSource.getInstance()),
// fragment);
//
// }
//
// // Save the fragment state to bundle.
// @Override
// protected void onSaveInstanceState(Bundle outState) {
// super.onSaveInstanceState(outState);
// getSupportFragmentManager().putFragment(outState, "AddPackageFragment", fragment);
// }
//
// }
|
import android.os.Build;
import android.support.test.espresso.matcher.ViewMatchers;
import android.support.test.filters.LargeTest;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import io.github.marktony.espresso.R;
import io.github.marktony.espresso.mvp.addpackage.AddPackageActivity;
import static android.support.test.InstrumentationRegistry.getInstrumentation;
import static android.support.test.InstrumentationRegistry.getTargetContext;
import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.action.ViewActions.click;
import static android.support.test.espresso.action.ViewActions.closeSoftKeyboard;
import static android.support.test.espresso.action.ViewActions.typeText;
import static android.support.test.espresso.assertion.ViewAssertions.matches;
import static android.support.test.espresso.matcher.ViewMatchers.isCompletelyDisplayed;
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static android.support.test.espresso.matcher.ViewMatchers.withParent;
import static android.support.test.espresso.matcher.ViewMatchers.withText;
import static org.hamcrest.core.AllOf.allOf;
|
package io.github.marktony.espresso.addpackage;
/**
* Created by lizhaotailang on 2017/5/14.
* Tests the components of {@link AddPackageActivity} layout.
*/
@RunWith(AndroidJUnit4.class)
@LargeTest
public class AddPackageScreenTest {
private String validPackageNumber;
private String invalidPackageNumber;
/**
* {@link ActivityTestRule} is a JUnit {@link Rule @Rule} to launch your activity under test.
*
* <p>
* Rules are interceptors which are executed for each test method and are important building
* blocks of Junit tests.
*/
@Rule
|
// Path: app/src/main/java/io/github/marktony/espresso/mvp/addpackage/AddPackageActivity.java
// public class AddPackageActivity extends AppCompatActivity {
//
// private AddPackageFragment fragment;
//
// @Override
// protected void onCreate(@Nullable Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.container);
//
// // Set the navigation bar color
// if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean("navigation_bar_tint", true)) {
// getWindow().setNavigationBarColor(ContextCompat.getColor(this, R.color.colorPrimaryDark));
// }
//
// if (savedInstanceState != null) {
// fragment = (AddPackageFragment) getSupportFragmentManager().getFragment(savedInstanceState, "AddPackageFragment");
// } else {
// fragment = AddPackageFragment.newInstance();
// }
//
// if (!fragment.isAdded()) {
// getSupportFragmentManager().beginTransaction()
// .replace(R.id.view_pager, fragment, "AddPackageFragment")
// .commit();
// }
//
// // Create the presenter.
// new AddPackagePresenter(PackagesRepository.getInstance(
// PackagesRemoteDataSource.getInstance(),
// PackagesLocalDataSource.getInstance()),
// CompaniesRepository.getInstance(CompaniesLocalDataSource.getInstance()),
// fragment);
//
// }
//
// // Save the fragment state to bundle.
// @Override
// protected void onSaveInstanceState(Bundle outState) {
// super.onSaveInstanceState(outState);
// getSupportFragmentManager().putFragment(outState, "AddPackageFragment", fragment);
// }
//
// }
// Path: app/src/androidTest/java/io/github/marktony/espresso/addpackage/AddPackageScreenTest.java
import android.os.Build;
import android.support.test.espresso.matcher.ViewMatchers;
import android.support.test.filters.LargeTest;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import io.github.marktony.espresso.R;
import io.github.marktony.espresso.mvp.addpackage.AddPackageActivity;
import static android.support.test.InstrumentationRegistry.getInstrumentation;
import static android.support.test.InstrumentationRegistry.getTargetContext;
import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.action.ViewActions.click;
import static android.support.test.espresso.action.ViewActions.closeSoftKeyboard;
import static android.support.test.espresso.action.ViewActions.typeText;
import static android.support.test.espresso.assertion.ViewAssertions.matches;
import static android.support.test.espresso.matcher.ViewMatchers.isCompletelyDisplayed;
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static android.support.test.espresso.matcher.ViewMatchers.withParent;
import static android.support.test.espresso.matcher.ViewMatchers.withText;
import static org.hamcrest.core.AllOf.allOf;
package io.github.marktony.espresso.addpackage;
/**
* Created by lizhaotailang on 2017/5/14.
* Tests the components of {@link AddPackageActivity} layout.
*/
@RunWith(AndroidJUnit4.class)
@LargeTest
public class AddPackageScreenTest {
private String validPackageNumber;
private String invalidPackageNumber;
/**
* {@link ActivityTestRule} is a JUnit {@link Rule @Rule} to launch your activity under test.
*
* <p>
* Rules are interceptors which are executed for each test method and are important building
* blocks of Junit tests.
*/
@Rule
|
public ActivityTestRule<AddPackageActivity> mAddPackageActivityTestRule
|
TonnyL/Espresso
|
app/src/main/java/io/github/marktony/espresso/component/FastScroller.java
|
// Path: app/src/main/java/io/github/marktony/espresso/interfaze/OnFastScrollStateChangeListener.java
// public interface OnFastScrollStateChangeListener {
//
// /**
// * Called when fast scrolling begins
// */
// void onFastScrollStart();
//
// /**
// * Called when fast scrolling ends
// */
// void onFastScrollStop();
//
//
// }
//
// Path: app/src/main/java/io/github/marktony/espresso/util/DensityUtil.java
// public class DensityUtil {
//
// public static int getScreenHeight(Context context) {
// DisplayMetrics displayMetrics = new DisplayMetrics();
// ((Activity) context).getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
// return displayMetrics.heightPixels;
// }
//
// public static int getScreenWidth(Context context) {
// DisplayMetrics displayMetrics = new DisplayMetrics();
// ((Activity) context).getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
// return displayMetrics.widthPixels;
// }
//
// public static int getScreenHeightWithDecorations(Context context) {
// int heightPixes;
// WindowManager windowManager = ((Activity) context).getWindowManager();
// Display display = windowManager.getDefaultDisplay();
// Point realSize = new Point();
// try {
// Display.class.getMethod("getRealSize", Point.class).invoke(display, realSize);
// } catch (NoSuchMethodException e) {
// e.printStackTrace();
// } catch (IllegalAccessException e) {
// e.printStackTrace();
// } catch (InvocationTargetException e) {
// e.printStackTrace();
// }
// heightPixes = realSize.y;
// return heightPixes;
// }
//
// public static int dip2px(Context context, float dpVale) {
// final float scale = context.getResources().getDisplayMetrics().density;
// return (int) (dpVale * scale + 0.5f);
// }
//
// public static int getStatusBarHeight(Context context) {
// Resources resources = context.getResources();
// int resourcesId = resources.getIdentifier("status_bar_height", "dimen", "android");
// int height = resources.getDimensionPixelSize(resourcesId);
// return height;
// }
//
// /**
// * Converts sp to px
// *
// * @param context Context
// * @param sp the value in sp
// * @return int
// */
// public static int dip2sp(Context context, float sp) {
// return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, sp, context.getResources().getDisplayMetrics());
// }
//
// public static int px2dip(Context context, float pxValue) {
// final float scale = context.getResources().getDisplayMetrics().density;
// return (int) (pxValue / scale + 0.5f);
// }
//
// }
|
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ObjectAnimator;
import android.content.Context;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Point;
import android.graphics.Rect;
import android.graphics.Typeface;
import android.support.annotation.ColorInt;
import android.support.v4.content.ContextCompat;
import android.support.v4.view.animation.FastOutLinearInInterpolator;
import android.support.v4.view.animation.LinearOutSlowInInterpolator;
import android.support.v7.widget.RecyclerView;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewConfiguration;
import io.github.marktony.espresso.R;
import io.github.marktony.espresso.interfaze.OnFastScrollStateChangeListener;
import io.github.marktony.espresso.util.DensityUtil;
|
/*
* Copyright(c) 2017 lizhaotailang
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.marktony.espresso.component;
/**
* Created by lizhaotailang on 2017/3/24.
*/
public class FastScroller {
private static final int DEFAULT_AUTO_HIDE_DELAY = 1500;
private FastScrollRecyclerView mRecyclerView;
private FastScrollPopup mPopup;
private int mThumbHeight;
private int mWidth;
private Paint mThumb;
private Paint mTrack;
private Rect mTmpRect = new Rect();
private Rect mInvalidateRect = new Rect();
private Rect mInvalidateTmpRect = new Rect();
// The inset is the buffer around which a point will still register as a click on the scrollbar
private int mTouchInset;
// This is the offset from the top of the scrollbar when the user first starts touching. To
// prevent jumping, this offset is applied as the user scrolls.
private int mTouchOffset;
private Point mThumbPosition = new Point(-1, -1);
private Point mOffset = new Point(0, 0);
private boolean mIsDragging;
private Animator mAutoHideAnimator;
private boolean mAnimatingShow;
private int mAutoHideDelay = DEFAULT_AUTO_HIDE_DELAY;
private boolean mAutoHideEnabled = true;
private final Runnable mHideRunnable;
public FastScroller(Context context, FastScrollRecyclerView recyclerView, AttributeSet attrs) {
Resources resources = context.getResources();
mRecyclerView = recyclerView;
mPopup = new FastScrollPopup(resources, recyclerView);
|
// Path: app/src/main/java/io/github/marktony/espresso/interfaze/OnFastScrollStateChangeListener.java
// public interface OnFastScrollStateChangeListener {
//
// /**
// * Called when fast scrolling begins
// */
// void onFastScrollStart();
//
// /**
// * Called when fast scrolling ends
// */
// void onFastScrollStop();
//
//
// }
//
// Path: app/src/main/java/io/github/marktony/espresso/util/DensityUtil.java
// public class DensityUtil {
//
// public static int getScreenHeight(Context context) {
// DisplayMetrics displayMetrics = new DisplayMetrics();
// ((Activity) context).getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
// return displayMetrics.heightPixels;
// }
//
// public static int getScreenWidth(Context context) {
// DisplayMetrics displayMetrics = new DisplayMetrics();
// ((Activity) context).getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
// return displayMetrics.widthPixels;
// }
//
// public static int getScreenHeightWithDecorations(Context context) {
// int heightPixes;
// WindowManager windowManager = ((Activity) context).getWindowManager();
// Display display = windowManager.getDefaultDisplay();
// Point realSize = new Point();
// try {
// Display.class.getMethod("getRealSize", Point.class).invoke(display, realSize);
// } catch (NoSuchMethodException e) {
// e.printStackTrace();
// } catch (IllegalAccessException e) {
// e.printStackTrace();
// } catch (InvocationTargetException e) {
// e.printStackTrace();
// }
// heightPixes = realSize.y;
// return heightPixes;
// }
//
// public static int dip2px(Context context, float dpVale) {
// final float scale = context.getResources().getDisplayMetrics().density;
// return (int) (dpVale * scale + 0.5f);
// }
//
// public static int getStatusBarHeight(Context context) {
// Resources resources = context.getResources();
// int resourcesId = resources.getIdentifier("status_bar_height", "dimen", "android");
// int height = resources.getDimensionPixelSize(resourcesId);
// return height;
// }
//
// /**
// * Converts sp to px
// *
// * @param context Context
// * @param sp the value in sp
// * @return int
// */
// public static int dip2sp(Context context, float sp) {
// return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, sp, context.getResources().getDisplayMetrics());
// }
//
// public static int px2dip(Context context, float pxValue) {
// final float scale = context.getResources().getDisplayMetrics().density;
// return (int) (pxValue / scale + 0.5f);
// }
//
// }
// Path: app/src/main/java/io/github/marktony/espresso/component/FastScroller.java
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ObjectAnimator;
import android.content.Context;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Point;
import android.graphics.Rect;
import android.graphics.Typeface;
import android.support.annotation.ColorInt;
import android.support.v4.content.ContextCompat;
import android.support.v4.view.animation.FastOutLinearInInterpolator;
import android.support.v4.view.animation.LinearOutSlowInInterpolator;
import android.support.v7.widget.RecyclerView;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewConfiguration;
import io.github.marktony.espresso.R;
import io.github.marktony.espresso.interfaze.OnFastScrollStateChangeListener;
import io.github.marktony.espresso.util.DensityUtil;
/*
* Copyright(c) 2017 lizhaotailang
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.marktony.espresso.component;
/**
* Created by lizhaotailang on 2017/3/24.
*/
public class FastScroller {
private static final int DEFAULT_AUTO_HIDE_DELAY = 1500;
private FastScrollRecyclerView mRecyclerView;
private FastScrollPopup mPopup;
private int mThumbHeight;
private int mWidth;
private Paint mThumb;
private Paint mTrack;
private Rect mTmpRect = new Rect();
private Rect mInvalidateRect = new Rect();
private Rect mInvalidateTmpRect = new Rect();
// The inset is the buffer around which a point will still register as a click on the scrollbar
private int mTouchInset;
// This is the offset from the top of the scrollbar when the user first starts touching. To
// prevent jumping, this offset is applied as the user scrolls.
private int mTouchOffset;
private Point mThumbPosition = new Point(-1, -1);
private Point mOffset = new Point(0, 0);
private boolean mIsDragging;
private Animator mAutoHideAnimator;
private boolean mAnimatingShow;
private int mAutoHideDelay = DEFAULT_AUTO_HIDE_DELAY;
private boolean mAutoHideEnabled = true;
private final Runnable mHideRunnable;
public FastScroller(Context context, FastScrollRecyclerView recyclerView, AttributeSet attrs) {
Resources resources = context.getResources();
mRecyclerView = recyclerView;
mPopup = new FastScrollPopup(resources, recyclerView);
|
mThumbHeight = DensityUtil.dip2px(context, 48);
|
TonnyL/Espresso
|
app/src/main/java/io/github/marktony/espresso/component/FastScroller.java
|
// Path: app/src/main/java/io/github/marktony/espresso/interfaze/OnFastScrollStateChangeListener.java
// public interface OnFastScrollStateChangeListener {
//
// /**
// * Called when fast scrolling begins
// */
// void onFastScrollStart();
//
// /**
// * Called when fast scrolling ends
// */
// void onFastScrollStop();
//
//
// }
//
// Path: app/src/main/java/io/github/marktony/espresso/util/DensityUtil.java
// public class DensityUtil {
//
// public static int getScreenHeight(Context context) {
// DisplayMetrics displayMetrics = new DisplayMetrics();
// ((Activity) context).getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
// return displayMetrics.heightPixels;
// }
//
// public static int getScreenWidth(Context context) {
// DisplayMetrics displayMetrics = new DisplayMetrics();
// ((Activity) context).getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
// return displayMetrics.widthPixels;
// }
//
// public static int getScreenHeightWithDecorations(Context context) {
// int heightPixes;
// WindowManager windowManager = ((Activity) context).getWindowManager();
// Display display = windowManager.getDefaultDisplay();
// Point realSize = new Point();
// try {
// Display.class.getMethod("getRealSize", Point.class).invoke(display, realSize);
// } catch (NoSuchMethodException e) {
// e.printStackTrace();
// } catch (IllegalAccessException e) {
// e.printStackTrace();
// } catch (InvocationTargetException e) {
// e.printStackTrace();
// }
// heightPixes = realSize.y;
// return heightPixes;
// }
//
// public static int dip2px(Context context, float dpVale) {
// final float scale = context.getResources().getDisplayMetrics().density;
// return (int) (dpVale * scale + 0.5f);
// }
//
// public static int getStatusBarHeight(Context context) {
// Resources resources = context.getResources();
// int resourcesId = resources.getIdentifier("status_bar_height", "dimen", "android");
// int height = resources.getDimensionPixelSize(resourcesId);
// return height;
// }
//
// /**
// * Converts sp to px
// *
// * @param context Context
// * @param sp the value in sp
// * @return int
// */
// public static int dip2sp(Context context, float sp) {
// return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, sp, context.getResources().getDisplayMetrics());
// }
//
// public static int px2dip(Context context, float pxValue) {
// final float scale = context.getResources().getDisplayMetrics().density;
// return (int) (pxValue / scale + 0.5f);
// }
//
// }
|
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ObjectAnimator;
import android.content.Context;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Point;
import android.graphics.Rect;
import android.graphics.Typeface;
import android.support.annotation.ColorInt;
import android.support.v4.content.ContextCompat;
import android.support.v4.view.animation.FastOutLinearInInterpolator;
import android.support.v4.view.animation.LinearOutSlowInInterpolator;
import android.support.v7.widget.RecyclerView;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewConfiguration;
import io.github.marktony.espresso.R;
import io.github.marktony.espresso.interfaze.OnFastScrollStateChangeListener;
import io.github.marktony.espresso.util.DensityUtil;
|
mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
show();
}
});
if (mAutoHideEnabled) {
postAutoHideDelayed();
}
}
public int getThumbHeight() {
return mThumbHeight;
}
public int getWidth() {
return mWidth;
}
public boolean isDragging() {
return mIsDragging;
}
/**
* Handles the touch event and determines whether to show the fast scroller (or updates it if
* it is already showing).
*/
public void handleTouchEvent(MotionEvent ev, int downX, int downY, int lastY,
|
// Path: app/src/main/java/io/github/marktony/espresso/interfaze/OnFastScrollStateChangeListener.java
// public interface OnFastScrollStateChangeListener {
//
// /**
// * Called when fast scrolling begins
// */
// void onFastScrollStart();
//
// /**
// * Called when fast scrolling ends
// */
// void onFastScrollStop();
//
//
// }
//
// Path: app/src/main/java/io/github/marktony/espresso/util/DensityUtil.java
// public class DensityUtil {
//
// public static int getScreenHeight(Context context) {
// DisplayMetrics displayMetrics = new DisplayMetrics();
// ((Activity) context).getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
// return displayMetrics.heightPixels;
// }
//
// public static int getScreenWidth(Context context) {
// DisplayMetrics displayMetrics = new DisplayMetrics();
// ((Activity) context).getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
// return displayMetrics.widthPixels;
// }
//
// public static int getScreenHeightWithDecorations(Context context) {
// int heightPixes;
// WindowManager windowManager = ((Activity) context).getWindowManager();
// Display display = windowManager.getDefaultDisplay();
// Point realSize = new Point();
// try {
// Display.class.getMethod("getRealSize", Point.class).invoke(display, realSize);
// } catch (NoSuchMethodException e) {
// e.printStackTrace();
// } catch (IllegalAccessException e) {
// e.printStackTrace();
// } catch (InvocationTargetException e) {
// e.printStackTrace();
// }
// heightPixes = realSize.y;
// return heightPixes;
// }
//
// public static int dip2px(Context context, float dpVale) {
// final float scale = context.getResources().getDisplayMetrics().density;
// return (int) (dpVale * scale + 0.5f);
// }
//
// public static int getStatusBarHeight(Context context) {
// Resources resources = context.getResources();
// int resourcesId = resources.getIdentifier("status_bar_height", "dimen", "android");
// int height = resources.getDimensionPixelSize(resourcesId);
// return height;
// }
//
// /**
// * Converts sp to px
// *
// * @param context Context
// * @param sp the value in sp
// * @return int
// */
// public static int dip2sp(Context context, float sp) {
// return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, sp, context.getResources().getDisplayMetrics());
// }
//
// public static int px2dip(Context context, float pxValue) {
// final float scale = context.getResources().getDisplayMetrics().density;
// return (int) (pxValue / scale + 0.5f);
// }
//
// }
// Path: app/src/main/java/io/github/marktony/espresso/component/FastScroller.java
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ObjectAnimator;
import android.content.Context;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Point;
import android.graphics.Rect;
import android.graphics.Typeface;
import android.support.annotation.ColorInt;
import android.support.v4.content.ContextCompat;
import android.support.v4.view.animation.FastOutLinearInInterpolator;
import android.support.v4.view.animation.LinearOutSlowInInterpolator;
import android.support.v7.widget.RecyclerView;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewConfiguration;
import io.github.marktony.espresso.R;
import io.github.marktony.espresso.interfaze.OnFastScrollStateChangeListener;
import io.github.marktony.espresso.util.DensityUtil;
mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
show();
}
});
if (mAutoHideEnabled) {
postAutoHideDelayed();
}
}
public int getThumbHeight() {
return mThumbHeight;
}
public int getWidth() {
return mWidth;
}
public boolean isDragging() {
return mIsDragging;
}
/**
* Handles the touch event and determines whether to show the fast scroller (or updates it if
* it is already showing).
*/
public void handleTouchEvent(MotionEvent ev, int downX, int downY, int lastY,
|
OnFastScrollStateChangeListener stateChangeListener) {
|
TonnyL/Espresso
|
app/src/main/java/io/github/marktony/espresso/data/source/local/CompaniesLocalDataSource.java
|
// Path: app/src/main/java/io/github/marktony/espresso/data/Company.java
// public class Company extends RealmObject {
//
// @Expose
// @SerializedName("name")
// private String name;
//
// @PrimaryKey
// @Expose
// @SerializedName("id")
// private String id;
//
// @Expose
// @SerializedName("tel")
// private String tel;
//
// @Expose
// @SerializedName("website")
// private String website;
//
// @Expose
// @SerializedName("alphabet")
// private String alphabet;
//
// @Expose
// @SerializedName("avatar")
// private String avatar;
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getTel() {
// return tel;
// }
//
// public void setTel(String tel) {
// this.tel = tel;
// }
//
// public String getWebsite() {
// return website;
// }
//
// public void setWebsite(String website) {
// this.website = website;
// }
//
// public String getAlphabet() {
// return alphabet;
// }
//
// public void setAlphabet(String alphabet) {
// this.alphabet = alphabet;
// }
//
// public String getAvatarColor() {
// return avatar;
// }
//
// public void setAvatarColor(String avatar) {
// this.avatar = avatar;
// }
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: app/src/main/java/io/github/marktony/espresso/data/source/CompaniesDataSource.java
// public interface CompaniesDataSource {
//
// Observable<List<Company>> getCompanies();
//
// Observable<Company> getCompany(@NonNull String companyId);
//
// void initData();
//
// Observable<List<Company>> searchCompanies(@NonNull String keyWords);
//
// }
//
// Path: app/src/main/java/io/github/marktony/espresso/realm/RealmHelper.java
// public class RealmHelper {
//
// public static final String DATABASE_NAME = "Espresso.realm";
//
// public static Realm newRealmInstance() {
// return Realm.getInstance(new RealmConfiguration.Builder()
// .deleteRealmIfMigrationNeeded()
// .name(RealmHelper.DATABASE_NAME)
// .build());
// }
//
// }
|
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import java.util.List;
import io.github.marktony.espresso.data.Company;
import io.github.marktony.espresso.data.source.CompaniesDataSource;
import io.github.marktony.espresso.realm.RealmHelper;
import io.reactivex.Observable;
import io.realm.Case;
import io.realm.Realm;
import io.realm.Sort;
|
/*
* Copyright(c) 2017 lizhaotailang
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.marktony.espresso.data.source.local;
/**
* Created by lizhaotailang on 2017/3/22.
*/
public class CompaniesLocalDataSource implements CompaniesDataSource {
@Nullable
public static CompaniesLocalDataSource INSTANCE = null;
// Prevent direct instantiation
private CompaniesLocalDataSource() {
}
public static CompaniesLocalDataSource getInstance() {
if (INSTANCE == null) {
INSTANCE = new CompaniesLocalDataSource();
}
return INSTANCE;
}
@Override
|
// Path: app/src/main/java/io/github/marktony/espresso/data/Company.java
// public class Company extends RealmObject {
//
// @Expose
// @SerializedName("name")
// private String name;
//
// @PrimaryKey
// @Expose
// @SerializedName("id")
// private String id;
//
// @Expose
// @SerializedName("tel")
// private String tel;
//
// @Expose
// @SerializedName("website")
// private String website;
//
// @Expose
// @SerializedName("alphabet")
// private String alphabet;
//
// @Expose
// @SerializedName("avatar")
// private String avatar;
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getTel() {
// return tel;
// }
//
// public void setTel(String tel) {
// this.tel = tel;
// }
//
// public String getWebsite() {
// return website;
// }
//
// public void setWebsite(String website) {
// this.website = website;
// }
//
// public String getAlphabet() {
// return alphabet;
// }
//
// public void setAlphabet(String alphabet) {
// this.alphabet = alphabet;
// }
//
// public String getAvatarColor() {
// return avatar;
// }
//
// public void setAvatarColor(String avatar) {
// this.avatar = avatar;
// }
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: app/src/main/java/io/github/marktony/espresso/data/source/CompaniesDataSource.java
// public interface CompaniesDataSource {
//
// Observable<List<Company>> getCompanies();
//
// Observable<Company> getCompany(@NonNull String companyId);
//
// void initData();
//
// Observable<List<Company>> searchCompanies(@NonNull String keyWords);
//
// }
//
// Path: app/src/main/java/io/github/marktony/espresso/realm/RealmHelper.java
// public class RealmHelper {
//
// public static final String DATABASE_NAME = "Espresso.realm";
//
// public static Realm newRealmInstance() {
// return Realm.getInstance(new RealmConfiguration.Builder()
// .deleteRealmIfMigrationNeeded()
// .name(RealmHelper.DATABASE_NAME)
// .build());
// }
//
// }
// Path: app/src/main/java/io/github/marktony/espresso/data/source/local/CompaniesLocalDataSource.java
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import java.util.List;
import io.github.marktony.espresso.data.Company;
import io.github.marktony.espresso.data.source.CompaniesDataSource;
import io.github.marktony.espresso.realm.RealmHelper;
import io.reactivex.Observable;
import io.realm.Case;
import io.realm.Realm;
import io.realm.Sort;
/*
* Copyright(c) 2017 lizhaotailang
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.marktony.espresso.data.source.local;
/**
* Created by lizhaotailang on 2017/3/22.
*/
public class CompaniesLocalDataSource implements CompaniesDataSource {
@Nullable
public static CompaniesLocalDataSource INSTANCE = null;
// Prevent direct instantiation
private CompaniesLocalDataSource() {
}
public static CompaniesLocalDataSource getInstance() {
if (INSTANCE == null) {
INSTANCE = new CompaniesLocalDataSource();
}
return INSTANCE;
}
@Override
|
public Observable<List<Company>> getCompanies() {
|
TonnyL/Espresso
|
app/src/main/java/io/github/marktony/espresso/data/source/local/CompaniesLocalDataSource.java
|
// Path: app/src/main/java/io/github/marktony/espresso/data/Company.java
// public class Company extends RealmObject {
//
// @Expose
// @SerializedName("name")
// private String name;
//
// @PrimaryKey
// @Expose
// @SerializedName("id")
// private String id;
//
// @Expose
// @SerializedName("tel")
// private String tel;
//
// @Expose
// @SerializedName("website")
// private String website;
//
// @Expose
// @SerializedName("alphabet")
// private String alphabet;
//
// @Expose
// @SerializedName("avatar")
// private String avatar;
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getTel() {
// return tel;
// }
//
// public void setTel(String tel) {
// this.tel = tel;
// }
//
// public String getWebsite() {
// return website;
// }
//
// public void setWebsite(String website) {
// this.website = website;
// }
//
// public String getAlphabet() {
// return alphabet;
// }
//
// public void setAlphabet(String alphabet) {
// this.alphabet = alphabet;
// }
//
// public String getAvatarColor() {
// return avatar;
// }
//
// public void setAvatarColor(String avatar) {
// this.avatar = avatar;
// }
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: app/src/main/java/io/github/marktony/espresso/data/source/CompaniesDataSource.java
// public interface CompaniesDataSource {
//
// Observable<List<Company>> getCompanies();
//
// Observable<Company> getCompany(@NonNull String companyId);
//
// void initData();
//
// Observable<List<Company>> searchCompanies(@NonNull String keyWords);
//
// }
//
// Path: app/src/main/java/io/github/marktony/espresso/realm/RealmHelper.java
// public class RealmHelper {
//
// public static final String DATABASE_NAME = "Espresso.realm";
//
// public static Realm newRealmInstance() {
// return Realm.getInstance(new RealmConfiguration.Builder()
// .deleteRealmIfMigrationNeeded()
// .name(RealmHelper.DATABASE_NAME)
// .build());
// }
//
// }
|
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import java.util.List;
import io.github.marktony.espresso.data.Company;
import io.github.marktony.espresso.data.source.CompaniesDataSource;
import io.github.marktony.espresso.realm.RealmHelper;
import io.reactivex.Observable;
import io.realm.Case;
import io.realm.Realm;
import io.realm.Sort;
|
/*
* Copyright(c) 2017 lizhaotailang
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.marktony.espresso.data.source.local;
/**
* Created by lizhaotailang on 2017/3/22.
*/
public class CompaniesLocalDataSource implements CompaniesDataSource {
@Nullable
public static CompaniesLocalDataSource INSTANCE = null;
// Prevent direct instantiation
private CompaniesLocalDataSource() {
}
public static CompaniesLocalDataSource getInstance() {
if (INSTANCE == null) {
INSTANCE = new CompaniesLocalDataSource();
}
return INSTANCE;
}
@Override
public Observable<List<Company>> getCompanies() {
|
// Path: app/src/main/java/io/github/marktony/espresso/data/Company.java
// public class Company extends RealmObject {
//
// @Expose
// @SerializedName("name")
// private String name;
//
// @PrimaryKey
// @Expose
// @SerializedName("id")
// private String id;
//
// @Expose
// @SerializedName("tel")
// private String tel;
//
// @Expose
// @SerializedName("website")
// private String website;
//
// @Expose
// @SerializedName("alphabet")
// private String alphabet;
//
// @Expose
// @SerializedName("avatar")
// private String avatar;
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getTel() {
// return tel;
// }
//
// public void setTel(String tel) {
// this.tel = tel;
// }
//
// public String getWebsite() {
// return website;
// }
//
// public void setWebsite(String website) {
// this.website = website;
// }
//
// public String getAlphabet() {
// return alphabet;
// }
//
// public void setAlphabet(String alphabet) {
// this.alphabet = alphabet;
// }
//
// public String getAvatarColor() {
// return avatar;
// }
//
// public void setAvatarColor(String avatar) {
// this.avatar = avatar;
// }
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: app/src/main/java/io/github/marktony/espresso/data/source/CompaniesDataSource.java
// public interface CompaniesDataSource {
//
// Observable<List<Company>> getCompanies();
//
// Observable<Company> getCompany(@NonNull String companyId);
//
// void initData();
//
// Observable<List<Company>> searchCompanies(@NonNull String keyWords);
//
// }
//
// Path: app/src/main/java/io/github/marktony/espresso/realm/RealmHelper.java
// public class RealmHelper {
//
// public static final String DATABASE_NAME = "Espresso.realm";
//
// public static Realm newRealmInstance() {
// return Realm.getInstance(new RealmConfiguration.Builder()
// .deleteRealmIfMigrationNeeded()
// .name(RealmHelper.DATABASE_NAME)
// .build());
// }
//
// }
// Path: app/src/main/java/io/github/marktony/espresso/data/source/local/CompaniesLocalDataSource.java
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import java.util.List;
import io.github.marktony.espresso.data.Company;
import io.github.marktony.espresso.data.source.CompaniesDataSource;
import io.github.marktony.espresso.realm.RealmHelper;
import io.reactivex.Observable;
import io.realm.Case;
import io.realm.Realm;
import io.realm.Sort;
/*
* Copyright(c) 2017 lizhaotailang
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.marktony.espresso.data.source.local;
/**
* Created by lizhaotailang on 2017/3/22.
*/
public class CompaniesLocalDataSource implements CompaniesDataSource {
@Nullable
public static CompaniesLocalDataSource INSTANCE = null;
// Prevent direct instantiation
private CompaniesLocalDataSource() {
}
public static CompaniesLocalDataSource getInstance() {
if (INSTANCE == null) {
INSTANCE = new CompaniesLocalDataSource();
}
return INSTANCE;
}
@Override
public Observable<List<Company>> getCompanies() {
|
Realm rlm = RealmHelper.newRealmInstance();
|
TonnyL/Espresso
|
app/src/main/java/io/github/marktony/espresso/component/FastScrollRecyclerView.java
|
// Path: app/src/main/java/io/github/marktony/espresso/interfaze/OnFastScrollStateChangeListener.java
// public interface OnFastScrollStateChangeListener {
//
// /**
// * Called when fast scrolling begins
// */
// void onFastScrollStart();
//
// /**
// * Called when fast scrolling ends
// */
// void onFastScrollStop();
//
//
// }
|
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Typeface;
import android.support.annotation.ColorInt;
import android.support.annotation.NonNull;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import io.github.marktony.espresso.interfaze.OnFastScrollStateChangeListener;
|
/*
* Copyright(c) 2017 lizhaotailang
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.marktony.espresso.component;
/**
* Created by lizhaotailang on 2017/3/24.
*/
public class FastScrollRecyclerView extends RecyclerView
implements RecyclerView.OnItemTouchListener {
private FastScroller mScrollbar;
/**
* The current scroll state of the recycler view. We use this in onUpdateScrollbar()
* and scrollToPositionAtProgress() to determine the scroll position of the recycler view so
* that we can calculate what the scroll bar looks like, and where to jump to from the fast
* scroller.
*/
public static class ScrollPositionState {
// The index of the first visible row
public int rowIndex;
// The offset of the first visible row
public int rowTopOffset;
// The height of a given row (they are currently all the same height)
public int rowHeight;
}
private ScrollPositionState mScrollPosState = new ScrollPositionState();
private int mDownX;
private int mDownY;
private int mLastY;
|
// Path: app/src/main/java/io/github/marktony/espresso/interfaze/OnFastScrollStateChangeListener.java
// public interface OnFastScrollStateChangeListener {
//
// /**
// * Called when fast scrolling begins
// */
// void onFastScrollStart();
//
// /**
// * Called when fast scrolling ends
// */
// void onFastScrollStop();
//
//
// }
// Path: app/src/main/java/io/github/marktony/espresso/component/FastScrollRecyclerView.java
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Typeface;
import android.support.annotation.ColorInt;
import android.support.annotation.NonNull;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import io.github.marktony.espresso.interfaze.OnFastScrollStateChangeListener;
/*
* Copyright(c) 2017 lizhaotailang
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.marktony.espresso.component;
/**
* Created by lizhaotailang on 2017/3/24.
*/
public class FastScrollRecyclerView extends RecyclerView
implements RecyclerView.OnItemTouchListener {
private FastScroller mScrollbar;
/**
* The current scroll state of the recycler view. We use this in onUpdateScrollbar()
* and scrollToPositionAtProgress() to determine the scroll position of the recycler view so
* that we can calculate what the scroll bar looks like, and where to jump to from the fast
* scroller.
*/
public static class ScrollPositionState {
// The index of the first visible row
public int rowIndex;
// The offset of the first visible row
public int rowTopOffset;
// The height of a given row (they are currently all the same height)
public int rowHeight;
}
private ScrollPositionState mScrollPosState = new ScrollPositionState();
private int mDownX;
private int mDownY;
private int mLastY;
|
private OnFastScrollStateChangeListener mStateChangeListener;
|
TonnyL/Espresso
|
app/src/main/java/io/github/marktony/espresso/mvp/companydetails/CompanyDetailContract.java
|
// Path: app/src/main/java/io/github/marktony/espresso/mvp/BasePresenter.java
// public interface BasePresenter {
//
// void subscribe();
//
// void unsubscribe();
//
// }
//
// Path: app/src/main/java/io/github/marktony/espresso/mvp/BaseView.java
// public interface BaseView<T> {
//
// void initViews(View view);
//
// void setPresenter(T presenter);
//
// }
|
import java.util.List;
import io.github.marktony.espresso.mvp.BasePresenter;
import io.github.marktony.espresso.mvp.BaseView;
|
/*
* Copyright(c) 2017 lizhaotailang
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.marktony.espresso.mvp.companydetails;
/**
* Created by lizhaotailang on 2017/2/10.
*/
public interface CompanyDetailContract {
interface View extends BaseView<Presenter> {
void setCompanyName(String name);
void setCompanyTel(String tel);
void setCompanyWebsite(String website);
void showErrorMsg();
}
|
// Path: app/src/main/java/io/github/marktony/espresso/mvp/BasePresenter.java
// public interface BasePresenter {
//
// void subscribe();
//
// void unsubscribe();
//
// }
//
// Path: app/src/main/java/io/github/marktony/espresso/mvp/BaseView.java
// public interface BaseView<T> {
//
// void initViews(View view);
//
// void setPresenter(T presenter);
//
// }
// Path: app/src/main/java/io/github/marktony/espresso/mvp/companydetails/CompanyDetailContract.java
import java.util.List;
import io.github.marktony.espresso.mvp.BasePresenter;
import io.github.marktony.espresso.mvp.BaseView;
/*
* Copyright(c) 2017 lizhaotailang
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.marktony.espresso.mvp.companydetails;
/**
* Created by lizhaotailang on 2017/2/10.
*/
public interface CompanyDetailContract {
interface View extends BaseView<Presenter> {
void setCompanyName(String name);
void setCompanyTel(String tel);
void setCompanyWebsite(String website);
void showErrorMsg();
}
|
interface Presenter extends BasePresenter {
|
TonnyL/Espresso
|
app/src/main/java/io/github/marktony/espresso/mvp/companies/CompaniesContract.java
|
// Path: app/src/main/java/io/github/marktony/espresso/mvp/BasePresenter.java
// public interface BasePresenter {
//
// void subscribe();
//
// void unsubscribe();
//
// }
//
// Path: app/src/main/java/io/github/marktony/espresso/mvp/BaseView.java
// public interface BaseView<T> {
//
// void initViews(View view);
//
// void setPresenter(T presenter);
//
// }
//
// Path: app/src/main/java/io/github/marktony/espresso/data/Company.java
// public class Company extends RealmObject {
//
// @Expose
// @SerializedName("name")
// private String name;
//
// @PrimaryKey
// @Expose
// @SerializedName("id")
// private String id;
//
// @Expose
// @SerializedName("tel")
// private String tel;
//
// @Expose
// @SerializedName("website")
// private String website;
//
// @Expose
// @SerializedName("alphabet")
// private String alphabet;
//
// @Expose
// @SerializedName("avatar")
// private String avatar;
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getTel() {
// return tel;
// }
//
// public void setTel(String tel) {
// this.tel = tel;
// }
//
// public String getWebsite() {
// return website;
// }
//
// public void setWebsite(String website) {
// this.website = website;
// }
//
// public String getAlphabet() {
// return alphabet;
// }
//
// public void setAlphabet(String alphabet) {
// this.alphabet = alphabet;
// }
//
// public String getAvatarColor() {
// return avatar;
// }
//
// public void setAvatarColor(String avatar) {
// this.avatar = avatar;
// }
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
|
import java.util.ArrayList;
import java.util.List;
import io.github.marktony.espresso.mvp.BasePresenter;
import io.github.marktony.espresso.mvp.BaseView;
import io.github.marktony.espresso.data.Company;
|
/*
* Copyright(c) 2017 lizhaotailang
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.marktony.espresso.mvp.companies;
/**
* Created by lizhaotailang on 2017/2/10.
*/
public interface CompaniesContract {
interface View extends BaseView<Presenter> {
void showGetCompaniesError();
|
// Path: app/src/main/java/io/github/marktony/espresso/mvp/BasePresenter.java
// public interface BasePresenter {
//
// void subscribe();
//
// void unsubscribe();
//
// }
//
// Path: app/src/main/java/io/github/marktony/espresso/mvp/BaseView.java
// public interface BaseView<T> {
//
// void initViews(View view);
//
// void setPresenter(T presenter);
//
// }
//
// Path: app/src/main/java/io/github/marktony/espresso/data/Company.java
// public class Company extends RealmObject {
//
// @Expose
// @SerializedName("name")
// private String name;
//
// @PrimaryKey
// @Expose
// @SerializedName("id")
// private String id;
//
// @Expose
// @SerializedName("tel")
// private String tel;
//
// @Expose
// @SerializedName("website")
// private String website;
//
// @Expose
// @SerializedName("alphabet")
// private String alphabet;
//
// @Expose
// @SerializedName("avatar")
// private String avatar;
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getTel() {
// return tel;
// }
//
// public void setTel(String tel) {
// this.tel = tel;
// }
//
// public String getWebsite() {
// return website;
// }
//
// public void setWebsite(String website) {
// this.website = website;
// }
//
// public String getAlphabet() {
// return alphabet;
// }
//
// public void setAlphabet(String alphabet) {
// this.alphabet = alphabet;
// }
//
// public String getAvatarColor() {
// return avatar;
// }
//
// public void setAvatarColor(String avatar) {
// this.avatar = avatar;
// }
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
// Path: app/src/main/java/io/github/marktony/espresso/mvp/companies/CompaniesContract.java
import java.util.ArrayList;
import java.util.List;
import io.github.marktony.espresso.mvp.BasePresenter;
import io.github.marktony.espresso.mvp.BaseView;
import io.github.marktony.espresso.data.Company;
/*
* Copyright(c) 2017 lizhaotailang
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.marktony.espresso.mvp.companies;
/**
* Created by lizhaotailang on 2017/2/10.
*/
public interface CompaniesContract {
interface View extends BaseView<Presenter> {
void showGetCompaniesError();
|
void showCompanies(List<Company> list);
|
TonnyL/Espresso
|
app/src/main/java/io/github/marktony/espresso/mvp/companies/CompaniesContract.java
|
// Path: app/src/main/java/io/github/marktony/espresso/mvp/BasePresenter.java
// public interface BasePresenter {
//
// void subscribe();
//
// void unsubscribe();
//
// }
//
// Path: app/src/main/java/io/github/marktony/espresso/mvp/BaseView.java
// public interface BaseView<T> {
//
// void initViews(View view);
//
// void setPresenter(T presenter);
//
// }
//
// Path: app/src/main/java/io/github/marktony/espresso/data/Company.java
// public class Company extends RealmObject {
//
// @Expose
// @SerializedName("name")
// private String name;
//
// @PrimaryKey
// @Expose
// @SerializedName("id")
// private String id;
//
// @Expose
// @SerializedName("tel")
// private String tel;
//
// @Expose
// @SerializedName("website")
// private String website;
//
// @Expose
// @SerializedName("alphabet")
// private String alphabet;
//
// @Expose
// @SerializedName("avatar")
// private String avatar;
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getTel() {
// return tel;
// }
//
// public void setTel(String tel) {
// this.tel = tel;
// }
//
// public String getWebsite() {
// return website;
// }
//
// public void setWebsite(String website) {
// this.website = website;
// }
//
// public String getAlphabet() {
// return alphabet;
// }
//
// public void setAlphabet(String alphabet) {
// this.alphabet = alphabet;
// }
//
// public String getAvatarColor() {
// return avatar;
// }
//
// public void setAvatarColor(String avatar) {
// this.avatar = avatar;
// }
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
|
import java.util.ArrayList;
import java.util.List;
import io.github.marktony.espresso.mvp.BasePresenter;
import io.github.marktony.espresso.mvp.BaseView;
import io.github.marktony.espresso.data.Company;
|
/*
* Copyright(c) 2017 lizhaotailang
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.marktony.espresso.mvp.companies;
/**
* Created by lizhaotailang on 2017/2/10.
*/
public interface CompaniesContract {
interface View extends BaseView<Presenter> {
void showGetCompaniesError();
void showCompanies(List<Company> list);
}
|
// Path: app/src/main/java/io/github/marktony/espresso/mvp/BasePresenter.java
// public interface BasePresenter {
//
// void subscribe();
//
// void unsubscribe();
//
// }
//
// Path: app/src/main/java/io/github/marktony/espresso/mvp/BaseView.java
// public interface BaseView<T> {
//
// void initViews(View view);
//
// void setPresenter(T presenter);
//
// }
//
// Path: app/src/main/java/io/github/marktony/espresso/data/Company.java
// public class Company extends RealmObject {
//
// @Expose
// @SerializedName("name")
// private String name;
//
// @PrimaryKey
// @Expose
// @SerializedName("id")
// private String id;
//
// @Expose
// @SerializedName("tel")
// private String tel;
//
// @Expose
// @SerializedName("website")
// private String website;
//
// @Expose
// @SerializedName("alphabet")
// private String alphabet;
//
// @Expose
// @SerializedName("avatar")
// private String avatar;
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getTel() {
// return tel;
// }
//
// public void setTel(String tel) {
// this.tel = tel;
// }
//
// public String getWebsite() {
// return website;
// }
//
// public void setWebsite(String website) {
// this.website = website;
// }
//
// public String getAlphabet() {
// return alphabet;
// }
//
// public void setAlphabet(String alphabet) {
// this.alphabet = alphabet;
// }
//
// public String getAvatarColor() {
// return avatar;
// }
//
// public void setAvatarColor(String avatar) {
// this.avatar = avatar;
// }
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
// Path: app/src/main/java/io/github/marktony/espresso/mvp/companies/CompaniesContract.java
import java.util.ArrayList;
import java.util.List;
import io.github.marktony.espresso.mvp.BasePresenter;
import io.github.marktony.espresso.mvp.BaseView;
import io.github.marktony.espresso.data.Company;
/*
* Copyright(c) 2017 lizhaotailang
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.marktony.espresso.mvp.companies;
/**
* Created by lizhaotailang on 2017/2/10.
*/
public interface CompaniesContract {
interface View extends BaseView<Presenter> {
void showGetCompaniesError();
void showCompanies(List<Company> list);
}
|
interface Presenter extends BasePresenter {
|
TonnyL/Espresso
|
app/src/main/java/io/github/marktony/espresso/mvp/packages/PackagesAdapter.java
|
// Path: app/src/main/java/io/github/marktony/espresso/data/Package.java
// public class Package extends RealmObject {
//
// public static final int STATUS_FAILED = 2, STATUS_NORMAL = 0,
// STATUS_ON_THE_WAY = 5, STATUS_DELIVERED = 3,
// STATUS_RETURNED = 4, STATUS_RETURNING = 6,
// STATUS_OTHER = 1;
//
// @Expose
// @SerializedName("message")
// private String message;
// @Expose
// @SerializedName("nu")
// @PrimaryKey
// private String number;
// @Expose
// @SerializedName("ischeck")
// private String isCheck;
// @Expose
// @SerializedName("condition")
// private String condition;
// @Expose
// @SerializedName("com")
// private String company;
// @Expose
// @SerializedName("status")
// private String status;
// @Expose
// @SerializedName("state")
// private String state;
// @Expose
// @SerializedName("data")
// private RealmList<PackageStatus> data;
//
// @Expose
// private boolean pushable = false;
// @Expose
// private boolean readable = false;
// @Expose
// private String name;
// @Expose
// private String companyChineseName;
// @Expose
// private int colorAvatar;
// @Expose
// private long timestamp;
//
// public String getMessage() {
// return message;
// }
//
// public void setMessage(String message) {
// this.message = message;
// }
//
// public String getNumber() {
// return number;
// }
//
// public void setNumber(String number) {
// this.number = number;
// }
//
// public String getIsCheck() {
// return isCheck;
// }
//
// public void setIsCheck(String isCheck) {
// this.isCheck = isCheck;
// }
//
// public String getCondition() {
// return condition;
// }
//
// public void setCondition(String condition) {
// this.condition = condition;
// }
//
// public String getStatus() {
// return status;
// }
//
// public void setStatus(String status) {
// this.status = status;
// }
//
// public String getState() {
// return state;
// }
//
// public void setState(String state) {
// this.state = state;
// }
//
// public RealmList<PackageStatus> getData() {
// return data;
// }
//
// public void setData(RealmList<PackageStatus> data) {
// this.data = data;
// }
//
// public boolean isReadable() {
// return readable;
// }
//
// public void setReadable(boolean readable) {
// this.readable = readable;
// }
//
// public String getCompany() {
// return company;
// }
//
// public void setCompany(String company) {
// this.company = company;
// }
//
// public boolean isPushable() {
// return pushable;
// }
//
// public void setPushable(boolean pushable) {
// this.pushable = pushable;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getCompanyChineseName() {
// return companyChineseName;
// }
//
// public void setCompanyChineseName(String companyChineseName) {
// this.companyChineseName = companyChineseName;
// }
//
// public void setColorAvatar(int colorAvatar) {
// this.colorAvatar = colorAvatar;
// }
//
// public int getColorAvatar() {
// return colorAvatar;
// }
//
// public void setTimestamp(long timestamp) {
// this.timestamp = timestamp;
// }
//
// public long getTimestamp() {
// return timestamp;
// }
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: app/src/main/java/io/github/marktony/espresso/interfaze/OnRecyclerViewItemClickListener.java
// public interface OnRecyclerViewItemClickListener {
//
// void OnItemClick(View v, int position);
//
// }
|
import java.util.List;
import de.hdodenhof.circleimageview.CircleImageView;
import io.github.marktony.espresso.R;
import io.github.marktony.espresso.data.Package;
import io.github.marktony.espresso.interfaze.OnRecyclerViewItemClickListener;
import android.content.Context;
import android.graphics.Typeface;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.widget.AppCompatTextView;
import android.support.v7.widget.RecyclerView;
import android.view.ContextMenu;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
|
/*
* Copyright(c) 2017 lizhaotailang
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.marktony.espresso.mvp.packages;
/**
* Created by lizhaotailang on 2017/2/11.
*/
public class PackagesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
@NonNull
private final Context context;
@NonNull
private final LayoutInflater inflater;
@NonNull
|
// Path: app/src/main/java/io/github/marktony/espresso/data/Package.java
// public class Package extends RealmObject {
//
// public static final int STATUS_FAILED = 2, STATUS_NORMAL = 0,
// STATUS_ON_THE_WAY = 5, STATUS_DELIVERED = 3,
// STATUS_RETURNED = 4, STATUS_RETURNING = 6,
// STATUS_OTHER = 1;
//
// @Expose
// @SerializedName("message")
// private String message;
// @Expose
// @SerializedName("nu")
// @PrimaryKey
// private String number;
// @Expose
// @SerializedName("ischeck")
// private String isCheck;
// @Expose
// @SerializedName("condition")
// private String condition;
// @Expose
// @SerializedName("com")
// private String company;
// @Expose
// @SerializedName("status")
// private String status;
// @Expose
// @SerializedName("state")
// private String state;
// @Expose
// @SerializedName("data")
// private RealmList<PackageStatus> data;
//
// @Expose
// private boolean pushable = false;
// @Expose
// private boolean readable = false;
// @Expose
// private String name;
// @Expose
// private String companyChineseName;
// @Expose
// private int colorAvatar;
// @Expose
// private long timestamp;
//
// public String getMessage() {
// return message;
// }
//
// public void setMessage(String message) {
// this.message = message;
// }
//
// public String getNumber() {
// return number;
// }
//
// public void setNumber(String number) {
// this.number = number;
// }
//
// public String getIsCheck() {
// return isCheck;
// }
//
// public void setIsCheck(String isCheck) {
// this.isCheck = isCheck;
// }
//
// public String getCondition() {
// return condition;
// }
//
// public void setCondition(String condition) {
// this.condition = condition;
// }
//
// public String getStatus() {
// return status;
// }
//
// public void setStatus(String status) {
// this.status = status;
// }
//
// public String getState() {
// return state;
// }
//
// public void setState(String state) {
// this.state = state;
// }
//
// public RealmList<PackageStatus> getData() {
// return data;
// }
//
// public void setData(RealmList<PackageStatus> data) {
// this.data = data;
// }
//
// public boolean isReadable() {
// return readable;
// }
//
// public void setReadable(boolean readable) {
// this.readable = readable;
// }
//
// public String getCompany() {
// return company;
// }
//
// public void setCompany(String company) {
// this.company = company;
// }
//
// public boolean isPushable() {
// return pushable;
// }
//
// public void setPushable(boolean pushable) {
// this.pushable = pushable;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getCompanyChineseName() {
// return companyChineseName;
// }
//
// public void setCompanyChineseName(String companyChineseName) {
// this.companyChineseName = companyChineseName;
// }
//
// public void setColorAvatar(int colorAvatar) {
// this.colorAvatar = colorAvatar;
// }
//
// public int getColorAvatar() {
// return colorAvatar;
// }
//
// public void setTimestamp(long timestamp) {
// this.timestamp = timestamp;
// }
//
// public long getTimestamp() {
// return timestamp;
// }
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: app/src/main/java/io/github/marktony/espresso/interfaze/OnRecyclerViewItemClickListener.java
// public interface OnRecyclerViewItemClickListener {
//
// void OnItemClick(View v, int position);
//
// }
// Path: app/src/main/java/io/github/marktony/espresso/mvp/packages/PackagesAdapter.java
import java.util.List;
import de.hdodenhof.circleimageview.CircleImageView;
import io.github.marktony.espresso.R;
import io.github.marktony.espresso.data.Package;
import io.github.marktony.espresso.interfaze.OnRecyclerViewItemClickListener;
import android.content.Context;
import android.graphics.Typeface;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.widget.AppCompatTextView;
import android.support.v7.widget.RecyclerView;
import android.view.ContextMenu;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
/*
* Copyright(c) 2017 lizhaotailang
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.marktony.espresso.mvp.packages;
/**
* Created by lizhaotailang on 2017/2/11.
*/
public class PackagesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
@NonNull
private final Context context;
@NonNull
private final LayoutInflater inflater;
@NonNull
|
private List<Package> list;
|
TonnyL/Espresso
|
app/src/main/java/io/github/marktony/espresso/mvp/packages/PackagesAdapter.java
|
// Path: app/src/main/java/io/github/marktony/espresso/data/Package.java
// public class Package extends RealmObject {
//
// public static final int STATUS_FAILED = 2, STATUS_NORMAL = 0,
// STATUS_ON_THE_WAY = 5, STATUS_DELIVERED = 3,
// STATUS_RETURNED = 4, STATUS_RETURNING = 6,
// STATUS_OTHER = 1;
//
// @Expose
// @SerializedName("message")
// private String message;
// @Expose
// @SerializedName("nu")
// @PrimaryKey
// private String number;
// @Expose
// @SerializedName("ischeck")
// private String isCheck;
// @Expose
// @SerializedName("condition")
// private String condition;
// @Expose
// @SerializedName("com")
// private String company;
// @Expose
// @SerializedName("status")
// private String status;
// @Expose
// @SerializedName("state")
// private String state;
// @Expose
// @SerializedName("data")
// private RealmList<PackageStatus> data;
//
// @Expose
// private boolean pushable = false;
// @Expose
// private boolean readable = false;
// @Expose
// private String name;
// @Expose
// private String companyChineseName;
// @Expose
// private int colorAvatar;
// @Expose
// private long timestamp;
//
// public String getMessage() {
// return message;
// }
//
// public void setMessage(String message) {
// this.message = message;
// }
//
// public String getNumber() {
// return number;
// }
//
// public void setNumber(String number) {
// this.number = number;
// }
//
// public String getIsCheck() {
// return isCheck;
// }
//
// public void setIsCheck(String isCheck) {
// this.isCheck = isCheck;
// }
//
// public String getCondition() {
// return condition;
// }
//
// public void setCondition(String condition) {
// this.condition = condition;
// }
//
// public String getStatus() {
// return status;
// }
//
// public void setStatus(String status) {
// this.status = status;
// }
//
// public String getState() {
// return state;
// }
//
// public void setState(String state) {
// this.state = state;
// }
//
// public RealmList<PackageStatus> getData() {
// return data;
// }
//
// public void setData(RealmList<PackageStatus> data) {
// this.data = data;
// }
//
// public boolean isReadable() {
// return readable;
// }
//
// public void setReadable(boolean readable) {
// this.readable = readable;
// }
//
// public String getCompany() {
// return company;
// }
//
// public void setCompany(String company) {
// this.company = company;
// }
//
// public boolean isPushable() {
// return pushable;
// }
//
// public void setPushable(boolean pushable) {
// this.pushable = pushable;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getCompanyChineseName() {
// return companyChineseName;
// }
//
// public void setCompanyChineseName(String companyChineseName) {
// this.companyChineseName = companyChineseName;
// }
//
// public void setColorAvatar(int colorAvatar) {
// this.colorAvatar = colorAvatar;
// }
//
// public int getColorAvatar() {
// return colorAvatar;
// }
//
// public void setTimestamp(long timestamp) {
// this.timestamp = timestamp;
// }
//
// public long getTimestamp() {
// return timestamp;
// }
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: app/src/main/java/io/github/marktony/espresso/interfaze/OnRecyclerViewItemClickListener.java
// public interface OnRecyclerViewItemClickListener {
//
// void OnItemClick(View v, int position);
//
// }
|
import java.util.List;
import de.hdodenhof.circleimageview.CircleImageView;
import io.github.marktony.espresso.R;
import io.github.marktony.espresso.data.Package;
import io.github.marktony.espresso.interfaze.OnRecyclerViewItemClickListener;
import android.content.Context;
import android.graphics.Typeface;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.widget.AppCompatTextView;
import android.support.v7.widget.RecyclerView;
import android.view.ContextMenu;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
|
/*
* Copyright(c) 2017 lizhaotailang
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.marktony.espresso.mvp.packages;
/**
* Created by lizhaotailang on 2017/2/11.
*/
public class PackagesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
@NonNull
private final Context context;
@NonNull
private final LayoutInflater inflater;
@NonNull
private List<Package> list;
@Nullable
|
// Path: app/src/main/java/io/github/marktony/espresso/data/Package.java
// public class Package extends RealmObject {
//
// public static final int STATUS_FAILED = 2, STATUS_NORMAL = 0,
// STATUS_ON_THE_WAY = 5, STATUS_DELIVERED = 3,
// STATUS_RETURNED = 4, STATUS_RETURNING = 6,
// STATUS_OTHER = 1;
//
// @Expose
// @SerializedName("message")
// private String message;
// @Expose
// @SerializedName("nu")
// @PrimaryKey
// private String number;
// @Expose
// @SerializedName("ischeck")
// private String isCheck;
// @Expose
// @SerializedName("condition")
// private String condition;
// @Expose
// @SerializedName("com")
// private String company;
// @Expose
// @SerializedName("status")
// private String status;
// @Expose
// @SerializedName("state")
// private String state;
// @Expose
// @SerializedName("data")
// private RealmList<PackageStatus> data;
//
// @Expose
// private boolean pushable = false;
// @Expose
// private boolean readable = false;
// @Expose
// private String name;
// @Expose
// private String companyChineseName;
// @Expose
// private int colorAvatar;
// @Expose
// private long timestamp;
//
// public String getMessage() {
// return message;
// }
//
// public void setMessage(String message) {
// this.message = message;
// }
//
// public String getNumber() {
// return number;
// }
//
// public void setNumber(String number) {
// this.number = number;
// }
//
// public String getIsCheck() {
// return isCheck;
// }
//
// public void setIsCheck(String isCheck) {
// this.isCheck = isCheck;
// }
//
// public String getCondition() {
// return condition;
// }
//
// public void setCondition(String condition) {
// this.condition = condition;
// }
//
// public String getStatus() {
// return status;
// }
//
// public void setStatus(String status) {
// this.status = status;
// }
//
// public String getState() {
// return state;
// }
//
// public void setState(String state) {
// this.state = state;
// }
//
// public RealmList<PackageStatus> getData() {
// return data;
// }
//
// public void setData(RealmList<PackageStatus> data) {
// this.data = data;
// }
//
// public boolean isReadable() {
// return readable;
// }
//
// public void setReadable(boolean readable) {
// this.readable = readable;
// }
//
// public String getCompany() {
// return company;
// }
//
// public void setCompany(String company) {
// this.company = company;
// }
//
// public boolean isPushable() {
// return pushable;
// }
//
// public void setPushable(boolean pushable) {
// this.pushable = pushable;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getCompanyChineseName() {
// return companyChineseName;
// }
//
// public void setCompanyChineseName(String companyChineseName) {
// this.companyChineseName = companyChineseName;
// }
//
// public void setColorAvatar(int colorAvatar) {
// this.colorAvatar = colorAvatar;
// }
//
// public int getColorAvatar() {
// return colorAvatar;
// }
//
// public void setTimestamp(long timestamp) {
// this.timestamp = timestamp;
// }
//
// public long getTimestamp() {
// return timestamp;
// }
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: app/src/main/java/io/github/marktony/espresso/interfaze/OnRecyclerViewItemClickListener.java
// public interface OnRecyclerViewItemClickListener {
//
// void OnItemClick(View v, int position);
//
// }
// Path: app/src/main/java/io/github/marktony/espresso/mvp/packages/PackagesAdapter.java
import java.util.List;
import de.hdodenhof.circleimageview.CircleImageView;
import io.github.marktony.espresso.R;
import io.github.marktony.espresso.data.Package;
import io.github.marktony.espresso.interfaze.OnRecyclerViewItemClickListener;
import android.content.Context;
import android.graphics.Typeface;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.widget.AppCompatTextView;
import android.support.v7.widget.RecyclerView;
import android.view.ContextMenu;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
/*
* Copyright(c) 2017 lizhaotailang
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.marktony.espresso.mvp.packages;
/**
* Created by lizhaotailang on 2017/2/11.
*/
public class PackagesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
@NonNull
private final Context context;
@NonNull
private final LayoutInflater inflater;
@NonNull
private List<Package> list;
@Nullable
|
private OnRecyclerViewItemClickListener listener;
|
TonnyL/Espresso
|
app/src/main/java/io/github/marktony/espresso/data/source/CompaniesRepository.java
|
// Path: app/src/main/java/io/github/marktony/espresso/data/Company.java
// public class Company extends RealmObject {
//
// @Expose
// @SerializedName("name")
// private String name;
//
// @PrimaryKey
// @Expose
// @SerializedName("id")
// private String id;
//
// @Expose
// @SerializedName("tel")
// private String tel;
//
// @Expose
// @SerializedName("website")
// private String website;
//
// @Expose
// @SerializedName("alphabet")
// private String alphabet;
//
// @Expose
// @SerializedName("avatar")
// private String avatar;
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getTel() {
// return tel;
// }
//
// public void setTel(String tel) {
// this.tel = tel;
// }
//
// public String getWebsite() {
// return website;
// }
//
// public void setWebsite(String website) {
// this.website = website;
// }
//
// public String getAlphabet() {
// return alphabet;
// }
//
// public void setAlphabet(String alphabet) {
// this.alphabet = alphabet;
// }
//
// public String getAvatarColor() {
// return avatar;
// }
//
// public void setAvatarColor(String avatar) {
// this.avatar = avatar;
// }
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
|
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import java.util.List;
import io.github.marktony.espresso.data.Company;
import io.reactivex.Observable;
|
/*
* Copyright(c) 2017 lizhaotailang
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.marktony.espresso.data.source;
/**
* Created by lizhaotailang on 2017/3/22.
*/
public class CompaniesRepository implements CompaniesDataSource {
@Nullable
private static CompaniesRepository INSTANCE = null;
@NonNull
private final CompaniesDataSource localDataSource;
// Prevent direct instantiation
private CompaniesRepository(@NonNull CompaniesDataSource localDataSource) {
this.localDataSource = localDataSource;
}
public static CompaniesRepository getInstance(@NonNull CompaniesDataSource localDataSource) {
if (INSTANCE == null) {
INSTANCE = new CompaniesRepository(localDataSource);
}
return INSTANCE;
}
@Override
|
// Path: app/src/main/java/io/github/marktony/espresso/data/Company.java
// public class Company extends RealmObject {
//
// @Expose
// @SerializedName("name")
// private String name;
//
// @PrimaryKey
// @Expose
// @SerializedName("id")
// private String id;
//
// @Expose
// @SerializedName("tel")
// private String tel;
//
// @Expose
// @SerializedName("website")
// private String website;
//
// @Expose
// @SerializedName("alphabet")
// private String alphabet;
//
// @Expose
// @SerializedName("avatar")
// private String avatar;
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getTel() {
// return tel;
// }
//
// public void setTel(String tel) {
// this.tel = tel;
// }
//
// public String getWebsite() {
// return website;
// }
//
// public void setWebsite(String website) {
// this.website = website;
// }
//
// public String getAlphabet() {
// return alphabet;
// }
//
// public void setAlphabet(String alphabet) {
// this.alphabet = alphabet;
// }
//
// public String getAvatarColor() {
// return avatar;
// }
//
// public void setAvatarColor(String avatar) {
// this.avatar = avatar;
// }
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
// Path: app/src/main/java/io/github/marktony/espresso/data/source/CompaniesRepository.java
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import java.util.List;
import io.github.marktony.espresso.data.Company;
import io.reactivex.Observable;
/*
* Copyright(c) 2017 lizhaotailang
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.marktony.espresso.data.source;
/**
* Created by lizhaotailang on 2017/3/22.
*/
public class CompaniesRepository implements CompaniesDataSource {
@Nullable
private static CompaniesRepository INSTANCE = null;
@NonNull
private final CompaniesDataSource localDataSource;
// Prevent direct instantiation
private CompaniesRepository(@NonNull CompaniesDataSource localDataSource) {
this.localDataSource = localDataSource;
}
public static CompaniesRepository getInstance(@NonNull CompaniesDataSource localDataSource) {
if (INSTANCE == null) {
INSTANCE = new CompaniesRepository(localDataSource);
}
return INSTANCE;
}
@Override
|
public Observable<List<Company>> getCompanies() {
|
TonnyL/Espresso
|
app/src/main/java/io/github/marktony/espresso/customtabs/CustomTabsHelper.java
|
// Path: app/src/main/java/io/github/marktony/espresso/util/SettingsUtil.java
// public class SettingsUtil {
//
// public static final String KEY_ALERT = "alert";
// public static final String KEY_DO_NOT_DISTURB_MODE = "do_not_disturb_mode";
// public static final String KEY_DO_NOT_DISTURB_MODE_START_HOUR = "do_not_disturb_mode_start_hour";
// public static final String KEY_DO_NOT_DISTURB_MODE_START_MINUTE = "do_not_disturb_mode_start_minute";
// public static final String KEY_DO_NOT_DISTURB_MODE_END_HOUR = "do_not_disturb_mode_end_hour";
// public static final String KEY_DO_NOT_DISTURB_MODE_END_MINUTE = "do_not_disturb_mode_end_minute";
// public static final String KEY_NOTIFICATION_INTERVAL = "notification_interval";
//
// public static final String KEY_FIRST_LAUNCH = "first_launch";
//
// public static final String KEY_CUSTOM_TABS = "chrome_custom_tabs";
//
// public static final String KEY_NIGHT_MODE = "night_mode";
//
// }
|
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
import android.preference.PreferenceManager;
import android.support.customtabs.CustomTabsIntent;
import android.support.v4.content.ContextCompat;
import android.widget.Toast;
import io.github.marktony.espresso.R;
import io.github.marktony.espresso.util.SettingsUtil;
|
/*
* Copyright(c) 2017 lizhaotailang
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.marktony.espresso.customtabs;
/**
* Created by lizhaotailang on 2017/3/27.
*/
public class CustomTabsHelper {
public static void openUrl(Context context, String url) {
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
|
// Path: app/src/main/java/io/github/marktony/espresso/util/SettingsUtil.java
// public class SettingsUtil {
//
// public static final String KEY_ALERT = "alert";
// public static final String KEY_DO_NOT_DISTURB_MODE = "do_not_disturb_mode";
// public static final String KEY_DO_NOT_DISTURB_MODE_START_HOUR = "do_not_disturb_mode_start_hour";
// public static final String KEY_DO_NOT_DISTURB_MODE_START_MINUTE = "do_not_disturb_mode_start_minute";
// public static final String KEY_DO_NOT_DISTURB_MODE_END_HOUR = "do_not_disturb_mode_end_hour";
// public static final String KEY_DO_NOT_DISTURB_MODE_END_MINUTE = "do_not_disturb_mode_end_minute";
// public static final String KEY_NOTIFICATION_INTERVAL = "notification_interval";
//
// public static final String KEY_FIRST_LAUNCH = "first_launch";
//
// public static final String KEY_CUSTOM_TABS = "chrome_custom_tabs";
//
// public static final String KEY_NIGHT_MODE = "night_mode";
//
// }
// Path: app/src/main/java/io/github/marktony/espresso/customtabs/CustomTabsHelper.java
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
import android.preference.PreferenceManager;
import android.support.customtabs.CustomTabsIntent;
import android.support.v4.content.ContextCompat;
import android.widget.Toast;
import io.github.marktony.espresso.R;
import io.github.marktony.espresso.util.SettingsUtil;
/*
* Copyright(c) 2017 lizhaotailang
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.marktony.espresso.customtabs;
/**
* Created by lizhaotailang on 2017/3/27.
*/
public class CustomTabsHelper {
public static void openUrl(Context context, String url) {
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
|
if (sharedPreferences.getBoolean(SettingsUtil.KEY_CUSTOM_TABS, true)) {
|
TonnyL/Espresso
|
app/src/main/java/io/github/marktony/espresso/component/FastScrollPopup.java
|
// Path: app/src/main/java/io/github/marktony/espresso/util/DensityUtil.java
// public class DensityUtil {
//
// public static int getScreenHeight(Context context) {
// DisplayMetrics displayMetrics = new DisplayMetrics();
// ((Activity) context).getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
// return displayMetrics.heightPixels;
// }
//
// public static int getScreenWidth(Context context) {
// DisplayMetrics displayMetrics = new DisplayMetrics();
// ((Activity) context).getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
// return displayMetrics.widthPixels;
// }
//
// public static int getScreenHeightWithDecorations(Context context) {
// int heightPixes;
// WindowManager windowManager = ((Activity) context).getWindowManager();
// Display display = windowManager.getDefaultDisplay();
// Point realSize = new Point();
// try {
// Display.class.getMethod("getRealSize", Point.class).invoke(display, realSize);
// } catch (NoSuchMethodException e) {
// e.printStackTrace();
// } catch (IllegalAccessException e) {
// e.printStackTrace();
// } catch (InvocationTargetException e) {
// e.printStackTrace();
// }
// heightPixes = realSize.y;
// return heightPixes;
// }
//
// public static int dip2px(Context context, float dpVale) {
// final float scale = context.getResources().getDisplayMetrics().density;
// return (int) (dpVale * scale + 0.5f);
// }
//
// public static int getStatusBarHeight(Context context) {
// Resources resources = context.getResources();
// int resourcesId = resources.getIdentifier("status_bar_height", "dimen", "android");
// int height = resources.getDimensionPixelSize(resourcesId);
// return height;
// }
//
// /**
// * Converts sp to px
// *
// * @param context Context
// * @param sp the value in sp
// * @return int
// */
// public static int dip2sp(Context context, float sp) {
// return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, sp, context.getResources().getDisplayMetrics());
// }
//
// public static int px2dip(Context context, float pxValue) {
// final float scale = context.getResources().getDisplayMetrics().density;
// return (int) (pxValue / scale + 0.5f);
// }
//
// }
|
import android.animation.ObjectAnimator;
import android.content.res.Resources;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.Typeface;
import android.text.TextUtils;
import android.view.View;
import io.github.marktony.espresso.util.DensityUtil;
|
/*
* Copyright(c) 2017 lizhaotailang
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.marktony.espresso.component;
/**
* Created by lizhaotailang on 2017/3/24.
*/
public class FastScrollPopup {
private FastScrollRecyclerView mRecyclerView;
private Resources mRes;
private int mBackgroundSize;
private int mCornerRadius;
private Path mBackgroundPath = new Path();
private RectF mBackgroundRect = new RectF();
private Paint mBackgroundPaint;
private Rect mInvalidateRect = new Rect();
private Rect mTmpRect = new Rect();
// The absolute bounds of the fast scroller bg
private Rect mBgBounds = new Rect();
private String mSectionName;
private Paint mTextPaint;
private Rect mTextBounds = new Rect();
private float mAlpha = 1;
private ObjectAnimator mAlphaAnimator;
private boolean mVisible;
public FastScrollPopup(Resources resources, FastScrollRecyclerView recyclerView) {
mRes = resources;
mRecyclerView = recyclerView;
mBackgroundPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mTextPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mTextPaint.setAlpha(0);
|
// Path: app/src/main/java/io/github/marktony/espresso/util/DensityUtil.java
// public class DensityUtil {
//
// public static int getScreenHeight(Context context) {
// DisplayMetrics displayMetrics = new DisplayMetrics();
// ((Activity) context).getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
// return displayMetrics.heightPixels;
// }
//
// public static int getScreenWidth(Context context) {
// DisplayMetrics displayMetrics = new DisplayMetrics();
// ((Activity) context).getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
// return displayMetrics.widthPixels;
// }
//
// public static int getScreenHeightWithDecorations(Context context) {
// int heightPixes;
// WindowManager windowManager = ((Activity) context).getWindowManager();
// Display display = windowManager.getDefaultDisplay();
// Point realSize = new Point();
// try {
// Display.class.getMethod("getRealSize", Point.class).invoke(display, realSize);
// } catch (NoSuchMethodException e) {
// e.printStackTrace();
// } catch (IllegalAccessException e) {
// e.printStackTrace();
// } catch (InvocationTargetException e) {
// e.printStackTrace();
// }
// heightPixes = realSize.y;
// return heightPixes;
// }
//
// public static int dip2px(Context context, float dpVale) {
// final float scale = context.getResources().getDisplayMetrics().density;
// return (int) (dpVale * scale + 0.5f);
// }
//
// public static int getStatusBarHeight(Context context) {
// Resources resources = context.getResources();
// int resourcesId = resources.getIdentifier("status_bar_height", "dimen", "android");
// int height = resources.getDimensionPixelSize(resourcesId);
// return height;
// }
//
// /**
// * Converts sp to px
// *
// * @param context Context
// * @param sp the value in sp
// * @return int
// */
// public static int dip2sp(Context context, float sp) {
// return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, sp, context.getResources().getDisplayMetrics());
// }
//
// public static int px2dip(Context context, float pxValue) {
// final float scale = context.getResources().getDisplayMetrics().density;
// return (int) (pxValue / scale + 0.5f);
// }
//
// }
// Path: app/src/main/java/io/github/marktony/espresso/component/FastScrollPopup.java
import android.animation.ObjectAnimator;
import android.content.res.Resources;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.Typeface;
import android.text.TextUtils;
import android.view.View;
import io.github.marktony.espresso.util.DensityUtil;
/*
* Copyright(c) 2017 lizhaotailang
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.marktony.espresso.component;
/**
* Created by lizhaotailang on 2017/3/24.
*/
public class FastScrollPopup {
private FastScrollRecyclerView mRecyclerView;
private Resources mRes;
private int mBackgroundSize;
private int mCornerRadius;
private Path mBackgroundPath = new Path();
private RectF mBackgroundRect = new RectF();
private Paint mBackgroundPaint;
private Rect mInvalidateRect = new Rect();
private Rect mTmpRect = new Rect();
// The absolute bounds of the fast scroller bg
private Rect mBgBounds = new Rect();
private String mSectionName;
private Paint mTextPaint;
private Rect mTextBounds = new Rect();
private float mAlpha = 1;
private ObjectAnimator mAlphaAnimator;
private boolean mVisible;
public FastScrollPopup(Resources resources, FastScrollRecyclerView recyclerView) {
mRes = resources;
mRecyclerView = recyclerView;
mBackgroundPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mTextPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mTextPaint.setAlpha(0);
|
setTextSize(DensityUtil.dip2sp(recyclerView.getContext(),56));
|
TonnyL/Espresso
|
app/src/main/java/io/github/marktony/espresso/mvp/companies/CompaniesPresenter.java
|
// Path: app/src/main/java/io/github/marktony/espresso/data/Company.java
// public class Company extends RealmObject {
//
// @Expose
// @SerializedName("name")
// private String name;
//
// @PrimaryKey
// @Expose
// @SerializedName("id")
// private String id;
//
// @Expose
// @SerializedName("tel")
// private String tel;
//
// @Expose
// @SerializedName("website")
// private String website;
//
// @Expose
// @SerializedName("alphabet")
// private String alphabet;
//
// @Expose
// @SerializedName("avatar")
// private String avatar;
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getTel() {
// return tel;
// }
//
// public void setTel(String tel) {
// this.tel = tel;
// }
//
// public String getWebsite() {
// return website;
// }
//
// public void setWebsite(String website) {
// this.website = website;
// }
//
// public String getAlphabet() {
// return alphabet;
// }
//
// public void setAlphabet(String alphabet) {
// this.alphabet = alphabet;
// }
//
// public String getAvatarColor() {
// return avatar;
// }
//
// public void setAvatarColor(String avatar) {
// this.avatar = avatar;
// }
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: app/src/main/java/io/github/marktony/espresso/data/source/CompaniesRepository.java
// public class CompaniesRepository implements CompaniesDataSource {
//
// @Nullable
// private static CompaniesRepository INSTANCE = null;
//
// @NonNull
// private final CompaniesDataSource localDataSource;
//
// // Prevent direct instantiation
// private CompaniesRepository(@NonNull CompaniesDataSource localDataSource) {
// this.localDataSource = localDataSource;
// }
//
// public static CompaniesRepository getInstance(@NonNull CompaniesDataSource localDataSource) {
// if (INSTANCE == null) {
// INSTANCE = new CompaniesRepository(localDataSource);
// }
// return INSTANCE;
// }
//
// @Override
// public Observable<List<Company>> getCompanies() {
// return localDataSource.getCompanies();
// }
//
// @Override
// public Observable<Company> getCompany(@NonNull String companyId) {
// return localDataSource.getCompany(companyId);
// }
//
// @Override
// public void initData() {
// localDataSource.initData();
// }
//
// @Override
// public Observable<List<Company>> searchCompanies(@NonNull String keyWords) {
// return localDataSource.searchCompanies(keyWords);
// }
//
// }
|
import android.support.annotation.NonNull;
import java.util.List;
import io.github.marktony.espresso.data.Company;
import io.github.marktony.espresso.data.source.CompaniesRepository;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.CompositeDisposable;
import io.reactivex.disposables.Disposable;
import io.reactivex.observers.DisposableObserver;
import io.reactivex.schedulers.Schedulers;
|
/*
* Copyright(c) 2017 lizhaotailang
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.marktony.espresso.mvp.companies;
/**
* Created by lizhaotailang on 2017/2/10.
*/
public class CompaniesPresenter implements CompaniesContract.Presenter {
@NonNull
private CompaniesContract.View view;
@NonNull
|
// Path: app/src/main/java/io/github/marktony/espresso/data/Company.java
// public class Company extends RealmObject {
//
// @Expose
// @SerializedName("name")
// private String name;
//
// @PrimaryKey
// @Expose
// @SerializedName("id")
// private String id;
//
// @Expose
// @SerializedName("tel")
// private String tel;
//
// @Expose
// @SerializedName("website")
// private String website;
//
// @Expose
// @SerializedName("alphabet")
// private String alphabet;
//
// @Expose
// @SerializedName("avatar")
// private String avatar;
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getTel() {
// return tel;
// }
//
// public void setTel(String tel) {
// this.tel = tel;
// }
//
// public String getWebsite() {
// return website;
// }
//
// public void setWebsite(String website) {
// this.website = website;
// }
//
// public String getAlphabet() {
// return alphabet;
// }
//
// public void setAlphabet(String alphabet) {
// this.alphabet = alphabet;
// }
//
// public String getAvatarColor() {
// return avatar;
// }
//
// public void setAvatarColor(String avatar) {
// this.avatar = avatar;
// }
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: app/src/main/java/io/github/marktony/espresso/data/source/CompaniesRepository.java
// public class CompaniesRepository implements CompaniesDataSource {
//
// @Nullable
// private static CompaniesRepository INSTANCE = null;
//
// @NonNull
// private final CompaniesDataSource localDataSource;
//
// // Prevent direct instantiation
// private CompaniesRepository(@NonNull CompaniesDataSource localDataSource) {
// this.localDataSource = localDataSource;
// }
//
// public static CompaniesRepository getInstance(@NonNull CompaniesDataSource localDataSource) {
// if (INSTANCE == null) {
// INSTANCE = new CompaniesRepository(localDataSource);
// }
// return INSTANCE;
// }
//
// @Override
// public Observable<List<Company>> getCompanies() {
// return localDataSource.getCompanies();
// }
//
// @Override
// public Observable<Company> getCompany(@NonNull String companyId) {
// return localDataSource.getCompany(companyId);
// }
//
// @Override
// public void initData() {
// localDataSource.initData();
// }
//
// @Override
// public Observable<List<Company>> searchCompanies(@NonNull String keyWords) {
// return localDataSource.searchCompanies(keyWords);
// }
//
// }
// Path: app/src/main/java/io/github/marktony/espresso/mvp/companies/CompaniesPresenter.java
import android.support.annotation.NonNull;
import java.util.List;
import io.github.marktony.espresso.data.Company;
import io.github.marktony.espresso.data.source.CompaniesRepository;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.CompositeDisposable;
import io.reactivex.disposables.Disposable;
import io.reactivex.observers.DisposableObserver;
import io.reactivex.schedulers.Schedulers;
/*
* Copyright(c) 2017 lizhaotailang
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.marktony.espresso.mvp.companies;
/**
* Created by lizhaotailang on 2017/2/10.
*/
public class CompaniesPresenter implements CompaniesContract.Presenter {
@NonNull
private CompaniesContract.View view;
@NonNull
|
private CompaniesRepository companiesRepository;
|
TonnyL/Espresso
|
app/src/main/java/io/github/marktony/espresso/mvp/companies/CompaniesPresenter.java
|
// Path: app/src/main/java/io/github/marktony/espresso/data/Company.java
// public class Company extends RealmObject {
//
// @Expose
// @SerializedName("name")
// private String name;
//
// @PrimaryKey
// @Expose
// @SerializedName("id")
// private String id;
//
// @Expose
// @SerializedName("tel")
// private String tel;
//
// @Expose
// @SerializedName("website")
// private String website;
//
// @Expose
// @SerializedName("alphabet")
// private String alphabet;
//
// @Expose
// @SerializedName("avatar")
// private String avatar;
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getTel() {
// return tel;
// }
//
// public void setTel(String tel) {
// this.tel = tel;
// }
//
// public String getWebsite() {
// return website;
// }
//
// public void setWebsite(String website) {
// this.website = website;
// }
//
// public String getAlphabet() {
// return alphabet;
// }
//
// public void setAlphabet(String alphabet) {
// this.alphabet = alphabet;
// }
//
// public String getAvatarColor() {
// return avatar;
// }
//
// public void setAvatarColor(String avatar) {
// this.avatar = avatar;
// }
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: app/src/main/java/io/github/marktony/espresso/data/source/CompaniesRepository.java
// public class CompaniesRepository implements CompaniesDataSource {
//
// @Nullable
// private static CompaniesRepository INSTANCE = null;
//
// @NonNull
// private final CompaniesDataSource localDataSource;
//
// // Prevent direct instantiation
// private CompaniesRepository(@NonNull CompaniesDataSource localDataSource) {
// this.localDataSource = localDataSource;
// }
//
// public static CompaniesRepository getInstance(@NonNull CompaniesDataSource localDataSource) {
// if (INSTANCE == null) {
// INSTANCE = new CompaniesRepository(localDataSource);
// }
// return INSTANCE;
// }
//
// @Override
// public Observable<List<Company>> getCompanies() {
// return localDataSource.getCompanies();
// }
//
// @Override
// public Observable<Company> getCompany(@NonNull String companyId) {
// return localDataSource.getCompany(companyId);
// }
//
// @Override
// public void initData() {
// localDataSource.initData();
// }
//
// @Override
// public Observable<List<Company>> searchCompanies(@NonNull String keyWords) {
// return localDataSource.searchCompanies(keyWords);
// }
//
// }
|
import android.support.annotation.NonNull;
import java.util.List;
import io.github.marktony.espresso.data.Company;
import io.github.marktony.espresso.data.source.CompaniesRepository;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.CompositeDisposable;
import io.reactivex.disposables.Disposable;
import io.reactivex.observers.DisposableObserver;
import io.reactivex.schedulers.Schedulers;
|
/*
* Copyright(c) 2017 lizhaotailang
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.marktony.espresso.mvp.companies;
/**
* Created by lizhaotailang on 2017/2/10.
*/
public class CompaniesPresenter implements CompaniesContract.Presenter {
@NonNull
private CompaniesContract.View view;
@NonNull
private CompaniesRepository companiesRepository;
@NonNull
private CompositeDisposable compositeDisposable;
public CompaniesPresenter(@NonNull CompaniesContract.View view,
@NonNull CompaniesRepository companiesRepository) {
this.view = view;
this.companiesRepository = companiesRepository;
compositeDisposable = new CompositeDisposable();
this.view.setPresenter(this);
}
@Override
public void subscribe() {
getCompanies();
}
@Override
public void unsubscribe() {
compositeDisposable.clear();
}
private void getCompanies() {
Disposable disposable = companiesRepository
.getCompanies()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
|
// Path: app/src/main/java/io/github/marktony/espresso/data/Company.java
// public class Company extends RealmObject {
//
// @Expose
// @SerializedName("name")
// private String name;
//
// @PrimaryKey
// @Expose
// @SerializedName("id")
// private String id;
//
// @Expose
// @SerializedName("tel")
// private String tel;
//
// @Expose
// @SerializedName("website")
// private String website;
//
// @Expose
// @SerializedName("alphabet")
// private String alphabet;
//
// @Expose
// @SerializedName("avatar")
// private String avatar;
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getTel() {
// return tel;
// }
//
// public void setTel(String tel) {
// this.tel = tel;
// }
//
// public String getWebsite() {
// return website;
// }
//
// public void setWebsite(String website) {
// this.website = website;
// }
//
// public String getAlphabet() {
// return alphabet;
// }
//
// public void setAlphabet(String alphabet) {
// this.alphabet = alphabet;
// }
//
// public String getAvatarColor() {
// return avatar;
// }
//
// public void setAvatarColor(String avatar) {
// this.avatar = avatar;
// }
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: app/src/main/java/io/github/marktony/espresso/data/source/CompaniesRepository.java
// public class CompaniesRepository implements CompaniesDataSource {
//
// @Nullable
// private static CompaniesRepository INSTANCE = null;
//
// @NonNull
// private final CompaniesDataSource localDataSource;
//
// // Prevent direct instantiation
// private CompaniesRepository(@NonNull CompaniesDataSource localDataSource) {
// this.localDataSource = localDataSource;
// }
//
// public static CompaniesRepository getInstance(@NonNull CompaniesDataSource localDataSource) {
// if (INSTANCE == null) {
// INSTANCE = new CompaniesRepository(localDataSource);
// }
// return INSTANCE;
// }
//
// @Override
// public Observable<List<Company>> getCompanies() {
// return localDataSource.getCompanies();
// }
//
// @Override
// public Observable<Company> getCompany(@NonNull String companyId) {
// return localDataSource.getCompany(companyId);
// }
//
// @Override
// public void initData() {
// localDataSource.initData();
// }
//
// @Override
// public Observable<List<Company>> searchCompanies(@NonNull String keyWords) {
// return localDataSource.searchCompanies(keyWords);
// }
//
// }
// Path: app/src/main/java/io/github/marktony/espresso/mvp/companies/CompaniesPresenter.java
import android.support.annotation.NonNull;
import java.util.List;
import io.github.marktony.espresso.data.Company;
import io.github.marktony.espresso.data.source.CompaniesRepository;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.CompositeDisposable;
import io.reactivex.disposables.Disposable;
import io.reactivex.observers.DisposableObserver;
import io.reactivex.schedulers.Schedulers;
/*
* Copyright(c) 2017 lizhaotailang
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.marktony.espresso.mvp.companies;
/**
* Created by lizhaotailang on 2017/2/10.
*/
public class CompaniesPresenter implements CompaniesContract.Presenter {
@NonNull
private CompaniesContract.View view;
@NonNull
private CompaniesRepository companiesRepository;
@NonNull
private CompositeDisposable compositeDisposable;
public CompaniesPresenter(@NonNull CompaniesContract.View view,
@NonNull CompaniesRepository companiesRepository) {
this.view = view;
this.companiesRepository = companiesRepository;
compositeDisposable = new CompositeDisposable();
this.view.setPresenter(this);
}
@Override
public void subscribe() {
getCompanies();
}
@Override
public void unsubscribe() {
compositeDisposable.clear();
}
private void getCompanies() {
Disposable disposable = companiesRepository
.getCompanies()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
|
.subscribeWith(new DisposableObserver<List<Company>>() {
|
psiegman/ehcachetag
|
ehcachetag/src/main/java/nl/siegmann/ehcachetag/CacheTag.java
|
// Path: ehcachetag/src/main/java/nl/siegmann/ehcachetag/cachetagmodifier/CacheTagModifier.java
// public interface CacheTagModifier {
//
// /**
// * CacheTagInterceptor that does not do anything.
// *
// */
// CacheTagModifier NULL_CACHETAG_MODIFIER = new CacheTagModifier() {
//
// @Override
// public void init(ServletContext servletContext) {
// }
//
// @Override
// public void beforeLookup(CacheTag cacheTag, JspContext jspContext) {
// }
//
// @Override
// public String afterRetrieval(CacheTag cacheTag, JspContext jspContext,
// String content) {
// return content;
// }
//
// @Override
// public void destroy() {
// }
//
// @Override
// public String beforeUpdate(CacheTag cacheTag, JspContext jspContext,
// String content) {
// return content;
// }
//
// };
//
// /**
// * Called once on Application startup.
// *
// * @param properties
// */
// void init(ServletContext servletContext);
//
// /**
// * Called before Cache lookup.
// *
// * Will be called by different threads concurrently.
// */
// void beforeLookup(CacheTag cacheTag, JspContext jspContext);
//
// /**
// * Called before updating the cache with the given content.
// *
// * @param cacheTag
// * @param jspContext
// * @param content the content that will be stored in the cache
// * @return the content to store in the cache.
// */
// String beforeUpdate(CacheTag cacheTag, JspContext jspContext, String content);
//
//
// /**
// * Called after retrieving content from the cache but before it's written to the output.
// *
// * @param cacheTag
// * @param jspContext
// * @param content the content that will be sent back to the client
// * @return The content to send back to the client
// */
// String afterRetrieval(CacheTag cacheTag, JspContext jspContext, String content);
//
// /**
// * Called on Application shutdown.
// */
// void destroy();
// }
//
// Path: ehcachetag/src/main/java/nl/siegmann/ehcachetag/cachetagmodifier/CacheTagModifierFactory.java
// public interface CacheTagModifierFactory {
//
// /**
// * Called once after application is initialized.
// *
// * @param servletContext
// */
// void init(ServletContext servletContext);
//
// /**
// * The names of the available cacheTagModifiers
// *
// * @return The names of the available cacheTagModifiers
// */
// Collection<String> getCacheTagModifierNames();
//
// /**
// * Gets the cacheTagModifier with the given name, null if not found.
// *
// * @param cacheTagModifierName name of the CacheTagModifier we're looking for.
// *
// * @return the CacheTagModifier with the given name, null if not found.
// */
// CacheTagModifier getCacheTagModifier(String cacheTagModifierName);
//
// /**
// * Called once on application destroy.
// *
// */
// void destroy();
// }
//
// Path: ehcachetag/src/main/java/nl/siegmann/ehcachetag/util/StringUtil.java
// public class StringUtil {
//
// /**
// * Finds and returns the string from the alternatives that closest matches the input string based on the Levenshtein distance.
// *
// * @see <a href="http://en.wikipedia.org/wiki/Levenshtein_distance">Levenshtein Distance</a>
// *
// * @param input
// * @param alternatives
// * @return the string from the alternatives that closest matches the input string based on the Levenshtein distance.
// */
// public static String getClosestMatchingString(String input, Collection<String> alternatives) {
// if (input == null || alternatives == null || alternatives.isEmpty()) {
// return null;
// }
// String current = null;
// int minDistance = Integer.MAX_VALUE;
// for (String alternative: alternatives) {
// int currentDistance = StringUtils.getLevenshteinDistance(input, alternative);
// if ((current == null) || (currentDistance < minDistance)) {
// current = alternative;
// minDistance = currentDistance;
// }
// }
// return current;
// }
//
// }
|
import java.io.IOException;
import javax.servlet.ServletRequest;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.BodyTagSupport;
import javax.servlet.jsp.tagext.Tag;
import net.sf.ehcache.CacheManager;
import net.sf.ehcache.Ehcache;
import net.sf.ehcache.Element;
import nl.siegmann.ehcachetag.cachetagmodifier.CacheTagModifier;
import nl.siegmann.ehcachetag.cachetagmodifier.CacheTagModifierFactory;
import nl.siegmann.ehcachetag.util.StringUtil;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
|
// set cacheKey to null so that the endTag knows
// it does not have to store anything in the cache
key = null;
result = BodyTagSupport.SKIP_BODY;
}
return result;
}
/**
* Internal exception that is used in case a modifier is search for but not found.
*
* @author paul
*
*/
static final class ModifierNotFoundException extends Exception {
private static final long serialVersionUID = 4535024464306691589L;
public ModifierNotFoundException(String message) {
super(message);
}
}
/**
* This method is called before doing a lookup in the cache.
* Invoke the cacheTagInterceptor.beforeLookup.
*/
void doBeforeLookup() throws Exception {
|
// Path: ehcachetag/src/main/java/nl/siegmann/ehcachetag/cachetagmodifier/CacheTagModifier.java
// public interface CacheTagModifier {
//
// /**
// * CacheTagInterceptor that does not do anything.
// *
// */
// CacheTagModifier NULL_CACHETAG_MODIFIER = new CacheTagModifier() {
//
// @Override
// public void init(ServletContext servletContext) {
// }
//
// @Override
// public void beforeLookup(CacheTag cacheTag, JspContext jspContext) {
// }
//
// @Override
// public String afterRetrieval(CacheTag cacheTag, JspContext jspContext,
// String content) {
// return content;
// }
//
// @Override
// public void destroy() {
// }
//
// @Override
// public String beforeUpdate(CacheTag cacheTag, JspContext jspContext,
// String content) {
// return content;
// }
//
// };
//
// /**
// * Called once on Application startup.
// *
// * @param properties
// */
// void init(ServletContext servletContext);
//
// /**
// * Called before Cache lookup.
// *
// * Will be called by different threads concurrently.
// */
// void beforeLookup(CacheTag cacheTag, JspContext jspContext);
//
// /**
// * Called before updating the cache with the given content.
// *
// * @param cacheTag
// * @param jspContext
// * @param content the content that will be stored in the cache
// * @return the content to store in the cache.
// */
// String beforeUpdate(CacheTag cacheTag, JspContext jspContext, String content);
//
//
// /**
// * Called after retrieving content from the cache but before it's written to the output.
// *
// * @param cacheTag
// * @param jspContext
// * @param content the content that will be sent back to the client
// * @return The content to send back to the client
// */
// String afterRetrieval(CacheTag cacheTag, JspContext jspContext, String content);
//
// /**
// * Called on Application shutdown.
// */
// void destroy();
// }
//
// Path: ehcachetag/src/main/java/nl/siegmann/ehcachetag/cachetagmodifier/CacheTagModifierFactory.java
// public interface CacheTagModifierFactory {
//
// /**
// * Called once after application is initialized.
// *
// * @param servletContext
// */
// void init(ServletContext servletContext);
//
// /**
// * The names of the available cacheTagModifiers
// *
// * @return The names of the available cacheTagModifiers
// */
// Collection<String> getCacheTagModifierNames();
//
// /**
// * Gets the cacheTagModifier with the given name, null if not found.
// *
// * @param cacheTagModifierName name of the CacheTagModifier we're looking for.
// *
// * @return the CacheTagModifier with the given name, null if not found.
// */
// CacheTagModifier getCacheTagModifier(String cacheTagModifierName);
//
// /**
// * Called once on application destroy.
// *
// */
// void destroy();
// }
//
// Path: ehcachetag/src/main/java/nl/siegmann/ehcachetag/util/StringUtil.java
// public class StringUtil {
//
// /**
// * Finds and returns the string from the alternatives that closest matches the input string based on the Levenshtein distance.
// *
// * @see <a href="http://en.wikipedia.org/wiki/Levenshtein_distance">Levenshtein Distance</a>
// *
// * @param input
// * @param alternatives
// * @return the string from the alternatives that closest matches the input string based on the Levenshtein distance.
// */
// public static String getClosestMatchingString(String input, Collection<String> alternatives) {
// if (input == null || alternatives == null || alternatives.isEmpty()) {
// return null;
// }
// String current = null;
// int minDistance = Integer.MAX_VALUE;
// for (String alternative: alternatives) {
// int currentDistance = StringUtils.getLevenshteinDistance(input, alternative);
// if ((current == null) || (currentDistance < minDistance)) {
// current = alternative;
// minDistance = currentDistance;
// }
// }
// return current;
// }
//
// }
// Path: ehcachetag/src/main/java/nl/siegmann/ehcachetag/CacheTag.java
import java.io.IOException;
import javax.servlet.ServletRequest;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.BodyTagSupport;
import javax.servlet.jsp.tagext.Tag;
import net.sf.ehcache.CacheManager;
import net.sf.ehcache.Ehcache;
import net.sf.ehcache.Element;
import nl.siegmann.ehcachetag.cachetagmodifier.CacheTagModifier;
import nl.siegmann.ehcachetag.cachetagmodifier.CacheTagModifierFactory;
import nl.siegmann.ehcachetag.util.StringUtil;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
// set cacheKey to null so that the endTag knows
// it does not have to store anything in the cache
key = null;
result = BodyTagSupport.SKIP_BODY;
}
return result;
}
/**
* Internal exception that is used in case a modifier is search for but not found.
*
* @author paul
*
*/
static final class ModifierNotFoundException extends Exception {
private static final long serialVersionUID = 4535024464306691589L;
public ModifierNotFoundException(String message) {
super(message);
}
}
/**
* This method is called before doing a lookup in the cache.
* Invoke the cacheTagInterceptor.beforeLookup.
*/
void doBeforeLookup() throws Exception {
|
CacheTagModifierFactory cacheTagModifierFactory = getCacheTagModifierFactory();
|
psiegman/ehcachetag
|
ehcachetag/src/main/java/nl/siegmann/ehcachetag/CacheTag.java
|
// Path: ehcachetag/src/main/java/nl/siegmann/ehcachetag/cachetagmodifier/CacheTagModifier.java
// public interface CacheTagModifier {
//
// /**
// * CacheTagInterceptor that does not do anything.
// *
// */
// CacheTagModifier NULL_CACHETAG_MODIFIER = new CacheTagModifier() {
//
// @Override
// public void init(ServletContext servletContext) {
// }
//
// @Override
// public void beforeLookup(CacheTag cacheTag, JspContext jspContext) {
// }
//
// @Override
// public String afterRetrieval(CacheTag cacheTag, JspContext jspContext,
// String content) {
// return content;
// }
//
// @Override
// public void destroy() {
// }
//
// @Override
// public String beforeUpdate(CacheTag cacheTag, JspContext jspContext,
// String content) {
// return content;
// }
//
// };
//
// /**
// * Called once on Application startup.
// *
// * @param properties
// */
// void init(ServletContext servletContext);
//
// /**
// * Called before Cache lookup.
// *
// * Will be called by different threads concurrently.
// */
// void beforeLookup(CacheTag cacheTag, JspContext jspContext);
//
// /**
// * Called before updating the cache with the given content.
// *
// * @param cacheTag
// * @param jspContext
// * @param content the content that will be stored in the cache
// * @return the content to store in the cache.
// */
// String beforeUpdate(CacheTag cacheTag, JspContext jspContext, String content);
//
//
// /**
// * Called after retrieving content from the cache but before it's written to the output.
// *
// * @param cacheTag
// * @param jspContext
// * @param content the content that will be sent back to the client
// * @return The content to send back to the client
// */
// String afterRetrieval(CacheTag cacheTag, JspContext jspContext, String content);
//
// /**
// * Called on Application shutdown.
// */
// void destroy();
// }
//
// Path: ehcachetag/src/main/java/nl/siegmann/ehcachetag/cachetagmodifier/CacheTagModifierFactory.java
// public interface CacheTagModifierFactory {
//
// /**
// * Called once after application is initialized.
// *
// * @param servletContext
// */
// void init(ServletContext servletContext);
//
// /**
// * The names of the available cacheTagModifiers
// *
// * @return The names of the available cacheTagModifiers
// */
// Collection<String> getCacheTagModifierNames();
//
// /**
// * Gets the cacheTagModifier with the given name, null if not found.
// *
// * @param cacheTagModifierName name of the CacheTagModifier we're looking for.
// *
// * @return the CacheTagModifier with the given name, null if not found.
// */
// CacheTagModifier getCacheTagModifier(String cacheTagModifierName);
//
// /**
// * Called once on application destroy.
// *
// */
// void destroy();
// }
//
// Path: ehcachetag/src/main/java/nl/siegmann/ehcachetag/util/StringUtil.java
// public class StringUtil {
//
// /**
// * Finds and returns the string from the alternatives that closest matches the input string based on the Levenshtein distance.
// *
// * @see <a href="http://en.wikipedia.org/wiki/Levenshtein_distance">Levenshtein Distance</a>
// *
// * @param input
// * @param alternatives
// * @return the string from the alternatives that closest matches the input string based on the Levenshtein distance.
// */
// public static String getClosestMatchingString(String input, Collection<String> alternatives) {
// if (input == null || alternatives == null || alternatives.isEmpty()) {
// return null;
// }
// String current = null;
// int minDistance = Integer.MAX_VALUE;
// for (String alternative: alternatives) {
// int currentDistance = StringUtils.getLevenshteinDistance(input, alternative);
// if ((current == null) || (currentDistance < minDistance)) {
// current = alternative;
// minDistance = currentDistance;
// }
// }
// return current;
// }
//
// }
|
import java.io.IOException;
import javax.servlet.ServletRequest;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.BodyTagSupport;
import javax.servlet.jsp.tagext.Tag;
import net.sf.ehcache.CacheManager;
import net.sf.ehcache.Ehcache;
import net.sf.ehcache.Element;
import nl.siegmann.ehcachetag.cachetagmodifier.CacheTagModifier;
import nl.siegmann.ehcachetag.cachetagmodifier.CacheTagModifierFactory;
import nl.siegmann.ehcachetag.util.StringUtil;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
|
}
return result;
}
/**
* Internal exception that is used in case a modifier is search for but not found.
*
* @author paul
*
*/
static final class ModifierNotFoundException extends Exception {
private static final long serialVersionUID = 4535024464306691589L;
public ModifierNotFoundException(String message) {
super(message);
}
}
/**
* This method is called before doing a lookup in the cache.
* Invoke the cacheTagInterceptor.beforeLookup.
*/
void doBeforeLookup() throws Exception {
CacheTagModifierFactory cacheTagModifierFactory = getCacheTagModifierFactory();
if (cacheTagModifierFactory == null) {
return;
}
for (String modifierName: modifiers) {
|
// Path: ehcachetag/src/main/java/nl/siegmann/ehcachetag/cachetagmodifier/CacheTagModifier.java
// public interface CacheTagModifier {
//
// /**
// * CacheTagInterceptor that does not do anything.
// *
// */
// CacheTagModifier NULL_CACHETAG_MODIFIER = new CacheTagModifier() {
//
// @Override
// public void init(ServletContext servletContext) {
// }
//
// @Override
// public void beforeLookup(CacheTag cacheTag, JspContext jspContext) {
// }
//
// @Override
// public String afterRetrieval(CacheTag cacheTag, JspContext jspContext,
// String content) {
// return content;
// }
//
// @Override
// public void destroy() {
// }
//
// @Override
// public String beforeUpdate(CacheTag cacheTag, JspContext jspContext,
// String content) {
// return content;
// }
//
// };
//
// /**
// * Called once on Application startup.
// *
// * @param properties
// */
// void init(ServletContext servletContext);
//
// /**
// * Called before Cache lookup.
// *
// * Will be called by different threads concurrently.
// */
// void beforeLookup(CacheTag cacheTag, JspContext jspContext);
//
// /**
// * Called before updating the cache with the given content.
// *
// * @param cacheTag
// * @param jspContext
// * @param content the content that will be stored in the cache
// * @return the content to store in the cache.
// */
// String beforeUpdate(CacheTag cacheTag, JspContext jspContext, String content);
//
//
// /**
// * Called after retrieving content from the cache but before it's written to the output.
// *
// * @param cacheTag
// * @param jspContext
// * @param content the content that will be sent back to the client
// * @return The content to send back to the client
// */
// String afterRetrieval(CacheTag cacheTag, JspContext jspContext, String content);
//
// /**
// * Called on Application shutdown.
// */
// void destroy();
// }
//
// Path: ehcachetag/src/main/java/nl/siegmann/ehcachetag/cachetagmodifier/CacheTagModifierFactory.java
// public interface CacheTagModifierFactory {
//
// /**
// * Called once after application is initialized.
// *
// * @param servletContext
// */
// void init(ServletContext servletContext);
//
// /**
// * The names of the available cacheTagModifiers
// *
// * @return The names of the available cacheTagModifiers
// */
// Collection<String> getCacheTagModifierNames();
//
// /**
// * Gets the cacheTagModifier with the given name, null if not found.
// *
// * @param cacheTagModifierName name of the CacheTagModifier we're looking for.
// *
// * @return the CacheTagModifier with the given name, null if not found.
// */
// CacheTagModifier getCacheTagModifier(String cacheTagModifierName);
//
// /**
// * Called once on application destroy.
// *
// */
// void destroy();
// }
//
// Path: ehcachetag/src/main/java/nl/siegmann/ehcachetag/util/StringUtil.java
// public class StringUtil {
//
// /**
// * Finds and returns the string from the alternatives that closest matches the input string based on the Levenshtein distance.
// *
// * @see <a href="http://en.wikipedia.org/wiki/Levenshtein_distance">Levenshtein Distance</a>
// *
// * @param input
// * @param alternatives
// * @return the string from the alternatives that closest matches the input string based on the Levenshtein distance.
// */
// public static String getClosestMatchingString(String input, Collection<String> alternatives) {
// if (input == null || alternatives == null || alternatives.isEmpty()) {
// return null;
// }
// String current = null;
// int minDistance = Integer.MAX_VALUE;
// for (String alternative: alternatives) {
// int currentDistance = StringUtils.getLevenshteinDistance(input, alternative);
// if ((current == null) || (currentDistance < minDistance)) {
// current = alternative;
// minDistance = currentDistance;
// }
// }
// return current;
// }
//
// }
// Path: ehcachetag/src/main/java/nl/siegmann/ehcachetag/CacheTag.java
import java.io.IOException;
import javax.servlet.ServletRequest;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.BodyTagSupport;
import javax.servlet.jsp.tagext.Tag;
import net.sf.ehcache.CacheManager;
import net.sf.ehcache.Ehcache;
import net.sf.ehcache.Element;
import nl.siegmann.ehcachetag.cachetagmodifier.CacheTagModifier;
import nl.siegmann.ehcachetag.cachetagmodifier.CacheTagModifierFactory;
import nl.siegmann.ehcachetag.util.StringUtil;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
}
return result;
}
/**
* Internal exception that is used in case a modifier is search for but not found.
*
* @author paul
*
*/
static final class ModifierNotFoundException extends Exception {
private static final long serialVersionUID = 4535024464306691589L;
public ModifierNotFoundException(String message) {
super(message);
}
}
/**
* This method is called before doing a lookup in the cache.
* Invoke the cacheTagInterceptor.beforeLookup.
*/
void doBeforeLookup() throws Exception {
CacheTagModifierFactory cacheTagModifierFactory = getCacheTagModifierFactory();
if (cacheTagModifierFactory == null) {
return;
}
for (String modifierName: modifiers) {
|
CacheTagModifier cacheTagModifier = getCacheTagModifier(cacheTagModifierFactory, modifierName);
|
psiegman/ehcachetag
|
ehcachetag/src/test/java/nl/siegmann/ehcachetag/CacheTagTest.java
|
// Path: ehcachetag/src/main/java/nl/siegmann/ehcachetag/CacheTag.java
// static final class ModifierNotFoundException extends Exception {
//
// private static final long serialVersionUID = 4535024464306691589L;
//
// public ModifierNotFoundException(String message) {
// super(message);
// }
// }
//
// Path: ehcachetag/src/main/java/nl/siegmann/ehcachetag/cachetagmodifier/CacheTagModifier.java
// public interface CacheTagModifier {
//
// /**
// * CacheTagInterceptor that does not do anything.
// *
// */
// CacheTagModifier NULL_CACHETAG_MODIFIER = new CacheTagModifier() {
//
// @Override
// public void init(ServletContext servletContext) {
// }
//
// @Override
// public void beforeLookup(CacheTag cacheTag, JspContext jspContext) {
// }
//
// @Override
// public String afterRetrieval(CacheTag cacheTag, JspContext jspContext,
// String content) {
// return content;
// }
//
// @Override
// public void destroy() {
// }
//
// @Override
// public String beforeUpdate(CacheTag cacheTag, JspContext jspContext,
// String content) {
// return content;
// }
//
// };
//
// /**
// * Called once on Application startup.
// *
// * @param properties
// */
// void init(ServletContext servletContext);
//
// /**
// * Called before Cache lookup.
// *
// * Will be called by different threads concurrently.
// */
// void beforeLookup(CacheTag cacheTag, JspContext jspContext);
//
// /**
// * Called before updating the cache with the given content.
// *
// * @param cacheTag
// * @param jspContext
// * @param content the content that will be stored in the cache
// * @return the content to store in the cache.
// */
// String beforeUpdate(CacheTag cacheTag, JspContext jspContext, String content);
//
//
// /**
// * Called after retrieving content from the cache but before it's written to the output.
// *
// * @param cacheTag
// * @param jspContext
// * @param content the content that will be sent back to the client
// * @return The content to send back to the client
// */
// String afterRetrieval(CacheTag cacheTag, JspContext jspContext, String content);
//
// /**
// * Called on Application shutdown.
// */
// void destroy();
// }
//
// Path: ehcachetag/src/main/java/nl/siegmann/ehcachetag/cachetagmodifier/CacheTagModifierFactory.java
// public interface CacheTagModifierFactory {
//
// /**
// * Called once after application is initialized.
// *
// * @param servletContext
// */
// void init(ServletContext servletContext);
//
// /**
// * The names of the available cacheTagModifiers
// *
// * @return The names of the available cacheTagModifiers
// */
// Collection<String> getCacheTagModifierNames();
//
// /**
// * Gets the cacheTagModifier with the given name, null if not found.
// *
// * @param cacheTagModifierName name of the CacheTagModifier we're looking for.
// *
// * @return the CacheTagModifier with the given name, null if not found.
// */
// CacheTagModifier getCacheTagModifier(String cacheTagModifierName);
//
// /**
// * Called once on application destroy.
// *
// */
// void destroy();
// }
|
import java.io.IOException;
import javax.servlet.ServletContext;
import javax.servlet.ServletRequest;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.jsp.JspContext;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.PageContext;
import javax.servlet.jsp.tagext.BodyContent;
import javax.servlet.jsp.tagext.BodyTagSupport;
import net.sf.ehcache.CacheManager;
import net.sf.ehcache.Ehcache;
import net.sf.ehcache.Element;
import nl.siegmann.ehcachetag.CacheTag.ModifierNotFoundException;
import nl.siegmann.ehcachetag.cachetagmodifier.CacheTagModifier;
import nl.siegmann.ehcachetag.cachetagmodifier.CacheTagModifierFactory;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
|
package nl.siegmann.ehcachetag;
public class CacheTagTest {
@Mock
private PageContext pageContext;
@Mock
private ServletContext servletContext;
@Mock
private JspWriter jspWriter = Mockito.mock(JspWriter.class);
@Mock
|
// Path: ehcachetag/src/main/java/nl/siegmann/ehcachetag/CacheTag.java
// static final class ModifierNotFoundException extends Exception {
//
// private static final long serialVersionUID = 4535024464306691589L;
//
// public ModifierNotFoundException(String message) {
// super(message);
// }
// }
//
// Path: ehcachetag/src/main/java/nl/siegmann/ehcachetag/cachetagmodifier/CacheTagModifier.java
// public interface CacheTagModifier {
//
// /**
// * CacheTagInterceptor that does not do anything.
// *
// */
// CacheTagModifier NULL_CACHETAG_MODIFIER = new CacheTagModifier() {
//
// @Override
// public void init(ServletContext servletContext) {
// }
//
// @Override
// public void beforeLookup(CacheTag cacheTag, JspContext jspContext) {
// }
//
// @Override
// public String afterRetrieval(CacheTag cacheTag, JspContext jspContext,
// String content) {
// return content;
// }
//
// @Override
// public void destroy() {
// }
//
// @Override
// public String beforeUpdate(CacheTag cacheTag, JspContext jspContext,
// String content) {
// return content;
// }
//
// };
//
// /**
// * Called once on Application startup.
// *
// * @param properties
// */
// void init(ServletContext servletContext);
//
// /**
// * Called before Cache lookup.
// *
// * Will be called by different threads concurrently.
// */
// void beforeLookup(CacheTag cacheTag, JspContext jspContext);
//
// /**
// * Called before updating the cache with the given content.
// *
// * @param cacheTag
// * @param jspContext
// * @param content the content that will be stored in the cache
// * @return the content to store in the cache.
// */
// String beforeUpdate(CacheTag cacheTag, JspContext jspContext, String content);
//
//
// /**
// * Called after retrieving content from the cache but before it's written to the output.
// *
// * @param cacheTag
// * @param jspContext
// * @param content the content that will be sent back to the client
// * @return The content to send back to the client
// */
// String afterRetrieval(CacheTag cacheTag, JspContext jspContext, String content);
//
// /**
// * Called on Application shutdown.
// */
// void destroy();
// }
//
// Path: ehcachetag/src/main/java/nl/siegmann/ehcachetag/cachetagmodifier/CacheTagModifierFactory.java
// public interface CacheTagModifierFactory {
//
// /**
// * Called once after application is initialized.
// *
// * @param servletContext
// */
// void init(ServletContext servletContext);
//
// /**
// * The names of the available cacheTagModifiers
// *
// * @return The names of the available cacheTagModifiers
// */
// Collection<String> getCacheTagModifierNames();
//
// /**
// * Gets the cacheTagModifier with the given name, null if not found.
// *
// * @param cacheTagModifierName name of the CacheTagModifier we're looking for.
// *
// * @return the CacheTagModifier with the given name, null if not found.
// */
// CacheTagModifier getCacheTagModifier(String cacheTagModifierName);
//
// /**
// * Called once on application destroy.
// *
// */
// void destroy();
// }
// Path: ehcachetag/src/test/java/nl/siegmann/ehcachetag/CacheTagTest.java
import java.io.IOException;
import javax.servlet.ServletContext;
import javax.servlet.ServletRequest;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.jsp.JspContext;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.PageContext;
import javax.servlet.jsp.tagext.BodyContent;
import javax.servlet.jsp.tagext.BodyTagSupport;
import net.sf.ehcache.CacheManager;
import net.sf.ehcache.Ehcache;
import net.sf.ehcache.Element;
import nl.siegmann.ehcachetag.CacheTag.ModifierNotFoundException;
import nl.siegmann.ehcachetag.cachetagmodifier.CacheTagModifier;
import nl.siegmann.ehcachetag.cachetagmodifier.CacheTagModifierFactory;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
package nl.siegmann.ehcachetag;
public class CacheTagTest {
@Mock
private PageContext pageContext;
@Mock
private ServletContext servletContext;
@Mock
private JspWriter jspWriter = Mockito.mock(JspWriter.class);
@Mock
|
private CacheTagModifierFactory cacheTagModifierFactory;
|
psiegman/ehcachetag
|
ehcachetag/src/test/java/nl/siegmann/ehcachetag/CacheTagTest.java
|
// Path: ehcachetag/src/main/java/nl/siegmann/ehcachetag/CacheTag.java
// static final class ModifierNotFoundException extends Exception {
//
// private static final long serialVersionUID = 4535024464306691589L;
//
// public ModifierNotFoundException(String message) {
// super(message);
// }
// }
//
// Path: ehcachetag/src/main/java/nl/siegmann/ehcachetag/cachetagmodifier/CacheTagModifier.java
// public interface CacheTagModifier {
//
// /**
// * CacheTagInterceptor that does not do anything.
// *
// */
// CacheTagModifier NULL_CACHETAG_MODIFIER = new CacheTagModifier() {
//
// @Override
// public void init(ServletContext servletContext) {
// }
//
// @Override
// public void beforeLookup(CacheTag cacheTag, JspContext jspContext) {
// }
//
// @Override
// public String afterRetrieval(CacheTag cacheTag, JspContext jspContext,
// String content) {
// return content;
// }
//
// @Override
// public void destroy() {
// }
//
// @Override
// public String beforeUpdate(CacheTag cacheTag, JspContext jspContext,
// String content) {
// return content;
// }
//
// };
//
// /**
// * Called once on Application startup.
// *
// * @param properties
// */
// void init(ServletContext servletContext);
//
// /**
// * Called before Cache lookup.
// *
// * Will be called by different threads concurrently.
// */
// void beforeLookup(CacheTag cacheTag, JspContext jspContext);
//
// /**
// * Called before updating the cache with the given content.
// *
// * @param cacheTag
// * @param jspContext
// * @param content the content that will be stored in the cache
// * @return the content to store in the cache.
// */
// String beforeUpdate(CacheTag cacheTag, JspContext jspContext, String content);
//
//
// /**
// * Called after retrieving content from the cache but before it's written to the output.
// *
// * @param cacheTag
// * @param jspContext
// * @param content the content that will be sent back to the client
// * @return The content to send back to the client
// */
// String afterRetrieval(CacheTag cacheTag, JspContext jspContext, String content);
//
// /**
// * Called on Application shutdown.
// */
// void destroy();
// }
//
// Path: ehcachetag/src/main/java/nl/siegmann/ehcachetag/cachetagmodifier/CacheTagModifierFactory.java
// public interface CacheTagModifierFactory {
//
// /**
// * Called once after application is initialized.
// *
// * @param servletContext
// */
// void init(ServletContext servletContext);
//
// /**
// * The names of the available cacheTagModifiers
// *
// * @return The names of the available cacheTagModifiers
// */
// Collection<String> getCacheTagModifierNames();
//
// /**
// * Gets the cacheTagModifier with the given name, null if not found.
// *
// * @param cacheTagModifierName name of the CacheTagModifier we're looking for.
// *
// * @return the CacheTagModifier with the given name, null if not found.
// */
// CacheTagModifier getCacheTagModifier(String cacheTagModifierName);
//
// /**
// * Called once on application destroy.
// *
// */
// void destroy();
// }
|
import java.io.IOException;
import javax.servlet.ServletContext;
import javax.servlet.ServletRequest;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.jsp.JspContext;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.PageContext;
import javax.servlet.jsp.tagext.BodyContent;
import javax.servlet.jsp.tagext.BodyTagSupport;
import net.sf.ehcache.CacheManager;
import net.sf.ehcache.Ehcache;
import net.sf.ehcache.Element;
import nl.siegmann.ehcachetag.CacheTag.ModifierNotFoundException;
import nl.siegmann.ehcachetag.cachetagmodifier.CacheTagModifier;
import nl.siegmann.ehcachetag.cachetagmodifier.CacheTagModifierFactory;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
|
package nl.siegmann.ehcachetag;
public class CacheTagTest {
@Mock
private PageContext pageContext;
@Mock
private ServletContext servletContext;
@Mock
private JspWriter jspWriter = Mockito.mock(JspWriter.class);
@Mock
private CacheTagModifierFactory cacheTagModifierFactory;
@Mock
|
// Path: ehcachetag/src/main/java/nl/siegmann/ehcachetag/CacheTag.java
// static final class ModifierNotFoundException extends Exception {
//
// private static final long serialVersionUID = 4535024464306691589L;
//
// public ModifierNotFoundException(String message) {
// super(message);
// }
// }
//
// Path: ehcachetag/src/main/java/nl/siegmann/ehcachetag/cachetagmodifier/CacheTagModifier.java
// public interface CacheTagModifier {
//
// /**
// * CacheTagInterceptor that does not do anything.
// *
// */
// CacheTagModifier NULL_CACHETAG_MODIFIER = new CacheTagModifier() {
//
// @Override
// public void init(ServletContext servletContext) {
// }
//
// @Override
// public void beforeLookup(CacheTag cacheTag, JspContext jspContext) {
// }
//
// @Override
// public String afterRetrieval(CacheTag cacheTag, JspContext jspContext,
// String content) {
// return content;
// }
//
// @Override
// public void destroy() {
// }
//
// @Override
// public String beforeUpdate(CacheTag cacheTag, JspContext jspContext,
// String content) {
// return content;
// }
//
// };
//
// /**
// * Called once on Application startup.
// *
// * @param properties
// */
// void init(ServletContext servletContext);
//
// /**
// * Called before Cache lookup.
// *
// * Will be called by different threads concurrently.
// */
// void beforeLookup(CacheTag cacheTag, JspContext jspContext);
//
// /**
// * Called before updating the cache with the given content.
// *
// * @param cacheTag
// * @param jspContext
// * @param content the content that will be stored in the cache
// * @return the content to store in the cache.
// */
// String beforeUpdate(CacheTag cacheTag, JspContext jspContext, String content);
//
//
// /**
// * Called after retrieving content from the cache but before it's written to the output.
// *
// * @param cacheTag
// * @param jspContext
// * @param content the content that will be sent back to the client
// * @return The content to send back to the client
// */
// String afterRetrieval(CacheTag cacheTag, JspContext jspContext, String content);
//
// /**
// * Called on Application shutdown.
// */
// void destroy();
// }
//
// Path: ehcachetag/src/main/java/nl/siegmann/ehcachetag/cachetagmodifier/CacheTagModifierFactory.java
// public interface CacheTagModifierFactory {
//
// /**
// * Called once after application is initialized.
// *
// * @param servletContext
// */
// void init(ServletContext servletContext);
//
// /**
// * The names of the available cacheTagModifiers
// *
// * @return The names of the available cacheTagModifiers
// */
// Collection<String> getCacheTagModifierNames();
//
// /**
// * Gets the cacheTagModifier with the given name, null if not found.
// *
// * @param cacheTagModifierName name of the CacheTagModifier we're looking for.
// *
// * @return the CacheTagModifier with the given name, null if not found.
// */
// CacheTagModifier getCacheTagModifier(String cacheTagModifierName);
//
// /**
// * Called once on application destroy.
// *
// */
// void destroy();
// }
// Path: ehcachetag/src/test/java/nl/siegmann/ehcachetag/CacheTagTest.java
import java.io.IOException;
import javax.servlet.ServletContext;
import javax.servlet.ServletRequest;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.jsp.JspContext;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.PageContext;
import javax.servlet.jsp.tagext.BodyContent;
import javax.servlet.jsp.tagext.BodyTagSupport;
import net.sf.ehcache.CacheManager;
import net.sf.ehcache.Ehcache;
import net.sf.ehcache.Element;
import nl.siegmann.ehcachetag.CacheTag.ModifierNotFoundException;
import nl.siegmann.ehcachetag.cachetagmodifier.CacheTagModifier;
import nl.siegmann.ehcachetag.cachetagmodifier.CacheTagModifierFactory;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
package nl.siegmann.ehcachetag;
public class CacheTagTest {
@Mock
private PageContext pageContext;
@Mock
private ServletContext servletContext;
@Mock
private JspWriter jspWriter = Mockito.mock(JspWriter.class);
@Mock
private CacheTagModifierFactory cacheTagModifierFactory;
@Mock
|
private CacheTagModifier cacheTagModifier;
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.