Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions CodenameOne/src/com/codename1/components/ScaleImageLabel.java
Original file line number Diff line number Diff line change
Expand Up @@ -244,10 +244,9 @@ public int getPreferredH() {
}
if (preferredW > 0) {
Image i = getIcon();
if (i != null) {
if (preferredW < i.getWidth()) {
return (int)(i.getHeight() * preferredW / (double)i.getWidth());
}
// PMD Fix (CollapsibleIfStatements): Combine the nested icon and width checks into a single conditional.
if (i != null && preferredW < i.getWidth()) {
return (int)(i.getHeight() * preferredW / (double)i.getWidth());
}
}
return super.getPreferredH();
Expand All @@ -260,10 +259,9 @@ public int getPreferredW() {
}
if (preferredH > 0) {
Image i = getIcon();
if (i != null) {
if (preferredH < i.getHeight()) {
return (int)(i.getWidth() * preferredH / (double)i.getHeight());
}
// PMD Fix (CollapsibleIfStatements): Merge the icon nullity and height comparison into one condition.
if (i != null && preferredH < i.getHeight()) {
return (int)(i.getWidth() * preferredH / (double)i.getHeight());
}
}
return super.getPreferredW();
Expand Down
7 changes: 3 additions & 4 deletions CodenameOne/src/com/codename1/components/SliderBridge.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,9 @@ public static void bindProgress(final ConnectionRequest[] sources, final Slider
* {@inheritDoc}
*/
public void actionPerformed(ActionEvent evt) {
if(sources != null) {
if(!sourceVec.contains(evt.getSource())) {
return;
}
// PMD Fix (CollapsibleIfStatements): Collapse the nested source checks into one conditional.
if(sources != null && !sourceVec.contains(evt.getSource())) {
return;
}
NetworkEvent e = (NetworkEvent)evt;
switch(e.getProgressType()) {
Expand Down
44 changes: 21 additions & 23 deletions CodenameOne/src/com/codename1/components/SplitPane.java
Original file line number Diff line number Diff line change
Expand Up @@ -576,11 +576,6 @@ private Inset getMaxDividerInset() {
return getFixedInset(maxInset);
}

private void setDividerInset(String inset) {
getDividerInset().setValueAsString(inset);
clampInset();
}

private Inset getAutoInset(LayeredLayoutConstraint cnst) {
switch (orientation) {
case VERTICAL_SPLIT:
Expand Down Expand Up @@ -616,6 +611,7 @@ private LayeredLayoutConstraint initDividerInset(LayeredLayoutConstraint cnst, S



// PMD Fix (UnusedPrivateMethod): Removed unused setDividerInset helper.
private void clampInset() {

int px = getDividerInset().getAbsolutePixels(divider);
Expand Down Expand Up @@ -793,14 +789,14 @@ public void expand(boolean force) {
getFixedInset(preferredInset).copyTo(getDividerInset());
clampInset();
isCollapsed = false;
SplitPane.this.animateLayout(300);
} else if (isExpanded) {
// do nothing
} else {
// PMD Fix (UselessQualifiedThis): Call animateLayout directly within the class scope.
animateLayout(300);
} else if (!isExpanded) {
getFixedInset(maxInset).copyTo(getDividerInset());
clampInset();
isExpanded = true;
SplitPane.this.animateLayout(300);
// PMD Fix (UselessQualifiedThis): Call animateLayout directly within the class scope.
animateLayout(300);
}
}

Expand All @@ -817,20 +813,22 @@ public void collapse() {
* @param force True to force it to collapse to minimum position (skipping preferred position if it is in expanded state).
*/
public void collapse(boolean force) {
if (isCollapsed) {
// do nothing
} else if (isExpanded && !force) {
getFixedInset(preferredInset).copyTo(getDividerInset());
clampInset();
isExpanded = false;
SplitPane.this.animateLayout(300);
} else {
getFixedInset(minInset).copyTo(getDividerInset());
clampInset();
isCollapsed = true;
SplitPane.this.animateLayout(300);
if (!isCollapsed) {
if (isExpanded && !force) {
getFixedInset(preferredInset).copyTo(getDividerInset());
clampInset();
isExpanded = false;
// PMD Fix (UselessQualifiedThis): Call animateLayout directly within the class scope.
animateLayout(300);
} else {
getFixedInset(minInset).copyTo(getDividerInset());
clampInset();
isCollapsed = true;
// PMD Fix (UselessQualifiedThis): Call animateLayout directly within the class scope.
animateLayout(300);
}
}

}

/**
Expand Down
7 changes: 2 additions & 5 deletions CodenameOne/src/com/codename1/components/Switch.java
Original file line number Diff line number Diff line change
Expand Up @@ -772,8 +772,8 @@ public void actionPerformed(ActionEvent evt) {
}

}
// PMD Fix (UnnecessaryReturn): Removed redundant return at the end of the method.
animationLock = false;
return;
}
};

Expand Down Expand Up @@ -836,6 +836,7 @@ public void setValue(boolean value) {
setValue(value, false);
}

// PMD Fix (UnusedPrivateMethod): Removed the unused flip() helper and retained this setter as the single source of truth.
private void setValue(boolean value, boolean fireEvent) {
boolean orig = animationLock;
animationLock = true;
Expand All @@ -852,10 +853,6 @@ private void setValue(boolean value, boolean fireEvent) {
animationLock = orig;
}

private void flip() {
setValue(!value);
}

/**
* Checks if switch is in the "on" position.
* @return True if switch is on.
Expand Down
37 changes: 17 additions & 20 deletions CodenameOne/src/com/codename1/components/ToastBar.java
Original file line number Diff line number Diff line change
Expand Up @@ -840,26 +840,23 @@ private ToastBarComponent getToastBarComponent(boolean create) {
updateStatus();
}
Rectangle safeArea = Display.getInstance().getDisplaySafeArea(new Rectangle(0, 0, 0, 0));
if(position == Component.BOTTOM) {
if (f.getInvisibleAreaUnderVKB() > 0) {
Style s = c.getAllStyles();
s.setMarginUnit(Style.UNIT_TYPE_PIXELS);
s.setMarginBottom(f.getInvisibleAreaUnderVKB());
}
int safeBottomMargin = Display.getInstance().getDisplayHeight()
- safeArea.getY()
- safeArea.getHeight();
if (0 < safeBottomMargin) {
Style s = c.getAllStyles();
s.setPaddingUnit(Style.UNIT_TYPE_PIXELS);
s.setPaddingBottom(safeBottomMargin);
}
} else if (position == Component.TOP) {
if (safeArea.getY() > 0) {
Style s = c.getAllStyles();
s.setPaddingUnit(Style.UNIT_TYPE_PIXELS);
s.setPaddingTop(safeArea.getY());
}
// PMD Fix (CollapsibleIfStatements): Combine nested position checks to simplify the layout adjustments.
if(position == Component.BOTTOM && f.getInvisibleAreaUnderVKB() > 0) {
Style s = c.getAllStyles();
s.setMarginUnit(Style.UNIT_TYPE_PIXELS);
s.setMarginBottom(f.getInvisibleAreaUnderVKB());
}
int safeBottomMargin = Display.getInstance().getDisplayHeight()
- safeArea.getY()
- safeArea.getHeight();
if (position == Component.BOTTOM && safeBottomMargin > 0) {
Style s = c.getAllStyles();
s.setPaddingUnit(Style.UNIT_TYPE_PIXELS);
s.setPaddingBottom(safeBottomMargin);
} else if (position == Component.TOP && safeArea.getY() > 0) {
Style s = c.getAllStyles();
s.setPaddingUnit(Style.UNIT_TYPE_PIXELS);
s.setPaddingTop(safeArea.getY());
}

return c;
Expand Down
23 changes: 11 additions & 12 deletions CodenameOne/src/com/codename1/components/WebBrowser.java
Original file line number Diff line number Diff line change
Expand Up @@ -117,20 +117,19 @@ protected ConnectionRequest createConnectionRequest(final DocumentInfo docInfo,
return new ConnectionRequest() {

protected void buildRequestBody(OutputStream os) throws IOException {
if (isPost()) {
if (docInfo.getParams() != null) {
String enc = docInfo.getEncoding();
if(enc.indexOf('/') > -1) {
if(enc.indexOf("charset=") > -1) {
enc = enc.substring(enc.indexOf("charset=") + 8);
} else {
enc = DocumentInfo.ENCODING_UTF8;
}
// PMD Fix (CollapsibleIfStatements): Merge the post and parameter checks into a single conditional.
if (isPost() && docInfo.getParams() != null) {
String enc = docInfo.getEncoding();
if(enc.indexOf('/') > -1) {
if(enc.indexOf("charset=") > -1) {
enc = enc.substring(enc.indexOf("charset=") + 8);
} else {
enc = DocumentInfo.ENCODING_UTF8;
}
OutputStreamWriter w = new OutputStreamWriter(os, enc);
w.write(docInfo.getParams());
w.flush();
}
OutputStreamWriter w = new OutputStreamWriter(os, enc);
w.write(docInfo.getParams());
w.flush();
}
}

Expand Down
33 changes: 17 additions & 16 deletions CodenameOne/src/com/codename1/db/Cursor.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,21 +41,22 @@ public interface Cursor {

/**
* Move the cursor to the first row.
*
* If cursor provides forward-only navigation and is positioned after the
* first row then calling first() method would throw a IOException.
* @return true if succeeded
* @throws IOException
*
* If cursor provides forward-only navigation and is positioned after the
* first row then calling first() method would throw a IOException.
* @return true if succeeded
* @throws IOException
*/
public boolean first() throws IOException;
// PMD Fix (UnnecessaryModifier): Interface methods are implicitly public; remove redundant modifiers.
boolean first() throws IOException;

/**
* Move the cursor to the last row.
*
* @return true if succeeded
* @throws IOException
*/
public boolean last() throws IOException;
boolean last() throws IOException;

/**
* Moves the cursor to the next row.
Expand All @@ -64,7 +65,7 @@ public interface Cursor {
* @return true if succeeded
* @throws IOException
*/
public boolean next() throws IOException;
boolean next() throws IOException;

/**
* Moves the cursor to the previous row.
Expand All @@ -73,7 +74,7 @@ public interface Cursor {
* @return true if succeeded
* @throws IOException
*/
public boolean prev() throws IOException;
boolean prev() throws IOException;

/**
* Returns the zero-based index for a given column name.
Expand All @@ -84,7 +85,7 @@ public interface Cursor {
* @return the index of the column
* @throws IOException
*/
public int getColumnIndex(String columnName) throws IOException;
int getColumnIndex(String columnName) throws IOException;

/**
* Returns the column name at a given zero-based column index.
Expand All @@ -96,22 +97,22 @@ public interface Cursor {
*
* @throws IOException
*/
public String getColumnName(int columnIndex) throws IOException;
String getColumnName(int columnIndex) throws IOException;

/**
* Returns the column count
* @return the column count
* @throws IOException
*/
public int getColumnCount() throws IOException;
int getColumnCount() throws IOException;

/**
* Returns the current Cursor position.
*
* @return the cursor position
* @throws IOException
*/
public int getPosition() throws IOException;
int getPosition() throws IOException;

/**
* Move the cursor to an absolute row position
Expand All @@ -120,20 +121,20 @@ public interface Cursor {
* @return true if succeeded
* @throws IOException
*/
public boolean position(int row) throws IOException;
boolean position(int row) throws IOException;

/**
* Close the cursor and release its resources
* @throws IOException
*/
public void close() throws IOException;
void close() throws IOException;

/**
* Get the Row data Object.
*
* @return a Row Object
* @throws IOException
*/
public Row getRow() throws IOException;
Row getRow() throws IOException;

}
7 changes: 3 additions & 4 deletions CodenameOne/src/com/codename1/db/Database.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,9 @@ public static boolean isCustomPathSupported() {
}

private static void validateDatabaseNameArgument(String databaseName) {
if (!isCustomPathSupported()) {
if (databaseName.indexOf("/") != -1 || databaseName.indexOf("\\") != -1) {
throw new IllegalArgumentException("This platform does not support custom database paths. The database name cannot contain file separators.");
}
// PMD Fix (CollapsibleIfStatements): Merge the custom path support and separator checks into one condition.
if (!isCustomPathSupported() && (databaseName.indexOf("/") != -1 || databaseName.indexOf("\\") != -1)) {
throw new IllegalArgumentException("This platform does not support custom database paths. The database name cannot contain file separators.");
}
}

Expand Down
Loading
Loading