id
int32 0
165k
| repo
stringlengths 7
58
| path
stringlengths 12
218
| func_name
stringlengths 3
140
| original_string
stringlengths 73
34.1k
| language
stringclasses 1
value | code
stringlengths 73
34.1k
| code_tokens
list | docstring
stringlengths 3
16k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 105
339
|
|---|---|---|---|---|---|---|---|---|---|---|---|
144,600
|
comapi/comapi-sdk-android
|
COMAPI/foundation/src/main/java/com/comapi/internal/log/AppenderFile.java
|
AppenderFile.rollOverFiles
|
private void rollOverFiles() {
Context context = appContextRef.get();
if (context != null) {
File dir = context.getFilesDir();
File mainFile = new File(dir, name(1));
if (mainFile.exists()) {
float fileSize = mainFile.length();
fileSize = fileSize / 1024.0f; //In kilobytes
if (fileSize > fileSizeLimitKb) {
File file;
File target;
file = new File(dir, name(maxFiles));
if (file.exists()) {
file.delete();
}
for (int i = maxFiles - 1; i > 0; i--) {
file = new File(dir, name(i));
if (file.exists()) {
target = new File(dir, name(i + 1));
file.renameTo(target);
}
}
}
}
}
}
|
java
|
private void rollOverFiles() {
Context context = appContextRef.get();
if (context != null) {
File dir = context.getFilesDir();
File mainFile = new File(dir, name(1));
if (mainFile.exists()) {
float fileSize = mainFile.length();
fileSize = fileSize / 1024.0f; //In kilobytes
if (fileSize > fileSizeLimitKb) {
File file;
File target;
file = new File(dir, name(maxFiles));
if (file.exists()) {
file.delete();
}
for (int i = maxFiles - 1; i > 0; i--) {
file = new File(dir, name(i));
if (file.exists()) {
target = new File(dir, name(i + 1));
file.renameTo(target);
}
}
}
}
}
}
|
[
"private",
"void",
"rollOverFiles",
"(",
")",
"{",
"Context",
"context",
"=",
"appContextRef",
".",
"get",
"(",
")",
";",
"if",
"(",
"context",
"!=",
"null",
")",
"{",
"File",
"dir",
"=",
"context",
".",
"getFilesDir",
"(",
")",
";",
"File",
"mainFile",
"=",
"new",
"File",
"(",
"dir",
",",
"name",
"(",
"1",
")",
")",
";",
"if",
"(",
"mainFile",
".",
"exists",
"(",
")",
")",
"{",
"float",
"fileSize",
"=",
"mainFile",
".",
"length",
"(",
")",
";",
"fileSize",
"=",
"fileSize",
"/",
"1024.0f",
";",
"//In kilobytes",
"if",
"(",
"fileSize",
">",
"fileSizeLimitKb",
")",
"{",
"File",
"file",
";",
"File",
"target",
";",
"file",
"=",
"new",
"File",
"(",
"dir",
",",
"name",
"(",
"maxFiles",
")",
")",
";",
"if",
"(",
"file",
".",
"exists",
"(",
")",
")",
"{",
"file",
".",
"delete",
"(",
")",
";",
"}",
"for",
"(",
"int",
"i",
"=",
"maxFiles",
"-",
"1",
";",
"i",
">",
"0",
";",
"i",
"--",
")",
"{",
"file",
"=",
"new",
"File",
"(",
"dir",
",",
"name",
"(",
"i",
")",
")",
";",
"if",
"(",
"file",
".",
"exists",
"(",
")",
")",
"{",
"target",
"=",
"new",
"File",
"(",
"dir",
",",
"name",
"(",
"i",
"+",
"1",
")",
")",
";",
"file",
".",
"renameTo",
"(",
"target",
")",
";",
"}",
"}",
"}",
"}",
"}",
"}"
] |
Keep the maximum size of log files close to maximum value.
Logs are cached if the size of the currently used log file exceeds max value.
|
[
"Keep",
"the",
"maximum",
"size",
"of",
"log",
"files",
"close",
"to",
"maximum",
"value",
".",
"Logs",
"are",
"cached",
"if",
"the",
"size",
"of",
"the",
"currently",
"used",
"log",
"file",
"exceeds",
"max",
"value",
"."
] |
53140a58d5a62afe196047ccc5120bfe090ef211
|
https://github.com/comapi/comapi-sdk-android/blob/53140a58d5a62afe196047ccc5120bfe090ef211/COMAPI/foundation/src/main/java/com/comapi/internal/log/AppenderFile.java#L162-L197
|
144,601
|
comapi/comapi-sdk-android
|
COMAPI/foundation/src/main/java/com/comapi/internal/log/AppenderFile.java
|
AppenderFile.loadLogsObservable
|
private Observable<String> loadLogsObservable() {
return Observable.fromCallable(() -> {
StringBuilder sb = new StringBuilder();
Context context = appContextRef.get();
if (context != null) {
synchronized (sharedLock) {
try {
File dir = context.getFilesDir();
String line;
for (int i = 1; i <= maxFiles; i++) {
File file = new File(dir, name(i));
if (file.exists()) {
inputStream = new FileInputStream(file);
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
while ((line = reader.readLine()) != null) {
sb.append(line).append('\n');
}
reader.close();
}
}
} catch (Exception e) {
throw Exceptions.propagate(e);
} finally {
sharedLock.notifyAll();
}
}
}
return sb.toString();
});
}
|
java
|
private Observable<String> loadLogsObservable() {
return Observable.fromCallable(() -> {
StringBuilder sb = new StringBuilder();
Context context = appContextRef.get();
if (context != null) {
synchronized (sharedLock) {
try {
File dir = context.getFilesDir();
String line;
for (int i = 1; i <= maxFiles; i++) {
File file = new File(dir, name(i));
if (file.exists()) {
inputStream = new FileInputStream(file);
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
while ((line = reader.readLine()) != null) {
sb.append(line).append('\n');
}
reader.close();
}
}
} catch (Exception e) {
throw Exceptions.propagate(e);
} finally {
sharedLock.notifyAll();
}
}
}
return sb.toString();
});
}
|
[
"private",
"Observable",
"<",
"String",
">",
"loadLogsObservable",
"(",
")",
"{",
"return",
"Observable",
".",
"fromCallable",
"(",
"(",
")",
"->",
"{",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"Context",
"context",
"=",
"appContextRef",
".",
"get",
"(",
")",
";",
"if",
"(",
"context",
"!=",
"null",
")",
"{",
"synchronized",
"(",
"sharedLock",
")",
"{",
"try",
"{",
"File",
"dir",
"=",
"context",
".",
"getFilesDir",
"(",
")",
";",
"String",
"line",
";",
"for",
"(",
"int",
"i",
"=",
"1",
";",
"i",
"<=",
"maxFiles",
";",
"i",
"++",
")",
"{",
"File",
"file",
"=",
"new",
"File",
"(",
"dir",
",",
"name",
"(",
"i",
")",
")",
";",
"if",
"(",
"file",
".",
"exists",
"(",
")",
")",
"{",
"inputStream",
"=",
"new",
"FileInputStream",
"(",
"file",
")",
";",
"BufferedReader",
"reader",
"=",
"new",
"BufferedReader",
"(",
"new",
"InputStreamReader",
"(",
"inputStream",
")",
")",
";",
"while",
"(",
"(",
"line",
"=",
"reader",
".",
"readLine",
"(",
")",
")",
"!=",
"null",
")",
"{",
"sb",
".",
"append",
"(",
"line",
")",
".",
"append",
"(",
"'",
"'",
")",
";",
"}",
"reader",
".",
"close",
"(",
")",
";",
"}",
"}",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"Exceptions",
".",
"propagate",
"(",
"e",
")",
";",
"}",
"finally",
"{",
"sharedLock",
".",
"notifyAll",
"(",
")",
";",
"}",
"}",
"}",
"return",
"sb",
".",
"toString",
"(",
")",
";",
"}",
")",
";",
"}"
] |
Gets rx observable that reads the log files and appends to string.
@return Observable that reads the log files and appends to string.
|
[
"Gets",
"rx",
"observable",
"that",
"reads",
"the",
"log",
"files",
"and",
"appends",
"to",
"string",
"."
] |
53140a58d5a62afe196047ccc5120bfe090ef211
|
https://github.com/comapi/comapi-sdk-android/blob/53140a58d5a62afe196047ccc5120bfe090ef211/COMAPI/foundation/src/main/java/com/comapi/internal/log/AppenderFile.java#L214-L255
|
144,602
|
javagl/CommonUI
|
src/main/java/de/javagl/common/ui/JScrollPanes.java
|
JScrollPanes.createVerticalScrollPane
|
public static JScrollPane createVerticalScrollPane(
final JComponent component)
{
JScrollPane scrollPane = new JScrollPane(component)
{
/**
* Serial UID
*/
private static final long serialVersionUID = -177913025197077320L;
@Override
public Dimension getPreferredSize()
{
Dimension d = super.getPreferredSize();
if (super.isPreferredSizeSet())
{
return d;
}
JScrollBar scrollBar = getVerticalScrollBar();
Dimension sd = scrollBar.getPreferredSize();
d.width += sd.width;
return d;
}
@Override
public boolean isValidateRoot()
{
return false;
}
};
return scrollPane;
}
|
java
|
public static JScrollPane createVerticalScrollPane(
final JComponent component)
{
JScrollPane scrollPane = new JScrollPane(component)
{
/**
* Serial UID
*/
private static final long serialVersionUID = -177913025197077320L;
@Override
public Dimension getPreferredSize()
{
Dimension d = super.getPreferredSize();
if (super.isPreferredSizeSet())
{
return d;
}
JScrollBar scrollBar = getVerticalScrollBar();
Dimension sd = scrollBar.getPreferredSize();
d.width += sd.width;
return d;
}
@Override
public boolean isValidateRoot()
{
return false;
}
};
return scrollPane;
}
|
[
"public",
"static",
"JScrollPane",
"createVerticalScrollPane",
"(",
"final",
"JComponent",
"component",
")",
"{",
"JScrollPane",
"scrollPane",
"=",
"new",
"JScrollPane",
"(",
"component",
")",
"{",
"/**\r\n * Serial UID\r\n */",
"private",
"static",
"final",
"long",
"serialVersionUID",
"=",
"-",
"177913025197077320L",
";",
"@",
"Override",
"public",
"Dimension",
"getPreferredSize",
"(",
")",
"{",
"Dimension",
"d",
"=",
"super",
".",
"getPreferredSize",
"(",
")",
";",
"if",
"(",
"super",
".",
"isPreferredSizeSet",
"(",
")",
")",
"{",
"return",
"d",
";",
"}",
"JScrollBar",
"scrollBar",
"=",
"getVerticalScrollBar",
"(",
")",
";",
"Dimension",
"sd",
"=",
"scrollBar",
".",
"getPreferredSize",
"(",
")",
";",
"d",
".",
"width",
"+=",
"sd",
".",
"width",
";",
"return",
"d",
";",
"}",
"@",
"Override",
"public",
"boolean",
"isValidateRoot",
"(",
")",
"{",
"return",
"false",
";",
"}",
"}",
";",
"return",
"scrollPane",
";",
"}"
] |
Creates a JScrollPane for vertically scrolling the given component.
The scroll pane will take into account that the vertical scroll bar
will be shown when needed, and return a preferred size that takes
the width of this scroll bar into account, so that when the vertical
scroll bar appears, the contained component can still have its
preferred width.
@param component The view component
@return The scroll pane
|
[
"Creates",
"a",
"JScrollPane",
"for",
"vertically",
"scrolling",
"the",
"given",
"component",
".",
"The",
"scroll",
"pane",
"will",
"take",
"into",
"account",
"that",
"the",
"vertical",
"scroll",
"bar",
"will",
"be",
"shown",
"when",
"needed",
"and",
"return",
"a",
"preferred",
"size",
"that",
"takes",
"the",
"width",
"of",
"this",
"scroll",
"bar",
"into",
"account",
"so",
"that",
"when",
"the",
"vertical",
"scroll",
"bar",
"appears",
"the",
"contained",
"component",
"can",
"still",
"have",
"its",
"preferred",
"width",
"."
] |
b2c7a7637d4e288271392ba148dc17e4c9780255
|
https://github.com/javagl/CommonUI/blob/b2c7a7637d4e288271392ba148dc17e4c9780255/src/main/java/de/javagl/common/ui/JScrollPanes.java#L51-L82
|
144,603
|
blackdoor/blackdoor
|
src/main/java/black/door/struct/SortedArrayList.java
|
SortedArrayList.addSorted
|
public boolean addSorted(E element) {
boolean added = false;
added = super.add(element);
Comparable<E> cmp = (Comparable<E>) element;
for (int i = size() - 1; i > 0 && cmp.compareTo(get(i - 1)) < 0; i--)
Collections.swap(this, i, i - 1);
return added;
}
|
java
|
public boolean addSorted(E element) {
boolean added = false;
added = super.add(element);
Comparable<E> cmp = (Comparable<E>) element;
for (int i = size() - 1; i > 0 && cmp.compareTo(get(i - 1)) < 0; i--)
Collections.swap(this, i, i - 1);
return added;
}
|
[
"public",
"boolean",
"addSorted",
"(",
"E",
"element",
")",
"{",
"boolean",
"added",
"=",
"false",
";",
"added",
"=",
"super",
".",
"add",
"(",
"element",
")",
";",
"Comparable",
"<",
"E",
">",
"cmp",
"=",
"(",
"Comparable",
"<",
"E",
">",
")",
"element",
";",
"for",
"(",
"int",
"i",
"=",
"size",
"(",
")",
"-",
"1",
";",
"i",
">",
"0",
"&&",
"cmp",
".",
"compareTo",
"(",
"get",
"(",
"i",
"-",
"1",
")",
")",
"<",
"0",
";",
"i",
"--",
")",
"Collections",
".",
"swap",
"(",
"this",
",",
"i",
",",
"i",
"-",
"1",
")",
";",
"return",
"added",
";",
"}"
] |
adds an element to the list in its place based on natural order. allows duplicates.
@param element
element to be appended to this list
@return true if this collection changed as a result of the call
|
[
"adds",
"an",
"element",
"to",
"the",
"list",
"in",
"its",
"place",
"based",
"on",
"natural",
"order",
".",
"allows",
"duplicates",
"."
] |
060c7a71dfafb85e10e8717736e6d3160262e96b
|
https://github.com/blackdoor/blackdoor/blob/060c7a71dfafb85e10e8717736e6d3160262e96b/src/main/java/black/door/struct/SortedArrayList.java#L26-L33
|
144,604
|
blackdoor/blackdoor
|
src/main/java/black/door/struct/SortedArrayList.java
|
SortedArrayList.addSorted
|
public boolean addSorted(E element, boolean allowDuplicates) {
boolean added = false;
if(!allowDuplicates){
if(this.contains(element)){
System.err.println("item is a duplicate");
return added;
}}
added = super.add(element);
Comparable<E> cmp = (Comparable<E>) element;
for (int i = size() - 1; i > 0 && cmp.compareTo(get(i - 1)) < 0; i--)
Collections.swap(this, i, i - 1);
return added;
}
|
java
|
public boolean addSorted(E element, boolean allowDuplicates) {
boolean added = false;
if(!allowDuplicates){
if(this.contains(element)){
System.err.println("item is a duplicate");
return added;
}}
added = super.add(element);
Comparable<E> cmp = (Comparable<E>) element;
for (int i = size() - 1; i > 0 && cmp.compareTo(get(i - 1)) < 0; i--)
Collections.swap(this, i, i - 1);
return added;
}
|
[
"public",
"boolean",
"addSorted",
"(",
"E",
"element",
",",
"boolean",
"allowDuplicates",
")",
"{",
"boolean",
"added",
"=",
"false",
";",
"if",
"(",
"!",
"allowDuplicates",
")",
"{",
"if",
"(",
"this",
".",
"contains",
"(",
"element",
")",
")",
"{",
"System",
".",
"err",
".",
"println",
"(",
"\"item is a duplicate\"",
")",
";",
"return",
"added",
";",
"}",
"}",
"added",
"=",
"super",
".",
"add",
"(",
"element",
")",
";",
"Comparable",
"<",
"E",
">",
"cmp",
"=",
"(",
"Comparable",
"<",
"E",
">",
")",
"element",
";",
"for",
"(",
"int",
"i",
"=",
"size",
"(",
")",
"-",
"1",
";",
"i",
">",
"0",
"&&",
"cmp",
".",
"compareTo",
"(",
"get",
"(",
"i",
"-",
"1",
")",
")",
"<",
"0",
";",
"i",
"--",
")",
"Collections",
".",
"swap",
"(",
"this",
",",
"i",
",",
"i",
"-",
"1",
")",
";",
"return",
"added",
";",
"}"
] |
adds an element to the list in its place based on natural order.
@param element
element to be appended to this list
@param allowDuplicates if true will allow multiple of the same item to be added, else returns false.
@return true if this collection changed as a result of the call
|
[
"adds",
"an",
"element",
"to",
"the",
"list",
"in",
"its",
"place",
"based",
"on",
"natural",
"order",
"."
] |
060c7a71dfafb85e10e8717736e6d3160262e96b
|
https://github.com/blackdoor/blackdoor/blob/060c7a71dfafb85e10e8717736e6d3160262e96b/src/main/java/black/door/struct/SortedArrayList.java#L43-L55
|
144,605
|
javagl/CommonUI
|
src/main/java/de/javagl/common/ui/LocationBasedPopupHandler.java
|
LocationBasedPopupHandler.prepareMenu
|
private void prepareMenu(Container menu, Component component, int x, int y)
{
int n = menu.getComponentCount();
for (int i=0; i<n; i++)
{
Component menuComponent = popupMenu.getComponent(i);
if (menuComponent instanceof JMenu)
{
JMenu subMenu = (JMenu)menuComponent;
prepareMenu(subMenu, component, x, y);
}
if (menuComponent instanceof AbstractButton)
{
AbstractButton abstractButton = (AbstractButton)menuComponent;
Action action = abstractButton.getAction();
if (action != null && action instanceof LocationBasedAction)
{
LocationBasedAction locationBasedAction =
(LocationBasedAction)action;
locationBasedAction.prepareShow(component, x, y);
}
}
}
}
|
java
|
private void prepareMenu(Container menu, Component component, int x, int y)
{
int n = menu.getComponentCount();
for (int i=0; i<n; i++)
{
Component menuComponent = popupMenu.getComponent(i);
if (menuComponent instanceof JMenu)
{
JMenu subMenu = (JMenu)menuComponent;
prepareMenu(subMenu, component, x, y);
}
if (menuComponent instanceof AbstractButton)
{
AbstractButton abstractButton = (AbstractButton)menuComponent;
Action action = abstractButton.getAction();
if (action != null && action instanceof LocationBasedAction)
{
LocationBasedAction locationBasedAction =
(LocationBasedAction)action;
locationBasedAction.prepareShow(component, x, y);
}
}
}
}
|
[
"private",
"void",
"prepareMenu",
"(",
"Container",
"menu",
",",
"Component",
"component",
",",
"int",
"x",
",",
"int",
"y",
")",
"{",
"int",
"n",
"=",
"menu",
".",
"getComponentCount",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"n",
";",
"i",
"++",
")",
"{",
"Component",
"menuComponent",
"=",
"popupMenu",
".",
"getComponent",
"(",
"i",
")",
";",
"if",
"(",
"menuComponent",
"instanceof",
"JMenu",
")",
"{",
"JMenu",
"subMenu",
"=",
"(",
"JMenu",
")",
"menuComponent",
";",
"prepareMenu",
"(",
"subMenu",
",",
"component",
",",
"x",
",",
"y",
")",
";",
"}",
"if",
"(",
"menuComponent",
"instanceof",
"AbstractButton",
")",
"{",
"AbstractButton",
"abstractButton",
"=",
"(",
"AbstractButton",
")",
"menuComponent",
";",
"Action",
"action",
"=",
"abstractButton",
".",
"getAction",
"(",
")",
";",
"if",
"(",
"action",
"!=",
"null",
"&&",
"action",
"instanceof",
"LocationBasedAction",
")",
"{",
"LocationBasedAction",
"locationBasedAction",
"=",
"(",
"LocationBasedAction",
")",
"action",
";",
"locationBasedAction",
".",
"prepareShow",
"(",
"component",
",",
"x",
",",
"y",
")",
";",
"}",
"}",
"}",
"}"
] |
Prepare the given menu recursively with the given parameters
@param menu The menu
@param component The component
@param x The x-coordinate
@param y THe y-coordinate
|
[
"Prepare",
"the",
"given",
"menu",
"recursively",
"with",
"the",
"given",
"parameters"
] |
b2c7a7637d4e288271392ba148dc17e4c9780255
|
https://github.com/javagl/CommonUI/blob/b2c7a7637d4e288271392ba148dc17e4c9780255/src/main/java/de/javagl/common/ui/LocationBasedPopupHandler.java#L102-L125
|
144,606
|
javagl/CommonUI
|
src/main/java/de/javagl/common/ui/table/CustomizedTableHeader.java
|
CustomizedTableHeader.removeColumn
|
private void removeColumn(int index)
{
TableColumn column = tableColumns.get(index);
column.removePropertyChangeListener(widthListener);
tableColumns.remove(index);
JComponent component = customComponents.remove(index);
remove(component);
if (componentRemover != null)
{
componentRemover.accept(index);
}
}
|
java
|
private void removeColumn(int index)
{
TableColumn column = tableColumns.get(index);
column.removePropertyChangeListener(widthListener);
tableColumns.remove(index);
JComponent component = customComponents.remove(index);
remove(component);
if (componentRemover != null)
{
componentRemover.accept(index);
}
}
|
[
"private",
"void",
"removeColumn",
"(",
"int",
"index",
")",
"{",
"TableColumn",
"column",
"=",
"tableColumns",
".",
"get",
"(",
"index",
")",
";",
"column",
".",
"removePropertyChangeListener",
"(",
"widthListener",
")",
";",
"tableColumns",
".",
"remove",
"(",
"index",
")",
";",
"JComponent",
"component",
"=",
"customComponents",
".",
"remove",
"(",
"index",
")",
";",
"remove",
"(",
"component",
")",
";",
"if",
"(",
"componentRemover",
"!=",
"null",
")",
"{",
"componentRemover",
".",
"accept",
"(",
"index",
")",
";",
"}",
"}"
] |
Remove the column and the custom component at the given index
@param index The index
|
[
"Remove",
"the",
"column",
"and",
"the",
"custom",
"component",
"at",
"the",
"given",
"index"
] |
b2c7a7637d4e288271392ba148dc17e4c9780255
|
https://github.com/javagl/CommonUI/blob/b2c7a7637d4e288271392ba148dc17e4c9780255/src/main/java/de/javagl/common/ui/table/CustomizedTableHeader.java#L242-L253
|
144,607
|
javagl/CommonUI
|
src/main/java/de/javagl/common/ui/table/CustomizedTableHeader.java
|
CustomizedTableHeader.addColumn
|
private void addColumn(int index)
{
TableColumnModel columnModel = getColumnModel();
TableColumn column = columnModel.getColumn(index);
while (tableColumns.size() - 1 < index)
{
tableColumns.add(null);
}
tableColumns.set(index, column);
column.addPropertyChangeListener(widthListener);
JComponent component = componentFactory.apply(index);
while (customComponents.size() - 1 < index)
{
customComponents.add(null);
}
customComponents.set(index, component);
add(component);
}
|
java
|
private void addColumn(int index)
{
TableColumnModel columnModel = getColumnModel();
TableColumn column = columnModel.getColumn(index);
while (tableColumns.size() - 1 < index)
{
tableColumns.add(null);
}
tableColumns.set(index, column);
column.addPropertyChangeListener(widthListener);
JComponent component = componentFactory.apply(index);
while (customComponents.size() - 1 < index)
{
customComponents.add(null);
}
customComponents.set(index, component);
add(component);
}
|
[
"private",
"void",
"addColumn",
"(",
"int",
"index",
")",
"{",
"TableColumnModel",
"columnModel",
"=",
"getColumnModel",
"(",
")",
";",
"TableColumn",
"column",
"=",
"columnModel",
".",
"getColumn",
"(",
"index",
")",
";",
"while",
"(",
"tableColumns",
".",
"size",
"(",
")",
"-",
"1",
"<",
"index",
")",
"{",
"tableColumns",
".",
"add",
"(",
"null",
")",
";",
"}",
"tableColumns",
".",
"set",
"(",
"index",
",",
"column",
")",
";",
"column",
".",
"addPropertyChangeListener",
"(",
"widthListener",
")",
";",
"JComponent",
"component",
"=",
"componentFactory",
".",
"apply",
"(",
"index",
")",
";",
"while",
"(",
"customComponents",
".",
"size",
"(",
")",
"-",
"1",
"<",
"index",
")",
"{",
"customComponents",
".",
"add",
"(",
"null",
")",
";",
"}",
"customComponents",
".",
"set",
"(",
"index",
",",
"component",
")",
";",
"add",
"(",
"component",
")",
";",
"}"
] |
Add the column and the custom component at the given index
@param index The index
|
[
"Add",
"the",
"column",
"and",
"the",
"custom",
"component",
"at",
"the",
"given",
"index"
] |
b2c7a7637d4e288271392ba148dc17e4c9780255
|
https://github.com/javagl/CommonUI/blob/b2c7a7637d4e288271392ba148dc17e4c9780255/src/main/java/de/javagl/common/ui/table/CustomizedTableHeader.java#L260-L278
|
144,608
|
javagl/CommonUI
|
src/main/java/de/javagl/common/ui/table/CustomizedTableHeader.java
|
CustomizedTableHeader.updateCustomComponentBounds
|
private void updateCustomComponentBounds()
{
if (customComponents == null)
{
return;
}
if (table == null)
{
return;
}
for (int i = 0; i < customComponents.size(); i++)
{
JComponent component = customComponents.get(i);
Rectangle rect = getHeaderRect(i);
rect.height = customComponentHeight;
component.setBounds(rect);
}
revalidate();
}
|
java
|
private void updateCustomComponentBounds()
{
if (customComponents == null)
{
return;
}
if (table == null)
{
return;
}
for (int i = 0; i < customComponents.size(); i++)
{
JComponent component = customComponents.get(i);
Rectangle rect = getHeaderRect(i);
rect.height = customComponentHeight;
component.setBounds(rect);
}
revalidate();
}
|
[
"private",
"void",
"updateCustomComponentBounds",
"(",
")",
"{",
"if",
"(",
"customComponents",
"==",
"null",
")",
"{",
"return",
";",
"}",
"if",
"(",
"table",
"==",
"null",
")",
"{",
"return",
";",
"}",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"customComponents",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"JComponent",
"component",
"=",
"customComponents",
".",
"get",
"(",
"i",
")",
";",
"Rectangle",
"rect",
"=",
"getHeaderRect",
"(",
"i",
")",
";",
"rect",
".",
"height",
"=",
"customComponentHeight",
";",
"component",
".",
"setBounds",
"(",
"rect",
")",
";",
"}",
"revalidate",
"(",
")",
";",
"}"
] |
Update the bounds of all custom components, based on the current
column widths
|
[
"Update",
"the",
"bounds",
"of",
"all",
"custom",
"components",
"based",
"on",
"the",
"current",
"column",
"widths"
] |
b2c7a7637d4e288271392ba148dc17e4c9780255
|
https://github.com/javagl/CommonUI/blob/b2c7a7637d4e288271392ba148dc17e4c9780255/src/main/java/de/javagl/common/ui/table/CustomizedTableHeader.java#L284-L302
|
144,609
|
comapi/comapi-sdk-android
|
COMAPI/foundation/src/main/java/com/comapi/BaseClient.java
|
BaseClient.initialiseLifecycleObserver
|
private void initialiseLifecycleObserver(Application application) {
LifeCycleController.registerLifeCycleObserver(application, new LifecycleListener() {
@Override
public void onForegrounded(Context context) {
for (LifecycleListener listener : lifecycleListeners) {
listener.onForegrounded(context);
}
}
@Override
public void onBackgrounded(Context context) {
for (LifecycleListener listener : lifecycleListeners) {
listener.onBackgrounded(context);
}
}
});
}
|
java
|
private void initialiseLifecycleObserver(Application application) {
LifeCycleController.registerLifeCycleObserver(application, new LifecycleListener() {
@Override
public void onForegrounded(Context context) {
for (LifecycleListener listener : lifecycleListeners) {
listener.onForegrounded(context);
}
}
@Override
public void onBackgrounded(Context context) {
for (LifecycleListener listener : lifecycleListeners) {
listener.onBackgrounded(context);
}
}
});
}
|
[
"private",
"void",
"initialiseLifecycleObserver",
"(",
"Application",
"application",
")",
"{",
"LifeCycleController",
".",
"registerLifeCycleObserver",
"(",
"application",
",",
"new",
"LifecycleListener",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"onForegrounded",
"(",
"Context",
"context",
")",
"{",
"for",
"(",
"LifecycleListener",
"listener",
":",
"lifecycleListeners",
")",
"{",
"listener",
".",
"onForegrounded",
"(",
"context",
")",
";",
"}",
"}",
"@",
"Override",
"public",
"void",
"onBackgrounded",
"(",
"Context",
"context",
")",
"{",
"for",
"(",
"LifecycleListener",
"listener",
":",
"lifecycleListeners",
")",
"{",
"listener",
".",
"onBackgrounded",
"(",
"context",
")",
";",
"}",
"}",
"}",
")",
";",
"}"
] |
Register for application lifecycle callbacks.
@param application Application instance.
|
[
"Register",
"for",
"application",
"lifecycle",
"callbacks",
"."
] |
53140a58d5a62afe196047ccc5120bfe090ef211
|
https://github.com/comapi/comapi-sdk-android/blob/53140a58d5a62afe196047ccc5120bfe090ef211/COMAPI/foundation/src/main/java/com/comapi/BaseClient.java#L242-L258
|
144,610
|
comapi/comapi-sdk-android
|
COMAPI/foundation/src/main/java/com/comapi/BaseClient.java
|
BaseClient.getSession
|
@Override
public Session getSession() {
return state.get() > GlobalState.INITIALISING ? new Session(dataMgr.getSessionDAO().session()) : new Session();
}
|
java
|
@Override
public Session getSession() {
return state.get() > GlobalState.INITIALISING ? new Session(dataMgr.getSessionDAO().session()) : new Session();
}
|
[
"@",
"Override",
"public",
"Session",
"getSession",
"(",
")",
"{",
"return",
"state",
".",
"get",
"(",
")",
">",
"GlobalState",
".",
"INITIALISING",
"?",
"new",
"Session",
"(",
"dataMgr",
".",
"getSessionDAO",
"(",
")",
".",
"session",
"(",
")",
")",
":",
"new",
"Session",
"(",
")",
";",
"}"
] |
Gets the active session data.
@return Active session data.
|
[
"Gets",
"the",
"active",
"session",
"data",
"."
] |
53140a58d5a62afe196047ccc5120bfe090ef211
|
https://github.com/comapi/comapi-sdk-android/blob/53140a58d5a62afe196047ccc5120bfe090ef211/COMAPI/foundation/src/main/java/com/comapi/BaseClient.java#L275-L278
|
144,611
|
comapi/comapi-sdk-android
|
COMAPI/foundation/src/main/java/com/comapi/BaseClient.java
|
BaseClient.loadSession
|
private Observable<SessionData> loadSession(final Boolean initialised) {
if (initialised) {
final SessionData session = dataMgr.getSessionDAO().session();
if (session != null) {
if (session.getExpiresOn() > System.currentTimeMillis()) {
state.compareAndSet(GlobalState.INITIALISED, GlobalState.SESSION_ACTIVE);
} else {
state.compareAndSet(GlobalState.INITIALISED, GlobalState.SESSION_OFF);
return service.reAuthenticate().onErrorReturn(throwable -> {
log.w("Authentication failure during init.");
return session;
});
}
}
return Observable.create(sub -> {
sub.onNext(session);
sub.onCompleted();
});
}
return Observable.just(null);
}
|
java
|
private Observable<SessionData> loadSession(final Boolean initialised) {
if (initialised) {
final SessionData session = dataMgr.getSessionDAO().session();
if (session != null) {
if (session.getExpiresOn() > System.currentTimeMillis()) {
state.compareAndSet(GlobalState.INITIALISED, GlobalState.SESSION_ACTIVE);
} else {
state.compareAndSet(GlobalState.INITIALISED, GlobalState.SESSION_OFF);
return service.reAuthenticate().onErrorReturn(throwable -> {
log.w("Authentication failure during init.");
return session;
});
}
}
return Observable.create(sub -> {
sub.onNext(session);
sub.onCompleted();
});
}
return Observable.just(null);
}
|
[
"private",
"Observable",
"<",
"SessionData",
">",
"loadSession",
"(",
"final",
"Boolean",
"initialised",
")",
"{",
"if",
"(",
"initialised",
")",
"{",
"final",
"SessionData",
"session",
"=",
"dataMgr",
".",
"getSessionDAO",
"(",
")",
".",
"session",
"(",
")",
";",
"if",
"(",
"session",
"!=",
"null",
")",
"{",
"if",
"(",
"session",
".",
"getExpiresOn",
"(",
")",
">",
"System",
".",
"currentTimeMillis",
"(",
")",
")",
"{",
"state",
".",
"compareAndSet",
"(",
"GlobalState",
".",
"INITIALISED",
",",
"GlobalState",
".",
"SESSION_ACTIVE",
")",
";",
"}",
"else",
"{",
"state",
".",
"compareAndSet",
"(",
"GlobalState",
".",
"INITIALISED",
",",
"GlobalState",
".",
"SESSION_OFF",
")",
";",
"return",
"service",
".",
"reAuthenticate",
"(",
")",
".",
"onErrorReturn",
"(",
"throwable",
"->",
"{",
"log",
".",
"w",
"(",
"\"Authentication failure during init.\"",
")",
";",
"return",
"session",
";",
"}",
")",
";",
"}",
"}",
"return",
"Observable",
".",
"create",
"(",
"sub",
"->",
"{",
"sub",
".",
"onNext",
"(",
"session",
")",
";",
"sub",
".",
"onCompleted",
"(",
")",
";",
"}",
")",
";",
"}",
"return",
"Observable",
".",
"just",
"(",
"null",
")",
";",
"}"
] |
Loads local session state.
@return Returns local session state.
|
[
"Loads",
"local",
"session",
"state",
"."
] |
53140a58d5a62afe196047ccc5120bfe090ef211
|
https://github.com/comapi/comapi-sdk-android/blob/53140a58d5a62afe196047ccc5120bfe090ef211/COMAPI/foundation/src/main/java/com/comapi/BaseClient.java#L310-L334
|
144,612
|
sebastiangraf/perfidix
|
src/main/java/org/perfidix/AbstractConfig.java
|
AbstractConfig.getMeters
|
public final AbstractMeter[] getMeters() {
final AbstractMeter[] returnVal = new AbstractMeter[meters.length];
System.arraycopy(meters, 0, returnVal, 0, returnVal.length);
return returnVal;
}
|
java
|
public final AbstractMeter[] getMeters() {
final AbstractMeter[] returnVal = new AbstractMeter[meters.length];
System.arraycopy(meters, 0, returnVal, 0, returnVal.length);
return returnVal;
}
|
[
"public",
"final",
"AbstractMeter",
"[",
"]",
"getMeters",
"(",
")",
"{",
"final",
"AbstractMeter",
"[",
"]",
"returnVal",
"=",
"new",
"AbstractMeter",
"[",
"meters",
".",
"length",
"]",
";",
"System",
".",
"arraycopy",
"(",
"meters",
",",
"0",
",",
"returnVal",
",",
"0",
",",
"returnVal",
".",
"length",
")",
";",
"return",
"returnVal",
";",
"}"
] |
Getter for member meters
@return the meters
|
[
"Getter",
"for",
"member",
"meters"
] |
f13aa793b6a3055215ed4edbb946c1bb5d564886
|
https://github.com/sebastiangraf/perfidix/blob/f13aa793b6a3055215ed4edbb946c1bb5d564886/src/main/java/org/perfidix/AbstractConfig.java#L129-L133
|
144,613
|
sebastiangraf/perfidix
|
src/main/java/org/perfidix/AbstractConfig.java
|
AbstractConfig.getListener
|
public final AbstractOutput[] getListener() {
final AbstractOutput[] returnVal = new AbstractOutput[listeners.length];
System.arraycopy(listeners, 0, returnVal, 0, returnVal.length);
return returnVal;
}
|
java
|
public final AbstractOutput[] getListener() {
final AbstractOutput[] returnVal = new AbstractOutput[listeners.length];
System.arraycopy(listeners, 0, returnVal, 0, returnVal.length);
return returnVal;
}
|
[
"public",
"final",
"AbstractOutput",
"[",
"]",
"getListener",
"(",
")",
"{",
"final",
"AbstractOutput",
"[",
"]",
"returnVal",
"=",
"new",
"AbstractOutput",
"[",
"listeners",
".",
"length",
"]",
";",
"System",
".",
"arraycopy",
"(",
"listeners",
",",
"0",
",",
"returnVal",
",",
"0",
",",
"returnVal",
".",
"length",
")",
";",
"return",
"returnVal",
";",
"}"
] |
Getter for member listeners
@return the listeners
|
[
"Getter",
"for",
"member",
"listeners"
] |
f13aa793b6a3055215ed4edbb946c1bb5d564886
|
https://github.com/sebastiangraf/perfidix/blob/f13aa793b6a3055215ed4edbb946c1bb5d564886/src/main/java/org/perfidix/AbstractConfig.java#L158-L162
|
144,614
|
comapi/comapi-sdk-android
|
COMAPI/foundation/src/main/java/com/comapi/internal/CallbackAdapter.java
|
CallbackAdapter.adapt
|
public <T> void adapt(@NonNull final Observable<T> subscriber, @Nullable final Callback<T> callback) {
subscriber.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Subscriber<T>() {
@Override
public void onCompleted() {
}
@Override
public void onError(Throwable e) {
if (callback != null) {
callback.error(e);
}
}
@Override
public void onNext(T result) {
if (callback != null) {
callback.success(result);
}
}
});
}
|
java
|
public <T> void adapt(@NonNull final Observable<T> subscriber, @Nullable final Callback<T> callback) {
subscriber.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Subscriber<T>() {
@Override
public void onCompleted() {
}
@Override
public void onError(Throwable e) {
if (callback != null) {
callback.error(e);
}
}
@Override
public void onNext(T result) {
if (callback != null) {
callback.success(result);
}
}
});
}
|
[
"public",
"<",
"T",
">",
"void",
"adapt",
"(",
"@",
"NonNull",
"final",
"Observable",
"<",
"T",
">",
"subscriber",
",",
"@",
"Nullable",
"final",
"Callback",
"<",
"T",
">",
"callback",
")",
"{",
"subscriber",
".",
"subscribeOn",
"(",
"Schedulers",
".",
"io",
"(",
")",
")",
".",
"observeOn",
"(",
"AndroidSchedulers",
".",
"mainThread",
"(",
")",
")",
".",
"subscribe",
"(",
"new",
"Subscriber",
"<",
"T",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"onCompleted",
"(",
")",
"{",
"}",
"@",
"Override",
"public",
"void",
"onError",
"(",
"Throwable",
"e",
")",
"{",
"if",
"(",
"callback",
"!=",
"null",
")",
"{",
"callback",
".",
"error",
"(",
"e",
")",
";",
"}",
"}",
"@",
"Override",
"public",
"void",
"onNext",
"(",
"T",
"result",
")",
"{",
"if",
"(",
"callback",
"!=",
"null",
")",
"{",
"callback",
".",
"success",
"(",
"result",
")",
";",
"}",
"}",
"}",
")",
";",
"}"
] |
Changes observables into callbacks.
@param subscriber Observable to subscribe to.
@param callback Callback where onError and onNext from Observable will be delivered
@param <T> Class of the result.
|
[
"Changes",
"observables",
"into",
"callbacks",
"."
] |
53140a58d5a62afe196047ccc5120bfe090ef211
|
https://github.com/comapi/comapi-sdk-android/blob/53140a58d5a62afe196047ccc5120bfe090ef211/COMAPI/foundation/src/main/java/com/comapi/internal/CallbackAdapter.java#L49-L73
|
144,615
|
javagl/CommonUI
|
src/main/java/de/javagl/common/ui/tree/checkbox/CheckBoxTree.java
|
CheckBoxTree.setSelectionStateOfAll
|
private void setSelectionStateOfAll(State state)
{
Objects.requireNonNull(state, "The state may not be null");
List<Object> allNodes = JTrees.getAllNodes(getModel());
for (Object node : allNodes)
{
setSelectionState(node, state);
}
}
|
java
|
private void setSelectionStateOfAll(State state)
{
Objects.requireNonNull(state, "The state may not be null");
List<Object> allNodes = JTrees.getAllNodes(getModel());
for (Object node : allNodes)
{
setSelectionState(node, state);
}
}
|
[
"private",
"void",
"setSelectionStateOfAll",
"(",
"State",
"state",
")",
"{",
"Objects",
".",
"requireNonNull",
"(",
"state",
",",
"\"The state may not be null\"",
")",
";",
"List",
"<",
"Object",
">",
"allNodes",
"=",
"JTrees",
".",
"getAllNodes",
"(",
"getModel",
"(",
")",
")",
";",
"for",
"(",
"Object",
"node",
":",
"allNodes",
")",
"{",
"setSelectionState",
"(",
"node",
",",
"state",
")",
";",
"}",
"}"
] |
Set the selection state of all nodes to the given state
@param state The state
|
[
"Set",
"the",
"selection",
"state",
"of",
"all",
"nodes",
"to",
"the",
"given",
"state"
] |
b2c7a7637d4e288271392ba148dc17e4c9780255
|
https://github.com/javagl/CommonUI/blob/b2c7a7637d4e288271392ba148dc17e4c9780255/src/main/java/de/javagl/common/ui/tree/checkbox/CheckBoxTree.java#L227-L235
|
144,616
|
javagl/CommonUI
|
src/main/java/de/javagl/common/ui/tree/checkbox/CheckBoxTree.java
|
CheckBoxTree.setSelectionState
|
private void setSelectionState(Object node, State state, boolean propagate)
{
Objects.requireNonNull(state, "The state may not be null");
Objects.requireNonNull(node, "The node may not be null");
State oldState = selectionStates.put(node, state);
if (!state.equals(oldState))
{
fireStateChanged(node, oldState, state);
if (propagate)
{
updateSelection(node);
}
}
repaint();
}
|
java
|
private void setSelectionState(Object node, State state, boolean propagate)
{
Objects.requireNonNull(state, "The state may not be null");
Objects.requireNonNull(node, "The node may not be null");
State oldState = selectionStates.put(node, state);
if (!state.equals(oldState))
{
fireStateChanged(node, oldState, state);
if (propagate)
{
updateSelection(node);
}
}
repaint();
}
|
[
"private",
"void",
"setSelectionState",
"(",
"Object",
"node",
",",
"State",
"state",
",",
"boolean",
"propagate",
")",
"{",
"Objects",
".",
"requireNonNull",
"(",
"state",
",",
"\"The state may not be null\"",
")",
";",
"Objects",
".",
"requireNonNull",
"(",
"node",
",",
"\"The node may not be null\"",
")",
";",
"State",
"oldState",
"=",
"selectionStates",
".",
"put",
"(",
"node",
",",
"state",
")",
";",
"if",
"(",
"!",
"state",
".",
"equals",
"(",
"oldState",
")",
")",
"{",
"fireStateChanged",
"(",
"node",
",",
"oldState",
",",
"state",
")",
";",
"if",
"(",
"propagate",
")",
"{",
"updateSelection",
"(",
"node",
")",
";",
"}",
"}",
"repaint",
"(",
")",
";",
"}"
] |
Set the selection state of the given node
@param node The node
@param state The state
@param propagate Whether the state change should be propagated
to its children and ancestor nodes
|
[
"Set",
"the",
"selection",
"state",
"of",
"the",
"given",
"node"
] |
b2c7a7637d4e288271392ba148dc17e4c9780255
|
https://github.com/javagl/CommonUI/blob/b2c7a7637d4e288271392ba148dc17e4c9780255/src/main/java/de/javagl/common/ui/tree/checkbox/CheckBoxTree.java#L256-L270
|
144,617
|
javagl/CommonUI
|
src/main/java/de/javagl/common/ui/tree/checkbox/CheckBoxTree.java
|
CheckBoxTree.handleMousePress
|
private void handleMousePress(MouseEvent e)
{
int row = getRowForLocation(e.getX(), e.getY());
TreePath path = getPathForLocation(e.getX(), e.getY());
if (path == null)
{
return;
}
TreeCellRenderer cellRenderer = getCellRenderer();
TreeNode node = (TreeNode) path.getLastPathComponent();
Component cellRendererComponent =
cellRenderer.getTreeCellRendererComponent(
CheckBoxTree.this, null, true, true, node.isLeaf(), row, true);
Rectangle bounds = getRowBounds(row);
Point localPoint = new Point();
localPoint.x = e.getX() - bounds.x;
localPoint.y = e.getY() - bounds.y;
Container container = (Container)cellRendererComponent;
Component clickedComponent = null;
for (Component component : container.getComponents())
{
Rectangle b = component.getBounds();
if (b.contains(localPoint))
{
clickedComponent = component;
}
}
if (clickedComponent != null)
{
if (clickedComponent instanceof JCheckBox)
{
toggleSelection(path);
repaint();
}
}
}
|
java
|
private void handleMousePress(MouseEvent e)
{
int row = getRowForLocation(e.getX(), e.getY());
TreePath path = getPathForLocation(e.getX(), e.getY());
if (path == null)
{
return;
}
TreeCellRenderer cellRenderer = getCellRenderer();
TreeNode node = (TreeNode) path.getLastPathComponent();
Component cellRendererComponent =
cellRenderer.getTreeCellRendererComponent(
CheckBoxTree.this, null, true, true, node.isLeaf(), row, true);
Rectangle bounds = getRowBounds(row);
Point localPoint = new Point();
localPoint.x = e.getX() - bounds.x;
localPoint.y = e.getY() - bounds.y;
Container container = (Container)cellRendererComponent;
Component clickedComponent = null;
for (Component component : container.getComponents())
{
Rectangle b = component.getBounds();
if (b.contains(localPoint))
{
clickedComponent = component;
}
}
if (clickedComponent != null)
{
if (clickedComponent instanceof JCheckBox)
{
toggleSelection(path);
repaint();
}
}
}
|
[
"private",
"void",
"handleMousePress",
"(",
"MouseEvent",
"e",
")",
"{",
"int",
"row",
"=",
"getRowForLocation",
"(",
"e",
".",
"getX",
"(",
")",
",",
"e",
".",
"getY",
"(",
")",
")",
";",
"TreePath",
"path",
"=",
"getPathForLocation",
"(",
"e",
".",
"getX",
"(",
")",
",",
"e",
".",
"getY",
"(",
")",
")",
";",
"if",
"(",
"path",
"==",
"null",
")",
"{",
"return",
";",
"}",
"TreeCellRenderer",
"cellRenderer",
"=",
"getCellRenderer",
"(",
")",
";",
"TreeNode",
"node",
"=",
"(",
"TreeNode",
")",
"path",
".",
"getLastPathComponent",
"(",
")",
";",
"Component",
"cellRendererComponent",
"=",
"cellRenderer",
".",
"getTreeCellRendererComponent",
"(",
"CheckBoxTree",
".",
"this",
",",
"null",
",",
"true",
",",
"true",
",",
"node",
".",
"isLeaf",
"(",
")",
",",
"row",
",",
"true",
")",
";",
"Rectangle",
"bounds",
"=",
"getRowBounds",
"(",
"row",
")",
";",
"Point",
"localPoint",
"=",
"new",
"Point",
"(",
")",
";",
"localPoint",
".",
"x",
"=",
"e",
".",
"getX",
"(",
")",
"-",
"bounds",
".",
"x",
";",
"localPoint",
".",
"y",
"=",
"e",
".",
"getY",
"(",
")",
"-",
"bounds",
".",
"y",
";",
"Container",
"container",
"=",
"(",
"Container",
")",
"cellRendererComponent",
";",
"Component",
"clickedComponent",
"=",
"null",
";",
"for",
"(",
"Component",
"component",
":",
"container",
".",
"getComponents",
"(",
")",
")",
"{",
"Rectangle",
"b",
"=",
"component",
".",
"getBounds",
"(",
")",
";",
"if",
"(",
"b",
".",
"contains",
"(",
"localPoint",
")",
")",
"{",
"clickedComponent",
"=",
"component",
";",
"}",
"}",
"if",
"(",
"clickedComponent",
"!=",
"null",
")",
"{",
"if",
"(",
"clickedComponent",
"instanceof",
"JCheckBox",
")",
"{",
"toggleSelection",
"(",
"path",
")",
";",
"repaint",
"(",
")",
";",
"}",
"}",
"}"
] |
Handle a mouse press and possibly toggle the selection state
@param e The mouse event
|
[
"Handle",
"a",
"mouse",
"press",
"and",
"possibly",
"toggle",
"the",
"selection",
"state"
] |
b2c7a7637d4e288271392ba148dc17e4c9780255
|
https://github.com/javagl/CommonUI/blob/b2c7a7637d4e288271392ba148dc17e4c9780255/src/main/java/de/javagl/common/ui/tree/checkbox/CheckBoxTree.java#L279-L314
|
144,618
|
javagl/CommonUI
|
src/main/java/de/javagl/common/ui/tree/checkbox/CheckBoxTree.java
|
CheckBoxTree.toggleSelection
|
private void toggleSelection(TreePath path)
{
Object node = path.getLastPathComponent();
State state = getSelectionState(node);
if (state == null)
{
return;
}
if (state == State.SELECTED)
{
setSelectionState(node, State.UNSELECTED);
updateSelection(node);
}
else if (state == State.UNSELECTED)
{
setSelectionState(node, State.SELECTED);
updateSelection(node);
}
else
{
setSelectionState(node, State.SELECTED);
updateSelection(node);
}
}
|
java
|
private void toggleSelection(TreePath path)
{
Object node = path.getLastPathComponent();
State state = getSelectionState(node);
if (state == null)
{
return;
}
if (state == State.SELECTED)
{
setSelectionState(node, State.UNSELECTED);
updateSelection(node);
}
else if (state == State.UNSELECTED)
{
setSelectionState(node, State.SELECTED);
updateSelection(node);
}
else
{
setSelectionState(node, State.SELECTED);
updateSelection(node);
}
}
|
[
"private",
"void",
"toggleSelection",
"(",
"TreePath",
"path",
")",
"{",
"Object",
"node",
"=",
"path",
".",
"getLastPathComponent",
"(",
")",
";",
"State",
"state",
"=",
"getSelectionState",
"(",
"node",
")",
";",
"if",
"(",
"state",
"==",
"null",
")",
"{",
"return",
";",
"}",
"if",
"(",
"state",
"==",
"State",
".",
"SELECTED",
")",
"{",
"setSelectionState",
"(",
"node",
",",
"State",
".",
"UNSELECTED",
")",
";",
"updateSelection",
"(",
"node",
")",
";",
"}",
"else",
"if",
"(",
"state",
"==",
"State",
".",
"UNSELECTED",
")",
"{",
"setSelectionState",
"(",
"node",
",",
"State",
".",
"SELECTED",
")",
";",
"updateSelection",
"(",
"node",
")",
";",
"}",
"else",
"{",
"setSelectionState",
"(",
"node",
",",
"State",
".",
"SELECTED",
")",
";",
"updateSelection",
"(",
"node",
")",
";",
"}",
"}"
] |
Toggle the selection of the given path due to a mouse click
@param path The path
|
[
"Toggle",
"the",
"selection",
"of",
"the",
"given",
"path",
"due",
"to",
"a",
"mouse",
"click"
] |
b2c7a7637d4e288271392ba148dc17e4c9780255
|
https://github.com/javagl/CommonUI/blob/b2c7a7637d4e288271392ba148dc17e4c9780255/src/main/java/de/javagl/common/ui/tree/checkbox/CheckBoxTree.java#L321-L345
|
144,619
|
javagl/CommonUI
|
src/main/java/de/javagl/common/ui/tree/checkbox/CheckBoxTree.java
|
CheckBoxTree.updateSelection
|
private void updateSelection(Object node)
{
State newState = getSelectionState(node);
List<Object> descendants =
JTrees.getAllDescendants(getModel(), node);
for (Object descendant : descendants)
{
setSelectionState(descendant, newState, false);
}
Object ancestor = JTrees.getParent(getModel(), node);
while (ancestor != null)
{
List<Object> childrenOfAncestor =
JTrees.getChildren(getModel(), ancestor);
State stateForAncestor = computeState(childrenOfAncestor);
setSelectionState(ancestor, stateForAncestor, false);
ancestor = JTrees.getParent(getModel(), ancestor);
}
}
|
java
|
private void updateSelection(Object node)
{
State newState = getSelectionState(node);
List<Object> descendants =
JTrees.getAllDescendants(getModel(), node);
for (Object descendant : descendants)
{
setSelectionState(descendant, newState, false);
}
Object ancestor = JTrees.getParent(getModel(), node);
while (ancestor != null)
{
List<Object> childrenOfAncestor =
JTrees.getChildren(getModel(), ancestor);
State stateForAncestor = computeState(childrenOfAncestor);
setSelectionState(ancestor, stateForAncestor, false);
ancestor = JTrees.getParent(getModel(), ancestor);
}
}
|
[
"private",
"void",
"updateSelection",
"(",
"Object",
"node",
")",
"{",
"State",
"newState",
"=",
"getSelectionState",
"(",
"node",
")",
";",
"List",
"<",
"Object",
">",
"descendants",
"=",
"JTrees",
".",
"getAllDescendants",
"(",
"getModel",
"(",
")",
",",
"node",
")",
";",
"for",
"(",
"Object",
"descendant",
":",
"descendants",
")",
"{",
"setSelectionState",
"(",
"descendant",
",",
"newState",
",",
"false",
")",
";",
"}",
"Object",
"ancestor",
"=",
"JTrees",
".",
"getParent",
"(",
"getModel",
"(",
")",
",",
"node",
")",
";",
"while",
"(",
"ancestor",
"!=",
"null",
")",
"{",
"List",
"<",
"Object",
">",
"childrenOfAncestor",
"=",
"JTrees",
".",
"getChildren",
"(",
"getModel",
"(",
")",
",",
"ancestor",
")",
";",
"State",
"stateForAncestor",
"=",
"computeState",
"(",
"childrenOfAncestor",
")",
";",
"setSelectionState",
"(",
"ancestor",
",",
"stateForAncestor",
",",
"false",
")",
";",
"ancestor",
"=",
"JTrees",
".",
"getParent",
"(",
"getModel",
"(",
")",
",",
"ancestor",
")",
";",
"}",
"}"
] |
Update the selection state of the given node based on the state
of its children
@param node The node
|
[
"Update",
"the",
"selection",
"state",
"of",
"the",
"given",
"node",
"based",
"on",
"the",
"state",
"of",
"its",
"children"
] |
b2c7a7637d4e288271392ba148dc17e4c9780255
|
https://github.com/javagl/CommonUI/blob/b2c7a7637d4e288271392ba148dc17e4c9780255/src/main/java/de/javagl/common/ui/tree/checkbox/CheckBoxTree.java#L353-L372
|
144,620
|
javagl/CommonUI
|
src/main/java/de/javagl/common/ui/tree/checkbox/CheckBoxTree.java
|
CheckBoxTree.computeState
|
private State computeState(List<Object> nodes)
{
Set<State> set = new LinkedHashSet<State>();
for (Object node : nodes)
{
set.add(getSelectionState(node));
}
// Should never happen
while (set.contains(null))
{
logger.warning("null found in selection states");
set.remove(null);
}
if (set.size() == 0)
{
// Should never happen
logger.warning("Empty selection states");
return State.SELECTED;
}
if (set.size() > 1)
{
return State.MIXED;
}
return set.iterator().next();
}
|
java
|
private State computeState(List<Object> nodes)
{
Set<State> set = new LinkedHashSet<State>();
for (Object node : nodes)
{
set.add(getSelectionState(node));
}
// Should never happen
while (set.contains(null))
{
logger.warning("null found in selection states");
set.remove(null);
}
if (set.size() == 0)
{
// Should never happen
logger.warning("Empty selection states");
return State.SELECTED;
}
if (set.size() > 1)
{
return State.MIXED;
}
return set.iterator().next();
}
|
[
"private",
"State",
"computeState",
"(",
"List",
"<",
"Object",
">",
"nodes",
")",
"{",
"Set",
"<",
"State",
">",
"set",
"=",
"new",
"LinkedHashSet",
"<",
"State",
">",
"(",
")",
";",
"for",
"(",
"Object",
"node",
":",
"nodes",
")",
"{",
"set",
".",
"add",
"(",
"getSelectionState",
"(",
"node",
")",
")",
";",
"}",
"// Should never happen\r",
"while",
"(",
"set",
".",
"contains",
"(",
"null",
")",
")",
"{",
"logger",
".",
"warning",
"(",
"\"null found in selection states\"",
")",
";",
"set",
".",
"remove",
"(",
"null",
")",
";",
"}",
"if",
"(",
"set",
".",
"size",
"(",
")",
"==",
"0",
")",
"{",
"// Should never happen\r",
"logger",
".",
"warning",
"(",
"\"Empty selection states\"",
")",
";",
"return",
"State",
".",
"SELECTED",
";",
"}",
"if",
"(",
"set",
".",
"size",
"(",
")",
">",
"1",
")",
"{",
"return",
"State",
".",
"MIXED",
";",
"}",
"return",
"set",
".",
"iterator",
"(",
")",
".",
"next",
"(",
")",
";",
"}"
] |
Compute the state for a node with the given children
@param nodes The nodes
@return The state
|
[
"Compute",
"the",
"state",
"for",
"a",
"node",
"with",
"the",
"given",
"children"
] |
b2c7a7637d4e288271392ba148dc17e4c9780255
|
https://github.com/javagl/CommonUI/blob/b2c7a7637d4e288271392ba148dc17e4c9780255/src/main/java/de/javagl/common/ui/tree/checkbox/CheckBoxTree.java#L380-L404
|
144,621
|
javagl/CommonUI
|
src/main/java/de/javagl/common/ui/panel/collapsible/AccordionPanel.java
|
AccordionPanel.removeFromAccordion
|
public void removeFromAccordion(JComponent component)
{
CollapsiblePanel collapsiblePanel = collapsiblePanels.get(component);
if (collapsiblePanel != null)
{
contentPanel.remove(collapsiblePanel);
collapsiblePanels.remove(component);
revalidate();
}
}
|
java
|
public void removeFromAccordion(JComponent component)
{
CollapsiblePanel collapsiblePanel = collapsiblePanels.get(component);
if (collapsiblePanel != null)
{
contentPanel.remove(collapsiblePanel);
collapsiblePanels.remove(component);
revalidate();
}
}
|
[
"public",
"void",
"removeFromAccordion",
"(",
"JComponent",
"component",
")",
"{",
"CollapsiblePanel",
"collapsiblePanel",
"=",
"collapsiblePanels",
".",
"get",
"(",
"component",
")",
";",
"if",
"(",
"collapsiblePanel",
"!=",
"null",
")",
"{",
"contentPanel",
".",
"remove",
"(",
"collapsiblePanel",
")",
";",
"collapsiblePanels",
".",
"remove",
"(",
"component",
")",
";",
"revalidate",
"(",
")",
";",
"}",
"}"
] |
Remove the given component from this accordion
@param component The component to remove
|
[
"Remove",
"the",
"given",
"component",
"from",
"this",
"accordion"
] |
b2c7a7637d4e288271392ba148dc17e4c9780255
|
https://github.com/javagl/CommonUI/blob/b2c7a7637d4e288271392ba148dc17e4c9780255/src/main/java/de/javagl/common/ui/panel/collapsible/AccordionPanel.java#L128-L137
|
144,622
|
comapi/comapi-sdk-android
|
COMAPI/foundation/src/main/java/com/comapi/internal/network/sockets/SocketController.java
|
SocketController.connectSocket
|
public void connectSocket() {
synchronized (lock) {
if (isForegrounded) {
if (socketConnection == null) {
SocketFactory factory = new SocketFactory(socketURI, new SocketEventDispatcher(listener, new Parser()).setLogger(log), log);
socketConnection = new SocketConnectionController(new Handler(Looper.getMainLooper()), dataMgr, factory, listener, new RetryStrategy(60, 60000), log);
socketConnection.setProxy(proxyURI);
socketConnection.connect();
} else {
socketConnection.connect();
}
socketConnection.setManageReconnection(true);
}
lock.notifyAll();
}
}
|
java
|
public void connectSocket() {
synchronized (lock) {
if (isForegrounded) {
if (socketConnection == null) {
SocketFactory factory = new SocketFactory(socketURI, new SocketEventDispatcher(listener, new Parser()).setLogger(log), log);
socketConnection = new SocketConnectionController(new Handler(Looper.getMainLooper()), dataMgr, factory, listener, new RetryStrategy(60, 60000), log);
socketConnection.setProxy(proxyURI);
socketConnection.connect();
} else {
socketConnection.connect();
}
socketConnection.setManageReconnection(true);
}
lock.notifyAll();
}
}
|
[
"public",
"void",
"connectSocket",
"(",
")",
"{",
"synchronized",
"(",
"lock",
")",
"{",
"if",
"(",
"isForegrounded",
")",
"{",
"if",
"(",
"socketConnection",
"==",
"null",
")",
"{",
"SocketFactory",
"factory",
"=",
"new",
"SocketFactory",
"(",
"socketURI",
",",
"new",
"SocketEventDispatcher",
"(",
"listener",
",",
"new",
"Parser",
"(",
")",
")",
".",
"setLogger",
"(",
"log",
")",
",",
"log",
")",
";",
"socketConnection",
"=",
"new",
"SocketConnectionController",
"(",
"new",
"Handler",
"(",
"Looper",
".",
"getMainLooper",
"(",
")",
")",
",",
"dataMgr",
",",
"factory",
",",
"listener",
",",
"new",
"RetryStrategy",
"(",
"60",
",",
"60000",
")",
",",
"log",
")",
";",
"socketConnection",
".",
"setProxy",
"(",
"proxyURI",
")",
";",
"socketConnection",
".",
"connect",
"(",
")",
";",
"}",
"else",
"{",
"socketConnection",
".",
"connect",
"(",
")",
";",
"}",
"socketConnection",
".",
"setManageReconnection",
"(",
"true",
")",
";",
"}",
"lock",
".",
"notifyAll",
"(",
")",
";",
"}",
"}"
] |
Create and connect socket.
|
[
"Create",
"and",
"connect",
"socket",
"."
] |
53140a58d5a62afe196047ccc5120bfe090ef211
|
https://github.com/comapi/comapi-sdk-android/blob/53140a58d5a62afe196047ccc5120bfe090ef211/COMAPI/foundation/src/main/java/com/comapi/internal/network/sockets/SocketController.java#L89-L106
|
144,623
|
comapi/comapi-sdk-android
|
COMAPI/foundation/src/main/java/com/comapi/internal/network/sockets/SocketController.java
|
SocketController.disconnectSocket
|
public void disconnectSocket() {
synchronized (lock) {
if (socketConnection != null) {
socketConnection.setManageReconnection(false);
socketConnection.disconnect();
}
lock.notifyAll();
}
}
|
java
|
public void disconnectSocket() {
synchronized (lock) {
if (socketConnection != null) {
socketConnection.setManageReconnection(false);
socketConnection.disconnect();
}
lock.notifyAll();
}
}
|
[
"public",
"void",
"disconnectSocket",
"(",
")",
"{",
"synchronized",
"(",
"lock",
")",
"{",
"if",
"(",
"socketConnection",
"!=",
"null",
")",
"{",
"socketConnection",
".",
"setManageReconnection",
"(",
"false",
")",
";",
"socketConnection",
".",
"disconnect",
"(",
")",
";",
"}",
"lock",
".",
"notifyAll",
"(",
")",
";",
"}",
"}"
] |
Disconnect socket.
|
[
"Disconnect",
"socket",
"."
] |
53140a58d5a62afe196047ccc5120bfe090ef211
|
https://github.com/comapi/comapi-sdk-android/blob/53140a58d5a62afe196047ccc5120bfe090ef211/COMAPI/foundation/src/main/java/com/comapi/internal/network/sockets/SocketController.java#L111-L119
|
144,624
|
comapi/comapi-sdk-android
|
COMAPI/foundation/src/main/java/com/comapi/internal/network/sockets/SocketController.java
|
SocketController.createLifecycleListener
|
public LifecycleListener createLifecycleListener() {
return new LifecycleListener() {
@Override
public void onForegrounded(Context context) {
synchronized (lock) {
if (!isForegrounded) {
isForegrounded = true;
connectSocket();
if (receiver == null) {
receiver = new InternetConnectionReceiver(socketConnection);
}
context.registerReceiver(receiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION));
}
lock.notifyAll();
}
}
@Override
public void onBackgrounded(Context context) {
synchronized (lock) {
if (isForegrounded) {
isForegrounded = false;
disconnectSocket();
if (receiver != null && !isForegrounded) {
context.unregisterReceiver(receiver);
}
}
lock.notifyAll();
}
}
};
}
|
java
|
public LifecycleListener createLifecycleListener() {
return new LifecycleListener() {
@Override
public void onForegrounded(Context context) {
synchronized (lock) {
if (!isForegrounded) {
isForegrounded = true;
connectSocket();
if (receiver == null) {
receiver = new InternetConnectionReceiver(socketConnection);
}
context.registerReceiver(receiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION));
}
lock.notifyAll();
}
}
@Override
public void onBackgrounded(Context context) {
synchronized (lock) {
if (isForegrounded) {
isForegrounded = false;
disconnectSocket();
if (receiver != null && !isForegrounded) {
context.unregisterReceiver(receiver);
}
}
lock.notifyAll();
}
}
};
}
|
[
"public",
"LifecycleListener",
"createLifecycleListener",
"(",
")",
"{",
"return",
"new",
"LifecycleListener",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"onForegrounded",
"(",
"Context",
"context",
")",
"{",
"synchronized",
"(",
"lock",
")",
"{",
"if",
"(",
"!",
"isForegrounded",
")",
"{",
"isForegrounded",
"=",
"true",
";",
"connectSocket",
"(",
")",
";",
"if",
"(",
"receiver",
"==",
"null",
")",
"{",
"receiver",
"=",
"new",
"InternetConnectionReceiver",
"(",
"socketConnection",
")",
";",
"}",
"context",
".",
"registerReceiver",
"(",
"receiver",
",",
"new",
"IntentFilter",
"(",
"ConnectivityManager",
".",
"CONNECTIVITY_ACTION",
")",
")",
";",
"}",
"lock",
".",
"notifyAll",
"(",
")",
";",
"}",
"}",
"@",
"Override",
"public",
"void",
"onBackgrounded",
"(",
"Context",
"context",
")",
"{",
"synchronized",
"(",
"lock",
")",
"{",
"if",
"(",
"isForegrounded",
")",
"{",
"isForegrounded",
"=",
"false",
";",
"disconnectSocket",
"(",
")",
";",
"if",
"(",
"receiver",
"!=",
"null",
"&&",
"!",
"isForegrounded",
")",
"{",
"context",
".",
"unregisterReceiver",
"(",
"receiver",
")",
";",
"}",
"}",
"lock",
".",
"notifyAll",
"(",
")",
";",
"}",
"}",
"}",
";",
"}"
] |
creates application lifecycle and network connectivity callbacks.
@return Application lifecycle and network connectivity callbacks.
|
[
"creates",
"application",
"lifecycle",
"and",
"network",
"connectivity",
"callbacks",
"."
] |
53140a58d5a62afe196047ccc5120bfe090ef211
|
https://github.com/comapi/comapi-sdk-android/blob/53140a58d5a62afe196047ccc5120bfe090ef211/COMAPI/foundation/src/main/java/com/comapi/internal/network/sockets/SocketController.java#L126-L158
|
144,625
|
sebastiangraf/perfidix
|
src/main/java/org/perfidix/socketadapter/SocketViewProgressUpdater.java
|
SocketViewProgressUpdater.initProgressView
|
public boolean initProgressView(final Map<BenchmarkMethod, Integer> mapping)
throws SocketViewException {
if (mapping != null) {
final Set<BenchmarkMethod> methodSet = mapping.keySet();
final Map<String, Integer> finalMap = new HashMap<String, Integer>();
for (BenchmarkMethod benchmarkMethod : methodSet) {
finalMap.put(benchmarkMethod.getMethodWithClassName(),
mapping.get(benchmarkMethod));
}
viewStub.initTotalBenchProgress(finalMap);
}
return true;
}
|
java
|
public boolean initProgressView(final Map<BenchmarkMethod, Integer> mapping)
throws SocketViewException {
if (mapping != null) {
final Set<BenchmarkMethod> methodSet = mapping.keySet();
final Map<String, Integer> finalMap = new HashMap<String, Integer>();
for (BenchmarkMethod benchmarkMethod : methodSet) {
finalMap.put(benchmarkMethod.getMethodWithClassName(),
mapping.get(benchmarkMethod));
}
viewStub.initTotalBenchProgress(finalMap);
}
return true;
}
|
[
"public",
"boolean",
"initProgressView",
"(",
"final",
"Map",
"<",
"BenchmarkMethod",
",",
"Integer",
">",
"mapping",
")",
"throws",
"SocketViewException",
"{",
"if",
"(",
"mapping",
"!=",
"null",
")",
"{",
"final",
"Set",
"<",
"BenchmarkMethod",
">",
"methodSet",
"=",
"mapping",
".",
"keySet",
"(",
")",
";",
"final",
"Map",
"<",
"String",
",",
"Integer",
">",
"finalMap",
"=",
"new",
"HashMap",
"<",
"String",
",",
"Integer",
">",
"(",
")",
";",
"for",
"(",
"BenchmarkMethod",
"benchmarkMethod",
":",
"methodSet",
")",
"{",
"finalMap",
".",
"put",
"(",
"benchmarkMethod",
".",
"getMethodWithClassName",
"(",
")",
",",
"mapping",
".",
"get",
"(",
"benchmarkMethod",
")",
")",
";",
"}",
"viewStub",
".",
"initTotalBenchProgress",
"(",
"finalMap",
")",
";",
"}",
"return",
"true",
";",
"}"
] |
This method initializes the values of the eclipse view and resets the
progress bar.
@param mapping
a mapping with all methods to benchmark and the related runs
@throws SocketViewException
if init fails
|
[
"This",
"method",
"initializes",
"the",
"values",
"of",
"the",
"eclipse",
"view",
"and",
"resets",
"the",
"progress",
"bar",
"."
] |
f13aa793b6a3055215ed4edbb946c1bb5d564886
|
https://github.com/sebastiangraf/perfidix/blob/f13aa793b6a3055215ed4edbb946c1bb5d564886/src/main/java/org/perfidix/socketadapter/SocketViewProgressUpdater.java#L73-L88
|
144,626
|
sebastiangraf/perfidix
|
src/main/java/org/perfidix/socketadapter/SocketViewProgressUpdater.java
|
SocketViewProgressUpdater.updateCurrentElement
|
public boolean updateCurrentElement(final AbstractMeter meter,
final String name) throws SocketViewException {
if (meter != null && !regMeterHash) {
registerFirstMeterHash(meter);
}
if (name != null && meter.hashCode() == (getRegMeter())) {
viewStub.updateCurrentRun(name);
}
return true;
}
|
java
|
public boolean updateCurrentElement(final AbstractMeter meter,
final String name) throws SocketViewException {
if (meter != null && !regMeterHash) {
registerFirstMeterHash(meter);
}
if (name != null && meter.hashCode() == (getRegMeter())) {
viewStub.updateCurrentRun(name);
}
return true;
}
|
[
"public",
"boolean",
"updateCurrentElement",
"(",
"final",
"AbstractMeter",
"meter",
",",
"final",
"String",
"name",
")",
"throws",
"SocketViewException",
"{",
"if",
"(",
"meter",
"!=",
"null",
"&&",
"!",
"regMeterHash",
")",
"{",
"registerFirstMeterHash",
"(",
"meter",
")",
";",
"}",
"if",
"(",
"name",
"!=",
"null",
"&&",
"meter",
".",
"hashCode",
"(",
")",
"==",
"(",
"getRegMeter",
"(",
")",
")",
")",
"{",
"viewStub",
".",
"updateCurrentRun",
"(",
"name",
")",
";",
"}",
"return",
"true",
";",
"}"
] |
This method notifies the eclipse view which element is currently benched.
@param meter
The current meter.
@param name
This param represents the java element which is currently
benched and which is fully qualified.
@throws SocketViewException
if update fails
|
[
"This",
"method",
"notifies",
"the",
"eclipse",
"view",
"which",
"element",
"is",
"currently",
"benched",
"."
] |
f13aa793b6a3055215ed4edbb946c1bb5d564886
|
https://github.com/sebastiangraf/perfidix/blob/f13aa793b6a3055215ed4edbb946c1bb5d564886/src/main/java/org/perfidix/socketadapter/SocketViewProgressUpdater.java#L101-L110
|
144,627
|
sebastiangraf/perfidix
|
src/main/java/org/perfidix/socketadapter/SocketViewProgressUpdater.java
|
SocketViewProgressUpdater.updateErrorInElement
|
public boolean updateErrorInElement(final String name,
final Exception exception) throws SocketViewException {
if (name != null && exception != null) {
if (exception instanceof AbstractPerfidixMethodException) {
final AbstractPerfidixMethodException exc = (AbstractPerfidixMethodException) exception;
viewStub.updateError(name, exc.getExec().getClass()
.getSimpleName());
}
if (exception instanceof SocketViewException) {
final SocketViewException viewException = (SocketViewException) exception;
viewStub.updateError(name, viewException.getExc().getClass()
.getSimpleName());
}
}
return true;
}
|
java
|
public boolean updateErrorInElement(final String name,
final Exception exception) throws SocketViewException {
if (name != null && exception != null) {
if (exception instanceof AbstractPerfidixMethodException) {
final AbstractPerfidixMethodException exc = (AbstractPerfidixMethodException) exception;
viewStub.updateError(name, exc.getExec().getClass()
.getSimpleName());
}
if (exception instanceof SocketViewException) {
final SocketViewException viewException = (SocketViewException) exception;
viewStub.updateError(name, viewException.getExc().getClass()
.getSimpleName());
}
}
return true;
}
|
[
"public",
"boolean",
"updateErrorInElement",
"(",
"final",
"String",
"name",
",",
"final",
"Exception",
"exception",
")",
"throws",
"SocketViewException",
"{",
"if",
"(",
"name",
"!=",
"null",
"&&",
"exception",
"!=",
"null",
")",
"{",
"if",
"(",
"exception",
"instanceof",
"AbstractPerfidixMethodException",
")",
"{",
"final",
"AbstractPerfidixMethodException",
"exc",
"=",
"(",
"AbstractPerfidixMethodException",
")",
"exception",
";",
"viewStub",
".",
"updateError",
"(",
"name",
",",
"exc",
".",
"getExec",
"(",
")",
".",
"getClass",
"(",
")",
".",
"getSimpleName",
"(",
")",
")",
";",
"}",
"if",
"(",
"exception",
"instanceof",
"SocketViewException",
")",
"{",
"final",
"SocketViewException",
"viewException",
"=",
"(",
"SocketViewException",
")",
"exception",
";",
"viewStub",
".",
"updateError",
"(",
"name",
",",
"viewException",
".",
"getExc",
"(",
")",
".",
"getClass",
"(",
")",
".",
"getSimpleName",
"(",
")",
")",
";",
"}",
"}",
"return",
"true",
";",
"}"
] |
This method informs the view that an error occurred while benching the
current element.
@param name
Element represents the java element which has not been
executed successfully.
@param exception
The exception caused by the element.
@throws SocketViewException
if update fails
|
[
"This",
"method",
"informs",
"the",
"view",
"that",
"an",
"error",
"occurred",
"while",
"benching",
"the",
"current",
"element",
"."
] |
f13aa793b6a3055215ed4edbb946c1bb5d564886
|
https://github.com/sebastiangraf/perfidix/blob/f13aa793b6a3055215ed4edbb946c1bb5d564886/src/main/java/org/perfidix/socketadapter/SocketViewProgressUpdater.java#L124-L139
|
144,628
|
comapi/comapi-sdk-android
|
COMAPI/foundation/src/main/java/com/comapi/internal/log/Formatter.java
|
Formatter.getLevelTag
|
static String getLevelTag(final int logLevel) {
switch (logLevel) {
case LogLevelConst.FATAL:
return LogConstants.TAG_FATAL;
case LogLevelConst.ERROR:
return LogConstants.TAG_ERROR;
case LogLevelConst.WARNING:
return LogConstants.TAG_WARNING;
case LogLevelConst.INFO:
return LogConstants.TAG_INFO;
case LogLevelConst.DEBUG:
return LogConstants.TAG_DEBUG;
default:
return "[DEFAULT]";
}
}
|
java
|
static String getLevelTag(final int logLevel) {
switch (logLevel) {
case LogLevelConst.FATAL:
return LogConstants.TAG_FATAL;
case LogLevelConst.ERROR:
return LogConstants.TAG_ERROR;
case LogLevelConst.WARNING:
return LogConstants.TAG_WARNING;
case LogLevelConst.INFO:
return LogConstants.TAG_INFO;
case LogLevelConst.DEBUG:
return LogConstants.TAG_DEBUG;
default:
return "[DEFAULT]";
}
}
|
[
"static",
"String",
"getLevelTag",
"(",
"final",
"int",
"logLevel",
")",
"{",
"switch",
"(",
"logLevel",
")",
"{",
"case",
"LogLevelConst",
".",
"FATAL",
":",
"return",
"LogConstants",
".",
"TAG_FATAL",
";",
"case",
"LogLevelConst",
".",
"ERROR",
":",
"return",
"LogConstants",
".",
"TAG_ERROR",
";",
"case",
"LogLevelConst",
".",
"WARNING",
":",
"return",
"LogConstants",
".",
"TAG_WARNING",
";",
"case",
"LogLevelConst",
".",
"INFO",
":",
"return",
"LogConstants",
".",
"TAG_INFO",
";",
"case",
"LogLevelConst",
".",
"DEBUG",
":",
"return",
"LogConstants",
".",
"TAG_DEBUG",
";",
"default",
":",
"return",
"\"[DEFAULT]\"",
";",
"}",
"}"
] |
Gets the string representation of the log level.
@param logLevel Level of the log message.
@return String representation of the log level.
|
[
"Gets",
"the",
"string",
"representation",
"of",
"the",
"log",
"level",
"."
] |
53140a58d5a62afe196047ccc5120bfe090ef211
|
https://github.com/comapi/comapi-sdk-android/blob/53140a58d5a62afe196047ccc5120bfe090ef211/COMAPI/foundation/src/main/java/com/comapi/internal/log/Formatter.java#L37-L60
|
144,629
|
comapi/comapi-sdk-android
|
COMAPI/foundation/src/main/java/com/comapi/internal/network/model/messaging/OrphanedEvent.java
|
OrphanedEvent.getMessageId
|
public String getMessageId() {
return (data != null && data.payload != null) ? data.payload.messageId : null;
}
|
java
|
public String getMessageId() {
return (data != null && data.payload != null) ? data.payload.messageId : null;
}
|
[
"public",
"String",
"getMessageId",
"(",
")",
"{",
"return",
"(",
"data",
"!=",
"null",
"&&",
"data",
".",
"payload",
"!=",
"null",
")",
"?",
"data",
".",
"payload",
".",
"messageId",
":",
"null",
";",
"}"
] |
Gets id of the updated message.
@return Id of the updated message.
|
[
"Gets",
"id",
"of",
"the",
"updated",
"message",
"."
] |
53140a58d5a62afe196047ccc5120bfe090ef211
|
https://github.com/comapi/comapi-sdk-android/blob/53140a58d5a62afe196047ccc5120bfe090ef211/COMAPI/foundation/src/main/java/com/comapi/internal/network/model/messaging/OrphanedEvent.java#L106-L108
|
144,630
|
comapi/comapi-sdk-android
|
COMAPI/foundation/src/main/java/com/comapi/internal/network/model/messaging/OrphanedEvent.java
|
OrphanedEvent.getConversationId
|
public String getConversationId() {
return (data != null && data.payload != null) ? data.payload.conversationId : null;
}
|
java
|
public String getConversationId() {
return (data != null && data.payload != null) ? data.payload.conversationId : null;
}
|
[
"public",
"String",
"getConversationId",
"(",
")",
"{",
"return",
"(",
"data",
"!=",
"null",
"&&",
"data",
".",
"payload",
"!=",
"null",
")",
"?",
"data",
".",
"payload",
".",
"conversationId",
":",
"null",
";",
"}"
] |
Gets id of the conversation for which message was updated.
@return Id of the updated message.
|
[
"Gets",
"id",
"of",
"the",
"conversation",
"for",
"which",
"message",
"was",
"updated",
"."
] |
53140a58d5a62afe196047ccc5120bfe090ef211
|
https://github.com/comapi/comapi-sdk-android/blob/53140a58d5a62afe196047ccc5120bfe090ef211/COMAPI/foundation/src/main/java/com/comapi/internal/network/model/messaging/OrphanedEvent.java#L115-L117
|
144,631
|
comapi/comapi-sdk-android
|
COMAPI/foundation/src/main/java/com/comapi/internal/network/model/messaging/OrphanedEvent.java
|
OrphanedEvent.getProfileId
|
public String getProfileId() {
return (data != null && data.payload != null) ? data.payload.profileId : null;
}
|
java
|
public String getProfileId() {
return (data != null && data.payload != null) ? data.payload.profileId : null;
}
|
[
"public",
"String",
"getProfileId",
"(",
")",
"{",
"return",
"(",
"data",
"!=",
"null",
"&&",
"data",
".",
"payload",
"!=",
"null",
")",
"?",
"data",
".",
"payload",
".",
"profileId",
":",
"null",
";",
"}"
] |
Gets profile id of the user that changed the message status.
@return Profile id of the user that changed the message status.
|
[
"Gets",
"profile",
"id",
"of",
"the",
"user",
"that",
"changed",
"the",
"message",
"status",
"."
] |
53140a58d5a62afe196047ccc5120bfe090ef211
|
https://github.com/comapi/comapi-sdk-android/blob/53140a58d5a62afe196047ccc5120bfe090ef211/COMAPI/foundation/src/main/java/com/comapi/internal/network/model/messaging/OrphanedEvent.java#L124-L126
|
144,632
|
comapi/comapi-sdk-android
|
COMAPI/foundation/src/main/java/com/comapi/internal/network/model/messaging/OrphanedEvent.java
|
OrphanedEvent.getTimestamp
|
public String getTimestamp() {
return (data != null && data.payload != null) ? data.payload.timestamp : null;
}
|
java
|
public String getTimestamp() {
return (data != null && data.payload != null) ? data.payload.timestamp : null;
}
|
[
"public",
"String",
"getTimestamp",
"(",
")",
"{",
"return",
"(",
"data",
"!=",
"null",
"&&",
"data",
".",
"payload",
"!=",
"null",
")",
"?",
"data",
".",
"payload",
".",
"timestamp",
":",
"null",
";",
"}"
] |
Gets time when the message status changed.
@return Time when the message status changed.
|
[
"Gets",
"time",
"when",
"the",
"message",
"status",
"changed",
"."
] |
53140a58d5a62afe196047ccc5120bfe090ef211
|
https://github.com/comapi/comapi-sdk-android/blob/53140a58d5a62afe196047ccc5120bfe090ef211/COMAPI/foundation/src/main/java/com/comapi/internal/network/model/messaging/OrphanedEvent.java#L133-L135
|
144,633
|
sebastiangraf/perfidix
|
src/main/java/org/perfidix/ouput/asciitable/Util.java
|
Util.combine
|
static String combine(final String... args) {
final StringBuilder builder = new StringBuilder();
for (final String arg : args) {
builder.append(arg);
}
return builder.toString();
}
|
java
|
static String combine(final String... args) {
final StringBuilder builder = new StringBuilder();
for (final String arg : args) {
builder.append(arg);
}
return builder.toString();
}
|
[
"static",
"String",
"combine",
"(",
"final",
"String",
"...",
"args",
")",
"{",
"final",
"StringBuilder",
"builder",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"for",
"(",
"final",
"String",
"arg",
":",
"args",
")",
"{",
"builder",
".",
"append",
"(",
"arg",
")",
";",
"}",
"return",
"builder",
".",
"toString",
"(",
")",
";",
"}"
] |
Combines an unknown number of Strings to one String.
@param args multiple Strings
@return the combined string
|
[
"Combines",
"an",
"unknown",
"number",
"of",
"Strings",
"to",
"one",
"String",
"."
] |
f13aa793b6a3055215ed4edbb946c1bb5d564886
|
https://github.com/sebastiangraf/perfidix/blob/f13aa793b6a3055215ed4edbb946c1bb5d564886/src/main/java/org/perfidix/ouput/asciitable/Util.java#L43-L49
|
144,634
|
sebastiangraf/perfidix
|
src/main/java/org/perfidix/ouput/asciitable/Util.java
|
Util.implode
|
static String implode(final String glue, final String[] what) {
final StringBuilder builder = new StringBuilder();
for (int i = 0; i < what.length; i++) {
builder.append(what[i]);
if (i + 1 != what.length) {
builder.append(glue);
}
}
return builder.toString();
}
|
java
|
static String implode(final String glue, final String[] what) {
final StringBuilder builder = new StringBuilder();
for (int i = 0; i < what.length; i++) {
builder.append(what[i]);
if (i + 1 != what.length) {
builder.append(glue);
}
}
return builder.toString();
}
|
[
"static",
"String",
"implode",
"(",
"final",
"String",
"glue",
",",
"final",
"String",
"[",
"]",
"what",
")",
"{",
"final",
"StringBuilder",
"builder",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"what",
".",
"length",
";",
"i",
"++",
")",
"{",
"builder",
".",
"append",
"(",
"what",
"[",
"i",
"]",
")",
";",
"if",
"(",
"i",
"+",
"1",
"!=",
"what",
".",
"length",
")",
"{",
"builder",
".",
"append",
"(",
"glue",
")",
";",
"}",
"}",
"return",
"builder",
".",
"toString",
"(",
")",
";",
"}"
] |
Concantenate a String array "what" with glue "glue".
@param what the array of strings to concantenate
@param glue the glue string to use.
<p/>
<pre>
String[] what = { "a", "b", "c" };
String s = Util.implode("-", what);
// result is "a-b-c"
</pre>
@return String
|
[
"Concantenate",
"a",
"String",
"array",
"what",
"with",
"glue",
"glue",
"."
] |
f13aa793b6a3055215ed4edbb946c1bb5d564886
|
https://github.com/sebastiangraf/perfidix/blob/f13aa793b6a3055215ed4edbb946c1bb5d564886/src/main/java/org/perfidix/ouput/asciitable/Util.java#L106-L116
|
144,635
|
sebastiangraf/perfidix
|
src/main/java/org/perfidix/ouput/asciitable/Util.java
|
Util.repeat
|
static String repeat(final String toBeRepeated, final int numTimes) {
final StringBuilder builder = new StringBuilder();
for (int i = 0; i < numTimes; i++) {
builder.append(toBeRepeated);
}
return builder.toString();
}
|
java
|
static String repeat(final String toBeRepeated, final int numTimes) {
final StringBuilder builder = new StringBuilder();
for (int i = 0; i < numTimes; i++) {
builder.append(toBeRepeated);
}
return builder.toString();
}
|
[
"static",
"String",
"repeat",
"(",
"final",
"String",
"toBeRepeated",
",",
"final",
"int",
"numTimes",
")",
"{",
"final",
"StringBuilder",
"builder",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"numTimes",
";",
"i",
"++",
")",
"{",
"builder",
".",
"append",
"(",
"toBeRepeated",
")",
";",
"}",
"return",
"builder",
".",
"toString",
"(",
")",
";",
"}"
] |
a str_repeat function.
@param toBeRepeated the string to repeat
@param numTimes how many times to concantenate the string
@return the repeated string.
|
[
"a",
"str_repeat",
"function",
"."
] |
f13aa793b6a3055215ed4edbb946c1bb5d564886
|
https://github.com/sebastiangraf/perfidix/blob/f13aa793b6a3055215ed4edbb946c1bb5d564886/src/main/java/org/perfidix/ouput/asciitable/Util.java#L125-L132
|
144,636
|
sebastiangraf/perfidix
|
src/main/java/org/perfidix/ouput/asciitable/Util.java
|
Util.numNewLines
|
private static int numNewLines(final String toExamine) {
final char[] arr = toExamine.toCharArray();
int result = 0;
for (char ch : arr) {
if (AbstractTabularComponent.NEWLINE.equals(new String(new char[]{ch}))) {
result++;
}
}
return result;
}
|
java
|
private static int numNewLines(final String toExamine) {
final char[] arr = toExamine.toCharArray();
int result = 0;
for (char ch : arr) {
if (AbstractTabularComponent.NEWLINE.equals(new String(new char[]{ch}))) {
result++;
}
}
return result;
}
|
[
"private",
"static",
"int",
"numNewLines",
"(",
"final",
"String",
"toExamine",
")",
"{",
"final",
"char",
"[",
"]",
"arr",
"=",
"toExamine",
".",
"toCharArray",
"(",
")",
";",
"int",
"result",
"=",
"0",
";",
"for",
"(",
"char",
"ch",
":",
"arr",
")",
"{",
"if",
"(",
"AbstractTabularComponent",
".",
"NEWLINE",
".",
"equals",
"(",
"new",
"String",
"(",
"new",
"char",
"[",
"]",
"{",
"ch",
"}",
")",
")",
")",
"{",
"result",
"++",
";",
"}",
"}",
"return",
"result",
";",
"}"
] |
Returns how many new lines are in the string.
@param toExamine the string to look upon.
@return the number of occurences of {@link org.perfidix.ouput.asciitable.AbstractTabularComponent#NEWLINE} in the string.
|
[
"Returns",
"how",
"many",
"new",
"lines",
"are",
"in",
"the",
"string",
"."
] |
f13aa793b6a3055215ed4edbb946c1bb5d564886
|
https://github.com/sebastiangraf/perfidix/blob/f13aa793b6a3055215ed4edbb946c1bb5d564886/src/main/java/org/perfidix/ouput/asciitable/Util.java#L150-L159
|
144,637
|
sebastiangraf/perfidix
|
src/main/java/org/perfidix/ouput/asciitable/Util.java
|
Util.createMatrix
|
public static String[][] createMatrix(final String[] data) {
int maxNewLines = 0;
for (final String col : data) {
maxNewLines = Math.max(maxNewLines, Util.numNewLines(col));
}
final String[][] matrix = new String[maxNewLines + 1][data.length];
for (int col = 0; col < data.length; col++) {
final String[] exploded = Util.explode(data[col]);
for (int row = 0; row < maxNewLines + 1; row++) {
if (exploded.length > row) {
matrix[row][col] = exploded[row];
} else {
matrix[row][col] = "";
}
}
}
return matrix;
}
|
java
|
public static String[][] createMatrix(final String[] data) {
int maxNewLines = 0;
for (final String col : data) {
maxNewLines = Math.max(maxNewLines, Util.numNewLines(col));
}
final String[][] matrix = new String[maxNewLines + 1][data.length];
for (int col = 0; col < data.length; col++) {
final String[] exploded = Util.explode(data[col]);
for (int row = 0; row < maxNewLines + 1; row++) {
if (exploded.length > row) {
matrix[row][col] = exploded[row];
} else {
matrix[row][col] = "";
}
}
}
return matrix;
}
|
[
"public",
"static",
"String",
"[",
"]",
"[",
"]",
"createMatrix",
"(",
"final",
"String",
"[",
"]",
"data",
")",
"{",
"int",
"maxNewLines",
"=",
"0",
";",
"for",
"(",
"final",
"String",
"col",
":",
"data",
")",
"{",
"maxNewLines",
"=",
"Math",
".",
"max",
"(",
"maxNewLines",
",",
"Util",
".",
"numNewLines",
"(",
"col",
")",
")",
";",
"}",
"final",
"String",
"[",
"]",
"[",
"]",
"matrix",
"=",
"new",
"String",
"[",
"maxNewLines",
"+",
"1",
"]",
"[",
"data",
".",
"length",
"]",
";",
"for",
"(",
"int",
"col",
"=",
"0",
";",
"col",
"<",
"data",
".",
"length",
";",
"col",
"++",
")",
"{",
"final",
"String",
"[",
"]",
"exploded",
"=",
"Util",
".",
"explode",
"(",
"data",
"[",
"col",
"]",
")",
";",
"for",
"(",
"int",
"row",
"=",
"0",
";",
"row",
"<",
"maxNewLines",
"+",
"1",
";",
"row",
"++",
")",
"{",
"if",
"(",
"exploded",
".",
"length",
">",
"row",
")",
"{",
"matrix",
"[",
"row",
"]",
"[",
"col",
"]",
"=",
"exploded",
"[",
"row",
"]",
";",
"}",
"else",
"{",
"matrix",
"[",
"row",
"]",
"[",
"col",
"]",
"=",
"\"\"",
";",
"}",
"}",
"}",
"return",
"matrix",
";",
"}"
] |
Creates a matrix according to the number of new lines given into the method.
@param data an array of row data
@return the matrix.
|
[
"Creates",
"a",
"matrix",
"according",
"to",
"the",
"number",
"of",
"new",
"lines",
"given",
"into",
"the",
"method",
"."
] |
f13aa793b6a3055215ed4edbb946c1bb5d564886
|
https://github.com/sebastiangraf/perfidix/blob/f13aa793b6a3055215ed4edbb946c1bb5d564886/src/main/java/org/perfidix/ouput/asciitable/Util.java#L178-L197
|
144,638
|
JoeKerouac/utils
|
src/main/java/com/joe/utils/common/telnet/TelnetProtocolHandler.java
|
TelnetProtocolHandler.handleCommand
|
private void handleCommand(byte b) throws IOException {
if (b == SE) {
telnetCommand += (char) b;
handleNegotiation();
reset();
} else if (isWill || isDo) {
if (isWill && b == TERMINAL_TYPE) {
socketChannel
.write(ByteBuffer.wrap(new byte[] { IAC, SB, TERMINAL_TYPE, ECHO, IAC, SE }));
} else if (b != ECHO && b != GA && b != NAWS) {
telnetCommand += (char) b;
socketChannel.write(ByteBuffer.wrap(telnetCommand.getBytes()));
}
reset();
} else if (isWont || isDont) {
telnetCommand += (char) b;
socketChannel.write(ByteBuffer.wrap(telnetCommand.getBytes()));
reset();
} else if (isSb) {
telnetCommand += (char) b;
}
}
|
java
|
private void handleCommand(byte b) throws IOException {
if (b == SE) {
telnetCommand += (char) b;
handleNegotiation();
reset();
} else if (isWill || isDo) {
if (isWill && b == TERMINAL_TYPE) {
socketChannel
.write(ByteBuffer.wrap(new byte[] { IAC, SB, TERMINAL_TYPE, ECHO, IAC, SE }));
} else if (b != ECHO && b != GA && b != NAWS) {
telnetCommand += (char) b;
socketChannel.write(ByteBuffer.wrap(telnetCommand.getBytes()));
}
reset();
} else if (isWont || isDont) {
telnetCommand += (char) b;
socketChannel.write(ByteBuffer.wrap(telnetCommand.getBytes()));
reset();
} else if (isSb) {
telnetCommand += (char) b;
}
}
|
[
"private",
"void",
"handleCommand",
"(",
"byte",
"b",
")",
"throws",
"IOException",
"{",
"if",
"(",
"b",
"==",
"SE",
")",
"{",
"telnetCommand",
"+=",
"(",
"char",
")",
"b",
";",
"handleNegotiation",
"(",
")",
";",
"reset",
"(",
")",
";",
"}",
"else",
"if",
"(",
"isWill",
"||",
"isDo",
")",
"{",
"if",
"(",
"isWill",
"&&",
"b",
"==",
"TERMINAL_TYPE",
")",
"{",
"socketChannel",
".",
"write",
"(",
"ByteBuffer",
".",
"wrap",
"(",
"new",
"byte",
"[",
"]",
"{",
"IAC",
",",
"SB",
",",
"TERMINAL_TYPE",
",",
"ECHO",
",",
"IAC",
",",
"SE",
"}",
")",
")",
";",
"}",
"else",
"if",
"(",
"b",
"!=",
"ECHO",
"&&",
"b",
"!=",
"GA",
"&&",
"b",
"!=",
"NAWS",
")",
"{",
"telnetCommand",
"+=",
"(",
"char",
")",
"b",
";",
"socketChannel",
".",
"write",
"(",
"ByteBuffer",
".",
"wrap",
"(",
"telnetCommand",
".",
"getBytes",
"(",
")",
")",
")",
";",
"}",
"reset",
"(",
")",
";",
"}",
"else",
"if",
"(",
"isWont",
"||",
"isDont",
")",
"{",
"telnetCommand",
"+=",
"(",
"char",
")",
"b",
";",
"socketChannel",
".",
"write",
"(",
"ByteBuffer",
".",
"wrap",
"(",
"telnetCommand",
".",
"getBytes",
"(",
")",
")",
")",
";",
"reset",
"(",
")",
";",
"}",
"else",
"if",
"(",
"isSb",
")",
"{",
"telnetCommand",
"+=",
"(",
"char",
")",
"b",
";",
"}",
"}"
] |
Handle telnet command
@param b
|
[
"Handle",
"telnet",
"command"
] |
45e1b2dc4d736956674fc4dcbe6cf84eaee69278
|
https://github.com/JoeKerouac/utils/blob/45e1b2dc4d736956674fc4dcbe6cf84eaee69278/src/main/java/com/joe/utils/common/telnet/TelnetProtocolHandler.java#L254-L275
|
144,639
|
JoeKerouac/utils
|
src/main/java/com/joe/utils/common/telnet/TelnetProtocolHandler.java
|
TelnetProtocolHandler.handleNegotiation
|
private void handleNegotiation() throws IOException {
if (telnetCommand.contains(new String(new byte[] { TERMINAL_TYPE }))) {
// IAC SB TERMINAL_TYPE IS XXX IAC SE
boolean isSuccess = false;
clientTerminalType = telnetCommand.substring(4, telnetCommand.length() - 2);
for (String terminalType : terminalTypeMapping.keySet()) {
if (clientTerminalType.contains(terminalType)) {
isSuccess = true;
clientTerminalType = terminalType;
echoPrompt();
break;
}
}
if (!isSuccess) {
socketChannel.write(ByteBuffer.wrap("TerminalType negotiate failed.".getBytes()));
throw new RuntimeException("TerminalType negotiate failed.");
}
}
}
|
java
|
private void handleNegotiation() throws IOException {
if (telnetCommand.contains(new String(new byte[] { TERMINAL_TYPE }))) {
// IAC SB TERMINAL_TYPE IS XXX IAC SE
boolean isSuccess = false;
clientTerminalType = telnetCommand.substring(4, telnetCommand.length() - 2);
for (String terminalType : terminalTypeMapping.keySet()) {
if (clientTerminalType.contains(terminalType)) {
isSuccess = true;
clientTerminalType = terminalType;
echoPrompt();
break;
}
}
if (!isSuccess) {
socketChannel.write(ByteBuffer.wrap("TerminalType negotiate failed.".getBytes()));
throw new RuntimeException("TerminalType negotiate failed.");
}
}
}
|
[
"private",
"void",
"handleNegotiation",
"(",
")",
"throws",
"IOException",
"{",
"if",
"(",
"telnetCommand",
".",
"contains",
"(",
"new",
"String",
"(",
"new",
"byte",
"[",
"]",
"{",
"TERMINAL_TYPE",
"}",
")",
")",
")",
"{",
"// IAC SB TERMINAL_TYPE IS XXX IAC SE",
"boolean",
"isSuccess",
"=",
"false",
";",
"clientTerminalType",
"=",
"telnetCommand",
".",
"substring",
"(",
"4",
",",
"telnetCommand",
".",
"length",
"(",
")",
"-",
"2",
")",
";",
"for",
"(",
"String",
"terminalType",
":",
"terminalTypeMapping",
".",
"keySet",
"(",
")",
")",
"{",
"if",
"(",
"clientTerminalType",
".",
"contains",
"(",
"terminalType",
")",
")",
"{",
"isSuccess",
"=",
"true",
";",
"clientTerminalType",
"=",
"terminalType",
";",
"echoPrompt",
"(",
")",
";",
"break",
";",
"}",
"}",
"if",
"(",
"!",
"isSuccess",
")",
"{",
"socketChannel",
".",
"write",
"(",
"ByteBuffer",
".",
"wrap",
"(",
"\"TerminalType negotiate failed.\"",
".",
"getBytes",
"(",
")",
")",
")",
";",
"throw",
"new",
"RuntimeException",
"(",
"\"TerminalType negotiate failed.\"",
")",
";",
"}",
"}",
"}"
] |
Handle negotiation of terminal type
|
[
"Handle",
"negotiation",
"of",
"terminal",
"type"
] |
45e1b2dc4d736956674fc4dcbe6cf84eaee69278
|
https://github.com/JoeKerouac/utils/blob/45e1b2dc4d736956674fc4dcbe6cf84eaee69278/src/main/java/com/joe/utils/common/telnet/TelnetProtocolHandler.java#L280-L298
|
144,640
|
codelibs/analyzers
|
src/main/java/org/codelibs/analysis/ja/KanjiNumberFilter.java
|
KanjiNumberFilter.normalizeNumber
|
public String normalizeNumber(final String number) {
try {
final BigDecimal normalizedNumber = parseNumber(new NumberBuffer(
number));
if (normalizedNumber == null) {
return number;
}
return normalizedNumber.toBigIntegerExact().toString();
} catch (NumberFormatException | ArithmeticException e) {
// Return the source number in case of error, i.e. malformed input
return number;
}
}
|
java
|
public String normalizeNumber(final String number) {
try {
final BigDecimal normalizedNumber = parseNumber(new NumberBuffer(
number));
if (normalizedNumber == null) {
return number;
}
return normalizedNumber.toBigIntegerExact().toString();
} catch (NumberFormatException | ArithmeticException e) {
// Return the source number in case of error, i.e. malformed input
return number;
}
}
|
[
"public",
"String",
"normalizeNumber",
"(",
"final",
"String",
"number",
")",
"{",
"try",
"{",
"final",
"BigDecimal",
"normalizedNumber",
"=",
"parseNumber",
"(",
"new",
"NumberBuffer",
"(",
"number",
")",
")",
";",
"if",
"(",
"normalizedNumber",
"==",
"null",
")",
"{",
"return",
"number",
";",
"}",
"return",
"normalizedNumber",
".",
"toBigIntegerExact",
"(",
")",
".",
"toString",
"(",
")",
";",
"}",
"catch",
"(",
"NumberFormatException",
"|",
"ArithmeticException",
"e",
")",
"{",
"// Return the source number in case of error, i.e. malformed input",
"return",
"number",
";",
"}",
"}"
] |
Normalizes a Japanese number
@param number number or normalize
@return normalized number, or number to normalize on error (no op)
|
[
"Normalizes",
"a",
"Japanese",
"number"
] |
1d959f072e06c92b2b123d00a186845c19eb3a13
|
https://github.com/codelibs/analyzers/blob/1d959f072e06c92b2b123d00a186845c19eb3a13/src/main/java/org/codelibs/analysis/ja/KanjiNumberFilter.java#L189-L202
|
144,641
|
codelibs/analyzers
|
src/main/java/org/codelibs/analysis/ja/KanjiNumberFilter.java
|
KanjiNumberFilter.parseNumber
|
private BigDecimal parseNumber(final NumberBuffer buffer) {
BigDecimal sum = BigDecimal.ZERO;
BigDecimal result = parseLargePair(buffer);
if (result == null) {
return null;
}
while (result != null) {
sum = sum.add(result);
result = parseLargePair(buffer);
}
return sum;
}
|
java
|
private BigDecimal parseNumber(final NumberBuffer buffer) {
BigDecimal sum = BigDecimal.ZERO;
BigDecimal result = parseLargePair(buffer);
if (result == null) {
return null;
}
while (result != null) {
sum = sum.add(result);
result = parseLargePair(buffer);
}
return sum;
}
|
[
"private",
"BigDecimal",
"parseNumber",
"(",
"final",
"NumberBuffer",
"buffer",
")",
"{",
"BigDecimal",
"sum",
"=",
"BigDecimal",
".",
"ZERO",
";",
"BigDecimal",
"result",
"=",
"parseLargePair",
"(",
"buffer",
")",
";",
"if",
"(",
"result",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"while",
"(",
"result",
"!=",
"null",
")",
"{",
"sum",
"=",
"sum",
".",
"add",
"(",
"result",
")",
";",
"result",
"=",
"parseLargePair",
"(",
"buffer",
")",
";",
"}",
"return",
"sum",
";",
"}"
] |
Parses a Japanese number
@param buffer buffer to parse
@return parsed number, or null on error or end of input
|
[
"Parses",
"a",
"Japanese",
"number"
] |
1d959f072e06c92b2b123d00a186845c19eb3a13
|
https://github.com/codelibs/analyzers/blob/1d959f072e06c92b2b123d00a186845c19eb3a13/src/main/java/org/codelibs/analysis/ja/KanjiNumberFilter.java#L210-L224
|
144,642
|
codelibs/analyzers
|
src/main/java/org/codelibs/analysis/ja/KanjiNumberFilter.java
|
KanjiNumberFilter.isNumeralPunctuation
|
public boolean isNumeralPunctuation(final String input) {
for (int i = 0; i < input.length(); i++) {
if (!isNumeralPunctuation(input.charAt(i))) {
return false;
}
}
return true;
}
|
java
|
public boolean isNumeralPunctuation(final String input) {
for (int i = 0; i < input.length(); i++) {
if (!isNumeralPunctuation(input.charAt(i))) {
return false;
}
}
return true;
}
|
[
"public",
"boolean",
"isNumeralPunctuation",
"(",
"final",
"String",
"input",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"input",
".",
"length",
"(",
")",
";",
"i",
"++",
")",
"{",
"if",
"(",
"!",
"isNumeralPunctuation",
"(",
"input",
".",
"charAt",
"(",
"i",
")",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
] |
Numeral punctuation predicate
@param input string to test
@return true if and only if c is a numeral punctuation string
|
[
"Numeral",
"punctuation",
"predicate"
] |
1d959f072e06c92b2b123d00a186845c19eb3a13
|
https://github.com/codelibs/analyzers/blob/1d959f072e06c92b2b123d00a186845c19eb3a13/src/main/java/org/codelibs/analysis/ja/KanjiNumberFilter.java#L428-L435
|
144,643
|
michael-rapp/AndroidBottomSheet
|
library/src/main/java/de/mrapp/android/bottomsheet/view/DividableGridView.java
|
DividableGridView.adaptHeightToChildren
|
public void adaptHeightToChildren() {
DividableGridAdapter adapter = (DividableGridAdapter) getAdapter();
if (adapter != null) {
int height = getPaddingTop() + getPaddingBottom();
for (int i = 0; i < adapter.getCount(); i += adapter.getColumnCount()) {
AbstractItem item = adapter.getItem(i);
if (item instanceof Divider) {
height += getResources().getDimensionPixelSize(
TextUtils.isEmpty(item.getTitle()) ?
R.dimen.bottom_sheet_divider_height :
R.dimen.bottom_sheet_divider_title_height);
} else {
height += getResources().getDimensionPixelSize(
adapter.getStyle() == BottomSheet.Style.GRID ?
R.dimen.bottom_sheet_grid_item_size :
R.dimen.bottom_sheet_list_item_height);
}
}
ViewGroup.LayoutParams params = getLayoutParams();
params.height = height;
setLayoutParams(params);
requestLayout();
}
}
|
java
|
public void adaptHeightToChildren() {
DividableGridAdapter adapter = (DividableGridAdapter) getAdapter();
if (adapter != null) {
int height = getPaddingTop() + getPaddingBottom();
for (int i = 0; i < adapter.getCount(); i += adapter.getColumnCount()) {
AbstractItem item = adapter.getItem(i);
if (item instanceof Divider) {
height += getResources().getDimensionPixelSize(
TextUtils.isEmpty(item.getTitle()) ?
R.dimen.bottom_sheet_divider_height :
R.dimen.bottom_sheet_divider_title_height);
} else {
height += getResources().getDimensionPixelSize(
adapter.getStyle() == BottomSheet.Style.GRID ?
R.dimen.bottom_sheet_grid_item_size :
R.dimen.bottom_sheet_list_item_height);
}
}
ViewGroup.LayoutParams params = getLayoutParams();
params.height = height;
setLayoutParams(params);
requestLayout();
}
}
|
[
"public",
"void",
"adaptHeightToChildren",
"(",
")",
"{",
"DividableGridAdapter",
"adapter",
"=",
"(",
"DividableGridAdapter",
")",
"getAdapter",
"(",
")",
";",
"if",
"(",
"adapter",
"!=",
"null",
")",
"{",
"int",
"height",
"=",
"getPaddingTop",
"(",
")",
"+",
"getPaddingBottom",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"adapter",
".",
"getCount",
"(",
")",
";",
"i",
"+=",
"adapter",
".",
"getColumnCount",
"(",
")",
")",
"{",
"AbstractItem",
"item",
"=",
"adapter",
".",
"getItem",
"(",
"i",
")",
";",
"if",
"(",
"item",
"instanceof",
"Divider",
")",
"{",
"height",
"+=",
"getResources",
"(",
")",
".",
"getDimensionPixelSize",
"(",
"TextUtils",
".",
"isEmpty",
"(",
"item",
".",
"getTitle",
"(",
")",
")",
"?",
"R",
".",
"dimen",
".",
"bottom_sheet_divider_height",
":",
"R",
".",
"dimen",
".",
"bottom_sheet_divider_title_height",
")",
";",
"}",
"else",
"{",
"height",
"+=",
"getResources",
"(",
")",
".",
"getDimensionPixelSize",
"(",
"adapter",
".",
"getStyle",
"(",
")",
"==",
"BottomSheet",
".",
"Style",
".",
"GRID",
"?",
"R",
".",
"dimen",
".",
"bottom_sheet_grid_item_size",
":",
"R",
".",
"dimen",
".",
"bottom_sheet_list_item_height",
")",
";",
"}",
"}",
"ViewGroup",
".",
"LayoutParams",
"params",
"=",
"getLayoutParams",
"(",
")",
";",
"params",
".",
"height",
"=",
"height",
";",
"setLayoutParams",
"(",
"params",
")",
";",
"requestLayout",
"(",
")",
";",
"}",
"}"
] |
Adapts the height of the grid view to the height of its children.
|
[
"Adapts",
"the",
"height",
"of",
"the",
"grid",
"view",
"to",
"the",
"height",
"of",
"its",
"children",
"."
] |
6e4690ee9f63b14a7b143d3a3717b5f8a11ca503
|
https://github.com/michael-rapp/AndroidBottomSheet/blob/6e4690ee9f63b14a7b143d3a3717b5f8a11ca503/library/src/main/java/de/mrapp/android/bottomsheet/view/DividableGridView.java#L118-L145
|
144,644
|
michael-rapp/AndroidBottomSheet
|
library/src/main/java/de/mrapp/android/bottomsheet/adapter/DividableGridAdapter.java
|
DividableGridAdapter.getRawItems
|
private List<AbstractItem> getRawItems() {
if (rawItems == null) {
rawItems = new ArrayList<>();
for (int i = 0; i < items.size(); i++) {
AbstractItem item = items.get(i);
if (item instanceof Divider && columnCount > 1) {
for (int j = 0; j < rawItems.size() % columnCount; j++) {
rawItems.add(null);
}
rawItems.add(item);
for (int j = 0; j < columnCount - 1; j++) {
rawItems.add(new Divider());
}
} else {
rawItems.add(item);
}
}
}
return rawItems;
}
|
java
|
private List<AbstractItem> getRawItems() {
if (rawItems == null) {
rawItems = new ArrayList<>();
for (int i = 0; i < items.size(); i++) {
AbstractItem item = items.get(i);
if (item instanceof Divider && columnCount > 1) {
for (int j = 0; j < rawItems.size() % columnCount; j++) {
rawItems.add(null);
}
rawItems.add(item);
for (int j = 0; j < columnCount - 1; j++) {
rawItems.add(new Divider());
}
} else {
rawItems.add(item);
}
}
}
return rawItems;
}
|
[
"private",
"List",
"<",
"AbstractItem",
">",
"getRawItems",
"(",
")",
"{",
"if",
"(",
"rawItems",
"==",
"null",
")",
"{",
"rawItems",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"items",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"AbstractItem",
"item",
"=",
"items",
".",
"get",
"(",
"i",
")",
";",
"if",
"(",
"item",
"instanceof",
"Divider",
"&&",
"columnCount",
">",
"1",
")",
"{",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"rawItems",
".",
"size",
"(",
")",
"%",
"columnCount",
";",
"j",
"++",
")",
"{",
"rawItems",
".",
"add",
"(",
"null",
")",
";",
"}",
"rawItems",
".",
"add",
"(",
"item",
")",
";",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"columnCount",
"-",
"1",
";",
"j",
"++",
")",
"{",
"rawItems",
".",
"add",
"(",
"new",
"Divider",
"(",
")",
")",
";",
"}",
"}",
"else",
"{",
"rawItems",
".",
"add",
"(",
"item",
")",
";",
"}",
"}",
"}",
"return",
"rawItems",
";",
"}"
] |
Returns a list, which contains the items of the adapter including placeholders.
@return A list, which contains the items of the adapter including placeholders, as an
instance of the type {@link List} or an empty list, if the adapter contains no items
|
[
"Returns",
"a",
"list",
"which",
"contains",
"the",
"items",
"of",
"the",
"adapter",
"including",
"placeholders",
"."
] |
6e4690ee9f63b14a7b143d3a3717b5f8a11ca503
|
https://github.com/michael-rapp/AndroidBottomSheet/blob/6e4690ee9f63b14a7b143d3a3717b5f8a11ca503/library/src/main/java/de/mrapp/android/bottomsheet/adapter/DividableGridAdapter.java#L170-L194
|
144,645
|
michael-rapp/AndroidBottomSheet
|
library/src/main/java/de/mrapp/android/bottomsheet/adapter/DividableGridAdapter.java
|
DividableGridAdapter.inflateItemView
|
private View inflateItemView(@Nullable final ViewGroup parent) {
LayoutInflater layoutInflater = LayoutInflater.from(context);
View view = layoutInflater
.inflate(style == Style.GRID ? R.layout.grid_item : R.layout.list_item, parent,
false);
ItemViewHolder viewHolder = new ItemViewHolder();
viewHolder.iconImageView = view.findViewById(android.R.id.icon);
viewHolder.titleTextView = view.findViewById(android.R.id.title);
view.setTag(viewHolder);
return view;
}
|
java
|
private View inflateItemView(@Nullable final ViewGroup parent) {
LayoutInflater layoutInflater = LayoutInflater.from(context);
View view = layoutInflater
.inflate(style == Style.GRID ? R.layout.grid_item : R.layout.list_item, parent,
false);
ItemViewHolder viewHolder = new ItemViewHolder();
viewHolder.iconImageView = view.findViewById(android.R.id.icon);
viewHolder.titleTextView = view.findViewById(android.R.id.title);
view.setTag(viewHolder);
return view;
}
|
[
"private",
"View",
"inflateItemView",
"(",
"@",
"Nullable",
"final",
"ViewGroup",
"parent",
")",
"{",
"LayoutInflater",
"layoutInflater",
"=",
"LayoutInflater",
".",
"from",
"(",
"context",
")",
";",
"View",
"view",
"=",
"layoutInflater",
".",
"inflate",
"(",
"style",
"==",
"Style",
".",
"GRID",
"?",
"R",
".",
"layout",
".",
"grid_item",
":",
"R",
".",
"layout",
".",
"list_item",
",",
"parent",
",",
"false",
")",
";",
"ItemViewHolder",
"viewHolder",
"=",
"new",
"ItemViewHolder",
"(",
")",
";",
"viewHolder",
".",
"iconImageView",
"=",
"view",
".",
"findViewById",
"(",
"android",
".",
"R",
".",
"id",
".",
"icon",
")",
";",
"viewHolder",
".",
"titleTextView",
"=",
"view",
".",
"findViewById",
"(",
"android",
".",
"R",
".",
"id",
".",
"title",
")",
";",
"view",
".",
"setTag",
"(",
"viewHolder",
")",
";",
"return",
"view",
";",
"}"
] |
Inflates the view, which is used to visualize an item.
@param parent
The parent of the view, which should be inflated, as an instance of the class {@link
ViewGroup} or null, if no parent is available
@return The view, which has been inflated, as an instance of the class {@link View}
|
[
"Inflates",
"the",
"view",
"which",
"is",
"used",
"to",
"visualize",
"an",
"item",
"."
] |
6e4690ee9f63b14a7b143d3a3717b5f8a11ca503
|
https://github.com/michael-rapp/AndroidBottomSheet/blob/6e4690ee9f63b14a7b143d3a3717b5f8a11ca503/library/src/main/java/de/mrapp/android/bottomsheet/adapter/DividableGridAdapter.java#L228-L238
|
144,646
|
michael-rapp/AndroidBottomSheet
|
library/src/main/java/de/mrapp/android/bottomsheet/adapter/DividableGridAdapter.java
|
DividableGridAdapter.visualizeItem
|
@SuppressWarnings("PrimitiveArrayArgumentToVariableArgMethod")
private void visualizeItem(@NonNull final Item item, @NonNull final ItemViewHolder viewHolder) {
viewHolder.iconImageView.setVisibility(iconCount > 0 ? View.VISIBLE : View.GONE);
viewHolder.iconImageView.setEnabled(item.isEnabled());
if (item.getIcon() != null && item.getIcon() instanceof StateListDrawable) {
StateListDrawable stateListDrawable = (StateListDrawable) item.getIcon();
try {
int[] currentState = viewHolder.iconImageView.getDrawableState();
Method getStateDrawableIndex =
StateListDrawable.class.getMethod("getStateDrawableIndex", int[].class);
Method getStateDrawable =
StateListDrawable.class.getMethod("getStateDrawable", int.class);
int index = (int) getStateDrawableIndex.invoke(stateListDrawable, currentState);
Drawable drawable = (Drawable) getStateDrawable.invoke(stateListDrawable, index);
viewHolder.iconImageView.setImageDrawable(drawable);
} catch (Exception e) {
viewHolder.iconImageView.setImageDrawable(item.getIcon());
}
} else {
viewHolder.iconImageView.setImageDrawable(item.getIcon());
}
viewHolder.titleTextView.setText(item.getTitle());
viewHolder.titleTextView.setEnabled(item.isEnabled());
if (getItemColor() != -1) {
viewHolder.titleTextView.setTextColor(getItemColor());
}
}
|
java
|
@SuppressWarnings("PrimitiveArrayArgumentToVariableArgMethod")
private void visualizeItem(@NonNull final Item item, @NonNull final ItemViewHolder viewHolder) {
viewHolder.iconImageView.setVisibility(iconCount > 0 ? View.VISIBLE : View.GONE);
viewHolder.iconImageView.setEnabled(item.isEnabled());
if (item.getIcon() != null && item.getIcon() instanceof StateListDrawable) {
StateListDrawable stateListDrawable = (StateListDrawable) item.getIcon();
try {
int[] currentState = viewHolder.iconImageView.getDrawableState();
Method getStateDrawableIndex =
StateListDrawable.class.getMethod("getStateDrawableIndex", int[].class);
Method getStateDrawable =
StateListDrawable.class.getMethod("getStateDrawable", int.class);
int index = (int) getStateDrawableIndex.invoke(stateListDrawable, currentState);
Drawable drawable = (Drawable) getStateDrawable.invoke(stateListDrawable, index);
viewHolder.iconImageView.setImageDrawable(drawable);
} catch (Exception e) {
viewHolder.iconImageView.setImageDrawable(item.getIcon());
}
} else {
viewHolder.iconImageView.setImageDrawable(item.getIcon());
}
viewHolder.titleTextView.setText(item.getTitle());
viewHolder.titleTextView.setEnabled(item.isEnabled());
if (getItemColor() != -1) {
viewHolder.titleTextView.setTextColor(getItemColor());
}
}
|
[
"@",
"SuppressWarnings",
"(",
"\"PrimitiveArrayArgumentToVariableArgMethod\"",
")",
"private",
"void",
"visualizeItem",
"(",
"@",
"NonNull",
"final",
"Item",
"item",
",",
"@",
"NonNull",
"final",
"ItemViewHolder",
"viewHolder",
")",
"{",
"viewHolder",
".",
"iconImageView",
".",
"setVisibility",
"(",
"iconCount",
">",
"0",
"?",
"View",
".",
"VISIBLE",
":",
"View",
".",
"GONE",
")",
";",
"viewHolder",
".",
"iconImageView",
".",
"setEnabled",
"(",
"item",
".",
"isEnabled",
"(",
")",
")",
";",
"if",
"(",
"item",
".",
"getIcon",
"(",
")",
"!=",
"null",
"&&",
"item",
".",
"getIcon",
"(",
")",
"instanceof",
"StateListDrawable",
")",
"{",
"StateListDrawable",
"stateListDrawable",
"=",
"(",
"StateListDrawable",
")",
"item",
".",
"getIcon",
"(",
")",
";",
"try",
"{",
"int",
"[",
"]",
"currentState",
"=",
"viewHolder",
".",
"iconImageView",
".",
"getDrawableState",
"(",
")",
";",
"Method",
"getStateDrawableIndex",
"=",
"StateListDrawable",
".",
"class",
".",
"getMethod",
"(",
"\"getStateDrawableIndex\"",
",",
"int",
"[",
"]",
".",
"class",
")",
";",
"Method",
"getStateDrawable",
"=",
"StateListDrawable",
".",
"class",
".",
"getMethod",
"(",
"\"getStateDrawable\"",
",",
"int",
".",
"class",
")",
";",
"int",
"index",
"=",
"(",
"int",
")",
"getStateDrawableIndex",
".",
"invoke",
"(",
"stateListDrawable",
",",
"currentState",
")",
";",
"Drawable",
"drawable",
"=",
"(",
"Drawable",
")",
"getStateDrawable",
".",
"invoke",
"(",
"stateListDrawable",
",",
"index",
")",
";",
"viewHolder",
".",
"iconImageView",
".",
"setImageDrawable",
"(",
"drawable",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"viewHolder",
".",
"iconImageView",
".",
"setImageDrawable",
"(",
"item",
".",
"getIcon",
"(",
")",
")",
";",
"}",
"}",
"else",
"{",
"viewHolder",
".",
"iconImageView",
".",
"setImageDrawable",
"(",
"item",
".",
"getIcon",
"(",
")",
")",
";",
"}",
"viewHolder",
".",
"titleTextView",
".",
"setText",
"(",
"item",
".",
"getTitle",
"(",
")",
")",
";",
"viewHolder",
".",
"titleTextView",
".",
"setEnabled",
"(",
"item",
".",
"isEnabled",
"(",
")",
")",
";",
"if",
"(",
"getItemColor",
"(",
")",
"!=",
"-",
"1",
")",
"{",
"viewHolder",
".",
"titleTextView",
".",
"setTextColor",
"(",
"getItemColor",
"(",
")",
")",
";",
"}",
"}"
] |
Visualizes a specific item.
@param item
The item, which should be visualized, as an instance of the class {@link Item}. The
item may not be null
@param viewHolder
The view holder, which contains the views, which should be used to visualize the
item, as an instance of the class {@link ItemViewHolder}. The view holder may not be
null
|
[
"Visualizes",
"a",
"specific",
"item",
"."
] |
6e4690ee9f63b14a7b143d3a3717b5f8a11ca503
|
https://github.com/michael-rapp/AndroidBottomSheet/blob/6e4690ee9f63b14a7b143d3a3717b5f8a11ca503/library/src/main/java/de/mrapp/android/bottomsheet/adapter/DividableGridAdapter.java#L251-L281
|
144,647
|
michael-rapp/AndroidBottomSheet
|
library/src/main/java/de/mrapp/android/bottomsheet/adapter/DividableGridAdapter.java
|
DividableGridAdapter.inflateDividerView
|
private View inflateDividerView(@Nullable final ViewGroup parent,
@NonNull final Divider divider, final int position) {
LayoutInflater layoutInflater = LayoutInflater.from(context);
View view = layoutInflater.inflate(R.layout.divider, parent, false);
DividerViewHolder viewHolder = new DividerViewHolder();
viewHolder.leftDivider = view.findViewById(R.id.left_divider);
viewHolder.rightDivider = view.findViewById(R.id.right_divider);
viewHolder.titleTextView = view.findViewById(android.R.id.title);
view.setTag(viewHolder);
if (!TextUtils.isEmpty(divider.getTitle()) || (position % columnCount > 0 && !TextUtils
.isEmpty(getRawItems().get(position - (position % columnCount)).getTitle()))) {
view.getLayoutParams().height = context.getResources()
.getDimensionPixelSize(R.dimen.bottom_sheet_divider_title_height);
}
return view;
}
|
java
|
private View inflateDividerView(@Nullable final ViewGroup parent,
@NonNull final Divider divider, final int position) {
LayoutInflater layoutInflater = LayoutInflater.from(context);
View view = layoutInflater.inflate(R.layout.divider, parent, false);
DividerViewHolder viewHolder = new DividerViewHolder();
viewHolder.leftDivider = view.findViewById(R.id.left_divider);
viewHolder.rightDivider = view.findViewById(R.id.right_divider);
viewHolder.titleTextView = view.findViewById(android.R.id.title);
view.setTag(viewHolder);
if (!TextUtils.isEmpty(divider.getTitle()) || (position % columnCount > 0 && !TextUtils
.isEmpty(getRawItems().get(position - (position % columnCount)).getTitle()))) {
view.getLayoutParams().height = context.getResources()
.getDimensionPixelSize(R.dimen.bottom_sheet_divider_title_height);
}
return view;
}
|
[
"private",
"View",
"inflateDividerView",
"(",
"@",
"Nullable",
"final",
"ViewGroup",
"parent",
",",
"@",
"NonNull",
"final",
"Divider",
"divider",
",",
"final",
"int",
"position",
")",
"{",
"LayoutInflater",
"layoutInflater",
"=",
"LayoutInflater",
".",
"from",
"(",
"context",
")",
";",
"View",
"view",
"=",
"layoutInflater",
".",
"inflate",
"(",
"R",
".",
"layout",
".",
"divider",
",",
"parent",
",",
"false",
")",
";",
"DividerViewHolder",
"viewHolder",
"=",
"new",
"DividerViewHolder",
"(",
")",
";",
"viewHolder",
".",
"leftDivider",
"=",
"view",
".",
"findViewById",
"(",
"R",
".",
"id",
".",
"left_divider",
")",
";",
"viewHolder",
".",
"rightDivider",
"=",
"view",
".",
"findViewById",
"(",
"R",
".",
"id",
".",
"right_divider",
")",
";",
"viewHolder",
".",
"titleTextView",
"=",
"view",
".",
"findViewById",
"(",
"android",
".",
"R",
".",
"id",
".",
"title",
")",
";",
"view",
".",
"setTag",
"(",
"viewHolder",
")",
";",
"if",
"(",
"!",
"TextUtils",
".",
"isEmpty",
"(",
"divider",
".",
"getTitle",
"(",
")",
")",
"||",
"(",
"position",
"%",
"columnCount",
">",
"0",
"&&",
"!",
"TextUtils",
".",
"isEmpty",
"(",
"getRawItems",
"(",
")",
".",
"get",
"(",
"position",
"-",
"(",
"position",
"%",
"columnCount",
")",
")",
".",
"getTitle",
"(",
")",
")",
")",
")",
"{",
"view",
".",
"getLayoutParams",
"(",
")",
".",
"height",
"=",
"context",
".",
"getResources",
"(",
")",
".",
"getDimensionPixelSize",
"(",
"R",
".",
"dimen",
".",
"bottom_sheet_divider_title_height",
")",
";",
"}",
"return",
"view",
";",
"}"
] |
Inflates the view, which is used to visualize a divider.
@param parent
The parent of the view, which should be inflated, as an instance of the class {@link
ViewGroup} or null, if no parent is available
@param divider
The divider, which should be visualized, as an instance of the class {@link Divider}.
The divider may not be null
@param position
The position of the divider, which should be visualized, as an {@link Integer} value
@return The view, which has been inflated, as an instance of the class {@link View}
|
[
"Inflates",
"the",
"view",
"which",
"is",
"used",
"to",
"visualize",
"a",
"divider",
"."
] |
6e4690ee9f63b14a7b143d3a3717b5f8a11ca503
|
https://github.com/michael-rapp/AndroidBottomSheet/blob/6e4690ee9f63b14a7b143d3a3717b5f8a11ca503/library/src/main/java/de/mrapp/android/bottomsheet/adapter/DividableGridAdapter.java#L296-L313
|
144,648
|
michael-rapp/AndroidBottomSheet
|
library/src/main/java/de/mrapp/android/bottomsheet/adapter/DividableGridAdapter.java
|
DividableGridAdapter.visualizeDivider
|
private void visualizeDivider(@NonNull final Divider divider,
@NonNull final DividerViewHolder viewHolder) {
if (!TextUtils.isEmpty(divider.getTitle())) {
viewHolder.titleTextView.setText(divider.getTitle());
viewHolder.titleTextView.setVisibility(View.VISIBLE);
viewHolder.leftDivider.setVisibility(View.VISIBLE);
} else {
viewHolder.titleTextView.setVisibility(View.GONE);
viewHolder.leftDivider.setVisibility(View.GONE);
}
if (dividerColor != -1) {
viewHolder.titleTextView.setTextColor(dividerColor);
viewHolder.leftDivider.setBackgroundColor(dividerColor);
viewHolder.rightDivider.setBackgroundColor(dividerColor);
}
}
|
java
|
private void visualizeDivider(@NonNull final Divider divider,
@NonNull final DividerViewHolder viewHolder) {
if (!TextUtils.isEmpty(divider.getTitle())) {
viewHolder.titleTextView.setText(divider.getTitle());
viewHolder.titleTextView.setVisibility(View.VISIBLE);
viewHolder.leftDivider.setVisibility(View.VISIBLE);
} else {
viewHolder.titleTextView.setVisibility(View.GONE);
viewHolder.leftDivider.setVisibility(View.GONE);
}
if (dividerColor != -1) {
viewHolder.titleTextView.setTextColor(dividerColor);
viewHolder.leftDivider.setBackgroundColor(dividerColor);
viewHolder.rightDivider.setBackgroundColor(dividerColor);
}
}
|
[
"private",
"void",
"visualizeDivider",
"(",
"@",
"NonNull",
"final",
"Divider",
"divider",
",",
"@",
"NonNull",
"final",
"DividerViewHolder",
"viewHolder",
")",
"{",
"if",
"(",
"!",
"TextUtils",
".",
"isEmpty",
"(",
"divider",
".",
"getTitle",
"(",
")",
")",
")",
"{",
"viewHolder",
".",
"titleTextView",
".",
"setText",
"(",
"divider",
".",
"getTitle",
"(",
")",
")",
";",
"viewHolder",
".",
"titleTextView",
".",
"setVisibility",
"(",
"View",
".",
"VISIBLE",
")",
";",
"viewHolder",
".",
"leftDivider",
".",
"setVisibility",
"(",
"View",
".",
"VISIBLE",
")",
";",
"}",
"else",
"{",
"viewHolder",
".",
"titleTextView",
".",
"setVisibility",
"(",
"View",
".",
"GONE",
")",
";",
"viewHolder",
".",
"leftDivider",
".",
"setVisibility",
"(",
"View",
".",
"GONE",
")",
";",
"}",
"if",
"(",
"dividerColor",
"!=",
"-",
"1",
")",
"{",
"viewHolder",
".",
"titleTextView",
".",
"setTextColor",
"(",
"dividerColor",
")",
";",
"viewHolder",
".",
"leftDivider",
".",
"setBackgroundColor",
"(",
"dividerColor",
")",
";",
"viewHolder",
".",
"rightDivider",
".",
"setBackgroundColor",
"(",
"dividerColor",
")",
";",
"}",
"}"
] |
Visualizes a specific divider.
@param divider
The divider, which should be visualized, as an instance of the class {@link Divider}.
The divider may not be null
@param viewHolder
The view holder, which contains the views, which should be used to visualize the
divider, as an instance of the class {@link DividerViewHolder}. The view holder may
not be null
|
[
"Visualizes",
"a",
"specific",
"divider",
"."
] |
6e4690ee9f63b14a7b143d3a3717b5f8a11ca503
|
https://github.com/michael-rapp/AndroidBottomSheet/blob/6e4690ee9f63b14a7b143d3a3717b5f8a11ca503/library/src/main/java/de/mrapp/android/bottomsheet/adapter/DividableGridAdapter.java#L326-L342
|
144,649
|
michael-rapp/AndroidBottomSheet
|
library/src/main/java/de/mrapp/android/bottomsheet/adapter/DividableGridAdapter.java
|
DividableGridAdapter.setStyle
|
public final void setStyle(@NonNull final Style style) {
Condition.INSTANCE.ensureNotNull(style, "The style may not be null");
this.style = style;
this.rawItems = null;
notifyDataSetChanged();
}
|
java
|
public final void setStyle(@NonNull final Style style) {
Condition.INSTANCE.ensureNotNull(style, "The style may not be null");
this.style = style;
this.rawItems = null;
notifyDataSetChanged();
}
|
[
"public",
"final",
"void",
"setStyle",
"(",
"@",
"NonNull",
"final",
"Style",
"style",
")",
"{",
"Condition",
".",
"INSTANCE",
".",
"ensureNotNull",
"(",
"style",
",",
"\"The style may not be null\"",
")",
";",
"this",
".",
"style",
"=",
"style",
";",
"this",
".",
"rawItems",
"=",
"null",
";",
"notifyDataSetChanged",
"(",
")",
";",
"}"
] |
Sets the style, which should be used to display the adapter's items.
@param style
The style, which should be set, as a value of the enum {@link Style}. The style may
either be <code>LIST</code>, <code>LIST_COLUMNS</code> or <code>GRID</code>
|
[
"Sets",
"the",
"style",
"which",
"should",
"be",
"used",
"to",
"display",
"the",
"adapter",
"s",
"items",
"."
] |
6e4690ee9f63b14a7b143d3a3717b5f8a11ca503
|
https://github.com/michael-rapp/AndroidBottomSheet/blob/6e4690ee9f63b14a7b143d3a3717b5f8a11ca503/library/src/main/java/de/mrapp/android/bottomsheet/adapter/DividableGridAdapter.java#L392-L397
|
144,650
|
michael-rapp/AndroidBottomSheet
|
library/src/main/java/de/mrapp/android/bottomsheet/adapter/DividableGridAdapter.java
|
DividableGridAdapter.setWidth
|
public final void setWidth(final int width) {
if (style == Style.LIST_COLUMNS && (getDeviceType(context) == DeviceType.TABLET ||
getOrientation(context) == Orientation.LANDSCAPE)) {
columnCount = 2;
} else if (style == Style.GRID) {
int padding = context.getResources()
.getDimensionPixelSize(R.dimen.bottom_sheet_grid_item_horizontal_padding);
int itemSize = context.getResources()
.getDimensionPixelSize(R.dimen.bottom_sheet_grid_item_size);
columnCount = ((getDeviceType(context) != DeviceType.TABLET &&
context.getResources().getConfiguration().orientation ==
Configuration.ORIENTATION_PORTRAIT ?
context.getResources().getDisplayMetrics().widthPixels : width) - 2 * padding) /
itemSize;
} else {
columnCount = 1;
}
rawItems = null;
notifyDataSetChanged();
}
|
java
|
public final void setWidth(final int width) {
if (style == Style.LIST_COLUMNS && (getDeviceType(context) == DeviceType.TABLET ||
getOrientation(context) == Orientation.LANDSCAPE)) {
columnCount = 2;
} else if (style == Style.GRID) {
int padding = context.getResources()
.getDimensionPixelSize(R.dimen.bottom_sheet_grid_item_horizontal_padding);
int itemSize = context.getResources()
.getDimensionPixelSize(R.dimen.bottom_sheet_grid_item_size);
columnCount = ((getDeviceType(context) != DeviceType.TABLET &&
context.getResources().getConfiguration().orientation ==
Configuration.ORIENTATION_PORTRAIT ?
context.getResources().getDisplayMetrics().widthPixels : width) - 2 * padding) /
itemSize;
} else {
columnCount = 1;
}
rawItems = null;
notifyDataSetChanged();
}
|
[
"public",
"final",
"void",
"setWidth",
"(",
"final",
"int",
"width",
")",
"{",
"if",
"(",
"style",
"==",
"Style",
".",
"LIST_COLUMNS",
"&&",
"(",
"getDeviceType",
"(",
"context",
")",
"==",
"DeviceType",
".",
"TABLET",
"||",
"getOrientation",
"(",
"context",
")",
"==",
"Orientation",
".",
"LANDSCAPE",
")",
")",
"{",
"columnCount",
"=",
"2",
";",
"}",
"else",
"if",
"(",
"style",
"==",
"Style",
".",
"GRID",
")",
"{",
"int",
"padding",
"=",
"context",
".",
"getResources",
"(",
")",
".",
"getDimensionPixelSize",
"(",
"R",
".",
"dimen",
".",
"bottom_sheet_grid_item_horizontal_padding",
")",
";",
"int",
"itemSize",
"=",
"context",
".",
"getResources",
"(",
")",
".",
"getDimensionPixelSize",
"(",
"R",
".",
"dimen",
".",
"bottom_sheet_grid_item_size",
")",
";",
"columnCount",
"=",
"(",
"(",
"getDeviceType",
"(",
"context",
")",
"!=",
"DeviceType",
".",
"TABLET",
"&&",
"context",
".",
"getResources",
"(",
")",
".",
"getConfiguration",
"(",
")",
".",
"orientation",
"==",
"Configuration",
".",
"ORIENTATION_PORTRAIT",
"?",
"context",
".",
"getResources",
"(",
")",
".",
"getDisplayMetrics",
"(",
")",
".",
"widthPixels",
":",
"width",
")",
"-",
"2",
"*",
"padding",
")",
"/",
"itemSize",
";",
"}",
"else",
"{",
"columnCount",
"=",
"1",
";",
"}",
"rawItems",
"=",
"null",
";",
"notifyDataSetChanged",
"(",
")",
";",
"}"
] |
Sets the width of the bottom sheet, the items, which are displayed by the adapter, belong
to.
@param width
The width, which should be set, as an {@link Integer} value
|
[
"Sets",
"the",
"width",
"of",
"the",
"bottom",
"sheet",
"the",
"items",
"which",
"are",
"displayed",
"by",
"the",
"adapter",
"belong",
"to",
"."
] |
6e4690ee9f63b14a7b143d3a3717b5f8a11ca503
|
https://github.com/michael-rapp/AndroidBottomSheet/blob/6e4690ee9f63b14a7b143d3a3717b5f8a11ca503/library/src/main/java/de/mrapp/android/bottomsheet/adapter/DividableGridAdapter.java#L406-L426
|
144,651
|
michael-rapp/AndroidBottomSheet
|
library/src/main/java/de/mrapp/android/bottomsheet/adapter/DividableGridAdapter.java
|
DividableGridAdapter.add
|
public final void add(@NonNull final AbstractItem item) {
Condition.INSTANCE.ensureNotNull(item, "The item may not be null");
items.add(item);
if (item instanceof Item && ((Item) item).getIcon() != null) {
iconCount++;
} else if (item instanceof Divider) {
dividerCount++;
}
rawItems = null;
notifyOnDataSetChanged();
}
|
java
|
public final void add(@NonNull final AbstractItem item) {
Condition.INSTANCE.ensureNotNull(item, "The item may not be null");
items.add(item);
if (item instanceof Item && ((Item) item).getIcon() != null) {
iconCount++;
} else if (item instanceof Divider) {
dividerCount++;
}
rawItems = null;
notifyOnDataSetChanged();
}
|
[
"public",
"final",
"void",
"add",
"(",
"@",
"NonNull",
"final",
"AbstractItem",
"item",
")",
"{",
"Condition",
".",
"INSTANCE",
".",
"ensureNotNull",
"(",
"item",
",",
"\"The item may not be null\"",
")",
";",
"items",
".",
"add",
"(",
"item",
")",
";",
"if",
"(",
"item",
"instanceof",
"Item",
"&&",
"(",
"(",
"Item",
")",
"item",
")",
".",
"getIcon",
"(",
")",
"!=",
"null",
")",
"{",
"iconCount",
"++",
";",
"}",
"else",
"if",
"(",
"item",
"instanceof",
"Divider",
")",
"{",
"dividerCount",
"++",
";",
"}",
"rawItems",
"=",
"null",
";",
"notifyOnDataSetChanged",
"(",
")",
";",
"}"
] |
Adds a new item to the adapter.
@param item
The item, which should be added, as an instance of the class {@link AbstractItem}.
The item may not be null
|
[
"Adds",
"a",
"new",
"item",
"to",
"the",
"adapter",
"."
] |
6e4690ee9f63b14a7b143d3a3717b5f8a11ca503
|
https://github.com/michael-rapp/AndroidBottomSheet/blob/6e4690ee9f63b14a7b143d3a3717b5f8a11ca503/library/src/main/java/de/mrapp/android/bottomsheet/adapter/DividableGridAdapter.java#L495-L507
|
144,652
|
michael-rapp/AndroidBottomSheet
|
library/src/main/java/de/mrapp/android/bottomsheet/adapter/DividableGridAdapter.java
|
DividableGridAdapter.set
|
public final void set(final int index, @NonNull final AbstractItem item) {
Condition.INSTANCE.ensureNotNull(item, "The item may not be null");
AbstractItem replacedItem = items.set(index, item);
if (replacedItem instanceof Item && ((Item) replacedItem).getIcon() != null) {
iconCount--;
} else if (replacedItem instanceof Divider) {
dividerCount--;
}
if (item instanceof Item && ((Item) item).getIcon() != null) {
iconCount++;
} else if (item instanceof Divider) {
dividerCount++;
}
rawItems = null;
notifyOnDataSetChanged();
}
|
java
|
public final void set(final int index, @NonNull final AbstractItem item) {
Condition.INSTANCE.ensureNotNull(item, "The item may not be null");
AbstractItem replacedItem = items.set(index, item);
if (replacedItem instanceof Item && ((Item) replacedItem).getIcon() != null) {
iconCount--;
} else if (replacedItem instanceof Divider) {
dividerCount--;
}
if (item instanceof Item && ((Item) item).getIcon() != null) {
iconCount++;
} else if (item instanceof Divider) {
dividerCount++;
}
rawItems = null;
notifyOnDataSetChanged();
}
|
[
"public",
"final",
"void",
"set",
"(",
"final",
"int",
"index",
",",
"@",
"NonNull",
"final",
"AbstractItem",
"item",
")",
"{",
"Condition",
".",
"INSTANCE",
".",
"ensureNotNull",
"(",
"item",
",",
"\"The item may not be null\"",
")",
";",
"AbstractItem",
"replacedItem",
"=",
"items",
".",
"set",
"(",
"index",
",",
"item",
")",
";",
"if",
"(",
"replacedItem",
"instanceof",
"Item",
"&&",
"(",
"(",
"Item",
")",
"replacedItem",
")",
".",
"getIcon",
"(",
")",
"!=",
"null",
")",
"{",
"iconCount",
"--",
";",
"}",
"else",
"if",
"(",
"replacedItem",
"instanceof",
"Divider",
")",
"{",
"dividerCount",
"--",
";",
"}",
"if",
"(",
"item",
"instanceof",
"Item",
"&&",
"(",
"(",
"Item",
")",
"item",
")",
".",
"getIcon",
"(",
")",
"!=",
"null",
")",
"{",
"iconCount",
"++",
";",
"}",
"else",
"if",
"(",
"item",
"instanceof",
"Divider",
")",
"{",
"dividerCount",
"++",
";",
"}",
"rawItems",
"=",
"null",
";",
"notifyOnDataSetChanged",
"(",
")",
";",
"}"
] |
Replaces the item with at a specific index
@param index
The index of the item, which should be replaced, as an {@link Integer} value
@param item
The item, which should be set, as an instance of the class {@link AbstractItem}. The
item may not be null
|
[
"Replaces",
"the",
"item",
"with",
"at",
"a",
"specific",
"index"
] |
6e4690ee9f63b14a7b143d3a3717b5f8a11ca503
|
https://github.com/michael-rapp/AndroidBottomSheet/blob/6e4690ee9f63b14a7b143d3a3717b5f8a11ca503/library/src/main/java/de/mrapp/android/bottomsheet/adapter/DividableGridAdapter.java#L518-L536
|
144,653
|
michael-rapp/AndroidBottomSheet
|
library/src/main/java/de/mrapp/android/bottomsheet/adapter/DividableGridAdapter.java
|
DividableGridAdapter.remove
|
public final void remove(final int index) {
AbstractItem removedItem = items.remove(index);
if (removedItem instanceof Item && ((Item) removedItem).getIcon() != null) {
iconCount--;
} else if (removedItem instanceof Divider) {
dividerCount--;
}
rawItems = null;
notifyOnDataSetChanged();
}
|
java
|
public final void remove(final int index) {
AbstractItem removedItem = items.remove(index);
if (removedItem instanceof Item && ((Item) removedItem).getIcon() != null) {
iconCount--;
} else if (removedItem instanceof Divider) {
dividerCount--;
}
rawItems = null;
notifyOnDataSetChanged();
}
|
[
"public",
"final",
"void",
"remove",
"(",
"final",
"int",
"index",
")",
"{",
"AbstractItem",
"removedItem",
"=",
"items",
".",
"remove",
"(",
"index",
")",
";",
"if",
"(",
"removedItem",
"instanceof",
"Item",
"&&",
"(",
"(",
"Item",
")",
"removedItem",
")",
".",
"getIcon",
"(",
")",
"!=",
"null",
")",
"{",
"iconCount",
"--",
";",
"}",
"else",
"if",
"(",
"removedItem",
"instanceof",
"Divider",
")",
"{",
"dividerCount",
"--",
";",
"}",
"rawItems",
"=",
"null",
";",
"notifyOnDataSetChanged",
"(",
")",
";",
"}"
] |
Removes the item at a specific index.
@param index
The index of the item, which should be removed, as an {@link Integer} value
|
[
"Removes",
"the",
"item",
"at",
"a",
"specific",
"index",
"."
] |
6e4690ee9f63b14a7b143d3a3717b5f8a11ca503
|
https://github.com/michael-rapp/AndroidBottomSheet/blob/6e4690ee9f63b14a7b143d3a3717b5f8a11ca503/library/src/main/java/de/mrapp/android/bottomsheet/adapter/DividableGridAdapter.java#L544-L555
|
144,654
|
michael-rapp/AndroidBottomSheet
|
library/src/main/java/de/mrapp/android/bottomsheet/adapter/DividableGridAdapter.java
|
DividableGridAdapter.clear
|
public final void clear() {
items.clear();
iconCount = 0;
dividerCount = 0;
if (rawItems != null) {
rawItems.clear();
}
notifyOnDataSetChanged();
}
|
java
|
public final void clear() {
items.clear();
iconCount = 0;
dividerCount = 0;
if (rawItems != null) {
rawItems.clear();
}
notifyOnDataSetChanged();
}
|
[
"public",
"final",
"void",
"clear",
"(",
")",
"{",
"items",
".",
"clear",
"(",
")",
";",
"iconCount",
"=",
"0",
";",
"dividerCount",
"=",
"0",
";",
"if",
"(",
"rawItems",
"!=",
"null",
")",
"{",
"rawItems",
".",
"clear",
"(",
")",
";",
"}",
"notifyOnDataSetChanged",
"(",
")",
";",
"}"
] |
Removes all items from the adapter.
|
[
"Removes",
"all",
"items",
"from",
"the",
"adapter",
"."
] |
6e4690ee9f63b14a7b143d3a3717b5f8a11ca503
|
https://github.com/michael-rapp/AndroidBottomSheet/blob/6e4690ee9f63b14a7b143d3a3717b5f8a11ca503/library/src/main/java/de/mrapp/android/bottomsheet/adapter/DividableGridAdapter.java#L560-L570
|
144,655
|
michael-rapp/AndroidBottomSheet
|
library/src/main/java/de/mrapp/android/bottomsheet/adapter/DividableGridAdapter.java
|
DividableGridAdapter.isItemEnabled
|
public final boolean isItemEnabled(final int index) {
AbstractItem item = items.get(index);
return item instanceof Item && ((Item) item).isEnabled();
}
|
java
|
public final boolean isItemEnabled(final int index) {
AbstractItem item = items.get(index);
return item instanceof Item && ((Item) item).isEnabled();
}
|
[
"public",
"final",
"boolean",
"isItemEnabled",
"(",
"final",
"int",
"index",
")",
"{",
"AbstractItem",
"item",
"=",
"items",
".",
"get",
"(",
"index",
")",
";",
"return",
"item",
"instanceof",
"Item",
"&&",
"(",
"(",
"Item",
")",
"item",
")",
".",
"isEnabled",
"(",
")",
";",
"}"
] |
Returns, whether the item at a specific index is enabled, or not.
@param index
The index of the item, which should be checked, as an {@link Integer} value
@return True, if the item is enabled, false otherwise
|
[
"Returns",
"whether",
"the",
"item",
"at",
"a",
"specific",
"index",
"is",
"enabled",
"or",
"not",
"."
] |
6e4690ee9f63b14a7b143d3a3717b5f8a11ca503
|
https://github.com/michael-rapp/AndroidBottomSheet/blob/6e4690ee9f63b14a7b143d3a3717b5f8a11ca503/library/src/main/java/de/mrapp/android/bottomsheet/adapter/DividableGridAdapter.java#L586-L589
|
144,656
|
michael-rapp/AndroidBottomSheet
|
library/src/main/java/de/mrapp/android/bottomsheet/adapter/DividableGridAdapter.java
|
DividableGridAdapter.setItemEnabled
|
public final void setItemEnabled(final int index, final boolean enabled) {
AbstractItem item = items.get(index);
if (item instanceof Item) {
((Item) item).setEnabled(enabled);
rawItems = null;
notifyOnDataSetChanged();
}
}
|
java
|
public final void setItemEnabled(final int index, final boolean enabled) {
AbstractItem item = items.get(index);
if (item instanceof Item) {
((Item) item).setEnabled(enabled);
rawItems = null;
notifyOnDataSetChanged();
}
}
|
[
"public",
"final",
"void",
"setItemEnabled",
"(",
"final",
"int",
"index",
",",
"final",
"boolean",
"enabled",
")",
"{",
"AbstractItem",
"item",
"=",
"items",
".",
"get",
"(",
"index",
")",
";",
"if",
"(",
"item",
"instanceof",
"Item",
")",
"{",
"(",
"(",
"Item",
")",
"item",
")",
".",
"setEnabled",
"(",
"enabled",
")",
";",
"rawItems",
"=",
"null",
";",
"notifyOnDataSetChanged",
"(",
")",
";",
"}",
"}"
] |
Sets, whether the item at a specific index should be enabled, or not.
@param index
The index of the item as an {@link Integer} value
@param enabled
True, if the item should be enabled, false otherwise
|
[
"Sets",
"whether",
"the",
"item",
"at",
"a",
"specific",
"index",
"should",
"be",
"enabled",
"or",
"not",
"."
] |
6e4690ee9f63b14a7b143d3a3717b5f8a11ca503
|
https://github.com/michael-rapp/AndroidBottomSheet/blob/6e4690ee9f63b14a7b143d3a3717b5f8a11ca503/library/src/main/java/de/mrapp/android/bottomsheet/adapter/DividableGridAdapter.java#L599-L607
|
144,657
|
michael-rapp/AndroidBottomSheet
|
library/src/main/java/de/mrapp/android/bottomsheet/model/Divider.java
|
Divider.setTitle
|
public final void setTitle(@NonNull final Context context, @StringRes final int resourceId) {
setTitle(context.getText(resourceId));
}
|
java
|
public final void setTitle(@NonNull final Context context, @StringRes final int resourceId) {
setTitle(context.getText(resourceId));
}
|
[
"public",
"final",
"void",
"setTitle",
"(",
"@",
"NonNull",
"final",
"Context",
"context",
",",
"@",
"StringRes",
"final",
"int",
"resourceId",
")",
"{",
"setTitle",
"(",
"context",
".",
"getText",
"(",
"resourceId",
")",
")",
";",
"}"
] |
Sets the divider's title.
@param context
The context, which should be used, as an instance of the class {@link Context}. The
context may not be null
@param resourceId
The resource id of the title, which should be set, as an {@link Integer} value. The
resource id must correspond to a valid string resource
|
[
"Sets",
"the",
"divider",
"s",
"title",
"."
] |
6e4690ee9f63b14a7b143d3a3717b5f8a11ca503
|
https://github.com/michael-rapp/AndroidBottomSheet/blob/6e4690ee9f63b14a7b143d3a3717b5f8a11ca503/library/src/main/java/de/mrapp/android/bottomsheet/model/Divider.java#L55-L57
|
144,658
|
michael-rapp/AndroidBottomSheet
|
library/src/main/java/de/mrapp/android/bottomsheet/view/DraggableView.java
|
DraggableView.isScrollUpEvent
|
private boolean isScrollUpEvent(final float x, final float y,
@NonNull final ViewGroup viewGroup) {
int location[] = new int[2];
viewGroup.getLocationOnScreen(location);
if (x >= location[0] && x <= location[0] + viewGroup.getWidth() && y >= location[1] &&
y <= location[1] + viewGroup.getHeight()) {
for (int i = 0; i < viewGroup.getChildCount(); i++) {
View view = viewGroup.getChildAt(i);
if (view.canScrollVertically(-1)) {
return true;
} else if (view instanceof ViewGroup) {
return isScrollUpEvent(x, y, (ViewGroup) view);
}
}
}
return false;
}
|
java
|
private boolean isScrollUpEvent(final float x, final float y,
@NonNull final ViewGroup viewGroup) {
int location[] = new int[2];
viewGroup.getLocationOnScreen(location);
if (x >= location[0] && x <= location[0] + viewGroup.getWidth() && y >= location[1] &&
y <= location[1] + viewGroup.getHeight()) {
for (int i = 0; i < viewGroup.getChildCount(); i++) {
View view = viewGroup.getChildAt(i);
if (view.canScrollVertically(-1)) {
return true;
} else if (view instanceof ViewGroup) {
return isScrollUpEvent(x, y, (ViewGroup) view);
}
}
}
return false;
}
|
[
"private",
"boolean",
"isScrollUpEvent",
"(",
"final",
"float",
"x",
",",
"final",
"float",
"y",
",",
"@",
"NonNull",
"final",
"ViewGroup",
"viewGroup",
")",
"{",
"int",
"location",
"[",
"]",
"=",
"new",
"int",
"[",
"2",
"]",
";",
"viewGroup",
".",
"getLocationOnScreen",
"(",
"location",
")",
";",
"if",
"(",
"x",
">=",
"location",
"[",
"0",
"]",
"&&",
"x",
"<=",
"location",
"[",
"0",
"]",
"+",
"viewGroup",
".",
"getWidth",
"(",
")",
"&&",
"y",
">=",
"location",
"[",
"1",
"]",
"&&",
"y",
"<=",
"location",
"[",
"1",
"]",
"+",
"viewGroup",
".",
"getHeight",
"(",
")",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"viewGroup",
".",
"getChildCount",
"(",
")",
";",
"i",
"++",
")",
"{",
"View",
"view",
"=",
"viewGroup",
".",
"getChildAt",
"(",
"i",
")",
";",
"if",
"(",
"view",
".",
"canScrollVertically",
"(",
"-",
"1",
")",
")",
"{",
"return",
"true",
";",
"}",
"else",
"if",
"(",
"view",
"instanceof",
"ViewGroup",
")",
"{",
"return",
"isScrollUpEvent",
"(",
"x",
",",
"y",
",",
"(",
"ViewGroup",
")",
"view",
")",
";",
"}",
"}",
"}",
"return",
"false",
";",
"}"
] |
Returns, whether a touch event at a specific position targets a view, which can be scrolled
up.
@param x
The horizontal position of the touch event in pixels as a {@link Float} value
@param y
The vertical position of the touch event in pixels as a {@link Float} value
@param viewGroup
The view group, which should be used to search for scrollable child views, as an
instance of the class {@link ViewGroup}. The view group may not be null
@return True, if the touch event targets a view, which can be scrolled up, false otherwise
|
[
"Returns",
"whether",
"a",
"touch",
"event",
"at",
"a",
"specific",
"position",
"targets",
"a",
"view",
"which",
"can",
"be",
"scrolled",
"up",
"."
] |
6e4690ee9f63b14a7b143d3a3717b5f8a11ca503
|
https://github.com/michael-rapp/AndroidBottomSheet/blob/6e4690ee9f63b14a7b143d3a3717b5f8a11ca503/library/src/main/java/de/mrapp/android/bottomsheet/view/DraggableView.java#L166-L185
|
144,659
|
michael-rapp/AndroidBottomSheet
|
library/src/main/java/de/mrapp/android/bottomsheet/view/DraggableView.java
|
DraggableView.handleDrag
|
private boolean handleDrag() {
if (!isAnimationRunning()) {
if (dragHelper.hasThresholdBeenReached()) {
int margin = Math.round(isMaximized() ? dragHelper.getDragDistance() :
initialMargin + dragHelper.getDragDistance());
margin = Math.max(Math.max(margin, minMargin), 0);
setTopMargin(margin);
}
return true;
}
return false;
}
|
java
|
private boolean handleDrag() {
if (!isAnimationRunning()) {
if (dragHelper.hasThresholdBeenReached()) {
int margin = Math.round(isMaximized() ? dragHelper.getDragDistance() :
initialMargin + dragHelper.getDragDistance());
margin = Math.max(Math.max(margin, minMargin), 0);
setTopMargin(margin);
}
return true;
}
return false;
}
|
[
"private",
"boolean",
"handleDrag",
"(",
")",
"{",
"if",
"(",
"!",
"isAnimationRunning",
"(",
")",
")",
"{",
"if",
"(",
"dragHelper",
".",
"hasThresholdBeenReached",
"(",
")",
")",
"{",
"int",
"margin",
"=",
"Math",
".",
"round",
"(",
"isMaximized",
"(",
")",
"?",
"dragHelper",
".",
"getDragDistance",
"(",
")",
":",
"initialMargin",
"+",
"dragHelper",
".",
"getDragDistance",
"(",
")",
")",
";",
"margin",
"=",
"Math",
".",
"max",
"(",
"Math",
".",
"max",
"(",
"margin",
",",
"minMargin",
")",
",",
"0",
")",
";",
"setTopMargin",
"(",
"margin",
")",
";",
"}",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] |
Handles when a drag gesture is performed by the user.
@return True, if the view has been moved by the drag gesture, false otherwise
|
[
"Handles",
"when",
"a",
"drag",
"gesture",
"is",
"performed",
"by",
"the",
"user",
"."
] |
6e4690ee9f63b14a7b143d3a3717b5f8a11ca503
|
https://github.com/michael-rapp/AndroidBottomSheet/blob/6e4690ee9f63b14a7b143d3a3717b5f8a11ca503/library/src/main/java/de/mrapp/android/bottomsheet/view/DraggableView.java#L192-L205
|
144,660
|
michael-rapp/AndroidBottomSheet
|
library/src/main/java/de/mrapp/android/bottomsheet/view/DraggableView.java
|
DraggableView.handleRelease
|
private void handleRelease() {
float speed = Math.max(dragHelper.getDragSpeed(), animationSpeed);
if (getTopMargin() > initialMargin ||
(dragHelper.getDragSpeed() > animationSpeed && dragHelper.getDragDistance() > 0) ||
(getDeviceType(getContext()) == DeviceType.TABLET && isMaximized() &&
getTopMargin() > minMargin)) {
animateHideView(parentHeight - getTopMargin(), speed, new DecelerateInterpolator(),
true);
} else {
animateShowView(-(getTopMargin() - minMargin), speed, new DecelerateInterpolator());
}
}
|
java
|
private void handleRelease() {
float speed = Math.max(dragHelper.getDragSpeed(), animationSpeed);
if (getTopMargin() > initialMargin ||
(dragHelper.getDragSpeed() > animationSpeed && dragHelper.getDragDistance() > 0) ||
(getDeviceType(getContext()) == DeviceType.TABLET && isMaximized() &&
getTopMargin() > minMargin)) {
animateHideView(parentHeight - getTopMargin(), speed, new DecelerateInterpolator(),
true);
} else {
animateShowView(-(getTopMargin() - minMargin), speed, new DecelerateInterpolator());
}
}
|
[
"private",
"void",
"handleRelease",
"(",
")",
"{",
"float",
"speed",
"=",
"Math",
".",
"max",
"(",
"dragHelper",
".",
"getDragSpeed",
"(",
")",
",",
"animationSpeed",
")",
";",
"if",
"(",
"getTopMargin",
"(",
")",
">",
"initialMargin",
"||",
"(",
"dragHelper",
".",
"getDragSpeed",
"(",
")",
">",
"animationSpeed",
"&&",
"dragHelper",
".",
"getDragDistance",
"(",
")",
">",
"0",
")",
"||",
"(",
"getDeviceType",
"(",
"getContext",
"(",
")",
")",
"==",
"DeviceType",
".",
"TABLET",
"&&",
"isMaximized",
"(",
")",
"&&",
"getTopMargin",
"(",
")",
">",
"minMargin",
")",
")",
"{",
"animateHideView",
"(",
"parentHeight",
"-",
"getTopMargin",
"(",
")",
",",
"speed",
",",
"new",
"DecelerateInterpolator",
"(",
")",
",",
"true",
")",
";",
"}",
"else",
"{",
"animateShowView",
"(",
"-",
"(",
"getTopMargin",
"(",
")",
"-",
"minMargin",
")",
",",
"speed",
",",
"new",
"DecelerateInterpolator",
"(",
")",
")",
";",
"}",
"}"
] |
Handles when a drag gesture has been ended by the user.
|
[
"Handles",
"when",
"a",
"drag",
"gesture",
"has",
"been",
"ended",
"by",
"the",
"user",
"."
] |
6e4690ee9f63b14a7b143d3a3717b5f8a11ca503
|
https://github.com/michael-rapp/AndroidBottomSheet/blob/6e4690ee9f63b14a7b143d3a3717b5f8a11ca503/library/src/main/java/de/mrapp/android/bottomsheet/view/DraggableView.java#L210-L222
|
144,661
|
michael-rapp/AndroidBottomSheet
|
library/src/main/java/de/mrapp/android/bottomsheet/view/DraggableView.java
|
DraggableView.setTopMargin
|
private void setTopMargin(final int margin) {
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) getLayoutParams();
layoutParams.topMargin = margin;
setLayoutParams(layoutParams);
}
|
java
|
private void setTopMargin(final int margin) {
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) getLayoutParams();
layoutParams.topMargin = margin;
setLayoutParams(layoutParams);
}
|
[
"private",
"void",
"setTopMargin",
"(",
"final",
"int",
"margin",
")",
"{",
"FrameLayout",
".",
"LayoutParams",
"layoutParams",
"=",
"(",
"FrameLayout",
".",
"LayoutParams",
")",
"getLayoutParams",
"(",
")",
";",
"layoutParams",
".",
"topMargin",
"=",
"margin",
";",
"setLayoutParams",
"(",
"layoutParams",
")",
";",
"}"
] |
Set the top margin of the view.
@param margin
The top margin, which should be set, in pixels as an {@link Integer} value
|
[
"Set",
"the",
"top",
"margin",
"of",
"the",
"view",
"."
] |
6e4690ee9f63b14a7b143d3a3717b5f8a11ca503
|
https://github.com/michael-rapp/AndroidBottomSheet/blob/6e4690ee9f63b14a7b143d3a3717b5f8a11ca503/library/src/main/java/de/mrapp/android/bottomsheet/view/DraggableView.java#L240-L244
|
144,662
|
michael-rapp/AndroidBottomSheet
|
library/src/main/java/de/mrapp/android/bottomsheet/view/DraggableView.java
|
DraggableView.animateShowView
|
private void animateShowView(final int diff, final float animationSpeed,
@NonNull final Interpolator interpolator) {
animateView(diff, animationSpeed, createAnimationListener(true, false), interpolator);
}
|
java
|
private void animateShowView(final int diff, final float animationSpeed,
@NonNull final Interpolator interpolator) {
animateView(diff, animationSpeed, createAnimationListener(true, false), interpolator);
}
|
[
"private",
"void",
"animateShowView",
"(",
"final",
"int",
"diff",
",",
"final",
"float",
"animationSpeed",
",",
"@",
"NonNull",
"final",
"Interpolator",
"interpolator",
")",
"{",
"animateView",
"(",
"diff",
",",
"animationSpeed",
",",
"createAnimationListener",
"(",
"true",
",",
"false",
")",
",",
"interpolator",
")",
";",
"}"
] |
Animates the view to become show.
@param diff
The distance the view has to be vertically moved by, as an {@link Integer} value
@param animationSpeed
The speed of the animation in pixels per milliseconds as a {@link Float} value
@param interpolator
The interpolator, which should be used by the animation, as an instance of the type
{@link Interpolator}. The interpolator may not be null
|
[
"Animates",
"the",
"view",
"to",
"become",
"show",
"."
] |
6e4690ee9f63b14a7b143d3a3717b5f8a11ca503
|
https://github.com/michael-rapp/AndroidBottomSheet/blob/6e4690ee9f63b14a7b143d3a3717b5f8a11ca503/library/src/main/java/de/mrapp/android/bottomsheet/view/DraggableView.java#L257-L260
|
144,663
|
michael-rapp/AndroidBottomSheet
|
library/src/main/java/de/mrapp/android/bottomsheet/view/DraggableView.java
|
DraggableView.animateHideView
|
private void animateHideView(final int diff, final float animationSpeed,
@NonNull final Interpolator interpolator, final boolean cancel) {
animateView(diff, animationSpeed, createAnimationListener(false, cancel), interpolator);
}
|
java
|
private void animateHideView(final int diff, final float animationSpeed,
@NonNull final Interpolator interpolator, final boolean cancel) {
animateView(diff, animationSpeed, createAnimationListener(false, cancel), interpolator);
}
|
[
"private",
"void",
"animateHideView",
"(",
"final",
"int",
"diff",
",",
"final",
"float",
"animationSpeed",
",",
"@",
"NonNull",
"final",
"Interpolator",
"interpolator",
",",
"final",
"boolean",
"cancel",
")",
"{",
"animateView",
"(",
"diff",
",",
"animationSpeed",
",",
"createAnimationListener",
"(",
"false",
",",
"cancel",
")",
",",
"interpolator",
")",
";",
"}"
] |
Animates the view to become hidden.
@param diff
The distance the view has to be vertically moved by, as an {@link Integer} value
@param animationSpeed
The speed of the animation in pixels per milliseconds as a {@link Float} value
@param interpolator
The interpolator, which should be used by the animation, as an instance of the type
{@link Interpolator}. The interpolator may not be null
@param cancel
True, if the view should be canceled, false otherwise
|
[
"Animates",
"the",
"view",
"to",
"become",
"hidden",
"."
] |
6e4690ee9f63b14a7b143d3a3717b5f8a11ca503
|
https://github.com/michael-rapp/AndroidBottomSheet/blob/6e4690ee9f63b14a7b143d3a3717b5f8a11ca503/library/src/main/java/de/mrapp/android/bottomsheet/view/DraggableView.java#L275-L278
|
144,664
|
michael-rapp/AndroidBottomSheet
|
library/src/main/java/de/mrapp/android/bottomsheet/view/DraggableView.java
|
DraggableView.animateView
|
private void animateView(final int diff, final float animationSpeed,
@NonNull final AnimationListener animationListener,
@NonNull final Interpolator interpolator) {
if (!isDragging() && !isAnimationRunning()) {
long duration = calculateAnimationDuration(diff, animationSpeed);
Animation animation =
new DraggableViewAnimation(this, diff, duration, animationListener);
animation.setInterpolator(interpolator);
startAnimation(animation);
}
}
|
java
|
private void animateView(final int diff, final float animationSpeed,
@NonNull final AnimationListener animationListener,
@NonNull final Interpolator interpolator) {
if (!isDragging() && !isAnimationRunning()) {
long duration = calculateAnimationDuration(diff, animationSpeed);
Animation animation =
new DraggableViewAnimation(this, diff, duration, animationListener);
animation.setInterpolator(interpolator);
startAnimation(animation);
}
}
|
[
"private",
"void",
"animateView",
"(",
"final",
"int",
"diff",
",",
"final",
"float",
"animationSpeed",
",",
"@",
"NonNull",
"final",
"AnimationListener",
"animationListener",
",",
"@",
"NonNull",
"final",
"Interpolator",
"interpolator",
")",
"{",
"if",
"(",
"!",
"isDragging",
"(",
")",
"&&",
"!",
"isAnimationRunning",
"(",
")",
")",
"{",
"long",
"duration",
"=",
"calculateAnimationDuration",
"(",
"diff",
",",
"animationSpeed",
")",
";",
"Animation",
"animation",
"=",
"new",
"DraggableViewAnimation",
"(",
"this",
",",
"diff",
",",
"duration",
",",
"animationListener",
")",
";",
"animation",
".",
"setInterpolator",
"(",
"interpolator",
")",
";",
"startAnimation",
"(",
"animation",
")",
";",
"}",
"}"
] |
Animates the view to become shown or hidden.
@param diff
The distance the view has to be vertically moved by, as an {@link Integer} value
@param animationSpeed
The speed of the animation in pixels per millisecond as a {@link Float} value
@param animationListener
The listener, which should be notified about the animation's progress, as an instance
of the type {@link AnimationListener}. The listener may not be null
@param interpolator
The interpolator, which should be used by the animation, as an instance of the type
{@link Interpolator}. The interpolator may not be null
|
[
"Animates",
"the",
"view",
"to",
"become",
"shown",
"or",
"hidden",
"."
] |
6e4690ee9f63b14a7b143d3a3717b5f8a11ca503
|
https://github.com/michael-rapp/AndroidBottomSheet/blob/6e4690ee9f63b14a7b143d3a3717b5f8a11ca503/library/src/main/java/de/mrapp/android/bottomsheet/view/DraggableView.java#L294-L304
|
144,665
|
michael-rapp/AndroidBottomSheet
|
library/src/main/java/de/mrapp/android/bottomsheet/view/DraggableView.java
|
DraggableView.createAnimationListener
|
private AnimationListener createAnimationListener(final boolean show, final boolean cancel) {
return new AnimationListener() {
@Override
public void onAnimationStart(final Animation animation) {
}
@Override
public void onAnimationEnd(final Animation animation) {
clearAnimation();
maximized = show;
if (maximized) {
notifyOnMaximized();
} else {
notifyOnHidden(cancel);
}
}
@Override
public void onAnimationRepeat(final Animation animation) {
}
};
}
|
java
|
private AnimationListener createAnimationListener(final boolean show, final boolean cancel) {
return new AnimationListener() {
@Override
public void onAnimationStart(final Animation animation) {
}
@Override
public void onAnimationEnd(final Animation animation) {
clearAnimation();
maximized = show;
if (maximized) {
notifyOnMaximized();
} else {
notifyOnHidden(cancel);
}
}
@Override
public void onAnimationRepeat(final Animation animation) {
}
};
}
|
[
"private",
"AnimationListener",
"createAnimationListener",
"(",
"final",
"boolean",
"show",
",",
"final",
"boolean",
"cancel",
")",
"{",
"return",
"new",
"AnimationListener",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"onAnimationStart",
"(",
"final",
"Animation",
"animation",
")",
"{",
"}",
"@",
"Override",
"public",
"void",
"onAnimationEnd",
"(",
"final",
"Animation",
"animation",
")",
"{",
"clearAnimation",
"(",
")",
";",
"maximized",
"=",
"show",
";",
"if",
"(",
"maximized",
")",
"{",
"notifyOnMaximized",
"(",
")",
";",
"}",
"else",
"{",
"notifyOnHidden",
"(",
"cancel",
")",
";",
"}",
"}",
"@",
"Override",
"public",
"void",
"onAnimationRepeat",
"(",
"final",
"Animation",
"animation",
")",
"{",
"}",
"}",
";",
"}"
] |
Creates and returns a listener, which allows to handle the end of an animation, which has
been used to show or hide the view.
@param show
True, if the view should be shown at the end of the animation, false otherwise
@param cancel
True, if the view should be canceled, false otherwise
@return The listener, which has been created, as an instance of the type {@link
AnimationListener}
|
[
"Creates",
"and",
"returns",
"a",
"listener",
"which",
"allows",
"to",
"handle",
"the",
"end",
"of",
"an",
"animation",
"which",
"has",
"been",
"used",
"to",
"show",
"or",
"hide",
"the",
"view",
"."
] |
6e4690ee9f63b14a7b143d3a3717b5f8a11ca503
|
https://github.com/michael-rapp/AndroidBottomSheet/blob/6e4690ee9f63b14a7b143d3a3717b5f8a11ca503/library/src/main/java/de/mrapp/android/bottomsheet/view/DraggableView.java#L331-L357
|
144,666
|
michael-rapp/AndroidBottomSheet
|
library/src/main/java/de/mrapp/android/bottomsheet/model/Item.java
|
Item.setIcon
|
public final void setIcon(@NonNull final Context context, @DrawableRes final int resourceId) {
setIcon(ContextCompat.getDrawable(context, resourceId));
}
|
java
|
public final void setIcon(@NonNull final Context context, @DrawableRes final int resourceId) {
setIcon(ContextCompat.getDrawable(context, resourceId));
}
|
[
"public",
"final",
"void",
"setIcon",
"(",
"@",
"NonNull",
"final",
"Context",
"context",
",",
"@",
"DrawableRes",
"final",
"int",
"resourceId",
")",
"{",
"setIcon",
"(",
"ContextCompat",
".",
"getDrawable",
"(",
"context",
",",
"resourceId",
")",
")",
";",
"}"
] |
Sets the item's icon.
@param context
The context, which should be used, as an instance of the class {@link Context}. The
context may not be null
@param resourceId
The resource id of the icon, which should be set, as an {@link Integer} value. The
resource id must correspond to a valid drawable resource
|
[
"Sets",
"the",
"item",
"s",
"icon",
"."
] |
6e4690ee9f63b14a7b143d3a3717b5f8a11ca503
|
https://github.com/michael-rapp/AndroidBottomSheet/blob/6e4690ee9f63b14a7b143d3a3717b5f8a11ca503/library/src/main/java/de/mrapp/android/bottomsheet/model/Item.java#L113-L115
|
144,667
|
michael-rapp/AndroidBottomSheet
|
library/src/main/java/de/mrapp/android/bottomsheet/model/Item.java
|
Item.setTitle
|
public final void setTitle(@NonNull final Context context, @StringRes final int resourceId) {
Condition.INSTANCE.ensureNotNull(context, "The context may not be null");
setTitle(context.getText(resourceId));
}
|
java
|
public final void setTitle(@NonNull final Context context, @StringRes final int resourceId) {
Condition.INSTANCE.ensureNotNull(context, "The context may not be null");
setTitle(context.getText(resourceId));
}
|
[
"public",
"final",
"void",
"setTitle",
"(",
"@",
"NonNull",
"final",
"Context",
"context",
",",
"@",
"StringRes",
"final",
"int",
"resourceId",
")",
"{",
"Condition",
".",
"INSTANCE",
".",
"ensureNotNull",
"(",
"context",
",",
"\"The context may not be null\"",
")",
";",
"setTitle",
"(",
"context",
".",
"getText",
"(",
"resourceId",
")",
")",
";",
"}"
] |
Sets the title of the item.
@param context
The context, which should be used, as an instance of the class {@link Context}. The
context may not be null
@param resourceId
The resource id of the title, which should be set, as an {@link Integer} value. The
resource id must correspond to a valid string resource
|
[
"Sets",
"the",
"title",
"of",
"the",
"item",
"."
] |
6e4690ee9f63b14a7b143d3a3717b5f8a11ca503
|
https://github.com/michael-rapp/AndroidBottomSheet/blob/6e4690ee9f63b14a7b143d3a3717b5f8a11ca503/library/src/main/java/de/mrapp/android/bottomsheet/model/Item.java#L146-L149
|
144,668
|
michael-rapp/AndroidBottomSheet
|
library/src/main/java/de/mrapp/android/bottomsheet/BottomSheet.java
|
BottomSheet.initialize
|
private void initialize() {
width = getContext().getResources().getDimensionPixelSize(R.dimen.default_width);
maximize = false;
adapter = new DividableGridAdapter(getContext(), Style.LIST, width);
super.setOnShowListener(createOnShowListener());
}
|
java
|
private void initialize() {
width = getContext().getResources().getDimensionPixelSize(R.dimen.default_width);
maximize = false;
adapter = new DividableGridAdapter(getContext(), Style.LIST, width);
super.setOnShowListener(createOnShowListener());
}
|
[
"private",
"void",
"initialize",
"(",
")",
"{",
"width",
"=",
"getContext",
"(",
")",
".",
"getResources",
"(",
")",
".",
"getDimensionPixelSize",
"(",
"R",
".",
"dimen",
".",
"default_width",
")",
";",
"maximize",
"=",
"false",
";",
"adapter",
"=",
"new",
"DividableGridAdapter",
"(",
"getContext",
"(",
")",
",",
"Style",
".",
"LIST",
",",
"width",
")",
";",
"super",
".",
"setOnShowListener",
"(",
"createOnShowListener",
"(",
")",
")",
";",
"}"
] |
Initializes the bottom sheet.
|
[
"Initializes",
"the",
"bottom",
"sheet",
"."
] |
6e4690ee9f63b14a7b143d3a3717b5f8a11ca503
|
https://github.com/michael-rapp/AndroidBottomSheet/blob/6e4690ee9f63b14a7b143d3a3717b5f8a11ca503/library/src/main/java/de/mrapp/android/bottomsheet/BottomSheet.java#L1144-L1149
|
144,669
|
michael-rapp/AndroidBottomSheet
|
library/src/main/java/de/mrapp/android/bottomsheet/BottomSheet.java
|
BottomSheet.createLayoutParams
|
private WindowManager.LayoutParams createLayoutParams() {
WindowManager.LayoutParams layoutParams = getWindow().getAttributes();
layoutParams.width = ViewGroup.LayoutParams.MATCH_PARENT;
layoutParams.height = ViewGroup.LayoutParams.MATCH_PARENT;
return layoutParams;
}
|
java
|
private WindowManager.LayoutParams createLayoutParams() {
WindowManager.LayoutParams layoutParams = getWindow().getAttributes();
layoutParams.width = ViewGroup.LayoutParams.MATCH_PARENT;
layoutParams.height = ViewGroup.LayoutParams.MATCH_PARENT;
return layoutParams;
}
|
[
"private",
"WindowManager",
".",
"LayoutParams",
"createLayoutParams",
"(",
")",
"{",
"WindowManager",
".",
"LayoutParams",
"layoutParams",
"=",
"getWindow",
"(",
")",
".",
"getAttributes",
"(",
")",
";",
"layoutParams",
".",
"width",
"=",
"ViewGroup",
".",
"LayoutParams",
".",
"MATCH_PARENT",
";",
"layoutParams",
".",
"height",
"=",
"ViewGroup",
".",
"LayoutParams",
".",
"MATCH_PARENT",
";",
"return",
"layoutParams",
";",
"}"
] |
Creates and returns the layout params, which should be used to show the bottom sheet.
@return The layout params, which have been created, as an instance of the class {@link
android.view.WindowManager.LayoutParams}
|
[
"Creates",
"and",
"returns",
"the",
"layout",
"params",
"which",
"should",
"be",
"used",
"to",
"show",
"the",
"bottom",
"sheet",
"."
] |
6e4690ee9f63b14a7b143d3a3717b5f8a11ca503
|
https://github.com/michael-rapp/AndroidBottomSheet/blob/6e4690ee9f63b14a7b143d3a3717b5f8a11ca503/library/src/main/java/de/mrapp/android/bottomsheet/BottomSheet.java#L1157-L1162
|
144,670
|
michael-rapp/AndroidBottomSheet
|
library/src/main/java/de/mrapp/android/bottomsheet/BottomSheet.java
|
BottomSheet.createRootViewLayoutParams
|
private FrameLayout.LayoutParams createRootViewLayoutParams() {
FrameLayout.LayoutParams layoutParams =
new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
FrameLayout.LayoutParams.MATCH_PARENT);
layoutParams.gravity = Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL;
return layoutParams;
}
|
java
|
private FrameLayout.LayoutParams createRootViewLayoutParams() {
FrameLayout.LayoutParams layoutParams =
new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
FrameLayout.LayoutParams.MATCH_PARENT);
layoutParams.gravity = Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL;
return layoutParams;
}
|
[
"private",
"FrameLayout",
".",
"LayoutParams",
"createRootViewLayoutParams",
"(",
")",
"{",
"FrameLayout",
".",
"LayoutParams",
"layoutParams",
"=",
"new",
"FrameLayout",
".",
"LayoutParams",
"(",
"FrameLayout",
".",
"LayoutParams",
".",
"MATCH_PARENT",
",",
"FrameLayout",
".",
"LayoutParams",
".",
"MATCH_PARENT",
")",
";",
"layoutParams",
".",
"gravity",
"=",
"Gravity",
".",
"BOTTOM",
"|",
"Gravity",
".",
"CENTER_HORIZONTAL",
";",
"return",
"layoutParams",
";",
"}"
] |
Creates and returns the layout params, which should be used to show the bottom sheet's root
view.
@return The layout params, which have been created, as an instance of the class {@link
android.widget.FrameLayout.LayoutParams }
|
[
"Creates",
"and",
"returns",
"the",
"layout",
"params",
"which",
"should",
"be",
"used",
"to",
"show",
"the",
"bottom",
"sheet",
"s",
"root",
"view",
"."
] |
6e4690ee9f63b14a7b143d3a3717b5f8a11ca503
|
https://github.com/michael-rapp/AndroidBottomSheet/blob/6e4690ee9f63b14a7b143d3a3717b5f8a11ca503/library/src/main/java/de/mrapp/android/bottomsheet/BottomSheet.java#L1171-L1177
|
144,671
|
michael-rapp/AndroidBottomSheet
|
library/src/main/java/de/mrapp/android/bottomsheet/BottomSheet.java
|
BottomSheet.inflateRootView
|
private void inflateRootView() {
ViewGroup contentView = findViewById(android.R.id.content);
contentView.removeAllViews();
LayoutInflater layoutInflater = LayoutInflater.from(getContext());
rootView =
(DraggableView) layoutInflater.inflate(R.layout.bottom_sheet, contentView, false);
rootView.setCallback(this);
contentView.addView(rootView, createRootViewLayoutParams());
}
|
java
|
private void inflateRootView() {
ViewGroup contentView = findViewById(android.R.id.content);
contentView.removeAllViews();
LayoutInflater layoutInflater = LayoutInflater.from(getContext());
rootView =
(DraggableView) layoutInflater.inflate(R.layout.bottom_sheet, contentView, false);
rootView.setCallback(this);
contentView.addView(rootView, createRootViewLayoutParams());
}
|
[
"private",
"void",
"inflateRootView",
"(",
")",
"{",
"ViewGroup",
"contentView",
"=",
"findViewById",
"(",
"android",
".",
"R",
".",
"id",
".",
"content",
")",
";",
"contentView",
".",
"removeAllViews",
"(",
")",
";",
"LayoutInflater",
"layoutInflater",
"=",
"LayoutInflater",
".",
"from",
"(",
"getContext",
"(",
")",
")",
";",
"rootView",
"=",
"(",
"DraggableView",
")",
"layoutInflater",
".",
"inflate",
"(",
"R",
".",
"layout",
".",
"bottom_sheet",
",",
"contentView",
",",
"false",
")",
";",
"rootView",
".",
"setCallback",
"(",
"this",
")",
";",
"contentView",
".",
"addView",
"(",
"rootView",
",",
"createRootViewLayoutParams",
"(",
")",
")",
";",
"}"
] |
Initializes the bottom sheet's root view.
|
[
"Initializes",
"the",
"bottom",
"sheet",
"s",
"root",
"view",
"."
] |
6e4690ee9f63b14a7b143d3a3717b5f8a11ca503
|
https://github.com/michael-rapp/AndroidBottomSheet/blob/6e4690ee9f63b14a7b143d3a3717b5f8a11ca503/library/src/main/java/de/mrapp/android/bottomsheet/BottomSheet.java#L1182-L1190
|
144,672
|
michael-rapp/AndroidBottomSheet
|
library/src/main/java/de/mrapp/android/bottomsheet/BottomSheet.java
|
BottomSheet.inflateTitleView
|
private void inflateTitleView() {
titleContainer = rootView.findViewById(R.id.title_container);
titleContainer.removeAllViews();
if (customTitleView != null) {
titleContainer.addView(customTitleView);
} else if (customTitleViewId != -1) {
LayoutInflater layoutInflater = LayoutInflater.from(getContext());
View view = layoutInflater.inflate(customTitleViewId, titleContainer, false);
titleContainer.addView(view);
} else {
LayoutInflater layoutInflater = LayoutInflater.from(getContext());
View view = layoutInflater.inflate(R.layout.bottom_sheet_title, titleContainer, false);
titleContainer.addView(view);
}
if (getStyle() == Style.LIST) {
int padding = getContext().getResources()
.getDimensionPixelSize(R.dimen.bottom_sheet_list_item_horizontal_padding);
titleContainer.setPadding(padding, 0, padding, 0);
} else {
int padding = getContext().getResources()
.getDimensionPixelSize(R.dimen.bottom_sheet_grid_item_horizontal_padding);
titleContainer.setPadding(padding, 0, padding, 0);
}
View titleView = titleContainer.findViewById(android.R.id.title);
titleTextView = titleView instanceof TextView ? (TextView) titleView : null;
}
|
java
|
private void inflateTitleView() {
titleContainer = rootView.findViewById(R.id.title_container);
titleContainer.removeAllViews();
if (customTitleView != null) {
titleContainer.addView(customTitleView);
} else if (customTitleViewId != -1) {
LayoutInflater layoutInflater = LayoutInflater.from(getContext());
View view = layoutInflater.inflate(customTitleViewId, titleContainer, false);
titleContainer.addView(view);
} else {
LayoutInflater layoutInflater = LayoutInflater.from(getContext());
View view = layoutInflater.inflate(R.layout.bottom_sheet_title, titleContainer, false);
titleContainer.addView(view);
}
if (getStyle() == Style.LIST) {
int padding = getContext().getResources()
.getDimensionPixelSize(R.dimen.bottom_sheet_list_item_horizontal_padding);
titleContainer.setPadding(padding, 0, padding, 0);
} else {
int padding = getContext().getResources()
.getDimensionPixelSize(R.dimen.bottom_sheet_grid_item_horizontal_padding);
titleContainer.setPadding(padding, 0, padding, 0);
}
View titleView = titleContainer.findViewById(android.R.id.title);
titleTextView = titleView instanceof TextView ? (TextView) titleView : null;
}
|
[
"private",
"void",
"inflateTitleView",
"(",
")",
"{",
"titleContainer",
"=",
"rootView",
".",
"findViewById",
"(",
"R",
".",
"id",
".",
"title_container",
")",
";",
"titleContainer",
".",
"removeAllViews",
"(",
")",
";",
"if",
"(",
"customTitleView",
"!=",
"null",
")",
"{",
"titleContainer",
".",
"addView",
"(",
"customTitleView",
")",
";",
"}",
"else",
"if",
"(",
"customTitleViewId",
"!=",
"-",
"1",
")",
"{",
"LayoutInflater",
"layoutInflater",
"=",
"LayoutInflater",
".",
"from",
"(",
"getContext",
"(",
")",
")",
";",
"View",
"view",
"=",
"layoutInflater",
".",
"inflate",
"(",
"customTitleViewId",
",",
"titleContainer",
",",
"false",
")",
";",
"titleContainer",
".",
"addView",
"(",
"view",
")",
";",
"}",
"else",
"{",
"LayoutInflater",
"layoutInflater",
"=",
"LayoutInflater",
".",
"from",
"(",
"getContext",
"(",
")",
")",
";",
"View",
"view",
"=",
"layoutInflater",
".",
"inflate",
"(",
"R",
".",
"layout",
".",
"bottom_sheet_title",
",",
"titleContainer",
",",
"false",
")",
";",
"titleContainer",
".",
"addView",
"(",
"view",
")",
";",
"}",
"if",
"(",
"getStyle",
"(",
")",
"==",
"Style",
".",
"LIST",
")",
"{",
"int",
"padding",
"=",
"getContext",
"(",
")",
".",
"getResources",
"(",
")",
".",
"getDimensionPixelSize",
"(",
"R",
".",
"dimen",
".",
"bottom_sheet_list_item_horizontal_padding",
")",
";",
"titleContainer",
".",
"setPadding",
"(",
"padding",
",",
"0",
",",
"padding",
",",
"0",
")",
";",
"}",
"else",
"{",
"int",
"padding",
"=",
"getContext",
"(",
")",
".",
"getResources",
"(",
")",
".",
"getDimensionPixelSize",
"(",
"R",
".",
"dimen",
".",
"bottom_sheet_grid_item_horizontal_padding",
")",
";",
"titleContainer",
".",
"setPadding",
"(",
"padding",
",",
"0",
",",
"padding",
",",
"0",
")",
";",
"}",
"View",
"titleView",
"=",
"titleContainer",
".",
"findViewById",
"(",
"android",
".",
"R",
".",
"id",
".",
"title",
")",
";",
"titleTextView",
"=",
"titleView",
"instanceof",
"TextView",
"?",
"(",
"TextView",
")",
"titleView",
":",
"null",
";",
"}"
] |
Inflates the layout, which is used to show the bottom sheet's title. The layout may either be
the default one or a custom view, if one has been set before.
|
[
"Inflates",
"the",
"layout",
"which",
"is",
"used",
"to",
"show",
"the",
"bottom",
"sheet",
"s",
"title",
".",
"The",
"layout",
"may",
"either",
"be",
"the",
"default",
"one",
"or",
"a",
"custom",
"view",
"if",
"one",
"has",
"been",
"set",
"before",
"."
] |
6e4690ee9f63b14a7b143d3a3717b5f8a11ca503
|
https://github.com/michael-rapp/AndroidBottomSheet/blob/6e4690ee9f63b14a7b143d3a3717b5f8a11ca503/library/src/main/java/de/mrapp/android/bottomsheet/BottomSheet.java#L1196-L1224
|
144,673
|
michael-rapp/AndroidBottomSheet
|
library/src/main/java/de/mrapp/android/bottomsheet/BottomSheet.java
|
BottomSheet.inflateContentView
|
private void inflateContentView() {
contentContainer = rootView.findViewById(R.id.content_container);
contentContainer.removeAllViews();
if (customView != null) {
contentContainer.setVisibility(View.VISIBLE);
contentContainer.addView(customView);
} else if (customViewId != -1) {
contentContainer.setVisibility(View.VISIBLE);
LayoutInflater layoutInflater = LayoutInflater.from(getContext());
View view = layoutInflater.inflate(customViewId, contentContainer, false);
contentContainer.addView(view);
} else {
LayoutInflater layoutInflater = LayoutInflater.from(getContext());
View view = layoutInflater
.inflate(R.layout.bottom_sheet_grid_view, contentContainer, false);
contentContainer.addView(view);
}
showGridView();
}
|
java
|
private void inflateContentView() {
contentContainer = rootView.findViewById(R.id.content_container);
contentContainer.removeAllViews();
if (customView != null) {
contentContainer.setVisibility(View.VISIBLE);
contentContainer.addView(customView);
} else if (customViewId != -1) {
contentContainer.setVisibility(View.VISIBLE);
LayoutInflater layoutInflater = LayoutInflater.from(getContext());
View view = layoutInflater.inflate(customViewId, contentContainer, false);
contentContainer.addView(view);
} else {
LayoutInflater layoutInflater = LayoutInflater.from(getContext());
View view = layoutInflater
.inflate(R.layout.bottom_sheet_grid_view, contentContainer, false);
contentContainer.addView(view);
}
showGridView();
}
|
[
"private",
"void",
"inflateContentView",
"(",
")",
"{",
"contentContainer",
"=",
"rootView",
".",
"findViewById",
"(",
"R",
".",
"id",
".",
"content_container",
")",
";",
"contentContainer",
".",
"removeAllViews",
"(",
")",
";",
"if",
"(",
"customView",
"!=",
"null",
")",
"{",
"contentContainer",
".",
"setVisibility",
"(",
"View",
".",
"VISIBLE",
")",
";",
"contentContainer",
".",
"addView",
"(",
"customView",
")",
";",
"}",
"else",
"if",
"(",
"customViewId",
"!=",
"-",
"1",
")",
"{",
"contentContainer",
".",
"setVisibility",
"(",
"View",
".",
"VISIBLE",
")",
";",
"LayoutInflater",
"layoutInflater",
"=",
"LayoutInflater",
".",
"from",
"(",
"getContext",
"(",
")",
")",
";",
"View",
"view",
"=",
"layoutInflater",
".",
"inflate",
"(",
"customViewId",
",",
"contentContainer",
",",
"false",
")",
";",
"contentContainer",
".",
"addView",
"(",
"view",
")",
";",
"}",
"else",
"{",
"LayoutInflater",
"layoutInflater",
"=",
"LayoutInflater",
".",
"from",
"(",
"getContext",
"(",
")",
")",
";",
"View",
"view",
"=",
"layoutInflater",
".",
"inflate",
"(",
"R",
".",
"layout",
".",
"bottom_sheet_grid_view",
",",
"contentContainer",
",",
"false",
")",
";",
"contentContainer",
".",
"addView",
"(",
"view",
")",
";",
"}",
"showGridView",
"(",
")",
";",
"}"
] |
Inflates the layout, which is used to show the bottom sheet's content. The layout may either
be the default one or a custom view, if one has been set before.
|
[
"Inflates",
"the",
"layout",
"which",
"is",
"used",
"to",
"show",
"the",
"bottom",
"sheet",
"s",
"content",
".",
"The",
"layout",
"may",
"either",
"be",
"the",
"default",
"one",
"or",
"a",
"custom",
"view",
"if",
"one",
"has",
"been",
"set",
"before",
"."
] |
6e4690ee9f63b14a7b143d3a3717b5f8a11ca503
|
https://github.com/michael-rapp/AndroidBottomSheet/blob/6e4690ee9f63b14a7b143d3a3717b5f8a11ca503/library/src/main/java/de/mrapp/android/bottomsheet/BottomSheet.java#L1230-L1250
|
144,674
|
michael-rapp/AndroidBottomSheet
|
library/src/main/java/de/mrapp/android/bottomsheet/BottomSheet.java
|
BottomSheet.showGridView
|
private void showGridView() {
gridView = contentContainer.findViewById(R.id.bottom_sheet_grid_view);
if (gridView != null) {
contentContainer.setVisibility(View.VISIBLE);
if (getStyle() == Style.GRID) {
int horizontalPadding = getContext().getResources()
.getDimensionPixelSize(R.dimen.bottom_sheet_grid_item_horizontal_padding);
int paddingBottom = getContext().getResources()
.getDimensionPixelSize(R.dimen.bottom_sheet_grid_padding_bottom);
gridView.setPadding(horizontalPadding, 0, horizontalPadding, paddingBottom);
gridView.setNumColumns(GridView.AUTO_FIT);
gridView.setColumnWidth(getContext().getResources()
.getDimensionPixelSize(R.dimen.bottom_sheet_grid_item_size));
} else {
int paddingBottom = getContext().getResources()
.getDimensionPixelSize(R.dimen.bottom_sheet_list_padding_bottom);
gridView.setPadding(0, 0, 0, paddingBottom);
gridView.setNumColumns(getStyle() == Style.LIST_COLUMNS &&
(getDeviceType(getContext()) == DisplayUtil.DeviceType.TABLET ||
getOrientation(getContext()) == DisplayUtil.Orientation.LANDSCAPE) ?
2 : 1);
}
gridView.setOnItemClickListener(createItemClickListener());
gridView.setOnItemLongClickListener(createItemLongClickListener());
gridView.setAdapter(adapter);
}
}
|
java
|
private void showGridView() {
gridView = contentContainer.findViewById(R.id.bottom_sheet_grid_view);
if (gridView != null) {
contentContainer.setVisibility(View.VISIBLE);
if (getStyle() == Style.GRID) {
int horizontalPadding = getContext().getResources()
.getDimensionPixelSize(R.dimen.bottom_sheet_grid_item_horizontal_padding);
int paddingBottom = getContext().getResources()
.getDimensionPixelSize(R.dimen.bottom_sheet_grid_padding_bottom);
gridView.setPadding(horizontalPadding, 0, horizontalPadding, paddingBottom);
gridView.setNumColumns(GridView.AUTO_FIT);
gridView.setColumnWidth(getContext().getResources()
.getDimensionPixelSize(R.dimen.bottom_sheet_grid_item_size));
} else {
int paddingBottom = getContext().getResources()
.getDimensionPixelSize(R.dimen.bottom_sheet_list_padding_bottom);
gridView.setPadding(0, 0, 0, paddingBottom);
gridView.setNumColumns(getStyle() == Style.LIST_COLUMNS &&
(getDeviceType(getContext()) == DisplayUtil.DeviceType.TABLET ||
getOrientation(getContext()) == DisplayUtil.Orientation.LANDSCAPE) ?
2 : 1);
}
gridView.setOnItemClickListener(createItemClickListener());
gridView.setOnItemLongClickListener(createItemLongClickListener());
gridView.setAdapter(adapter);
}
}
|
[
"private",
"void",
"showGridView",
"(",
")",
"{",
"gridView",
"=",
"contentContainer",
".",
"findViewById",
"(",
"R",
".",
"id",
".",
"bottom_sheet_grid_view",
")",
";",
"if",
"(",
"gridView",
"!=",
"null",
")",
"{",
"contentContainer",
".",
"setVisibility",
"(",
"View",
".",
"VISIBLE",
")",
";",
"if",
"(",
"getStyle",
"(",
")",
"==",
"Style",
".",
"GRID",
")",
"{",
"int",
"horizontalPadding",
"=",
"getContext",
"(",
")",
".",
"getResources",
"(",
")",
".",
"getDimensionPixelSize",
"(",
"R",
".",
"dimen",
".",
"bottom_sheet_grid_item_horizontal_padding",
")",
";",
"int",
"paddingBottom",
"=",
"getContext",
"(",
")",
".",
"getResources",
"(",
")",
".",
"getDimensionPixelSize",
"(",
"R",
".",
"dimen",
".",
"bottom_sheet_grid_padding_bottom",
")",
";",
"gridView",
".",
"setPadding",
"(",
"horizontalPadding",
",",
"0",
",",
"horizontalPadding",
",",
"paddingBottom",
")",
";",
"gridView",
".",
"setNumColumns",
"(",
"GridView",
".",
"AUTO_FIT",
")",
";",
"gridView",
".",
"setColumnWidth",
"(",
"getContext",
"(",
")",
".",
"getResources",
"(",
")",
".",
"getDimensionPixelSize",
"(",
"R",
".",
"dimen",
".",
"bottom_sheet_grid_item_size",
")",
")",
";",
"}",
"else",
"{",
"int",
"paddingBottom",
"=",
"getContext",
"(",
")",
".",
"getResources",
"(",
")",
".",
"getDimensionPixelSize",
"(",
"R",
".",
"dimen",
".",
"bottom_sheet_list_padding_bottom",
")",
";",
"gridView",
".",
"setPadding",
"(",
"0",
",",
"0",
",",
"0",
",",
"paddingBottom",
")",
";",
"gridView",
".",
"setNumColumns",
"(",
"getStyle",
"(",
")",
"==",
"Style",
".",
"LIST_COLUMNS",
"&&",
"(",
"getDeviceType",
"(",
"getContext",
"(",
")",
")",
"==",
"DisplayUtil",
".",
"DeviceType",
".",
"TABLET",
"||",
"getOrientation",
"(",
"getContext",
"(",
")",
")",
"==",
"DisplayUtil",
".",
"Orientation",
".",
"LANDSCAPE",
")",
"?",
"2",
":",
"1",
")",
";",
"}",
"gridView",
".",
"setOnItemClickListener",
"(",
"createItemClickListener",
"(",
")",
")",
";",
"gridView",
".",
"setOnItemLongClickListener",
"(",
"createItemLongClickListener",
"(",
")",
")",
";",
"gridView",
".",
"setAdapter",
"(",
"adapter",
")",
";",
"}",
"}"
] |
Shows the grid view, which is used to show the bottom sheet's items.
|
[
"Shows",
"the",
"grid",
"view",
"which",
"is",
"used",
"to",
"show",
"the",
"bottom",
"sheet",
"s",
"items",
"."
] |
6e4690ee9f63b14a7b143d3a3717b5f8a11ca503
|
https://github.com/michael-rapp/AndroidBottomSheet/blob/6e4690ee9f63b14a7b143d3a3717b5f8a11ca503/library/src/main/java/de/mrapp/android/bottomsheet/BottomSheet.java#L1255-L1284
|
144,675
|
michael-rapp/AndroidBottomSheet
|
library/src/main/java/de/mrapp/android/bottomsheet/BottomSheet.java
|
BottomSheet.adaptRootView
|
private void adaptRootView() {
if (rootView != null) {
if (getStyle() == Style.LIST) {
int paddingTop = getContext().getResources()
.getDimensionPixelSize(R.dimen.bottom_sheet_list_padding_top);
rootView.setPadding(0, paddingTop, 0, 0);
} else {
int paddingTop = getContext().getResources()
.getDimensionPixelSize(R.dimen.bottom_sheet_grid_padding_top);
rootView.setPadding(0, paddingTop, 0, 0);
}
}
}
|
java
|
private void adaptRootView() {
if (rootView != null) {
if (getStyle() == Style.LIST) {
int paddingTop = getContext().getResources()
.getDimensionPixelSize(R.dimen.bottom_sheet_list_padding_top);
rootView.setPadding(0, paddingTop, 0, 0);
} else {
int paddingTop = getContext().getResources()
.getDimensionPixelSize(R.dimen.bottom_sheet_grid_padding_top);
rootView.setPadding(0, paddingTop, 0, 0);
}
}
}
|
[
"private",
"void",
"adaptRootView",
"(",
")",
"{",
"if",
"(",
"rootView",
"!=",
"null",
")",
"{",
"if",
"(",
"getStyle",
"(",
")",
"==",
"Style",
".",
"LIST",
")",
"{",
"int",
"paddingTop",
"=",
"getContext",
"(",
")",
".",
"getResources",
"(",
")",
".",
"getDimensionPixelSize",
"(",
"R",
".",
"dimen",
".",
"bottom_sheet_list_padding_top",
")",
";",
"rootView",
".",
"setPadding",
"(",
"0",
",",
"paddingTop",
",",
"0",
",",
"0",
")",
";",
"}",
"else",
"{",
"int",
"paddingTop",
"=",
"getContext",
"(",
")",
".",
"getResources",
"(",
")",
".",
"getDimensionPixelSize",
"(",
"R",
".",
"dimen",
".",
"bottom_sheet_grid_padding_top",
")",
";",
"rootView",
".",
"setPadding",
"(",
"0",
",",
"paddingTop",
",",
"0",
",",
"0",
")",
";",
"}",
"}",
"}"
] |
Adapts the root view.
|
[
"Adapts",
"the",
"root",
"view",
"."
] |
6e4690ee9f63b14a7b143d3a3717b5f8a11ca503
|
https://github.com/michael-rapp/AndroidBottomSheet/blob/6e4690ee9f63b14a7b143d3a3717b5f8a11ca503/library/src/main/java/de/mrapp/android/bottomsheet/BottomSheet.java#L1298-L1310
|
144,676
|
michael-rapp/AndroidBottomSheet
|
library/src/main/java/de/mrapp/android/bottomsheet/BottomSheet.java
|
BottomSheet.adaptIcon
|
private void adaptIcon() {
if (titleTextView != null) {
titleTextView.setCompoundDrawablesWithIntrinsicBounds(icon, null, null, null);
}
adaptTitleContainerVisibility();
}
|
java
|
private void adaptIcon() {
if (titleTextView != null) {
titleTextView.setCompoundDrawablesWithIntrinsicBounds(icon, null, null, null);
}
adaptTitleContainerVisibility();
}
|
[
"private",
"void",
"adaptIcon",
"(",
")",
"{",
"if",
"(",
"titleTextView",
"!=",
"null",
")",
"{",
"titleTextView",
".",
"setCompoundDrawablesWithIntrinsicBounds",
"(",
"icon",
",",
"null",
",",
"null",
",",
"null",
")",
";",
"}",
"adaptTitleContainerVisibility",
"(",
")",
";",
"}"
] |
Adapts the bottom sheet's icon.
|
[
"Adapts",
"the",
"bottom",
"sheet",
"s",
"icon",
"."
] |
6e4690ee9f63b14a7b143d3a3717b5f8a11ca503
|
https://github.com/michael-rapp/AndroidBottomSheet/blob/6e4690ee9f63b14a7b143d3a3717b5f8a11ca503/library/src/main/java/de/mrapp/android/bottomsheet/BottomSheet.java#L1347-L1353
|
144,677
|
michael-rapp/AndroidBottomSheet
|
library/src/main/java/de/mrapp/android/bottomsheet/BottomSheet.java
|
BottomSheet.adaptTitleContainerVisibility
|
private void adaptTitleContainerVisibility() {
if (titleContainer != null) {
if (customTitleView == null && customTitleViewId == -1) {
titleContainer.setVisibility(
!TextUtils.isEmpty(title) || icon != null ? View.VISIBLE : View.GONE);
} else {
titleContainer.setVisibility(View.VISIBLE);
}
}
}
|
java
|
private void adaptTitleContainerVisibility() {
if (titleContainer != null) {
if (customTitleView == null && customTitleViewId == -1) {
titleContainer.setVisibility(
!TextUtils.isEmpty(title) || icon != null ? View.VISIBLE : View.GONE);
} else {
titleContainer.setVisibility(View.VISIBLE);
}
}
}
|
[
"private",
"void",
"adaptTitleContainerVisibility",
"(",
")",
"{",
"if",
"(",
"titleContainer",
"!=",
"null",
")",
"{",
"if",
"(",
"customTitleView",
"==",
"null",
"&&",
"customTitleViewId",
"==",
"-",
"1",
")",
"{",
"titleContainer",
".",
"setVisibility",
"(",
"!",
"TextUtils",
".",
"isEmpty",
"(",
"title",
")",
"||",
"icon",
"!=",
"null",
"?",
"View",
".",
"VISIBLE",
":",
"View",
".",
"GONE",
")",
";",
"}",
"else",
"{",
"titleContainer",
".",
"setVisibility",
"(",
"View",
".",
"VISIBLE",
")",
";",
"}",
"}",
"}"
] |
Adapts the visibility of the layout, which is used to show the bottom sheet's title.
|
[
"Adapts",
"the",
"visibility",
"of",
"the",
"layout",
"which",
"is",
"used",
"to",
"show",
"the",
"bottom",
"sheet",
"s",
"title",
"."
] |
6e4690ee9f63b14a7b143d3a3717b5f8a11ca503
|
https://github.com/michael-rapp/AndroidBottomSheet/blob/6e4690ee9f63b14a7b143d3a3717b5f8a11ca503/library/src/main/java/de/mrapp/android/bottomsheet/BottomSheet.java#L1358-L1367
|
144,678
|
michael-rapp/AndroidBottomSheet
|
library/src/main/java/de/mrapp/android/bottomsheet/BottomSheet.java
|
BottomSheet.adaptWidth
|
private void adaptWidth() {
adapter.setWidth(width);
if (rootView != null) {
rootView.setWidth(width);
rootView.requestLayout();
}
}
|
java
|
private void adaptWidth() {
adapter.setWidth(width);
if (rootView != null) {
rootView.setWidth(width);
rootView.requestLayout();
}
}
|
[
"private",
"void",
"adaptWidth",
"(",
")",
"{",
"adapter",
".",
"setWidth",
"(",
"width",
")",
";",
"if",
"(",
"rootView",
"!=",
"null",
")",
"{",
"rootView",
".",
"setWidth",
"(",
"width",
")",
";",
"rootView",
".",
"requestLayout",
"(",
")",
";",
"}",
"}"
] |
Adapts the width of the bottom sheet.
|
[
"Adapts",
"the",
"width",
"of",
"the",
"bottom",
"sheet",
"."
] |
6e4690ee9f63b14a7b143d3a3717b5f8a11ca503
|
https://github.com/michael-rapp/AndroidBottomSheet/blob/6e4690ee9f63b14a7b143d3a3717b5f8a11ca503/library/src/main/java/de/mrapp/android/bottomsheet/BottomSheet.java#L1390-L1397
|
144,679
|
michael-rapp/AndroidBottomSheet
|
library/src/main/java/de/mrapp/android/bottomsheet/BottomSheet.java
|
BottomSheet.createOnShowListener
|
@TargetApi(VERSION_CODES.FROYO)
private OnShowListener createOnShowListener() {
return new OnShowListener() {
@Override
public void onShow(final DialogInterface dialog) {
if (onShowListener != null) {
onShowListener.onShow(dialog);
}
if (maximize) {
maximize = false;
rootView.maximize(new DecelerateInterpolator());
}
}
};
}
|
java
|
@TargetApi(VERSION_CODES.FROYO)
private OnShowListener createOnShowListener() {
return new OnShowListener() {
@Override
public void onShow(final DialogInterface dialog) {
if (onShowListener != null) {
onShowListener.onShow(dialog);
}
if (maximize) {
maximize = false;
rootView.maximize(new DecelerateInterpolator());
}
}
};
}
|
[
"@",
"TargetApi",
"(",
"VERSION_CODES",
".",
"FROYO",
")",
"private",
"OnShowListener",
"createOnShowListener",
"(",
")",
"{",
"return",
"new",
"OnShowListener",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"onShow",
"(",
"final",
"DialogInterface",
"dialog",
")",
"{",
"if",
"(",
"onShowListener",
"!=",
"null",
")",
"{",
"onShowListener",
".",
"onShow",
"(",
"dialog",
")",
";",
"}",
"if",
"(",
"maximize",
")",
"{",
"maximize",
"=",
"false",
";",
"rootView",
".",
"maximize",
"(",
"new",
"DecelerateInterpolator",
"(",
")",
")",
";",
"}",
"}",
"}",
";",
"}"
] |
Creates and returns a listener, which allows to immediately maximize the bottom sheet after
it has been shown.
@return The listener, which has been created, as an instance of the type {@link
OnShowListener}
|
[
"Creates",
"and",
"returns",
"a",
"listener",
"which",
"allows",
"to",
"immediately",
"maximize",
"the",
"bottom",
"sheet",
"after",
"it",
"has",
"been",
"shown",
"."
] |
6e4690ee9f63b14a7b143d3a3717b5f8a11ca503
|
https://github.com/michael-rapp/AndroidBottomSheet/blob/6e4690ee9f63b14a7b143d3a3717b5f8a11ca503/library/src/main/java/de/mrapp/android/bottomsheet/BottomSheet.java#L1415-L1432
|
144,680
|
michael-rapp/AndroidBottomSheet
|
library/src/main/java/de/mrapp/android/bottomsheet/BottomSheet.java
|
BottomSheet.createCancelOnTouchListener
|
private View.OnTouchListener createCancelOnTouchListener() {
return new View.OnTouchListener() {
@Override
public boolean onTouch(final View v, final MotionEvent event) {
if (cancelable && canceledOnTouchOutside) {
cancel();
v.performClick();
return true;
}
return false;
}
};
}
|
java
|
private View.OnTouchListener createCancelOnTouchListener() {
return new View.OnTouchListener() {
@Override
public boolean onTouch(final View v, final MotionEvent event) {
if (cancelable && canceledOnTouchOutside) {
cancel();
v.performClick();
return true;
}
return false;
}
};
}
|
[
"private",
"View",
".",
"OnTouchListener",
"createCancelOnTouchListener",
"(",
")",
"{",
"return",
"new",
"View",
".",
"OnTouchListener",
"(",
")",
"{",
"@",
"Override",
"public",
"boolean",
"onTouch",
"(",
"final",
"View",
"v",
",",
"final",
"MotionEvent",
"event",
")",
"{",
"if",
"(",
"cancelable",
"&&",
"canceledOnTouchOutside",
")",
"{",
"cancel",
"(",
")",
";",
"v",
".",
"performClick",
"(",
")",
";",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}",
"}",
";",
"}"
] |
Creates and returns a listener, which allows to cancel the bottom sheet, when the decor view
is touched.
@return The listener, which has been created, as an instance of the type {@link
View.OnTouchListener}
|
[
"Creates",
"and",
"returns",
"a",
"listener",
"which",
"allows",
"to",
"cancel",
"the",
"bottom",
"sheet",
"when",
"the",
"decor",
"view",
"is",
"touched",
"."
] |
6e4690ee9f63b14a7b143d3a3717b5f8a11ca503
|
https://github.com/michael-rapp/AndroidBottomSheet/blob/6e4690ee9f63b14a7b143d3a3717b5f8a11ca503/library/src/main/java/de/mrapp/android/bottomsheet/BottomSheet.java#L1441-L1456
|
144,681
|
michael-rapp/AndroidBottomSheet
|
library/src/main/java/de/mrapp/android/bottomsheet/BottomSheet.java
|
BottomSheet.createItemClickListener
|
private OnItemClickListener createItemClickListener() {
return new OnItemClickListener() {
@Override
public void onItemClick(final AdapterView<?> parent, final View view,
final int position, final long id) {
if (itemClickListener != null && !rootView.isDragging() &&
!rootView.isAnimationRunning()) {
int index = position;
if (adapter.containsDividers()) {
for (int i = position; i >= 0; i--) {
if (adapter.getItem(i) == null ||
(adapter.getItem(i) instanceof Divider &&
i % adapter.getColumnCount() > 0)) {
index--;
}
}
}
itemClickListener.onItemClick(parent, view, index, getId(position));
}
dismiss();
}
};
}
|
java
|
private OnItemClickListener createItemClickListener() {
return new OnItemClickListener() {
@Override
public void onItemClick(final AdapterView<?> parent, final View view,
final int position, final long id) {
if (itemClickListener != null && !rootView.isDragging() &&
!rootView.isAnimationRunning()) {
int index = position;
if (adapter.containsDividers()) {
for (int i = position; i >= 0; i--) {
if (adapter.getItem(i) == null ||
(adapter.getItem(i) instanceof Divider &&
i % adapter.getColumnCount() > 0)) {
index--;
}
}
}
itemClickListener.onItemClick(parent, view, index, getId(position));
}
dismiss();
}
};
}
|
[
"private",
"OnItemClickListener",
"createItemClickListener",
"(",
")",
"{",
"return",
"new",
"OnItemClickListener",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"onItemClick",
"(",
"final",
"AdapterView",
"<",
"?",
">",
"parent",
",",
"final",
"View",
"view",
",",
"final",
"int",
"position",
",",
"final",
"long",
"id",
")",
"{",
"if",
"(",
"itemClickListener",
"!=",
"null",
"&&",
"!",
"rootView",
".",
"isDragging",
"(",
")",
"&&",
"!",
"rootView",
".",
"isAnimationRunning",
"(",
")",
")",
"{",
"int",
"index",
"=",
"position",
";",
"if",
"(",
"adapter",
".",
"containsDividers",
"(",
")",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"position",
";",
"i",
">=",
"0",
";",
"i",
"--",
")",
"{",
"if",
"(",
"adapter",
".",
"getItem",
"(",
"i",
")",
"==",
"null",
"||",
"(",
"adapter",
".",
"getItem",
"(",
"i",
")",
"instanceof",
"Divider",
"&&",
"i",
"%",
"adapter",
".",
"getColumnCount",
"(",
")",
">",
"0",
")",
")",
"{",
"index",
"--",
";",
"}",
"}",
"}",
"itemClickListener",
".",
"onItemClick",
"(",
"parent",
",",
"view",
",",
"index",
",",
"getId",
"(",
"position",
")",
")",
";",
"}",
"dismiss",
"(",
")",
";",
"}",
"}",
";",
"}"
] |
Creates and returns a listener, which allows to observe when the items of a bottom sheet have
been clicked.
@return The listener, which has been created, as an instance of the type {@link
OnItemClickListener}
|
[
"Creates",
"and",
"returns",
"a",
"listener",
"which",
"allows",
"to",
"observe",
"when",
"the",
"items",
"of",
"a",
"bottom",
"sheet",
"have",
"been",
"clicked",
"."
] |
6e4690ee9f63b14a7b143d3a3717b5f8a11ca503
|
https://github.com/michael-rapp/AndroidBottomSheet/blob/6e4690ee9f63b14a7b143d3a3717b5f8a11ca503/library/src/main/java/de/mrapp/android/bottomsheet/BottomSheet.java#L1478-L1505
|
144,682
|
michael-rapp/AndroidBottomSheet
|
library/src/main/java/de/mrapp/android/bottomsheet/BottomSheet.java
|
BottomSheet.createItemLongClickListener
|
private OnItemLongClickListener createItemLongClickListener() {
return new OnItemLongClickListener() {
@Override
public boolean onItemLongClick(final AdapterView<?> parent, final View view,
final int position, final long id) {
if (!rootView.isDragging() && !rootView.isAnimationRunning() &&
itemLongClickListener != null) {
int index = position;
if (adapter.containsDividers()) {
for (int i = position; i >= 0; i--) {
if (adapter.getItem(i) == null ||
(adapter.getItem(i) instanceof Divider &&
i % adapter.getColumnCount() > 0)) {
index--;
}
}
}
return itemLongClickListener
.onItemLongClick(parent, view, index, getId(position));
}
return false;
}
};
}
|
java
|
private OnItemLongClickListener createItemLongClickListener() {
return new OnItemLongClickListener() {
@Override
public boolean onItemLongClick(final AdapterView<?> parent, final View view,
final int position, final long id) {
if (!rootView.isDragging() && !rootView.isAnimationRunning() &&
itemLongClickListener != null) {
int index = position;
if (adapter.containsDividers()) {
for (int i = position; i >= 0; i--) {
if (adapter.getItem(i) == null ||
(adapter.getItem(i) instanceof Divider &&
i % adapter.getColumnCount() > 0)) {
index--;
}
}
}
return itemLongClickListener
.onItemLongClick(parent, view, index, getId(position));
}
return false;
}
};
}
|
[
"private",
"OnItemLongClickListener",
"createItemLongClickListener",
"(",
")",
"{",
"return",
"new",
"OnItemLongClickListener",
"(",
")",
"{",
"@",
"Override",
"public",
"boolean",
"onItemLongClick",
"(",
"final",
"AdapterView",
"<",
"?",
">",
"parent",
",",
"final",
"View",
"view",
",",
"final",
"int",
"position",
",",
"final",
"long",
"id",
")",
"{",
"if",
"(",
"!",
"rootView",
".",
"isDragging",
"(",
")",
"&&",
"!",
"rootView",
".",
"isAnimationRunning",
"(",
")",
"&&",
"itemLongClickListener",
"!=",
"null",
")",
"{",
"int",
"index",
"=",
"position",
";",
"if",
"(",
"adapter",
".",
"containsDividers",
"(",
")",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"position",
";",
"i",
">=",
"0",
";",
"i",
"--",
")",
"{",
"if",
"(",
"adapter",
".",
"getItem",
"(",
"i",
")",
"==",
"null",
"||",
"(",
"adapter",
".",
"getItem",
"(",
"i",
")",
"instanceof",
"Divider",
"&&",
"i",
"%",
"adapter",
".",
"getColumnCount",
"(",
")",
">",
"0",
")",
")",
"{",
"index",
"--",
";",
"}",
"}",
"}",
"return",
"itemLongClickListener",
".",
"onItemLongClick",
"(",
"parent",
",",
"view",
",",
"index",
",",
"getId",
"(",
"position",
")",
")",
";",
"}",
"return",
"false",
";",
"}",
"}",
";",
"}"
] |
Creates and returns a listener, which allows to observe when the items of a bottom sheet have
been long-clicked.
@return The listener, which has been created, as an instance of the type {qlink
OnItemLongClickListener}
|
[
"Creates",
"and",
"returns",
"a",
"listener",
"which",
"allows",
"to",
"observe",
"when",
"the",
"items",
"of",
"a",
"bottom",
"sheet",
"have",
"been",
"long",
"-",
"clicked",
"."
] |
6e4690ee9f63b14a7b143d3a3717b5f8a11ca503
|
https://github.com/michael-rapp/AndroidBottomSheet/blob/6e4690ee9f63b14a7b143d3a3717b5f8a11ca503/library/src/main/java/de/mrapp/android/bottomsheet/BottomSheet.java#L1514-L1543
|
144,683
|
michael-rapp/AndroidBottomSheet
|
library/src/main/java/de/mrapp/android/bottomsheet/BottomSheet.java
|
BottomSheet.createIntentClickListener
|
private OnItemClickListener createIntentClickListener(@NonNull final Activity activity,
@NonNull final Intent intent,
@NonNull final List<ResolveInfo> resolveInfos) {
return new OnItemClickListener() {
@Override
public void onItemClick(final AdapterView<?> parent, final View view,
final int position, final long id) {
ActivityInfo activityInfo = resolveInfos.get(position).activityInfo;
ComponentName componentName =
new ComponentName(activityInfo.applicationInfo.packageName,
activityInfo.name);
intent.setFlags(
Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
intent.setComponent(componentName);
activity.startActivity(intent);
dismiss();
}
};
}
|
java
|
private OnItemClickListener createIntentClickListener(@NonNull final Activity activity,
@NonNull final Intent intent,
@NonNull final List<ResolveInfo> resolveInfos) {
return new OnItemClickListener() {
@Override
public void onItemClick(final AdapterView<?> parent, final View view,
final int position, final long id) {
ActivityInfo activityInfo = resolveInfos.get(position).activityInfo;
ComponentName componentName =
new ComponentName(activityInfo.applicationInfo.packageName,
activityInfo.name);
intent.setFlags(
Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
intent.setComponent(componentName);
activity.startActivity(intent);
dismiss();
}
};
}
|
[
"private",
"OnItemClickListener",
"createIntentClickListener",
"(",
"@",
"NonNull",
"final",
"Activity",
"activity",
",",
"@",
"NonNull",
"final",
"Intent",
"intent",
",",
"@",
"NonNull",
"final",
"List",
"<",
"ResolveInfo",
">",
"resolveInfos",
")",
"{",
"return",
"new",
"OnItemClickListener",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"onItemClick",
"(",
"final",
"AdapterView",
"<",
"?",
">",
"parent",
",",
"final",
"View",
"view",
",",
"final",
"int",
"position",
",",
"final",
"long",
"id",
")",
"{",
"ActivityInfo",
"activityInfo",
"=",
"resolveInfos",
".",
"get",
"(",
"position",
")",
".",
"activityInfo",
";",
"ComponentName",
"componentName",
"=",
"new",
"ComponentName",
"(",
"activityInfo",
".",
"applicationInfo",
".",
"packageName",
",",
"activityInfo",
".",
"name",
")",
";",
"intent",
".",
"setFlags",
"(",
"Intent",
".",
"FLAG_ACTIVITY_NEW_TASK",
"|",
"Intent",
".",
"FLAG_ACTIVITY_RESET_TASK_IF_NEEDED",
")",
";",
"intent",
".",
"setComponent",
"(",
"componentName",
")",
";",
"activity",
".",
"startActivity",
"(",
"intent",
")",
";",
"dismiss",
"(",
")",
";",
"}",
"}",
";",
"}"
] |
Creates and returns a listener, which allows to start an app, when an item of the bottom
sheet has been clicked.
@param activity
The activity, the bottom sheet belongs to, as an instance of the class {@link
Activity}. The activity may not be null
@param intent
The intent, which should be passed to the started app, as an instance of the class
{@link Intent}. The intent may not be null
@param resolveInfos
A list, which contains the resolve infos, which correspond to the apps, which are
able to handle the intent, as an instance of the type {@link List} or an empty list,
if no apps are able to handle the intent
@return The listener, which has been created, as an instance of the type {@link
OnItemClickListener}
|
[
"Creates",
"and",
"returns",
"a",
"listener",
"which",
"allows",
"to",
"start",
"an",
"app",
"when",
"an",
"item",
"of",
"the",
"bottom",
"sheet",
"has",
"been",
"clicked",
"."
] |
6e4690ee9f63b14a7b143d3a3717b5f8a11ca503
|
https://github.com/michael-rapp/AndroidBottomSheet/blob/6e4690ee9f63b14a7b143d3a3717b5f8a11ca503/library/src/main/java/de/mrapp/android/bottomsheet/BottomSheet.java#L1562-L1582
|
144,684
|
michael-rapp/AndroidBottomSheet
|
library/src/main/java/de/mrapp/android/bottomsheet/BottomSheet.java
|
BottomSheet.getGridView
|
public final GridView getGridView() {
return (gridView != null && gridView.getVisibility() == View.VISIBLE) ? gridView : null;
}
|
java
|
public final GridView getGridView() {
return (gridView != null && gridView.getVisibility() == View.VISIBLE) ? gridView : null;
}
|
[
"public",
"final",
"GridView",
"getGridView",
"(",
")",
"{",
"return",
"(",
"gridView",
"!=",
"null",
"&&",
"gridView",
".",
"getVisibility",
"(",
")",
"==",
"View",
".",
"VISIBLE",
")",
"?",
"gridView",
":",
"null",
";",
"}"
] |
Returns the grid view, which is contained by the bottom sheet.
@return The grid view, which is contained by the bottom sheet, as an instance of the class
{@link GridView} or null, if the bottom sheet does not show any items or has not been shown
yet
|
[
"Returns",
"the",
"grid",
"view",
"which",
"is",
"contained",
"by",
"the",
"bottom",
"sheet",
"."
] |
6e4690ee9f63b14a7b143d3a3717b5f8a11ca503
|
https://github.com/michael-rapp/AndroidBottomSheet/blob/6e4690ee9f63b14a7b143d3a3717b5f8a11ca503/library/src/main/java/de/mrapp/android/bottomsheet/BottomSheet.java#L1652-L1654
|
144,685
|
michael-rapp/AndroidBottomSheet
|
library/src/main/java/de/mrapp/android/bottomsheet/BottomSheet.java
|
BottomSheet.setIcon
|
public final void setIcon(@DrawableRes final int resourceId) {
this.icon = ContextCompat.getDrawable(getContext(), resourceId);
this.iconBitmap = null;
this.iconId = resourceId;
this.iconAttributeId = -1;
adaptIcon();
}
|
java
|
public final void setIcon(@DrawableRes final int resourceId) {
this.icon = ContextCompat.getDrawable(getContext(), resourceId);
this.iconBitmap = null;
this.iconId = resourceId;
this.iconAttributeId = -1;
adaptIcon();
}
|
[
"public",
"final",
"void",
"setIcon",
"(",
"@",
"DrawableRes",
"final",
"int",
"resourceId",
")",
"{",
"this",
".",
"icon",
"=",
"ContextCompat",
".",
"getDrawable",
"(",
"getContext",
"(",
")",
",",
"resourceId",
")",
";",
"this",
".",
"iconBitmap",
"=",
"null",
";",
"this",
".",
"iconId",
"=",
"resourceId",
";",
"this",
".",
"iconAttributeId",
"=",
"-",
"1",
";",
"adaptIcon",
"(",
")",
";",
"}"
] |
Sets the icon of the bottom sheet.
@param resourceId
The resource id of the icon, which should be set, as an {@link Integer} value. The
resource id must correspond to a valid drawable resource
|
[
"Sets",
"the",
"icon",
"of",
"the",
"bottom",
"sheet",
"."
] |
6e4690ee9f63b14a7b143d3a3717b5f8a11ca503
|
https://github.com/michael-rapp/AndroidBottomSheet/blob/6e4690ee9f63b14a7b143d3a3717b5f8a11ca503/library/src/main/java/de/mrapp/android/bottomsheet/BottomSheet.java#L1698-L1704
|
144,686
|
michael-rapp/AndroidBottomSheet
|
library/src/main/java/de/mrapp/android/bottomsheet/BottomSheet.java
|
BottomSheet.setIconAttribute
|
public final void setIconAttribute(@AttrRes final int attributeId) {
TypedArray typedArray =
getContext().getTheme().obtainStyledAttributes(new int[]{attributeId});
this.icon = typedArray.getDrawable(0);
this.iconBitmap = null;
this.iconId = -1;
this.iconAttributeId = attributeId;
adaptIcon();
}
|
java
|
public final void setIconAttribute(@AttrRes final int attributeId) {
TypedArray typedArray =
getContext().getTheme().obtainStyledAttributes(new int[]{attributeId});
this.icon = typedArray.getDrawable(0);
this.iconBitmap = null;
this.iconId = -1;
this.iconAttributeId = attributeId;
adaptIcon();
}
|
[
"public",
"final",
"void",
"setIconAttribute",
"(",
"@",
"AttrRes",
"final",
"int",
"attributeId",
")",
"{",
"TypedArray",
"typedArray",
"=",
"getContext",
"(",
")",
".",
"getTheme",
"(",
")",
".",
"obtainStyledAttributes",
"(",
"new",
"int",
"[",
"]",
"{",
"attributeId",
"}",
")",
";",
"this",
".",
"icon",
"=",
"typedArray",
".",
"getDrawable",
"(",
"0",
")",
";",
"this",
".",
"iconBitmap",
"=",
"null",
";",
"this",
".",
"iconId",
"=",
"-",
"1",
";",
"this",
".",
"iconAttributeId",
"=",
"attributeId",
";",
"adaptIcon",
"(",
")",
";",
"}"
] |
Set the icon of the bottom sheet.
@param attributeId
The id of the theme attribute, which supplies the icon, which should be set, as an
{@link Integer} value. The id must point to a valid drawable resource
|
[
"Set",
"the",
"icon",
"of",
"the",
"bottom",
"sheet",
"."
] |
6e4690ee9f63b14a7b143d3a3717b5f8a11ca503
|
https://github.com/michael-rapp/AndroidBottomSheet/blob/6e4690ee9f63b14a7b143d3a3717b5f8a11ca503/library/src/main/java/de/mrapp/android/bottomsheet/BottomSheet.java#L1713-L1721
|
144,687
|
michael-rapp/AndroidBottomSheet
|
library/src/main/java/de/mrapp/android/bottomsheet/BottomSheet.java
|
BottomSheet.setBackgroundColor
|
public final void setBackgroundColor(@ColorInt final int color) {
this.background = new ColorDrawable(color);
this.backgroundBitmap = null;
this.backgroundId = -1;
this.backgroundColor = color;
adaptBackground();
}
|
java
|
public final void setBackgroundColor(@ColorInt final int color) {
this.background = new ColorDrawable(color);
this.backgroundBitmap = null;
this.backgroundId = -1;
this.backgroundColor = color;
adaptBackground();
}
|
[
"public",
"final",
"void",
"setBackgroundColor",
"(",
"@",
"ColorInt",
"final",
"int",
"color",
")",
"{",
"this",
".",
"background",
"=",
"new",
"ColorDrawable",
"(",
"color",
")",
";",
"this",
".",
"backgroundBitmap",
"=",
"null",
";",
"this",
".",
"backgroundId",
"=",
"-",
"1",
";",
"this",
".",
"backgroundColor",
"=",
"color",
";",
"adaptBackground",
"(",
")",
";",
"}"
] |
Sets the background color of the bottom sheet.
@param color
The background color, which should be set, as an {@link Integer} value or -1, if no
custom background color should be set
|
[
"Sets",
"the",
"background",
"color",
"of",
"the",
"bottom",
"sheet",
"."
] |
6e4690ee9f63b14a7b143d3a3717b5f8a11ca503
|
https://github.com/michael-rapp/AndroidBottomSheet/blob/6e4690ee9f63b14a7b143d3a3717b5f8a11ca503/library/src/main/java/de/mrapp/android/bottomsheet/BottomSheet.java#L1835-L1841
|
144,688
|
michael-rapp/AndroidBottomSheet
|
library/src/main/java/de/mrapp/android/bottomsheet/BottomSheet.java
|
BottomSheet.setDragSensitivity
|
public final void setDragSensitivity(final float dragSensitivity) {
Condition.INSTANCE
.ensureAtLeast(dragSensitivity, 0, "The drag sensitivity must be at least 0");
Condition.INSTANCE
.ensureAtMaximum(dragSensitivity, 1, "The drag sensitivity must be at maximum 1");
this.dragSensitivity = dragSensitivity;
adaptDragSensitivity();
}
|
java
|
public final void setDragSensitivity(final float dragSensitivity) {
Condition.INSTANCE
.ensureAtLeast(dragSensitivity, 0, "The drag sensitivity must be at least 0");
Condition.INSTANCE
.ensureAtMaximum(dragSensitivity, 1, "The drag sensitivity must be at maximum 1");
this.dragSensitivity = dragSensitivity;
adaptDragSensitivity();
}
|
[
"public",
"final",
"void",
"setDragSensitivity",
"(",
"final",
"float",
"dragSensitivity",
")",
"{",
"Condition",
".",
"INSTANCE",
".",
"ensureAtLeast",
"(",
"dragSensitivity",
",",
"0",
",",
"\"The drag sensitivity must be at least 0\"",
")",
";",
"Condition",
".",
"INSTANCE",
".",
"ensureAtMaximum",
"(",
"dragSensitivity",
",",
"1",
",",
"\"The drag sensitivity must be at maximum 1\"",
")",
";",
"this",
".",
"dragSensitivity",
"=",
"dragSensitivity",
";",
"adaptDragSensitivity",
"(",
")",
";",
"}"
] |
Sets the sensitivity, which specifies the distance after which dragging has an effect on the
bottom sheet, in relation to an internal value range.
@param dragSensitivity
The drag sensitivity, which should be set, as a {@link Float} value. The drag
sensitivity must be at lest 0 and at maximum 1
|
[
"Sets",
"the",
"sensitivity",
"which",
"specifies",
"the",
"distance",
"after",
"which",
"dragging",
"has",
"an",
"effect",
"on",
"the",
"bottom",
"sheet",
"in",
"relation",
"to",
"an",
"internal",
"value",
"range",
"."
] |
6e4690ee9f63b14a7b143d3a3717b5f8a11ca503
|
https://github.com/michael-rapp/AndroidBottomSheet/blob/6e4690ee9f63b14a7b143d3a3717b5f8a11ca503/library/src/main/java/de/mrapp/android/bottomsheet/BottomSheet.java#L1915-L1922
|
144,689
|
michael-rapp/AndroidBottomSheet
|
library/src/main/java/de/mrapp/android/bottomsheet/BottomSheet.java
|
BottomSheet.setDimAmount
|
public final void setDimAmount(final float dimAmount) {
Condition.INSTANCE.ensureAtLeast(dimAmount, 0, "The dim amount must be at least 0");
Condition.INSTANCE.ensureAtMaximum(dimAmount, 1, "The dim amount must be at maximum 1");
this.dimAmount = dimAmount;
getWindow().getAttributes().dimAmount = dimAmount;
}
|
java
|
public final void setDimAmount(final float dimAmount) {
Condition.INSTANCE.ensureAtLeast(dimAmount, 0, "The dim amount must be at least 0");
Condition.INSTANCE.ensureAtMaximum(dimAmount, 1, "The dim amount must be at maximum 1");
this.dimAmount = dimAmount;
getWindow().getAttributes().dimAmount = dimAmount;
}
|
[
"public",
"final",
"void",
"setDimAmount",
"(",
"final",
"float",
"dimAmount",
")",
"{",
"Condition",
".",
"INSTANCE",
".",
"ensureAtLeast",
"(",
"dimAmount",
",",
"0",
",",
"\"The dim amount must be at least 0\"",
")",
";",
"Condition",
".",
"INSTANCE",
".",
"ensureAtMaximum",
"(",
"dimAmount",
",",
"1",
",",
"\"The dim amount must be at maximum 1\"",
")",
";",
"this",
".",
"dimAmount",
"=",
"dimAmount",
";",
"getWindow",
"(",
")",
".",
"getAttributes",
"(",
")",
".",
"dimAmount",
"=",
"dimAmount",
";",
"}"
] |
Sets the dim amount, which should be used to darken the area outside the bottom sheet.
@param dimAmount
The dim amount, which should be set, as a {@link Float} value. The dim amount must be
at least 0 (fully transparent) and at maximum 1 (fully opaque)
|
[
"Sets",
"the",
"dim",
"amount",
"which",
"should",
"be",
"used",
"to",
"darken",
"the",
"area",
"outside",
"the",
"bottom",
"sheet",
"."
] |
6e4690ee9f63b14a7b143d3a3717b5f8a11ca503
|
https://github.com/michael-rapp/AndroidBottomSheet/blob/6e4690ee9f63b14a7b143d3a3717b5f8a11ca503/library/src/main/java/de/mrapp/android/bottomsheet/BottomSheet.java#L1941-L1946
|
144,690
|
michael-rapp/AndroidBottomSheet
|
library/src/main/java/de/mrapp/android/bottomsheet/BottomSheet.java
|
BottomSheet.indexOf
|
public final int indexOf(final int id) {
Condition.INSTANCE.ensureAtLeast(id, 0, "The id must be at least 0");
for (int i = 0; i < getItemCount(); i++) {
AbstractItem item = adapter.getItem(i);
if (item.getId() == id) {
return i;
}
}
return -1;
}
|
java
|
public final int indexOf(final int id) {
Condition.INSTANCE.ensureAtLeast(id, 0, "The id must be at least 0");
for (int i = 0; i < getItemCount(); i++) {
AbstractItem item = adapter.getItem(i);
if (item.getId() == id) {
return i;
}
}
return -1;
}
|
[
"public",
"final",
"int",
"indexOf",
"(",
"final",
"int",
"id",
")",
"{",
"Condition",
".",
"INSTANCE",
".",
"ensureAtLeast",
"(",
"id",
",",
"0",
",",
"\"The id must be at least 0\"",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"getItemCount",
"(",
")",
";",
"i",
"++",
")",
"{",
"AbstractItem",
"item",
"=",
"adapter",
".",
"getItem",
"(",
"i",
")",
";",
"if",
"(",
"item",
".",
"getId",
"(",
")",
"==",
"id",
")",
"{",
"return",
"i",
";",
"}",
"}",
"return",
"-",
"1",
";",
"}"
] |
Returns the index of the item, which corresponds to a specific id.
@param id
The id of the item, whose index should be returned, as an {@link Integer} value. The
id must be at least 0
@return The index of the item, which corresponds to the given id, or -1, if no item, which
corresponds to the given id, is contained by the bottom sheet
|
[
"Returns",
"the",
"index",
"of",
"the",
"item",
"which",
"corresponds",
"to",
"a",
"specific",
"id",
"."
] |
6e4690ee9f63b14a7b143d3a3717b5f8a11ca503
|
https://github.com/michael-rapp/AndroidBottomSheet/blob/6e4690ee9f63b14a7b143d3a3717b5f8a11ca503/library/src/main/java/de/mrapp/android/bottomsheet/BottomSheet.java#L2255-L2267
|
144,691
|
michael-rapp/AndroidBottomSheet
|
library/src/main/java/de/mrapp/android/bottomsheet/BottomSheet.java
|
BottomSheet.setIntent
|
public final void setIntent(@NonNull final Activity activity, @NonNull final Intent intent) {
Condition.INSTANCE.ensureNotNull(activity, "The activity may not be null");
Condition.INSTANCE.ensureNotNull(intent, "The intent may not be null");
removeAllItems();
PackageManager packageManager = activity.getPackageManager();
List<ResolveInfo> resolveInfos = packageManager.queryIntentActivities(intent, 0);
for (int i = 0; i < resolveInfos.size(); i++) {
ResolveInfo resolveInfo = resolveInfos.get(i);
addItem(i, resolveInfo.loadLabel(packageManager), resolveInfo.loadIcon(packageManager));
}
setOnItemClickListener(
createIntentClickListener(activity, (Intent) intent.clone(), resolveInfos));
}
|
java
|
public final void setIntent(@NonNull final Activity activity, @NonNull final Intent intent) {
Condition.INSTANCE.ensureNotNull(activity, "The activity may not be null");
Condition.INSTANCE.ensureNotNull(intent, "The intent may not be null");
removeAllItems();
PackageManager packageManager = activity.getPackageManager();
List<ResolveInfo> resolveInfos = packageManager.queryIntentActivities(intent, 0);
for (int i = 0; i < resolveInfos.size(); i++) {
ResolveInfo resolveInfo = resolveInfos.get(i);
addItem(i, resolveInfo.loadLabel(packageManager), resolveInfo.loadIcon(packageManager));
}
setOnItemClickListener(
createIntentClickListener(activity, (Intent) intent.clone(), resolveInfos));
}
|
[
"public",
"final",
"void",
"setIntent",
"(",
"@",
"NonNull",
"final",
"Activity",
"activity",
",",
"@",
"NonNull",
"final",
"Intent",
"intent",
")",
"{",
"Condition",
".",
"INSTANCE",
".",
"ensureNotNull",
"(",
"activity",
",",
"\"The activity may not be null\"",
")",
";",
"Condition",
".",
"INSTANCE",
".",
"ensureNotNull",
"(",
"intent",
",",
"\"The intent may not be null\"",
")",
";",
"removeAllItems",
"(",
")",
";",
"PackageManager",
"packageManager",
"=",
"activity",
".",
"getPackageManager",
"(",
")",
";",
"List",
"<",
"ResolveInfo",
">",
"resolveInfos",
"=",
"packageManager",
".",
"queryIntentActivities",
"(",
"intent",
",",
"0",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"resolveInfos",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"ResolveInfo",
"resolveInfo",
"=",
"resolveInfos",
".",
"get",
"(",
"i",
")",
";",
"addItem",
"(",
"i",
",",
"resolveInfo",
".",
"loadLabel",
"(",
"packageManager",
")",
",",
"resolveInfo",
".",
"loadIcon",
"(",
"packageManager",
")",
")",
";",
"}",
"setOnItemClickListener",
"(",
"createIntentClickListener",
"(",
"activity",
",",
"(",
"Intent",
")",
"intent",
".",
"clone",
"(",
")",
",",
"resolveInfos",
")",
")",
";",
"}"
] |
Adds the apps, which are able to handle a specific intent, as items to the bottom sheet. This
causes all previously added items to be removed. When an item is clicked, the corresponding
app is started.
@param activity
The activity, the bottom sheet belongs to, as an instance of the class {@link
Activity}. The activity may not be null
@param intent
The intent as an instance of the class {@link Intent}. The intent may not be null
|
[
"Adds",
"the",
"apps",
"which",
"are",
"able",
"to",
"handle",
"a",
"specific",
"intent",
"as",
"items",
"to",
"the",
"bottom",
"sheet",
".",
"This",
"causes",
"all",
"previously",
"added",
"items",
"to",
"be",
"removed",
".",
"When",
"an",
"item",
"is",
"clicked",
"the",
"corresponding",
"app",
"is",
"started",
"."
] |
6e4690ee9f63b14a7b143d3a3717b5f8a11ca503
|
https://github.com/michael-rapp/AndroidBottomSheet/blob/6e4690ee9f63b14a7b143d3a3717b5f8a11ca503/library/src/main/java/de/mrapp/android/bottomsheet/BottomSheet.java#L2315-L2329
|
144,692
|
michael-rapp/AndroidBottomSheet
|
library/src/main/java/de/mrapp/android/bottomsheet/BottomSheet.java
|
BottomSheet.maximize
|
@TargetApi(VERSION_CODES.FROYO)
public final void maximize() {
if (!isMaximized()) {
if (!isShowing()) {
maximize = true;
show();
} else {
rootView.maximize(new AccelerateDecelerateInterpolator());
}
}
}
|
java
|
@TargetApi(VERSION_CODES.FROYO)
public final void maximize() {
if (!isMaximized()) {
if (!isShowing()) {
maximize = true;
show();
} else {
rootView.maximize(new AccelerateDecelerateInterpolator());
}
}
}
|
[
"@",
"TargetApi",
"(",
"VERSION_CODES",
".",
"FROYO",
")",
"public",
"final",
"void",
"maximize",
"(",
")",
"{",
"if",
"(",
"!",
"isMaximized",
"(",
")",
")",
"{",
"if",
"(",
"!",
"isShowing",
"(",
")",
")",
"{",
"maximize",
"=",
"true",
";",
"show",
"(",
")",
";",
"}",
"else",
"{",
"rootView",
".",
"maximize",
"(",
"new",
"AccelerateDecelerateInterpolator",
"(",
")",
")",
";",
"}",
"}",
"}"
] |
Maximizes the bottom sheet.
|
[
"Maximizes",
"the",
"bottom",
"sheet",
"."
] |
6e4690ee9f63b14a7b143d3a3717b5f8a11ca503
|
https://github.com/michael-rapp/AndroidBottomSheet/blob/6e4690ee9f63b14a7b143d3a3717b5f8a11ca503/library/src/main/java/de/mrapp/android/bottomsheet/BottomSheet.java#L2363-L2373
|
144,693
|
michael-rapp/AndroidBottomSheet
|
library/src/main/java/de/mrapp/android/bottomsheet/BottomSheet.java
|
BottomSheet.setStyle
|
public final void setStyle(@NonNull final Style style) {
Condition.INSTANCE.ensureNotNull(style, "The style may not be null");
adapter.setStyle(style);
adaptRootView();
adaptTitleView();
adaptContentView();
adaptGridViewHeight();
}
|
java
|
public final void setStyle(@NonNull final Style style) {
Condition.INSTANCE.ensureNotNull(style, "The style may not be null");
adapter.setStyle(style);
adaptRootView();
adaptTitleView();
adaptContentView();
adaptGridViewHeight();
}
|
[
"public",
"final",
"void",
"setStyle",
"(",
"@",
"NonNull",
"final",
"Style",
"style",
")",
"{",
"Condition",
".",
"INSTANCE",
".",
"ensureNotNull",
"(",
"style",
",",
"\"The style may not be null\"",
")",
";",
"adapter",
".",
"setStyle",
"(",
"style",
")",
";",
"adaptRootView",
"(",
")",
";",
"adaptTitleView",
"(",
")",
";",
"adaptContentView",
"(",
")",
";",
"adaptGridViewHeight",
"(",
")",
";",
"}"
] |
Sets the style, which should be used to display the bottom sheet's items.
@param style
The style, which should be set, as a value of the enum {@link Style}. The style may
either be <code>LIST</code>, <code>LIST_COLUMNS</code> or <code>GRID</code>
|
[
"Sets",
"the",
"style",
"which",
"should",
"be",
"used",
"to",
"display",
"the",
"bottom",
"sheet",
"s",
"items",
"."
] |
6e4690ee9f63b14a7b143d3a3717b5f8a11ca503
|
https://github.com/michael-rapp/AndroidBottomSheet/blob/6e4690ee9f63b14a7b143d3a3717b5f8a11ca503/library/src/main/java/de/mrapp/android/bottomsheet/BottomSheet.java#L2392-L2399
|
144,694
|
michael-rapp/AndroidBottomSheet
|
example/src/main/java/de/mrapp/android/bottomsheet/example/PreferenceFragment.java
|
PreferenceFragment.initializeBottomSheet
|
private void initializeBottomSheet() {
BottomSheet.Builder builder = createBottomSheetBuilder();
addItems(builder);
bottomSheet = builder.create();
}
|
java
|
private void initializeBottomSheet() {
BottomSheet.Builder builder = createBottomSheetBuilder();
addItems(builder);
bottomSheet = builder.create();
}
|
[
"private",
"void",
"initializeBottomSheet",
"(",
")",
"{",
"BottomSheet",
".",
"Builder",
"builder",
"=",
"createBottomSheetBuilder",
"(",
")",
";",
"addItems",
"(",
"builder",
")",
";",
"bottomSheet",
"=",
"builder",
".",
"create",
"(",
")",
";",
"}"
] |
Initializes the regular bottom sheet containing list items.
|
[
"Initializes",
"the",
"regular",
"bottom",
"sheet",
"containing",
"list",
"items",
"."
] |
6e4690ee9f63b14a7b143d3a3717b5f8a11ca503
|
https://github.com/michael-rapp/AndroidBottomSheet/blob/6e4690ee9f63b14a7b143d3a3717b5f8a11ca503/example/src/main/java/de/mrapp/android/bottomsheet/example/PreferenceFragment.java#L92-L96
|
144,695
|
michael-rapp/AndroidBottomSheet
|
example/src/main/java/de/mrapp/android/bottomsheet/example/PreferenceFragment.java
|
PreferenceFragment.initializeCustomBottomSheet
|
private void initializeCustomBottomSheet() {
BottomSheet.Builder builder = createBottomSheetBuilder();
builder.setView(R.layout.custom_view);
customBottomSheet = builder.create();
}
|
java
|
private void initializeCustomBottomSheet() {
BottomSheet.Builder builder = createBottomSheetBuilder();
builder.setView(R.layout.custom_view);
customBottomSheet = builder.create();
}
|
[
"private",
"void",
"initializeCustomBottomSheet",
"(",
")",
"{",
"BottomSheet",
".",
"Builder",
"builder",
"=",
"createBottomSheetBuilder",
"(",
")",
";",
"builder",
".",
"setView",
"(",
"R",
".",
"layout",
".",
"custom_view",
")",
";",
"customBottomSheet",
"=",
"builder",
".",
"create",
"(",
")",
";",
"}"
] |
Initializes the bottom sheet containing a custom view.
|
[
"Initializes",
"the",
"bottom",
"sheet",
"containing",
"a",
"custom",
"view",
"."
] |
6e4690ee9f63b14a7b143d3a3717b5f8a11ca503
|
https://github.com/michael-rapp/AndroidBottomSheet/blob/6e4690ee9f63b14a7b143d3a3717b5f8a11ca503/example/src/main/java/de/mrapp/android/bottomsheet/example/PreferenceFragment.java#L101-L105
|
144,696
|
michael-rapp/AndroidBottomSheet
|
example/src/main/java/de/mrapp/android/bottomsheet/example/PreferenceFragment.java
|
PreferenceFragment.initializeIntentBottomSheet
|
private void initializeIntentBottomSheet() {
BottomSheet.Builder builder = createBottomSheetBuilder();
Intent intent = new Intent();
intent.setAction(Intent.ACTION_SEND);
intent.putExtra(Intent.EXTRA_TEXT, "This is my text to send.");
intent.setType("text/plain");
builder.setIntent(getActivity(), intent);
intentBottomSheet = builder.create();
}
|
java
|
private void initializeIntentBottomSheet() {
BottomSheet.Builder builder = createBottomSheetBuilder();
Intent intent = new Intent();
intent.setAction(Intent.ACTION_SEND);
intent.putExtra(Intent.EXTRA_TEXT, "This is my text to send.");
intent.setType("text/plain");
builder.setIntent(getActivity(), intent);
intentBottomSheet = builder.create();
}
|
[
"private",
"void",
"initializeIntentBottomSheet",
"(",
")",
"{",
"BottomSheet",
".",
"Builder",
"builder",
"=",
"createBottomSheetBuilder",
"(",
")",
";",
"Intent",
"intent",
"=",
"new",
"Intent",
"(",
")",
";",
"intent",
".",
"setAction",
"(",
"Intent",
".",
"ACTION_SEND",
")",
";",
"intent",
".",
"putExtra",
"(",
"Intent",
".",
"EXTRA_TEXT",
",",
"\"This is my text to send.\"",
")",
";",
"intent",
".",
"setType",
"(",
"\"text/plain\"",
")",
";",
"builder",
".",
"setIntent",
"(",
"getActivity",
"(",
")",
",",
"intent",
")",
";",
"intentBottomSheet",
"=",
"builder",
".",
"create",
"(",
")",
";",
"}"
] |
Initializes the bottom sheet containing possible receivers for an intent.
|
[
"Initializes",
"the",
"bottom",
"sheet",
"containing",
"possible",
"receivers",
"for",
"an",
"intent",
"."
] |
6e4690ee9f63b14a7b143d3a3717b5f8a11ca503
|
https://github.com/michael-rapp/AndroidBottomSheet/blob/6e4690ee9f63b14a7b143d3a3717b5f8a11ca503/example/src/main/java/de/mrapp/android/bottomsheet/example/PreferenceFragment.java#L110-L118
|
144,697
|
michael-rapp/AndroidBottomSheet
|
example/src/main/java/de/mrapp/android/bottomsheet/example/PreferenceFragment.java
|
PreferenceFragment.initializeShowBottomSheetPreference
|
private void initializeShowBottomSheetPreference() {
Preference showBottomSheetPreference =
findPreference(getString(R.string.show_bottom_sheet_preference_key));
showBottomSheetPreference.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(final Preference preference) {
initializeBottomSheet();
bottomSheet.show();
return true;
}
});
}
|
java
|
private void initializeShowBottomSheetPreference() {
Preference showBottomSheetPreference =
findPreference(getString(R.string.show_bottom_sheet_preference_key));
showBottomSheetPreference.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(final Preference preference) {
initializeBottomSheet();
bottomSheet.show();
return true;
}
});
}
|
[
"private",
"void",
"initializeShowBottomSheetPreference",
"(",
")",
"{",
"Preference",
"showBottomSheetPreference",
"=",
"findPreference",
"(",
"getString",
"(",
"R",
".",
"string",
".",
"show_bottom_sheet_preference_key",
")",
")",
";",
"showBottomSheetPreference",
".",
"setOnPreferenceClickListener",
"(",
"new",
"OnPreferenceClickListener",
"(",
")",
"{",
"@",
"Override",
"public",
"boolean",
"onPreferenceClick",
"(",
"final",
"Preference",
"preference",
")",
"{",
"initializeBottomSheet",
"(",
")",
";",
"bottomSheet",
".",
"show",
"(",
")",
";",
"return",
"true",
";",
"}",
"}",
")",
";",
"}"
] |
Initializes the preference, which allows to show a bottom sheet.
|
[
"Initializes",
"the",
"preference",
"which",
"allows",
"to",
"show",
"a",
"bottom",
"sheet",
"."
] |
6e4690ee9f63b14a7b143d3a3717b5f8a11ca503
|
https://github.com/michael-rapp/AndroidBottomSheet/blob/6e4690ee9f63b14a7b143d3a3717b5f8a11ca503/example/src/main/java/de/mrapp/android/bottomsheet/example/PreferenceFragment.java#L150-L163
|
144,698
|
michael-rapp/AndroidBottomSheet
|
example/src/main/java/de/mrapp/android/bottomsheet/example/PreferenceFragment.java
|
PreferenceFragment.initializeShowCustomBottomSheetPreference
|
private void initializeShowCustomBottomSheetPreference() {
Preference showCustomBottomSheetPreference =
findPreference(getString(R.string.show_custom_bottom_sheet_preference_key));
showCustomBottomSheetPreference
.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(final Preference preference) {
initializeCustomBottomSheet();
customBottomSheet.show();
return true;
}
});
}
|
java
|
private void initializeShowCustomBottomSheetPreference() {
Preference showCustomBottomSheetPreference =
findPreference(getString(R.string.show_custom_bottom_sheet_preference_key));
showCustomBottomSheetPreference
.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(final Preference preference) {
initializeCustomBottomSheet();
customBottomSheet.show();
return true;
}
});
}
|
[
"private",
"void",
"initializeShowCustomBottomSheetPreference",
"(",
")",
"{",
"Preference",
"showCustomBottomSheetPreference",
"=",
"findPreference",
"(",
"getString",
"(",
"R",
".",
"string",
".",
"show_custom_bottom_sheet_preference_key",
")",
")",
";",
"showCustomBottomSheetPreference",
".",
"setOnPreferenceClickListener",
"(",
"new",
"OnPreferenceClickListener",
"(",
")",
"{",
"@",
"Override",
"public",
"boolean",
"onPreferenceClick",
"(",
"final",
"Preference",
"preference",
")",
"{",
"initializeCustomBottomSheet",
"(",
")",
";",
"customBottomSheet",
".",
"show",
"(",
")",
";",
"return",
"true",
";",
"}",
"}",
")",
";",
"}"
] |
Initializes the preference, which allows to show a bottom sheet with custom content.
|
[
"Initializes",
"the",
"preference",
"which",
"allows",
"to",
"show",
"a",
"bottom",
"sheet",
"with",
"custom",
"content",
"."
] |
6e4690ee9f63b14a7b143d3a3717b5f8a11ca503
|
https://github.com/michael-rapp/AndroidBottomSheet/blob/6e4690ee9f63b14a7b143d3a3717b5f8a11ca503/example/src/main/java/de/mrapp/android/bottomsheet/example/PreferenceFragment.java#L168-L182
|
144,699
|
michael-rapp/AndroidBottomSheet
|
example/src/main/java/de/mrapp/android/bottomsheet/example/PreferenceFragment.java
|
PreferenceFragment.initializeShowIntentBottmSheetPreference
|
private void initializeShowIntentBottmSheetPreference() {
Preference showIntentBottomSheetPreference =
findPreference(getString(R.string.show_intent_bottom_sheet_preference_key));
showIntentBottomSheetPreference
.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
initializeIntentBottomSheet();
intentBottomSheet.show();
return true;
}
});
}
|
java
|
private void initializeShowIntentBottmSheetPreference() {
Preference showIntentBottomSheetPreference =
findPreference(getString(R.string.show_intent_bottom_sheet_preference_key));
showIntentBottomSheetPreference
.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
initializeIntentBottomSheet();
intentBottomSheet.show();
return true;
}
});
}
|
[
"private",
"void",
"initializeShowIntentBottmSheetPreference",
"(",
")",
"{",
"Preference",
"showIntentBottomSheetPreference",
"=",
"findPreference",
"(",
"getString",
"(",
"R",
".",
"string",
".",
"show_intent_bottom_sheet_preference_key",
")",
")",
";",
"showIntentBottomSheetPreference",
".",
"setOnPreferenceClickListener",
"(",
"new",
"OnPreferenceClickListener",
"(",
")",
"{",
"@",
"Override",
"public",
"boolean",
"onPreferenceClick",
"(",
"Preference",
"preference",
")",
"{",
"initializeIntentBottomSheet",
"(",
")",
";",
"intentBottomSheet",
".",
"show",
"(",
")",
";",
"return",
"true",
";",
"}",
"}",
")",
";",
"}"
] |
Initializes the preference, which allows to display the applications, which are suited for
handling an intent.
|
[
"Initializes",
"the",
"preference",
"which",
"allows",
"to",
"display",
"the",
"applications",
"which",
"are",
"suited",
"for",
"handling",
"an",
"intent",
"."
] |
6e4690ee9f63b14a7b143d3a3717b5f8a11ca503
|
https://github.com/michael-rapp/AndroidBottomSheet/blob/6e4690ee9f63b14a7b143d3a3717b5f8a11ca503/example/src/main/java/de/mrapp/android/bottomsheet/example/PreferenceFragment.java#L188-L202
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.