Skip to content

Commit bf4c042

Browse files
committed
Multiple fixes and removed call in constructor
1 parent 2665620 commit bf4c042

24 files changed

+156
-83
lines changed

.github/scripts/generate-quality-report.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -800,7 +800,6 @@ def main() -> None:
800800
"EI_EXPOSE_REP2",
801801
"EI_EXPOSE_STATIC_REP2",
802802
"EQ_COMPARETO_USE_OBJECT_EQUALS",
803-
"MC_OVERRIDABLE_METHOD_CALL_IN_CONSTRUCTOR",
804803
"MS_EXPOSE_REP",
805804
"NM_CONFUSING",
806805
"NO_NOTIFY_NOT_NOTIFYALL",

CodenameOne/src/com/codename1/impl/CodenameOneImplementation.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,9 @@ public void stopTextEditing() {
575575
*/
576576
public void stopTextEditing(Runnable onFinish) {
577577
stopTextEditing();
578-
onFinish.run();
578+
if(onFinish != null) {
579+
onFinish.run();
580+
}
579581
}
580582

581583
/**

CodenameOne/src/com/codename1/io/Oauth2.java

Lines changed: 31 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
*/
2424
package com.codename1.io;
2525

26+
import com.codename1.compat.java.util.Objects;
2627
import com.codename1.components.InfiniteProgress;
2728
import com.codename1.components.WebBrowser;
2829
import com.codename1.ui.BrowserWindow;
@@ -542,27 +543,20 @@ protected void handleException(Exception err) {
542543
}
543544
}
544545

