checkstyle: enable OneTopLevelClass

The only remaining error was ClipboardCompat, which was unnecessarily
exposing three top-level classes. Make the two implementation classes be
nested, private and static.
This commit is contained in:
Daniel Martí 2016-05-05 11:02:26 +01:00
parent 6311ad5c6b
commit 78af79cd4f
2 changed files with 26 additions and 27 deletions

View File

@ -17,34 +17,33 @@ public abstract class ClipboardCompat {
return new OldClipboard(); return new OldClipboard();
} }
} @TargetApi(11)
private static class HoneycombClipboard extends ClipboardCompat {
@TargetApi(11) private final ClipboardManager manager;
class HoneycombClipboard extends ClipboardCompat {
private final ClipboardManager manager; HoneycombClipboard(Context context) {
this.manager = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
HoneycombClipboard(Context context) { }
this.manager = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
} @Override
public String getText() {
@Override CharSequence text = null;
public String getText() { if (manager.hasPrimaryClip()) {
CharSequence text = null; ClipData data = manager.getPrimaryClip();
if (manager.hasPrimaryClip()) { if (data.getItemCount() > 0) {
ClipData data = manager.getPrimaryClip(); text = data.getItemAt(0).getText();
if (data.getItemCount() > 0) { }
text = data.getItemAt(0).getText(); }
} return text != null ? text.toString() : null;
}
}
private static class OldClipboard extends ClipboardCompat {
@Override
public String getText() {
return null;
} }
return text != null ? text.toString() : null;
}
}
class OldClipboard extends ClipboardCompat {
@Override
public String getText() {
return null;
} }
} }

View File

@ -62,7 +62,7 @@
</module> </module>
<module name="NoLineWrap"/> <module name="NoLineWrap"/>
<!--<module name="OneTopLevelClass" />--> <module name="OneTopLevelClass" />
<module name="OneStatementPerLine" /> <module name="OneStatementPerLine" />
<module name="EmptyBlock"> <module name="EmptyBlock">