Skip to content

Commit

Permalink
Merge pull request haibuzou#6 from DevFactory/release/Multiple_Qualit…
Browse files Browse the repository at this point in the history
…y_Fixes_3

Fixing Multiple Quality Issues
  • Loading branch information
haibuzou committed May 22, 2016
2 parents beb36bf + 03dd30c commit 8856708
Show file tree
Hide file tree
Showing 6 changed files with 101 additions and 101 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public class DPCNCalendar extends DPCalendar {

private static final String SOLAR_TERM[][] = {{"小寒", "大寒"}, {"立春", "雨水"}, {"惊蛰", "春分"}, {"清明", "谷雨"}, {"立夏", "小满"}, {"芒种", "夏至"}, {"小暑", "大暑"}, {"立秋", "处暑"}, {"白露", "秋分"}, {"寒露", "霜降"}, {"立冬", "小雪"}, {"大雪", "冬至"}};

private final HashMap<Integer, String[][]> CACHE_SOLAR_TERM = new HashMap<>();
private final HashMap<Integer, String[][]> cacheSolarTerm = new HashMap<>();

private SolarTerm mSolarTerm = new SolarTerm();

Expand Down Expand Up @@ -130,7 +130,7 @@ private String[][] buildMonthL(int year, int month) {
L l = null;
String result = "";
if (year >= 1900 && year <= 2100) {
l = GTL(g);
l = gtl(g);
result = getFestivalL(l.m, l.d);
}
if (TextUtils.isEmpty(result)) {
Expand Down Expand Up @@ -186,10 +186,10 @@ public boolean isDeferred(int year, int month, int day) {
}

private String getSolarTerm(int year, int month, int day) {
String[][] tmp = CACHE_SOLAR_TERM.get(year);
String[][] tmp = cacheSolarTerm.get(year);
if (null == tmp) {
tmp = mSolarTerm.buildSolarTerm(year);
CACHE_SOLAR_TERM.put(year, tmp);
cacheSolarTerm.put(year, tmp);
}
String[] STOfMonth = tmp[month - 1];
if (Integer.valueOf(STOfMonth[0]) == day) {
Expand Down Expand Up @@ -222,7 +222,7 @@ private String getFestivalG(int month, int day) {
return tmp;
}

private L GTL(G g) {
private L gtl(G g) {
int index = g.y - DAYS_AND_LEAP_MONTH_OF_LUNAR[0];
int data = (g.y << 9) | (g.m << 5) | (g.d);
int lunarFirstDayInGregorian;
Expand All @@ -235,7 +235,7 @@ private L GTL(G g) {
int m = getBitInt(lunarFirstDayInGregorian, 4, 5);
int d = getBitInt(lunarFirstDayInGregorian, 5, 0);

long offset = GToNum(g.y, g.m, g.d) - GToNum(y, m, d);
long offset = gToNum(g.y, g.m, g.d) - gToNum(y, m, d);
int days = FIRST_DAY_OF_LUNAR_IN_GREGORIAN[index];
int leap = getBitInt(days, 4, 13);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public abstract class DPCalendar {
* @return true表示闰年
*/
public boolean isLeapYear(int year) {
return (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0));
return ((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0);
}

/**
Expand Down Expand Up @@ -130,7 +130,7 @@ public Set<String> buildMonthWeekend(int year, int month) {
return set;
}

protected long GToNum(int year, int month, int day) {
protected long gToNum(int year, int month, int day) {
month = (month + 9) % 12;
year = year - month / 10;
return 365 * year + year / 4 - year / 100 + year / 400 + (month * 306 + 5) / 10 + (day - 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ final class SolarTerm {

private static final double[] dts = {-4000, 108371.7, -13036.80, 392.000, 0.0000, -500, 17201.0, -627.82, 16.170, -0.3413, -150, 12200.6, -346.41, 5.403, -0.1593, 150, 9113.8, -328.13, -1.647, 0.0377, 500, 5707.5, -391.41, 0.915, 0.3145, 900, 2203.4, -283.45, 13.034, -0.1778, 1300, 490.1, -57.35, 2.085, -0.0072, 1600, 120.0, -9.81, -1.532, 0.1403, 1700, 10.2, -0.91, 0.510, -0.0370, 1800, 13.4, -0.72, 0.202, -0.0193, 1830, 7.8, -1.81, 0.416, -0.0247, 1860, 8.3, -0.13, -0.406, 0.0292, 1880, -5.4, 0.32, -0.183, 0.0173, 1900, -2.3, 2.06, 0.169, -0.0135, 1920, 21.2, 1.69, -0.304, 0.0167, 1940, 24.2, 1.22, -0.064, 0.0031, 1960, 33.2, 0.51, 0.231, -0.0109, 1980, 51.0, 1.29, -0.026, 0.0032, 2000, 64.7, -1.66, 5.224, -0.2905, 2150, 279.4, 732.95, 429.579, 0.0158, 6000};

private double EnnT = 0;
private double MnnT = 0;
private double enNT = 0;
private double mnNT = 0;

private double D = 1;

Expand All @@ -95,7 +95,7 @@ String[][] buildSolarTerm(int year) {
double jd = 365.2422 * (year - 2000), q;
int j;
for (int i = 0; i < tmp.length; i++) {
j = (i - 5);
j = i - 5;
q = angleCal(jd + j * 15.2, j * 15, 0);
q = q + J2000 + (double) 8 / 24;
setFromJD(q, true);
Expand Down Expand Up @@ -197,12 +197,12 @@ private double jiaoCai(int lx, double t, double jiao) {
}

private double[] moonCal(double jd) {
MnnT = jd / 36525;
double t1 = MnnT, t2 = t1 * t1, t3 = t2 * t1, t4 = t3 * t1;
mnNT = jd / 36525;
double t1 = mnNT, t2 = t1 * t1, t3 = t2 * t1, t4 = t3 * t1;
double[] llr = new double[3];
llr[0] = (Mnn(M10) + Mnn(M11) * t1 + Mnn(M12) * t2) / rad;
llr[1] = (Mnn(M20) + Mnn(M21) * t1) / rad;
llr[2] = (Mnn(M30) + Mnn(M31) * t1) * 0.999999949827;
llr[0] = (mnn(M10) + mnn(M11) * t1 + mnn(M12) * t2) / rad;
llr[1] = (mnn(M20) + mnn(M21) * t1) / rad;
llr[2] = (mnn(M30) + mnn(M31) * t1) * 0.999999949827;
llr[0] = llr[0] + M1n[0] + M1n[1] * t1 + M1n[2] * t2 + M1n[3] * t3 + M1n[4] * t4;
llr[0] = rad2mrad(llr[0]);
addPrece(jd, llr);
Expand All @@ -219,8 +219,8 @@ private void addPrece(double jd, double[] zb) {
zb[0] = rad2mrad(zb[0] + (v + 2.9965 * t1) / rad);
}

private double Mnn(double[] F) {
double v = 0, t1 = MnnT, t2 = t1 * t1, t3 = t2 * t1, t4 = t3 * t1;
private double mnn(double[] F) {
double v = 0, t1 = mnNT, t2 = t1 * t1, t3 = t2 * t1, t4 = t3 * t1;
for (int i = 0; i < F.length; i += 6)
v += F[i] * Math.sin(F[i + 1] + t1 * F[i + 2] + t2 * F[i + 3] + t3 * F[i + 4] + t4 * F[i + 5]);
return v;
Expand Down Expand Up @@ -257,12 +257,12 @@ private void addGxc(double t, double[] zb) {
}

private double[] earCal(double jd) {
EnnT = jd / 365250;
enNT = jd / 365250;
double llr[] = new double[3];
double t1 = EnnT, t2 = t1 * t1, t3 = t2 * t1, t4 = t3 * t1, t5 = t4 * t1;
llr[0] = Enn(E10) + Enn(E11) * t1 + Enn(E12) * t2 + Enn(E13) * t3 + Enn(E14) * t4 + Enn(E15) * t5;
llr[1] = Enn(E20) + Enn(E21) * t1;
llr[2] = Enn(E30) + Enn(E31) * t1 + Enn(E32) * t2 + Enn(E33) * t3;
double t1 = enNT, t2 = t1 * t1, t3 = t2 * t1, t4 = t3 * t1, t5 = t4 * t1;
llr[0] = enn(E10) + enn(E11) * t1 + enn(E12) * t2 + enn(E13) * t3 + enn(E14) * t4 + enn(E15) * t5;
llr[1] = enn(E20) + enn(E21) * t1;
llr[2] = enn(E30) + enn(E31) * t1 + enn(E32) * t2 + enn(E33) * t3;
llr[0] = rad2mrad(llr[0]);
return llr;
}
Expand All @@ -274,10 +274,10 @@ private double rad2mrad(double v) {
return v;
}

private double Enn(double[] F) {
private double enn(double[] F) {
double v = 0;
for (int i = 0; i < F.length; i += 3)
v += F[i] * Math.cos(F[i + 1] + EnnT * F[i + 2]);
v += F[i] * Math.cos(F[i + 1] + enNT * F[i + 2]);
return v;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,15 @@
* @author AigeStudio 2015-06-29
*/
public class MonthView extends View {
private final Region[][] MONTH_REGIONS_4 = new Region[4][7];
private final Region[][] MONTH_REGIONS_5 = new Region[5][7];
private final Region[][] MONTH_REGIONS_6 = new Region[6][7];
private final Region[][] monthRegionsFour = new Region[4][7];
private final Region[][] monthRegionsFive = new Region[5][7];
private final Region[][] monthRegionsSix = new Region[6][7];

private final DPInfo[][] INFO_4 = new DPInfo[4][7];
private final DPInfo[][] INFO_5 = new DPInfo[5][7];
private final DPInfo[][] INFO_6 = new DPInfo[6][7];
private final DPInfo[][] infoFour = new DPInfo[4][7];
private final DPInfo[][] infoFive = new DPInfo[5][7];
private final DPInfo[][] infoSix = new DPInfo[6][7];

private final Map<String, List<Region>> REGION_SELECTED = new HashMap<>();
private final Map<String, List<Region>> regionSelected = new HashMap<>();

private DPCManager mCManager = DPCManager.getInstance();
private DPTManager mTManager = DPTManager.getInstance();
Expand Down Expand Up @@ -312,28 +312,28 @@ protected void onSizeChanged(int w, int h, int oldW, int oldH) {
+ heightFestival / 2F + heightGregorian / 2F) / 2F;
offsetYFestival2 = offsetYFestival1 * 2F;

for (int i = 0; i < MONTH_REGIONS_4.length; i++) {
for (int j = 0; j < MONTH_REGIONS_4[i].length; j++) {
for (int i = 0; i < monthRegionsFour.length; i++) {
for (int j = 0; j < monthRegionsFour[i].length; j++) {
Region region = new Region();
region.set((j * cellW), (i * cellH4), cellW + (j * cellW),
region.set(j * cellW, i * cellH4, cellW + (j * cellW),
cellW + (i * cellH4));
MONTH_REGIONS_4[i][j] = region;
monthRegionsFour[i][j] = region;
}
}
for (int i = 0; i < MONTH_REGIONS_5.length; i++) {
for (int j = 0; j < MONTH_REGIONS_5[i].length; j++) {
for (int i = 0; i < monthRegionsFive.length; i++) {
for (int j = 0; j < monthRegionsFive[i].length; j++) {
Region region = new Region();
region.set((j * cellW), (i * cellH5), cellW + (j * cellW),
region.set(j * cellW, i * cellH5, cellW + (j * cellW),
cellW + (i * cellH5));
MONTH_REGIONS_5[i][j] = region;
monthRegionsFive[i][j] = region;
}
}
for (int i = 0; i < MONTH_REGIONS_6.length; i++) {
for (int j = 0; j < MONTH_REGIONS_6[i].length; j++) {
for (int i = 0; i < monthRegionsSix.length; i++) {
for (int j = 0; j < monthRegionsSix[i].length; j++) {
Region region = new Region();
region.set((j * cellW), (i * cellH6), cellW + (j * cellW),
cellW + (i * cellH6));
MONTH_REGIONS_6[i][j] = region;
monthRegionsSix[i][j] = region;
}
}
}
Expand Down Expand Up @@ -388,17 +388,17 @@ private void draw(Canvas canvas, int x, int y, int year, int month) {
DPInfo[][] result;
Region[][] tmp;
if (TextUtils.isEmpty(info[4][0].strG)) {
tmp = MONTH_REGIONS_4;
arrayClear(INFO_4);
result = arrayCopy(info, INFO_4);
tmp = monthRegionsFour;
arrayClear(infoFour);
result = arrayCopy(info, infoFour);
} else if (TextUtils.isEmpty(info[5][0].strG)) {
tmp = MONTH_REGIONS_5;
arrayClear(INFO_5);
result = arrayCopy(info, INFO_5);
tmp = monthRegionsFive;
arrayClear(infoFive);
result = arrayCopy(info, infoFive);
} else {
tmp = MONTH_REGIONS_6;
arrayClear(INFO_6);
result = arrayCopy(info, INFO_6);
tmp = monthRegionsSix;
arrayClear(infoSix);
result = arrayCopy(info, infoSix);
}
for (int i = 0; i < result.length; i++) {
for (int j = 0; j < result[i].length; j++) {
Expand Down Expand Up @@ -680,8 +680,8 @@ private BGCircle createCircle(float x, float y) {

private void buildRegion() {
String key = indexYear + ":" + indexMonth;
if (!REGION_SELECTED.containsKey(key)) {
REGION_SELECTED.put(key, new ArrayList<Region>());
if (!regionSelected.containsKey(key)) {
regionSelected.put(key, new ArrayList<Region>());
}
}

Expand All @@ -703,11 +703,11 @@ public void defineRegion(final int x, final int y) {
DPInfo[][] info = mCManager.obtainDPInfo(centerYear, centerMonth);
Region[][] tmp;
if (TextUtils.isEmpty(info[4][0].strG)) {
tmp = MONTH_REGIONS_4;
tmp = monthRegionsFour;
} else if (TextUtils.isEmpty(info[5][0].strG)) {
tmp = MONTH_REGIONS_5;
tmp = monthRegionsFive;
} else {
tmp = MONTH_REGIONS_6;
tmp = monthRegionsSix;
}
for (int i = 0; i < tmp.length; i++) {
for (int j = 0; j < tmp[i].length; j++) {
Expand All @@ -717,7 +717,7 @@ public void defineRegion(final int x, final int y) {
continue;
}
if (region.contains(x, y)) {
List<Region> regions = REGION_SELECTED.get(indexYear + ":"
List<Region> regions = regionSelected.get(indexYear + ":"
+ indexMonth);
if (mDPMode == DPMode.SINGLE) {
cirApr.clear();
Expand Down Expand Up @@ -873,11 +873,11 @@ public void changeChooseDate(int x, int y) {
DPInfo[][] info = mCManager.obtainDPInfo(centerYear, centerMonth);
Region[][] tmp;
if (TextUtils.isEmpty(info[4][0].strG)) {
tmp = MONTH_REGIONS_4;
tmp = monthRegionsFour;
} else if (TextUtils.isEmpty(info[5][0].strG)) {
tmp = MONTH_REGIONS_5;
tmp = monthRegionsFive;
} else {
tmp = MONTH_REGIONS_6;
tmp = monthRegionsSix;
}
for (int i = 0; i < tmp.length; i++) {
for (int j = 0; j < tmp[i].length; j++) {
Expand All @@ -887,7 +887,7 @@ public void changeChooseDate(int x, int y) {
continue;
}
if (region.contains(x, y)) {
List<Region> regions = REGION_SELECTED.get(indexYear + ":"
List<Region> regions = regionSelected.get(indexYear + ":"
+ indexMonth);
if (mDPMode == DPMode.SINGLE) {
cirApr.clear();
Expand Down
Loading

0 comments on commit 8856708

Please sign in to comment.