545-
/**
546-
* {@inheritDoc}
547-
*/
548-
public boolean equals(Object o) {
549-
if (this == o) {
550-
return true;
551-
}
552-
if (o == null || getClass() != o.getClass()) {
553-
return false;
554-
}
555-
if (!super.equals(o)) {
556-
return false;
557-
}
558-
return true;
546+
@Override
547+
public final boolean equals(Object o) {
548+
if (!(o instanceof TokenRequest)) return false;
549+
if (!super.equals(o)) return false;
550+
551+
TokenRequest that = (TokenRequest) o;
552+
return callbackCalled == that.callbackCalled;
559553
}
560554

561-
/**
562-
* {@inheritDoc}
563-
*/
555+
@Override
564556
public int hashCode() {
565-
return super.hashCode();
557+
int result = super.hashCode();
558+
result = 31 * result + (callbackCalled ? 1 : 0);
559+
return result;
566560
}
567561

568562
protected void postResponse() {
@@ -660,7 +654,6 @@ private Hashtable getParamsFromURL(String url) {
660654
}
661655

662656
public static class RefreshTokenRequest extends AsyncResource<AccessToken> {
663-
664657
}
665658

666659
private static class RefreshTokenActionListener implements ActionListener<ActionEvent> {
@@ -692,6 +685,25 @@ public ShowAuthenticationCommand(Dialog progress, Form old) {
692685
this.old = old;
693686
}
694687

688+
@Override
689+
public boolean equals(Object obj) {
690+
if(obj instanceof ShowAuthenticationCommand) {
691+
ShowAuthenticationCommand c = (ShowAuthenticationCommand) obj;
692+
return super.equals(c) &&
693+
Objects.equals(progress, c.progress) &&
694+
Objects.equals(old, c.old);
695+
}
696+
return false;
697+
}
698+
699+
@Override
700+
public int hashCode() {
701+
int result = super.hashCode();
702+
result = 31 * result + (progress != null ? progress.hashCode() : 0);
703+
result = 31 * result + (old != null ? old.hashCode() : 0);
704+
return result;
705+
}
706+
695707
public void actionPerformed(ActionEvent ev) {
696708
if (Display.getInstance().getCurrent() == progress) {
697709
progress.dispose();

CodenameOne/src/com/codename1/share/ShareForm.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,22 @@ public BackCommand(Form contacts) {
116116
this.contacts = contacts;
117117
}
118118

119+
@Override
120+
public final boolean equals(Object o) {
121+
if (!(o instanceof BackCommand)) return false;
122+
if (!super.equals(o)) return false;
123+
124+
BackCommand that = (BackCommand) o;
125+
return (contacts == null ? that.contacts == null : contacts.equals(that.contacts));
126+
}
127+
128+
@Override
129+
public int hashCode() {
130+
int result = super.hashCode();
131+
result = 31 * result + (contacts != null ? contacts.hashCode() : 0);
132+
return result;
133+
}
134+
119135
public void actionPerformed(ActionEvent evt) {
120136
contacts.showBack();
121137
}

CodenameOne/src/com/codename1/social/FacebookConnect.java

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
import com.codename1.io.Oauth2;
3131
import com.codename1.util.Callback;
3232

33+
import java.util.Arrays;
34+
3335
/**
3436
* Invokes the native bundled facebook SDK to login/logout of facebook, notice
3537
* that in order for this to work server build arguments must indicate that you
@@ -42,7 +44,7 @@
4244
*/
4345
public class FacebookConnect extends Login {
4446

45-
static Class implClass;
47+
static Class<?> implClass;
4648
private static FacebookConnect instance;
4749
private final String[] permissions = new String[]{"public_profile", "email", "user_friends"};
4850

@@ -267,6 +269,22 @@ public ValidateTokenConnectionRequest(boolean[] retval) {
267269
this.retval = retval;
268270
}
269271

272+
@Override
273+
public final boolean equals(Object o) {
274+
if (!(o instanceof ValidateTokenConnectionRequest)) return false;
275+
if (!super.equals(o)) return false;
276+
277+
ValidateTokenConnectionRequest that = (ValidateTokenConnectionRequest) o;
278+
return Arrays.equals(retval, that.retval);
279+
}
280+
281+
@Override
282+
public int hashCode() {
283+
int result = super.hashCode();
284+
result = 31 * result + Arrays.hashCode(retval);
285+
return result;
286+
}
287+
270288
@Override
271289
protected void handleErrorResponseCode(int code, String message) {
272290
//access token not valid anymore

CodenameOne/src/com/codename1/social/GoogleConnect.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import com.codename1.io.NetworkManager;
2727
import com.codename1.io.Oauth2;
2828

29+
import java.util.Arrays;
2930
import java.util.Hashtable;
3031

3132
/**
@@ -115,6 +116,22 @@ public ValidateTokenConnectionRequest(boolean[] retval) {
115116
this.retval = retval;
116117
}
117118

119+
@Override
120+
public final boolean equals(Object o) {
121+
if (!(o instanceof ValidateTokenConnectionRequest)) return false;
122+
if (!super.equals(o)) return false;
123+
124+
ValidateTokenConnectionRequest that = (ValidateTokenConnectionRequest) o;
125+
return Arrays.equals(retval, that.retval);
126+
}
127+
128+
@Override
129+
public int hashCode() {
130+
int result = super.hashCode();
131+
result = 31 * result + Arrays.hashCode(retval);
132+
return result;
133+
}
134+
118135
@Override
119136
protected void handleErrorResponseCode(int code, String message) {
120137
//access token not valid anymore

CodenameOne/src/com/codename1/ui/Button.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1087,7 +1087,7 @@ public final boolean isCapsText() {
10871087
if (capsTextDefault) {
10881088
String uiid = getUIID();
10891089
return uiid.equals("Button") || uiid.equals("RaisedButton") ||
1090-
getUIManager().getThemeConstant("capsButtonUiids", "").indexOf(uiid) > -1;
1090+
super.getUIManager().getThemeConstant("capsButtonUiids", "").indexOf(uiid) > -1;
10911091
}
10921092
return false;
10931093
}

CodenameOne/src/com/codename1/ui/CommonProgressAnimations.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -259,9 +259,11 @@ public static class LoadingTextAnimation extends ProgressAnimation {
259259

260260

261261
public LoadingTextAnimation() {
262-
getStyle().setFgColor(0x666666);
263-
getStyle().setOpacity(0x66);
264-
$(this).setPaddingMillimeters(2f);
262+
Style s = getUnselectedStyle();
263+
s.setFgColor(0x666666);
264+
s.setOpacity(0x66);
265+
s.setPadding(2, 2, 2, 2);
266+
s.setPaddingUnit(Style.UNIT_TYPE_DIPS);
265267
}
266268

267269
/**

CodenameOne/src/com/codename1/ui/Component.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,7 @@ public class Component implements Animation, StyleListener, Editable {
510510
* Creates a new instance of Component
511511
*/
512512
protected Component() {
513-
initLaf(getUIManager());
513+
initLaf(getUIManagerImpl());
514514
setCursor(DEFAULT_CURSOR);
515515
}
516516

@@ -727,7 +727,7 @@ public Object getNativeOverlay() {
727727
*
728728
* <script src="https://gist.github.com/codenameone/31a32bdcf014a9e55a95.js"></script>
729729
*
730-
* @return a unified style object for the purpose of setting on object object instances
730+
* @return a unified style object to set values on all styles
731731
*/
732732
public final Style getAllStyles() {
733733
if (allStyles == null) {
@@ -1047,6 +1047,10 @@ private void initStyle() {
10471047
* @return a UIManager instance
10481048
*/
10491049
public UIManager getUIManager() {
1050+
return getUIManagerImpl();
1051+
}
1052+
1053+
private UIManager getUIManagerImpl() {
10501054
Container parent = getParent();
10511055
//if no parent return the default UIManager
10521056
if (parent == null) {
@@ -1695,7 +1699,7 @@ public void setSize(Dimension d) {
16951699
*
16961700
* @return unique string identifying this component for the style sheet
16971701
*/
1698-
public String getUIID() {
1702+
public final String getUIID() {
16991703
if (landscapeUiid != null) {
17001704
if (Display.impl.isPortrait()) {
17011705
return portraitUiid;
@@ -6043,7 +6047,7 @@ protected void initSelectedStyle(Style selectedStyle) {
60436047
*
60446048
* @return the component Style object
60456049
*/
6046-
public Style getUnselectedStyle() {
6050+
public final Style getUnselectedStyle() {
60476051
if (unSelectedStyle == null) {
60486052
initStyle();
60496053
}

CodenameOne/src/com/codename1/ui/Display.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1313,7 +1313,7 @@ void processSerialCalls() {
13131313
// after finishing an event cycle there might be serial calls waiting
13141314
// to return.
13151315
synchronized (lock) {
1316-
lock.notify();
1316+
lock.notifyAll();
13171317
}
13181318
}
13191319
processingSerialCalls = false;
@@ -1332,7 +1332,7 @@ boolean isProcessingSerialCalls() {
13321332

13331333
void notifyDisplay() {
13341334
synchronized (lock) {
1335-
lock.notify();
1335+
lock.notifyAll();
13361336
}
13371337
}
13381338

@@ -1621,7 +1621,7 @@ void setCurrent(final Form newForm, boolean reverse) {
16211621
}
16221622
}
16231623
synchronized (lock) {
1624-
lock.notify();
1624+
lock.notifyAll();
16251625
}
16261626

16271627
if (!transitionExists) {
@@ -1847,7 +1847,7 @@ private void addSingleArgumentEvent(int type, int code) {
18471847
inputEventStackPointer++;
18481848
inputEventStack[inputEventStackPointer] = code;
18491849
inputEventStackPointer++;
1850-
lock.notify();
1850+
lock.notifyAll();
18511851
}
18521852
}
18531853

@@ -1977,7 +1977,7 @@ private void addPointerEvent(int type, int x, int y) {
19771977
inputEventStackPointer++;
19781978
inputEventStack[inputEventStackPointer] = y;
19791979
inputEventStackPointer++;
1980-
lock.notify();
1980+
lock.notifyAll();
19811981
}
19821982
}
19831983

@@ -2000,7 +2000,7 @@ private void addPointerEvent(int type, int[] x, int[] y) {
20002000
inputEventStack[inputEventStackPointer] = y[iter];
20012001
inputEventStackPointer++;
20022002
}
2003-
lock.notify();
2003+
lock.notifyAll();
20042004
}
20052005
}
20062006

@@ -2029,7 +2029,7 @@ private void addPointerDragEventWithTimestamp(int x, int y) {
20292029
Log.p("EDT performance is very slow triggering this exception!");
20302030
Log.e(err);
20312031
}
2032-
lock.notify();
2032+
lock.notifyAll();
20332033
}
20342034
}
20352035

@@ -2051,7 +2051,7 @@ private void addPointerEventWithTimestamp(int type, int x, int y) {
20512051
Log.p("EDT performance is very slow triggering this exception!");
20522052
Log.e(err);
20532053
}
2054-
lock.notify();
2054+
lock.notifyAll();
20552055
}
20562056
}
20572057

@@ -2165,7 +2165,7 @@ private void addSizeChangeEvent(int type, int w, int h) {
21652165
inputEventStackPointer++;
21662166
inputEventStack[inputEventStackPointer] = h;
21672167
inputEventStackPointer++;
2168-
lock.notify();
2168+
lock.notifyAll();
21692169
}
21702170
}
21712171

@@ -2196,7 +2196,7 @@ private void addNotifyEvent(int type) {
21962196
synchronized (lock) {
21972197
inputEventStack[inputEventStackPointer] = type;
21982198
inputEventStackPointer++;
2199-
lock.notify();
2199+
lock.notifyAll();
22002200
}
22012201
}
22022202

0 commit comments

Comments
 (0)